MDL-50664 mod_data: tests for 'manageapproved' setting.
[moodle.git] / mod / data / tests / behat / manageapproved.feature
CommitLineData
ec9e1bec
RW
1@mod @mod_data
2Feature: Users can edit approved entries in database activities
3 In order to control whether approved database entries can be changed
4 As a teacher
5 I need to be able to enable or disable management of approved entries
6
7 Background:
8 Given the following "users" exist:
9 | username | firstname | lastname | email |
10 | student1 | Student | 1 | student1@example.com |
11 | teacher1 | Teacher | 1 | teacher1@example.com |
12 And the following "courses" exist:
13 | fullname | shortname | category |
14 | Course 1 | C1 | 0 |
15 And the following "course enrolments" exist:
16 | user | course | role |
17 | teacher1 | C1 | editingteacher |
18 | student1 | C1 | student |
19 And I log in as "teacher1"
20 And I follow "Course 1"
21 And I turn editing mode on
22
23 @javascript
24 Scenario: Students can manage their approved entries to a database
25 # Create database activity and allow editing of
26 # approved entries.
27 And I add a "Database" to section "1" and I fill the form with:
28 | Name | Test database name |
29 | Description | Test |
30 | id_approval | Yes |
31 | id_manageapproved | Yes |
32 And I add a "Text input" field to "Test database name" database and I fill the form with:
33 | Field name | Test field name |
34 | Field description | Test field description |
35 # To generate the default templates.
36 And I follow "Templates"
37 And I log out
38 # Add an entry as a student.
39 And I log in as "student1"
40 And I follow "Course 1"
41 And I add an entry to "Test database name" database with:
42 | Test field name | Student entry |
43 And I press "Save and view"
44 And I log out
45 # Approve the student's entry as a teacher.
46 And I log in as "teacher1"
47 And I follow "Course 1"
48 And I follow "Test database name"
49 And I follow "Approve"
50 And I log out
51 # Make sure the student can still edit their entry after it's approved.
52 When I log in as "student1"
53 And I follow "Course 1"
54 And I follow "Test database name"
55 Then I should see "Student entry"
56 And "Edit" "link" should exist
57
58 @javascript
59 Scenario: Students can not manage their approved entries to a database
60 # Create database activity and don't allow editing of
61 # approved entries.
62 And I add a "Database" to section "1" and I fill the form with:
63 | Name | Test database name |
64 | Description | Test |
65 | id_approval | Yes |
66 | id_manageapproved | No |
67 And I add a "Text input" field to "Test database name" database and I fill the form with:
68 | Field name | Test field name |
69 | Field description | Test field description |
70 # To generate the default templates.
71 And I follow "Templates"
72 And I log out
73 # Add an entry as a student.
74 And I log in as "student1"
75 And I follow "Course 1"
76 And I add an entry to "Test database name" database with:
77 | Test field name | Student entry |
78 And I press "Save and view"
79 And I log out
80 # Approve the student's entry as a teacher.
81 And I log in as "teacher1"
82 And I follow "Course 1"
83 And I follow "Test database name"
84 And I follow "Approve"
85 And I log out
86 # Make sure the student isn't able to edit their entry after it's approved.
87 When I log in as "student1"
88 And I follow "Course 1"
89 And I follow "Test database name"
90 Then I should see "Student entry"
91 And "Edit" "link" should not exist