Merge branch 'MDL-53140-master' of git://github.com/rezaies/moodle
[moodle.git] / completion / tests / behat / restrict_section_availability.feature
CommitLineData
550d842e 1@core @core_completion
3f038d6d
RT
2Feature: Restrict sections availability through completion or grade conditions
3 In order to control section's contents access through activities completion or grade condition
5d7b6307 4 As a teacher
4569bc7c
DM
5 I need to restrict sections availability using different conditions
6
3f038d6d 7 Background:
759b323e 8 Given the following "courses" exist:
4569bc7c
DM
9 | fullname | shortname | category |
10 | Course 1 | C1 | 0 |
759b323e 11 And the following "users" exist:
4569bc7c 12 | username | firstname | lastname | email |
0fe86bbd
RT
13 | teacher1 | Teacher | Frist | teacher1@example.com |
14 | student1 | Student | First | student1@example.com |
759b323e 15 And the following "course enrolments" exist:
4569bc7c
DM
16 | user | course | role |
17 | teacher1 | C1 | editingteacher |
18 | student1 | C1 | student |
3f038d6d
RT
19
20 @javascript
21 Scenario: Show section greyed-out to student when completion condition is not satisfied
22 Given I log in as "teacher1"
fdeeaff9 23 And I am on "Course 1" course homepage with editing mode on
e5287f9b 24 And I navigate to "Edit settings" in current page administration
f083d614 25 And I set the following fields to these values:
5bc7cd92 26 | Enable completion tracking | Yes |
38ea5e0a 27 And I press "Save and display"
4569bc7c
DM
28 And I add a "Label" to section "1" and I fill the form with:
29 | Label text | Test label |
30 | Completion tracking | Students can manually mark the activity as completed |
31 And I add a "Page" to section "2" and I fill the form with:
32 | Name | Test page name |
33 | Description | Test page description |
34 | Page content | Test page contents |
ae90dec5
RT
35 When I edit the section "2"
36 And I expand all fieldsets
37 And I click on "Add restriction..." "button"
38 And I click on "Activity completion" "button" in the "Add restriction..." "dialogue"
39 And I set the following fields to these values:
40 | cm | Test label |
41 | Required completion status | must be marked complete |
42 And I press "Save changes"
4569bc7c
DM
43 And I log out
44 And I log in as "student1"
fdeeaff9 45 And I am on "Course 1" course homepage
ae90dec5 46 Then I should see "Not available unless: The activity Test label is marked complete"
4569bc7c 47 And I should not see "Test page name"
8857c715 48 And I click on "Not completed: Test label. Select to mark as complete." "icon"
4569bc7c 49 And I should see "Test page name"
ae90dec5 50 And I should not see "Not available unless: The activity Test label is marked complete"
3f038d6d
RT
51
52 @javascript
53 Scenario: Show section greyed-out to student when grade condition is not satisfied
54 Given I log in as "teacher1"
fdeeaff9 55 And I am on "Course 1" course homepage with editing mode on
3f038d6d
RT
56 And I add a "Assignment" to section "1" and I fill the form with:
57 | Assignment name | Grade assignment |
58 | Description | Grade this assignment to revoke restriction on restricted assignment |
59 | assignsubmission_onlinetext_enabled | 1 |
60 | assignsubmission_file_enabled | 0 |
61 And I add a "Page" to section "2" and I fill the form with:
62 | Name | Test page name |
63 | Description | Restricted section page resource, till grades in Grade assignment is at least 20% |
64 | Page content | Test page contents |
ae90dec5
RT
65 And I edit the section "2"
66 And I expand all fieldsets
67 And I click on "Add restriction..." "button"
68 And I click on "Grade" "button" in the "Add restriction..." "dialogue"
ae90dec5 69 And I set the following fields to these values:
6d04e551
EL
70 | id | Grade assignment |
71 | min | 1 |
72 | minval | 20 |
ae90dec5 73 And I press "Save changes"
3f038d6d
RT
74 And I log out
75 When I log in as "student1"
fdeeaff9 76 And I am on "Course 1" course homepage
ae90dec5 77 Then I should see "Not available unless: You achieve a required score in Grade assignment"
3f038d6d
RT
78 And "Test page name" activity should be hidden
79 And I follow "Grade assignment"
80 And I press "Add submission"
f083d614 81 And I set the following fields to these values:
3f038d6d
RT
82 | Online text | I'm the student submission |
83 And I press "Save changes"
84 And I should see "Submitted for grading"
85 And I log out
86 And I log in as "teacher1"
fdeeaff9 87 And I am on "Course 1" course homepage
3f038d6d 88 And I follow "Grade assignment"
e5287f9b 89 And I navigate to "View all submissions" in current page administration
821ab1bf 90 And I click on "Grade" "link" in the "Student First" "table_row"
f083d614 91 And I set the following fields to these values:
3f038d6d
RT
92 | Grade | 21 |
93 And I press "Save changes"
821ab1bf
DW
94 And I press "Ok"
95 And I follow "Edit settings"
3f038d6d
RT
96 And I log out
97 And I log in as "student1"
fdeeaff9 98 And I am on "Course 1" course homepage
3f038d6d 99 And "Test page name" activity should be visible
ae90dec5 100 And I should not see "Not available unless: You achieve a required score in Grade assignment"