From 5b152a44db3086614f85f65affe77a6e1ebbf28c Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Mon, 17 Nov 2025 10:46:01 +0800 Subject: [PATCH 1/4] MDL-87149 mod_feedback: Do not use `.feedback_is_dependent` anymore Making a visual distinction for dependent questions compared to other questions does not add much value in the perspective of users. We should just stop adding the `.feedback_is_dependent` class for dependent questions. --- public/mod/feedback/classes/complete_form.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/public/mod/feedback/classes/complete_form.php b/public/mod/feedback/classes/complete_form.php index bdd36d8f53a..eae37ffd03e 100644 --- a/public/mod/feedback/classes/complete_form.php +++ b/public/mod/feedback/classes/complete_form.php @@ -282,9 +282,6 @@ class mod_feedback_complete_form extends moodleform { */ protected function get_suggested_class($item) { $class = "feedback_itemlist feedback-item-{$item->typ}"; - if ($item->dependitem) { - $class .= " feedback_is_dependent"; - } if ($item->typ !== 'pagebreak') { $itemobj = feedback_get_item_class($item->typ); if ($itemobj->get_hasvalue()) { From 9620e6ec3439c791f426f1cbc315b7d31e25d2f9 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Mon, 17 Nov 2025 10:57:09 +0800 Subject: [PATCH 2/4] MDL-87149 theme_boost: Remove the .feedback_is_dependent class It's no longer being used. So, just remove it. --- public/theme/boost/scss/moodle/modules.scss | 3 --- public/theme/boost/style/moodle.css | 3 --- public/theme/classic/style/moodle.css | 3 --- 3 files changed, 9 deletions(-) diff --git a/public/theme/boost/scss/moodle/modules.scss b/public/theme/boost/scss/moodle/modules.scss index 865f8013228..57c2716f346 100644 --- a/public/theme/boost/scss/moodle/modules.scss +++ b/public/theme/boost/scss/moodle/modules.scss @@ -1549,9 +1549,6 @@ $popout-header-height: 4rem; span.feedback_info { font-weight: bold; } - div.feedback_is_dependent { - background: $gray-600; - } span.feedback_depend { color: $danger; } diff --git a/public/theme/boost/style/moodle.css b/public/theme/boost/style/moodle.css index c9e6b4fa0ef..8d61d8bd905 100644 --- a/public/theme/boost/style/moodle.css +++ b/public/theme/boost/style/moodle.css @@ -36825,9 +36825,6 @@ img.userpicture { .path-mod-feedback span.feedback_info { font-weight: bold; } -.path-mod-feedback div.feedback_is_dependent { - background: #6a737b; -} .path-mod-feedback span.feedback_depend { color: #ca3120; } diff --git a/public/theme/classic/style/moodle.css b/public/theme/classic/style/moodle.css index bc9f8729ddb..3bfbc40c3bb 100644 --- a/public/theme/classic/style/moodle.css +++ b/public/theme/classic/style/moodle.css @@ -36825,9 +36825,6 @@ img.userpicture { .path-mod-feedback span.feedback_info { font-weight: bold; } -.path-mod-feedback div.feedback_is_dependent { - background: #6a737b; -} .path-mod-feedback span.feedback_depend { color: #ca3120; } From 5f4e4d731d4a07524a6d3df0279cfb1a407674c5 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Mon, 17 Nov 2025 12:36:03 +0800 Subject: [PATCH 3/4] MDL-87149 mod_feedback: Generate dependent questions Allow the generator to create questions that depend on other questions. --- public/mod/feedback/tests/generator/lib.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/public/mod/feedback/tests/generator/lib.php b/public/mod/feedback/tests/generator/lib.php index 84f22393351..acd4500971d 100644 --- a/public/mod/feedback/tests/generator/lib.php +++ b/public/mod/feedback/tests/generator/lib.php @@ -103,6 +103,19 @@ class mod_feedback_generator extends testing_module_generator { $data['values'] = $this->format_item_values($questiontype, $data['values']); } + if (isset($data['dependitem'])) { + $select = 'label = ? OR name = ?'; + $params = [ + $data['dependitem'], + $data['dependitem'], + ]; + $dependid = $DB->get_field_select('feedback_item', 'id', $select, $params, MUST_EXIST); + $data['dependitem'] = $dependid; + } else { + // Make sure `dependvalue` is not set if we are not creating a dependent item. + unset($data['dependvalue']); + } + return call_user_func([$this, "create_item_{$questiontype}"], $feedback, $data); } From 04d7d3061f1dbd84754cc0e993944cfd6ae71b4e Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Mon, 17 Nov 2025 12:40:51 +0800 Subject: [PATCH 4/4] MDL-87149 mod_feedback: Accessibility Behat test coverage * Check the accessibility of the questionnaire, especially when there are dependent questions. * Use generators for a more efficient and faster test execution. --- .../tests/behat/preview_questions.feature | 35 +++++++++++++------ 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/public/mod/feedback/tests/behat/preview_questions.feature b/public/mod/feedback/tests/behat/preview_questions.feature index 6fdb33bf589..fccd512de94 100644 --- a/public/mod/feedback/tests/behat/preview_questions.feature +++ b/public/mod/feedback/tests/behat/preview_questions.feature @@ -19,16 +19,14 @@ Feature: Preview feedback questions | editingteacher | C1 | editingteacher | | teacher | C1 | teacher | And the following "activities" exist: - | activity | name | course | idnumber | - | feedback | Music history | C1 | feedback0 | - And I am on the "Music history" "feedback activity" page logged in as editingteacher - And I navigate to "Questions" in current page administration - And I add a "Multiple choice" question to the feedback with: - | Question | What is your favourite instrument | - | Label | instrument1 | - | Multiple choice type | Multiple choice - single answer | - | Multiple choice values | drums\guitar\hurdygurdy | - And I log out + | activity | name | course | idnumber | + | feedback | Music history | C1 | feedback0 | + And the following "mod_feedback > question" exists: + | activity | feedback0 | + | name | What is your favourite instrument | + | questiontype | multichoice | + | label | instrument1 | + | values | Drums\nGuitar\nHurdy-gurdy | Scenario: Students cannot see the Preview questions button When I am on the "Music history" "feedback activity" page logged in as student @@ -45,3 +43,20 @@ Feature: Preview feedback questions Then I should see "Preview questions" And I follow "Preview questions" And I should see "What is your favourite instrument" + + @javascript @accessibility + Scenario: Feedback questionnaire pages should be accessible + Given the following "mod_feedback > question" exists: + | activity | feedback0 | + | name | What type of guitar is your favourite? | + | questiontype | multichoice | + | label | whatguitar | + | dependitem | instrument1 | + | dependvalue | Guitar | + | values | Electric\nAcoustic\nBass | + When I am on the "Music history" "feedback activity" page logged in as editingteacher + And I navigate to "Questions" in current page administration + Then the "region-main" "region" should meet accessibility standards with "best-practice" extra tests + And I am on the "Music history" "feedback activity" page logged in as student + And I follow "Answer the questions" + And the "region-main" "region" should meet accessibility standards with "best-practice" extra tests