1 |
efrain |
1 |
@core @core_question @javascript
|
|
|
2 |
Feature: A teacher can edit questions in the question bank
|
|
|
3 |
In order to improve my questions
|
|
|
4 |
As a teacher
|
|
|
5 |
I need to be able to edit questions
|
|
|
6 |
|
|
|
7 |
Background:
|
|
|
8 |
Given the following "users" exist:
|
|
|
9 |
| username | firstname | lastname | email |
|
|
|
10 |
| teacher1 | Teacher | 1 | teacher1@example.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 |
|
1441 |
ariadna |
17 |
And the following "activities" exist:
|
|
|
18 |
| activity | name | intro | course | idnumber |
|
|
|
19 |
| qbank | Qbank 1 | Question bank 1 | C1 | qbank1 |
|
1 |
efrain |
20 |
And the following "question categories" exist:
|
1441 |
ariadna |
21 |
| contextlevel | reference | name |
|
|
|
22 |
| Activity module | qbank1 | Test questions |
|
1 |
efrain |
23 |
And the following "questions" exist:
|
|
|
24 |
| questioncategory | qtype | name | questiontext |
|
|
|
25 |
| Test questions | essay | Test question to be edited | Write about whatever you want |
|
1441 |
ariadna |
26 |
And I am on the "Qbank 1" "core_question > question bank" page logged in as "teacher1"
|
|
|
27 |
And I apply question bank filter "Category" with value "Test questions"
|
1 |
efrain |
28 |
|
|
|
29 |
@javascript
|
|
|
30 |
Scenario: Edit a previously created question
|
|
|
31 |
When I am on the "Test question to be edited" "core_question > edit" page logged in as "teacher1"
|
|
|
32 |
And I set the following fields to these values:
|
|
|
33 |
| Question name | Edited question name |
|
|
|
34 |
| Question text | Write a lot about what you want |
|
|
|
35 |
And I press "id_submitbutton"
|
|
|
36 |
Then I should see "Edited question name"
|
|
|
37 |
And I should not see "Test question to be edited"
|
|
|
38 |
And I should see "Teacher 1"
|
|
|
39 |
|
|
|
40 |
Scenario: Edit a previously created question without permission 'moodle/question:moveall' and 'moodle/question:movemine'
|
|
|
41 |
Given I log in as "admin"
|
|
|
42 |
And the following "permission overrides" exist:
|
|
|
43 |
| capability | permission | role | contextlevel | reference |
|
|
|
44 |
| moodle/question:movemine | Prevent | editingteacher | System | |
|
|
|
45 |
| moodle/question:moveall | Prevent | editingteacher | System | |
|
|
|
46 |
When I am on the "Test question to be edited" "core_question > edit" page logged in as "teacher1"
|
|
|
47 |
And I set the following fields to these values:
|
|
|
48 |
| Question name | Edited question name |
|
|
|
49 |
| Question text | Write a lot about what you want |
|
|
|
50 |
And I press "id_submitbutton"
|
|
|
51 |
Then I should see "Edited question name"
|
|
|
52 |
And I should not see "Test question to be edited"
|
|
|
53 |
And I should see "Teacher 1"
|
|
|
54 |
|
|
|
55 |
Scenario: Edit a previously created question without permission 'moodle/question:editall' and 'moodle/question:editmine'
|
|
|
56 |
Given I log in as "admin"
|
|
|
57 |
And the following "permission overrides" exist:
|
|
|
58 |
| capability | permission | role | contextlevel | reference |
|
|
|
59 |
| moodle/question:editmine | Prevent | editingteacher | System | |
|
|
|
60 |
| moodle/question:editall | Prevent | editingteacher | System | |
|
|
|
61 |
When I am on the "Test question to be edited" "core_question > edit" page logged in as "teacher1"
|
|
|
62 |
And I set the following fields to these values:
|
|
|
63 |
| Question name | Edited question name |
|
|
|
64 |
| Question text | Write a lot about what you want |
|
|
|
65 |
And I press "id_submitbutton"
|
|
|
66 |
Then I should see "You don't have permission to edit questions from here."
|
|
|
67 |
|
|
|
68 |
Scenario: Editing a question can be cancelled
|
|
|
69 |
When I am on the "Test question to be edited" "core_question > edit" page logged in as "teacher1"
|
|
|
70 |
And I set the field "Question name" to "Edited question name"
|
|
|
71 |
And I press "Cancel"
|
1441 |
ariadna |
72 |
And I apply question bank filter "Category" with value "Test questions"
|
1 |
efrain |
73 |
Then I should see "Test question to be edited"
|
|
|
74 |
And I should see "Admin User"
|
|
|
75 |
|
|
|
76 |
Scenario: A question can have its idnumber removed
|
|
|
77 |
Given the following "questions" exist:
|
|
|
78 |
| questioncategory | qtype | name | idnumber |
|
|
|
79 |
| Test questions | essay | Question with idnumber | frog |
|
1441 |
ariadna |
80 |
When I am on the "Qbank 1" "core_question > question bank" page logged in as "teacher1"
|
|
|
81 |
And I apply question bank filter "Category" with value "Test questions"
|
1 |
efrain |
82 |
Then I should see "frog" in the "Question with idnumber" "table_row"
|
|
|
83 |
When I choose "Edit question" action for "Question with idnumber" in the question bank
|
|
|
84 |
And I set the field "ID number" to ""
|
|
|
85 |
And I press "id_submitbutton"
|
|
|
86 |
Then I should not see "frog" in the "Question with idnumber" "table_row"
|
|
|
87 |
|
|
|
88 |
Scenario: If the question type is no longer installed, then most edit actions are not present
|
|
|
89 |
Given the following "questions" exist:
|
|
|
90 |
| questioncategory | qtype | name | questiontext |
|
|
|
91 |
| Test questions | missingtype | Broken question | Write something |
|
1441 |
ariadna |
92 |
When I am on the "Qbank 1" "core_question > question bank" page logged in as "teacher1"
|
|
|
93 |
And I apply question bank filter "Category" with value "Test questions"
|
1 |
efrain |
94 |
Then the "Edit question" item should not exist in the "Edit" action menu of the "Broken question" "table_row"
|
|
|
95 |
And the "Duplicate" item should not exist in the "Edit" action menu of the "Broken question" "table_row"
|
|
|
96 |
And the "Preview" item should not exist in the "Edit" action menu of the "Broken question" "table_row"
|
|
|
97 |
And the "Export as XML" item should not exist in the "Edit" action menu of the "Broken question" "table_row"
|
|
|
98 |
And the "Manage tags" item should exist in the "Edit" action menu of the "Broken question" "table_row"
|
|
|
99 |
And the "Delete" item should exist in the "Edit" action menu of the "Broken question" "table_row"
|