2 Feature: Sections can be edited and deleted in topics format
3 In order to rearrange my course contents
5 I need to edit and Delete topics
8 Given the following "users" exist:
9 | username | firstname | lastname | email |
10 | teacher1 | Teacher | 1 | teacher1@example.com |
11 And the following "courses" exist:
12 | fullname | shortname | format | coursedisplay | numsections |
13 | Course 1 | C1 | topics | 0 | 5 |
14 And the following "activities" exist:
15 | activity | name | intro | course | idnumber | section |
16 | assign | Test assignment name | Test assignment description | C1 | assign1 | 0 |
17 | book | Test book name | Test book description | C1 | book1 | 1 |
18 | chat | Test chat name | Test chat description | C1 | chat1 | 4 |
19 | choice | Test choice name | Test choice description | C1 | choice1 | 5 |
20 And the following "course enrolments" exist:
21 | user | course | role |
22 | teacher1 | C1 | editingteacher |
23 And I log in as "teacher1"
24 And I follow "Course 1"
25 And I turn editing mode on
27 Scenario: Edit section summary in topics format
28 When I edit the section "2"
29 And I set the following fields to these values:
30 | Summary | Welcome to section 2 |
31 And I press "Save changes"
32 Then I should see "Welcome to section 2" in the "li#section-2" "css_element"
34 Scenario: Edit section default name in topics format
35 When I edit the section "2"
36 And I set the following fields to these values:
37 | Use default section name | 0 |
38 | name | This is the second topic |
39 And I press "Save changes"
40 Then I should see "This is the second topic" in the "li#section-2" "css_element"
41 And I should not see "Topic 2" in the "li#section-2" "css_element"
43 Scenario: Deleting the last section in topics format
44 When I delete section "5"
45 Then I should see "Are you absolutely sure you want to completely delete \"Topic 5\" and all the activities it contains?"
47 And I should not see "Topic 5"
48 And I navigate to "Edit settings" node in "Course administration"
49 And I expand all fieldsets
50 And the field "Number of sections" matches value "4"
52 Scenario: Deleting the middle section in topics format
53 When I delete section "4"
55 Then I should not see "Topic 5"
56 And I should not see "Test chat name"
57 And I should see "Test choice name" in the "li#section-4" "css_element"
58 And I navigate to "Edit settings" node in "Course administration"
59 And I expand all fieldsets
60 And the field "Number of sections" matches value "4"
62 Scenario: Deleting the orphaned section in topics format
63 When I follow "Reduce the number of sections"
64 Then I should see "Orphaned activities (section 5)" in the "li#section-5" "css_element"
65 And I delete section "5"
67 And I should not see "Topic 5"
68 And I should not see "Orphaned activities"
69 And "li#section-5" "css_element" should not exist
70 And I navigate to "Edit settings" node in "Course administration"
71 And I expand all fieldsets
72 And the field "Number of sections" matches value "4"
74 Scenario: Deleting a section when orphaned section is present in topics format
75 When I follow "Reduce the number of sections"
76 Then I should see "Orphaned activities (section 5)" in the "li#section-5" "css_element"
77 And "li#section-5.orphaned" "css_element" should exist
78 And "li#section-4.orphaned" "css_element" should not exist
79 And I delete section "1"
81 And I should not see "Test book name"
82 And I should see "Orphaned activities (section 4)" in the "li#section-4" "css_element"
83 And "li#section-5" "css_element" should not exist
84 And "li#section-4.orphaned" "css_element" should exist
85 And "li#section-3.orphaned" "css_element" should not exist