MDL-9616 - Custom checks in environment.xml
[moodle.git] / question / upgrade.php
CommitLineData
bac40536 1<?php
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
10 * @package package_name
11 *//** */
12
13/**
14 * This test is becuase the RQP question type was included in core
15 * up to and including Moodle 1.8, and was removed before Moodle 1.9.
16 *
17 * Therefore, we want to check whether any rqp questions exist in the database
18 * before doing the upgrade. However, the check is not relevant if that
19 * question type was never installed, or if the person has chosen to
20 * manually reinstall the rqp question type from contrib.
21 *
22 * @param $version the version to test.
23 * @return null if the test is irrelevant, or true or false depending on whether the test passes.
24 */
25function question_check_no_rqp_questions($result) {
26 global $CFG;
27
28 if (empty($CFG->qtype_rqp_version) || is_dir($CFG->dirroot . '/question/type/rqp')) {
29 return null;
30 } else {
31 $result->setStatus(count_records('question', 'qtype', 'rqp') == 0);
32 }
33 return $result;
34}
35?>