This commit is contained in:
Jun Pataleta 2022-10-06 10:14:07 +08:00
commit 9b0f435569
4 changed files with 70 additions and 6 deletions

View File

@ -64,7 +64,8 @@ class qtype_multichoice_edit_form extends question_edit_form {
$mform->addElement('selectyesno', 'showstandardinstruction',
get_string('showstandardinstruction', 'qtype_multichoice'), null, null, [0, 1]);
$mform->addHelpButton('showstandardinstruction', 'showstandardinstruction', 'qtype_multichoice');
$mform->setDefault('showstandardinstruction', $this->get_default_value('showstandardinstruction', 0));
$mform->setDefault('showstandardinstruction', $this->get_default_value('showstandardinstruction',
get_config('qtype_multichoice', 'showstandardinstruction')));
$this->add_per_answer_fields($mform, get_string('choiceno', 'qtype_multichoice', '{no}'),
question_bank::fraction_options_full(), max(5, QUESTION_NUMANS_START));

View File

@ -80,5 +80,6 @@ $string['shuffleanswers_desc'] = 'Whether options should be randomly shuffled fo
$string['shuffleanswers_help'] = 'If enabled, the order of the answers is randomly shuffled for each attempt, provided that "Shuffle within questions" in the activity settings is also enabled.';
$string['singleanswer'] = 'Choose one answer.';
$string['showstandardinstruction'] = 'Show standard instructions';
$string['showstandardinstruction_help'] = 'Whether to show the instructions "Select one:" or "Select one or more:" before multiple choice answers.';
$string['showstandardinstruction_desc'] = 'Whether to show the instructions "Select one:" or "Select one or more:" before multiple choice answers.';
$string['showstandardinstruction_help'] = 'Whether to show the instructions "Select one:" or "Select one or more:" before multiple choice answers. If disabled, question authors can instead include instructions in the question content, if required.';
$string['toomanyselected'] = 'You have selected too many options.';

View File

@ -25,10 +25,10 @@
defined('MOODLE_INTERNAL') || die();
if ($ADMIN->fulltree) {
$menu = array(
$menu = [
new lang_string('answersingleno', 'qtype_multichoice'),
new lang_string('answersingleyes', 'qtype_multichoice'),
);
new lang_string('answersingleyes', 'qtype_multichoice')
];
$settings->add(new admin_setting_configselect('qtype_multichoice/answerhowmany',
new lang_string('answerhowmany', 'qtype_multichoice'),
new lang_string('answerhowmany_desc', 'qtype_multichoice'), '1', $menu));
@ -39,6 +39,10 @@ if ($ADMIN->fulltree) {
$settings->add(new qtype_multichoice_admin_setting_answernumbering('qtype_multichoice/answernumbering',
new lang_string('answernumbering', 'qtype_multichoice'),
new lang_string('answernumbering_desc', 'qtype_multichoice'), 'abc', null ));
new lang_string('answernumbering_desc', 'qtype_multichoice'), 'abc', null));
$settings->add(new admin_setting_configcheckbox('qtype_multichoice/showstandardinstruction',
new lang_string('showstandardinstruction', 'qtype_multichoice'),
new lang_string('showstandardinstruction_desc', 'qtype_multichoice'), 0));
}

View File

@ -0,0 +1,58 @@
@qtype @qtype_multichoice @javascript
Feature: Test settings for Multiple choice question
As an admininstrator
In order to provide default settings for commonly used fields in Multiple choice questions
I need to be able to edit side-wide settings, so teachers have less fields to setup for their first time.
Background:
Given the following "users" exist:
| username |
| teacher |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher | C1 | editingteacher |
Scenario: Testing the settings for qtype_multichoice
Given I log in as "admin"
When I navigate to "Plugins > Question types > Multiple choice" in site administration
Then the following fields match these values:
|id_s_qtype_multichoice_answerhowmany | One answer only |
|id_s_qtype_multichoice_shuffleanswers | 1 |
|id_s_qtype_multichoice_answernumbering | a., b., c., ... |
|id_s_qtype_multichoice_showstandardinstruction | |
And I set the following fields to these values:
|id_s_qtype_multichoice_shuffleanswers | |
|id_s_qtype_multichoice_answernumbering | 1., 2., 3., ... |
|id_s_qtype_multichoice_showstandardinstruction | 1 |
And I press "Save changes"
And I log out
And I am on the "Course 1" "core_question > course question bank" page logged in as teacher
And I add a "Multiple choice" question filling the form with:
| Question name | Multi-choice-001 |
| Question text | Find the capital city of England. |
| General feedback | London is the capital city of England. |
| Default mark | 5 |
| Choice 1 | Manchester |
| Choice 2 | Buckingham |
| Choice 3 | London |
| Choice 4 | Barcelona |
| Choice 5 | Paris |
| id_fraction_0 | None |
| id_fraction_1 | None |
| id_fraction_2 | 100% |
| id_fraction_3 | None |
| id_fraction_4 | None |
| Hint 1 | First hint |
| Hint 2 | Second hint |
And I should see "Multi-choice-001"
And I press "Create a new question ..."
And I set the field "Multiple choice" to "1"
And I click on "Add" "button" in the "Choose a question type to add" "dialogue"
And the following fields match these values:
| One or multiple answers? | One answer only |
| Shuffle the choices? | |
| Number the choices? | 1., 2., 3., ... |
| Show standard instructions | Yes |