MDL-47494 gapselect: qtype_gapselect: Adding behat feature and testing, #12009

This commit is contained in:
M Kassaei
2014-11-03 14:35:00 +00:00
committed by Tim Hunt
parent 2095ea2c13
commit 45dba0d0e7
3 changed files with 251 additions and 0 deletions
@@ -0,0 +1,157 @@
@ou @ou_vle @qtype @qtype_gapselect
Feature: Test all the basic functionality of this question type
In order to evaluate students responses, As a teacher I need to
create and preview gapselect (Select missing words) questions.
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | T1 | Teacher1 | teacher1@moodle.com |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
@javascript
Scenario: Create, edit then preview a gapselect question.
Given I log in as "teacher1"
And I follow "Course 1"
And I navigate to "Question bank" node in "Course administration"
# Create a new question.
And I add a "Select missing words" question filling the form with:
| Question name | Select missing words 001 |
| Question text | The [[1]] [[2]] on the [[3]]. |
| General feedback | The cat sat on the mat. |
| id_choices_0_answer | cat |
| id_choices_1_answer | sat |
| id_choices_2_answer | mat |
| id_choices_3_answer | dog |
| id_choices_4_answer | table |
| Hint 1 | First hint |
| Hint 2 | Second hint |
Then I should see "Select missing words 001"
# Preview it.
When I click on "Preview" "link" in the "Select missing words 001" "table_row"
And I switch to "questionpreview" window
# Gaps (drop-down menus) do not have labels. ids and names are generated
# dynamically and therefore not reliable, i.e. this is an accessibility bug
# which need to be fixed at some stage. Meanwhile, I use the ids and increment
# them as appropriate (e.g.: q3_1_p1 become q4_1_p1, etc.).
# Set display and behaviour options
And I set the following fields to these values:
| How questions behave | Interactive with multiple tries |
| Marked out of | 3 |
| Marks | Show mark and max |
| Specific feedback | Shown |
| Right answer | Shown |
And I press "Start again with these options"
# Answer question correctly
And I set the following fields to these values:
| q3_1_p1 | cat |
| q3_1_p2 | sat |
| q3_1_p3 | mat |
And I press "Check"
Then I should see "Your answer is correct"
And I should see "The cat sat on the mat"
And I should see "The correct answer is: The [cat] [sat] on the [mat]."
And I press "Start again"
# Answer question partially correct twice and then correct
And I set the following fields to these values:
| q4_1_p1 | cat |
| q4_1_p2 | sat |
| q4_1_p3 | dog |
And I press "Check"
Then I should see "Your answer is partially correct"
And I should see "First hint"
When I press "Try again"
And I set the field "q4_1_p3" to "table"
And I press "Check"
Then I should see "Your answer is partially correct"
And I should see "Second hint"
When I press "Try again"
And I set the field "q4_1_p3" to "mat"
And I press "Check"
Then I should see "Your answer is correct"
And I should see "The cat sat on the mat"
And I should see "The correct answer is: The [cat] [sat] on the [mat]."
# Set behaviour options
And I set the following fields to these values:
| behaviour | immediatefeedback |
And I press "Start again with these options"
# Answer question correctly
When I press "Check"
Then I should see "Please put an answer in each box."
And I set the following fields to these values:
| q5_1_p1 | cat |
| q5_1_p2 | sat |
| q5_1_p3 | mat |
And I press "Check"
Then I should see "Your answer is correct"
And I should see "The cat sat on the mat"
And I should see "The correct answer is: The [cat] [sat] on the [mat]."
And I press "Start again"
# Answer question partially correct
And I set the following fields to these values:
| q6_1_p1 | dog |
| q6_1_p2 | sat |
| q6_1_p3 | cat |
And I press "Check"
Then I should see "Your answer is partially correct"
And I should see "You have correctly selected 1."
And I should see "The cat sat on the mat"
And I should see "The correct answer is: The [cat] [sat] on the [mat]."
And I press "Start again"
# Answer question incorrectly
And I set the following fields to these values:
| q7_1_p1 | mat |
| q7_1_p2 | cat |
| q7_1_p3 | sat |
And I press "Check"
Then I should see "Your answer is incorrect"
And I should see "The cat sat on the mat"
And I should see "The correct answer is: The [cat] [sat] on the [mat]."
And I switch to the main window
# Backup the course and restore it.
When I log out
And I log in as "admin"
When I backup "Course 1" course using this options:
| Confirmation | Filename | test_backup.mbz |
When I restore "test_backup.mbz" backup into a new course using this options:
| Schema | Course name | Course 2 |
Then I should see "Course 2"
When I navigate to "Question bank" node in "Course administration"
Then I should see "Select missing words 001"
# Edit the copy and verify the form field contents.
When I click on "Edit" "link" in the "Select missing words 001" "table_row"
Then the following fields match these values:
| Question name | Select missing words 001 |
| Question text | The [[1]] [[2]] on the [[3]]. |
| General feedback | The cat sat on the mat. |
| id_choices_0_answer | cat |
| id_choices_1_answer | sat |
| id_choices_2_answer | mat |
| id_choices_3_answer | dog |
| id_choices_4_answer | table |
| Hint 1 | First hint |
| Hint 2 | Second hint |
And I set the following fields to these values:
| Question name | Edited question name |
And I press "id_submitbutton"
Then I should see "Edited question name"
And I wait "10" seconds
@@ -0,0 +1,30 @@
@ou @ou_vle @qtype @qtype_gapselect
Feature: Test all the basic functionality of this question type
As a manager/teacher i should be able to import questions from other courses to this course
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | T1 | Teacher1 | teacher1@moodle.com |
| manager1 | M1 | Manager1 | manager11@moodle.com |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| manager1 | C1 | manager |
And I log in as "teacher1"
And I follow "Course 1"
@javascript
Scenario: import a variable numeric sets question.
# Import sample file.
When I navigate to "Import" node in "Course administration > Question bank"
And I set the field "id_format_xml" to "1"
And I upload "question/type/gapselect/tests/fixtures/testquestion.moodle.xml" file to "Import" filemanager
And I press "id_submitbutton"
Then I should see "Parsing questions from import file."
And I should see "Importing 1 questions from file"
And I should see "1. The [[1]] [[2]] on the [[3]]."
And I press "Continue"
And I should see "Imported Select missing words 001"
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>
<quiz>
<!-- question: 0 -->
<question type="category">
<category>
<text>$course$/Default for C1</text>
</category>
</question>
<!-- question: 1 -->
<question type="gapselect">
<name>
<text>Imported Select missing words 001</text>
</name>
<questiontext format="html">
<text>The [[1]] [[2]] on the [[3]].</text>
</questiontext>
<generalfeedback format="html">
<text>The cat sat on the mat.</text>
</generalfeedback>
<defaultgrade>1.0000000</defaultgrade>
<penalty>0.3333333</penalty>
<hidden>0</hidden>
<shuffleanswers>0</shuffleanswers>
<correctfeedback format="html">
<text>Your answer is correct.</text>
</correctfeedback>
<partiallycorrectfeedback format="html">
<text>Your answer is partially correct.</text>
</partiallycorrectfeedback>
<incorrectfeedback format="html">
<text>Your answer is incorrect.</text>
</incorrectfeedback>
<shownumcorrect/>
<selectoption>
<text>cat</text>
<group>1</group>
</selectoption>
<selectoption>
<text>sat</text>
<group>1</group>
</selectoption>
<selectoption>
<text>mat</text>
<group>1</group>
</selectoption>
<selectoption>
<text>dog</text>
<group>1</group>
</selectoption>
<selectoption>
<text>table</text>
<group>1</group>
</selectoption>
<hint format="html">
<text>First hint</text>
</hint>
<hint format="html">
<text>Second hint</text>
</hint>
</question>
</quiz>