Browse Source

Added Please ask your administrator. distinction in home page and other minimal bug fixes and frontend changes.

Victor Hernandez 4 years ago
parent
commit
2a9906e867
14 changed files with 623 additions and 274 deletions
  1. 6
    2
      footer.php
  2. 15
    8
      header.php
  3. 378
    38
      home.php
  4. 19
    5
      js/handleSubmit.js
  5. 2
    2
      js/home.js
  6. 15
    6
      js/main.js
  7. 14
    10
      js/viewExperience.js
  8. 39
    0
      processes/updateMoment.php
  9. 4
    4
      special2.php
  10. 14
    178
      testFrontEnd.php
  11. 1
    1
      users.php
  12. 106
    20
      viewExperience.php
  13. 9
    0
      viewMoment.php
  14. 1
    0
      viewQuestionnaire.php

+ 6
- 2
footer.php View File

3
     	    <p>Universidad de Puerto Rico</p>
3
     	    <p>Universidad de Puerto Rico</p>
4
     	    <p>Recinto de Río Piedras</p>
4
     	    <p>Recinto de Río Piedras</p>
5
     	</footer>
5
     	</footer>
6
-
7
-    	<script src="js/main.js" defer></script>
6
+    	
7
+    	<script>
8
+	    	// FOOTER COPYRIGHT YEAR
9
+			let date = new Date().getFullYear();
10
+			document.getElementById('copyrightDate').innerHTML = date;
11
+    	</script>
8
     	
12
     	
9
 	</body>
13
 	</body>
10
 </html>
14
 </html>

+ 15
- 8
header.php View File

13
     	<!-- JQUERY IMPORT-->
13
     	<!-- JQUERY IMPORT-->
14
     	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
14
     	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
15
     	
15
     	
16
-		<!-- BOOTSTRAP JS IMPORT -->
17
-    	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
18
-    	
19
     	<!-- FONTAWESOME IMPORT -->
16
     	<!-- FONTAWESOME IMPORT -->
20
     	<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.10.2/css/all.css">
17
     	<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.10.2/css/all.css">
21
     	
18
     	
33
     	<!-- CUSTOM STYLES -->
30
     	<!-- CUSTOM STYLES -->
34
     	<link rel="stylesheet" href="css/style.css">
31
     	<link rel="stylesheet" href="css/style.css">
35
     	
32
     	
33
+		<!-- CUSTOM GENERAL SCRIPT -->
34
+		<script src="js/main.js"></script>
35
+		
36
+		<!-- BOOTSTRAP JS IMPORT -->
37
+    	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
38
+    	
36
     	<style>
39
     	<style>
37
     	
40
     	
38
 textarea {
41
 textarea {
55
 
58
 
56
 .loader {
59
 .loader {
57
 	display: inline-block;
60
 	display: inline-block;
58
-	width: 12px;
59
-	height: 12px;
61
+	width: var(--size);
62
+	height: var(--size);
60
 	position: relative;
63
 	position: relative;
61
-	margin-right: calc(12px / 2);
64
+	margin-right: calc(var(--size) / 2);
65
+}
66
+
67
+.loader.loader-lg {
68
+	--size: 60px;
62
 }
69
 }
63
 
70
 
64
 .loader:before, .loader:after {
71
 .loader:before, .loader:after {
68
 	width: 100%;
75
 	width: 100%;
69
 	height: 100%;
76
 	height: 100%;
70
 	border-radius: 100%;
77
 	border-radius: 100%;
71
-	border: calc(12px / 5) solid transparent;
78
+	border: calc(var(--size) / 5) solid transparent;
72
 	border-top-color: #3498db;
79
 	border-top-color: #3498db;
73
 }
80
 }
74
 
81
 
78
 }
85
 }
79
 
86
 
80
 .loader:after {
87
 .loader:after {
81
-	border: calc(12px / 5) solid white;
88
+	border: calc(var(--size) / 5) solid white;
82
 }
89
 }
83
 
90
 
84
 @keyframes spin {
91
 @keyframes spin {

+ 378
- 38
home.php View File

20
 	}
20
 	}
21
 	
21
 	
22
 ?>
22
 ?>
23
+
24
+	<style>
25
+	.popover-content {
26
+		color: #333;
27
+	}
28
+	</style>
29
+	
30
+	
23
 	<!-- START OF home.php -->
31
 	<!-- START OF home.php -->
24
 	<body>
32
 	<body>
25
 
33
 
60
             	</div>
68
             	</div>
61
 
69
 
62
 <?php
70
 <?php
71
+
72
+	// DISPLAY ALL EXPERIENCES THAT ARE NOT PART OF A PROJECT FIRST
73
+	// THEN CREATE A NEW ROW FOR EACH PROJECT WHICH IS 'POPULATED' BY ITS EXPERIENCES
74
+
63
 	// CHANGE QUERY DEPENDING ON IF USER IS ADMIN OR NOT
75
 	// CHANGE QUERY DEPENDING ON IF USER IS ADMIN OR NOT
64
 	if($_SESSION['dbUserData']['admin'] === '1') {
76
 	if($_SESSION['dbUserData']['admin'] === '1') {
65
-		$query2 = "SELECT * FROM `experience`;";
77
+		$queryProjectlessExperiences = "SELECT E.id AS eid, E.start_date AS start_date, E.end_date AS end_date, E.title AS ename FROM `experience` AS E WHERE E.id NOT IN (SELECT P.id_experience FROM project_experience AS P);";
78
+		
79
+// 		$queryProjectsWithExperiences = "SELECT E.id AS eid, E.start_date AS start_date, E.end_date AS end_date, E.title AS ename, P.id AS pid, P.name AS pname
80
+// 					FROM experience AS E
81
+// 					JOIN project_experience AS PE
82
+// 					JOIN project AS P
83
+// 					WHERE E.id = PE.id_experience
84
+// 					AND P.id = PE.id_project
85
+// 					ORDER BY P.id, E.start_date";
86
+
87
+		$queryProjects = "SELECT * FROM project ORDER BY project.id DESC;";
88
+		$queryCountExperiences = "SELECT COUNT(*) FROM experience;";
89
+		
66
 	} else {
90
 	} else {
67
-		$query2 = "SELECT * FROM `experience` WHERE id IN (SELECT id_experience FROM researcher_experience WHERE id_researcher = '" . $_SESSION['dbUserData']['id_researcher'] . "');";
91
+		$queryProjectlessExperiences = "SELECT E.id AS eid, E.start_date AS start_date, E.end_date AS end_date, E.title AS ename FROM `experience` AS E WHERE E.id NOT IN (SELECT P.id_experience FROM project_experience AS P) AND E.id IN (SELECT id_experience FROM researcher_experience WHERE id_researcher = '" . $_SESSION['dbUserData']['id_researcher'] . "');";
92
+		
93
+// 		$queryProjectsWithExperiences = "SELECT E.id AS eid, E.start_date AS start_date, E.end_date AS end_date, E.title AS ename, P.id AS pid, P.name AS pname
94
+// 					FROM experience AS E
95
+// 					JOIN project_experience AS PE
96
+// 					JOIN project AS P
97
+// 					WHERE E.id = PE.id_experience
98
+// 					AND P.id = PE.id_project
99
+// 					AND E.id IN (SELECT id_experience FROM researcher_experience WHERE id_researcher = '" . $_SESSION['dbUserData']['id_researcher'] . "')
100
+// 					ORDER BY P.id, E.start_date";
101
+		
102
+		$queryCountExperiences = "SELECT COUNT(*) FROM experience AS E WHERE E.id IN (SELECT id_experience FROM researcher_experience WHERE id_researcher = '" . $_SESSION['dbUserData']['id_researcher'] . "');";
103
+		
104
+		$queryProjects = "SELECT * FROM project WHERE id IN (SELECT id_project FROM project_experience WHERE id_experience IN (SELECT id_experience FROM researcher_experience WHERE id_researcher = '" . $_SESSION['dbUserData']['id_researcher'] . "')) ORDER BY project.id DESC;";
68
 	}
105
 	}
69
-	$result2 = mysqli_query($connection, $query2);
70
 	
106
 	
71
-	// IF USER HAS EXPERIENCES, SHOW ALL OF THEM
72
-	// ELSE PROMPT USER TO CREATE A NEW EXPERIENCE
73
-	if($result2->num_rows > 0): // USER HAS EXPERIENCE (STANDARD PAGE)
107
+	$resultProjectlessExperiences = mysqli_query($connection, $queryProjectlessExperiences);	
108
+	while($row = mysqli_fetch_array($resultProjectlessExperiences)):
109
+	
74
 ?>
110
 ?>
75
 
111
 
76
-				<?php while($row = mysqli_fetch_array($result2)): ?>
77
-
78
-            	<div class="grid-box" onclick="location='viewExperience.php?view=<?php echo $row['id']; ?>'">
112
+            	<div class="grid-box" onclick="location='viewExperience.php?view=<?php echo $row['eid']; ?>'">
79
             	
113
             	
