| 1 | efrain | 1 | @mod @mod_quiz
 | 
        
           |  |  | 2 | Feature: Edit quiz page - drag-and-drop
 | 
        
           |  |  | 3 |   In order to change the layout of a quiz I built
 | 
        
           |  |  | 4 |   As a teacher
 | 
        
           |  |  | 5 |   I need to be able to drag and drop questions to reorder them.
 | 
        
           |  |  | 6 |   | 
        
           |  |  | 7 |   Background:
 | 
        
           |  |  | 8 |     Given the following "users" exist:
 | 
        
           |  |  | 9 |       | username | firstname | lastname | email                |
 | 
        
           |  |  | 10 |       | teacher1 | T1        | Teacher1 | teacher1@example.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       | questiontext        |
 | 
        
           |  |  | 22 |       | Test questions   | truefalse | Question A | This is question 01 |
 | 
        
           |  |  | 23 |       | Test questions   | truefalse | Question B | This is question 02 |
 | 
        
           |  |  | 24 |       | Test questions   | truefalse | Question C | This is question 03 |
 | 
        
           |  |  | 25 |     And the following "activities" exist:
 | 
        
           |  |  | 26 |       | activity   | name   | course | idnumber |
 | 
        
           |  |  | 27 |       | quiz       | Quiz 1 | C1     | quiz1    |
 | 
        
           |  |  | 28 |     And quiz "Quiz 1" contains the following questions:
 | 
        
           |  |  | 29 |       | question   | page |
 | 
        
           |  |  | 30 |       | Question A | 1    |
 | 
        
           |  |  | 31 |       | Question B | 1    |
 | 
        
           |  |  | 32 |       | Question C | 2    |
 | 
        
           |  |  | 33 |     And I log in as "teacher1"
 | 
        
           |  |  | 34 |     And I am on the "Quiz 1" "mod_quiz > Edit" page
 | 
        
           |  |  | 35 |   | 
        
           |  |  | 36 |   @javascript
 | 
        
           |  |  | 37 |   Scenario: Re-order questions by clicking on the move icon.
 | 
        
           |  |  | 38 |     Then I should see "Question A" on quiz page "1"
 | 
        
           |  |  | 39 |     And I should see "Question B" on quiz page "1"
 | 
        
           |  |  | 40 |     And I should see "Question C" on quiz page "2"
 | 
        
           |  |  | 41 |   | 
        
           |  |  | 42 |     When I move "Question A" to "After Question 2" in the quiz by clicking the move icon
 | 
        
           |  |  | 43 |     Then I should see "Question B" on quiz page "1"
 | 
        
           |  |  | 44 |     And I should see "Question A" on quiz page "1"
 | 
        
           |  |  | 45 |     And I should see "Question B" before "Question A" on the edit quiz page
 | 
        
           |  |  | 46 |     And I should see "Question C" on quiz page "2"
 | 
        
           |  |  | 47 |   | 
        
           |  |  | 48 |     When I move "Question A" to "After Page 2" in the quiz by clicking the move icon
 | 
        
           |  |  | 49 |     Then I should see "Question B" on quiz page "1"
 | 
        
           |  |  | 50 |     And I should see "Question A" on quiz page "2"
 | 
        
           |  |  | 51 |     And I should see "Question C" on quiz page "2"
 | 
        
           |  |  | 52 |     And I should see "Question A" before "Question C" on the edit quiz page
 | 
        
           |  |  | 53 |   | 
        
           |  |  | 54 |     When I move "Question B" to "After Question 2" in the quiz by clicking the move icon
 | 
        
           |  |  | 55 |     Then I should see "Question A" on quiz page "1"
 | 
        
           |  |  | 56 |     And I should see "Question B" on quiz page "1"
 | 
        
           |  |  | 57 |     And I should see "Question C" on quiz page "1"
 | 
        
           |  |  | 58 |     And I should see "Question A" before "Question B" on the edit quiz page
 | 
        
           |  |  | 59 |     And I should see "Question B" before "Question C" on the edit quiz page
 | 
        
           |  |  | 60 |   | 
        
           |  |  | 61 |     When I move "Question B" to "After Page 1" in the quiz by clicking the move icon
 | 
        
           |  |  | 62 |     Then I should see "Question B" on quiz page "1"
 | 
        
           |  |  | 63 |     And I should see "Question A" on quiz page "1"
 | 
        
           |  |  | 64 |     And I should see "Question C" on quiz page "1"
 | 
        
           |  |  | 65 |     And I should see "Question B" before "Question A" on the edit quiz page
 | 
        
           |  |  | 66 |     And I should see "Question A" before "Question C" on the edit quiz page
 | 
        
           |  |  | 67 |   | 
        
           |  |  | 68 |     When I click on the "Add" page break icon after question "Question A"
 | 
        
           |  |  | 69 |     When I open the "Page 2" add to quiz menu
 | 
        
           |  |  | 70 |     And I choose "a new question" in the open action menu
 | 
        
           |  |  | 71 |     And I set the field "item_qtype_description" to "1"
 | 
        
           |  |  | 72 |     And I press "submitbutton"
 | 
        
           |  |  | 73 |     Then I should see "Adding a description"
 | 
        
           |  |  | 74 |     And I set the following fields to these values:
 | 
        
           |  |  | 75 |       | Question name | Question D  |
 | 
        
           |  |  | 76 |       | Question text | Useful info |
 | 
        
           |  |  | 77 |     And I press "id_submitbutton"
 | 
        
           |  |  | 78 |     Then I should see "Question B" on quiz page "1"
 | 
        
           |  |  | 79 |     And I should see "Question A" on quiz page "1"
 | 
        
           |  |  | 80 |     And I should see "Question C" on quiz page "2"
 | 
        
           |  |  | 81 |     And I should see "Question D" on quiz page "2"
 | 
        
           |  |  | 82 |     And I should see "Question B" before "Question A" on the edit quiz page
 | 
        
           |  |  | 83 |     And I should see "Question C" before "Question D" on the edit quiz page
 | 
        
           |  |  | 84 |   | 
        
           |  |  | 85 |     And "Question B" should have number "1" on the edit quiz page
 | 
        
           |  |  | 86 |     And "Question A" should have number "2" on the edit quiz page
 | 
        
           |  |  | 87 |     And "Question C" should have number "3" on the edit quiz page
 | 
        
           |  |  | 88 |     And "Question D" should have number "i" on the edit quiz page
 | 
        
           |  |  | 89 |   | 
        
           |  |  | 90 |     When I move "Question D" to "After Question 2" in the quiz by clicking the move icon
 | 
        
           |  |  | 91 |     Then I should see "Question B" on quiz page "1"
 | 
        
           |  |  | 92 |     And I should see "Question D" on quiz page "1"
 | 
        
           |  |  | 93 |     And I should see "Question A" on quiz page "1"
 | 
        
           |  |  | 94 |     And I should see "Question C" on quiz page "2"
 | 
        
           |  |  | 95 |     And I should see "Question B" before "Question A" on the edit quiz page
 | 
        
           |  |  | 96 |     And I should see "Question A" before "Question D" on the edit quiz page
 | 
        
           |  |  | 97 |   | 
        
           |  |  | 98 |     And "Question B" should have number "1" on the edit quiz page
 | 
        
           |  |  | 99 |     And "Question D" should have number "i" on the edit quiz page
 | 
        
           |  |  | 100 |     And "Question A" should have number "2" on the edit quiz page
 | 
        
           |  |  | 101 |     And "Question C" should have number "3" on the edit quiz page
 |