Merge branch 'MDL-58431-master' of git://github.com/jleyva/moodle

This commit is contained in:
Andrew Nicols 2017-05-04 11:01:39 +08:00
commit edf1ea10ca

View File

@ -176,6 +176,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) {
@ -201,16 +212,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);
// This will force to redirect to the newpageid.
$result->inmediatejump = true;