80
-            		<?php if(mb_strlen($row['title']) == 0): ?>
81
-                	<span class="box-title" onclick="location='viewExperience.php?view=<?php echo $row['id']; ?>'"><small>N/A</small></span>
82
-            		<?php elseif(mb_strlen($row['title']) < 21): ?>
83
-                	<span class="box-title" onclick="location='viewExperience.php?view=<?php echo $row['id']; ?>'"><?php echo $row['title']; ?></span>
114
+            		<?php if(mb_strlen($row['ename']) == 0): ?>
115
+                	<span class="box-title" onclick="location='viewExperience.php?view=<?php echo $row['eid']; ?>'"><small>N/A</small></span>
116
+            		<?php elseif(mb_strlen($row['ename']) < 21): ?>
117
+                	<span class="box-title" onclick="location='viewExperience.php?view=<?php echo $row['eid']; ?>'"><?php echo $row['ename']; ?></span>
84
                 	<?php else: ?>
118
                 	<?php else: ?>
85
-<!--style="white-space: nowrap;"--><span class="box-title" onclick="location='viewExperience.php?view=<?php echo $row['id']; ?>'"><?php echo substr($row['title'], 0, 30)."<small>...</small>"; ?></span>
119
+<!--style="white-space: nowrap;"--><span class="box-title" onclick="location='viewExperience.php?view=<?php echo $row['eid']; ?>'"><?php echo substr($row['ename'], 0, 30)."<small>...</small>"; ?></span>
86
                 	<?php endif; ?>
120
                 	<?php endif; ?>
87
                 	
121
                 	
88
-                	<div class="box-dates" onclick="location='viewExperience.php?view=<?php echo $row['id']; ?>'">
122
+                	<div class="box-dates" onclick="location='viewExperience.php?view=<?php echo $row['eid']; ?>'">
89
                 	    <p style="margin-bottom: 0;">• Starts: <?php echo date("M j, Y", strtotime($row['start_date'])); ?></p>
123
                 	    <p style="margin-bottom: 0;">• Starts: <?php echo date("M j, Y", strtotime($row['start_date'])); ?></p>
90
                 	    <p>• Ends: <?php echo date("M j, Y", strtotime($row['end_date'])); ?></p>
124
                 	    <p>• Ends: <?php echo date("M j, Y", strtotime($row['end_date'])); ?></p>
91
                 	</div>
125
                 	</div>
95
                 		if($x <= 0):
129
                 		if($x <= 0):
96
                 	?>
130
                 	?>
97
                 	<span class="box-weeks warning">Finished</span>
131
                 	<span class="box-weeks warning">Finished</span>
132
+                 	<?php elseif(0 < $x && $x < 1):?>
133
+                	<span class="box-weeks" style="font-size: 1.2rem">Less than a week remaining</span>
98
                 	<?php else: ?>
134
                 	<?php else: ?>
99
-                	<span class="box-weeks"><?php echo round($x); ?> week<?php if(round($x) > 1) echo 's'; ?> remaining</span>
135
+                	<span class="box-weeks"><?php echo round($x); ?> week<?php if($x > 0) echo 's'; ?> remaining</span>
100
                 	<?php endif; ?>
136
                 	<?php endif; ?>
101
                 	<span class="box-edit" style="background: none;">
137
                 	<span class="box-edit" style="background: none;">
102
-                	    <a>
103
-                	        <i class="fas fa-pen"></i>
104
-                	    </a>
138
+                	    <a><i class="fas fa-pen"></i></a>
105
                 	</span>
139
                 	</span>
106
 
140
 
107
-            	</div>
141
+            	</div><!--grid-box-->
108
 	
142
 	
109
-            	<?php endwhile; ?>
143
+<?php endwhile; ?>
110
 
144
 
111
-<?php else: // USER DOESN'T HAVE EXPERIENCES YET (ALTERNATE PAGE) ?>
145
+			</div><!--experience-content-->
112
 
146
 
113
-				<script> setTimeout(() => $('#FirstTime').modal('show'), 1000); </script>
114
-		
115
-<?php endif; ?>
147
+<?php
148
+	
149
+            	
150
+	$resultProjects = mysqli_query($connection, $queryProjects);
151
+	while($rowP = mysqli_fetch_array($resultProjects)):
152
+	
153
+?>
116
 
154
 
155
+			<div class="row">
156
+<!-- 				<div > -->
157
+				<h3 class="col-sm-12" style="color: white;">
158
+					<?php echo $rowP['name']; ?>
159
+					<button type="button" class="btn btn-link btn-lg" data-toggle="popover" title="Project Description" data-content="<?php echo $rowP['description']; ?>" data-placement="right">
160
+						<span style="color: #eee;" class="glyphicon glyphicon-align-left" aria-hidden="true"></span>
161
+					</button>
162
+				</h3>
163
+<!-- 				</div> -->
117
 			</div>
164
 			</div>
165
+				
166
+				
167
+        	<div id="experience-content">
168
+				
169
+<?php
170
+
171
+		$queryExperiencesInProject = "SELECT E.id AS eid, E.title AS ename, E.start_date, E.end_date
172
+										FROM experience AS E
173
+										WHERE E.id IN (SELECT id_experience FROM project_experience WHERE id_project = '" . $rowP['id'] . "')
174
+										ORDER BY E.start_date DESC";
175
+		$resultExperiencesInProject = mysqli_query($connection, $queryExperiencesInProject);
176
+		while($row = mysqli_fetch_array($resultExperiencesInProject)):
177
+
178
+?>
179
+				
180
+            	<div class="grid-box" onclick="location='viewExperience.php?view=<?php echo $row['eid']; ?>'">
181
+            	
182
+            		<?php if(mb_strlen($row['ename']) == 0): ?>
183
+                	<span class="box-title" onclick="location='viewExperience.php?view=<?php echo $row['eid']; ?>'"><small>N/A</small></span>
184
+            		<?php elseif(mb_strlen($row['ename']) < 21): ?>
185
+                	<span class="box-title" onclick="location='viewExperience.php?view=<?php echo $row['eid']; ?>'"><?php echo $row['ename']; ?></span>
186
+                	<?php else: ?>
187
+<!--style="white-space: nowrap;"--><span class="box-title" onclick="location='viewExperience.php?view=<?php echo $row['eid']; ?>'"><?php echo substr($row['ename'], 0, 30)."<small>...</small>"; ?></span>
188
+                	<?php endif; ?>
189
+                	
190
+                	<div class="box-dates" onclick="location='viewExperience.php?view=<?php echo $row['eid']; ?>'">
191
+                	    <p style="margin-bottom: 0;">• Starts: <?php echo date("M j, Y", strtotime($row['start_date'])); ?></p>
192
+                	    <p>• Ends: <?php echo date("M j, Y", strtotime($row['end_date'])); ?></p>
193
+                	</div>
194
+                	
195
+                	<?php 
196
+                		$x = (strtotime($row['end_date']) - strtotime('now')) / 604800;
197
+                		if($x <= 0):
198
+                	?>
199
+                	<span class="box-weeks warning">Finished</span>
200
+                 	<?php elseif(0 < $x && $x < 1):?>
201
+                	<span class="box-weeks" style="font-size: 1.2rem">Less than a week remaining</span>
202
+                	<?php else: ?>
203
+                	<span class="box-weeks"><?php echo round($x); ?> week<?php if($x > 0) echo 's'; ?> remaining</span>
204
+                	<?php endif; ?>
205
+                	<span class="box-edit" style="background: none;">
206
+                	    <a><i class="fas fa-pen"></i></a>
207
+                	</span>
208
+
209
+            	</div>
210
+
211
+
212
+<?php endwhile; ?>
213
+
214
+			</div><!--experience-content-->
215
+		
216
+<?php endwhile; ?>
118
 			
217
 			
119
-			<br><br>
120
 			
218
 			
219
+			<br><br>
220
+
121
 		</main>
221
 		</main>
122
 
222
 
123
 
223
 
224
+<?php if(mysqli_query($connection, $queryCountExperiences)->num_rows === 0): // USER DOESN'T HAVE EXPERIENCES YET (PROMPT MODAL) ?>
225
+		<script> setTimeout(() => $('#FirstTime').modal('show'), 1000); </script>
226
+<?php endif; ?>
227
+
124
 
228
 
125
 		<!-- POPUP FOR FIRST TIME -->
229
 		<!-- POPUP FOR FIRST TIME -->
126
 		<div class='modal fade' id='FirstTime' tabindex='-1' role='dialog' aria-labelledby='FirstTimeLabel' aria-hidden='true'>
230
 		<div class='modal fade' id='FirstTime' tabindex='-1' role='dialog' aria-labelledby='FirstTimeLabel' aria-hidden='true'>
223
 								<label class='control-label col-sm-2' for='e_description'>Type:</label>
327
 								<label class='control-label col-sm-2' for='e_description'>Type:</label>
224
 								<div class='col-sm-9'>
328
 								<div class='col-sm-9'>
225
 									<select class="form-control text-center" style="text-align-last: center;" id='e_type' name='type' required>
329
 									<select class="form-control text-center" style="text-align-last: center;" id='e_type' name='type' required>
