Skip to content

Commit

Permalink
MDL-35793 question preview: config for the display options.
Browse files Browse the repository at this point in the history
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 Dec 22, 2012
1 parent 0dc5a53 commit 4125ded
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
49 changes: 49 additions & 0 deletions admin/settings/plugins.php
Expand Up @@ -316,13 +316,62 @@
require_once("$CFG->libdir/pluginlib.php"); require_once("$CFG->libdir/pluginlib.php");
$allplugins = plugin_manager::instance()->get_plugins(); $allplugins = plugin_manager::instance()->get_plugins();
} }

// Question behaviour settings. // Question behaviour settings.
$ADMIN->add('modules', new admin_category('qbehavioursettings', new lang_string('questionbehaviours', 'admin'))); $ADMIN->add('modules', new admin_category('qbehavioursettings', new lang_string('questionbehaviours', 'admin')));
$ADMIN->add('qbehavioursettings', new admin_page_manageqbehaviours()); $ADMIN->add('qbehavioursettings', new admin_page_manageqbehaviours());


// Question type settings. // Question type settings.
$ADMIN->add('modules', new admin_category('qtypesettings', new lang_string('questiontypes', 'admin'))); $ADMIN->add('modules', new admin_category('qtypesettings', new lang_string('questiontypes', 'admin')));
$ADMIN->add('qtypesettings', new admin_page_manageqtypes()); $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) { foreach ($allplugins['qtype'] as $qtype) {
$qtype->load_settings($ADMIN, 'qtypesettings', $hassiteconfig); $qtype->load_settings($ADMIN, 'qtypesettings', $hassiteconfig);
} }
Expand Down
2 changes: 2 additions & 0 deletions lang/en/question.php
Expand Up @@ -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['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['questionidmismatch'] = 'Question ids mismatch';
$string['questionname'] = 'Question name'; $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['questions'] = 'Questions';
$string['questionx'] = 'Question {$a}'; $string['questionx'] = 'Question {$a}';
$string['questiontext'] = 'Question text'; $string['questiontext'] = 'Question text';
Expand Down
4 changes: 2 additions & 2 deletions question/previewlib.php
Expand Up @@ -118,7 +118,6 @@ class question_preview_options extends question_display_options {
* Constructor. * Constructor.
*/ */
public function __construct($question) { public function __construct($question) {
global $CFG;
$this->behaviour = 'deferredfeedback'; $this->behaviour = 'deferredfeedback';
$this->maxmark = $question->defaultmark; $this->maxmark = $question->defaultmark;
$this->variant = null; $this->variant = null;
Expand Down Expand Up @@ -164,9 +163,10 @@ protected function get_field_types() {
* Load the value of the options from the user_preferences table. * Load the value of the options from the user_preferences table.
*/ */
public function load_user_defaults() { public function load_user_defaults() {
$defaults = get_config('question_preview');
foreach ($this->get_user_pref_fields() as $field) { foreach ($this->get_user_pref_fields() as $field) {
$this->$field = get_user_preferences( $this->$field = get_user_preferences(
self::OPTIONPREFIX . $field, $this->$field); self::OPTIONPREFIX . $field, $defaults->$field);
} }
$this->numpartscorrect = $this->feedback; $this->numpartscorrect = $this->feedback;
} }
Expand Down

0 comments on commit 4125ded

Please sign in to comment.