MDL-29296 lesson mod: fixed regression for continue button on last lesson page.

This commit is contained in:
Rossiani Wijaya
2011-09-26 16:41:49 +08:00
parent e63ae067f4
commit 0343553fbc
2 changed files with 12 additions and 20 deletions
+11 -16
View File
@@ -1117,7 +1117,7 @@ class lesson extends lesson_base {
}
/**
* 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 @@ class lesson extends lesson_base {
$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 @@ class lesson extends lesson_base {
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 @@ abstract class lesson_page extends lesson_base {
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
+1 -4
View File
@@ -374,10 +374,7 @@ if ($pageid != LESSON_EOL) {
$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,