MDL-20601 fixed fatal SQL upgrade error, missing {} around table names
[moodle.git] / question / upgrade.php
CommitLineData
0c982226 1<?php // $Id$
bac40536 2/**
3 * This file contains dtabase upgrade code that is called from lib/db/upgrade.php,
4 * and also check methods that can be used for pre-install checks via
5 * admin/environment.php and lib/environmentlib.php.
6 *
7 * @copyright &copy; 2007 The Open University
8 * @author T.J.Hunt@open.ac.uk
9 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
0c982226 10 * @package questionbank
271e6dec 11 */
bac40536 12
994fbaab 13/**
14 * In Moodle, all random questions should have question.parent set to be the same
15 * as question.id. One effect of MDL-5482 is that this will not be true for questions that
16 * were backed up then restored. The probably does not cause many problems, except occasionally,
17 * if the bogus question.parent happens to point to a multianswer question type, or when you
18 * try to do a subsequent backup. Anyway, these question.parent values should be fixed, and
19 * that is what this update does.
20 */
21function question_fix_random_question_parents() {
f34488b2 22 global $CFG, $DB;
23 return $DB->execute("UPDATE {question} SET parent = id WHERE qtype = 'random' AND parent <> id");
994fbaab 24}
25
bac40536 26?>