Proyectos de Subversion Moodle

Rev

Ir a la última revisión | | Ultima modificación | Ver Log |

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