From 9efaa719cc0891ca7a18388039bf89d1c4ff3cee Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Tue, 28 Mar 2023 10:22:25 +0100 Subject: [PATCH] MDL-77656 quiz: stop using displayed number as an id --- mod/quiz/classes/output/edit_renderer.php | 3 +-- .../editing_remove_multiple_questions.feature | 21 +++++++++++-------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/mod/quiz/classes/output/edit_renderer.php b/mod/quiz/classes/output/edit_renderer.php index 95c1f6aa30a..a13c0b4851a 100644 --- a/mod/quiz/classes/output/edit_renderer.php +++ b/mod/quiz/classes/output/edit_renderer.php @@ -796,9 +796,8 @@ class edit_renderer extends \plugin_renderer_base { $questionslot = $structure->get_displayed_number_for_slot($slot); $checkbox = new \core\output\checkbox_toggleall($this->togglegroup, false, [ - 'id' => 'selectquestion-' . $questionslot, + 'id' => 'selectquestion-' . $slot, 'name' => 'selectquestion[]', - 'value' => $questionslot, 'classes' => 'select-multiple-checkbox', 'label' => get_string('selectquestionslot', 'quiz', $questionslot), 'labelclasses' => 'sr-only', diff --git a/mod/quiz/tests/behat/editing_remove_multiple_questions.feature b/mod/quiz/tests/behat/editing_remove_multiple_questions.feature index fc3d913c79b..1e7ff95ad03 100644 --- a/mod/quiz/tests/behat/editing_remove_multiple_questions.feature +++ b/mod/quiz/tests/behat/editing_remove_multiple_questions.feature @@ -25,12 +25,14 @@ Feature: Edit quiz page - remove multiple questions @javascript Scenario: Delete selected question using select multiple items feature. Given the following "questions" exist: - | questioncategory | qtype | name | questiontext | - | Test questions | truefalse | Question A | This is question 01 | - | Test questions | truefalse | Question B | This is question 02 | - | Test questions | truefalse | Question C | This is question 03 | + | questioncategory | qtype | name | questiontext | + | Test questions | description | Info | Some instructions | + | Test questions | truefalse | Question A | This is question 01 | + | Test questions | truefalse | Question B | This is question 02 | + | Test questions | truefalse | Question C | This is question 03 | And quiz "Quiz 1" contains the following questions: | question | page | + | Info | 1 | | Question A | 1 | | Question B | 1 | | Question C | 2 | @@ -41,7 +43,7 @@ Feature: Edit quiz page - remove multiple questions And I should see "Question B" on quiz page "1" And I should see "Question C" on quiz page "2" And I should see "Total of marks: 3.00" - And I should see "Questions: 3" + And I should see "Questions: 4" And I should see "This quiz is open" # Delete last question in last page. Page contains multiple questions. No reordering. @@ -50,11 +52,12 @@ Feature: Edit quiz page - remove multiple questions And I click on "Delete selected" "button" And I click on "Yes" "button" in the "Confirm" "dialogue" - Then I should see "Question A" on quiz page "1" - And I should see "Question B" on quiz page "1" - And I should not see "Question C" on quiz page "2" + Then I should see "Info" on quiz page "1" + And I should see "Question A" on quiz page "1" + And I should not see "Question B" on quiz page "1" + And I should see "Question C" on quiz page "2" And I should see "Total of marks: 2.00" - And I should see "Questions: 2" + And I should see "Questions: 3" @javascript Scenario: Delete first selected question using select multiple items feature.