Skip to content

Commit

Permalink
Merge branch 'MDL-28037' of git://github.com/timhunt/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Jun 29, 2011
2 parents 282a0a7 + 50de6ad commit fae9cd0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
3 changes: 1 addition & 2 deletions backup/moodle2/restore_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2904,8 +2904,7 @@ protected function process_legacy_quiz_attempt_data($data, $quiz) {
$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);
Expand Down
24 changes: 12 additions & 12 deletions mod/quiz/backup/moodle2/restore_quiz_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,27 +271,19 @@ protected function process_quiz_grade($data) {
}

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) {
Expand All @@ -306,8 +298,16 @@ protected function process_quiz_attempt_legacy($data) {

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() {
Expand Down

0 comments on commit fae9cd0

Please sign in to comment.