-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenterSession.php
executable file
·376 lines (331 loc) · 16 KB
/
enterSession.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
<?php
require_once('control/startSession.php');
require_once("control/connection.php");
include('classes/InstructionSession.php');
//djc added 2014
include('classes/User.php');
if (!isset($_GET['lite'])) {
$page_title = 'Enter Session Data';
include('includes/header.php');
} else {
$jsOutput = '';
}
$currentSession = new InstructionSession();
if (isset($_GET["sesdID"])) {
$currentSession->loadSession($_GET["sesdID"]);
}
if (isset($_GET['action'])){
$action = $_GET['action'];
} else {
if (isset($_GET['sesdID'])) {
$action = 'view';
} else {
$action = 'insert';
}
}
?>
<form id="assessmentForm" method="post" action="submitData.php">
<?php /****** Librarian dropdown ******/ ?>
<div id="librarianSelect" class="item ui-corner-all">
<h2 id="librarianHeader">Librarian</h2>
<div class="selectBox">
<div class="floatLeft">
<?php
$thisUser = new User($_SESSION['userID'], $_SESSION['userName'], $_SESSION['roleName']);
$_SESSION['librarianID'] = $thisUser->getLibrarianID();
echo '<select id="librarianID" name="librarianID" required title="You must select a librarian."' . ($_SESSION['roleName'] == 'user' ? 'disabled="disabled"' : '') . '>';
$reportLibID = $currentSession->getLibrarianID();
echo '<option value="" ' . ((!$reportLibID && $_SESSION['roleName'] == 'admin') ? 'selected="selected"' : '') . '> Please select:</option>';
$query = "select l.libmID as ID, p.ppleFName as FName, p.ppleLName as LName, l.libmStatus as Status " .
"from people p, librarianmap l where p.ppleID=l.libmppleID;";
$result = mysqli_query($dbc, $query) or die('Error querying for librarians: ' . mysqli_error($dbc));
while ($row = mysqli_fetch_assoc($result)) {
if ($row['Status'] != 'active') { continue; }
$id = $row['ID'];
$librarianName = $row['FName'] . ' ' . $row['LName'];
if (($reportLibID == $id) || (!$reportLibID && $_SESSION['librarianID'] == $id)) {
echo '<option id="libm' . $id . '" value="' . $id . '" selected="selected">' . $librarianName . '</option>';
} else {
echo '<option id="libm' . $id . '" value="' . $id . '">' . $librarianName . '</option>';
}
}
mysqli_free_result($result);
?>
</select>
<br>
<?php
//add hidden input to compensate for cases where select is disabled
if ($_SESSION['roleName']=='user'){
echo "<input type='hidden' name='librarianID' value='".$_SESSION['librarianID']."' />";
}
echo '<input type="checkbox" id="fellowPresent" name="fellowPresent"'.(($currentSession->getFellowPresent()=='yes')?' checked':'').'>
<label for="fellowPresent">Fellow was present</label>';
?>
</div>
</div>
</div>
<?php /****** Course information block ******/ ?>
<div id="courseSelect" class="item">
<h2 id="courseSelectHeader">Course ID-Selection </h2>
<div class="coursePrefixColumn">
<h4>Course Prefix</h4>
<div id="selectBox">
<div id="coursePrefixSelectContainer" class="floatLeft">
<select id="coursePrefixID" name="coursePrefixID" required title="You must select a course prefix.">
<option value="" > </option>
<?php
$query = "select crspID as ID, crspName as Name from courseprefix";
$result = mysqli_query($dbc, $query) or die('Mr. Christian!- query issues.' . mysqli_error($dbc));
if (!$result) { echo "this is an outrage: " . mysqli_error($dbc) . "\n"; }
$crspID = $currentSession->getCoursePrefixID();
while ($row = mysqli_fetch_assoc($result)) {
$id = $row['ID'];
$Name = trim($row['Name']);
if ($crspID == $id) {
echo '<option id="crsp' . $id . '" value="' . $id . '" selected="selected" >' . $Name . '</option>';
} else {
echo '<option id="crsp' . $id . '" value="' . $id . '">' . $Name . '</option>';
}
}
mysqli_free_result($result);
?>
</select>
</div>
</div>
</div>
<div class="courseNumberColumn">
<h4>Number</h4> <div id="courseNumberContainer"><input id="courseNumber" name="courseNumber" required type="number" size="15" value="<?php echo $currentSession->getCourseNumber(); ?>" tyitle="You must have a course number." /></div>
</div>
<div class="courseSectionColumn">
<h4>Section</h4> <div id="courseSectionContainer"><input id="courseSection" name="courseSection" required type="number" size="10" value="<?php if ($action!='duplicate'){echo $currentSession->getCourseSection();} ?>" title="You must provide a section number." /></div>
</div>
<div class="courseTitleColumn">
<h4>Title</h4> <div id="courseTitleContainer"><input id="courseTitle" name="courseTitle" required type="text" size="15" value="<?php echo $currentSession->getCourseTitle(); ?>" title="You must have a course title." /></div>
</div>
<div class="courseSessionColumn">
<h4>Session #</h4>
<div id="sessionNumberContainer">
<select name="sessionNumber" id="sessionNumber" required title="You must select a session number." >
<?php $sessionNumber = $currentSession->getSessionNumber(); ?>
<option value="I" <?php if($sessionNumber === "I") echo 'selected="selected"'; ?> >I</option>
<option value="II" <?php if($sessionNumber === "II") echo 'selected="selected"'; ?> >II</option>
<option value="III" <?php if($sessionNumber === "III") echo 'selected="selected"'; ?> >III</option>
<option value="Visit" <?php if($sessionNumber === "Visit") echo 'selected="selected"'; ?> >Visit</option>
<option value="Other" <?php if($sessionNumber === "Other") echo 'selected="selected"'; ?> >Other</option>
</select>
</div>
</div>
<br />
</div>
<?php /****** Faculty text box ******/ ?>
<div id="facultySelect" class="item">
<h2>Faculty name <span id="facultyComment" class="commentDiv" ></span></h2> <!-- classroom faculty -->
<div id="facultySelectContainer" >
<span class="courseInfo faculty"></span><span class="courseSection faculty"></span>
<input id="faculty" class="faculty" required name="faculty" type="text" value="<?php echo $currentSession->getFaculty(); ?>" title="You must enter the faculty name." />
</div>
</div>
<?php /****** Location dropdown ******/ ?>
<div id="locationSelect" class="item ui-corner-all">
<h2>Location <span id="locationComment" class="commentDiv" ></span></h2> <!-- classroom -->
<div class="selectBox">
<div id="locationSelectContainer" class="floatLeft">
<span class="courseInfo location"></span><span class="courseSection location"></span>
<select id="locationID" name="locationID" class="location" required title="You must select a location." >
<option class="location" value=""> Please select:</option>
<?php
$query = "select locaID as ID, locaname as Name from location";
$result = mysqli_query($dbc, $query) or die('crappy crustacean!- query issues.' . mysqli_error($dbc));
if (!$result) { echo "this is an outrage: " . mysqli_error($dbc) . "\n"; }
$location = $currentSession->getLocation();
while ($row = mysqli_fetch_assoc($result)) {
$id = $row['ID'];
$Name = $row['Name'];
if ($location == $id) {
echo '<option class="location" value="' . $id . '" selected="selected">' . $Name . '</option>';
} else {
echo '<option class="location" value="' . $id . '" >' . $Name . '</option>';
}
}
mysqli_free_result($result);
?>
</select>
</div>
</div>
</div>
<?php /****** Date picker ******/ ?>
<div id="dateSelect" class="item">
<h2>Date of session <span id="dateTimeComment" class="commentDiv"></span></h2>
<div id="dateSelectContainer" class="floatLeft">
<span class="courseInfo datepicker"></span><span class="courseSection datepicker"></span>
<?php $date = $currentSession->getDateOfSession(); ?>
<input type="text" id="datePicker" class="datepicker" required name="dateOfSession" value="<?php if($date) {echo date("m/d/y", strtotime($date)); } ?>" title="You must enter the date of the session." />
<!-- <input type="text" name="timeOfSession" id="timepicker" /> -->
</div>
</div>
<?php /****** Session length dropdown ******/ ?>
<div id="lengthSelect" class="item ui-corner-all">
<h2>Session Length <span id="lengthComment" class="commentDiv"></span></h2>
<div class="selectBox">
<div id="lengthSelectContainer" class="floatLeft">
<span class="courseInfolength"></span><span class="courseSection length"></span>
<select id="lengthID" name="lengthID" required title="You must select a session length." >
<option value="" selected="selected"> Please select:</option>
<?php
$query = "select seslID as ID, seslName as Name from sesslength";
$result = mysqli_query($dbc, $query) or die('Victoria! I know your secret!- query issues.' . mysqli_error($dbc));
if (!$result) { echo "this is an outrage: " . mysqli_error($dbc) . "\n"; }
$length = $currentSession->getLengthOfSessionID();
while ($row = mysqli_fetch_assoc($result)) {
$id = $row['ID'];
$Name = $row['Name'];
if ($length == $id) {
echo '<option id="sesl' . $id . '" value="' . $id . '" selected="selected">' . $Name . '</option>';
} else {
echo '<option id="sesl' . $id . '" value="' . $id . '" >' . $Name . '</option>';
}
}
mysqli_free_result($result);
?>
</select>
</div>
</div>
</div>
<?php /****** Number of students text box ******/ ?>
<div id="numberSelect" class="item ui-corner-all">
<h2>Number of students<span id="numberStudentsComment" class="commentDiv"></span></h2>
<div id="numberOfStudentsContainer">
<span class="courseInfostudent"></span><span class="courseSection student"></span>
<input id="numberOfStudents" required title="You must enter the number of students in session."
name="numberOfStudents" type="number" value="<?php echo $currentSession->getNumberOfStudents(); ?>"/>
</div>
</div>
<?php /****** Resources checkboxes ******/ ?>
<?php /*
<div id="resourcesSelect" class="item ui-corner-all">
<h2>Resources introduced <span id="resourcesComment" class="commentDiv"></span></h2>
<div class="selectBox">
<div id="resourcesSelectContainer" class="floatLeft">
<span class="courseInforesourcesBox"></span><span class="courseSection resourcesBox"></span><br />
<?php
if(isset($_GET['sesdID'])) {
$query = "select rsrpID, rsrpName, rsrirsrpID from resourcepool rp
left outer join resourcesintroduced ri
on (ri.rsrirsrpID = rp.rsrpID and ri.rsrisesdID = ?)
where rp.rsrpActive='yes'";
$stmt = mysqli_prepare($dbc, $query);
mysqli_stmt_bind_param($stmt, "i", $_GET['sesdID']);
mysqli_stmt_execute($stmt) or die('Error querying for resource checkboxes: ' . mysqli_error($dbc));
mysqli_stmt_store_result($stmt);
mysqli_stmt_bind_result($stmt, $id, $Name, $resourceID);
$isNone='none'; // Add 'none' class for first row
while (mysqli_stmt_fetch($stmt)) {
$resourceID ? $checked = "checked" : $checked = "";
echo '<input class="resourcesBox '.$isNone.'" title="You must choose at least 1 resource (or \'None\') per session" type="checkbox" ' . $checked . ' name="resourcesIntroduced[]" value="' . $id . '" /><span class="resourcesbox">' . $Name . '</span><br class="resourcesbox" />';
$isNone='notNone'; // Add notNone class for subsequent rows
}
mysqli_stmt_free_result($stmt);
} else {
$query = "select rsrpID as ID, rsrpName as Name from resourcepool where rsrpActive='yes'";
$result = mysqli_query($dbc, $query) or die('Error querying for resource checkboxes: ' . mysqli_error($dbc));
$isNone='none'; // Add 'none' class for first row
while ($row = mysqli_fetch_assoc($result)) {
$id = $row['ID'];
$Name = $row['Name'];
echo '<input class="resourcesBox '.$isNone.'" title="You must choose at least 1 resource (or \'None\') per session" type="checkbox" name="resourcesIntroduced[]" value="' . $id . '" /><span class="resourcesbox">' . $Name . '</span><br class="resourcesbox" />';
$isNone='notNone'; // Add notNone class for subsequent rows
}
mysqli_free_result($result);
}
?>
</div>
</div>
</div>
*/ ?>
<?php /****** Outcomes checkboxes ******/ ?>
<div id="outcomesSelect" class="item ui-corner-all">
<h2>Outcomes taught</h2>
<div id="outcomesSelectContainer">
<?php
// Don't allow changing outcomes if they've been assessed
if ($currentSession->getAssessed() == 'yes') {
$disabled = 'disabled';
echo '<span style="color: #78f;">These outcomes have already been assessed. Editing is disabled.</span>';
} else {
$disabled = '';
}
$lastheading = 0;
$row = array();
$stmt = mysqli_prepare($dbc, '
select oh.otchID, oh.otchName, od.otcdID, od.otcdName, ot.otctsesdID
from outcomedetail od
left join outcomeheading oh on oh.otchID = od.otcdotchID
left join outcomestaught ot on ot.otctotcdID = od.otcdID and ot.otctsesdID = ?
order by oh.otchID, od.otcdName
');
mysqli_stmt_bind_param($stmt, 'i', $_GET['sesdID']);
mysqli_stmt_execute($stmt) or die('Failed to get outcomes: ' . mysqli_error($dbc));
mysqli_stmt_store_result($stmt);
mysqli_stmt_bind_result($stmt, $row['otchID'], $row['otchName'], $row['otcdID'], $row['otcdName'], $row['checked']);
while (mysqli_stmt_fetch($stmt)) {
if ($row['otchID'] != $lastheading) {
echo '<br><h3>'.$row['otchID'].". ".$row['otchName'].'</h3>';
$lastheading = $row['otchID'];
}
if ($row['checked']) { $checked = 'checked'; } else { $checked = ''; }
echo '<label><input type="checkbox" name="outcomesTaught[]" class="outcomesBox" value="'.$row['otcdID'].'" '.$checked.' '.$disabled.'>'.$row['otcdName'].'</label><br>';
}
mysqli_stmt_free_result($stmt);
?>
</div>
</div>
<?php /****** Notes field ******/ ?>
<div id="commentSelect" class="item">
<h2>Comments/Notes</h2>
<div id="noteSelectContainer">
<span class="courseInfonotebox"></span><span class="courseSection notebox"></span><br />
<textarea class="notebox optional" rows="4" cols="60" id="sessionNote" name="sessionNote" title="Notes are optional"><?php echo $currentSession->getSessionNote() ?></textarea>
</div>
</div>
<?php /****** Submit button ******/ ?>
<?php
if (isset($_GET['sesdID'])) {
$session = $_GET['sesdID'];
} else {
if ($action != 'insert') die('Error: Trying to perform a non-insert action without session ID!');
$session = null;
}
switch ($action) {
case 'insert':
case 'duplicate':
$submitText='Add session';
break;
case 'edit':
$submitText='Update session';
break;
case 'view':
default:
$submitText='';
break;
}
if ($submitText) {
echo '<div id="submitButtonDiv" class="item ui-corner-all ">
<h2>Complete form: </h2>
<div class="selectBox">
<div id="completionStatus"></div>
<div class="floatLeft">
<input type="hidden" name="action" value="'.$action.'"/>
<input type="hidden" name="sesdID" value="'.$session.'"/>
<input id="submitButton" type="submit" name="submit" value="'.$submitText.'"/>
</div>
</div>
</div>';
} // else, no button (view/unknown action)
?>
</form>
<br />
<?php
$jsOutput .= '//$(document).ready( function(){noneOrSome(); checkCompletion();} );';
$jsOutput .= '$("#numberOfStudents").spinner();';
if (!isset($_GET['lite'])) { include('includes/footer.php'); }
?>