MDL-58431 mod_lesson: Fix error in random jumps on first visit
Random jumps to content pages were not working when they were set in the first page. This was caused because the page where the jump was, was not being marked as visited before calculating the jump.
This commit is contained in:
@@ -174,6 +174,17 @@ class lesson_page_type_branchtable extends lesson_page {
|
||||
$retries = 0;
|
||||
}
|
||||
|
||||
// First record this page in lesson_branch. This record may be needed by lesson_unseen_branch_jump.
|
||||
$branch = new stdClass;
|
||||
$branch->lessonid = $this->lesson->id;
|
||||
$branch->userid = $USER->id;
|
||||
$branch->pageid = $this->properties->id;
|
||||
$branch->retry = $retries;
|
||||
$branch->flag = $branchflag;
|
||||
$branch->timeseen = time();
|
||||
$branch->nextpageid = 0; // Next page id will be set later.
|
||||
$branch->id = $DB->insert_record("lesson_branch", $branch);
|
||||
|
||||
// this is called when jumping to random from a branch table
|
||||
$context = context_module::instance($PAGE->cm->id);
|
||||
if($newpageid == LESSON_UNSEENBRANCHPAGE) {
|
||||
@@ -199,16 +210,9 @@ class lesson_page_type_branchtable extends lesson_page {
|
||||
$newpageid = lesson_unseen_branch_jump($this->lesson, $USER->id);
|
||||
}
|
||||
|
||||
// Record this page in lesson_branch.
|
||||
$branch = new stdClass;
|
||||
$branch->lessonid = $this->lesson->id;
|
||||
$branch->userid = $USER->id;
|
||||
$branch->pageid = $this->properties->id;
|
||||
$branch->retry = $retries;
|
||||
$branch->flag = $branchflag;
|
||||
$branch->timeseen = time();
|
||||
// Update record to set nextpageid.
|
||||
$branch->nextpageid = $newpageid;
|
||||
$DB->insert_record("lesson_branch", $branch);
|
||||
$DB->update_record("lesson_branch", $branch);
|
||||
|
||||
redirect(new moodle_url('/mod/lesson/view.php', array('id' => $PAGE->cm->id, 'pageid' => $newpageid)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user