Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-29296 lesson mod: fixed regression for continue button on last le…

…sson page.
  • Loading branch information...
commit 9551f0360675b1714ea844940ffbf3a24314b7c4 1 parent 7294a06
rwijaya rwijaya authored
Showing with 12 additions and 20 deletions.
  1. +11 −16 mod/lesson/locallib.php
  2. +1 −4 mod/lesson/view.php
27 mod/lesson/locallib.php
View
@@ -1117,7 +1117,7 @@ public function get_lastpageid() {
}
/**
- * Gets the next page to display after the one that is provided.
+ * Gets the next page id to display after the one that is provided.
* @param int $nextpageid
* @return bool
*/
@@ -1126,19 +1126,19 @@ public function get_next_page($nextpageid) {
$allpages = $this->load_all_pages();
if ($this->properties->nextpagedefault) {
// in Flash Card mode...first get number of retakes
- $nretakes = $DB->count_records("lesson_grades", array("lessonid"=>$this->properties->id, "userid"=>$USER->id));
+ $nretakes = $DB->count_records("lesson_grades", array("lessonid" => $this->properties->id, "userid" => $USER->id));
shuffle($allpages);
$found = false;
if ($this->properties->nextpagedefault == LESSON_UNSEENPAGE) {
foreach ($allpages as $nextpage) {
- if (!$DB->count_records("lesson_attempts", array("pageid"=>$nextpage->id, "userid"=>$USER->id, "retry"=>$nretakes))) {
+ if (!$DB->count_records("lesson_attempts", array("pageid" => $nextpage->id, "userid" => $USER->id, "retry" => $nretakes))) {
$found = true;
break;
}
}
} elseif ($this->properties->nextpagedefault == LESSON_UNANSWEREDPAGE) {
foreach ($allpages as $nextpage) {
- if (!$DB->count_records("lesson_attempts", array('pageid'=>$nextpage->id, 'userid'=>$USER->id, 'correct'=>1, 'retry'=>$nretakes))) {
+ if (!$DB->count_records("lesson_attempts", array('pageid' => $nextpage->id, 'userid' => $USER->id, 'correct' => 1, 'retry' => $nretakes))) {
$found = true;
break;
}
@@ -1147,20 +1147,20 @@ public function get_next_page($nextpageid) {
if ($found) {
if ($this->properties->maxpages) {
// check number of pages viewed (in the lesson)
- if ($DB->count_records("lesson_attempts", array("lessonid"=>$this->properties->id, "userid"=>$USER->id, "retry"=>$nretakes)) >= $this->properties->maxpages) {
- return false;
+ if ($DB->count_records("lesson_attempts", array("lessonid" => $this->properties->id, "userid" => $USER->id, "retry" => $nretakes)) >= $this->properties->maxpages) {
+ return LESSON_EOL;
}
}
- return $nextpage;
+ return $nextpage->id;
}
}
// In a normal lesson mode
foreach ($allpages as $nextpage) {
- if ((int)$nextpage->id===(int)$nextpageid) {
- return $nextpage;
+ if ((int)$nextpage->id === (int)$nextpageid) {
+ return $nextpage->id;
}
}
- return false;
+ return LESSON_EOL;
}
/**
@@ -1985,12 +1985,7 @@ public function properties() {
if ($result->newpageid == 0) {
$result->newpageid = $this->properties->id;
} elseif ($result->newpageid == LESSON_NEXTPAGE) {
- $nextpage = $this->lesson->get_next_page($this->properties->nextpageid);
- if ($nextpage === false) {
- $result->newpageid = LESSON_EOL;
- } else {
- $result->newpageid = $nextpage->id;
- }
+ $result->newpageid = $this->lesson->get_next_page($this->properties->nextpageid);
}
// Determine default feedback if necessary
5 mod/lesson/view.php
View
@@ -374,10 +374,7 @@
$data = new stdClass;
$data->id = $PAGE->cm->id;
$data->pageid = $page->id;
- $data->newpageid = LESSON_NEXTPAGE;
- if ($nextpage = $lesson->get_next_page($page->nextpageid)) {
- $data->newpageid = $nextpage->id;
- }
+ $data->newpageid = $lesson->get_next_page($page->nextpageid);
$customdata = array(
'title' => $page->title,
Please sign in to comment.
Something went wrong with that request. Please try again.