From f462a48202507f61ce44b8ee0030ce47c1fbbbd8 Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Fri, 29 Sep 2023 09:31:36 +0100 Subject: [PATCH] MDL-79507 quiz: Hide version info when rendering blocked questions --- mod/quiz/classes/quiz_attempt.php | 1 + .../behat/attempt_require_previous.feature | 27 ++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/mod/quiz/classes/quiz_attempt.php b/mod/quiz/classes/quiz_attempt.php index aacf15a5256..de5204ee5f0 100644 --- a/mod/quiz/classes/quiz_attempt.php +++ b/mod/quiz/classes/quiz_attempt.php @@ -1294,6 +1294,7 @@ class quiz_attempt { $displayoptions->manualcomment = question_display_options::HIDDEN; $displayoptions->history = question_display_options::HIDDEN; $displayoptions->readonly = true; + $displayoptions->versioninfo = question_display_options::HIDDEN; return html_writer::div($placeholderqa->render($displayoptions, $this->get_question_number($this->get_original_slot($slot))), diff --git a/mod/quiz/tests/behat/attempt_require_previous.feature b/mod/quiz/tests/behat/attempt_require_previous.feature index 4703e754b93..80d3863cabe 100644 --- a/mod/quiz/tests/behat/attempt_require_previous.feature +++ b/mod/quiz/tests/behat/attempt_require_previous.feature @@ -13,9 +13,9 @@ Feature: Attempt a quiz where some questions require that the previous question | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | student | C1 | student | - | teacher | C1 | teacher | + | user | course | role | + | student | C1 | student | + | teacher | C1 | editingteacher | And the following "question categories" exist: | contextlevel | reference | name | | Course | C1 | Test questions | @@ -48,6 +48,27 @@ Feature: Attempt a quiz where some questions require that the previous question And "Question 1" "link" should exist And "Question 2" "link" should not exist + @javascript + Scenario: A question is shown as blocked when previewing a quiz + Given the following "questions" exist: + | questioncategory | qtype | name | questiontext | + | Test questions | truefalse | TF1 | First question | + | Test questions | truefalse | TF2 | Second question | + And the following "activities" exist: + | activity | name | intro | course | idnumber | preferredbehaviour | + | quiz | Quiz 1 | Quiz 1 description | C1 | quiz1 | immediatefeedback | + And quiz "Quiz 1" contains the following questions: + | question | page | requireprevious | + | TF1 | 1 | 0 | + | TF2 | 1 | 1 | + + When I am on the "Quiz 1" "mod_quiz > View" page logged in as "teacher" + And I press "Preview quiz" + + Then I should see "First question" + And I should see "This question cannot be attempted until the previous question has been completed." + And I should not see "Second question" + @javascript Scenario: A question requires the previous one becomes available when the first one is answered Given the following "questions" exist: