diff --git a/mod/lesson/lesson.php b/mod/lesson/lesson.php index fda139d8853..0a14e049399 100644 --- a/mod/lesson/lesson.php +++ b/mod/lesson/lesson.php @@ -652,32 +652,37 @@ /// CDC-FLAG /// /// 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; if($lesson->timed) { if(isteacher($course->id)) { echo "

".get_string("teachertimerwarning", "lesson")."

"; } 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) { // code for the clock - print_simple_box_start("right", "150px", "#ffffff", 0); - echo "". - "
".get_string("timeremaining", "lesson"). - "
"; - echo "\n"; - echo "
"; - print_simple_box_end(); - echo "



"; + print_simple_box_start("right", "150px", "#ffffff", 0); + echo "". + "
".get_string("timeremaining", "lesson"). + "
"; + echo "\n"; + echo "
"; + print_simple_box_end(); + echo "



"; } 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)) { echo "

".get_string("studentoneminwarning", "lesson")."

"; @@ -685,13 +690,13 @@ echo "

".get_string("studentoutoftime", "lesson")."

"; $outoftime = true; } - $newtime = new stdClass; - $newtime->id = $timer->id; - $newtime->lessontime = time(); - - if (!update_record("lesson_timer", $newtime)) { - error("Error: could not update lesson_timer table"); - } + } + } + // update the clock + if (!isteacher($course->id)) { + $timer->lessontime = time(); + if (!update_record("lesson_timer", $timer)) { + error("Error: could not update lesson_timer table"); } } /// CDC-FLAG ///