Permalink
Browse files

MDL-39412 disabling manual graded behaviour refinements

1. Change behaviour admin settings so you can only select enabled
behaviours.
2. During the upgrade, change admin settings that might be currently set
to manual graded, so that instead they are set to deferredfeedback (if
that is available. If not, we just take the first alphabetically.)
  • Loading branch information...
1 parent e9df9e8 commit cbdb09a9ef79bbfd798b8fb5f9b2f2f74fb13509 @timhunt timhunt committed with damyon May 8, 2013
Showing with 30 additions and 3 deletions.
  1. +1 −1 lib/adminlib.php
  2. +28 −1 question/behaviour/manualgraded/db/upgrade.php
  3. +1 −1 question/behaviour/manualgraded/version.php
View
2 lib/adminlib.php
@@ -4142,7 +4142,7 @@ public function __construct($name, $visiblename, $description, $default) {
public function load_choices() {
global $CFG;
require_once($CFG->dirroot . '/question/engine/lib.php');
- $this->choices = question_engine::get_archetypal_behaviours();
+ $this->choices = question_engine::get_behaviour_options();
return true;
}
}
View
29 question/behaviour/manualgraded/db/upgrade.php
@@ -30,7 +30,7 @@
* Manual graded question behaviour upgrade code.
*/
function xmldb_qbehaviour_manualgraded_upgrade($oldversion) {
- global $DB;
+ global $CFG, $DB;
$dbman = $DB->get_manager();
@@ -59,6 +59,33 @@ function xmldb_qbehaviour_manualgraded_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2013050200, 'qbehaviour', 'manualgraded');
}
+ if ($oldversion < 2013050800) {
+ // Also, fix any other admin settings that currently select manualgraded behaviour.
+
+ // Work out a sensible default alternative to manualgraded.
+ require_once($CFG->libdir . '/questionlib.php');
+ $behaviours = question_engine::get_behaviour_options();
+ if (array_key_exists('deferredfeedback', $behaviours)) {
+ $defaultbehaviour = 'deferredfeedback';
+ } else {
+ reset($behaviours);
+ $defaultbehaviour = key($behaviours);
+ }
+
+ // Fix the question preview default.
+ if (get_config('question_preview', 'behaviour') == 'manualgraded') {
+ set_config('behaviour', $defaultbehaviour, 'question_preview');
+ }
+
+ // Fix the quiz settings default.
+ if (get_config('quiz', 'preferredbehaviour') == 'manualgraded') {
+ set_config('preferredbehaviour', $defaultbehaviour, 'quiz');
+ }
+
+ // Manual graded question behaviour savepoint reached.
+ upgrade_plugin_savepoint(true, 2013050800, 'qbehaviour', 'manualgraded');
+ }
+
return true;
}
View
2 question/behaviour/manualgraded/version.php
@@ -26,7 +26,7 @@
defined('MOODLE_INTERNAL') || die();
$plugin->component = 'qbehaviour_manualgraded';
-$plugin->version = 2013050200;
+$plugin->version = 2013050800;
$plugin->requires = 2013050100;

0 comments on commit cbdb09a

Please sign in to comment.