mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
When restoring numerical questions, don't create duplicate unit definitions. Merged from MOODLE_18_STABLE.
This commit is contained in:
parent
51e89d95f7
commit
a24a414f24
1 changed files with 18 additions and 12 deletions
|
@ -427,7 +427,7 @@
|
||||||
return $status;
|
return $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
function question_restore_numerical_units ($old_question_id,$new_question_id,$info,$restore) {
|
function question_restore_numerical_units($old_question_id,$new_question_id,$info,$restore) {
|
||||||
|
|
||||||
global $CFG;
|
global $CFG;
|
||||||
|
|
||||||
|
@ -447,17 +447,23 @@
|
||||||
//print_object ($GLOBALS['traverse_array']); //Debug
|
//print_object ($GLOBALS['traverse_array']); //Debug
|
||||||
//$GLOBALS['traverse_array']=""; //Debug
|
//$GLOBALS['traverse_array']=""; //Debug
|
||||||
|
|
||||||
//Now, build the question_numerical_UNITS record structure
|
// Check to see if this until already exists in the database, which it might, for
|
||||||
$numerical_unit = new stdClass;
|
// Historical reasons.
|
||||||
$numerical_unit->question = $new_question_id;
|
$unit = backup_todb($nu_info['#']['UNIT']['0']['#']);
|
||||||
$numerical_unit->multiplier = backup_todb($nu_info['#']['MULTIPLIER']['0']['#']);
|
if (!record_exists('question_numerical_units', 'question', $new_question_id, 'unit', $unit)) {
|
||||||
$numerical_unit->unit = backup_todb($nu_info['#']['UNIT']['0']['#']);
|
|
||||||
|
//Now, build the question_numerical_UNITS record structure.
|
||||||
//The structure is equal to the db, so insert the question_numerical_units
|
$numerical_unit = new stdClass;
|
||||||
$newid = insert_record ("question_numerical_units",$numerical_unit);
|
$numerical_unit->question = $new_question_id;
|
||||||
|
$numerical_unit->multiplier = backup_todb($nu_info['#']['MULTIPLIER']['0']['#']);
|
||||||
if (!$newid) {
|
$numerical_unit->unit = $unit;
|
||||||
$status = false;
|
|
||||||
|
//The structure is equal to the db, so insert the question_numerical_units
|
||||||
|
$newid = insert_record("question_numerical_units", $numerical_unit);
|
||||||
|
|
||||||
|
if (!$newid) {
|
||||||
|
$status = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue