dirroot/mod/attendance/lib.php"); // error_reporting(E_ALL); optional_variable($id); // Course Module ID, or optional_variable($a); // attendance ID if ($id) { if (! $cm = get_record("course_modules", "id", $id)) { error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { error("Course is misconfigured"); } if (! $attendance = get_record("attendance", "id", $cm->instance)) { error("Course module is incorrect"); } } else { if (! $attendance = get_record("attendance", "id", $a)) { error("Course module is incorrect"); } if (! $course = get_record("course", "id", $attendance->course)) { error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("attendance", $attendance->id, $course->id)) { error("Course Module ID was incorrect"); } } require_login($course->id); add_to_log($course->id, "attendance", "view", "view.php?id=$cm->id", $attendance->id, $cm->id); /// Print the page header if ($course->category) { $navigation = "id\">$course->shortname ->"; } $strattendances = get_string("modulenameplural", "attendance"); $strattendance = get_string("modulename", "attendance"); print_header("$course->shortname: $attendance->name", "$course->fullname", "$navigation id>$strattendances -> $attendance->name", "", "", true, update_module_button($cm->id, $course->id, $strattendance), navmenu($course, $cm)); /// Print the main part of the page // adaptation of mod code to view code needs this: $form = $attendance; if (isteacher($course->id)) { $rolls = get_records("attendance_roll", "dayid", $form->id); } else if (!$cm->visible) { notice(get_string("activityiscurrentlyhidden")); print_footer($course); exit; } else if (isstudent($course->id)) { // visible and a student $rolls = get_records("attendance_roll", "dayid", $form->id, "userid", $USER->id); } else { notice(get_string("noviews", "attendance")); print_footer($course); exit; } if ($rolls) { foreach ($rolls as $roll) { $sroll[$roll->userid][$roll->hour]->status=$roll->status; $sroll[$roll->userid][$roll->hour]->notes=$roll->notes; } } // 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 $strviewall = get_string("viewall", "attendance"); $strviewweek = get_string("viewweek", "attendance"); echo ""; echo ""; echo "
id."\">"; echo "$strviewall
id."\">"; echo "$strviewweek


"; // this is the wrapper table echo ""; echo "
"; // this is the main table echo ""; // print the date headings at the top of the table echo "\n"; // put notes for the date in the date heading $notes = ($form->notes != "") ? ":
".$form->notes : ""; echo "\n"; echo (($form->hours > 1) ? "\n" : ""); echo "\n"; // print the second level headings with name and possibly hour numbers echo "\n"; echo "\n"; echo "\n"; // generate the headers for the attendance hours if ($form->hours > 1) { for($i=1;$i<=$form->hours;$i++) { echo "\n"; } echo "\n"; } echo "\n"; // 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 if (isteacher($course->id)){ $students = attendance_get_course_students($form->course, "u.lastname ASC"); } else { // must be a student $students[0] = get_user_info_from_db("id", $USER->id); } $i=0; $A = get_string("absentshort","attendance"); $T = get_string("tardyshort","attendance"); $P = get_string("presentshort","attendance"); if ($students) foreach ($students as $student) { echo "\n"; echo "\n"; $studentid=(($student->idnumber != "") ? $student->idnumber : " "); echo "\n"; $abs=$tar=0; for($j=1;$j<=$form->hours;$j++) { // set the attendance defaults for each student if ($sroll[$student->id][$j]->status == 1) {$status=$T;$tar++;} elseif ($sroll[$student->id][$j]->status == 2) {$status=$A;$abs++;} else {$status=$P;} echo "\n"; } /// for loop if ($form->hours > 1) { $tot=attendance_tally_overall_absences_fraction($abs,$tar); echo "\n"; } } /// ending for the table echo "
". " hours. "\" nowrap class=\"generaltableheader\">". userdate($form->day,get_string("strftimedateshort")).$notes." 
Last NameFirst NameID".$i."total"; } else { echo " 
".$student->lastname."".$student->firstname."".$studentid."".$status."".$tot."
\n"; /// print the miscellaneous settings information before the attendance roll echo "
". "
"; // this is the main table echo ""; echo"\n"; echo"\n"; echo"\n"; echo"\n"; echo"\n"; echo"\n"; if ($form->grade == "1") { echo"\n"; echo"\n"; } echo "
". get_string("dynsectionshort","attendance").":". (($form->dynsection=="1")?"Yes":"No")."
". get_string("autoattendshort","attendance").":". (($form->autoattend=="1")?"Yes":"No")."
". get_string("gradeshort","attendance").":". (($form->grade=="1")?"Yes":"No")."
". get_string("maxgradeshort","attendance").":". $form->maxgrade."
\n"; /// Finish the page print_footer($course); ?>