2003-09-16 05:33:54 +00:00
|
|
|
<!-- This page defines the form to create or edit an instance of the attendance module -->
|
|
|
|
<!-- It is used from /course/mod.php. The whole instance is available as $form. -->
|
|
|
|
|
|
|
|
<!-- RJJ I'm using inline CSS styles for some stuff in this page because I want to centralize -->
|
|
|
|
<!-- the logic and styles in a single directory -->
|
2003-09-17 14:37:42 +00:00
|
|
|
<?php @include_once("$CFG->dirroot/mod/attendance/lib.php")
|
2003-09-16 05:33:54 +00:00
|
|
|
//require_once("lib.php")
|
|
|
|
?>
|
2003-09-17 14:37:42 +00:00
|
|
|
<FORM name="form" method="post" action="<?=$ME ?>">
|
2003-09-16 05:33:54 +00:00
|
|
|
<CENTER>
|
2003-09-17 14:37:42 +00:00
|
|
|
<INPUT type="submit" value="<? print_string("savechanges") ?>">
|
|
|
|
<INPUT type="submit" name="cancel" value="<? print_string("cancel") ?>">
|
2003-09-16 05:33:54 +00:00
|
|
|
<TABLE cellpadding=5>
|
|
|
|
|
2003-09-17 14:37:42 +00:00
|
|
|
<!-- <? $options[0] = get_string("no"); $options[1] = get_string("yes"); ?> -->
|
2003-09-16 05:33:54 +00:00
|
|
|
<!-- <TR valign=top> -->
|
2003-09-17 14:37:42 +00:00
|
|
|
<!-- <TD align=right><P><B><? print_string("takeroll", "attendance") ?>:</B></P></TD> -->
|
|
|
|
<!-- <TD align=left><? choose_from_menu($options, "roll", $form->roll, "") ?></td> -->
|
2003-09-16 05:33:54 +00:00
|
|
|
<!-- </tr> -->
|
|
|
|
|
|
|
|
<TR valign=top>
|
2003-09-17 14:37:42 +00:00
|
|
|
<TD align=right><P><B><?php print_string("dayofroll", "attendance") ?>:</B></P></TD>
|
|
|
|
<TD colspan="3"><?php print_date_selector("theday", "themonth", "theyear", $form->day) ?></TD>
|
2003-09-16 05:33:54 +00:00
|
|
|
</TR>
|
|
|
|
<tr valign=top>
|
2003-09-17 14:37:42 +00:00
|
|
|
<TD align="right"><P><B><?php print_string("dynamicsection", "attendance") ?>:</B></P></TD>
|
2003-09-16 05:33:54 +00:00
|
|
|
<TD align="left">
|
2003-09-17 14:37:42 +00:00
|
|
|
<input type="checkbox" name="dynsection" <?php echo !empty($form->dynsection) ? 'checked' : '' ?> >
|
2003-09-16 05:33:54 +00:00
|
|
|
</TD>
|
|
|
|
</tr>
|
2003-09-17 14:37:42 +00:00
|
|
|
<?php // starting with 2 to allow for the nothing value in choose_from_menu to be the default of 1
|
2003-09-16 05:33:54 +00:00
|
|
|
for ($i=2;$i<=24;$i++){ $opt[$i] = $i; } ?>
|
|
|
|
<TR valign=top>
|
2003-09-17 14:37:42 +00:00
|
|
|
<TD align=right><P><B><?php print_string("hoursinclass", "attendance") ?>:</B></P></TD>
|
|
|
|
<TD colspan="3" align="left"><?php choose_from_menu($opt, "hours", $form->hours, "1","","1") ?></td>
|
2003-09-16 05:33:54 +00:00
|
|
|
</tr>
|
|
|
|
<tr valign=top>
|
2003-09-17 14:37:42 +00:00
|
|
|
<td align=right><p><b><?php print_string("notes", "attendance") ?>:</b></p></td>
|
2003-09-16 05:33:54 +00:00
|
|
|
<td colspan="3">
|
2003-09-17 14:37:42 +00:00
|
|
|
<input type="text" name="notes" size=60 value="<?php p($form->notes) ?>">
|
2003-09-16 05:33:54 +00:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</TABLE>
|
|
|
|
|
|
|
|
|
2003-09-17 14:37:42 +00:00
|
|
|
<?php // if we're modifying an existing instance of attendance instead
|
2003-09-16 05:33:54 +00:00
|
|
|
// of creating a new one
|
|
|
|
if ($form->id) {
|
|
|
|
// get the list of attendance records for all hours of the given day and
|
|
|
|
// put it in the array for use in the attendance table
|
|
|
|
$rolls = get_records("attendance_roll", "dayid", $form->id);
|
2003-09-17 14:37:42 +00:00
|
|
|
if ($rolls) {
|
|
|
|
foreach ($rolls as $roll) {
|
|
|
|
$sroll[$roll->userid][$roll->hour]->status=$roll->status;
|
|
|
|
$sroll[$roll->userid][$roll->hour]->notes=$roll->notes;
|
|
|
|
}
|
|
|
|
}
|
2003-09-16 05:33:54 +00:00
|
|
|
// get the list of students along with student ID field
|
|
|
|
// get back array of stdclass objects in sorted order, with members:
|
|
|
|
// id, username,firstname,lastname,maildisplay,mailformat,email,city,country,
|
|
|
|
// lastaccess,lastlogin,picture (picture is null, 0, or 1), idnumber
|
|
|
|
// build the table for attendance roll
|
|
|
|
// this is the wrapper table
|
|
|
|
echo "<table align=\"center\" width=\"80\" class=\"generalbox\"".
|
|
|
|
"border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>".
|
|
|
|
"<td bgcolor=\"#ffffff\" class=\"generalboxcontent\">";
|
|
|
|
// this is the main table
|
|
|
|
echo "<table width=\"100%\" border=\"0\" valign=\"top\" align=\"center\" ".
|
|
|
|
"cellpadding=\"5\" cellspacing=\"1\" class=\"generaltable\">";
|
|
|
|
if ($form->hours >1) {
|
|
|
|
echo "<tr><th valign=\"top\" align=\"right\" colspan=\"3\" nowrap class=\"generaltableheader\">".
|
|
|
|
"Hours:</th>\n";
|
|
|
|
for($i=1;$i<=$form->hours;$i++) {
|
|
|
|
echo "<th valign=\"top\" align=\"center\" colspan=\"3\" nowrap class=\"generaltableheader\">".
|
|
|
|
"$i</th>\n";
|
|
|
|
}
|
|
|
|
echo "</tr>\n";
|
|
|
|
} // if more than one hour for each day
|
|
|
|
echo "<tr><th valign=\"top\" align=\"left\" nowrap class=\"generaltableheader\">Last Name</th>\n";
|
|
|
|
echo "<th valign=\"top\" align=\"left\" nowrap class=\"generaltableheader\">First Name</th>\n";
|
|
|
|
echo "<th valign=\"top\" align=\"left\" nowrap class=\"generaltableheader\">ID</th>\n";
|
|
|
|
$P=get_string("presentshort","attendance");
|
|
|
|
$T=get_string("tardyshort","attendance");
|
|
|
|
$A=get_string("absentshort","attendance");
|
|
|
|
// generate the headers for the attendance hours
|
|
|
|
for($i=1;$i<=$form->hours;$i++) {
|
|
|
|
echo "<th valign=\"top\" align=\"center\" nowrap class=\"generaltableheader\">".$P."</th>\n";
|
|
|
|
echo "<th valign=\"top\" align=\"center\" nowrap class=\"generaltableheader\">".$T."</th>\n";
|
|
|
|
echo "<th valign=\"top\" align=\"center\" nowrap class=\"generaltableheader\">".$A."</th>\n";
|
|
|
|
}
|
|
|
|
echo "</tr>\n";
|
|
|
|
$table->head = array("Last Name","First Name","ID",
|
|
|
|
get_string("presentlong","attendance"),
|
|
|
|
get_string("tardylong","attendance"),
|
|
|
|
get_string("absentlong","attendance"));
|
|
|
|
$table->align = array("left", "left", "left", "center","center","center");
|
|
|
|
$table->wrap = array("nowrap", "nowrap", "nowrap", "nowrap", "nowrap", "nowrap");
|
|
|
|
$table->width = "80";
|
|
|
|
|
|
|
|
$students = attendance_get_course_students($form->course, "u.lastname ASC");
|
|
|
|
$i=0;
|
|
|
|
foreach ($students as $student) {
|
|
|
|
echo "<tr><td align=\"left\" nowrap class=\"generaltablecell\" style=\"border-top: 1px solid;\">".$student->lastname."</td>\n";
|
|
|
|
echo "<td align=\"left\" nowrap class=\"generaltablecell\" style=\"border-top: 1px solid;\">".$student->firstname."</td>\n";
|
|
|
|
echo "<td align=\"left\" nowrap class=\"generaltablecell\" style=\"border-top: 1px solid;\">".$student->idnumber."</td>\n";
|
|
|
|
for($j=1;$j<=$form->hours;$j++) {
|
|
|
|
// set the attendance defaults for each student
|
|
|
|
$r1c=$r2c=$r3c=" ";
|
2003-09-19 04:24:28 +00:00
|
|
|
$rollstatus = (($form->edited==0)?$CFG->attendance_default_student_status:$sroll[$student->id][$j]->status);
|
|
|
|
if ($rollstatus==1) {$r2c="checked";}
|
|
|
|
elseif ($rollstatus==2) {$r3c="checked";}
|
|
|
|
else {$r1c="checked";}
|
|
|
|
$radio1="<input type=\"radio\" name=\"student_".$student->id."_".$j."\" value=\"0\" ".$r1c.">";
|
2003-09-16 05:33:54 +00:00
|
|
|
$radio2="<input type=\"radio\" name=\"student_".$student->id."_".$j."\" value=\"1\" ".$r2c.">";
|
2003-09-19 04:24:28 +00:00
|
|
|
$radio3="<input type=\"radio\" name=\"student_".$student->id."_".$j."\" value=\"2\" ".$r3c.">";
|
|
|
|
echo "<td align=\"left\" nowrap class=\"generaltablecell\" style=\"border-left: 1px dotted; border-top: 1px solid;\">".$radio1."</td>\n";
|
|
|
|
echo "<td align=\"left\" nowrap class=\"generaltablecell\" style=\"border-top: 1px solid;\">".$radio2."</td>\n";
|
|
|
|
echo "<td align=\"left\" nowrap class=\"generaltablecell\" style=\"border-top: 1px solid;\">".$radio3."</td>\n";
|
2003-09-16 05:33:54 +00:00
|
|
|
} // for loop
|
|
|
|
echo "</tr>\n";
|
|
|
|
// $radio1="<input type=\"radio\" name=\"student_".$student->id."\" value=\"0\" checked>";
|
|
|
|
// $radio2="<input type=\"radio\" name=\"student_".$student->id."\" value=\"1\">";
|
|
|
|
// $radio3="<input type=\"radio\" name=\"student_".$student->id."\" value=\"2\">";
|
|
|
|
// $table->data[$i]=array($student->lastname, $student->firstname,
|
|
|
|
// $student->idnumber, $radio1,$radio2,$radio3);
|
|
|
|
// $i++;
|
|
|
|
}
|
|
|
|
// doing the table manually now
|
|
|
|
// print_table($table);
|
|
|
|
// ending for both the tables
|
|
|
|
echo "</table></td></tr></table>\n";
|
|
|
|
} // if ($form->id)
|
|
|
|
?>
|
|
|
|
<!-- These hidden variables are always the same -->
|
2003-09-17 14:37:42 +00:00
|
|
|
<INPUT type="hidden" name=course value="<?php p($form->course) ?>">
|
|
|
|
<INPUT type="hidden" name=coursemodule value="<?php p($form->coursemodule) ?>">
|
|
|
|
<INPUT type="hidden" name=section value="<?php p($form->section) ?>">
|
|
|
|
<INPUT type="hidden" name=module value="<?php p($form->module) ?>">
|
|
|
|
<INPUT type="hidden" name=modulename value="<?php p($form->modulename) ?>">
|
|
|
|
<INPUT type="hidden" name=instance value="<?php p($form->instance) ?>">
|
|
|
|
<INPUT type="hidden" name=mode value="<?php p($form->mode) ?>">
|
2003-09-16 05:33:54 +00:00
|
|
|
<BR />
|
2003-09-17 23:46:53 +00:00
|
|
|
<?php
|
|
|
|
echo "<a href=\"../mod/attendance/add.php?id=".$form->course . "§ion=".$form->section ."\">Add multiple rolls</a><br /><br />";
|
|
|
|
?>
|
2003-09-17 14:37:42 +00:00
|
|
|
<INPUT type="submit" value="<?php print_string("savechanges") ?>">
|
|
|
|
<INPUT type="submit" name="cancel" value="<?php print_string("cancel") ?>">
|
2003-09-16 05:33:54 +00:00
|
|
|
</CENTER>
|
|
|
|
</FORM>
|