diff --git a/admin/environment.xml b/admin/environment.xml index 31477f927a0..916b91a10e1 100644 --- a/admin/environment.xml +++ b/admin/environment.xml @@ -1122,5 +1122,12 @@ + + + + + + + diff --git a/lang/en/admin.php b/lang/en/admin.php index 650fd658bfe..66efc52dbaa 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -892,6 +892,7 @@ $string['questioncwqpfscheck'] = 'One or more \'random\' questions in a quiz are $string['questioncwqpfsok'] = 'Good. There are no \'random\' questions in your quizzes that are set up to select questions from a mixture of shared and unshared question categories.'; $string['questiontype'] = 'Question type'; $string['questiontypes'] = 'Question types'; +$string['quizattemptsupgradedmessage'] = 'In Moodle 2.1 there was a major upgrade to questions. It was possible to delay parts of the database upgrade to be run later. Before upgrading to Moodle 2.7, this upgrade must be completed.'; $string['recaptchaprivatekey'] = 'ReCAPTCHA private key'; $string['recaptchapublickey'] = 'ReCAPTCHA public key'; $string['register'] = 'Register your site'; diff --git a/lib/customcheckslib.php b/lib/customcheckslib.php index 7c63c502f79..5a155539b66 100644 --- a/lib/customcheckslib.php +++ b/lib/customcheckslib.php @@ -15,15 +15,16 @@ // along with Moodle. If not, see . /** - * This is a one-line short description of the file + * This is a place to put custom environment checks, if there is not a better place. * * This library contains a collection of functions able to perform * some custom checks executed by environmental tests (automatically * executed on install & upgrade and under petition in the admin block). * - * Any function in this library must return: + * Any function in this library gets a environment_results object passed in. + * It must return: * - null: if the test isn't relevant and must not be showed (ignored) - * - environment_results object with the status set to: + * - the environment_results object that was passed in, with the status set to: * - true: if passed * - false: if failed * diff --git a/lib/environmentlib.php b/lib/environmentlib.php index 3d8a0dffd33..73337b2453f 100644 --- a/lib/environmentlib.php +++ b/lib/environmentlib.php @@ -1123,7 +1123,7 @@ class environment_results { */ var $part; /** - * @var bool + * @var bool true means the test passed and all is OK. false means it failed. */ var $status; /** @@ -1180,11 +1180,11 @@ class environment_results { /** * Set the status * - * @param boolean $status the status (true/false) + * @param bool $testpassed true means the test passed and all is OK. false means it failed. */ - function setStatus($status) { - $this->status=$status; - if ($status) { + function setStatus($testpassed) { + $this->status = $testpassed; + if ($testpassed) { $this->setErrorCode(NO_ERROR); } } @@ -1274,7 +1274,7 @@ class environment_results { /** * Get the status * - * @return boolean result + * @return bool true means the test passed and all is OK. false means it failed. */ function getStatus() { return $this->status; diff --git a/question/engine/upgrade/upgradelib.php b/question/engine/upgrade/upgradelib.php index 531889dbe77..9cb15e55b71 100644 --- a/question/engine/upgrade/upgradelib.php +++ b/question/engine/upgrade/upgradelib.php @@ -621,3 +621,32 @@ class question_deleted_question_attempt_updater extends question_qtype_attempt_u $data['upgradedfromdeletedquestion'] = $state->answer; } } + +/** + * This check verifies that all quiz attempts were upgraded since following + * the question engine upgrade in Moodle 2.1. + * + * @param environment_results object to update, if relevant. + * @return environment_results updated results object, or null if this test is not relevant. + */ +function quiz_attempts_upgraded(environment_results $result) { + global $DB; + + $dbman = $DB->get_manager(); + $table = new xmldb_table('quiz_attempts'); + $field = new xmldb_field('needsupgradetonewqe'); + + if (!$dbman->table_exists($table) || !$dbman->field_exists($table, $field)) { + // DB already upgraded. This test is no longer relevant. + return null; + } + + if (!$DB->record_exists('quiz_attempts', array('needsupgradetonewqe' => 1))) { + // No 1s present in that column means there are no problems. + return null; + } + + // Only display anything if the admins need to be aware of the problem. + $result->setStatus(false); + return $result; +}