Permalink
Browse files

MDL-26229 backup & restore - fix quiz & lesson conflicts

  • Loading branch information...
1 parent 945962a commit 7cff4927be710e8a4a46f00bd7a27cd32cacd2ac @stronk7 stronk7 committed Feb 12, 2011
@@ -76,8 +76,11 @@ protected function define_structure() {
'minquestions','maxpages','timed','maxtime','retake','activitylink',
'mediafile','mediaheight','mediawidth','mediaclose','slideshow',
'width','height','bgcolor','displayleft','displayleftif','progressbar',
- 'highscores','maxhighscores','available','deadline','timemodified'
+ 'showhighscores','maxhighscores','available','deadline','timemodified'
));
+ // Tell the lesson element about the showhighscores elements mapping to the highscores
+ // database field.
+ $lesson->set_source_alias('highscores', 'showhighscores');
// The lesson_pages table
// Grouped within a `pages` element, important to note that page is relational
@@ -62,6 +62,13 @@ protected function process_lesson($data) {
$data->deadline = $this->apply_date_offset($data->deadline);
$data->timemodified = $this->apply_date_offset($data->timemodified);
+ // lesson->highscores can come both in data->highscores and
+ // data->showhighscores, handle both. MDL-26229
+ if (isset($data->showhighscores)) {
+ $data->highscores = $data->showhighscores;
+ unset($data->showhighscores);
+ }
+
// insert the lesson record
$newitemid = $DB->insert_record('lesson', $data);
// immediately after inserting "activity" record, call this
@@ -39,7 +39,7 @@ protected function define_structure() {
// Define each element separated
$quiz = new backup_nested_element('quiz', array('id'), array(
'name', 'intro', 'introformat', 'timeopen',
- 'timeclose', 'optionflags', 'penaltyscheme', 'attempts',
+ 'timeclose', 'optionflags', 'penaltyscheme', 'attempts_number',
'attemptonlast', 'grademethod', 'decimalpoints', 'questiondecimalpoints',
'review', 'questionsperpage', 'shufflequestions', 'shuffleanswers',
'questions', 'sumgrades', 'grade', 'timecreated',
@@ -119,6 +119,7 @@ protected function define_structure() {
}
// Define source alias
+ $quiz->set_source_alias('attempts', 'attempts_number');
$grade->set_source_alias('grade', 'gradeval');
$attempt->set_source_alias('attempt', 'attemptnum');
@@ -67,6 +67,13 @@ protected function process_quiz($data) {
$data->questions = $this->questions_recode_layout($data->questions);
+ // quiz->attempts can come both in data->attempts and
+ // data->attempts_number, handle both. MDL-26229
+ if (isset($data->attempts_number)) {
+ $data->attempts = $data->attempts_number;
+ unset($data->attempts_number);
+ }
+
// insert the quiz record
$newitemid = $DB->insert_record('quiz', $data);
// immediately after inserting "activity" record, call this

0 comments on commit 7cff492

Please sign in to comment.