Permalink
Browse files

MDL-35793 question preview: config for the display options.

The settings control the display options used when a user
first previews a question in the question bank. Once a
user has previewed some questions, these are stored as user
preferences.

It may not seem worth making this configurable, but acutally
it is important when training new users to get them started
off using the right opitions.
  • Loading branch information...
timhunt committed Oct 16, 2012
1 parent 0dc5a53 commit 4125ded1396906ac552b4f49dab614cc29f67c6b
Showing with 53 additions and 2 deletions.
  1. +49 −0 admin/settings/plugins.php
  2. +2 −0 lang/en/question.php
  3. +2 −2 question/previewlib.php
View
@@ -316,13 +316,62 @@
require_once("$CFG->libdir/pluginlib.php");
$allplugins = plugin_manager::instance()->get_plugins();
}
+
// Question behaviour settings.
$ADMIN->add('modules', new admin_category('qbehavioursettings', new lang_string('questionbehaviours', 'admin')));
$ADMIN->add('qbehavioursettings', new admin_page_manageqbehaviours());
// Question type settings.
$ADMIN->add('modules', new admin_category('qtypesettings', new lang_string('questiontypes', 'admin')));
$ADMIN->add('qtypesettings', new admin_page_manageqtypes());
+
+ // Question preview defaults.
+ $settings = new admin_settingpage('qdefaultsetting',
+ get_string('questionpreviewdefaults', 'question'),
+ 'moodle/question:config');
+ $ADMIN->add('qtypesettings', $settings);
+
+ $settings->add(new admin_setting_heading('qdefaultsetting_preview_options',
+ '', get_string('questionpreviewdefaults_desc', 'question')));
+
+ // These keys are question_display_options::HIDDEN and VISIBLE.
+ $hiddenofvisible = array(
+ 0 => get_string('notshown', 'question'),
+ 1 => get_string('shown', 'question'),
+ );
+
+ $settings->add(new admin_setting_question_behaviour('question_preview/behaviour',
+ get_string('howquestionsbehave', 'question'), '',
+ 'deferredfeedback'));
+
+ $settings->add(new admin_setting_configselect('question_preview/correctness',
+ get_string('whethercorrect', 'question'), '', 1, $hiddenofvisible));
+
+ // These keys are question_display_options::HIDDEN, MARK_ONLY and MARK_AND_MAX.
+ $marksoptions = array(
+ 0 => get_string('notshown', 'question'),
+ 1 => get_string('showmaxmarkonly', 'question'),
+ 2 => get_string('showmarkandmax', 'question'),
+ );
+ $settings->add(new admin_setting_configselect('question_preview/marks',
+ get_string('marks', 'question'), '', 1, $marksoptions));
+
+ $settings->add(new admin_setting_configselect('question_preview/markdp',
+ get_string('decimalplacesingrades', 'question'), '', 2, array(0, 1, 2, 3, 4, 5, 6, 7)));
+
+ $settings->add(new admin_setting_configselect('question_preview/feedback',
+ get_string('specificfeedback', 'question'), '', 1, $hiddenofvisible));
+
+ $settings->add(new admin_setting_configselect('question_preview/generalfeedback',
+ get_string('generalfeedback', 'question'), '', 1, $hiddenofvisible));
+
+ $settings->add(new admin_setting_configselect('question_preview/rightanswer',
+ get_string('rightanswer', 'question'), '', 1, $hiddenofvisible));
+
+ $settings->add(new admin_setting_configselect('question_preview/history',
+ get_string('responsehistory', 'question'), '', 0, $hiddenofvisible));
+
+ // Settings for particular question types.
foreach ($allplugins['qtype'] as $qtype) {
$qtype->load_settings($ADMIN, 'qtypesettings', $hassiteconfig);
}
View
@@ -377,6 +377,8 @@
$string['questionbehavioursorderexplained'] = 'Enter a comma separated list of behaviours in the order you want them to appear in dropdown menu';
$string['questionidmismatch'] = 'Question ids mismatch';
$string['questionname'] = 'Question name';
+$string['questionpreviewdefaults'] = 'Question preview defaults';
+$string['questionpreviewdefaults_desc'] = 'These defaults are used when a user first previews a question in the question bank. Once a user has previewed a question, their personal preferences are stored as user preferences.';
$string['questions'] = 'Questions';
$string['questionx'] = 'Question {$a}';
$string['questiontext'] = 'Question text';
View
@@ -118,7 +118,6 @@ class question_preview_options extends question_display_options {
* Constructor.
*/
public function __construct($question) {
- global $CFG;
$this->behaviour = 'deferredfeedback';
$this->maxmark = $question->defaultmark;
$this->variant = null;
@@ -164,9 +163,10 @@ protected function get_field_types() {
* Load the value of the options from the user_preferences table.
*/
public function load_user_defaults() {
+ $defaults = get_config('question_preview');
foreach ($this->get_user_pref_fields() as $field) {
$this->$field = get_user_preferences(
- self::OPTIONPREFIX . $field, $this->$field);
+ self::OPTIONPREFIX . $field, $defaults->$field);
}
$this->numpartscorrect = $this->feedback;
}

0 comments on commit 4125ded

Please sign in to comment.