This commit is contained in:
Jun Pataleta 2024-07-17 12:44:29 +08:00
commit f96778f74d
No known key found for this signature in database
GPG Key ID: F83510526D99E2C7
5 changed files with 25 additions and 4 deletions

View File

@ -544,6 +544,18 @@ if ($hassiteconfig || has_capability('moodle/question:config', $systemcontext))
$settings->add(new admin_setting_configselect('question_preview/history',
get_string('responsehistory', 'question'), '', 0, $hiddenofvisible));
// Question editing settings.
$settings = new admin_settingpage('qediting',
get_string('questionediting', 'question'),
'moodle/question:config');
$ADMIN->add('qtypesettings', $settings);
$settings->add(new admin_setting_heading('qediting_options',
'', get_string('questionediting_desc', 'question')));
$settings->add(new admin_setting_configcheckbox('questiondefaultssave',
get_string('questiondefaultssave', 'question'), get_string('questiondefaultssave_desc', 'question'), 1));
// Settings for particular question types.
$plugins = core_plugin_manager::instance()->get_plugins_of_type('qtype');
core_collator::asort_objects_by_property($plugins, 'displayname');

View File

@ -449,6 +449,10 @@ $string['questionbehavioursdisabled'] = 'Question behaviours to disable';
$string['questionbehavioursdisabledexplained'] = 'Enter a comma-separated list of behaviours you do not want to appear in the drop-down menu.';
$string['questionbehavioursorder'] = 'Question behaviours order';
$string['questionbehavioursorderexplained'] = 'Enter a comma-separated list of behaviours in the order you want them to appear in the drop-down menu.';
$string['questiondefaultssave'] = 'Enable saving question defaults';
$string['questiondefaultssave_desc'] = 'When enabled, the value of certain question form elements will be saved as user preferences when the question editing form is submitted. The value stored in the user preference will then be used as the default value the next time the form is viewed.';
$string['questionediting'] = 'Question editing';
$string['questionediting_desc'] = 'These settings control aspects of the question editing forms';
$string['questionidmismatch'] = 'Question ids mismatch';
$string['questionformtagheader'] = '{$a} tags';
$string['questionname'] = 'Question name';

View File

@ -287,8 +287,8 @@ if ($mform->is_cancelled()) {
}
}
// If this is a new question, save defaults for user in user_preferences table.
if (empty($question->id)) {
// If this is a new question and question defaults save is enabled, save defaults for user in user_preferences table.
if (empty($question->id) && !empty($CFG->questiondefaultssave)) {
$qtypeobj->save_defaults_for_new_questions($fromform);
}
$question = $qtypeobj->save_question($question, $fromform);

View File

@ -140,7 +140,12 @@ abstract class question_edit_form extends question_wizard_form {
* @return string|null default value for a given form element.
*/
protected function get_default_value(string $name, $default): ?string {
return question_bank::get_qtype($this->qtype())->get_default_value($name, $default);
global $CFG;
if (!empty($CFG->questiondefaultssave)) {
return question_bank::get_qtype($this->qtype())->get_default_value($name, $default);
}
return $default;
}
/**

View File

@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2024071200.00; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2024071600.00; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.
$release = '4.5dev (Build: 20240712)'; // Human-friendly version name