MDL-75719 completion: Fix unit tests and Behat tests.
[moodle.git] / mod / quiz / tests / behat / quiz_activity_completion_unlocked.feature
blobb1e35f074a1507e03282290ddfa83a5a15f2f86b
1 @mod @mod_quiz @core_completion
2 Feature: Activity completion in the quiz activity with unlocked and re-grading.
3   In order to have visibility of quiz completion requirements
4   As a student
5   I need to be able to view my quiz completion progress even teacher have re-grading the grade pass.
7   Background:
8     Given the following "users" exist:
9       | username | firstname | lastname | email                |
10       | student1 | Student   | 1        | student1@example.com |
11       | teacher1 | Teacher   | 1        | teacher1@example.com |
12     And the following "courses" exist:
13       | fullname | shortname | category | enablecompletion |
14       | Course 1 | C1        | 0        | 1                |
15     And the following "course enrolments" exist:
16       | user     | course | role           |
17       | teacher1 | C1     | editingteacher |
18       | student1 | C1     | student        |
19     And the following config values are set as admin:
20       | grade_item_advanced | hiddenuntil |
21     And the following "question categories" exist:
22       | contextlevel | reference | name           |
23       | Course       | C1        | Test questions |
24     And the following "questions" exist:
25       | questioncategory | qtype     | name            | questiontext               | defaultmark |
26       | Test questions   | truefalse | First question  | Answer the first question  | 8           |
27       | Test questions   | truefalse | Second question | Answer the second question | 2           |
28     And the following "activity" exists:
29       | activity            | quiz           |
30       | course              | C1             |
31       | idnumber            | quiz1          |
32       | name                | Test quiz name |
33       | section             | 1              |
34       | gradepass           | 8              |
35       | grade               | 10             |
36       | grademethod         | 1              |
37       | completion          | 2              |
38       | completionusegrade  | 1              |
39       | completionpassgrade | 1              |
40     And quiz "Test quiz name" contains the following questions:
41       | question        | page |
42       | First question  | 1    |
43       | Second question | 2    |
45   @javascript
46   Scenario: Student will receive correct completion even when teacher unlocked completion and re-grading.
47     Given I am on the "Test quiz name" "quiz activity" page logged in as student1
48     And the "Receive a grade" completion condition of "Test quiz name" is displayed as "todo"
49     And the "Receive a passing grade" completion condition of "Test quiz name" is displayed as "todo"
50     And user "student1" has attempted "Test quiz name" with responses:
51       | slot | response |
52       | 1    | True     |
53       | 2    | False    |
54     And I am on "Course 1" course homepage
55     And I follow "Test quiz name"
56     And the "Receive a grade" completion condition of "Test quiz name" is displayed as "done"
57     And the "Receive a passing grade" completion condition of "Test quiz name" is displayed as "done"
58     And I log out
59     When I am on the "Course 1" course page logged in as teacher1
60     And I navigate to "Reports > Activity completion" in current page administration
61     And "Completed (achieved pass grade)" "icon" should exist in the "Student 1" "table_row"
62     And I am on the "Test quiz name" "quiz activity" page
63     And I navigate to "Settings" in current page administration
64     And I expand all fieldsets
65     And I press "Unlock completion settings"
66     And I set the following fields to these values:
67       | gradepass | 10 |
68     And I press "Save and return to course"
69     And I navigate to "Reports > Activity completion" in current page administration
70     Then "Completed (achieved pass grade)" "icon" should not exist in the "Student 1" "table_row"
71     And I log out
72     And I am on the "Test quiz name" "quiz activity" page logged in as student1
73     And the "Receive a grade" completion condition of "Test quiz name" is displayed as "done"
74     And the "Receive a passing grade" completion condition of "Test quiz name" is displayed as "failed"