From 80c360d573a9c04f3bcbbf8ea0732f4330831567 Mon Sep 17 00:00:00 2001 From: Shamim Rezaie Date: Mon, 20 May 2019 22:56:57 +1000 Subject: [PATCH] MDL-65630 mod_quiz: Allow redo within an attempt with random questions --- mod/quiz/attemptlib.php | 2 +- .../behat/attempt_redo_questions.feature | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/mod/quiz/attemptlib.php b/mod/quiz/attemptlib.php index 1f6674a9a08..87d29437dad 100644 --- a/mod/quiz/attemptlib.php +++ b/mod/quiz/attemptlib.php @@ -588,7 +588,7 @@ class quiz_attempt { $this->quba = question_engine::load_questions_usage_by_activity($this->attempt->uniqueid); $this->slots = $DB->get_records('quiz_slots', array('quizid' => $this->get_quizid()), 'slot', - 'slot, requireprevious, questionid, includingsubcategories'); + 'slot, id, requireprevious, questionid, includingsubcategories'); $this->sections = array_values($DB->get_records('quiz_sections', array('quizid' => $this->get_quizid()), 'firstslot')); diff --git a/mod/quiz/tests/behat/attempt_redo_questions.feature b/mod/quiz/tests/behat/attempt_redo_questions.feature index 4499aaad480..fbadb44b45f 100644 --- a/mod/quiz/tests/behat/attempt_redo_questions.feature +++ b/mod/quiz/tests/behat/attempt_redo_questions.feature @@ -116,3 +116,23 @@ Feature: Allow students to redo questions in a practice quiz, without starting a And I press "Try another question like this one" And I click on "Check" "button" in the "Second question" "question" Then the state of "Second question" question is shown as "Correct" + + @javascript + Scenario: Redoing questions should work with random questions as well + Given the following "questions" exist: + | questioncategory | qtype | name | questiontext | + | Test questions | random | Random (Test questions) | 0 | + And the following "activities" exist: + | activity | name | intro | course | idnumber | preferredbehaviour | canredoquestions | + | quiz | Quiz 2 | Quiz 2 description | C1 | quiz2 | immediatefeedback | 1 | + And quiz "Quiz 2" contains the following questions: + | question | page | + | Random (Test questions) | 1 | + And I log in as "student" + And I am on "Course 1" course homepage + When I follow "Quiz 2" + And I press "Attempt quiz now" + And I click on "False" "radio" + And I click on "Check" "button" + And I press "Try another question like this one" + Then "Check" "button" should exist