diff --git a/question/behaviour/manualgraded/db/install.php b/question/behaviour/manualgraded/db/install.php new file mode 100644 index 00000000000..78187699d4b --- /dev/null +++ b/question/behaviour/manualgraded/db/install.php @@ -0,0 +1,49 @@ +. + +/** + * Post-install script for manual graded question behaviour. + * @package qbehaviour_manualgraded + * @copyright 2013 The Open Universtiy + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + + +defined('MOODLE_INTERNAL') || die(); + + +/** + * Post-install script + */ +function xmldb_qbehaviour_manualgraded_install() { + + // Hide the manualgraded behaviour from the list of behaviours that users + // can select in the user-interface. If a user accidentally chooses manual + // graded behaviour for a quiz, there is no way to get the questions automatically + // graded after the student has answered them. If teachers really want to do + // this they can ask their admin to enable it on the manage behaviours + // screen in the UI. + $disabledbehaviours = get_config('question', 'disabledbehaviours'); + if (!empty($disabledbehaviours)) { + $disabledbehaviours = explode(',', $disabledbehaviours); + } else { + $disabledbehaviours = array(); + } + if (array_search('manualgraded', $disabledbehaviours) === false) { + $disabledbehaviours[] = 'manualgraded'; + set_config('disabledbehaviours', implode(',', $disabledbehaviours), 'question'); + } +} diff --git a/question/behaviour/manualgraded/db/upgrade.php b/question/behaviour/manualgraded/db/upgrade.php new file mode 100644 index 00000000000..9c22cfb4c8d --- /dev/null +++ b/question/behaviour/manualgraded/db/upgrade.php @@ -0,0 +1,64 @@ +. + +/** + * Post-install script for the manual graded question behaviour. + * + * @package qbehaviour_manualgraded + * @copyright 2013 The Open Universtiy + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + + +defined('MOODLE_INTERNAL') || die(); + + +/** + * Manual graded question behaviour upgrade code. + */ +function xmldb_qbehaviour_manualgraded_upgrade($oldversion) { + global $DB; + + $dbman = $DB->get_manager(); + + // Moodle v2.4.0 release upgrade line + // Put any upgrade step following this + + if ($oldversion < 2013050200) { + // Hide the manualgraded behaviour from the list of behaviours that users + // can select in the user-interface. If a user accidentally chooses manual + // graded behaviour for a quiz, there is no way to get the questions automatically + // graded after the student has answered them. If teachers really want to do + // this they can ask their admin to enable it on the manage behaviours + // screen in the UI. + $disabledbehaviours = get_config('question', 'disabledbehaviours'); + if (!empty($disabledbehaviours)) { + $disabledbehaviours = explode(',', $disabledbehaviours); + } else { + $disabledbehaviours = array(); + } + if (array_search('manualgraded', $disabledbehaviours) === false) { + $disabledbehaviours[] = 'manualgraded'; + set_config('disabledbehaviours', implode(',', $disabledbehaviours), 'question'); + } + + // Manual graded question behaviour savepoint reached. + upgrade_plugin_savepoint(true, 2013050200, 'qbehaviour', 'manualgraded'); + } + + return true; +} + diff --git a/question/behaviour/manualgraded/version.php b/question/behaviour/manualgraded/version.php index c53f90f8ee4..c90df4be51d 100644 --- a/question/behaviour/manualgraded/version.php +++ b/question/behaviour/manualgraded/version.php @@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'qbehaviour_manualgraded'; -$plugin->version = 2013050100; +$plugin->version = 2013050200; $plugin->requires = 2013050100;