MDL-32135 mod_choice: fix behat tests
[moodle.git] / mod / choice / tests / behat / publish_results.feature
1 @mod @mod_choice
2 Feature: A teacher can choose one of 4 options for publishing choice results
3   In order to display choice activities outcomes
4   As a teacher
5   I need to publish the choice activity results in different ways
7   Background:
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 follow "Course 1"
21     And I turn editing mode on
23   Scenario: Do not publish results to students
24     Given I add a "Choice" to section "1" and I fill the form with:
25       | Choice name | Choice 1 |
26       | Description | Choice Description |
27       | Publish results | Do not publish results to students |
28       | option[0] | Option 1 |
29       | option[1] | Option 2 |
30     And I log out
31     And I log in as "student1"
32     And I follow "Course 1"
33     When I choose "Option 1" from "Choice 1" choice activity
34     Then I should see "Your selection: Option 1"
35     And I should not see "Responses"
36     And I should not see "Graph display"
38   Scenario: Show results to students after they answer
39     Given I add a "Choice" to section "1" and I fill the form with:
40       | Choice name | Choice 1 |
41       | Description | Choice Description |
42       | option[0] | Option 1 |
43       | option[1] | Option 2 |
44       | Publish results | Show results to students after they answer |
45     And I log out
46     And I log in as "student1"
47     And I follow "Course 1"
48     When I follow "Choice 1"
49     Then I should not see "Responses"
50     And I should not see "Graph display"
51     And I follow "Course 1"
52     And I choose "Option 1" from "Choice 1" choice activity
53     And I should see "Your selection: Option 1"
54     And I should see "Responses"
55     And I should see "Graph display"
57   Scenario: Show results to students only after the choice is closed
58     Given I add a "Choice" to section "1" and I fill the form with:
59       | Choice name | Choice 1 |
60       | Description | Choice Description |
61       | Publish results | Show results to students only after the choice is closed |
62       | option[0] | Option 1 |
63       | option[1] | Option 2 |
64     And I log out
65     And I log in as "student1"
66     And I follow "Course 1"
67     When I follow "Choice 1"
68     Then I should not see "Responses"
69     And I should not see "Graph display"
70     And I choose "Option 1" from "Choice 1" choice activity
71     And I log out
72     And I log in as "teacher1"
73     And I follow "Course 1"
74     And I follow "Choice 1"
75     And I follow "Edit settings"
76     And I expand all fieldsets
77     And I set the following fields to these values:
78       | Restrict answering to this time period | 1 |
79       | timeopen[day] | 1 |
80       | timeopen[month] | January |
81       | timeopen[year] | 2010 |
82       | timeclose[day] | 2 |
83       | timeclose[month] | January |
84       | timeclose[year] | 2010 |
85     And I press "Save and return to course"
86     And I log out
87     And I log in as "student1"
88     And I follow "Course 1"
89     And I follow "Choice 1"
90     And I should see "Responses"
91     And I should see "Graph display"
93   Scenario: Always show results to students
94     Given I add a "Choice" to section "1" and I fill the form with:
95       | Choice name | Choice 1 |
96       | Description | Choice Description |
97       | option[0] | Option 1 |
98       | option[1] | Option 2 |
99       | Publish results | Always show results to students |
100     And I log out
101     And I log in as "student1"
102     And I follow "Course 1"
103     When I follow "Choice 1"
104     And I should see "Responses"
105     And I should see "Graph display"