mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
MDL-26229 backup & restore - fix quiz & lesson conflicts
This commit is contained in:
parent
945962a45d
commit
7cff4927be
@ -76,8 +76,11 @@ class backup_lesson_activity_structure_step extends backup_activity_structure_st
|
|||||||
'minquestions','maxpages','timed','maxtime','retake','activitylink',
|
'minquestions','maxpages','timed','maxtime','retake','activitylink',
|
||||||
'mediafile','mediaheight','mediawidth','mediaclose','slideshow',
|
'mediafile','mediaheight','mediawidth','mediaclose','slideshow',
|
||||||
'width','height','bgcolor','displayleft','displayleftif','progressbar',
|
'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
|
// The lesson_pages table
|
||||||
// Grouped within a `pages` element, important to note that page is relational
|
// Grouped within a `pages` element, important to note that page is relational
|
||||||
|
@ -62,6 +62,13 @@ class restore_lesson_activity_structure_step extends restore_activity_structure_
|
|||||||
$data->deadline = $this->apply_date_offset($data->deadline);
|
$data->deadline = $this->apply_date_offset($data->deadline);
|
||||||
$data->timemodified = $this->apply_date_offset($data->timemodified);
|
$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
|
// insert the lesson record
|
||||||
$newitemid = $DB->insert_record('lesson', $data);
|
$newitemid = $DB->insert_record('lesson', $data);
|
||||||
// immediately after inserting "activity" record, call this
|
// immediately after inserting "activity" record, call this
|
||||||
|
@ -39,7 +39,7 @@ class backup_quiz_activity_structure_step extends backup_questions_activity_stru
|
|||||||
// Define each element separated
|
// Define each element separated
|
||||||
$quiz = new backup_nested_element('quiz', array('id'), array(
|
$quiz = new backup_nested_element('quiz', array('id'), array(
|
||||||
'name', 'intro', 'introformat', 'timeopen',
|
'name', 'intro', 'introformat', 'timeopen',
|
||||||
'timeclose', 'optionflags', 'penaltyscheme', 'attempts',
|
'timeclose', 'optionflags', 'penaltyscheme', 'attempts_number',
|
||||||
'attemptonlast', 'grademethod', 'decimalpoints', 'questiondecimalpoints',
|
'attemptonlast', 'grademethod', 'decimalpoints', 'questiondecimalpoints',
|
||||||
'review', 'questionsperpage', 'shufflequestions', 'shuffleanswers',
|
'review', 'questionsperpage', 'shufflequestions', 'shuffleanswers',
|
||||||
'questions', 'sumgrades', 'grade', 'timecreated',
|
'questions', 'sumgrades', 'grade', 'timecreated',
|
||||||
@ -119,6 +119,7 @@ class backup_quiz_activity_structure_step extends backup_questions_activity_stru
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Define source alias
|
// Define source alias
|
||||||
|
$quiz->set_source_alias('attempts', 'attempts_number');
|
||||||
$grade->set_source_alias('grade', 'gradeval');
|
$grade->set_source_alias('grade', 'gradeval');
|
||||||
$attempt->set_source_alias('attempt', 'attemptnum');
|
$attempt->set_source_alias('attempt', 'attemptnum');
|
||||||
|
|
||||||
|
@ -67,6 +67,13 @@ class restore_quiz_activity_structure_step extends restore_questions_activity_st
|
|||||||
|
|
||||||
$data->questions = $this->questions_recode_layout($data->questions);
|
$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
|
// insert the quiz record
|
||||||
$newitemid = $DB->insert_record('quiz', $data);
|
$newitemid = $DB->insert_record('quiz', $data);
|
||||||
// immediately after inserting "activity" record, call this
|
// immediately after inserting "activity" record, call this
|
||||||
|
Loading…
x
Reference in New Issue
Block a user