MDL-37745 mod_choice: Show taken and limit.
[moodle.git] / mod / choice / tests / behat / multiple_options.feature
blob2efd12414bc669ebfa7c94063308ea34cbde5554
1 @mod @mod_choice
2 Feature: Multiple option choice response
3   In order to ask questions as a choice of multiple responses
4   As a teacher
5   I need to add choice activities to courses with multiple options enabled
7   Scenario: Complete a choice with multiple options enabled
8     Given the following "users" exist:
9       | username | firstname | lastname | email |
10       | teacher1 | Teacher | 1 | teacher1@example.com |
11       | student1 | Student | 1 | student1@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 am on "Course 1" course homepage with editing mode on
21     And I add a "Choice" to section "1" and I fill the form with:
22       | Choice name | Choice name |
23       | Description | Choice Description |
24       | Allow more than one choice to be selected | Yes |
25       | option[0] | Option 1 |
26       | option[1] | Option 2 |
27     And I log out
28     When I log in as "student1"
29     And I am on "Course 1" course homepage
30     And I choose options "Option 1","Option 2" from "Choice name" choice activity
31     Then I should see "Your selection: Option 1; Option 2"
32     And I should see "Your choice has been saved"
34   Scenario: Complete a choice with multiple options enabled and limited responses set
35     Given the following "users" exist:
36       | username | firstname | lastname | email |
37       | teacher1 | Teacher | 1 | teacher1@example.com |
38       | student1 | Student | 1 | student1@example.com |
39       | student2 | Student | 2 | student2@example.com |
40     And the following "courses" exist:
41       | fullname | shortname | category |
42       | Course 1 | C1 | 0 |
43     And the following "course enrolments" exist:
44       | user | course | role |
45       | teacher1 | C1 | editingteacher |
46       | student1 | C1 | student |
47       | student2 | C1 | student |
48     And I log in as "teacher1"
49     And I am on "Course 1" course homepage with editing mode on
50     And I add a "Choice" to section "1" and I fill the form with:
51       | Choice name | Choice name |
52       | Description | Choice Description |
53       | Allow more than one choice to be selected | Yes |
54       | Limit the number of responses allowed | 1 |
55       | Show available spaces  | 1 |
56       | option[0] | Option 1 |
57       | limit[0] | 1 |
58       | option[1] | Option 2 |
59       | limit[1] | 1 |
60       | option[2] | Option 3 |
61       | limit[2] | 1 |
62     And I log out
63     When I log in as "student1"
64     And I am on "Course 1" course homepage
65     And I choose options "Option 1","Option 2" from "Choice name" choice activity
66     Then I should see "Your selection: Option 1; Option 2"
67     And I should see "Your choice has been saved"
68     And I log out
69     And I log in as "student2"
70     And I am on "Course 1" course homepage
71     And I follow "Choice name"
72     And I should see "Option 1 (Full)"
73     And I should see "Option 2 (Full)"
74     And I should see "Option 3"
75     And the "#choice_1" "css_element" should be disabled
76     And the "#choice_2" "css_element" should be disabled
77     And the "#choice_3" "css_element" should be enabled
78     And I log out
79     And I log in as "teacher1"
80     And I am on "Course 1" course homepage
81     And I follow "Choice name"
82     And I follow "View 1 responses"
83     Then I should see "Option 1 (Full)"
84     And I should see "Limit: 1"
85     And I am on "Course 1" course homepage with editing mode on
86     And I follow "Choice name"
87     And I navigate to "Edit settings" in current page administration
88     And I set the following fields to these values:
89       | Limit the number of responses allowed | No |
90     And I press "Save and return to course"
91     And I am on "Course 1" course homepage
92     And I follow "Choice name"
93     And I follow "View 1 responses"
94     Then I should not see "Limit: 1"
95     And I log out