MDL-61115 mod_lesson: Lesson overrides to observe group membership

This commit is contained in:
Shamim Rezaie 2019-07-01 11:03:06 +10:00 committed by Eloy Lafuente (stronk7)
parent f7b0d0fe7f
commit b392686a65
5 changed files with 301 additions and 41 deletions

View file

@ -48,8 +48,11 @@ Feature: Lesson group override
| id_response_editor_1 | Wrong |
| id_jumpto_1 | This page |
And I press "Save page"
And I log out
Scenario: Add, modify then delete a group override
Given I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
When I follow "Test lesson name"
And I navigate to "Group overrides" in current page administration
And I press "Add group override"
@ -73,6 +76,8 @@ Feature: Lesson group override
And I should not see "Group 1"
Scenario: Duplicate a user override
Given I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
When I follow "Test lesson name"
And I navigate to "Group overrides" in current page administration
And I press "Add group override"
@ -95,6 +100,8 @@ Feature: Lesson group override
And I should see "Group 2"
Scenario: Allow a single group to have re-take the lesson
Given I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
When I follow "Test lesson name"
And I navigate to "Edit settings" in current page administration
And I set the following fields to these values:
@ -134,6 +141,8 @@ Feature: Lesson group override
And I should see "You are not allowed to retake this lesson."
Scenario: Allow a single group to have a different password
Given I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
When I follow "Test lesson name"
And I navigate to "Edit settings" in current page administration
And I set the following fields to these values:
@ -179,6 +188,8 @@ Feature: Lesson group override
And I press "Continue"
Scenario: Allow a group to have a different due date
Given I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
When I follow "Test lesson name"
And I navigate to "Edit settings" in current page administration
And I set the following fields to these values:
@ -214,6 +225,8 @@ Feature: Lesson group override
And I should see "Cat is an amphibian"
Scenario: Allow a group to have a different start date
Given I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
When I follow "Test lesson name"
And I navigate to "Edit settings" in current page administration
And I set the following fields to these values:
@ -249,6 +262,8 @@ Feature: Lesson group override
And I should see "Cat is an amphibian"
Scenario: Allow a single group to have multiple attempts at each question
Given I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
When I follow "Test lesson name"
And I navigate to "Edit settings" in current page administration
And I set the following fields to these values:
@ -289,6 +304,8 @@ Feature: Lesson group override
@javascript
Scenario: Add both a user and group override and verify that both are applied correctly
Given I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
When I follow "Test lesson name"
And I navigate to "Edit settings" in current page administration
And I set the following fields to these values:
@ -340,3 +357,76 @@ Feature: Lesson group override
And I am on "Course 1" course homepage
And I follow "Test lesson"
And I should see "This lesson will be open on Wednesday, 1 January 2020, 8:00"
Scenario: Override a group when teacher is in no group, and does not have accessallgroups permission, and the activity's group mode is 'separate groups'
Given the following "permission overrides" exist:
| capability | permission | role | contextlevel | reference |
| moodle/site:accessallgroups | Prevent | editingteacher | Course | C1 |
And the following "activities" exist:
| activity | name | intro | course | idnumber | groupmode |
| lesson | Lesson 2 | Lesson 2 description | C1 | lesson2 | 1 |
When I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "Lesson 2"
And I navigate to "Group overrides" in current page administration
Then I should see "No groups you can access."
And the "Add group override" "button" should be disabled
Scenario: A teacher without accessallgroups permission should only be able to add group override for their groups, when the activity's group mode is 'separate groups'
Given the following "permission overrides" exist:
| capability | permission | role | contextlevel | reference |
| moodle/site:accessallgroups | Prevent | editingteacher | Course | C1 |
And the following "activities" exist:
| activity | name | intro | course | idnumber | groupmode |
| lesson | Lesson 2 | Lesson 2 description | C1 | lesson2 | 1 |
And the following "group members" exist:
| user | group |
| teacher1 | G1 |
When I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "Lesson 2"
And I navigate to "Group overrides" in current page administration
And I press "Add group override"
Then the "Override group" select box should contain "Group 1"
And the "Override group" select box should not contain "Group 2"
Scenario: A teacher without accessallgroups permission should only be able to see the group overrides for their groups, when the activity's group mode is 'separate groups'
Given the following "permission overrides" exist:
| capability | permission | role | contextlevel | reference |
| moodle/site:accessallgroups | Prevent | editingteacher | Course | C1 |
And the following "activities" exist:
| activity | name | intro | course | idnumber | groupmode |
| lesson | Lesson 2 | Lesson 2 description | C1 | lesson2 | 1 |
And the following "group members" exist:
| user | group |
| teacher1 | G1 |
And I log in as "admin"
And I am on "Course 1" course homepage
And I follow "Lesson 2"
And I navigate to "Group overrides" in current page administration
And I press "Add group override"
And I set the following fields to these values:
| Override group | Group 1 |
| id_available_enabled | 1 |
| available[day] | 1 |
| available[month] | January |
| available[year] | 2020 |
| available[hour] | 08 |
| available[minute] | 00 |
And I press "Save and enter another override"
And I set the following fields to these values:
| Override group | Group 2 |
| id_available_enabled | 1 |
| available[day] | 1 |
| available[month] | January |
| available[year] | 2020 |
| available[hour] | 08 |
| available[minute] | 00 |
And I press "Save"
And I log out
When I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "Lesson 2"
And I navigate to "Group overrides" in current page administration
Then I should see "Group 1" in the ".generaltable" "css_element"
And I should not see "Group 2" in the ".generaltable" "css_element"

