mirror of
https://github.com/moodle/moodle.git
synced 2025-02-08 09:02:07 +01:00
Merge branch 'MDL-28037' of git://github.com/timhunt/moodle
This commit is contained in:
commit
fae9cd077c
@ -2904,8 +2904,7 @@ abstract class restore_questions_activity_structure_step extends restore_activit
|
||||
$usage->preferredbehaviour = $quiz->preferredbehaviour;
|
||||
$usage->id = $DB->insert_record('question_usages', $usage);
|
||||
|
||||
$DB->set_field('quiz_attempts', 'uniqueid', $usage->id,
|
||||
array('id' => $this->get_mappingid('quiz_attempt', $data->id)));
|
||||
$this->inform_new_usage_id($usage->id);
|
||||
|
||||
$data->uniqueid = $usage->id;
|
||||
$upgrader->save_usage($quiz->preferredbehaviour, $data, $qas, $quiz->questions);
|
||||
|
@ -271,27 +271,19 @@ class restore_quiz_activity_structure_step extends restore_questions_activity_st
|
||||
}
|
||||
|
||||
protected function process_quiz_attempt($data) {
|
||||
global $DB;
|
||||
|
||||
$data = (object)$data;
|
||||
$oldid = $data->id;
|
||||
$olduniqueid = $data->uniqueid;
|
||||
|
||||
$data->quiz = $this->get_new_parentid('quiz');
|
||||
$data->attempt = $data->attemptnum;
|
||||
|
||||
$data->uniqueid = 0; // filled in later by {@link inform_new_usage_id()}
|
||||
|
||||
$data->userid = $this->get_mappingid('user', $data->userid);
|
||||
|
||||
$data->timestart = $this->apply_date_offset($data->timestart);
|
||||
$data->timefinish = $this->apply_date_offset($data->timefinish);
|
||||
$data->timemodified = $this->apply_date_offset($data->timemodified);
|
||||
|
||||
$newitemid = $DB->insert_record('quiz_attempts', $data);
|
||||
|
||||
// Save quiz_attempt->id mapping, because logs use it
|
||||
$this->set_mapping('quiz_attempt', $oldid, $newitemid, false);
|
||||
// The data is actually inserted into the database later in inform_new_usage_id.
|
||||
$this->currentquizattempt = clone($data);
|
||||
}
|
||||
|
||||
protected function process_quiz_attempt_legacy($data) {
|
||||
@ -306,8 +298,16 @@ class restore_quiz_activity_structure_step extends restore_questions_activity_st
|
||||
|
||||
protected function inform_new_usage_id($newusageid) {
|
||||
global $DB;
|
||||
$DB->set_field('quiz_attempts', 'uniqueid', $newusageid, array('id' =>
|
||||
$this->get_new_parentid('quiz_attempt')));
|
||||
|
||||
$data = $this->currentquizattempt;
|
||||
|
||||
$oldid = $data->id;
|
||||
$data->uniqueid = $newusageid;
|
||||
|
||||
$newitemid = $DB->insert_record('quiz_attempts', $data);
|
||||
|
||||
// Save quiz_attempt->id mapping, because logs use it
|
||||
$this->set_mapping('quiz_attempt', $oldid, $newitemid, false);
|
||||
}
|
||||
|
||||
protected function after_execute() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user