diff --git a/mod/lesson/backuplib.php b/mod/lesson/backuplib.php index 8a0d44bd403..de45b00b82c 100644 --- a/mod/lesson/backuplib.php +++ b/mod/lesson/backuplib.php @@ -6,12 +6,12 @@ //This is the "graphical" structure of the lesson mod: // // lesson_default lesson ----------------------------|--------------------------|--------------------------| - // (UL, pk->id,fk->courseid) (CL,pk->id) | | | - // | | | | - // | lesson_grades lesson_high_scores lesson_timer - // | (UL, pk->id,fk->lessonid) (UL, pk->id,fk->lessonid) (UL, pk->id,fk->lessonid) - // | - // | + // (UL, pk->id,fk->courseid) (CL,pk->id) | | | + // | | | | + // | lesson_grades lesson_high_scores lesson_timer + // | (UL, pk->id,fk->lessonid) (UL, pk->id,fk->lessonid) (UL, pk->id,fk->lessonid) + // | + // | // lesson_pages---------------------------| // (CL,pk->id,fk->lessonid) | // | | @@ -51,31 +51,31 @@ fwrite ($bf,full_tag("ID",4,false,$lesson->id)); fwrite ($bf,full_tag("MODTYPE",4,false,"lesson")); fwrite ($bf,full_tag("NAME",4,false,$lesson->name)); - fwrite ($bf,full_tag("PRACTICE",4,false,$lesson->practice)); - fwrite ($bf,full_tag("MODATTEMPTS",4,false,$lesson->modattempts)); - fwrite ($bf,full_tag("PASSWORD",4,false,$lesson->password)); - fwrite ($bf,full_tag("USEPASSWORD",4,false,$lesson->usepassword)); + fwrite ($bf,full_tag("PRACTICE",4,false,$lesson->practice)); + fwrite ($bf,full_tag("MODATTEMPTS",4,false,$lesson->modattempts)); + fwrite ($bf,full_tag("PASSWORD",4,false,$lesson->password)); + fwrite ($bf,full_tag("USEPASSWORD",4,false,$lesson->usepassword)); fwrite ($bf,full_tag("GRADE",4,false,$lesson->grade)); - fwrite ($bf,full_tag("CUSTOM",4,false,$lesson->custom)); - fwrite ($bf,full_tag("ONGOING",4,false,$lesson->ongoing)); + fwrite ($bf,full_tag("CUSTOM",4,false,$lesson->custom)); + fwrite ($bf,full_tag("ONGOING",4,false,$lesson->ongoing)); fwrite ($bf,full_tag("USEMAXGRADE",4,false,$lesson->usemaxgrade)); fwrite ($bf,full_tag("MAXANSWERS",4,false,$lesson->maxanswers)); fwrite ($bf,full_tag("MAXATTEMPTS",4,false,$lesson->maxattempts)); - fwrite ($bf,full_tag("REVIEW",4,false,$lesson->review)); + fwrite ($bf,full_tag("REVIEW",4,false,$lesson->review)); fwrite ($bf,full_tag("NEXTPAGEDEFAULT",4,false,$lesson->nextpagedefault)); fwrite ($bf,full_tag("MINQUESTIONS",4,false,$lesson->minquestions)); fwrite ($bf,full_tag("MAXPAGES",4,false,$lesson->maxpages)); - fwrite ($bf,full_tag("TIMED",4,false,$lesson->timed)); - fwrite ($bf,full_tag("MAXTIME",4,false,$lesson->maxtime)); + fwrite ($bf,full_tag("TIMED",4,false,$lesson->timed)); + fwrite ($bf,full_tag("MAXTIME",4,false,$lesson->maxtime)); fwrite ($bf,full_tag("RETAKE",4,false,$lesson->retake)); - fwrite ($bf,full_tag("TREE",4,false,$lesson->tree)); - fwrite ($bf,full_tag("SLIDESHOW",4,false,$lesson->slideshow)); - fwrite ($bf,full_tag("WIDTH",4,false,$lesson->width)); - fwrite ($bf,full_tag("HEIGHT",4,false,$lesson->height)); - fwrite ($bf,full_tag("BGCOLOR",4,false,$lesson->bgcolor)); - fwrite ($bf,full_tag("DISPLAYLEFT",4,false,$lesson->displayleft)); - fwrite ($bf,full_tag("HIGHSCORES",4,false,$lesson->highscores)); - fwrite ($bf,full_tag("MAXHIGHSCORES",4,false,$lesson->maxhighscores)); + fwrite ($bf,full_tag("TREE",4,false,$lesson->tree)); + fwrite ($bf,full_tag("SLIDESHOW",4,false,$lesson->slideshow)); + fwrite ($bf,full_tag("WIDTH",4,false,$lesson->width)); + fwrite ($bf,full_tag("HEIGHT",4,false,$lesson->height)); + fwrite ($bf,full_tag("BGCOLOR",4,false,$lesson->bgcolor)); + fwrite ($bf,full_tag("DISPLAYLEFT",4,false,$lesson->displayleft)); + fwrite ($bf,full_tag("HIGHSCORES",4,false,$lesson->highscores)); + fwrite ($bf,full_tag("MAXHIGHSCORES",4,false,$lesson->maxhighscores)); fwrite ($bf,full_tag("AVAILABLE",4,false,$lesson->available)); fwrite ($bf,full_tag("DEADLINE",4,false,$lesson->deadline)); fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$lesson->timemodified)); @@ -86,22 +86,22 @@ if ($status) { if ($preferences->mods["lesson"]->userinfo) { if(!backup_lesson_grades($bf, $preferences, $lesson->id)) { - return false; - } - if (!backup_lesson_high_scores($bf, $preferences, $lesson->id)) { - return false; - } - if (!backup_lesson_timer($bf, $preferences, $lesson->id)) { - return false; - } + return false; + } + if (!backup_lesson_high_scores($bf, $preferences, $lesson->id)) { + return false; + } + if (!backup_lesson_timer($bf, $preferences, $lesson->id)) { + return false; + } + } + // back up the default for the course. There might not be one, but if there + // is, there will only be one. + $status = backup_lesson_default($bf,$preferences); + //End mod + if ($status) { + $status =fwrite ($bf,end_tag("MOD",3,true)); } - // back up the default for the course. There might not be one, but if there - // is, there will only be one. - $status = backup_lesson_default($bf,$preferences); - //End mod - if ($status) { - $status =fwrite ($bf,end_tag("MOD",3,true)); - } } } } @@ -127,20 +127,20 @@ fwrite ($bf,full_tag("PAGEID",6,false,$page->id)); // needed to fix (absolute) jumps fwrite ($bf,full_tag("QTYPE",6,false,$page->qtype)); fwrite ($bf,full_tag("QOPTION",6,false,$page->qoption)); - fwrite ($bf,full_tag("LAYOUT",6,false,$page->layout)); - fwrite ($bf,full_tag("DISPLAY",6,false,$page->display)); + fwrite ($bf,full_tag("LAYOUT",6,false,$page->layout)); + fwrite ($bf,full_tag("DISPLAY",6,false,$page->display)); fwrite ($bf,full_tag("TIMECREATED",6,false,$page->timecreated)); fwrite ($bf,full_tag("TIMEMODIFIED",6,false,$page->timemodified)); fwrite ($bf,full_tag("TITLE",6,false,$page->title)); fwrite ($bf,full_tag("CONTENTS",6,false,$page->contents)); //Now we backup lesson answers for this page $status = backup_lesson_answers($bf, $preferences, $page->id); - // backup branch table info for branch tables. - if ($status && $preferences->mods["lesson"]->userinfo) { - if (!backup_lesson_branch($bf, $preferences, $page->id)) { - return false; - } - } + // backup branch table info for branch tables. + if ($status && $preferences->mods["lesson"]->userinfo) { + if (!backup_lesson_branch($bf, $preferences, $page->id)) { + return false; + } + } //End of page $status =fwrite ($bf,end_tag("PAGE",5,true)); // move to the next (logical) page @@ -182,7 +182,7 @@ fwrite ($bf,full_tag("ID",8,false,$answer->id)); fwrite ($bf,full_tag("JUMPTO",8,false,$answer->jumpto)); fwrite ($bf,full_tag("GRADE",8,false,$answer->grade)); - fwrite ($bf,full_tag("SCORE",8,false,$answer->score)); + fwrite ($bf,full_tag("SCORE",8,false,$answer->score)); fwrite ($bf,full_tag("FLAGS",8,false,$answer->flags)); fwrite ($bf,full_tag("TIMECREATED",8,false,$answer->timecreated)); fwrite ($bf,full_tag("TIMEMODIFIED",8,false,$answer->timemodified)); @@ -285,11 +285,11 @@ //Print answer contents fwrite ($bf,full_tag("LESSONID",8,false,$branch->lessonid)); fwrite ($bf,full_tag("USERID",8,false,$branch->userid)); - fwrite ($bf,full_tag("PAGEID",8,false,$branch->pageid)); + fwrite ($bf,full_tag("PAGEID",8,false,$branch->pageid)); fwrite ($bf,full_tag("RETRY",8,false,$branch->retry)); fwrite ($bf,full_tag("FLAG",8,false,$branch->flag)); fwrite ($bf,full_tag("TIMESEEN",8,false,$branch->timeseen)); - // END BRANCH + // END BRANCH $status =fwrite ($bf,end_tag("BRANCH",7,true)); } //Write end tag @@ -328,9 +328,9 @@ } return $status; } - - // backup lesson_high_score contents (executed from backup_lesson_mods) - function backup_lesson_high_scores($bf, $preferences, $lessonid) { + + // backup lesson_high_score contents (executed from backup_lesson_mods) + function backup_lesson_high_scores($bf, $preferences, $lessonid) { global $CFG; $status = true; @@ -357,10 +357,10 @@ $status =fwrite ($bf,end_tag("HIGHSCORES",8,true)); } return $status; - } - - // backup lesson_default contents (executed from backup_lesson_mods) - function backup_lesson_default ($bf,$preferences) { + } + + // backup lesson_default contents (executed from backup_lesson_mods) + function backup_lesson_default ($bf,$preferences) { global $CFG; $status = true; @@ -368,41 +368,41 @@ //only one default record per course $default = get_record("lesson_default", "course", $preferences->backup_course); if ($default) { - //Start mod - $status =fwrite ($bf,start_tag("DEFAULTS",3,true)); + //Start mod + $status =fwrite ($bf,start_tag("DEFAULTS",3,true)); $status =fwrite ($bf,start_tag("DEFAULT",4,true)); - //Print default data - fwrite ($bf,full_tag("PRACTICE",5,false,$default->practice)); - fwrite ($bf,full_tag("MODATTEMPTS",5,false,$default->modattempts)); - fwrite ($bf,full_tag("PASSWORD",5,false,$default->password)); - fwrite ($bf,full_tag("USEPASSWORD",5,false,$default->usepassword)); - fwrite ($bf,full_tag("GRADE",5,false,$default->grade)); - fwrite ($bf,full_tag("CUSTOM",5,false,$default->custom)); - fwrite ($bf,full_tag("ONGOING",5,false,$default->ongoing)); - fwrite ($bf,full_tag("USEMAXGRADE",5,false,$default->usemaxgrade)); - fwrite ($bf,full_tag("MAXANSWERS",5,false,$default->maxanswers)); - fwrite ($bf,full_tag("MAXATTEMPTS",5,false,$default->maxattempts)); - fwrite ($bf,full_tag("REVIEW",5,false,$default->review)); - fwrite ($bf,full_tag("NEXTPAGEDEFAULT",5,false,$default->nextpagedefault)); - fwrite ($bf,full_tag("MINQUESTIONS",5,false,$default->minquestions)); - fwrite ($bf,full_tag("MAXPAGES",5,false,$default->maxpages)); - fwrite ($bf,full_tag("TIMED",5,false,$default->timed)); - fwrite ($bf,full_tag("MAXTIME",5,false,$default->maxtime)); - fwrite ($bf,full_tag("RETAKE",5,false,$default->retake)); - fwrite ($bf,full_tag("TREE",5,false,$default->tree)); - fwrite ($bf,full_tag("SLIDESHOW",5,false,$default->slideshow)); - fwrite ($bf,full_tag("WIDTH",5,false,$default->width)); - fwrite ($bf,full_tag("HEIGHT",5,false,$default->height)); - fwrite ($bf,full_tag("BGCOLOR",5,false,$default->bgcolor)); - fwrite ($bf,full_tag("DISPLAYLEFT",5,false,$default->displayleft)); - fwrite ($bf,full_tag("HIGHSCORES",5,false,$default->highscores)); - fwrite ($bf,full_tag("MAXHIGHSCORES",5,false,$default->maxhighscores)); + //Print default data + fwrite ($bf,full_tag("PRACTICE",5,false,$default->practice)); + fwrite ($bf,full_tag("MODATTEMPTS",5,false,$default->modattempts)); + fwrite ($bf,full_tag("PASSWORD",5,false,$default->password)); + fwrite ($bf,full_tag("USEPASSWORD",5,false,$default->usepassword)); + fwrite ($bf,full_tag("GRADE",5,false,$default->grade)); + fwrite ($bf,full_tag("CUSTOM",5,false,$default->custom)); + fwrite ($bf,full_tag("ONGOING",5,false,$default->ongoing)); + fwrite ($bf,full_tag("USEMAXGRADE",5,false,$default->usemaxgrade)); + fwrite ($bf,full_tag("MAXANSWERS",5,false,$default->maxanswers)); + fwrite ($bf,full_tag("MAXATTEMPTS",5,false,$default->maxattempts)); + fwrite ($bf,full_tag("REVIEW",5,false,$default->review)); + fwrite ($bf,full_tag("NEXTPAGEDEFAULT",5,false,$default->nextpagedefault)); + fwrite ($bf,full_tag("MINQUESTIONS",5,false,$default->minquestions)); + fwrite ($bf,full_tag("MAXPAGES",5,false,$default->maxpages)); + fwrite ($bf,full_tag("TIMED",5,false,$default->timed)); + fwrite ($bf,full_tag("MAXTIME",5,false,$default->maxtime)); + fwrite ($bf,full_tag("RETAKE",5,false,$default->retake)); + fwrite ($bf,full_tag("TREE",5,false,$default->tree)); + fwrite ($bf,full_tag("SLIDESHOW",5,false,$default->slideshow)); + fwrite ($bf,full_tag("WIDTH",5,false,$default->width)); + fwrite ($bf,full_tag("HEIGHT",5,false,$default->height)); + fwrite ($bf,full_tag("BGCOLOR",5,false,$default->bgcolor)); + fwrite ($bf,full_tag("DISPLAYLEFT",5,false,$default->displayleft)); + fwrite ($bf,full_tag("HIGHSCORES",5,false,$default->highscores)); + fwrite ($bf,full_tag("MAXHIGHSCORES",5,false,$default->maxhighscores)); $status =fwrite ($bf,end_tag("DEFAULT",4,true)); $status =fwrite ($bf,end_tag("DEFAULTS",3,true)); - } + } return $status; - } - + } + //Return an array of info (name,value) function lesson_check_backup_mods($course,$user_data=false,$backup_unique_code) { //First the course data diff --git a/mod/lesson/restorelib.php b/mod/lesson/restorelib.php index 3bda5cf4bfc..450cf74dd21 100644 --- a/mod/lesson/restorelib.php +++ b/mod/lesson/restorelib.php @@ -6,12 +6,12 @@ //This is the "graphical" structure of the lesson mod: // // lesson_default lesson ----------------------------|--------------------------|--------------------------| - // (UL, pk->id,fk->courseid) (CL,pk->id) | | | - // | | | | - // | lesson_grades lesson_high_scores lesson_timer - // | (UL, pk->id,fk->lessonid) (UL, pk->id,fk->lessonid) (UL, pk->id,fk->lessonid) - // | - // | + // (UL, pk->id,fk->courseid) (CL,pk->id) | | | + // | | | | + // | lesson_grades lesson_high_scores lesson_timer + // | (UL, pk->id,fk->lessonid) (UL, pk->id,fk->lessonid) (UL, pk->id,fk->lessonid) + // | + // | // lesson_pages---------------------------| // (CL,pk->id,fk->lessonid) | // | | @@ -54,31 +54,31 @@ //Now, build the lesson record structure $lesson->course = $restore->course_id; $lesson->name = backup_todb($info['MOD']['#']['NAME']['0']['#']); - $lesson->practice = backup_todb($info['MOD']['#']['PRACTICE']['0']['#']); - $lesson->modattempts = backup_todb($info['MOD']['#']['MODATTEMPTS']['0']['#']); - $lesson->password = backup_todb($info['MOD']['#']['PASSWORD']['0']['#']); - $lesson->usepassword = backup_todb($info['MOD']['#']['USEPASSWORD']['0']['#']); + $lesson->practice = backup_todb($info['MOD']['#']['PRACTICE']['0']['#']); + $lesson->modattempts = backup_todb($info['MOD']['#']['MODATTEMPTS']['0']['#']); + $lesson->password = backup_todb($info['MOD']['#']['PASSWORD']['0']['#']); + $lesson->usepassword = backup_todb($info['MOD']['#']['USEPASSWORD']['0']['#']); $lesson->grade = backup_todb($info['MOD']['#']['GRADE']['0']['#']); - $lesson->custom = backup_todb($info['MOD']['#']['CUSTOM']['0']['#']); - $lesson->ongoing = backup_todb($info['MOD']['#']['ONGOING']['0']['#']); + $lesson->custom = backup_todb($info['MOD']['#']['CUSTOM']['0']['#']); + $lesson->ongoing = backup_todb($info['MOD']['#']['ONGOING']['0']['#']); $lesson->usemaxgrade = backup_todb($info['MOD']['#']['USEMAXGRADE']['0']['#']); $lesson->maxanswers = backup_todb($info['MOD']['#']['MAXANSWERS']['0']['#']); $lesson->maxattempts = backup_todb($info['MOD']['#']['MAXATTEMPTS']['0']['#']); - $lesson->review = backup_todb($info['MOD']['#']['REVIEW']['0']['#']); + $lesson->review = backup_todb($info['MOD']['#']['REVIEW']['0']['#']); $lesson->nextpagedefault = backup_todb($info['MOD']['#']['NEXTPAGEDEFAULT']['0']['#']); $lesson->minquestions = backup_todb($info['MOD']['#']['MINQUESTIONS']['0']['#']); $lesson->maxpages = backup_todb($info['MOD']['#']['MAXPAGES']['0']['#']); - $lesson->timed = backup_todb($info['MOD']['#']['TIMED']['0']['#']); - $lesson->maxtime = backup_todb($info['MOD']['#']['MAXTIME']['0']['#']); + $lesson->timed = backup_todb($info['MOD']['#']['TIMED']['0']['#']); + $lesson->maxtime = backup_todb($info['MOD']['#']['MAXTIME']['0']['#']); $lesson->retake = backup_todb($info['MOD']['#']['RETAKE']['0']['#']); - $lesson->tree = backup_todb($info['MOD']['#']['TREE']['0']['#']); - $lesson->slideshow = backup_todb($info['MOD']['#']['SLIDESHOW']['0']['#']); - $lesson->width = backup_todb($info['MOD']['#']['WIDTH']['0']['#']); - $lesson->height = backup_todb($info['MOD']['#']['HEIGHT']['0']['#']); - $lesson->bgcolor = backup_todb($info['MOD']['#']['BGCOLOR']['0']['#']); - $lesson->displayleft = backup_todb($info['MOD']['#']['DISPLAYLEFT']['0']['#']); - $lesson->highscores = backup_todb($info['MOD']['#']['HIGHSCORES']['0']['#']); - $lesson->maxhighscores = backup_todb($info['MOD']['#']['MAXHIGHSCORES']['0']['#']); + $lesson->tree = backup_todb($info['MOD']['#']['TREE']['0']['#']); + $lesson->slideshow = backup_todb($info['MOD']['#']['SLIDESHOW']['0']['#']); + $lesson->width = backup_todb($info['MOD']['#']['WIDTH']['0']['#']); + $lesson->height = backup_todb($info['MOD']['#']['HEIGHT']['0']['#']); + $lesson->bgcolor = backup_todb($info['MOD']['#']['BGCOLOR']['0']['#']); + $lesson->displayleft = backup_todb($info['MOD']['#']['DISPLAYLEFT']['0']['#']); + $lesson->highscores = backup_todb($info['MOD']['#']['HIGHSCORES']['0']['#']); + $lesson->maxhighscores = backup_todb($info['MOD']['#']['MAXHIGHSCORES']['0']['#']); $lesson->available = backup_todb($info['MOD']['#']['AVAILABLE']['0']['#']); $lesson->deadline = backup_todb($info['MOD']['#']['DEADLINE']['0']['#']); $lesson->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']); @@ -100,19 +100,19 @@ if ($status) { if ($restore->mods["lesson"]->userinfo) { if(!lesson_grades_restore_mods($newid,$info,$restore)) { - return false; - } - if (!lesson_high_scores_restore_mods($newid,$info,$restore)) { - return false; - } - if (!lesson_timer_restore_mods($newid,$info,$restore)) { - return false; - } + return false; + } + if (!lesson_high_scores_restore_mods($newid,$info,$restore)) { + return false; + } + if (!lesson_timer_restore_mods($newid,$info,$restore)) { + return false; + } } - // restore the default for the course. There might not be one, but if there - // is, there will only be one. - $status = lesson_default_restore_mods($info,$restore); - } + // restore the default for the course. There might not be one, but if there + // is, there will only be one. + $status = lesson_default_restore_mods($info,$restore); + } /*if ($restore->mods['lesson']->userinfo) { $status = lesson_grades_restore_mods($newid,$info,$restore); }*/ @@ -151,8 +151,8 @@ $page->prevpageid = $prevpageid; $page->qtype = backup_todb($page_info['#']['QTYPE']['0']['#']); $page->qoption = backup_todb($page_info['#']['QOPTION']['0']['#']); - $page->layout = backup_todb($page_info['#']['LAYOUT']['0']['#']); - $page->display = backup_todb($page_info['#']['DISPLAY']['0']['#']); + $page->layout = backup_todb($page_info['#']['LAYOUT']['0']['#']); + $page->display = backup_todb($page_info['#']['DISPLAY']['0']['#']); $page->timecreated = backup_todb($page_info['#']['TIMECREATED']['0']['#']); $page->timemodified = backup_todb($page_info['#']['TIMEMODIFIED']['0']['#']); $page->title = backup_todb($page_info['#']['TITLE']['0']['#']); @@ -186,41 +186,41 @@ backup_putid($restore->backup_unique_code,"lesson_pages", $oldid, $newid); //We have to restore the lesson_answers table now (a page level table) $status = lesson_answers_restore($lessonid,$newid,$page_info,$restore); - - // need to update useranswer field (which has answer id's in it) - // for matching and multi-answer multi-choice questions - if ($restore->mods["lesson"]->userinfo) { // firs check to see if we even have to do this - // if multi-answer multi-choice question or matching - if (($page->qtype == 3 && $page->qoption) || - $page->qtype == 5) { - // get all the attempt records for this page - if ($attempts = get_records("lesson_attempts", "pageid", $newid)) { - foreach ($attempts as $attempt) { - unset($newuseranswer); - if ($attempt->useranswer != NULL) { - // explode the user answer. Each element in - // $useranswer is an old answer id, so needs to be updated - $useranswer = explode(",", $attempt->useranswer); - foreach ($useranswer as $oldanswerid) { - $backupdata = backup_getid($restore->backup_unique_code,"answers",$oldanswerid); - $newuseranswer[] = $backupdata->new_id; - } - // get the useranswer in the right format - $attempt->useranswer = implode(",", $newuseranswer); - // update it - update_record("lesson_attempts", $attempt); - } - } - } - } - } - - // backup branch table info for branch tables. - if ($status && $restore->mods["lesson"]->userinfo) { - if (!lesson_branch_restore($lessonid,$newid,$page_info,$restore)) { - return false; - } - } + + // need to update useranswer field (which has answer id's in it) + // for matching and multi-answer multi-choice questions + if ($restore->mods["lesson"]->userinfo) { // firs check to see if we even have to do this + // if multi-answer multi-choice question or matching + if (($page->qtype == 3 && $page->qoption) || + $page->qtype == 5) { + // get all the attempt records for this page + if ($attempts = get_records("lesson_attempts", "pageid", $newid)) { + foreach ($attempts as $attempt) { + unset($newuseranswer); + if ($attempt->useranswer != NULL) { + // explode the user answer. Each element in + // $useranswer is an old answer id, so needs to be updated + $useranswer = explode(",", $attempt->useranswer); + foreach ($useranswer as $oldanswerid) { + $backupdata = backup_getid($restore->backup_unique_code,"answers",$oldanswerid); + $newuseranswer[] = $backupdata->new_id; + } + // get the useranswer in the right format + $attempt->useranswer = implode(",", $newuseranswer); + // update it + update_record("lesson_attempts", $attempt); + } + } + } + } + } + + // backup branch table info for branch tables. + if ($status && $restore->mods["lesson"]->userinfo) { + if (!lesson_branch_restore($lessonid,$newid,$page_info,$restore)) { + return false; + } + } } else { $status = false; } @@ -267,7 +267,7 @@ // the absolute jumps will need fixing $answer->jumpto = backup_todb($answer_info['#']['JUMPTO']['0']['#']); $answer->grade = backup_todb($answer_info['#']['GRADE']['0']['#']); - $answer->score = backup_todb($answer_info['#']['SCORE']['0']['#']); + $answer->score = backup_todb($answer_info['#']['SCORE']['0']['#']); $answer->flags = backup_todb($answer_info['#']['FLAGS']['0']['#']); $answer->timecreated = backup_todb($answer_info['#']['TIMECREATED']['0']['#']); $answer->timemodified = backup_todb($answer_info['#']['TIMEMODIFIED']['0']['#']); @@ -287,11 +287,11 @@ } if ($newid) { - // need to store the id so we can update the useranswer - // field in attempts. This is done in the lesson_pages_restore_mods - backup_putid($restore->backup_unique_code,"answers", - backup_todb($answer_info['#']['ID']['0']['#']), $newid); - + // need to store the id so we can update the useranswer + // field in attempts. This is done in the lesson_pages_restore_mods + backup_putid($restore->backup_unique_code,"answers", + backup_todb($answer_info['#']['ID']['0']['#']), $newid); + if ($restore->mods['lesson']->userinfo) { //We have to restore the lesson_attempts table now (a answers level table) $status = lesson_attempts_restore($lessonid, $pageid, $newid, $answer_info, $restore); @@ -332,7 +332,7 @@ $attempt->userid = backup_todb($attempt_info['#']['USERID']['0']['#']); $attempt->retry = backup_todb($attempt_info['#']['RETRY']['0']['#']); $attempt->correct = backup_todb($attempt_info['#']['CORRECT']['0']['#']); - $attempt->useranswer = backup_todb($attempt_info['#']['USERANSWER']['0']['#']); + $attempt->useranswer = backup_todb($attempt_info['#']['USERANSWER']['0']['#']); $attempt->timeseen = backup_todb($attempt_info['#']['TIMESEEN']['0']['#']); //We have to recode the userid field @@ -412,9 +412,9 @@ return $status; } - - - + + + //This function restores the lesson_branch function lesson_branch_restore($lessonid, $pageid, $info, $restore) { @@ -548,7 +548,7 @@ if ($user) { $highscore->userid = $user->new_id; } - + //The structure is equal to the db, so insert the lesson_grade $newid = insert_record ("lesson_high_score",$highscore); @@ -569,7 +569,7 @@ return $status; } - + //This function restores the lesson_default function lesson_default_restore_mods($info, $restore) { @@ -589,32 +589,32 @@ //$GLOBALS['traverse_array']=""; //Debug //Now, build the lesson_default record structure - $default->course = $restore->course_id; - $default->practice = backup_todb($default_info['#']['PRACTICE']['0']['#']); - $default->modattempts = backup_todb($default_info['#']['MODATTEMPTS']['0']['#']); - $default->password = backup_todb($default_info['#']['PASSWORD']['0']['#']); - $default->usepassword = backup_todb($default_info['#']['USEPASSWORD']['0']['#']); - $default->grade = backup_todb($default_info['#']['GRADE']['0']['#']); - $default->custom = backup_todb($default_info['#']['CUSTOM']['0']['#']); - $default->ongoing = backup_todb($default_info['#']['ONGOING']['0']['#']); - $default->usemaxgrade = backup_todb($default_info['#']['USEMAXGRADE']['0']['#']); - $default->maxanswers = backup_todb($default_info['#']['MAXANSWERS']['0']['#']); - $default->maxattempts = backup_todb($default_info['#']['MAXATTEMPTS']['0']['#']); - $default->review = backup_todb($default_info['#']['REVIEW']['0']['#']); - $default->nextpagedefault = backup_todb($default_info['#']['NEXTPAGEDEFAULT']['0']['#']); - $default->minquestions = backup_todb($default_info['#']['MINQUESTIONS']['0']['#']); - $default->maxpages = backup_todb($default_info['#']['MAXPAGES']['0']['#']); - $default->timed = backup_todb($default_info['#']['TIMED']['0']['#']); - $default->maxtime = backup_todb($default_info['#']['MAXTIME']['0']['#']); - $default->retake = backup_todb($default_info['#']['RETAKE']['0']['#']); - $default->tree = backup_todb($default_info['#']['TREE']['0']['#']); - $default->slideshow = backup_todb($default_info['#']['SLIDESHOW']['0']['#']); - $default->width = backup_todb($default_info['#']['WIDTH']['0']['#']); - $default->height = backup_todb($default_info['#']['HEIGHT']['0']['#']); - $default->bgcolor = backup_todb($default_info['#']['BGCOLOR']['0']['#']); - $default->displayleft = backup_todb($default_info['#']['DISPLAYLEFT']['0']['#']); - $default->highscores = backup_todb($default_info['#']['HIGHSCORES']['0']['#']); - $default->maxhighscores = backup_todb($default_info['#']['MAXHIGHSCORES']['0']['#']); + $default->course = $restore->course_id; + $default->practice = backup_todb($default_info['#']['PRACTICE']['0']['#']); + $default->modattempts = backup_todb($default_info['#']['MODATTEMPTS']['0']['#']); + $default->password = backup_todb($default_info['#']['PASSWORD']['0']['#']); + $default->usepassword = backup_todb($default_info['#']['USEPASSWORD']['0']['#']); + $default->grade = backup_todb($default_info['#']['GRADE']['0']['#']); + $default->custom = backup_todb($default_info['#']['CUSTOM']['0']['#']); + $default->ongoing = backup_todb($default_info['#']['ONGOING']['0']['#']); + $default->usemaxgrade = backup_todb($default_info['#']['USEMAXGRADE']['0']['#']); + $default->maxanswers = backup_todb($default_info['#']['MAXANSWERS']['0']['#']); + $default->maxattempts = backup_todb($default_info['#']['MAXATTEMPTS']['0']['#']); + $default->review = backup_todb($default_info['#']['REVIEW']['0']['#']); + $default->nextpagedefault = backup_todb($default_info['#']['NEXTPAGEDEFAULT']['0']['#']); + $default->minquestions = backup_todb($default_info['#']['MINQUESTIONS']['0']['#']); + $default->maxpages = backup_todb($default_info['#']['MAXPAGES']['0']['#']); + $default->timed = backup_todb($default_info['#']['TIMED']['0']['#']); + $default->maxtime = backup_todb($default_info['#']['MAXTIME']['0']['#']); + $default->retake = backup_todb($default_info['#']['RETAKE']['0']['#']); + $default->tree = backup_todb($default_info['#']['TREE']['0']['#']); + $default->slideshow = backup_todb($default_info['#']['SLIDESHOW']['0']['#']); + $default->width = backup_todb($default_info['#']['WIDTH']['0']['#']); + $default->height = backup_todb($default_info['#']['HEIGHT']['0']['#']); + $default->bgcolor = backup_todb($default_info['#']['BGCOLOR']['0']['#']); + $default->displayleft = backup_todb($default_info['#']['DISPLAYLEFT']['0']['#']); + $default->highscores = backup_todb($default_info['#']['HIGHSCORES']['0']['#']); + $default->maxhighscores = backup_todb($default_info['#']['MAXHIGHSCORES']['0']['#']); //The structure is equal to the db, so insert the lesson_grade $newid = insert_record ("lesson_default",$default); @@ -636,7 +636,7 @@ return $status; } - + //This function returns a log record with all the necessay transformations //done. It's used by restore_log_module() to restore modules log. function lesson_restore_logs($restore,$log) {