MDL-20636 Fix new stdClass -> stdClass(), and trailing whitespace.
[moodle.git] / question / type / multianswer / db / upgrade.php
CommitLineData
aeb15530 1<?php
dfdd5332 2
aeb15530 3// This file keeps track of upgrades to
dfdd5332 4// the multianswer qtype plugin
5//
6// Sometimes, changes between versions involve
7// alterations to database structures and other
8// major things that may break installations.
9//
10// The upgrade function in this file will attempt
11// to perform all the necessary actions to upgrade
2e0406a5 12// your older installation to the current version.
dfdd5332 13//
14// If there's something it cannot do itself, it
15// will tell you what you need to do.
16//
17// The commands in here will all be database-neutral,
b1f93b15 18// using the methods of database_manager class
775f811a 19//
20// Please do not forget to use upgrade_set_timeout()
21// before any action that may take longer time to finish.
dfdd5332 22
775f811a 23function xmldb_qtype_multianswer_upgrade($oldversion) {
24 global $CFG, $DB;
dfdd5332 25
775f811a 26 $dbman = $DB->get_manager();
dfdd5332 27
a4cdd6d2
PS
28 if ($oldversion < 2008050800) {
29 //hey - no functions here in this file !!!!!!!
e2134c5d 30
a4cdd6d2
PS
31 $rs = $DB->get_recordset_sql("SELECT q.id, q.category, qma.sequence
32 FROM {question} q
33 JOIN {question_multianswer} qma ON q.id = qma.question");
bae73624 34 foreach ($rs as $q) {
ed5ba2df 35 if (!empty($q->sequence)) {
a4cdd6d2
PS
36 $DB->execute("UPDATE {question}
37 SET parent = ?, category = ?
38 WHERE id IN ($q->sequence) AND parent <> 0",
39 array($q->id, $q->category));
ed5ba2df 40 }
e2134c5d 41 }
bae73624 42 $rs->close();
a4cdd6d2
PS
43
44 /// multianswer savepoint reached
45 upgrade_plugin_savepoint(true, 2008050800, 'qtype', 'multianswer');
e2134c5d 46 }
aeb15530 47
a4cdd6d2
PS
48 return true;
49}