MDL-20636 Fix new stdClass -> stdClass(), and trailing whitespace.
[moodle.git] / question / upgrade.php
CommitLineData
aeb15530 1<?php
bac40536 2/**
61676608 3 * This file contains datbase upgrade code that is called from lib/db/upgrade.php,
bac40536 4 * and also check methods that can be used for pre-install checks via
5 * admin/environment.php and lib/environmentlib.php.
6 *
b04a4319 7 * @copyright 2007 The Open University
bac40536 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;
61676608
PS
23 $DB->execute("UPDATE {question} SET parent = id WHERE qtype = 'random' AND parent <> id");
24 return true;
994fbaab 25}
26
aeb15530 27