1 |
efrain |
1 |
@core @core_course @core_customfield @javascript
|
|
|
2 |
Feature: Requiredness The course custom fields can be mandatory or not
|
|
|
3 |
In order to make users required to fill a custom field
|
|
|
4 |
As a manager
|
|
|
5 |
I can change the requiredness of the 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 |
Given the following "users" exist:
|
|
|
12 |
| username | firstname | lastname | email |
|
|
|
13 |
| teacher1 | Teacher | 1 | teacher1@example.com |
|
|
|
14 |
And the following "courses" exist:
|
|
|
15 |
| fullname | shortname | format |
|
|
|
16 |
| Course 1 | C1 | topics |
|
|
|
17 |
And the following "course enrolments" exist:
|
|
|
18 |
| user | course | role |
|
|
|
19 |
| teacher1 | C1 | editingteacher |
|
|
|
20 |
|
|
|
21 |
Scenario: A required course custom field must be filled when editing course settings
|
|
|
22 |
When I log in as "admin"
|
|
|
23 |
And I navigate to "Courses > Default settings > Course custom fields" in site administration
|
|
|
24 |
And I click on "Add a new custom field" "link"
|
|
|
25 |
And I click on "Short text" "link"
|
|
|
26 |
And I set the following fields to these values:
|
|
|
27 |
| Name | Test field |
|
|
|
28 |
| Short name | testfield |
|
|
|
29 |
| Required | Yes |
|
|
|
30 |
And I click on "Save changes" "button" in the "Adding a new Short text" "dialogue"
|
|
|
31 |
And I log out
|
|
|
32 |
And I log in as "teacher1"
|
|
|
33 |
And I am on "Course 1" course homepage
|
|
|
34 |
And I navigate to "Settings" in current page administration
|
|
|
35 |
And I press "Save and display"
|
|
|
36 |
Then I should see "You must supply a value here"
|
|
|
37 |
And I set the field "Test field" to "some value"
|
|
|
38 |
And I press "Save and display"
|
|
|
39 |
And I should not see "This field is required"
|
|
|
40 |
And I log out
|
|
|
41 |
|
|
|
42 |
Scenario: A course custom field that is not required may not be filled
|
|
|
43 |
When I log in as "admin"
|
|
|
44 |
And I navigate to "Courses > Default settings > Course custom fields" in site administration
|
|
|
45 |
And I click on "Add a new custom field" "link"
|
|
|
46 |
And I click on "Short text" "link"
|
|
|
47 |
And I set the following fields to these values:
|
|
|
48 |
| Name | Test field |
|
|
|
49 |
| Short name | testfield |
|
|
|
50 |
| Required | No |
|
|
|
51 |
And I click on "Save changes" "button" in the "Adding a new Short text" "dialogue"
|
|
|
52 |
And I log out
|
|
|
53 |
And I log in as "teacher1"
|
|
|
54 |
And I am on "Course 1" course homepage
|
|
|
55 |
And I navigate to "Settings" in current page administration
|
|
|
56 |
And I press "Save and display"
|
|
|
57 |
Then I should see "Course 1"
|
|
|
58 |
And I should see "New section"
|