Merge branch 'MDL-48373' of git://github.com/timhunt/moodle
[moodle.git] / question / tests / behat / delete_questions.feature
1 @core @core_question
2 Feature: A teacher can delete questions in the question bank
3   In order to remove unused questions from the question bank
4   As a teacher
5   I need to delete questions
7   Background:
8     Given the following "users" exist:
9       | username | firstname | lastname | email |
10       | teacher1 | Teacher | 1 | teacher1@asd.com |
11     And the following "courses" exist:
12       | fullname | shortname | format |
13       | Course 1 | C1 | weeks |
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                        | questiontext                  |
22       | Test questions   | essay | Test question to be deleted | Write about whatever you want |
23     And I log in as "teacher1"
24     And I follow "Course 1"
25     And I navigate to "Questions" node in "Course administration > Question bank"
27   @javascript
28   Scenario: A question not used anywhere can really be deleted
29     When I click on "Delete" "link" in the "Test question to be deleted" "table_row"
30     And I press "Continue"
31     And I click on "Also show old questions" "checkbox"
32     Then I should not see "Test question to be deleted"
34   @javascript
35   Scenario: Deleting a question can be cancelled
36     When I click on "Delete" "link" in the "Test question to be deleted" "table_row"
37     And I press "Cancel"
38     Then I should see "Test question to be deleted"
40   @javascript
41   Scenario: Delete a question used in a quiz
42     Given I follow "Course 1"
43     And I turn editing mode on
44     And I add a "Quiz" to section "1" and I fill the form with:
45       | Name | Test quiz |
46     And I add a "True/False" question to the "Test quiz" quiz with:
47       | Question name | Test used question to be deleted |
48       | Question text | Write about whatever you want    |
49     And I navigate to "Questions" node in "Course administration > Question bank"
50     When I click on "Delete" "link" in the "Test used question to be deleted" "table_row"
51     And I press "Continue"
52     Then I should not see "Test used question to be deleted"
53     And I click on "Also show old questions" "checkbox"
54     And I should see "Test used question to be deleted"
55     And I follow "Course 1"
56     And I follow "Test quiz"
57     And I click on "Preview quiz now" "button"
58     And I should see "Write about whatever you want"