MDL-52964 Qtype: Add behat tests to core question types
[moodle.git] / question / type / shortanswer / tests / behat / preview.feature
bloba9b6ebc4ec10863c62b7e601e30acf824bcd0d15
1 @qtype @qtype_shortanswer
2 Feature: Preview a Short answer question
3   As a teacher
4   In order to check my Short answer questions will work for students
5   I need to preview them
7   Background:
8     Given the following "users" exist:
9       | username | firstname | lastname | email               |
10       | teacher1 | T1        | Teacher1 | teacher1@moodle.com |
11     And the following "courses" exist:
12       | fullname | shortname | category |
13       | Course 1 | C1        | 0        |
14     And the following "course enrolments" exist:
15       | user     | course | role           |
16       | teacher1 | C1     | editingteacher |
17     And the following "question categories" exist:
18       | contextlevel | reference | name           |
19       | Course       | C1        | Test questions |
20     And the following "questions" exist:
21       | questioncategory | qtype       | name            | template |
22       | Test questions   | shortanswer | shortanswer-001 | frogtoad |
23     Given I log in as "teacher1"
24     And I follow "Course 1"
25     And I navigate to "Question bank" node in "Course administration"
28   @javascript
29   Scenario: Preview a Short answer question with correct answer
30     When I click on "Preview" "link" in the "shortanswer-001" "table_row"
31     And I switch to "questionpreview" window
32     Then I should see "Name an amphibian:"
33     # Set behaviour options
34     And I set the following fields to these values:
35       | behaviour | immediatefeedback |
36     And I press "Start again with these options"
37     And I set the field with xpath "//div[@class='qtext']//input[contains(@id, '1_answer')]" to "frog"
38     And I press "Check"
39     Then I should see "Frog is a very good answer."
40     And I should see "Generalfeedback: frog or toad would have been OK."
41     And I should see "The correct answer is: frog"
43   @javascript
44   Scenario: Preview a Short answer question with almost correct answer
45     When I click on "Preview" "link" in the "shortanswer-001" "table_row"
46     And I switch to "questionpreview" window
47     Then I should see "Name an amphibian:"
48     # Set behaviour options
49     And I set the following fields to these values:
50       | behaviour | immediatefeedback |
51     And I press "Start again with these options"
52     And I set the field with xpath "//div[@class='qtext']//input[contains(@id, '1_answer')]" to "toad"
53     And I press "Check"
54     Then I should see "Toad is an OK good answer."
55     And I should see "Generalfeedback: frog or toad would have been OK."
56     And I should see "The correct answer is: frog"
58   @javascript
59   Scenario: Preview a Short answer question with incorrect answer
60     When I click on "Preview" "link" in the "shortanswer-001" "table_row"
61     And I switch to "questionpreview" window
62     Then I should see "Name an amphibian:"
63     # Set behaviour options
64     And I set the following fields to these values:
65       | behaviour | immediatefeedback |
66     And I press "Start again with these options"
67     And I set the field with xpath "//div[@class='qtext']//input[contains(@id, '1_answer')]" to "cat"
68     And I press "Check"
69     Then I should see "That is a bad answer."
70     And I should see "Generalfeedback: frog or toad would have been OK."
71     And I should see "The correct answer is: frog"