From 8888882af4fc80e64860322686c9e187625e3a1f Mon Sep 17 00:00:00 2001 From: mark-nielsen Date: Sat, 29 Dec 2007 22:18:19 +0000 Subject: [PATCH] Merging fix for MDL-12605 from MOODLE_19_STABLE --- lang/en_utf8/lesson.php | 2 -- mod/lesson/action/continue.php | 36 ++++++++++++++-------------------- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/lang/en_utf8/lesson.php b/lang/en_utf8/lesson.php index 92cb254043..8b2b1acbcf 100644 --- a/lang/en_utf8/lesson.php +++ b/lang/en_utf8/lesson.php @@ -203,7 +203,6 @@ $string['or'] = 'OR'; $string['ordered'] = 'Ordered'; $string['other'] = 'Other'; $string['outof'] = 'Out of $a'; -$string['outoftime'] = 'Out of time'; $string['overview'] = 'Overview'; $string['page'] = 'Page: $a'; $string['pagecontents'] = 'Page contents'; @@ -262,7 +261,6 @@ $string['startlesson'] = 'Start lesson'; $string['studentattemptlesson'] = '$a->lastname, $a->firstname\'s attempt number $a->attempt'; $string['studentname'] = '$a Name'; $string['studentoneminwarning'] = 'Warning: You have 1 minute or less to finish the lesson.'; -$string['studentoutoftime'] = 'Attention: You ran out of time for this lesson. Your last answer does not count because it was answered after the time was up. Please push the continue button to finish the lesson.'; $string['studentresponse'] = '{$a}\'s response'; $string['submitname'] = 'Submit name'; $string['teacherjumpwarning'] = 'An $a->cluster jump or an $a->unseen jump is being used in this lesson. The Next Page jump will be used instead. Login as a student to test these jumps.'; diff --git a/mod/lesson/action/continue.php b/mod/lesson/action/continue.php index 05d6cb312e..18e73edb67 100644 --- a/mod/lesson/action/continue.php +++ b/mod/lesson/action/continue.php @@ -19,7 +19,6 @@ // This is the code updates the lesson time for a timed test // get time information for this user - $outoftime = false; $timer = new stdClass; if (!has_capability('mod/lesson:manage', $context)) { if (!$timer = get_records_select('lesson_timer', "lessonid = $lesson->id AND userid = $USER->id", 'starttime')) { @@ -29,16 +28,16 @@ } if ($lesson->timed) { - if ((($timer->starttime + $lesson->maxtime * 60) - time()) < 60 && !((($timer->starttime + $lesson->maxtime * 60) - time()) < 0)) { - lesson_set_message(get_string("studentoneminwarning", "lesson")); - } else if (($timer->starttime + $lesson->maxtime * 60) < time()) { - lesson_set_message(get_string("studentoutoftime", "lesson")); - $outoftime = true; - } - if ((($timer->starttime + $lesson->maxtime * 60) - time()) <= 0) { + $timeleft = ($timer->starttime + $lesson->maxtime * 60) - time(); + + if ($timeleft <= 0) { // Out of time lesson_set_message(get_string('eolstudentoutoftime', 'lesson')); - redirect("$CFG->wwwroot/mod/lesson/view.php?id=$cm->id&pageid=".LESSON_EOL."&outoftime=normal", get_string("outoftime", "lesson")); + redirect("$CFG->wwwroot/mod/lesson/view.php?id=$cm->id&pageid=".LESSON_EOL."&outoftime=normal"); + die; // Shouldn't be reached, but make sure + } else if ($timeleft < 60) { + // One minute warning + lesson_set_message(get_string("studentoneminwarning", "lesson")); } } @@ -567,15 +566,12 @@ } $attempt->timeseen = time(); - // dont want to insert the attempt if they ran out of time - if (!$outoftime) { - // if allow modattempts, then update the old attempt record, otherwise, insert new answer record - if (isset($USER->modattempts[$lesson->id])) { - $attempt->retry = $nretakes - 1; // they are going through on review, $nretakes will be too high - } - if (!$newattemptid = insert_record("lesson_attempts", $attempt)) { - error("Continue: attempt not inserted"); - } + // if allow modattempts, then update the old attempt record, otherwise, insert new answer record + if (isset($USER->modattempts[$lesson->id])) { + $attempt->retry = $nretakes - 1; // they are going through on review, $nretakes will be too high + } + if (!$newattemptid = insert_record("lesson_attempts", $attempt)) { + error("Continue: attempt not inserted"); } // "number of attempts remaining" message if $lesson->maxattempts > 1 // displaying of message(s) is at the end of page for more ergonomic display @@ -703,9 +699,7 @@ } // TODO: merge with the jump code above. This is where some jump numbers are interpreted - if($outoftime) { - $newpageid = LESSON_EOL; // ran out of time for the test, so go to eol - } elseif (isset($USER->modattempts[$lesson->id])) { + if (isset($USER->modattempts[$lesson->id])) { // make sure if the student is reviewing, that he/she sees the same pages/page path that he/she saw the first time if ($USER->modattempts[$lesson->id] == $pageid) { // remember, this session variable holds the pageid of the last page that the user saw $newpageid = LESSON_EOL; -- 2.39.5