1 @mod @mod_quiz @javascript
2 Feature: Adding random questions to a quiz based on category and tags
3 In order to have better assessment
5 I want to display questions that are randomly picked from the question bank
8 Given the following "users" exist:
9 | username | firstname | lastname | email |
10 | teacher1 | Teacher | 1 | t1@example.com |
11 And the following "courses" exist:
12 | fullname | shortname |
14 And the following "course enrolments" exist:
15 | user | course | role |
16 | teacher1 | C1 | editingteacher |
17 And the following "activities" exist:
18 | activity | name | intro | course | idnumber |
19 | quiz | Quiz 1 | Quiz 1 for testing the Add random question form | C1 | quiz1 |
20 And the following "question categories" exist:
21 | contextlevel | reference | name |
22 | Course | C1 | Questions Category 1|
23 | Course | C1 | Questions Category 2|
24 And the following "questions" exist:
25 | questioncategory | qtype | name | user | questiontext |
26 | Questions Category 1 | essay | question 1 name | admin | Question 1 text |
27 | Questions Category 1 | essay | question 2 name | teacher1 | Question 2 text |
29 Scenario: Available tags are shown in the autocomplete tag field
30 Given I log in as "teacher1"
31 And I am on "Course 1" course homepage
32 When I navigate to "Question bank > Questions" in current page administration
33 And I click on "Edit" "link" in the "question 1 name" "table_row"
34 And I set the following fields to these values:
36 And I press "id_submitbutton"
37 And I click on "Manage tags" "link" in the "question 2 name" "table_row"
38 And I set the following fields in the "Question tags" "dialogue" to these values:
40 And I press "Save changes"
41 And I am on the "Quiz 1" "mod_quiz > Edit" page
42 And I open the "last" add to quiz menu
43 And I follow "a random question"
44 And I open the autocomplete suggestions list
45 Then "foo" "autocomplete_suggestions" should exist
46 And "bar" "autocomplete_suggestions" should exist
48 Scenario: Teacher without moodle/question:useall should not see the add a random question menu item
49 Given the following "permission overrides" exist:
50 | capability | permission | role | contextlevel | reference |
51 | moodle/question:useall | Prevent | editingteacher | Course | C1 |
52 And I log in as "teacher1"
53 And I am on the "Quiz 1" "mod_quiz > Edit" page
54 When I open the "last" add to quiz menu
55 Then I should not see "a random question"