226
-										<option selected value="Course-Based Research">Course-Based Research</option>
227
-										<option value="Independent Research">Independent Research</option>
330
+										<option selected value="Course-Based Research Experience">Course-Based Research Experience</option>
331
+										<option value="Undergraduate Research Experience">Undergraduate Research Experience</option>
228
 									</select>
332
 									</select>
229
 								</div>
333
 								</div>
230
 							</div>
334
 							</div>
231
 				
335
 				
232
 							<!-- DURATION -->
336
 							<!-- DURATION -->
233
-							<div class='form-group'>
234
-								<label class='control-label col-sm-2' for='e_description'>Duration:</label>
235
-								<div class='col-sm-9'>
236
-									<input type='number' class='form-control text-center' id='e_duration' name='duration' placeholder='Duration' min="0" required readonly>
237
-								</div>
238
-							</div>
337
+<!-- 							<div class='form-group'> -->
338
+<!-- 								<label class='control-label col-sm-2' for='e_description'>Duration:</label> -->
339
+<!-- 								<div class='col-sm-9'> -->
340
+<!-- 									<input type='number' class='form-control text-center' id='e_duration' name='duration' placeholder='Duration' min="0" required readonly> -->
341
+<!-- 								</div> -->
342
+<!-- 							</div> -->
239
 				
343
 				
240
 							<!-- START DATE -->
344
 							<!-- START DATE -->
241
 							<div class='form-group'>
345
 							<div class='form-group'>
306
 			
410
 			
307
 
411
 
308
 		<!-- ERROR ALERT FOR USER -->			
412
 		<!-- ERROR ALERT FOR USER -->			
413
+<!-- 	<div id="error-newExperience" class="row" style="display: none;"> -->
414
+<!-- 		<div class="col-sm-12"> -->
415
+<!-- 			<div class="alert alert-danger mb-1" role="alert"> -->
416
+<!-- 				<h4 class="error-lead">Error!</h4> -->
417
+<!-- 				<p class="error-description"></p> -->
418
+<!-- 			</div> -->
419
+<!-- 		</div> -->
420
+<!-- 	</div> -->
421
+			
422
+			
423
+      				</div><!--modal-body-->
424
+      				
425
+      				<!-- SUBMIT OR CANCEL -->
426
+     				<div class='modal-footer'>
427
+       					<button type='button' class='btn btn-default' data-dismiss='modal'>Cancel</button>
428
+        				<button id="toProjectModal" type='button' class='btn btn-primary' data-dismiss='modal' onclick="nextModal('#New_3')" disabled>Next</button>
429
+      				</div>
430
+      				
431
+    			</div><!--modal-content-->
432
+  			</div><!--modal-dialog-->
433
+		</div><!--modal-->
434
+		
435
+		
436
+		
437
+		
438
+		
439
+		<!-- POPUP FOR NEW EXPERIENCE 3 -->
440
+		<div class='modal fade' id='New_3' tabindex='-1' role='dialog' aria-labelledby='NewLabel_3' aria-hidden='true'>
441
+			<div class='modal-dialog modal-lg' role='document'>
442
+ 				<div class='modal-content'>
443
+ 				
444
+ 					<div class='modal-body'>
445
+ 						
446
+ 						
447
+ 						
448
+ 						<!-- CLOSE BUTTON -->
449
+ 						<button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>&times;</span></button>
450
+						
451
+						<div class='row'>
452
+							<div class='col-sm-10'>
453
+								<h2>Brand New Experience <small>(Additional Info)</small></h2>
454
+							</div>
455
+						</div><!--row--> 						
456
+
457
+						<hr>
458
+						
459
+						
460
+						
461
+						<div class="row">
462
+							<div class="col-sm-12 col-sm-offset-1">
463
+								<h4>Is this experience part of a project or standalone?</h4>
464
+							</div>
465
+						</div>
466
+	
467
+	
468
+						<!-- TYPE OF EXPERIENCE (STANDALONE - PROJECT) -->
469
+						<div class="form-horizontal">
470
+							<div class='form-group'>
471
+								<div class='col-sm-6 col-sm-offset-3'>
472
+									<select class="form-control text-center" style="text-align-last: center;" id='typeOfExperience' name='typeOfExperience' required onchange="standaloneOrNot(event)">
473
+										<option selected value="Standalone">Standalone Experience</option>
474
+										<option value="Part of a Project">Part of a Project</option>
475
+									</select>
476
+								</div>
477
+							</div>
478
+						</div>
479
+				
480
+				
481
+<div id="standalone" style="display: none;">
482
+			
483
+			
484
+						<div class="row">
485
+							<div class="col-sm-12 col-sm-offset-1">
486
+								<h4>Does the project already exist, or would you like a new one?</h4>
487
+							</div>
488
+						</div>
489
+			
490
+						
491
+
492
+						<div class="form-horizontal">
493
+				
494
+							<!-- IS THE PROJECT EXISTING OR NEW? -->
495
+							<div class='form-group'>
496
+								<div class='col-sm-9 col-sm-offset-2'>
497
+									<select class="form-control text-center" style="text-align-last: center;" id='typeOfProject' name='typeOfProject' onchange="existingOrNot(event)">
498
+										<option selected value="New">New Project</option>
499
+										<option value="Existing">Existing Project</option>
500
+									</select>
501
+								</div>
502
+							</div>
503
+				
504
+<div id="newProject">
505
+							<!-- PROJECT NAME -->
506
+							<div class='form-group'>
507
+								<label class='control-label col-sm-2 col-sm-offset-2' for='projectName'>Name:</label>
508
+								<div class='col-sm-7'>
509
+									<input type='text' class='form-control text-center' id='projectName' name='projectName' placeholder="Project Name">
510
+								</div>
511
+							</div>
512
+
513
+							<!-- PROJECT DESCRIPTION -->
514
+							<div class='form-group'>
515
+								<label class='control-label col-sm-2 col-sm-offset-2' for='projectDescription'>Description:</label>
516
+								<div class='col-sm-7'>
517
+									<textarea class='form-control text-center' id='projectDescription' rows="2" name='projectDescription' placeholder="Project Description"></textarea>
518
+								</div>
519
+							</div>
520
+							
521
+</div>
522
+
523
+<div id="existingProject" style="display: none;">
524
+							<?php 
525
+							
526
+								// CHANGE QUERY DEPENDING ON IF USER IS ADMIN OR NOT
527
+								if($_SESSION['dbUserData']['admin'] === '1') {
528
+									$queryProjects = "SELECT * FROM project;";
529
+								} else {
530
+									$queryProjects = "SELECT * FROM project WHERE id IN (SELECT id_project FROM project_experience WHERE id_experience IN (SELECT id_experience FROM researcher_experience WHERE id_researcher = '" . $_SESSION['dbUserData']['id_researcher'] . "'));";
531
+								}
532
+								
533
+								$resultProjects = mysqli_query($connection, $queryProjects);
534
+								
535
+								if($resultProjects->num_rows > 0):
536
+							?>
537
+							<!-- CHOOSE EXISTING PROJECT -->
538
+							<div class='form-group'>
539
+								<label class='control-label col-sm-2 col-sm-offset-2' for='projectID'>Project:</label>
540
+								<div class='col-sm-7'>
541
+									<select class="form-control text-center" style="text-align-last: center;" id='projectID' name='projectID'>
542
+										<?php while($rowProjects = mysqli_fetch_assoc($resultProjects)): ?>
543
+										<option selected value="<?php echo $rowProjects['id']; ?>"><?php echo $rowProjects['name']; ?></option>
544
+										<?php endwhile; ?>
545
+									</select>
546
+								</div>
547
+							</div>
548
+							<?php else: ?>
549
+							<div class="row">
550
+								<div class="col-sm-9 col-sm-offset-3">
551
+									<h4><small>Uh oh! It seems you don't have a project to choose from...</small></h4>
552
+								</div>
553
+							</div>
554
+							<?php endif; ?>
555
+</div>
556
+
557
+
558
+
559
+						</div><!--form-horizontal-->
560
+						
561
+</div>
562
+						
563
+						<br>
564
+						
565
+						<!-- TIPS FOR USER -->
566
+						<div class="row">
567
+							<div class="col-sm-10 col-sm-offset-1">
568
+								<div class="alert alert-info alert-dismissable mb-1" role="alert">
569
+									<button type="button" class="close" data-dismiss="alert" aria-label="Close">
570
+										<span aria-hidden="true">&times;</span>
571
+									</button>
572
+									<h4 class="error-lead">Tips</h4>
573
+									<p>If you're not sure what to choose, select "<strong>Standalone</strong>".</p>
574
+								</div>
575
+							</div>
576
+						</div>
577
+						
578
+						
579
+						<br>
580
+			
581
+			
582
+
583
+		<!-- ERROR ALERT FOR USER -->			
309
 	<div id="error-newExperience" class="row" style="display: none;">
584
 	<div id="error-newExperience" class="row" style="display: none;">
310
 		<div class="col-sm-12">
585
 		<div class="col-sm-12">
