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