Merge branch 'MDL-48373' of git://github.com/timhunt/moodle
[moodle.git] / question / tests / behat / sort_questions.feature
1 @core @core_question
2 Feature: The questions in the question bank can be sorted in various ways
3   In order to see what questions I have
4   As a teacher
5   I want to view them in different orders
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              | user     | questiontext    |
22       | Test questions   | essay     | A question 1 name | admin    | Question 1 text |
23       | Test questions   | essay     | B question 2 name | teacher1 | Question 2 text |
24       | Test questions   | numerical | C question 3 name | teacher1 | Question 3 text |
25     And I log in as "teacher1"
26     And I follow "Course 1"
27     And I navigate to "Questions" node in "Course administration > Question bank"
29   @javascript
30   Scenario: The questions are sorted by type by default
31     Then "A question 1 name" "checkbox" should appear before "C question 3 name" "checkbox"
33   @javascript
34   Scenario: The questions can be sorted in reverse order by type
35     When I follow "Sort by Question type descending"
36     Then "C question 3 name" "checkbox" should appear before "A question 1 name" "checkbox"
38   @javascript
39   Scenario: The questions can be sorted by name
40     When I follow "Sort by Question ascending"
41     Then "A question 1 name" "checkbox" should appear before "B question 2 name" "checkbox"
42     And "B question 2 name" "checkbox" should appear before "C question 3 name" "checkbox"
44   @javascript
45   Scenario: The questions can be sorted in reverse order by name
46     When I follow "Sort by Question ascending"
47     And I follow "Sort by Question descending"
48     Then "C question 3 name" "checkbox" should appear before "B question 2 name" "checkbox"
49     And "B question 2 name" "checkbox" should appear before "A question 1 name" "checkbox"
51   @javascript
52   Scenario: The questions can be sorted by creator name
53     When I follow "Sort by First name ascending"
54     Then "A question 1 name" "checkbox" should appear before "B question 2 name" "checkbox"
56   @javascript
57   Scenario: The questions can be sorted in reverse order by creator name
58     When I follow "Sort by First name ascending"
59     And I follow "Sort by First name descending"
60     Then "B question 2 name" "checkbox" should appear before "A question 1 name" "checkbox"
62   @javascript
63   Scenario: The question text can be shown in the list of questions
64     When I click on "Show question text in the question list" "checkbox"
65     Then I should see "Question 1 text"
66     And I should see "Question 2 text"
67     And I should see "Question 3 text"