View file

@ -1,4 +1,4 @@
@mod @mod_lesson @javascript
@mod @mod_lesson
Feature: Lesson user override
In order to grant a student special access to a lesson
As a teacher
@ -18,10 +18,6 @@ Feature: Lesson user override
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
| student2 | C1 | student |
And the following "groups" exist:
| name | course | idnumber |
| Group 1 | C1 | G1 |
| Group 2 | C1 | G2 |
And the following "activities" exist:
| activity | name | intro | course | idnumber |
| lesson | Test lesson name | Test lesson description | C1 | lesson1 |
@ -41,9 +37,12 @@ Feature: Lesson user override
| id_response_editor_1 | Wrong |
| id_jumpto_1 | This page |
And I press "Save page"
And I log out
@javascript
Scenario: Add, modify then delete a user override
Given I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
When I follow "Test lesson name"
And I navigate to "User overrides" in current page administration
And I press "Add user override"
@ -66,7 +65,10 @@ Feature: Lesson user override
And I press "Continue"
And I should not see "Sam1 Student1"
@javascript
Scenario: Duplicate a user override
Given I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
When I follow "Test lesson name"
And I navigate to "User overrides" in current page administration
And I press "Add user override"
@ -88,7 +90,10 @@ Feature: Lesson user override
And I should see "Tuesday, 1 January 2030, 8:00"
And I should see "Sam2 Student2"
@javascript
Scenario: Allow a single user to have re-take the lesson
Given I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
When I follow "Test lesson name"
And I navigate to "Edit settings" in current page administration
And I set the following fields to these values:
@ -127,7 +132,10 @@ Feature: Lesson user override
And I follow "Test lesson name"
And I should see "You are not allowed to retake this lesson."
@javascript
Scenario: Allow a single user to have a different password
Given I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
When I follow "Test lesson name"
And I navigate to "Edit settings" in current page administration
And I set the following fields to these values:
@ -172,7 +180,10 @@ Feature: Lesson user override
And I set the field "userpassword" to "moodle_rules"
And I press "Continue"
@javascript
Scenario: Allow a user to have a different due date
Given I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
When I follow "Test lesson name"
And I navigate to "Edit settings" in current page administration
And I set the following fields to these values:
@ -207,7 +218,10 @@ Feature: Lesson user override
And I follow "Test lesson"
And I should see "Cat is an amphibian"
@javascript
Scenario: Allow a user to have a different start date
Given I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
When I follow "Test lesson name"
And I navigate to "Edit settings" in current page administration
And I set the following fields to these values:
@ -242,7 +256,10 @@ Feature: Lesson user override
And I follow "Test lesson"
And I should see "Cat is an amphibian"
@javascript
Scenario: Allow a single user to have multiple attempts at each question
Given I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
When I follow "Test lesson name"
And I navigate to "Edit settings" in current page administration
And I set the following fields to these values:
@ -280,3 +297,89 @@ Feature: Lesson user override
And I press "Submit"
Then I press "Continue"
And I should see "Congratulations - end of lesson reached"
Scenario: Override a user when teacher is in no group, and does not have accessallgroups permission, and the activity's group mode is 'separate groups'
Given the following "permission overrides" exist:
| capability | permission | role | contextlevel | reference |
| moodle/site:accessallgroups | Prevent | editingteacher | Course | C1 |
And the following "activities" exist:
| activity | name | intro | course | idnumber | groupmode |
| lesson | Lesson 2 | Lesson 2 description | C1 | lesson2 | 1 |
When I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "Lesson 2"
And I navigate to "User overrides" in current page administration
Then I should see "No groups you can access."
And the "Add user override" "button" should be disabled
Scenario: A teacher without accessallgroups permission should only be able to add user override for their group-mates, when the activity's group mode is 'separate groups'
Given the following "permission overrides" exist:
| capability | permission | role | contextlevel | reference |
| moodle/site:accessallgroups | Prevent | editingteacher | Course | C1 |
And the following "activities" exist:
| activity | name | intro | course | idnumber | groupmode |
| lesson | Lesson 2 | Lesson 2 description | C1 | lesson2 | 1 |
And the following "groups" exist:
| name | course | idnumber |
| Group 1 | C1 | G1 |
| Group 2 | C1 | G2 |
And the following "group members" exist:
| user | group |
| teacher1 | G1 |
| student1 | G1 |
| student2 | G2 |
When I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "Lesson 2"
And I navigate to "User overrides" in current page administration
And I press "Add user override"
Then the "Override user" select box should contain "Sam1 Student1, student1@example.com"
And the "Override user" select box should not contain "Sam2 Student2, student2@example.com"
@javascript
Scenario: A teacher without accessallgroups permission should only be able to see the user override for their group-mates, when the activity's group mode is 'separate groups'
Given the following "permission overrides" exist:
| capability | permission | role | contextlevel | reference |
| moodle/site:accessallgroups | Prevent | editingteacher | Course | C1 |
And the following "activities" exist:
| activity | name | intro | course | idnumber | groupmode |
| lesson | Lesson 2 | Lesson 2 description | C1 | lesson2 | 1 |
And the following "groups" exist:
| name | course | idnumber |
| Group 1 | C1 | G1 |
| Group 2 | C1 | G2 |
And the following "group members" exist:
| user | group |
| teacher1 | G1 |
| student1 | G1 |
| student2 | G2 |
And I log in as "admin"
And I am on "Course 1" course homepage
And I follow "Lesson 2"
And I navigate to "User overrides" in current page administration
And I press "Add user override"
And I set the following fields to these values:
| Override user | Student1 |
| id_deadline_enabled | 1 |
| deadline[day] | 1 |
| deadline[month] | January |
| deadline[year] | 2020 |
| deadline[hour] | 08 |
| deadline[minute] | 00 |
And I press "Save and enter another override"
And I set the following fields to these values:
| Override user | Student2 |
| id_deadline_enabled | 1 |
| deadline[day] | 1 |
| deadline[month] | January |
| deadline[year] | 2020 |
| deadline[hour] | 08 |
| deadline[minute] | 00 |
And I press "Save"
And I log out
When I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "Lesson 2"
And I navigate to "User overrides" in current page administration
Then I should see "Student1" in the ".generaltable" "css_element"
And I should not see "Student2" in the ".generaltable" "css_element"