[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/mod/quiz/tests/behat/ -> editing_add.feature (source)

   1  @mod @mod_quiz
   2  Feature: Edit quiz page - adding things
   3    In order to build the quiz I want my students to attempt
   4    As a teacher
   5    I need to be able to add questions to the quiz.
   6  
   7    Background:
   8      Given the following "users" exist:
   9        | username | firstname | lastname | email               |
  10        | teacher1 | T1        | Teacher1 | [email protected] |
  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 "activities" exist:
  18        | activity   | name   | intro                           | course | idnumber |
  19        | quiz       | Quiz 1 | Quiz 1 for testing the Add menu | C1     | quiz1    |
  20      And I log in as "teacher1"
  21      And I follow "Course 1"
  22      And I follow "Quiz 1"
  23      And I navigate to "Edit quiz" node in "Quiz administration"
  24      Then I should see "Editing quiz: Quiz 1"
  25  
  26    @javascript
  27    Scenario: Add some new question to the quiz using '+ a new question' options of the 'Add' menu.
  28      And I open the "last" add to quiz menu
  29      And I follow "a new question"
  30      And I set the field "qtype_qtype_essay" to "1"
  31      And I press "submitbutton"
  32      Then I should see "Adding an Essay question"
  33      And I set the field "Question name" to "Essay 01 new"
  34      And I set the field "Question text" to "Please write 200 words about Essay 01"
  35      And I press "id_submitbutton"
  36      Then I should see "Editing quiz: Quiz 1"
  37      And I should see "Essay 01 new" on quiz page "1"
  38  
  39      And I open the "Page 1" add to quiz menu
  40      And I follow "a new question"
  41      And I set the field "qtype_qtype_essay" to "1"
  42      And I press "submitbutton"
  43      Then I should see "Adding an Essay question"
  44      And I set the field "Question name" to "Essay 02 new"
  45      And I set the field "Question text" to "Please write 200 words about Essay 02"
  46      And I press "id_submitbutton"
  47      Then I should see "Editing quiz: Quiz 1"
  48      And I should see "Essay 01 new" on quiz page "1"
  49      And I should see "Essay 02 new" on quiz page "1"
  50  
  51      And I open the "Page 1" add to quiz menu
  52      And I follow "a new question"
  53      And I set the field "qtype_qtype_essay" to "1"
  54      And I press "submitbutton"
  55      Then I should see "Adding an Essay question"
  56      And I set the field "Question name" to "Essay 03 new"
  57      And I set the field "Question text" to "Please write 300 words about Essay 03"
  58      And I press "id_submitbutton"
  59      Then I should see "Editing quiz: Quiz 1"
  60      And I should see "Essay 01 new" on quiz page "1"
  61      And I should see "Essay 02 new" on quiz page "1"
  62      And I should see "Essay 03 new" on quiz page "1"
  63  
  64      And I open the "Page 1" add to quiz menu
  65      And I follow "a new question"
  66      And I set the field "qtype_qtype_essay" to "1"
  67      And I press "submitbutton"
  68      Then I should see "Adding an Essay question"
  69      And I set the field "Question name" to "Essay 04 new"
  70      And I set the field "Question text" to "Please write 300 words about Essay 04"
  71      And I press "id_submitbutton"
  72      Then I should see "Editing quiz: Quiz 1"
  73      And I should see "Essay 01 new" on quiz page "1"
  74      And I should see "Essay 02 new" on quiz page "1"
  75      And I should see "Essay 03 new" on quiz page "1"
  76      And I should see "Essay 04 new" on quiz page "1"
  77  
  78      # Repaginate as two questions per page.
  79      And I should not see "Page 2"
  80      When I press "Repaginate"
  81      Then I should see "Repaginate with"
  82      And I set the field "menuquestionsperpage" to "2"
  83      When I press "Go"
  84      And I should see "Essay 01 new" on quiz page "1"
  85      And I should see "Essay 02 new" on quiz page "1"
  86      And I should see "Essay 03 new" on quiz page "2"
  87      And I should see "Essay 04 new" on quiz page "2"
  88  
  89      # Add a question to page 2.
  90      When I open the "Page 2" add to quiz menu
  91      And I follow "a new question" in the open menu
  92      And I set the field "qtype_qtype_essay" to "1"
  93      And I press "submitbutton"
  94      Then I should see "Adding an Essay question"
  95      When I set the field "Question name" to "Essay for page 2"
  96      And I set the field "Question text" to "Please write 200 words about Essay for page 2"
  97      And I press "id_submitbutton"
  98      Then I should see "Editing quiz: Quiz 1"
  99      And I should see "Essay 01 new" on quiz page "1"
 100      And I should see "Essay 02 new" on quiz page "1"
 101      And I should see "Essay 03 new" on quiz page "2"
 102      And I should see "Essay 04 new" on quiz page "2"
 103      And I should see "Essay for page 2" on quiz page "2"
 104  
 105    @javascript
 106    Scenario: Add questions from question bank to the quiz. In order to be able to
 107        add questions from question bank to the quiz, first we create some new questions
 108        in various categories and add them to the question bank.
 109  
 110      # Create a couple of sub categories.
 111      And I follow "Course 1"
 112      And I navigate to "Categories" node in "Course administration > Question bank"
 113      Then I should see "Add category"
 114      Then I set the field "Parent category" to "Default for C1"
 115      And I set the field "Name" to "Subcat 1"
 116      And I set the field "Category info" to "This is sub category 1"
 117      Then I press "id_submitbutton"
 118      And I should see "Subcat 1"
 119  
 120      Then I set the field "Parent category" to "Default for C1"
 121      And I set the field "Name" to "Subcat 2"
 122      And I set the field "Category info" to "This is sub category 2"
 123      Then I press "id_submitbutton"
 124      And I should see "Subcat 2"
 125  
 126      And I navigate to "Questions" node in "Course administration > Question bank"
 127      Then I should see "Question bank"
 128      And I should see "Select a category"
 129  
 130      # Create the Essay 01 question.
 131      When I press "Create a new question ..."
 132      And I set the field "qtype_qtype_essay" to "1"
 133      And I press "Add"
 134      Then I should see "Adding an Essay question"
 135      And I set the field "Question name" to "Essay 01"
 136      And I set the field "Question text" to "Please write 100 words about Essay 01"
 137      And I press "id_submitbutton"
 138      Then I should see "Question bank"
 139      And I should see "Essay 01"
 140  
 141      # Create the Essay 02 question.
 142      And I should see "Select a category"
 143      And I set the field "Select a category:" to "Subcat 1"
 144      When I press "Create a new question ..."
 145      And I set the field "qtype_qtype_essay" to "1"
 146      And I press "Add"
 147      Then I should see "Adding an Essay question"
 148      And I set the field "Question name" to "Essay 02"
 149      And I set the field "Question text" to "Please write 200 words about Essay 02"
 150      And I press "id_submitbutton"
 151      Then I should see "Question bank"
 152      And I should see "Essay 02"
 153  
 154      # Create the Essay 03 question.
 155      And I set the field "Select a category" to "Default for C1"
 156      When I press "Create a new question ..."
 157      And I set the field "qtype_qtype_essay" to "1"
 158      And I press "Add"
 159      Then I should see "Adding an Essay question"
 160      And I set the field "Question name" to "Essay 03"
 161      And I set the field "Question text" to "Please write 300 words about Essay 03"
 162      And I press "id_submitbutton"
 163      Then I should see "Question bank"
 164      And I should see "Essay 03"
 165  
 166      # Create the TF 01 question.
 167      When I press "Create a new question ..."
 168      And I set the field "qtype_qtype_truefalse" to "1"
 169      And I press "Add"
 170      Then I should see "Adding a True/False question"
 171      And I set the field "Question name" to "TF 01"
 172      And I set the field "Question text" to "The correct answer is true"
 173      And I set the field "Correct answer" to "True"
 174      And I press "id_submitbutton"
 175      Then I should see "Question bank"
 176      And I should see "TF 01"
 177  
 178      # Create the TF 02 question.
 179      When I press "Create a new question ..."
 180      And I set the field "qtype_qtype_truefalse" to "1"
 181      And I press "Add"
 182      Then I should see "Adding a True/False question"
 183      And I set the field "Question name" to "TF 02"
 184      And I set the field "Question text" to "The correct answer is false"
 185      And I set the field "Correct answer" to "False"
 186      And I press "id_submitbutton"
 187      Then I should see "Question bank"
 188      And I should see "TF 02"
 189  
 190      # Add questions from question bank using the Add menu.
 191      # Add Essay 03 from question bank.
 192      And I follow "Course 1"
 193      And I follow "Quiz 1"
 194      And I follow "Edit quiz"
 195      And I open the "last" add to quiz menu
 196      And I follow "from question bank"
 197      And I click on "Add to quiz" "link" in the "Essay 03" "table_row"
 198      Then I should see "Editing quiz: Quiz 1"
 199      And I should see "Essay 03" on quiz page "1"
 200  
 201      # Add Essay 01 from question bank.
 202      And I open the "Page 1" add to quiz menu
 203      And I follow "from question bank"
 204      And I click on "Add to quiz" "link" in the "Essay 01" "table_row"
 205      Then I should see "Editing quiz: Quiz 1"
 206      And I should see "Essay 03" on quiz page "1"
 207      And I should see "Essay 01" on quiz page "1"
 208  
 209      # Add Esay 02 from question bank.
 210      And I open the "Page 1" add to quiz menu
 211      And I follow "from question bank"
 212      And I should see "Select a category"
 213      And I set the field "Select a category" to "Subcat 1"
 214      And I click on "Add to quiz" "link" in the "Essay 02" "table_row"
 215      Then I should see "Editing quiz: Quiz 1"
 216      And I should see "Essay 03" on quiz page "1"
 217      And I should see "Essay 01" on quiz page "1"
 218      And I should see "Essay 02" on quiz page "1"
 219  
 220      # Add a random question.
 221      And I open the "Page 1" add to quiz menu
 222      And I follow "a random question"
 223      And I press "Add random question"
 224      Then I should see "Editing quiz: Quiz 1"
 225      And I should see "Essay 03" on quiz page "1"
 226      And I should see "Essay 01" on quiz page "1"
 227      And I should see "Essay 02" on quiz page "1"
 228      And I should see "Random" on quiz page "1"
 229  
 230      # Repaginate as one question per page.
 231      And I should not see "Page 2"
 232      When I press "Repaginate"
 233      Then I should see "Repaginate with"
 234      And I set the field "menuquestionsperpage" to "1"
 235      When I press "Go"
 236      And I should see "Essay 03" on quiz page "1"
 237      And I should see "Essay 01" on quiz page "2"
 238      And I should see "Essay 02" on quiz page "3"
 239      And I should see "Random" on quiz page "4"
 240  
 241      # Add a random question to page 4.
 242      And I open the "Page 4" add to quiz menu
 243      And I follow "a new question" in the open menu
 244      And I set the field "qtype_qtype_essay" to "1"
 245      And I press "submitbutton"
 246      Then I should see "Adding an Essay question"
 247      And I set the field "Question name" to "Essay for page 4"
 248      And I set the field "Question text" to "Please write 200 words about Essay for page 4"
 249      And I press "id_submitbutton"
 250      Then I should see "Editing quiz: Quiz 1"
 251      And I should see "Essay 03" on quiz page "1"
 252      And I should see "Essay 01" on quiz page "2"
 253      And I should see "Essay 02" on quiz page "3"
 254      And I should see "Random" on quiz page "4"
 255      And I should see "Essay for page 4" on quiz page "4"


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1