Skip to content

Commit

Permalink
updated the time code to refect the new view
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelpenne committed Feb 25, 2005
1 parent c022b49 commit ff2978c
Showing 1 changed file with 30 additions and 25 deletions.
55 changes: 30 additions & 25 deletions mod/lesson/lesson.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -652,46 +652,51 @@
/// CDC-FLAG /// /// CDC-FLAG ///


/// CDC-FLAG /// 6/14/04 -- This is the code updates the lesson time for a timed test /// CDC-FLAG /// 6/14/04 -- This is the code updates the lesson time for a timed test
// get time information for this user
if (!isteacher($course->id)) {
if (!$timer = get_records_select('lesson_timer', "lessonid = $lesson->id AND userid = $USER->id", 'starttime')) {
error('Error: could not find records');
} else {
$timer = array_pop($timer); // this will get the latest start time record
}
}
$outoftime = false; $outoftime = false;
if($lesson->timed) { if($lesson->timed) {
if(isteacher($course->id)) { if(isteacher($course->id)) {
echo "<p align=\"center\">".get_string("teachertimerwarning", "lesson")."</p>"; echo "<p align=\"center\">".get_string("teachertimerwarning", "lesson")."</p>";
} else { } else {
if (!$timer = get_record("lesson_timer", "lessonid", $lesson->id, "userid", $USER->id)) {
error("Error: could not find record");
}
if ((($timer->starttime + $lesson->maxtime * 60) - time()) > 0) { if ((($timer->starttime + $lesson->maxtime * 60) - time()) > 0) {
// code for the clock // code for the clock
print_simple_box_start("right", "150px", "#ffffff", 0); print_simple_box_start("right", "150px", "#ffffff", 0);
echo "<table border=\"0\" valign=\"top\" align=\"center\" class=\"generaltable\" width=\"100%\" cellspacing=\"0\">". echo "<table border=\"0\" valign=\"top\" align=\"center\" class=\"generaltable\" width=\"100%\" cellspacing=\"0\">".
"<tr><th valign=\"top\" class=\"generaltableheader\">".get_string("timeremaining", "lesson"). "<tr><th valign=\"top\" class=\"generaltableheader\">".get_string("timeremaining", "lesson").
"</th></tr><tr><td align=\"center\" class=\"generaltablecell\">"; "</th></tr><tr><td align=\"center\" class=\"generaltablecell\">";
echo "<script language=\"javascript\">\n"; echo "<script language=\"javascript\">\n";
echo "var starttime = ". $timer->starttime . ";\n"; echo "var starttime = ". $timer->starttime . ";\n";
echo "var servertime = ". time() . ";\n"; echo "var servertime = ". time() . ";\n";
echo "var testlength = ". $lesson->maxtime * 60 .";\n"; echo "var testlength = ". $lesson->maxtime * 60 .";\n";
echo "document.write('<SCRIPT LANGUAGE=\"JavaScript\" SRC=\"timer.js\"><\/SCRIPT>');\n"; echo "document.write('<SCRIPT LANGUAGE=\"JavaScript\" SRC=\"timer.js\"><\/SCRIPT>');\n";
echo "window.onload = function () { show_clock(); }\n"; echo "window.onload = function () { show_clock(); }\n";
echo "</script>\n"; echo "</script>\n";
echo "</td></tr></table>"; echo "</td></tr></table>";
print_simple_box_end(); print_simple_box_end();
echo "<br /><br /><br /><br />"; echo "<br /><br /><br /><br />";
} else { } else {
redirect("view.php?id=$cm->id&action=navigation&pageid=".LESSON_EOL."&outoftime=normal", get_string("outoftime", "lesson")); redirect("view.php?id=$cm->id&action=navigation&pageid=".LESSON_EOL."&outoftime=normal", get_string("outoftime", "lesson"));
} }
if ((($timer->starttime + $lesson->maxtime * 60) - time()) < 60 && !((($timer->starttime + $lesson->maxtime * 60) - time()) < 0)) { if ((($timer->starttime + $lesson->maxtime * 60) - time()) < 60 && !((($timer->starttime + $lesson->maxtime * 60) - time()) < 0)) {
echo "<p align=\"center\">".get_string("studentoneminwarning", "lesson")."</p>"; echo "<p align=\"center\">".get_string("studentoneminwarning", "lesson")."</p>";
} elseif (($timer->starttime + $lesson->maxtime * 60) < time()) { } elseif (($timer->starttime + $lesson->maxtime * 60) < time()) {
echo "<p align=\"center\">".get_string("studentoutoftime", "lesson")."</p>"; echo "<p align=\"center\">".get_string("studentoutoftime", "lesson")."</p>";
$outoftime = true; $outoftime = true;
} }
$newtime = new stdClass; }
$newtime->id = $timer->id; }
$newtime->lessontime = time(); // update the clock
if (!isteacher($course->id)) {
if (!update_record("lesson_timer", $newtime)) { $timer->lessontime = time();
error("Error: could not update lesson_timer table"); if (!update_record("lesson_timer", $timer)) {
} error("Error: could not update lesson_timer table");
} }
} }
/// CDC-FLAG /// /// CDC-FLAG ///
Expand Down

0 comments on commit ff2978c

Please sign in to comment.