MDL-20636 Fix @package names and PHPdoc layout.
[moodle.git] / question / upgrade.php
CommitLineData
aeb15530 1<?php
d3603157
TH
2
3// This file is part of Moodle - http://moodle.org/
4//
5// Moodle is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// Moodle is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17
bac40536 18/**
61676608 19 * This file contains datbase upgrade code that is called from lib/db/upgrade.php,
bac40536 20 * and also check methods that can be used for pre-install checks via
21 * admin/environment.php and lib/environmentlib.php.
22 *
d3603157
TH
23 * @package moodlecore
24 * @subpackage questionbank
25 * @copyright 2007 The Open University
26 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
271e6dec 27 */
bac40536 28
d3603157 29
994fbaab 30/**
31 * In Moodle, all random questions should have question.parent set to be the same
32 * as question.id. One effect of MDL-5482 is that this will not be true for questions that
33 * were backed up then restored. The probably does not cause many problems, except occasionally,
34 * if the bogus question.parent happens to point to a multianswer question type, or when you
35 * try to do a subsequent backup. Anyway, these question.parent values should be fixed, and
36 * that is what this update does.
37 */
38function question_fix_random_question_parents() {
f34488b2 39 global $CFG, $DB;
61676608
PS
40 $DB->execute("UPDATE {question} SET parent = id WHERE qtype = 'random' AND parent <> id");
41 return true;
994fbaab 42}