MDL-20808 "Create AMF test client" Some updates to client
[moodle.git] / question / upgrade.php
blob5394e99ee05ba25c8fae2e4624519bac0286140a
1 <?php
2 /**
3 * This file contains datbase 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.
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
10 * @package questionbank
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.
21 function question_fix_random_question_parents() {
22 global $CFG, $DB;
23 $DB->execute("UPDATE {question} SET parent = id WHERE qtype = 'random' AND parent <> id");
24 return true;