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 218976ad867..fbadb44b45f 100644 --- a/mod/quiz/tests/behat/attempt_redo_questions.feature +++ b/mod/quiz/tests/behat/attempt_redo_questions.feature @@ -30,11 +30,11 @@ Feature: Allow students to redo questions in a practice quiz, without starting a | question | page | maxmark | | TF1 | 1 | 2 | | TF2 | 1 | 1 | - And I log in as "student" - And I am on "Course 1" course homepage @javascript Scenario: After completing a question, there is a redo question button that restarts the question + Given I log in as "student" + And I am on "Course 1" course homepage When I follow "Quiz 1" And I press "Attempt quiz now" And I click on "False" "radio" in the "First question" "question" @@ -45,6 +45,8 @@ Feature: Allow students to redo questions in a practice quiz, without starting a @javascript Scenario: The redo question button is visible but disabled for teachers + Given I log in as "student" + And I am on "Course 1" course homepage When I follow "Quiz 1" And I press "Attempt quiz now" And I click on "False" "radio" in the "First question" "question" @@ -59,6 +61,8 @@ Feature: Allow students to redo questions in a practice quiz, without starting a @javascript Scenario: The redo question buttons are no longer visible after the attempt is submitted. + Given I log in as "student" + And I am on "Course 1" course homepage When I follow "Quiz 1" And I press "Attempt quiz now" And I click on "False" "radio" in the "First question" "question" @@ -70,6 +74,8 @@ Feature: Allow students to redo questions in a practice quiz, without starting a @javascript @_switch_window Scenario: Teachers reviewing can see all the qestions attempted in a slot + Given I log in as "student" + And I am on "Course 1" course homepage When I follow "Quiz 1" And I press "Attempt quiz now" And I click on "False" "radio" in the "First question" "question" @@ -100,6 +106,8 @@ Feature: Allow students to redo questions in a practice quiz, without starting a @javascript Scenario: Redoing question 1 should save any changes to question 2 on the same page + Given I log in as "student" + And I am on "Course 1" course homepage When I follow "Quiz 1" And I press "Attempt quiz now" And I click on "False" "radio" in the "First question" "question" @@ -108,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