1441 |
ariadna |
1 |
@customfield @customfield_number @javascript
|
|
|
2 |
Feature: Managers can manage course custom fields number
|
|
|
3 |
In order to have additional data on the course
|
|
|
4 |
As a manager
|
|
|
5 |
I need to create, edit, remove and display number custom fields
|
|
|
6 |
|
|
|
7 |
Background:
|
|
|
8 |
Given the following "custom field categories" exist:
|
|
|
9 |
| name | component | area | itemid |
|
|
|
10 |
| Category for test | core_course | course | 0 |
|
|
|
11 |
And I log in as "admin"
|
|
|
12 |
And I navigate to "Courses > Default settings > Course custom fields" in site administration
|
|
|
13 |
|
|
|
14 |
Scenario: Create a custom course number field
|
|
|
15 |
When I click on "Add a new custom field" "link"
|
|
|
16 |
And I click on "Number" "link"
|
|
|
17 |
When I set the following fields to these values:
|
|
|
18 |
| Name | Number field |
|
|
|
19 |
| Short name | numberfield |
|
|
|
20 |
| Display template | test |
|
|
|
21 |
And I click on "Save changes" "button" in the "Adding a new Number" "dialogue"
|
|
|
22 |
Then I should see "Invalid placeholder"
|
|
|
23 |
And I set the following fields to these values:
|
|
|
24 |
| Name | Number field |
|
|
|
25 |
| Short name | numberfield |
|
|
|
26 |
| Display template | {value} |
|
|
|
27 |
And I click on "Save changes" "button" in the "Adding a new Number" "dialogue"
|
|
|
28 |
And I should see "Number field"
|
|
|
29 |
And I log out
|
|
|
30 |
|
|
|
31 |
Scenario: Edit a custom course number field
|
|
|
32 |
When I click on "Add a new custom field" "link"
|
|
|
33 |
And I click on "Number" "link"
|
|
|
34 |
And I set the following fields to these values:
|
|
|
35 |
| Name | Number field |
|
|
|
36 |
| Short name | numberfield |
|
|
|
37 |
And I click on "Save changes" "button" in the "Adding a new Number" "dialogue"
|
|
|
38 |
Then I should see "Number field"
|
|
|
39 |
And I click on "Edit" "link" in the "Number field" "table_row"
|
|
|
40 |
And I set the following fields to these values:
|
|
|
41 |
| Name | Edited number field |
|
|
|
42 |
And I click on "Save changes" "button" in the "Updating Number field" "dialogue"
|
|
|
43 |
Then I should see "Edited number field"
|
|
|
44 |
And I log out
|
|
|
45 |
|
|
|
46 |
Scenario: Delete a custom course number field
|
|
|
47 |
When I click on "Add a new custom field" "link"
|
|
|
48 |
And I click on "Number" "link"
|
|
|
49 |
And I set the following fields to these values:
|
|
|
50 |
| Name | Number field |
|
|
|
51 |
| Short name | numberfield |
|
|
|
52 |
And I click on "Save changes" "button" in the "Adding a new Number" "dialogue"
|
|
|
53 |
And I click on "Delete" "link" in the "Number field" "table_row"
|
|
|
54 |
And I click on "Yes" "button" in the "Confirm" "dialogue"
|
|
|
55 |
And I wait until the page is ready
|
|
|
56 |
And I wait until "Number field" "text" does not exist
|
|
|
57 |
Then I should not see "Number field"
|
|
|
58 |
And I log out
|
|
|
59 |
|
|
|
60 |
Scenario Outline: A number field must shown correctly on course listing
|
|
|
61 |
Given the following "users" exist:
|
|
|
62 |
| username | firstname | lastname | email |
|
|
|
63 |
| teacher1 | Teacher | Example 1 | teacher1@example.com |
|
|
|
64 |
And the following "courses" exist:
|
|
|
65 |
| fullname | shortname | format |
|
|
|
66 |
| Course 1 | C1 | topics |
|
|
|
67 |
And the following "course enrolments" exist:
|
|
|
68 |
| user | course | role |
|
|
|
69 |
| teacher1 | C1 | editingteacher |
|
|
|
70 |
And I navigate to "Courses > Default settings > Course custom fields" in site administration
|
|
|
71 |
And I click on "Add a new custom field" "link"
|
|
|
72 |
And I click on "Number" "link"
|
|
|
73 |
When I set the following fields to these values:
|
|
|
74 |
| Name | Test number |
|
|
|
75 |
| Short name | testnumber |
|
|
|
76 |
| Decimal places | 2 |
|
|
|
77 |
| Display template | <template> |
|
|
|
78 |
| Display when zero | <whenzero> |
|
|
|
79 |
And I click on "Save changes" "button" in the "Adding a new Number" "dialogue"
|
|
|
80 |
And I log out
|
|
|
81 |
Then I log in as "teacher1"
|
|
|
82 |
And I am on "Course 1" course homepage
|
|
|
83 |
And I navigate to "Settings" in current page administration
|
|
|
84 |
And I set the following fields to these values:
|
|
|
85 |
| Test number | <fieldvalue> |
|
|
|
86 |
And I press "Save and display"
|
|
|
87 |
And I am on site homepage
|
|
|
88 |
And I should see "Test number" in the ".customfields-container .customfieldname" "css_element"
|
|
|
89 |
And I should see "<expectedvalue>" in the ".customfields-container .customfieldvalue" "css_element"
|
|
|
90 |
Examples:
|
|
|
91 |
| template | whenzero | fieldvalue | expectedvalue |
|
|
|
92 |
| $ {value} | 0 | 150 | $ 150.00 |
|
|
|
93 |
| {value} | Free | 0 | Free |
|
|
|
94 |
|
|
|
95 |
Scenario: Automatically populated field should hide some field form elements
|
|
|
96 |
Given I click on "Add a new custom field" "link"
|
|
|
97 |
And I click on "Number" "link"
|
|
|
98 |
And I should see "Default value"
|
|
|
99 |
And I should see "Minimum value"
|
|
|
100 |
And I should see "Maximum value"
|
|
|
101 |
And I should see "Decimal places"
|
|
|
102 |
And I should see "Display format"
|
|
|
103 |
And I should see "Display template"
|
|
|
104 |
And I should see "Display when zero"
|
|
|
105 |
And I should see "Display template"
|
|
|
106 |
And I should not see "No selection"
|
|
|
107 |
|
|
|
108 |
When I set the following fields to these values:
|
|
|
109 |
| Name | Number field |
|
|
|
110 |
| Field type | Number of activities in the course |
|
|
|
111 |
Then I should not see "Default value"
|
|
|
112 |
And I should not see "Minimum value"
|
|
|
113 |
And I should not see "Maximum value"
|
|
|
114 |
And I should not see "Decimal places"
|
|
|
115 |
And I should not see "Display format"
|
|
|
116 |
And I should not see "Display template"
|
|
|
117 |
And I should see "Display when zero"
|
|
|
118 |
And I should not see "Display when empty"
|
|
|
119 |
And I should see "No selection"
|
|
|
120 |
And I open the autocomplete suggestions list
|
|
|
121 |
And "Assignment" "autocomplete_suggestions" should exist
|
|
|
122 |
|
|
|
123 |
Scenario: Automatically populated field should be displayed in course settings
|
|
|
124 |
Given the following "courses" exist:
|
|
|
125 |
| fullname | shortname | category |
|
|
|
126 |
| Test course1 | C1 | 0 |
|
|
|
127 |
| Test course2 | C2 | 0 |
|
|
|
128 |
And the following "users" exist:
|
|
|
129 |
| username | firstname | lastname | email |
|
|
|
130 |
| teacher | Teacher | 1 | teacher@example.com |
|
|
|
131 |
And the following "course enrolments" exist:
|
|
|
132 |
| user | course | role |
|
|
|
133 |
| teacher | C1 | editingteacher |
|
|
|
134 |
| teacher | C2 | editingteacher |
|
|
|
135 |
And the following "activities" exist:
|
|
|
136 |
| activity | name | intro | course | idnumber | section | visible |
|
|
|
137 |
| assign | Assignment1 | Test description | C1 | assign1 | 1 | 0 |
|
|
|
138 |
| assign | Assignment2 | Test description | C1 | assign2 | 1 | 1 |
|
|
|
139 |
| assign | Assignment3 | Test description | C1 | assign3 | 1 | 1 |
|
|
|
140 |
| quiz | Quiz1 | Test description | C1 | quiz1 | 1 | 0 |
|
|
|
141 |
| quiz | Quiz2 | Test description | C1 | quiz2 | 1 | 1 |
|
|
|
142 |
| forum | Forum1 | Test description | C1 | forum1 | 1 | 0 |
|
|
|
143 |
| forum | Forum2 | Test description | C1 | forum2 | 1 | 1 |
|
|
|
144 |
| forum | Forum3 | Test description | C1 | forum3 | 1 | 1 |
|
|
|
145 |
| forum | Forum4 | Test description | C1 | forum4 | 1 | 1 |
|
|
|
146 |
| quiz | QuizC2 | Test description | C2 | quizC2 | 1 | 1 |
|
|
|
147 |
Given I click on "Add a new custom field" "link"
|
|
|
148 |
And I click on "Number" "link"
|
|
|
149 |
When I set the following fields to these values:
|
|
|
150 |
| Name | Number field |
|
|
|
151 |
| Short name | numberfield |
|
|
|
152 |
| Field type | Number of activities in the course |
|
|
|
153 |
And I open the autocomplete suggestions list
|
|
|
154 |
And I click on "Save changes" "button" in the "Adding a new Number" "dialogue"
|
|
|
155 |
And I should see "You must supply a value here." in the "Adding a new Number" "dialogue"
|
|
|
156 |
And I set the following fields to these values:
|
|
|
157 |
| Activity types | Assignment, Forum |
|
|
|
158 |
And I click on "Save changes" "button" in the "Adding a new Number" "dialogue"
|
|
|
159 |
And I log in as "teacher"
|
|
|
160 |
And I am on "C1" course homepage
|
|
|
161 |
And I navigate to "Settings" in current page administration
|
|
|
162 |
And I expand all fieldsets
|
|
|
163 |
And I click on "Update" "link"
|
|
|
164 |
And I should see "5" in the ".customfield_number-recalculate-value" "css_element"
|
|
|
165 |
And I add a assign activity to course "C1" section "1" and I fill the form with:
|
|
|
166 |
| Assignment name | Assignment4 |
|
|
|
167 |
| ID number | assign4 |
|
|
|
168 |
| Description | Test description |
|
|
|
169 |
And I run the scheduled task "\customfield_number\task\cron"
|
|
|
170 |
And I navigate to "Settings" in current page administration
|
|
|
171 |
And I expand all fieldsets
|
|
|
172 |
And I should see "6" in the ".customfield_number-recalculate-value" "css_element"
|
|
|
173 |
And I add a quiz activity to course "C1" section "1" and I fill the form with:
|
|
|
174 |
| Name | Quiz3 |
|
|
|
175 |
| ID number | quiz3 |
|
|
|
176 |
| Description | Test description |
|
|
|
177 |
And I run the scheduled task "\customfield_number\task\cron"
|
|
|
178 |
And I navigate to "Settings" in current page administration
|
|
|
179 |
And I expand all fieldsets
|
|
|
180 |
And I should see "6" in the ".customfield_number-recalculate-value" "css_element"
|
|
|
181 |
|
|
|
182 |
And I am on "C2" course homepage
|
|
|
183 |
And I navigate to "Settings" in current page administration
|
|
|
184 |
And I expand all fieldsets
|
|
|
185 |
And I should see "0" in the ".customfield_number-recalculate-value" "css_element"
|
|
|
186 |
|
|
|
187 |
And I log in as "admin"
|
|
|
188 |
And I navigate to "Courses > Default settings > Course custom fields" in site administration
|
|
|
189 |
And I click on "Edit" "link" in the "Number field" "table_row"
|
|
|
190 |
And I set the following fields to these values:
|
|
|
191 |
| Display when zero | |
|
|
|
192 |
And I click on "Save changes" "button" in the "Updating Number field" "dialogue"
|
|
|
193 |
And I run the scheduled task "\customfield_number\task\cron"
|
|
|
194 |
And I log in as "teacher"
|
|
|
195 |
And I am on "C2" course homepage
|
|
|
196 |
And I navigate to "Settings" in current page administration
|
|
|
197 |
And I expand all fieldsets
|
|
|
198 |
And I should not see "0" in the ".customfield_number-recalculate-value" "css_element"
|