MDL-14750 - followup - make the code robust in the case their are broken questions in the DB.

This commit is contained in:
tjhunt 2008-05-15 16:05:47 +00:00
parent 994c8c3509
commit ed5ba2df55

View File

@ -52,9 +52,11 @@ function question_multianswer_fix_subquestion_parents_and_categories() {
'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');
if (!empty($q->sequence)) {
$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 {