Permalink
Browse files

MDL-38664 Lesson mod: fixed re-attempt unseen page

  • Loading branch information...
Joseph Rézeau rwijaya
Joseph Rézeau authored and rwijaya committed Mar 28, 2013
1 parent 22084d5 commit 21c314df1497d5db81eea40e988fa478a8ceb543
Showing with 8 additions and 4 deletions.
  1. +8 −4 mod/lesson/view.php
View
@@ -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

0 comments on commit 21c314d

Please sign in to comment.