2 Feature: Sections can be edited and deleted in weeks format
3 In order to rearrange my course contents
5 I need to edit and Delete weeks
8 Given the following "users" exist:
9 | username | firstname | lastname | email |
10 | teacher1 | Teacher | 1 | teacher1@asd.com |
11 And the following "courses" exist:
12 | fullname | shortname | format | coursedisplay | numsections | startdate |
13 | Course 1 | C1 | weeks | 0 | 5 | 957139200 |
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 weeks format
28 When I click on "Edit summary" "link" in the "li#section-2" "css_element"
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 weeks format
35 Given I should see "8 May - 14 May" in the "li#section-2" "css_element"
36 When I click on "Edit summary" "link" in the "li#section-2" "css_element"
37 And I set the following fields to these values:
38 | Use default section name | 0 |
39 | name | This is the second week |
40 And I press "Save changes"
41 Then I should see "This is the second week" in the "li#section-2" "css_element"
42 And I should not see "8 May - 14 May" in the "li#section-2" "css_element"
44 Scenario: Deleting the last section in weeks format
45 Given I should see "29 May - 4 June" in the "li#section-5" "css_element"
46 When I click on "Delete week" "link" in the "li#section-5" "css_element"
47 Then I should see "Are you absolutely sure you want to completely delete \"29 May - 4 June\" and all the activities it contains?"
48 And I press "Continue"
49 And I should not see "29 May - 4 June"
50 And I navigate to "Edit settings" node in "Course administration"
51 And I expand all fieldsets
52 And the field "Number of sections" matches value "4"
54 Scenario: Deleting the middle section in weeks format
55 Given I should see "29 May - 4 June" in the "li#section-5" "css_element"
56 When I click on "Delete week" "link" in the "li#section-4" "css_element"
57 And I press "Continue"
58 Then I should not see "29 May - 4 June"
59 And I should not see "Test chat name"
60 And I should see "Test choice name" in the "li#section-4" "css_element"
61 And I navigate to "Edit settings" node in "Course administration"
62 And I expand all fieldsets
63 And the field "Number of sections" matches value "4"
65 Scenario: Deleting the orphaned section in weeks format
66 When I follow "Reduce the number of sections"
67 Then I should see "Orphaned activities (section 5)" in the "li#section-5" "css_element"
68 And I click on "Delete week" "link" in the "li#section-5" "css_element"
69 And I press "Continue"
70 And I should not see "29 May - 4 June"
71 And I should not see "Orphaned activities"
72 And "li#section-5" "css_element" should not exist
73 And I navigate to "Edit settings" node in "Course administration"
74 And I expand all fieldsets
75 And the field "Number of sections" matches value "4"
77 Scenario: Deleting a section when orphaned section is present in weeks format
78 When I follow "Reduce the number of sections"
79 Then I should see "Orphaned activities (section 5)" in the "li#section-5" "css_element"
80 And "li#section-5.orphaned" "css_element" should exist
81 And "li#section-4.orphaned" "css_element" should not exist
82 And I click on "Delete week" "link" in the "li#section-1" "css_element"
83 And I press "Continue"
84 And I should not see "Test book name"
85 And I should see "Orphaned activities (section 4)" in the "li#section-4" "css_element"
86 And "li#section-5" "css_element" should not exist
87 And "li#section-4.orphaned" "css_element" should exist
88 And "li#section-3.orphaned" "css_element" should not exist