MDL-66796 mod_quiz: only update the id number if changed
If the idnumber is present in the DB, it's set to null. In this case, don't update the value.
This commit is contained in:
@@ -470,6 +470,7 @@ class question_category_object {
|
||||
$cat->sortorder = 999;
|
||||
$cat->stamp = make_unique_id_code();
|
||||
$cat->idnumber = $idnumber;
|
||||
|
||||
$categoryid = $DB->insert_record("question_categories", $cat);
|
||||
|
||||
// Log the creation of this category.
|
||||
@@ -532,6 +533,7 @@ class question_category_object {
|
||||
}
|
||||
}
|
||||
|
||||
$updateidnumber = true;
|
||||
if ((string) $idnumber === '') {
|
||||
$idnumber = null;
|
||||
} else if (!empty($tocontextid)) {
|
||||
@@ -539,6 +541,7 @@ class question_category_object {
|
||||
if ($DB->record_exists('question_categories',
|
||||
['idnumber' => $idnumber, 'contextid' => $tocontextid])) {
|
||||
$idnumber = null;
|
||||
$updateidnumber = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -550,7 +553,9 @@ class question_category_object {
|
||||
$cat->infoformat = $newinfoformat;
|
||||
$cat->parent = $parentid;
|
||||
$cat->contextid = $tocontextid;
|
||||
$cat->idnumber = $idnumber;
|
||||
if ($updateidnumber) {
|
||||
$cat->idnumber = $idnumber;
|
||||
}
|
||||
if ($newstamprequired) {
|
||||
$cat->stamp = make_unique_id_code();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user