mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
Following the fixes for MDL-14750 and MDL-10899, do a database upgrade that fixes any bogus values in the parent or category columns of multianswer questions' subquestions.
This commit is contained in:
parent
9ade28e57e
commit
e2134c5ddc
2 changed files with 29 additions and 2 deletions
|
@ -32,7 +32,34 @@ function xmldb_qtype_multianswer_upgrade($oldversion=0) {
|
|||
/// $result = result of "/lib/ddllib.php" function calls
|
||||
/// }
|
||||
|
||||
if ($result && $oldversion < 2008050800) {
|
||||
question_multianswer_fix_subquestion_parents_and_categories();
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Due to MDL-14750, subquestions of multianswer questions restored from backup will
|
||||
* have the wrong parent, and due to MDL-10899 subquestions of multianswer questions
|
||||
* that have been moved between categories will be in the wrong category, This code fixes these up.
|
||||
*/
|
||||
function question_multianswer_fix_subquestion_parents_and_categories() {
|
||||
global $CFG;
|
||||
|
||||
$result = true;
|
||||
$rs = get_recordset_sql('SELECT q.id, q.category, qma.sequence FROM ' . $CFG->prefix .
|
||||
'question q JOIN ' . $CFG->prefix . 'question_multianswer qma ON q.id = qma.question');
|
||||
if ($rs) {
|
||||
while ($q = rs_fetch_next_record($rs)) {
|
||||
$result = $result && execute_sql('UPDATE ' . $CFG->prefix . 'question' .
|
||||
' SET parent = ' . $q->id . ', category = ' . $q->category .
|
||||
' WHERE id IN (' . $q->sequence . ') AND parent <> 0');
|
||||
}
|
||||
rs_close($rs);
|
||||
} else {
|
||||
$result = false;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?PHP // $Id$
|
||||
|
||||
$plugin->version = 2006032200;
|
||||
$plugin->requires = 2007101000;
|
||||
$plugin->version = 2008050800;
|
||||
$plugin->requires = 2007101509;
|
||||
|
||||
?>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue