Skip to content

Commit

Permalink
Merge branch 'MDL-75744-311' of https://github.com/NashTechOpenUniver…
Browse files Browse the repository at this point in the history
…sity/moodle into MOODLE_311_STABLE
  • Loading branch information
andrewnicols committed Sep 27, 2022
2 parents 6a6344e + d03da85 commit e5bf98a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 11 deletions.
14 changes: 3 additions & 11 deletions question/type/gapselect/edit_form_base.php
Expand Up @@ -142,18 +142,10 @@ protected function definition_answer_choice(&$mform) {
$textboxgroup[] = $mform->createElement('group', 'choices',
get_string('choicex', 'qtype_gapselect'), $this->choice_group($mform));

if (isset($this->question->options)) {
$countanswers = count($this->question->options->answers);
if (!empty($this->question->options->answers)) {
$repeatsatstart = count($this->question->options->answers);
} else {
$countanswers = 0;
}

if ($this->question->formoptions->repeatelements) {
$defaultstartnumbers = QUESTION_NUMANS_START * 2;
$repeatsatstart = max($defaultstartnumbers, QUESTION_NUMANS_START,
$countanswers + QUESTION_NUMANS_ADD);
} else {
$repeatsatstart = $countanswers;
$repeatsatstart = QUESTION_NUMANS_ADD * 2;
}

$repeatedoptions = $this->repeated_options();
Expand Down
32 changes: 32 additions & 0 deletions question/type/gapselect/tests/behat/add.feature
Expand Up @@ -37,3 +37,35 @@ Feature: Test creating a Select missing words question
And I click on "Add" "button" in the "Choose a question type to add" "dialogue"
And the following fields match these values:
| id_shuffleanswers | 1 |

@javascript
Scenario: Edit a Select missing words question with 2 choice and should not have empty choice.
Given I am on the "Course 1" "core_question > course question bank" page logged in as teacher
And I add a "Select missing words" question filling the form with:
| Question name | Select missing words 002 |
| Question text | The [[1]] [[2]] on the mat. |
| General feedback | The cat sat on the mat. |
| id_shuffleanswers | 1 |
| id_choices_0_answer | cat |
| id_choices_1_answer | sat |
| id_choices_2_answer | dog |
| id_choices_2_choicegroup | 2 |
| id_choices_3_answer | stand |
| id_choices_3_choicegroup | 2 |
| Hint 1 | First hint |
| Hint 2 | Second hint |
When I choose "Edit question" action for "Select missing words 002" in the question bank
And the following fields match these values:
| Question name | Select missing words 002 |
| Question text | The [[1]] [[2]] on the mat. |
| General feedback | The cat sat on the mat. |
| id_shuffleanswers | 1 |
| id_choices_0_answer | cat |
| id_choices_1_answer | sat |
| id_choices_2_answer | dog |
| id_choices_2_choicegroup | 2 |
| id_choices_3_answer | stand |
| id_choices_3_choicegroup | 2 |
| Hint 1 | First hint |
| Hint 2 | Second hint |
Then I should not see "Choice [[5]]"

0 comments on commit e5bf98a

Please sign in to comment.