311
 			<div class="alert alert-danger mb-1" role="alert">
586
 			<div class="alert alert-danger mb-1" role="alert">
320
       				
595
       				
321
       				<!-- SUBMIT OR CANCEL -->
596
       				<!-- SUBMIT OR CANCEL -->
322
      				<div class='modal-footer'>
597
      				<div class='modal-footer'>
323
-       					<button type='button' class='btn btn-default' data-dismiss='modal'>Cancel</button>
598
+       					<button type='button' class='btn btn-default' data-dismiss='modal' onclick="nextModal('#New_2')">Previous</button>
324
         				<button type='submit' class='btn btn-primary' name='newExperience'>Create</button>
599
         				<button type='submit' class='btn btn-primary' name='newExperience'>Create</button>
325
-<!--         				<button type='button' class='btn btn-primary' data-dismiss='modal' onclick="nextModal('#New_3')">Next</button> -->
326
       				</div>
600
       				</div>
327
       				
601
       				
328
     			</div><!--modal-content-->
602
     			</div><!--modal-content-->
330
 		</div><!--modal-->
604
 		</div><!--modal-->
331
 </form><!--form-->
605
 </form><!--form-->
332
 
606
 
607
+		<script>
608
+		
609
+			let button = document.getElementById('toProjectModal');
610
+			let title = document.getElementById('e_title');
611
+			let description = document.getElementById('e_description');
612
+// 			let type = document.getElementById('e_type');
613
+			let start = document.getElementById('e_start');
614
+			let end = document.getElementById('e_end');
615
+			let institution = document.getElementById('e_institution');
616
+// 			let expiryTime = document.getElementById('expiry_time');
617
+
618
+			title.addEventListener('change', experienceFirstModal);
619
+			description.addEventListener('change', experienceFirstModal);
620
+// 			type.addEventListener('change', experienceFirstModal);
621
+			start.addEventListener('change', experienceFirstModal);
622
+			end.addEventListener('change', experienceFirstModal);
623
+			institution.addEventListener('change', experienceFirstModal);
624
+// 			expiryTime.addEventListener('change', experienceFirstModal);
625
+			
626
+			function experienceFirstModal() {
627
+				
628
+				let validity = true;
629
+				validity &= title.checkValidity();
630
+				validity &= description.checkValidity();
631
+// 				validity &= type.checkValidity();
632
+				validity &= start.checkValidity();
633
+				validity &= end.checkValidity();
634
+				validity &= institution.checkValidity();
635
+// 				validity &= expiryTime.checkValidity();
636
+								
637
+				button.disabled = !validity;
638
+			
639
+			}
640
+			
641
+			
642
+			function standaloneOrNot(e) {
333
 
643
 
644
+				let standalonePart = document.getElementById('standalone');
645
+				let selection = e.currentTarget.value;
646
+				standalonePart.style.display = (selection !== 'Standalone' ? 'block' : 'none');
647
+			
648
+			}
649
+			
650
+			
651
+			function existingOrNot(e) {
652
+			
653
+				let existingPart = document.getElementById('existingProject');
654
+				let newPart = document.getElementById('newProject');
655
+				let selection = e.currentTarget.value;
656
+				
657
+				if(selection === 'New') {
658
+					existingPart.style.display = 'none';
659
+					newPart.style.display = 'block';
660
+				} else {
661
+					existingPart.style.display = 'block';
662
+					newPart.style.display = 'none';
663
+				}
664
+				
665
+				
666
+			}
667
+		
668
+		</script>
334
 
669
 
335
 
670
 
336
 
671
 
348
 
683
 
349
 <script>
684
 <script>
350
 
685
 
686
+// Enable popovers
687
+$(function () {
688
+  $('[data-toggle="popover"]').popover();
689
+});
690
+
351
 		
691
 		
352
 		["newExperience"].forEach(function(formName) {
692
 		["newExperience"].forEach(function(formName) {
353
 			
693
 			
371
 			startDate.addEventListener('change', setEndDateRange);
711
 			startDate.addEventListener('change', setEndDateRange);
372
 	
712
 	
373
 			// Duration
713
 			// Duration
374
-			startDate.addEventListener('change', setDuration);
375
-			endDate.addEventListener('change', setDuration);
714
+// 			startDate.addEventListener('change', setDuration);
715
+// 			endDate.addEventListener('change', setDuration);
376
 			
716
 			
377
 		}		
717
 		}		
378
 
718
 

+ 19
- 5
js/handleSubmit.js View File

18
 
18
 
19
 	// Fetch all input from form
19
 	// Fetch all input from form
20
 	var fields = {};
20
 	var fields = {};
21
-	$("form#" + formName).find("input, textarea, select, button[type='submit']").each(function() {
22
-		var input = $(this);
23
-		fields[input.attr('name')] = input.val();
24
-	});
21
+// 	if(formName !== "importQuestionnaire") {
22
+		$("form#" + formName).find("input, textarea, select, button[type='submit']").each(function() {
23
+			var input = $(this);
24
+			fields[input.attr('name')] = input.val();
25
+		});	
26
+// 	} else {
27
+// 		fields = new FormData($('#' + formName));
28
+//		https://stackoverflow.com/questions/27936645/send-input-files-data-with-ajax
29
+// 	}
25
 
30
 
26
 
31
 
27
 	// Construct request URL (make sure to use http or https accordingly)
32
 	// Construct request URL (make sure to use http or https accordingly)
42
 		case "newQuestionnaire":
47
 		case "newQuestionnaire":
43
 			fullURI += "insertQuestionnaire.php";
48
 			fullURI += "insertQuestionnaire.php";
44
 			break;
49
 			break;
50
+// 		case "importQuestionnaire":
51
+// 			fullURI += "importQuestionnaire.php";
52
+// 			break;
53
+		case "duplicateQuestionnaire":
54
+			fullURI += "duplicateQuestionnaire.php";
55
+			break;			
45
 		case "newMoment":
56
 		case "newMoment":
46
 		 	fullURI += "insertMoment.php";
57
 		 	fullURI += "insertMoment.php";
47
 		 	break;
58
 		 	break;
94
 			
105
 			
95
 	}
106
 	}
96
 
107
 
97
-// 	console.log(JSON.stringify(fields) + "\n" + fullURI);
108
+	// !!!!!! FOR DEBUGGING PURPOSES !!!!!!
109
+	console.log(JSON.stringify(fields) + "\n" + fullURI);
98
 
110
 
99
 
111
 
100
 	// Use fullURI to make POST request w/ jQuery,
112
 	// Use fullURI to make POST request w/ jQuery,
105
 	$.post(fullURI, fields)
117
 	$.post(fullURI, fields)
106
 		.done(function(data, text) {
118
 		.done(function(data, text) {
107
 				
119
 				
120
+			// !!!!!! FOR DEBUGGING PURPOSES !!!!!!
108
 			console.log(data + "and" + text);
121
 			console.log(data + "and" + text);
109
 
122
 
110
 			// Fetch needed elements
123
 			// Fetch needed elements
145
 		})
158
 		})
