Skip to content

Commit

Permalink
MDL-38664 Lesson mod: fixed re-attempt unseen page
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph Rézeau authored and rwijaya committed Oct 21, 2013
1 parent 4e47920 commit b882b8c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions mod/lesson/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,18 @@
unset($USER->modattempts[$lesson->id]); // if no pageid, then student is NOT reviewing
}

// if there are any questions have been answered correctly in this attempt
$corrrectattempts = $lesson->get_attempts($retries, true);
// If there are any questions that have been answered correctly (or not) in this attempt
$corrrectattempts = $lesson->get_attempts($retries);
if (!empty($corrrectattempts)) {
$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;
if ($jumpto == 0) { // unlikely value! except in JR mod
// Check if a question has been incorrectly answered AND no more attempts at it are left
$nattempts = $DB->count_records("lesson_attempts", array("pageid" => $attempt->pageid, "userid" => $USER->id, "retry" => $attempt->retry));
if ($nattempts >= $lesson->maxattempts) {
$lastpageseen = $DB->get_field('lesson_pages', 'nextpageid', array('id' => $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
Expand Down

0 comments on commit b882b8c

Please sign in to comment.