diff --git a/admin/settings/plugins.php b/admin/settings/plugins.php index b7fa57e8884..f2d6f587f80 100644 --- a/admin/settings/plugins.php +++ b/admin/settings/plugins.php @@ -316,6 +316,7 @@ if ($hassiteconfig || has_capability('moodle/question:config', $systemcontext)) 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()); @@ -323,6 +324,54 @@ if ($hassiteconfig || has_capability('moodle/question:config', $systemcontext)) // 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); } diff --git a/lang/en/question.php b/lang/en/question.php index 56d1a07728e..021b7fd5b1a 100644 --- a/lang/en/question.php +++ b/lang/en/question.php @@ -379,6 +379,8 @@ $string['questionbehavioursorder'] = 'Question behaviours order'; $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'; diff --git a/question/previewlib.php b/question/previewlib.php index fc03097260f..2daa9cd927d 100644 --- a/question/previewlib.php +++ b/question/previewlib.php @@ -123,7 +123,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; @@ -169,9 +168,10 @@ class question_preview_options extends question_display_options { * 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; }