146
 		.fail(function(request, status, error) {
159
 		.fail(function(request, status, error) {
147
 				
160
 				
161
+			// !!!!!! FOR DEBUGGING PURPOSES !!!!!!
148
 			console.log(request.responseText);
162
 			console.log(request.responseText);
149
 			console.log(status);
163
 			console.log(status);
150
 			console.log(error);
164
 			console.log(error);

+ 2
- 2
js/home.js View File

5
 // Target the input fields to be updated
5
 // Target the input fields to be updated
6
 let startDate = document.querySelector('input[name=start]');
6
 let startDate = document.querySelector('input[name=start]');
7
 let endDate = document.querySelector('input[name=end]');
7
 let endDate = document.querySelector('input[name=end]');
8
-let duration = document.querySelector('input[name=duration]');
8
+// let duration = document.querySelector('input[name=duration]');
9
 
9
 
10
 
10
 
11
 
11
 
70
 	y = new Date(endDate.value);
70
 	y = new Date(endDate.value);
71
 	y.setDate(y.getDate() + 1); // (additional 1 necessary because of line above, apparent 0-indexing)
71
 	y.setDate(y.getDate() + 1); // (additional 1 necessary because of line above, apparent 0-indexing)
72
 	
72
 	
73
-	duration.value = String(Math.max(Math.round((y - x) / 604800000), 0)); // (1000 * 60 * 60 * 24 * 7 = 604800000)
73
+// 	duration.value = String(Math.max(Math.round((y - x) / 604800000), 0)); // (1000 * 60 * 60 * 24 * 7 = 604800000)
74
 
74
 
75
 }
75
 }
76
 
76
 

+ 15
- 6
js/main.js View File

23
 
23
 
24
 // MODAL SWITCHING FUNCTION (home.php & viewExperience.php)
24
 // MODAL SWITCHING FUNCTION (home.php & viewExperience.php)
25
 function nextModal(name) {
25
 function nextModal(name) {
26
-	$('[data-toggle="tooltip"]').tooltip('hide');
26
+// 	$('[data-toggle="tooltip"]').tooltip('hide');
27
 	setTimeout(() => $(name).modal('show'), 100);
27
 	setTimeout(() => $(name).modal('show'), 100);
28
 }
28
 }
29
 
29
 
56
 testDateField.setAttribute("type", "date");
56
 testDateField.setAttribute("type", "date");
57
 
57
 
58
 if(testDateField.type != "date") {
58
 if(testDateField.type != "date") {
59
+
60
+// 	console.log('Browser does not support input of type date, loading jQuery UI...');
59
 	
61
 	
60
 	// First load the CSS ("base" theme) for the calendar
62
 	// First load the CSS ("base" theme) for the calendar
61
-	document.write('<link href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />\n');
63
+	document.write('<link href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet" type="text/css">\n');
64
+// 	let objectContainer = document.createElement('div');
65
+// 	objectContainer.innerHTML = '<link href="//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css" rel="stylesheet">';
66
+// 	document.body.appendChild(objectContainer);
67
+	//<link href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet" type="text/css">
62
 	
68
 	
63
 	// Then load the calendar functionality
69
 	// Then load the calendar functionality
64
     document.write('<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js" integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU=" crossorigin="anonymous"></script>\n');
70
     document.write('<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js" integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU=" crossorigin="anonymous"></script>\n');
71
+// 	objectContainer = document.createElement('div');
72
+// 	objectContainer.innerHTML = '<script src="//code.jquery.com/jquery-1.12.4.js"></script><script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>';
73
+// 	document.body.appendChild(objectContainer);
74
+   	//<script src="https://code.jquery.com/jquery-1.12.4.js"></script><script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js" integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU=" crossorigin="anonymous"></script>
65
    	
75
    	
66
    	// Initialize date picker widget (on document.ready)
76
    	// Initialize date picker widget (on document.ready)
67
    	// Help: https://jqueryui.com/datepicker/#min-max
77
    	// Help: https://jqueryui.com/datepicker/#min-max
68
    	window.onload = () => {
78
    	window.onload = () => {
69
    		if($('input[type="date"]').length !== 0) {
79
    		if($('input[type="date"]').length !== 0) {
70
-	   		jQuery(($) => $('input[type="date"]').datepicker({ minDate: 0, maxDate: "+1Y"}));
80
+// 	   		jQuery(($) => $('input[type="date"]').datepicker({ minDate: 0, maxDate: "+1Y"}));
81
+// 	   		console.log('Done!');
71
    		}
82
    		}
72
 	}
83
 	}
73
 	
84
 	
75
 
86
 
76
 
87
 
77
 
88
 
78
-// FOOTER COPYRIGHT YEAR
79
-let date = new Date().getFullYear();
80
-document.getElementById('copyrightDate').innerHTML = date;
89
+
81
 
90
 
82
 
91
 
83
 
92
 

+ 14
- 10
js/viewExperience.js View File

192
 
192
 
193
 // For new moments, create the dropdowns for question selection
193
 // For new moments, create the dropdowns for question selection
194
 let correspondingQuestionnaire = document.querySelector('select#m_questionnaire');
194
 let correspondingQuestionnaire = document.querySelector('select#m_questionnaire');
195
-correspondingQuestionnaire.addEventListener('change', function() {
196
-	$.post(document.location.protocol + "//tania.uprrp.edu/admin_nuevo/special.php",
197
-		{
198
-			id_questionnaire: correspondingQuestionnaire.value
199
-		},
200
-		function(data, status) {
201
-			$("select[id^=m_question_]").html(data);
202
-		}
203
-	);
204
-});
195
+
196
+// User may not have a questionnaire yet, thus correspondingQuestionnaire might be null
197
+if(correspondingQuestionnaire) {
198
+	correspondingQuestionnaire.addEventListener('change', function() {
199
+		$.post(document.location.protocol + "//tania.uprrp.edu/admin_nuevo/special.php",
200
+			{
201
+				id_questionnaire: correspondingQuestionnaire.value
202
+			},
203
+			function(data, status) {
204
+				$("select[id^=m_question_]").html(data);
205
+			}
206
+		);
207
+	});
208
+}
205
 
209
 
206
 
210
 
207
 
211
 

+ 39
- 0
processes/updateMoment.php View File

76
 		}
76
 		}
77
 		
77
 		
78
 	
78
 	
79
+
80
+		if(isset($_POST['newDate'])) {
81
+		
82
+			$momentDate = mysqli_real_escape_string($connection, trim($_POST['newDate']));
83
+			
84
+			// Check that momentDate is not an empty string
85
+			// And that momentDate is in appropriate format YYYY-MM-DDThh:mm (e.g. 121212-12-12T12:12)
86
+			// WARNING: only handling AST
87
+			// HELP: https://www.codexworld.com/how-to/validate-date-input-string-in-php/
88
+			
89
+			function validDate($date) {
90
+				$d = date_create_from_format("Y-m-d\TH:i", $date);
91
+				return $d && date_format($d, "Y-m-d\TH:i") === $date;
92
+			}
93
+			
94
+			if($momentDate === "") {
95
+				http_response_code(400);
96
+				echo json_encode(array("error" => "Please specify moment date."));
97
+				exit();
98
+			} else if(!validDate($momentDate)) {
99
+				http_response_code(400);
100
+				echo json_encode(array("error" => "Moment date ($momentDate) given in wrong format (use YYYY-MM-DDTHH:mm instead)."));
101
+				exit();
102
+			}
103
+
104
+			$queryMoment = 
105
+			"UPDATE subquestionnair
106
+			SET date_to_administer = '$momentDate'
107
+			WHERE id = '$momentID';";
79
 	
108
 	
109
+			if(!mysqli_query($connection, $queryMoment)) {
110
+				http_response_code(400);
111
+				echo json_encode(array("error" => "Couldn't update moment date. ".mysqli_error($connection)));
112
+			}
113
+			
114
+			
115
+			
116
+
117
+		}
118
+
80
 		
119
 		
81
 	}
120
 	}
82
 	
121
 	

+ 4
- 4
special2.php View File

49
 			http_response_code(400);
49
 			http_response_code(400);
50
 			echo json_encode(array("error" => "Please specify experience ID."));
50
 			echo json_encode(array("error" => "Please specify experience ID."));
51
 			exit();
51
 			exit();
