MDL-65630 mod_quiz: Allow redo within an attempt with random questions
authorShamim Rezaie <shamim@moodle.com>
Mon, 20 May 2019 12:56:57 +0000 (22:56 +1000)
committerShamim Rezaie <shamim@moodle.com>
Mon, 20 May 2019 13:10:30 +0000 (23:10 +1000)
mod/quiz/attemptlib.php
mod/quiz/tests/behat/attempt_redo_questions.feature

index 1f6674a..87d2943 100644 (file)
@@ -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'));
 
index 4499aaa..fbadb44 100644 (file)
@@ -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