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 612dc9f commit 342dc2025ca0278fa255748e264655f8e8a9642e @timhunt timhunt committed 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
@@ -3842,7 +3842,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;
}
}
@@ -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, 2012061701, 'qbehaviour', 'manualgraded');
}
+ if ($oldversion < 2012061702) {
+ // 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, 2012061702, 'qbehaviour', 'manualgraded');
+ }
+
return true;
}
@@ -26,7 +26,7 @@
defined('MOODLE_INTERNAL') || die();
$plugin->component = 'qbehaviour_manualgraded';
-$plugin->version = 2012061701;
+$plugin->version = 2012061702;
$plugin->requires = 2012061700;

0 comments on commit 342dc20

Please sign in to comment.