From 99a6ea40aca947406dd9bbc6e020636c45a8ce71 Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Tue, 28 Feb 2023 16:29:03 +0000 Subject: [PATCH] MDL-77440 quiz: fix nav error reviewing after redoing a question --- mod/quiz/reviewquestion.php | 4 ++- .../behat/attempt_redo_questions.feature | 32 +++++++++++++++++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/mod/quiz/reviewquestion.php b/mod/quiz/reviewquestion.php index f49306b9774..f544d225140 100644 --- a/mod/quiz/reviewquestion.php +++ b/mod/quiz/reviewquestion.php @@ -101,7 +101,9 @@ $summarydata['questionname'] = array( // Other attempts at the quiz. if ($attemptobj->has_capability('mod/quiz:viewreports')) { - $attemptlist = $attemptobj->links_to_other_attempts($baseurl); + $otherattemptsurl = clone($baseurl); + $otherattemptsurl->param('slot', $attemptobj->get_original_slot($slot)); + $attemptlist = $attemptobj->links_to_other_attempts($otherattemptsurl); if ($attemptlist) { $summarydata['attemptlist'] = array( 'title' => get_string('attempts', 'quiz'), diff --git a/mod/quiz/tests/behat/attempt_redo_questions.feature b/mod/quiz/tests/behat/attempt_redo_questions.feature index 58e8e950eca..35d9abda7da 100644 --- a/mod/quiz/tests/behat/attempt_redo_questions.feature +++ b/mod/quiz/tests/behat/attempt_redo_questions.feature @@ -115,7 +115,7 @@ Feature: Allow students to redo questions in a practice quiz, without starting a @javascript @_switch_window Scenario: Teachers reviewing can see all the questions attempted in a slot Given I am on the "Quiz 1" "mod_quiz > View" page logged in as "student" - When I press "Attempt quiz" + And I press "Attempt quiz" And I click on "False" "radio" in the "First question" "question" And I click on "Check" "button" in the "First question" "question" And I press "Try another question like this one" @@ -123,7 +123,7 @@ Feature: Allow students to redo questions in a practice quiz, without starting a And I press "Submit all and finish" And I click on "Submit all and finish" "button" in the "Submit all your answers and finish?" "dialogue" And I log out - And I am on the "Quiz 1" "mod_quiz > View" page logged in as "teacher" + When I am on the "Quiz 1" "mod_quiz > View" page logged in as "teacher" And I follow "Attempts: 1" And I follow "Review attempt" And I click on "1" "link" in the "First question" "question" @@ -140,6 +140,34 @@ Feature: Allow students to redo questions in a practice quiz, without starting a And "True" row "Frequency" column of "quizresponseanalysis" table should contain "0.00%" And "[No response]" row "Frequency" column of "quizresponseanalysis" table should contain "100.00%" + @javascript @_switch_window + Scenario: Teachers reviewing can switch between attempts in the review question popup + Given I am on the "Quiz 1" "mod_quiz > View" page logged in as student + # Create two attempts, only one of which has a redo. + When I press "Attempt quiz" + And I click on "False" "radio" in the "First question" "question" + And I click on "Check" "button" in the "First question" "question" + And I press "Try another question like this one" + And I press "Finish attempt ..." + And I press "Submit all and finish" + And I click on "Submit all and finish" "button" in the "Submit all your answers and finish?" "dialogue" + And I follow "Finish review" + And I press "Re-attempt quiz" + And I click on "True" "radio" in the "First question" "question" + And I click on "Check" "button" in the "First question" "question" + And I log out + And I am on the "Quiz 1" "mod_quiz > View" page logged in as teacher + And I follow "Attempts: 2" + # Review the first attempt - and switch to the first question seen. + And I follow "Review attempt" + And I click on "1" "link" in the "First question" "question" + And I switch to "reviewquestion" window + And the state of "First question" question is shown as "Incorrect" + # Now switch to the other quiz attempt using the link at the top, which does not have a redo. + And I click on "2" "link" in the "Attempts" "table_row" + Then the state of "First question" question is shown as "Correct" + And I should not see "Other questions attempted here" + @javascript Scenario: Redoing question 1 should save any changes to question 2 on the same page Given I am on the "Quiz 1" "mod_quiz > View" page logged in as "student"