From 49ef5d4c7f95ed1d58e7b03b19979f1309887581 Mon Sep 17 00:00:00 2001 From: Rossiani Wijaya Date: Tue, 20 Mar 2012 17:32:58 +0800 Subject: [PATCH] MDL-31775 Lesson Module: fixed start at last page seen bug --- mod/lesson/view.php | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/mod/lesson/view.php b/mod/lesson/view.php index e0540b01cc6..c274104141d 100644 --- a/mod/lesson/view.php +++ b/mod/lesson/view.php @@ -194,20 +194,18 @@ if (empty($pageid)) { // if there are any questions have been answered correctly in this attempt $corrrectattempts = $lesson->get_attempts($retries, true); if ($corrrectattempts>0) { - foreach ($corrrectattempts as $attempt) { - $jumpto = $DB->get_field('lesson_answers', 'jumpto', array('id' => $attempt->answerid)); - // convert the jumpto to a proper page id - if ($jumpto == 0) { // unlikely value! - $lastpageseen = $attempt->pageid; - } elseif ($jumpto == LESSON_NEXTPAGE) { - if (!$lastpageseen = $DB->get_field('lesson_pages', 'nextpageid', array('id' => $attempt->pageid))) { - // no nextpage go to end of lesson - $lastpageseen = LESSON_EOL; - } - } else { - $lastpageseen = $jumpto; + $attempt = end($corrrectattempts); + $jumpto = $DB->get_field('lesson_answers', 'jumpto', array('id' => $attempt->answerid)); + // convert the jumpto to a proper page id + if ($jumpto == 0) { // unlikely value! + $lastpageseen = $attempt->pageid; + } elseif ($jumpto == LESSON_NEXTPAGE) { + if (!$lastpageseen = $DB->get_field('lesson_pages', 'nextpageid', array('id' => $attempt->pageid))) { + // no nextpage go to end of lesson + $lastpageseen = LESSON_EOL; } - break; // only look at the latest correct attempt + } else { + $lastpageseen = $jumpto; } }