MDL-71162 mod_data: Add behat testing for completion conditions
[moodle.git] / mod / data / tests / behat / data_activity_completion.feature
CommitLineData
1f2daaef
MH
1@mod @mod_data @core_completion
2Feature: View activity completion in the database activity
3 In order to have visibility of database completion requirements
4 As a student
5 I need to be able to view my database completion progress
6
7 Background:
8 Given the following "users" exist:
9 | username | firstname | lastname | email |
10 | student1 | Vinnie | Student1 | student1@example.com |
11 | teacher1 | Darrell | Teacher1 | teacher1@example.com |
12 And the following "courses" exist:
13 | fullname | shortname | category |
14 | Course 1 | C1 | 0 |
15 And the following "course enrolments" exist:
16 | user | course | role |
17 | student1 | C1 | student |
18 | teacher1 | C1 | editingteacher |
19 And I log in as "teacher1"
20 And I am on "Course 1" course homepage
21 And I navigate to "Edit settings" in current page administration
22 And I expand all fieldsets
23 And I set the following fields to these values:
24 | Enable completion tracking | Yes |
25 | Show completion conditions | Yes |
26 And I press "Save and display"
27 And the following "activity" exists:
28 | activity | data |
29 | course | C1 |
30 | idnumber | mh1 |
31 | name | Music history |
32 | section | 1 |
33 And I am on "Course 1" course homepage
34 And I follow "Music history"
35 And I navigate to "Edit settings" in current page administration
36 And I expand all fieldsets
37 And I set the following fields to these values:
38 | Aggregate type | Average of ratings |
39 | scale[modgrade_type] | Point |
40 | scale[modgrade_point] | 100 |
41 | Completion tracking | Show activity as complete when conditions are met |
42 | Require view | 1 |
43 | Require grade | 1 |
44 | completionentriesenabled | 1 |
45 | completionentries | 2 |
46 And I press "Save and display"
47 And I add a "Text input" field to "Music history" database and I fill the form with:
48 | Field name | Instrument types |
49 And I follow "Templates"
50 And I press "Save template"
51 And I log out
52
53 Scenario: View automatic completion items as a teacher and confirm all tabs display conditions
54 Given I log in as "teacher1"
55 And I am on "Course 1" course homepage
56 When I follow "Music history"
57 Then "Music history" should have the "View" completion condition
58 And "Music history" should have the "Make entries: 2" completion condition
59 And "Music history" should have the "Receive a grade" completion condition
60 And I follow "View single"
61 And "Music history" should have the "View" completion condition
62 And "Music history" should have the "Make entries: 2" completion condition
63 And "Music history" should have the "Receive a grade" completion condition
64 And I follow "Search"
65 And "Music history" should have the "View" completion condition
66 And "Music history" should have the "Make entries: 2" completion condition
67 And "Music history" should have the "Receive a grade" completion condition
68 And I follow "Add entry"
69 And "Music history" should have the "View" completion condition
70 And "Music history" should have the "Make entries: 2" completion condition
71 And "Music history" should have the "Receive a grade" completion condition
72 And I follow "Export"
73 And "Music history" should have the "View" completion condition
74 And "Music history" should have the "Make entries: 2" completion condition
75 And "Music history" should have the "Receive a grade" completion condition
76 And I follow "Templates"
77 And "Music history" should have the "View" completion condition
78 And "Music history" should have the "Make entries: 2" completion condition
79 And "Music history" should have the "Receive a grade" completion condition
80 And I follow "Fields"
81 And "Music history" should have the "View" completion condition
82 And "Music history" should have the "Make entries: 2" completion condition
83 And "Music history" should have the "Receive a grade" completion condition
84 And I follow "Presets"
85 And "Music history" should have the "View" completion condition
86 And "Music history" should have the "Make entries: 2" completion condition
87 And "Music history" should have the "Receive a grade" completion condition
88
89 Scenario: View automatic completion items as a student
90 Given I log in as "student1"
91 And I am on "Course 1" course homepage
92 And I follow "Music history"
93 And the "View" completion condition of "Music history" is displayed as "done"
94 And the "Make entries: 2" completion condition of "Music history" is displayed as "todo"
95 And the "Receive a grade" completion condition of "Music history" is displayed as "todo"
96 And I am on "Course 1" course homepage
97 And I add an entry to "Music history" database with:
98 | Instrument types | Drums |
99 And I press "Save and view"
100 # One entry is not enough to mark as complete.
101 And the "Make entries: 2" completion condition of "Music history" is displayed as "todo"
102 And I log out
103 And I log in as "teacher1"
104 And I am on "Course 1" course homepage
105 And I follow "Music history"
106 And I follow "View single"
107 And I set the field "rating" to "3"
108 And I press "Rate"
109 And I log out
110 When I log in as "student1"
111 And I am on "Course 1" course homepage
112 And I add an entry to "Music history" database with:
113 | Instrument types | Hurdygurdy |
114 And I press "Save and view"
115 Then the "View" completion condition of "Music history" is displayed as "done"
116 And the "Make entries: 2" completion condition of "Music history" is displayed as "done"
117 And the "Receive a grade" completion condition of "Music history" is displayed as "done"
118 And I log out
119 And I log in as "teacher1"
120 And I am on "Course 1" course homepage
121 And "Vinnie Student1" user has completed "Music history" activity
122
123 @javascript
124 Scenario: Use manual completion
125 Given I log in as "teacher1"
126 And I am on "Course 1" course homepage
127 And I follow "Music history"
128 And I navigate to "Edit settings" in current page administration
129 And I expand all fieldsets
130 And I set the field "Completion tracking" to "Students can manually mark the activity as completed"
131 And I press "Save and display"
132 # Teacher view.
133 And the manual completion button for "Music history" should be disabled
134 And I log out
135 # Student view.
136 When I log in as "student1"
137 And I am on "Course 1" course homepage
138 And I follow "Music history"
139 Then the manual completion button of "Music history" is displayed as "Mark as done"
140 And I toggle the manual completion state of "Music history"
141 And the manual completion button of "Music history" is displayed as "Done"