52
-		} else if(!mysqli_query($connection, "SELECT * FROM experience WHERE id = $experienceID;")) {
52
+		} else if(!mysqli_query($connection, "SELECT * FROM experience WHERE id = '$experienceID';")) {
53
 			http_response_code(400);
53
 			http_response_code(400);
54
 			echo json_encode(array("error" => "Given experience ID ($experienceID) not in database."));
54
 			echo json_encode(array("error" => "Given experience ID ($experienceID) not in database."));
55
 			exit();
55
 			exit();
73
 		
73
 		
74
 		
74
 		
75
 		// Get the start date of the experience...
75
 		// Get the start date of the experience...
76
-		$queryExperience = "SELECT * FROM experience WHERE id = $experienceID;";
76
+		$queryExperience = "SELECT * FROM experience WHERE id = '$experienceID';";
77
 		$resultExperience = mysqli_query($connection, $queryExperience);
77
 		$resultExperience = mysqli_query($connection, $queryExperience);
78
 		$rowExperience = mysqli_fetch_assoc($resultExperience);
78
 		$rowExperience = mysqli_fetch_assoc($resultExperience);
79
 		$calendarConfig->defaultDate = $rowExperience['start_date'];
79
 		$calendarConfig->defaultDate = $rowExperience['start_date'];
98
 		
98
 		
99
 		
99
 		
100
 		// Create a new event for each moment
100
 		// Create a new event for each moment
101
-		$queryMoments = "SELECT * FROM `subquestionnair` WHERE id_questionnair IN (SELECT id_questionnair FROM `experience_questionnair` WHERE id_experience = $experienceID);";
101
+		$queryMoments = "SELECT * FROM `subquestionnair` WHERE id_questionnair IN (SELECT id_questionnair FROM `experience_questionnair` WHERE id_experience = '$experienceID');";
102
 		$resultMoments = mysqli_query($connection, $queryMoments);
102
 		$resultMoments = mysqli_query($connection, $queryMoments);
103
 		while($rowMoments = mysqli_fetch_assoc($resultMoments)) {
103
 		while($rowMoments = mysqli_fetch_assoc($resultMoments)) {
104
 		
104
 		
123
 		
123
 		
124
 		
124
 		
125
 		// Create a new event for each milestone
125
 		// Create a new event for each milestone
126
-		$queryMilestones = "SELECT * FROM `milestone` WHERE id_experience = $experienceID;";
126
+		$queryMilestones = "SELECT * FROM `milestone` WHERE id_experience = '$experienceID';";
127
 		$resultMilestones = mysqli_query($connection, $queryMilestones);
127
 		$resultMilestones = mysqli_query($connection, $queryMilestones);
128
 		while($rowMilestones = mysqli_fetch_assoc($resultMilestones)) {
128
 		while($rowMilestones = mysqli_fetch_assoc($resultMilestones)) {
129
 			
129
 			

+ 14
- 178
testFrontEnd.php View File

1
-<!DOCTYPE html>
2
-<html>
1
+<!doctype html>
2
+<html lang="en">
3
 <head>
3
 <head>
4
-	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
5
-    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
6
-    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
7
-	<title>Test</title>
8
-	<style type="text/css">
9
-		
10
-:root {
11
-	--size: 12px;
12
-	/* 15px for btn-xl */
13
-	/* 15px for btn-lg */
14
-	/* 12px for btn-md */
15
-	/* 10px for btn-sm */
16
-	/* 5px for btn-xs */
17
-	--period: 750ms;
18
-	--color: #3498db;
19
-	--bg-color: white;
20
-	--thinness: 5;
21
-	/* 10 is okay */
22
-}
23
-
24
-.loader {
25
-	display: inline-block;
26
-	width: 12px;
27
-	height: 12px;
28
-	position: relative;
29
-	margin-right: calc(12px / 2);
30
-}
31
-
32
-.loader:before, .loader:after {
33
-	content: "";
34
-	position: absolute;
35
-	left: 0; /* make sure it's inside the box */
36
-	width: 100%;
37
-	height: 100%;
38
-	border-radius: 100%;
39
-	border: calc(12px / 5) solid transparent;
40
-	border-top-color: #3498db;
41
-}
42
-
43
-.loader:before {
44
-	z-index: 100;
45
-	animation: spin 750ms infinite;
46
-}
47
-
48
-.loader:after {
49
-	border: calc(12px / 5) solid white;
50
-}
51
-
52
-@keyframes spin {
53
-	0% {
54
-		-webkit-transform: rotate(0deg);
55
-		-ms-transform: rotate(0deg);
56
-		-o-transform: rotate(0deg);
57
-		transform: rotate(0deg);
58
-	}
59
-
60
-	100% {
61
-		-webkit-transform: rotate(360deg);
62
-		-ms-transform: rotate(360deg);
63
-		-o-transform: rotate(360deg);
64
-		transform: rotate(360deg);
65
-	}
66
-}
67
-
68
-	</style>
4
+  <meta charset="utf-8">
5
+  <title>datepicker demo</title>
6
+  <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css">
7
+  <script src="//code.jquery.com/jquery-1.12.4.js"></script>
8
+  <script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
69
 </head>
9
 </head>
70
 <body>
10
 <body>
71
-	
72
-<!-- 
73
-	<form id="myForm">
74
-		<input type="hidden" name="caca" value="pipi">
75
-		<input type="hidden" name="caca2" value="pipi2">
76
-		<input type="hidden" name="caca3" value="pipi3">
77
-		<button type="submit" name="formSubmit" class="btn btn-xl btn-primary">
78
-			Press Me!
79
-		</button>
80
-	</form>
81
-
82
-	<div id="error-myForm" class="row" style="display: none;">
83
-		<div class="col-sm-3">
84
-			<div class="alert alert-danger mb-1" role="alert">
85
-				<h4 class="error-lead">Error!</h4>
86
-				<p class="error-description"></p>
87
-			</div>
88
-		</div>
89
-	</div>
90
- -->
91
  
11
  
12
+<!-- <div id="datepicker"></div> -->
13
+
14
+<input type="date">
92
  
15
  
93
-    	<header id="main-header">
94
-        	<a id="logo" href=".">
95
-				TANIA
96
-            	<img src="./img/pen_800x800.png" alt="tania logo pen" width="25" height="25">
97
-        	</a>
98
-        	<div id="account">
99
-            	<a class="nav-link" href="./questionnaires.php">Questionnaire Collection</a>
100
-            	<a class="sign-out" href="./processes/logout.php">Sign Out</a>
101
-        	</div>
102
-    	</header>
103
-		
104
-		<div class="container-fluid" id="view-experience-showcase" style="background-color: #333;">
105
-        	<h2 style="color: white;">Test 123</h2>
106
-        	<div id="view-experience-block">
107
-            	<blockquote style="color:rgb(216,216,216); margin: 0;">
108
-                	<h4><b style="color:#fff;">Description:</b> <span style="color:rgb(216,216,216);">Testing purposes</span></h4>
109
-                	<h4><b style="color:#fff;">Type:</b> <span style="color:rgb(216,216,216);">Independent Research</span></h4>
110
-                	<h4><b style="color:#fff;">Duration:</b> <span style="color:rgb(216,216,216);">3 weeks</span></h4>
111
-            	</blockquote>
112
-            	<div id="view-experience-buttons">
113
-            		<div id="experience-pen" onclick="window.location='respuestas.php?exp=<?php echo $id_experience; ?>'">
114
-            			<span class="fas fa-poll-h"></span>
115
-            		</div>
116
-            		<div id="experience-pen" onclick="nextModal('#Edit')">
117
-            		    <span class="fas fa-pen"></span>
118
-            		</div>
119
-            		<div id="experience-pen" onclick="prompt('Press Ctrl + C to copy to clipboard!','https://tania.uprrp.edu/enrollInExp.php?id=<?php echo $rowHash['hash_id']; ?>')">
120
-            			<span class="fas fa-link"></span>
121
-            		</div>
122
-            	</div>
123
-        	</div>
124
-        	<br>
125
-        	<div id="view-experience-tabs">
126
-        	    <a class="active" href="#calendar">Calendar</a>
127
-        	    <a href="#questionnaires">Questionnaires</a>
128
-        	    <a href="#moments">Moments</a>
129
-        	    <a href="#milestones">Milestones</a>
130
-        	</div>
131
-    	</div>
132
-    	
133
-    	
134
-    	
135
-    	
16
+<script>
17
+$( "#datepicker, input[type='date']" ).datepicker();
18
+</script>
136
  
19
  
137
-	<div class="container">
138
-		<div class="row">
139
-			<div class="col-sm-12">
140
-				<button type="button" data-piruli="acérrimo" data-pupi="yandel" class="btn btn-primary" data-toggle="modal" data-target="#bookModal">Hello World</button>
141
-			</div>
142
-		</div>
143
-	</div>
144
-
145
-	<div id="bookModal" class="modal fade" role="dialog" aria-labelledby="orderModalLabel" aria-hidden="true">
146
-		<div class="modal-dialog" role="document">
147
-			<div class="modal-content">
148
-				<div class="modal-header">
149
-					<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
150
-				</div>
151
-				<div id="orderDetails" class="modal-body">
152
-				
153
-				</div>
154
-				<div class="modal-footer">
155
-					<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
156
-				</div>
157
-			</div>
158
-		</div>
159
-	</div>
160
-
161
-	<script type="text/javascript">
162
-
163
-	$('#bookModal').on('show.bs.modal', function(e) {
164
-		var modal = $(this);
165
-		modal.find('#orderDetails').text(e.relatedTarget.innerText);
166
-		var data = $(e.relatedTarget).data('piruli');
167
-		var data2 = $(e.relatedTarget).data('pupi');
168
-		console.log(data);
169
-		console.log(data2);
170
-		console.log(modal);
171
-		
172
-	});
173
-
174
-	//setTimeout(() => $('#bookModal').modal('toggle'), 5000);
175
-
176
-	</script>
177
-
178
 </body>
20
 </body>
179
-</html>
180
-
181
-
182
-
183
-
184
-
185
-
21
+</html>

+ 1
- 1
users.php View File

24
             	<img src="./img/pen_800x800.png" alt="tania logo pen" width="25" height="25">
24
             	<img src="./img/pen_800x800.png" alt="tania logo pen" width="25" height="25">
25
         	</a>
25
         	</a>
26
         	<div id="account">
26
         	<div id="account">
27
-            	<a class="nav-link" href="#" onclick="location='home.php'">Go Back</a>
27
+            	<a class="nav-link" href="#" onclick="location='home.php'"><i class="fas fa-arrow-left"></i> Back</a>
28
             	<a class="sign-out" href="./processes/logout.php">Sign Out</a>
28
             	<a class="sign-out" href="./processes/logout.php">Sign Out</a>
29
         	</div>
29
         	</div>
30
     	</header>
30
     	</header>

+ 106
- 20
viewExperience.php View File

34
 		
34
 		
35
 	}
35
 	}
36
 
36
 
37
-
38
 	include_once 'header.php';
37
 	include_once 'header.php';
39
 	
38
 	
40
 ?>
39
 ?>
47
             	<img src="./img/pen_800x800.png" alt="tania logo pen" width="25" height="25">
46
             	<img src="./img/pen_800x800.png" alt="tania logo pen" width="25" height="25">
48
         	</a>
47
         	</a>
49
         	<div id="account">
48
         	<div id="account">
49
+        		<a class="nav-link" style="margin-right: 1rem;" href="./home.php"><i class="fas fa-arrow-left"></i> Back</a>
50
             	<a class="sign-out" href="./processes/logout.php">Sign Out</a>
50
             	<a class="sign-out" href="./processes/logout.php">Sign Out</a>
51
         	</div>
51
         	</div>
52
     	</header>
52
     	</header>
107
 			<div class="container">
107
 			<div class="container">
108
 		
108
 		
109
 				<div class="row">
109
 				<div class="row">
110
-					<h3 class="col-sm-12">Schedule Your Experience</h3>
110
+					<h3 class="col-sm-12">
111
+						Schedule Your Experience
112
+						<button type="button" class="btn btn-link btn-lg" data-toggle="popover" title="Calendar Tips" data-content="Drag and drop existing events to change their dates. Toggle month & week views for finer control." data-placement="bottom">
113
+							<span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span>
114
+						</button>
115
+					</h3>
111
 				</div><!--row-->
116
 				</div><!--row-->
112
 			
117
 			
113
 				<br>
118
 				<br>
265
 							// ELSE, DISPLAY A MESSAGE TO THE USER LETTING THEM KNOW THEY DON'T HAVE ONE
270
 							// ELSE, DISPLAY A MESSAGE TO THE USER LETTING THEM KNOW THEY DON'T HAVE ONE
266
 							if(mysqli_num_rows($result4) > 0):
271
 							if(mysqli_num_rows($result4) > 0):
267
 							
272
 							
273
+								$queryTotalStudents = "SELECT * FROM student_participate_experience WHERE id_experience = '$experienceID'";
274
+								$resultTotalStudents = mysqli_query($connection, $queryTotalStudents);
275
+								$studentCount = $resultTotalStudents->num_rows;
276
+								
268
 						?>
277
 						?>
269
 						<table class="table table-hover table-striped table-responsive">
278
 						<table class="table table-hover table-striped table-responsive">
270
   							<thead>
279
   							<thead>
272
   									<th style="text-align: center;"><h4>Moment</h4></th>
281
   									<th style="text-align: center;"><h4>Moment</h4></th>
273
   									<th style="text-align: center;"><h4>Questions</h4></th>
282
   									<th style="text-align: center;"><h4>Questions</h4></th>
274
   									<th style="text-align: center;"><h4>Date</h4></th>
283
   									<th style="text-align: center;"><h4>Date</h4></th>
284
+  									<th style="text-align: center;"><h4>Answer Rate</h4></th>
275
   								</tr>
285
   								</tr>
276
   							</thead>
286
   							</thead>
277
   							<tbody>
287
   							<tbody>
278
   								<?php while($row4 = mysqli_fetch_assoc($result4)): ?>
288
   								<?php while($row4 = mysqli_fetch_assoc($result4)): ?>
279
-  								<tr style="cursor: pointer;" onclick="location='viewMoment.php?view=<?php echo $row4['id']?>'">
289
+  								<tr style="cursor: pointer;" onclick="location='viewMoment.php?view=<?php echo $row4['id']; ?>'">
280
   									<td style="text-align: center;"><h5><?php echo $row4['title']; ?></h5></td>
290
   									<td style="text-align: center;"><h5><?php echo $row4['title']; ?></h5></td>
281
   									<?php
291
   									<?php
282
   										$query5 = "SELECT * FROM subquestionnair_question WHERE `id_subquestionnair` = ".$row4['id'];
292
   										$query5 = "SELECT * FROM subquestionnair_question WHERE `id_subquestionnair` = ".$row4['id'];
284
   									?>
294
   									?>
285
   									<td style="text-align: center;"><h5><?php echo mysqli_num_rows($result5); ?></h5></td>
295
   									<td style="text-align: center;"><h5><?php echo mysqli_num_rows($result5); ?></h5></td>
286
 									<td style="text-align: center;"><h5><?php echo date("M j, Y (g:i A)", strtotime($row4['date_to_administer'])); ?></h5></td>
296
 									<td style="text-align: center;"><h5><?php echo date("M j, Y (g:i A)", strtotime($row4['date_to_administer'])); ?></h5></td>
297
+									
298
+									<?php if($studentCount === 0): ?>
299
+									
300
+									<td style="text-align: center;"><h5 class="text-danger">Register students!</h5></td>
301
+									
302
+									<?php elseif(strtotime($row4['date_to_administer']) > strtotime('now')): ?>
303
+									
304
+									<td style="text-align: center;"><h5 class="text-warning">Still not sent</h5></td>
305
+									
306
+									<?php
307
+									else:
308
+										$queryAnswers = "SELECT * FROM student_subquestionnair WHERE id_subquestionnair = '" . $row4['id'] . "';";
309
+										$resultAnswers = mysqli_query($connection, $queryAnswers);
310
+										$answerCount = $resultAnswers->num_rows;
311
+									?>
312
+									
313
+									<td style="text-align: center;"><h5 class="text-muted"><?php echo "$answerCount out of $studentCount"; ?></h5></td>
314
+									
315
+									<?php endif; ?>
287
   								</tr>
316
   								</tr>
288
   								<?php endwhile; ?>
317
   								<?php endwhile; ?>
289
   							</tbody>
318
   							</tbody>
290
   						</table>
319
   						</table>
291
   					
320
   					
292
     					<?php else: ?>
321
     					<?php else: ?>
293
- 							<h3 class="text-center"><small>It seems you still haven't added any moments to this experience...</small></h3>
322
+ 						<h3 class="text-center"><small>It seems you still haven't added any moments to this experience...</small></h3>
294
   						<?php endif; ?>
323
   						<?php endif; ?>
295
   							 
324
   							 
296
   						<br>
325
   						<br>
934
 
963
 
935
 
964
 
936
 		<!-- POPUP FOR IMPORT QUESTIONNAIRE -->
965
 		<!-- POPUP FOR IMPORT QUESTIONNAIRE -->
937
-		<form class='form-horizontal' action='processes/importQuestionnaire.php' method='POST' enctype="multipart/form-data">
966
+		<form id="importQuestionnaire" method="post" action="processes/importQuestionnaire.php" class='form-horizontal' enctype="multipart/form-data">
938
 			<div class='modal fade' id='Import' tabindex='-1' role='dialog' aria-labelledby='ImportLabel' aria-hidden='true'>
967
 			<div class='modal fade' id='Import' tabindex='-1' role='dialog' aria-labelledby='ImportLabel' aria-hidden='true'>
939
 				<div class='modal-dialog modal-dialog-centered modal-md' role='document'>
968
 				<div class='modal-dialog modal-dialog-centered modal-md' role='document'>
940
  					<div class='modal-content'>
969
  					<div class='modal-content'>
947
 
976
 
948
 							<div class="form-horizontal">
977
 							<div class="form-horizontal">
949
 							
978
 							
950
-								<input type="hidden" name="id_experience" value="<?php echo $experienceID; ?>">
979
+								<input type="hidden" name="id_experience" value="<?php echo $experienceID; ?>" required>
951
 							
980
 							
952
 								<div class="row">
981
 								<div class="row">
953
 									<div class="col-sm-12">
982
 									<div class="col-sm-12">
971
 							</div>
1000
 							</div>
972
 
1001
 
973
 
1002
 
1003
+						<!-- ERROR ALERT FOR USER -->			
1004
+						<div id="error-importQuestionnaire" class="row" style="display: none;">
1005
+							<div class="col-sm-12">
1006
+								<div class="alert alert-danger mb-1" role="alert">
1007
+									<h4 class="error-lead">Error!</h4>
1008
+									<p class="error-description"></p>
1009
+								</div>
1010
+							</div>
1011
+						</div>
1012
+
1013
+
974
       					</div><!--modal-body-->
1014
       					</div><!--modal-body-->
975
      					
1015
      					
976
      					<div class='modal-footer'>
1016
      					<div class='modal-footer'>
981
     				</div><!--modal-content-->
1021
     				</div><!--modal-content-->
982
   				</div><!--modal-dialog-->
1022
   				</div><!--modal-dialog-->
983
 			</div><!--modal-->
1023
 			</div><!--modal-->
984
-			
1024
+		</form>
985
 			
1025
 			
986
 			
1026
 			
987
 			
1027
 			
988
 			
1028
 			
989
 		<!-- POPUP FOR DUPLICATE QUESTIONNAIRE -->
1029
 		<!-- POPUP FOR DUPLICATE QUESTIONNAIRE -->
990
-		<form class='form-horizontal' action='processes/duplicateQuestionnaire.php' method='POST'>
1030
+		<form id="duplicateQuestionnaire" class='form-horizontal'>
991
 			<div class='modal fade' id='Duplicate' tabindex='-1' role='dialog' aria-labelledby='DuplicateLabel' aria-hidden='true'>
1031
 			<div class='modal fade' id='Duplicate' tabindex='-1' role='dialog' aria-labelledby='DuplicateLabel' aria-hidden='true'>
992
 				<div class='modal-dialog modal-dialog-centered' role='document'>
1032
 				<div class='modal-dialog modal-dialog-centered' role='document'>
993
  					<div class='modal-content'>
1033
  					<div class='modal-content'>
1004
 							
1044
 							
1005
 							<br>
1045
 							<br>
1006
 							
1046
 							
1047
+
1048
+							<?php
1049
+								$queryProject = "SELECT id_project FROM project_experience WHERE id_experience = '$experienceID';";
1050
+								$resultProject = mysqli_query($connection, $queryProject);
1051
+								$rowProject = mysqli_fetch_assoc($resultProject);
1052
+							?>
1053
+							<!-- PROJECT ID (EMPTY STRING IF THERE'S NONE) -->
1054
+							<input type="hidden" name="projectID" value="<?php echo $rowProject['id_project']; ?>">
1055
+							
1056
+							
1057
+							
1058
+							
1007
 							<!-- FROM QUESTIONNAIRE -->
1059
 							<!-- FROM QUESTIONNAIRE -->
1008
 							<label for="fromQuestionnaireID">Which Questionnaire:</label>
1060
 							<label for="fromQuestionnaireID">Which Questionnaire:</label>
1009
 							<?php
1061
 							<?php
1057
 							<?php endif; ?>
1109
 							<?php endif; ?>
1058
 							
1110
 							
1059
 							
1111
 							
1112
+						<br>
1113
+							
1114
+							
1115
+						<!-- ERROR ALERT FOR USER -->			
1116
+						<div id="error-duplicateQuestionnaire" class="row" style="display: none;">
1117
+							<div class="col-sm-12">
1118
+								<div class="alert alert-danger mb-1" role="alert">
1119
+									<h4 class="error-lead">Error!</h4>
1120
+									<p class="error-description"></p>
1121
+								</div>
1122
+							</div>
1123
+						</div>
1124
+							
1125
+							
1126
+							
1127
+							
1060
       					</div><!--modal-body-->
1128
       					</div><!--modal-body-->
1061
       					
1129
       					
1062
       					<!-- SUBMIT OR CANCEL -->
1130
       					<!-- SUBMIT OR CANCEL -->
1121
 							<div class="form-group">
1189
 							<div class="form-group">
1122
 								<label class="control-label col-sm-2">Date to Administer:</label>
1190
 								<label class="control-label col-sm-2">Date to Administer:</label>
1123
 								<div class="col-sm-9">
1191
 								<div class="col-sm-9">
1124
-									<input type="datetime-local" class="form-control text-center" name="m_date" maxlength="16" placeholder="YYYY-MM-DDThh:mm" required>
1192
+									<input type="datetime-local" class="form-control text-center" name="m_date" placeholder="YYYY-MM-DDThh:mm" required>
1125
 								</div>
1193
 								</div>
1126
 							</div>
1194
 							</div>
1127
 							
1195
 							
1188
 		momentDescription.addEventListener('change', validateNewMoment);
1256
 		momentDescription.addEventListener('change', validateNewMoment);
1189
 		momentDate.addEventListener('keyup', validateNewMoment);
1257
 		momentDate.addEventListener('keyup', validateNewMoment);
1190
 		momentDate.addEventListener('change', validateNewMoment);
1258
 		momentDate.addEventListener('change', validateNewMoment);
1191
-		momentQuestionnaire.addEventListener('keyup', validateNewMoment);
1192
-		momentQuestionnaire.addEventListener('change', validateNewMoment);
1193
 		
1259
 		
1260
+		
1261
+		// User may not have a questionnaire yet, thus momentQuestionnaire might be null
1262
+		if(momentQuestionnaire) {
1263
+			momentQuestionnaire.addEventListener('keyup', validateNewMoment);
1264
+			momentQuestionnaire.addEventListener('change', validateNewMoment);
1265
+		}
1194
 
1266
 
1195
 		
1267
 		
1196
 		// First modal's validation function
1268
 		// First modal's validation function
1204
 			let validity = momentTitle.checkValidity();
1276
 			let validity = momentTitle.checkValidity();
1205
 			validity &= momentDescription.checkValidity();
1277
 			validity &= momentDescription.checkValidity();
1206
 			validity &= momentDate.checkValidity();
1278
 			validity &= momentDate.checkValidity();
1207
-			validity &= momentQuestionnaire.checkValidity();
1279
+			
1280
+			// If user doesn't have a questionnaire yet, he can't create a moment
1281
+			if(momentQuestionnaire) {
1282
+				validity &= momentQuestionnaire.checkValidity();
1283
+			} else {
1284
+				validity = false;
1285
+			}
1208
 			
1286
 			
1209
 			// Disabled if not valid, enabled otherwise
1287
 			// Disabled if not valid, enabled otherwise
1210
 			nextButton.disabled = !validity;
1288
 			nextButton.disabled = !validity;
1237
 						<hr><br>
1315
 						<hr><br>
1238
 						
1316
 						
1239
 						<!-- QUESTION -->
1317
 						<!-- QUESTION -->
1240
-						<div id="qq1" >
1318
+						<div id="qq1">
1241
 						
1319
 						
1242
 							<div class="row">
1320
 							<div class="row">
1243
-								<div class="col col-sm-offset-1">
1321
+								<div class="col-sm-11 col-sm-offset-1">
1244
 									<h4>Question 1</h4>
1322
 									<h4>Question 1</h4>
1245
 								</div>
1323
 								</div>
1246
 							</div>
1324
 							</div>
1256
 									</div>
1334
 									</div>
1257
 								</div>
1335
 								</div>
1258
 							</div>
1336
 							</div>
1259
-							
1260
-						</div>
1261
-						
1262
-						
1337
+
1263
 						<br>
1338
 						<br>
1339
+							
1340
+						</div><!--#qq-->						
1341
+
1264
 						
1342
 						
1265
 						 <div class="row">
1343
 						 <div class="row">
1266
  							<div class="col-sm-offset-9 col-sm-2">
1344
  							<div class="col-sm-offset-9 col-sm-2">
1393
 <script>
1471
 <script>
1394
 
1472
 
1395
 
1473
 
1396
-		["editForm", "newQuestionnaire", "newMoment", "newMilestone"].forEach(function(formName) {
1474
+// Enable popovers
1475
+$(function () {
1476
+  $('[data-toggle="popover"]').popover();
1477
+});
1478
+
1479
+
1480
+
1481
+		// Removed "importQuestionnaire" because of weird non-fetching behaviour of importQuestionnaire.php
1482
+		["editForm", "newQuestionnaire", "newMoment", "newMilestone", "duplicateQuestionnaire"].forEach(function(formName) {
1397
 			
1483
 			
1398
 			var form = document.getElementById(formName);
1484
 			var form = document.getElementById(formName);
1399
 			
1485
 			
1415
 	header: {
1501
 	header: {
1416
 		left: 'prev,next today',
1502
 		left: 'prev,next today',
1417
 		center: 'title',
1503
 		center: 'title',
1418
-		right: 'dayGridMonth,timeGridWeek,timeGridDay'
1504
+		right: 'dayGridMonth,timeGridWeek'//,timeGridDay
1419
 	},
1505
 	},
1420
 	defaultDate: document.getElementById('experience_start_date').value,
1506
 	defaultDate: document.getElementById('experience_start_date').value,
1421
 	businessHours: true,
1507
 	businessHours: true,

+ 9
- 0
viewMoment.php View File

52
             		<img src="./img/pen_800x800.png" alt="tania logo pen" width="25" height="25">
52
             		<img src="./img/pen_800x800.png" alt="tania logo pen" width="25" height="25">
53
         		</a>
53
         		</a>
54
         		<div id="account">
54
         		<div id="account">
55
+        			<a class="nav-link" style="margin-right: 1rem;" href="javascript:history.go(-1)"><i class="fas fa-arrow-left"></i> Back</a>
55
         		    <a class="sign-out" href="./processes/logout.php">Sign Out</a>
56
         		    <a class="sign-out" href="./processes/logout.php">Sign Out</a>
56
         		</div>
57
         		</div>
57
     		</header>
58
     		</header>
181
 								</div>
182
 								</div>
182
 							</div>
183
 							</div>
183
 
184
 
185
+							<!-- DATE TO ADMINISTER -->
186
+							<div class="form-group">
187
+								<label class="control-label col-sm-2 col-sm-offset-1">Date to Administer:</label>
188
+								<div class="col-sm-7">
189
+									<input type="datetime-local" class="form-control text-center" name="newDate" value="<?php echo substr($row1['date_to_administer'], 0, -3); ?>" placeholder="YYYY-MM-DDThh:mm" required>
190
+								</div>
191
+							</div>
192
+
184
 
193
 
185
 							<br>
194
 							<br>
186
 
195
 

+ 1
- 0
viewQuestionnaire.php View File

52
             		<img src="./img/pen_800x800.png" alt="tania logo pen" width="25" height="25">
52
             		<img src="./img/pen_800x800.png" alt="tania logo pen" width="25" height="25">
53
         		</a>
53
         		</a>
54
         		<div id="account">
54
         		<div id="account">
55
+        			<a class="nav-link" style="margin-right: 1rem;" href="javascript:history.go(-1)"><i class="fas fa-arrow-left"></i> Back</a>
55
         		    <a class="sign-out" href="./processes/logout.php">Sign Out</a>
56
         		    <a class="sign-out" href="./processes/logout.php">Sign Out</a>
56
         		</div>
57
         		</div>
57
     		</header>
58
     		</header>