Browse Source

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

Victor Hernandez 3 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,8 +3,12 @@
3 3
     	    <p>Universidad de Puerto Rico</p>
4 4
     	    <p>Recinto de Río Piedras</p>
5 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 13
 	</body>
10 14
 </html>

+ 15
- 8
header.php View File

@@ -13,9 +13,6 @@
13 13
     	<!-- JQUERY IMPORT-->
14 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 16
     	<!-- FONTAWESOME IMPORT -->
20 17
     	<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.10.2/css/all.css">
21 18
     	
@@ -33,6 +30,12 @@
33 30
     	<!-- CUSTOM STYLES -->
34 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 39
     	<style>
37 40
     	
38 41
 textarea {
@@ -55,10 +58,14 @@ textarea {
55 58
 
56 59
 .loader {
57 60
 	display: inline-block;
58
-	width: 12px;
59
-	height: 12px;
61
+	width: var(--size);
62
+	height: var(--size);
60 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 71
 .loader:before, .loader:after {
@@ -68,7 +75,7 @@ textarea {
68 75
 	width: 100%;
69 76
 	height: 100%;
70 77
 	border-radius: 100%;
71
-	border: calc(12px / 5) solid transparent;
78
+	border: calc(var(--size) / 5) solid transparent;
72 79
 	border-top-color: #3498db;
73 80
 }
74 81
 
@@ -78,7 +85,7 @@ textarea {
78 85
 }
79 86
 
80 87
 .loader:after {
81
-	border: calc(12px / 5) solid white;
88
+	border: calc(var(--size) / 5) solid white;
82 89
 }
83 90
 
84 91
 @keyframes spin {

+ 378
- 38
home.php View File

@@ -20,6 +20,14 @@
20 20
 	}
21 21
 	
22 22
 ?>
23
+
24
+	<style>
25
+	.popover-content {
26
+		color: #333;
27
+	}
28
+	</style>
29
+	
30
+	
23 31
 	<!-- START OF home.php -->
24 32
 	<body>
25 33
 
@@ -60,32 +68,58 @@
60 68
             	</div>
61 69
 
62 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 75
 	// CHANGE QUERY DEPENDING ON IF USER IS ADMIN OR NOT
64 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 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 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 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 123
                 	    <p style="margin-bottom: 0;">• Starts: <?php echo date("M j, Y", strtotime($row['start_date'])); ?></p>
90 124
                 	    <p>• Ends: <?php echo date("M j, Y", strtotime($row['end_date'])); ?></p>
91 125
                 	</div>
@@ -95,32 +129,102 @@
95 129
                 		if($x <= 0):
96 130
                 	?>
97 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 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 136
                 	<?php endif; ?>
101 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 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 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 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 229
 		<!-- POPUP FOR FIRST TIME -->
126 230
 		<div class='modal fade' id='FirstTime' tabindex='-1' role='dialog' aria-labelledby='FirstTimeLabel' aria-hidden='true'>
@@ -223,19 +327,19 @@
223 327
 								<label class='control-label col-sm-2' for='e_description'>Type:</label>
224 328
 								<div class='col-sm-9'>
225 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 332
 									</select>
229 333
 								</div>
230 334
 							</div>
231 335
 				
232 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 344
 							<!-- START DATE -->
241 345
 							<div class='form-group'>
@@ -306,6 +410,177 @@
306 410
 			
307 411
 
308 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 584
 	<div id="error-newExperience" class="row" style="display: none;">
310 585
 		<div class="col-sm-12">
311 586
 			<div class="alert alert-danger mb-1" role="alert">
@@ -320,9 +595,8 @@
320 595
       				
321 596
       				<!-- SUBMIT OR CANCEL -->
322 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 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 600
       				</div>
327 601
       				
328 602
     			</div><!--modal-content-->
@@ -330,7 +604,68 @@
330 604
 		</div><!--modal-->
331 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,6 +683,11 @@
348 683
 
349 684
 <script>
350 685
 
686
+// Enable popovers
687
+$(function () {
688
+  $('[data-toggle="popover"]').popover();
689
+});
690
+
351 691
 		
352 692
 		["newExperience"].forEach(function(formName) {
353 693
 			
@@ -371,8 +711,8 @@
371 711
 			startDate.addEventListener('change', setEndDateRange);
372 712
 	
373 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,10 +18,15 @@ function handleSubmit(event, formName) {
18 18
 
19 19
 	// Fetch all input from form
20 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 32
 	// Construct request URL (make sure to use http or https accordingly)
@@ -42,6 +47,12 @@ function handleSubmit(event, formName) {
42 47
 		case "newQuestionnaire":
43 48
 			fullURI += "insertQuestionnaire.php";
44 49
 			break;
50
+// 		case "importQuestionnaire":
51
+// 			fullURI += "importQuestionnaire.php";
52
+// 			break;
53
+		case "duplicateQuestionnaire":
54
+			fullURI += "duplicateQuestionnaire.php";
55
+			break;			
45 56
 		case "newMoment":
46 57
 		 	fullURI += "insertMoment.php";
47 58
 		 	break;
@@ -94,7 +105,8 @@ function handleSubmit(event, formName) {
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 112
 	// Use fullURI to make POST request w/ jQuery,
@@ -105,6 +117,7 @@ function handleSubmit(event, formName) {
105 117
 	$.post(fullURI, fields)
106 118
 		.done(function(data, text) {
107 119
 				
120
+			// !!!!!! FOR DEBUGGING PURPOSES !!!!!!
108 121
 			console.log(data + "and" + text);
109 122
 
110 123
 			// Fetch needed elements
@@ -145,6 +158,7 @@ function handleSubmit(event, formName) {
145 158
 		})
146 159
 		.fail(function(request, status, error) {
147 160
 				
161
+			// !!!!!! FOR DEBUGGING PURPOSES !!!!!!
148 162
 			console.log(request.responseText);
149 163
 			console.log(status);
150 164
 			console.log(error);

+ 2
- 2
js/home.js View File

@@ -5,7 +5,7 @@
5 5
 // Target the input fields to be updated
6 6
 let startDate = document.querySelector('input[name=start]');
7 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,7 +70,7 @@ function setDuration() {
70 70
 	y = new Date(endDate.value);
71 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,7 +23,7 @@ function isJSON(item) {
23 23
 
24 24
 // MODAL SWITCHING FUNCTION (home.php & viewExperience.php)
25 25
 function nextModal(name) {
26
-	$('[data-toggle="tooltip"]').tooltip('hide');
26
+// 	$('[data-toggle="tooltip"]').tooltip('hide');
27 27
 	setTimeout(() => $(name).modal('show'), 100);
28 28
 }
29 29
 
@@ -56,18 +56,29 @@ let testDateField = document.createElement("input");
56 56
 testDateField.setAttribute("type", "date");
57 57
 
58 58
 if(testDateField.type != "date") {
59
+
60
+// 	console.log('Browser does not support input of type date, loading jQuery UI...');
59 61
 	
60 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 69
 	// Then load the calendar functionality
64 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 76
    	// Initialize date picker widget (on document.ready)
67 77
    	// Help: https://jqueryui.com/datepicker/#min-max
68 78
    	window.onload = () => {
69 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,9 +86,7 @@ if(testDateField.type != "date") {
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,16 +192,20 @@ subcategoriesString.addEventListener('change', function() {
192 192
 
193 193
 // For new moments, create the dropdowns for question selection
194 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,7 +76,46 @@
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,7 +49,7 @@
49 49
 			http_response_code(400);
50 50
 			echo json_encode(array("error" => "Please specify experience ID."));
51 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 53
 			http_response_code(400);
54 54
 			echo json_encode(array("error" => "Given experience ID ($experienceID) not in database."));
55 55
 			exit();
@@ -73,7 +73,7 @@
73 73
 		
74 74
 		
75 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 77
 		$resultExperience = mysqli_query($connection, $queryExperience);
78 78
 		$rowExperience = mysqli_fetch_assoc($resultExperience);
79 79
 		$calendarConfig->defaultDate = $rowExperience['start_date'];
@@ -98,7 +98,7 @@
98 98
 		
99 99
 		
100 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 102
 		$resultMoments = mysqli_query($connection, $queryMoments);
103 103
 		while($rowMoments = mysqli_fetch_assoc($resultMoments)) {
104 104
 		
@@ -123,7 +123,7 @@
123 123
 		
124 124
 		
125 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 127
 		$resultMilestones = mysqli_query($connection, $queryMilestones);
128 128
 		while($rowMilestones = mysqli_fetch_assoc($resultMilestones)) {
129 129
 			

+ 14
- 178
testFrontEnd.php View File

@@ -1,185 +1,21 @@
1
-<!DOCTYPE html>
2
-<html>
1
+<!doctype html>
2
+<html lang="en">
3 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 9
 </head>
70 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 20
 </body>
179
-</html>
180
-
181
-
182
-
183
-
184
-
185
-
21
+</html>

+ 1
- 1
users.php View File

@@ -24,7 +24,7 @@
24 24
             	<img src="./img/pen_800x800.png" alt="tania logo pen" width="25" height="25">
25 25
         	</a>
26 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 28
             	<a class="sign-out" href="./processes/logout.php">Sign Out</a>
29 29
         	</div>
30 30
     	</header>

+ 106
- 20
viewExperience.php View File

@@ -34,7 +34,6 @@
34 34
 		
35 35
 	}
36 36
 
37
-
38 37
 	include_once 'header.php';
39 38
 	
40 39
 ?>
@@ -47,6 +46,7 @@
47 46
             	<img src="./img/pen_800x800.png" alt="tania logo pen" width="25" height="25">
48 47
         	</a>
49 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 50
             	<a class="sign-out" href="./processes/logout.php">Sign Out</a>
51 51
         	</div>
52 52
     	</header>
@@ -107,7 +107,12 @@
107 107
 			<div class="container">
108 108
 		
109 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 116
 				</div><!--row-->
112 117
 			
113 118
 				<br>
@@ -265,6 +270,10 @@
265 270
 							// ELSE, DISPLAY A MESSAGE TO THE USER LETTING THEM KNOW THEY DON'T HAVE ONE
266 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 278
 						<table class="table table-hover table-striped table-responsive">
270 279
   							<thead>
@@ -272,11 +281,12 @@
272 281
   									<th style="text-align: center;"><h4>Moment</h4></th>
273 282
   									<th style="text-align: center;"><h4>Questions</h4></th>
274 283
   									<th style="text-align: center;"><h4>Date</h4></th>
284
+  									<th style="text-align: center;"><h4>Answer Rate</h4></th>
275 285
   								</tr>
276 286
   							</thead>
277 287
   							<tbody>
278 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 290
   									<td style="text-align: center;"><h5><?php echo $row4['title']; ?></h5></td>
281 291
   									<?php
282 292
   										$query5 = "SELECT * FROM subquestionnair_question WHERE `id_subquestionnair` = ".$row4['id'];
@@ -284,13 +294,32 @@
284 294
   									?>
285 295
   									<td style="text-align: center;"><h5><?php echo mysqli_num_rows($result5); ?></h5></td>
286 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 316
   								</tr>
288 317
   								<?php endwhile; ?>
289 318
   							</tbody>
290 319
   						</table>
291 320
   					
292 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 323
   						<?php endif; ?>
295 324
   							 
296 325
   						<br>
@@ -934,7 +963,7 @@
934 963
 
935 964
 
936 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 967
 			<div class='modal fade' id='Import' tabindex='-1' role='dialog' aria-labelledby='ImportLabel' aria-hidden='true'>
939 968
 				<div class='modal-dialog modal-dialog-centered modal-md' role='document'>
940 969
  					<div class='modal-content'>
@@ -947,7 +976,7 @@
947 976
 
948 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 981
 								<div class="row">
953 982
 									<div class="col-sm-12">
@@ -971,6 +1000,17 @@
971 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 1014
       					</div><!--modal-body-->
975 1015
      					
976 1016
      					<div class='modal-footer'>
@@ -981,13 +1021,13 @@
981 1021
     				</div><!--modal-content-->
982 1022
   				</div><!--modal-dialog-->
983 1023
 			</div><!--modal-->
984
-			
1024
+		</form>
985 1025
 			
986 1026
 			
987 1027
 			
988 1028
 			
989 1029
 		<!-- POPUP FOR DUPLICATE QUESTIONNAIRE -->
990
-		<form class='form-horizontal' action='processes/duplicateQuestionnaire.php' method='POST'>
1030
+		<form id="duplicateQuestionnaire" class='form-horizontal'>
991 1031
 			<div class='modal fade' id='Duplicate' tabindex='-1' role='dialog' aria-labelledby='DuplicateLabel' aria-hidden='true'>
992 1032
 				<div class='modal-dialog modal-dialog-centered' role='document'>
993 1033
  					<div class='modal-content'>
@@ -1004,6 +1044,18 @@
1004 1044
 							
1005 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 1059
 							<!-- FROM QUESTIONNAIRE -->
1008 1060
 							<label for="fromQuestionnaireID">Which Questionnaire:</label>
1009 1061
 							<?php
@@ -1057,6 +1109,22 @@
1057 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 1128
       					</div><!--modal-body-->
1061 1129
       					
1062 1130
       					<!-- SUBMIT OR CANCEL -->
@@ -1121,7 +1189,7 @@
1121 1189
 							<div class="form-group">
1122 1190
 								<label class="control-label col-sm-2">Date to Administer:</label>
1123 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 1193
 								</div>
1126 1194
 							</div>
1127 1195
 							
@@ -1188,9 +1256,13 @@
1188 1256
 		momentDescription.addEventListener('change', validateNewMoment);
1189 1257
 		momentDate.addEventListener('keyup', validateNewMoment);
1190 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 1268
 		// First modal's validation function
@@ -1204,7 +1276,13 @@
1204 1276
 			let validity = momentTitle.checkValidity();
1205 1277
 			validity &= momentDescription.checkValidity();
1206 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 1287
 			// Disabled if not valid, enabled otherwise
1210 1288
 			nextButton.disabled = !validity;
@@ -1237,10 +1315,10 @@
1237 1315
 						<hr><br>
1238 1316
 						
1239 1317
 						<!-- QUESTION -->
1240
-						<div id="qq1" >
1318
+						<div id="qq1">
1241 1319
 						
1242 1320
 							<div class="row">
1243
-								<div class="col col-sm-offset-1">
1321
+								<div class="col-sm-11 col-sm-offset-1">
1244 1322
 									<h4>Question 1</h4>
1245 1323
 								</div>
1246 1324
 							</div>
@@ -1256,11 +1334,11 @@
1256 1334
 									</div>
1257 1335
 								</div>
1258 1336
 							</div>
1259
-							
1260
-						</div>
1261
-						
1262
-						
1337
+
1263 1338
 						<br>
1339
+							
1340
+						</div><!--#qq-->						
1341
+
1264 1342
 						
1265 1343
 						 <div class="row">
1266 1344
  							<div class="col-sm-offset-9 col-sm-2">
@@ -1393,7 +1471,15 @@
1393 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 1484
 			var form = document.getElementById(formName);
1399 1485
 			
@@ -1415,7 +1501,7 @@ var calendar = new FullCalendar.Calendar(calendarElement, {
1415 1501
 	header: {
1416 1502
 		left: 'prev,next today',
1417 1503
 		center: 'title',
1418
-		right: 'dayGridMonth,timeGridWeek,timeGridDay'
1504
+		right: 'dayGridMonth,timeGridWeek'//,timeGridDay
1419 1505
 	},
1420 1506
 	defaultDate: document.getElementById('experience_start_date').value,
1421 1507
 	businessHours: true,

+ 9
- 0
viewMoment.php View File

@@ -52,6 +52,7 @@
52 52
             		<img src="./img/pen_800x800.png" alt="tania logo pen" width="25" height="25">
53 53
         		</a>
54 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 56
         		    <a class="sign-out" href="./processes/logout.php">Sign Out</a>
56 57
         		</div>
57 58
     		</header>
@@ -181,6 +182,14 @@
181 182
 								</div>
182 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 194
 							<br>
186 195
 

+ 1
- 0
viewQuestionnaire.php View File

@@ -52,6 +52,7 @@
52 52
             		<img src="./img/pen_800x800.png" alt="tania logo pen" width="25" height="25">
53 53
         		</a>
54 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 56
         		    <a class="sign-out" href="./processes/logout.php">Sign Out</a>
56 57
         		</div>
57 58
     		</header>