Merge branch 'MDL-80220-main' of https://github.com/laurentdavid/moodle
[moodle.git] / course / format / tests / behat / section_visibility.feature
blob316f895d11cfe297544388efb79158ac4dbc4124
1 @core @core_courseformat
2 Feature: Varify section visibility interface
3   In order to edit the course sections visibility
4   As a teacher
5   I need to be able to see the updated visibility information
7   Background:
8     Given the following "course" exists:
9       | fullname         | Course 1 |
10       | shortname        | C1       |
11       | category         | 0        |
12       | numsections      | 3        |
13       | initsections     | 1        |
14     And the following "activities" exist:
15       | activity | name              | intro                       | course | idnumber | section |
16       | assign   | Activity sample 1 | Test assignment description | C1     | sample1  | 1       |
17     And the following "users" exist:
18       | username | firstname | lastname | email                |
19       | teacher1 | Teacher   | 1        | teacher1@example.com |
20       | student1 | Student   | 1        | student1@example.com |
21     And the following "course enrolments" exist:
22       | user     | course | role           |
23       | teacher1 | C1     | editingteacher |
24     Given I am on the "C1" "Course" page logged in as "teacher1"
25     And I turn editing mode on
27   @javascript
28   Scenario: Activities available but not shown on course page only apply to hidden sections.
29     Given I hide section "1"
30     And I open "Activity sample 1" actions menu
31     And I choose "Availability > Make available but don't show on course page" in the open action menu
32     And I should see "Available but not shown on course page" in the "Activity sample 1" "activity"
33     When I show section "1"
34     Then I should not see "Available but not shown on course page" in the "Activity sample 1" "activity"
36   @javascript
37   Scenario: Hide a section also hides the activities.
38     When I hide section "1"
39     Then I should see "Hidden from students" in the "Section 1" "section"
40     And I should see "Hidden from students" in the "Activity sample 1" "activity"
41     And I show section "1"
42     And I should not see "Hidden from students" in the "Section 1" "section"
43     And I should not see "Hidden from students" in the "Activity sample 1" "activity"
45   @javascript
46   Scenario: Hidden activities in hidden sections stay hidden when the section is shown.
47     Given I open "Activity sample 1" actions menu
48     And I choose "Hide" in the open action menu
49     And I should see "Hidden from students" in the "Activity sample 1" "activity"
50     And I hide section "1"
51     And I should see "Hidden from students" in the "Activity sample 1" "activity"
52     When I show section "1"
53     Then I should see "Hidden from students" in the "Activity sample 1" "activity"
55   @javascript
56   Scenario: Hidden sections can be shown and hidden using the drop down menu in the activity card.
57     Given I hide section "1"
58     When I click on "Hidden from students" "button" in the "Section 1" "section"
59     And I should see "Show on course page" in the "Section 1" "section"
60     And I should see "Hide on course page" in the "Section 1" "section"
61     And I click on "Show on course page" "link" in the "Section 1" "section"
62     Then I should not see "Hidden from students" in the "Section 1" "section"
64   @javascript
65   Scenario: Hidden sections are shown as "not available" to student when
66   the course is set to show hidden sections "not available". They are shown
67   as "hidden from students" to editing teachers.
68     Given the following "courses" exist:
69       | fullname | shortname | format | hiddensections | numsections | initsections |
70       | Course 2 | C2        | topics | 0              | 3           | 1            |
71     And the following "course enrolments" exist:
72       | user     | course | role           |
73       | student1 | C2     | student        |
74       | teacher1 | C2     | editingteacher |
75     And I am on the "C2" "Course" page logged in as "admin"
76     And I turn editing mode on
77     And I hide section "1"
78     And I log out
79     When I am on the "C2" "Course" page logged in as "student1"
80     Then I should see "Not available" in the "Section 1" "section"
81     And I log out
82     And I am on the "C2" "Course" page logged in as "teacher1"
83     And I should see "Hidden from students" in the "Section 1" "section"