1 |
efrain |
1 |
@core @core_course @core_customfield @javascript
|
|
|
2 |
Feature: Teachers can edit course custom fields
|
|
|
3 |
In order to have additional data on the course
|
|
|
4 |
As a teacher
|
|
|
5 |
I need to edit data for 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 the following "custom fields" exist:
|
|
|
12 |
| name | category | type | shortname | description | configdata |
|
|
|
13 |
| Field 1 | Category for test | text | f1 | d1 | |
|
|
|
14 |
| Field 2 | Category for test | textarea | f2 | d2 | |
|
|
|
15 |
| Field 3 | Category for test | checkbox | f3 | d3 | |
|
|
|
16 |
| Field 4 | Category for test | date | f4 | d4 | |
|
|
|
17 |
| Field 5 | Category for test | select | f5 | d5 | {"options":"a\nb\nc"} |
|
|
|
18 |
And the following "users" exist:
|
|
|
19 |
| username | firstname | lastname | email |
|
|
|
20 |
| teacher1 | Teacher | 1 | teacher1@example.com |
|
|
|
21 |
And the following "courses" exist:
|
|
|
22 |
| fullname | shortname | format |
|
|
|
23 |
| Course 1 | C1 | topics |
|
|
|
24 |
And the following "course enrolments" exist:
|
|
|
25 |
| user | course | role |
|
|
|
26 |
| teacher1 | C1 | editingteacher |
|
|
|
27 |
And the following "user private files" exist:
|
11 |
efrain |
28 |
| user | filepath |
|
|
|
29 |
| admin | lib/tests/fixtures/gd-logo.png |
|
1 |
efrain |
30 |
|
|
|
31 |
Scenario: Display custom fields on course edit form
|
|
|
32 |
When 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 expand all fieldsets
|
|
|
36 |
Then I should see "Category for test"
|
|
|
37 |
And I should see "Field 1"
|
|
|
38 |
And I should see "Field 2"
|
|
|
39 |
And I should see "Field 3"
|
|
|
40 |
And I should see "Field 4"
|
|
|
41 |
And I should see "Field 5"
|
|
|
42 |
And I log out
|
|
|
43 |
|
|
|
44 |
Scenario: Create a course with custom fields from the management interface
|
|
|
45 |
When I log in as "admin"
|
|
|
46 |
And I go to the courses management page
|
|
|
47 |
And I should see the "Categories" management page
|
|
|
48 |
And I click on category "Category 1" in the management interface
|
|
|
49 |
And I should see the "Course categories and courses" management page
|
|
|
50 |
And I click on "Create new course" "link" in the "#course-listing" "css_element"
|
|
|
51 |
And I set the following fields to these values:
|
|
|
52 |
| Course full name | Course 2 |
|
|
|
53 |
| Course short name | C2 |
|
|
|
54 |
| Field 1 | testcontent1 |
|
|
|
55 |
| Field 2 | testcontent2 |
|
|
|
56 |
| Field 3 | 1 |
|
|
|
57 |
| customfield_f4[enabled] | 1 |
|
|
|
58 |
| customfield_f4[day] | 1 |
|
|
|
59 |
| customfield_f4[month] | January |
|
|
|
60 |
| customfield_f4[year] | 2019 |
|
|
|
61 |
| Field 5 | b |
|
|
|
62 |
And I press "Save and display"
|
|
|
63 |
And I navigate to "Settings" in current page administration
|
|
|
64 |
And the following fields match these values:
|
|
|
65 |
| Course full name | Course 2 |
|
|
|
66 |
| Course short name | C2 |
|
|
|
67 |
| Field 1 | testcontent1 |
|
|
|
68 |
| Field 2 | testcontent2 |
|
|
|
69 |
| Field 3 | 1 |
|
|
|
70 |
| customfield_f4[day] | 1 |
|
|
|
71 |
| customfield_f4[month] | January |
|
|
|
72 |
| customfield_f4[year] | 2019 |
|
|
|
73 |
| Field 5 | b |
|
|
|
74 |
And I log out
|
|
|
75 |
|
|
|
76 |
@javascript @editor_tiny
|
|
|
77 |
Scenario: Use images in the custom field description
|
|
|
78 |
When I log in as "admin"
|
|
|
79 |
And I navigate to "Courses > Default settings > Course custom fields" in site administration
|
|
|
80 |
And I click on "Edit" "link" in the "Field 1" "table_row"
|
|
|
81 |
And I click on "Image" "button" in the "Description" "form_row"
|
|
|
82 |
And I click on "Browse repositories" "button"
|
|
|
83 |
And I click on "Private files" "link" in the ".fp-repo-area" "css_element"
|
|
|
84 |
And I click on "gd-logo.png" "link"
|
|
|
85 |
And I click on "Select this file" "button"
|
11 |
efrain |
86 |
And I set the field "How would you describe this image to someone who can't see it?" to "Example"
|
1 |
efrain |
87 |
And I click on "Save" "button" in the "Image details" "dialogue"
|
|
|
88 |
And I click on "Save changes" "button" in the "Updating Field 1" "dialogue"
|
|
|
89 |
And I log out
|
|
|
90 |
And I log in as "teacher1"
|
|
|
91 |
And I am on "Course 1" course homepage
|
|
|
92 |
And I navigate to "Settings" in current page administration
|
|
|
93 |
And I expand all fieldsets
|
|
|
94 |
Then the image at "//div[contains(@class, 'fitem')][contains(., 'Field 1')]/following-sibling::div[1]//img[contains(@src, 'pluginfile.php') and contains(@src, '/core_customfield/description/') and @alt='Example']" "xpath_element" should be identical to "lib/tests/fixtures/gd-logo.png"
|
|
|
95 |
And I log out
|
|
|
96 |
|
|
|
97 |
@javascript
|
|
|
98 |
Scenario: Custom field short name must be present and unique
|
|
|
99 |
When I log in as "admin"
|
|
|
100 |
And I navigate to "Courses > Default settings > Course custom fields" in site administration
|
|
|
101 |
And I click on "Add a new custom field" "link"
|
|
|
102 |
And I click on "Short text" "link"
|
|
|
103 |
And I set the following fields to these values:
|
|
|
104 |
| Name | Test field |
|
|
|
105 |
And I click on "Save changes" "button" in the "Adding a new Short text" "dialogue"
|
|
|
106 |
Then I should see "You must supply a value here" in the "Short name" "form_row"
|
|
|
107 |
And I set the field "Short name" to "short name"
|
|
|
108 |
And I click on "Save changes" "button" in the "Adding a new Short text" "dialogue"
|
|
|
109 |
Then I should see "The short name can only contain alphanumeric lowercase characters and underscores (_)." in the "Short name" "form_row"
|
|
|
110 |
And I set the field "Short name" to "f1"
|
|
|
111 |
And I click on "Save changes" "button" in the "Adding a new Short text" "dialogue"
|
|
|
112 |
Then I should see "Short name already exists" in the "Short name" "form_row"
|
|
|
113 |
And I click on "Cancel" "button" in the "Adding a new Short text" "dialogue"
|
|
|
114 |
And I log out
|