MDL-52964 Qtype: Add behat tests to core question types

This commit is contained in:
M Kassaei 2016-02-02 10:50:16 +00:00
parent 2f45a11ac4
commit 50aaf13e01
42 changed files with 1845 additions and 0 deletions

View File

@ -0,0 +1,27 @@
@qtype @qtype_description
Feature: Test creating a Description question
As a teacher
In order to test my students
I need to be able to create a Description question
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 |
And I log in as "teacher1"
And I follow "Course 1"
And I navigate to "Question bank" node in "Course administration"
@javascript
Scenario: Create a Description question with Correct answer as False
When I add a "Description" question filling the form with:
| Question name | description-001 |
| Question text | Instructions about the following questions. |
| General feedback | Why actually the field 'General feedback' used in this qytype? |
Then I should see "description-001"

View File

@ -0,0 +1,37 @@
@qtype @qtype_description
Feature: Test duplicating a quiz containing a Description question
As a teacher
In order re-use my courses containing Description questions
I need to be able to backup and restore them
Background:
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "question categories" exist:
| contextlevel | reference | name |
| Course | C1 | Test questions |
And the following "questions" exist:
| questioncategory | qtype | name | template |
| Test questions | description | description-001 | info |
And the following "activities" exist:
| activity | name | course | idnumber |
| quiz | Test quiz | C1 | quiz1 |
And quiz "Test quiz" contains the following questions:
| description-001 | 1 |
And I log in as "admin"
And I am on site homepage
And I follow "Course 1"
@javascript
Scenario: Backup and restore a course containing a Description question
When I backup "Course 1" course using this options:
| Confirmation | Filename | test_backup.mbz |
And I restore "test_backup.mbz" backup into a new course using this options:
| Schema | Course name | Course 2 |
And I navigate to "Question bank" node in "Course administration"
And I click on "Edit" "link" in the "description-001" "table_row"
Then the following fields match these values:
| Question name | description-001 |
| Question text | Here is some information about the questions you are about to attempt. |
| General feedback | And here is some more text shown only on the review page. |

View File

@ -0,0 +1,37 @@
@qtype @qtype_description
Feature: Test editing a Description question
As a teacher
In order to be able to update my Description question
I need to edit them
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | T1 | Teacher1 | teacher1@example.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 |
And the following "question categories" exist:
| contextlevel | reference | name |
| Course | C1 | Test questions |
And the following "questions" exist:
| questioncategory | qtype | name | template |
| Test questions | description | description-001 | info |
And I log in as "teacher1"
And I follow "Course 1"
And I navigate to "Question bank" node in "Course administration"
@javascript
Scenario: Edit a Description question
When I click on "Edit" "link" in the "description-001" "table_row"
And I set the following fields to these values:
| Question name | |
And I press "id_submitbutton"
Then I should see "You must supply a value here."
When I set the following fields to these values:
| Question name | Edited description-001 name |
And I press "id_submitbutton"
Then I should see "Edited description-001 name"

View File

@ -0,0 +1,36 @@
@qtype @qtype_description
Feature: Test exporting Description questions
As a teacher
In order to be able to reuse my Description questions
I need to export them
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | T1 | Teacher1 | teacher1@example.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 |
And the following "question categories" exist:
| contextlevel | reference | name |
| Course | C1 | Test questions |
And the following "questions" exist:
| questioncategory | qtype | name | template |
| Test questions | description | description-001 | info |
And I log in as "teacher1"
And I follow "Course 1"
@javascript
Scenario: Export a Description question
When I navigate to "Export" node in "Course administration > Question bank"
And I set the field "id_format_xml" to "1"
And I press "Export questions to file"
Then following "click here" should download between "650" and "750" bytes
# If the download step is the last in the scenario then we can sometimes run
# into the situation where the download page causes a http redirect but behat
# has already conducted its reset (generating an error). By putting a logout
# step we avoid behat doing the reset until we are off that page.
And I log out

View File

@ -0,0 +1,30 @@
@qtype @qtype_description
Feature: Test importing Description questions
As a teacher
In order to reuse Description questions
I need to import them
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | T1 | Teacher1 | teacher1@example.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 |
And I log in as "teacher1"
And I follow "Course 1"
@javascript @_file_upload
Scenario: import a Description question.
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/description/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 "Instructions about the following questions."
And I press "Continue"
And I should see "description-001"

View File

@ -0,0 +1,34 @@
@qtype @qtype_description
Feature: Preview a Description question
As a teacher
In order to check my Description questions will work for students
I need to preview them
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 |
And the following "question categories" exist:
| contextlevel | reference | name |
| Course | C1 | Test questions |
And the following "questions" exist:
| questioncategory | qtype | name | template |
| Test questions | description | description-001 | info |
Given I log in as "teacher1"
And I follow "Course 1"
And I navigate to "Question bank" node in "Course administration"
@javascript
Scenario: Preview a question and submit a correct response.
When I click on "Preview" "link" in the "description-001" "table_row"
And I switch to "questionpreview" window
And I set the field "How questions behave" to "Immediate feedback"
And I press "Start again with these options"
And I should see "Here is some information about the questions you are about to attempt."
And I switch to the main window

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<quiz>
<!-- question: 0 -->
<question type="category">
<category>
<text>$course$/Default for C1</text>
</category>
</question>
<!-- question: 115000 -->
<question type="description">
<name>
<text>description-001</text>
</name>
<questiontext format="html">
<text>Instructions about the following questions.</text>
</questiontext>
<generalfeedback format="html">
<text>Why actually the field 'General feedback' used in this qytype?</text>
</generalfeedback>
<defaultgrade>0.0000000</defaultgrade>
<penalty>0.0000000</penalty>
<hidden>0</hidden>
</question>
</quiz>

View File

@ -0,0 +1,37 @@
@qtype @qtype_essay
Feature: Test creating an Essay question
As a teacher
In order to test my students
I need to be able to create an Essay question
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 |
And I log in as "teacher1"
And I follow "Course 1"
And I navigate to "Question bank" node in "Course administration"
@javascript
Scenario: Create an Essay question with Response format set to 'HTML editor'
When I add a "Essay" question filling the form with:
| Question name | essay-001 |
| Question text | Write an essay with 500 words. |
| General feedback | This is general feedback |
| Response format | HTML editor |
Then I should see "essay-001"
@javascript
Scenario: Create an Essay question with Response format set to 'HTML editor with the file picker'
When I add a "Essay" question filling the form with:
| Question name | essay-002 |
| Question text | Write an essay with 500 words. |
| General feedback | This is general feedback |
| Response format | HTML editor |
Then I should see "essay-002"

View File

@ -0,0 +1,62 @@
@qtype @qtype_essay
Feature: Test duplicating a quiz containing an Assay question
As a teacher
In order re-use my courses containing Essay questions
I need to be able to backup and restore them
Background:
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "question categories" exist:
| contextlevel | reference | name |
| Course | C1 | Test questions |
And the following "questions" exist:
| questioncategory | qtype | name | template |
| Test questions | essay | essay-001 | editor |
| Test questions | essay | essay-002 | editorfilepicker |
| Test questions | essay | essay-003 | plain |
And the following "activities" exist:
| activity | name | course | idnumber |
| quiz | Test quiz | C1 | quiz1 |
And quiz "Test quiz" contains the following questions:
| essay-001 | 1 |
| essay-002 | 1 |
| essay-003 | 1 |
And I log in as "admin"
And I am on site homepage
And I follow "Course 1"
@javascript
Scenario: Backup and restore a course containing 3 Essay questions
When I backup "Course 1" course using this options:
| Confirmation | Filename | test_backup.mbz |
And I restore "test_backup.mbz" backup into a new course using this options:
| Schema | Course name | Course 2 |
And I navigate to "Question bank" node in "Course administration"
And I should see "essay-001"
And I should see "essay-002"
And I should see "essay-003"
And I click on "Edit" "link" in the "essay-001" "table_row"
Then the following fields match these values:
| Question name | essay-001 |
| Question text | Please write a story about a frog. |
| General feedback | I hope your story had a beginning, a middle and an end. |
| Response format | HTML editor |
| Require text | Require the student to enter text |
And I press "Cancel"
And I click on "Edit" "link" in the "essay-002" "table_row"
Then the following fields match these values:
| Question name | essay-002 |
| Question text | Please write a story about a frog. |
| General feedback | I hope your story had a beginning, a middle and an end. |
| Response format | HTML editor with file picker |
| Require text | Require the student to enter text |
And I press "Cancel"
And I click on "Edit" "link" in the "essay-003" "table_row"
Then the following fields match these values:
| Question name | essay-003 |
| Question text | Please write a story about a frog. |
| General feedback | I hope your story had a beginning, a middle and an end. |
| Response format | Plain text |
| Require text | Require the student to enter text |

View File

@ -0,0 +1,44 @@
@qtype @qtype_essay
Feature: Test editing an Essay question
As a teacher
In order to be able to update my Essay question
I need to edit them
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | T1 | Teacher1 | teacher1@example.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 |
And the following "question categories" exist:
| contextlevel | reference | name |
| Course | C1 | Test questions |
And the following "questions" exist:
| questioncategory | qtype | name | template |
| Test questions | essay | essay-001 | editor |
| Test questions | essay | essay-002 | editorfilepicker |
| Test questions | essay | essay-003 | plain |
And I log in as "teacher1"
And I follow "Course 1"
And I navigate to "Question bank" node in "Course administration"
@javascript
Scenario: Edit an Essay question
When I click on "Edit" "link" in the "essay-001" "table_row"
And I set the following fields to these values:
| Question name | |
And I press "id_submitbutton"
Then I should see "You must supply a value here."
When I set the following fields to these values:
| Question name | Edited essay-001 name |
| Response format | No inline text |
And I press "id_submitbutton"
Then I should see "When \"no inline text\" is selected, or responses are optional, you must allow at least one attachment."
When I set the following fields to these values:
| Response format | Plain text |
And I press "id_submitbutton"
Then I should see "Edited essay-001 name"

View File

@ -0,0 +1,38 @@
@qtype @qtype_essay
Feature: Test exporting Essay questions
As a teacher
In order to be able to reuse my Essay questions
I need to export them
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | T1 | Teacher1 | teacher1@example.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 |
And the following "question categories" exist:
| contextlevel | reference | name |
| Course | C1 | Test questions |
And the following "questions" exist:
| questioncategory | qtype | name | template |
| Test questions | essay | essay-001 | editor |
| Test questions | essay | essay-002 | editorfilepicker |
| Test questions | essay | essay-003 | plain |
And I log in as "teacher1"
And I follow "Course 1"
@javascript
Scenario: Export 3 Essay questions
When I navigate to "Export" node in "Course administration > Question bank"
And I set the field "id_format_xml" to "1"
And I press "Export questions to file"
Then following "click here" should download between "2600" and "2700" bytes
# If the download step is the last in the scenario then we can sometimes run
# into the situation where the download page causes a http redirect but behat
# has already conducted its reset (generating an error). By putting a logout
# step we avoid behat doing the reset until we are off that page.
And I log out

View File

@ -0,0 +1,30 @@
@qtype @qtype_essay
Feature: Test importing Essay questions
As a teacher
In order to reuse Essay questions
I need to import them
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | T1 | Teacher1 | teacher1@example.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 |
And I log in as "teacher1"
And I follow "Course 1"
@javascript @_file_upload
Scenario: import Essay question.
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/essay/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 "Write an essay with 500 words."
And I press "Continue"
And I should see "essay-001"

View File

@ -0,0 +1,55 @@
@qtype @qtype_essay
Feature: Preview Essay questions
As a teacher
In order to check my Essay questions will work for students
I need to preview them
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 |
And the following "question categories" exist:
| contextlevel | reference | name |
| Course | C1 | Test questions |
And the following "questions" exist:
| questioncategory | qtype | name | template |
| Test questions | essay | essay-001 | editor |
| Test questions | essay | essay-002 | editorfilepicker |
| Test questions | essay | essay-003 | plain |
Given I log in as "teacher1"
And I follow "Course 1"
And I navigate to "Question bank" node in "Course administration"
@javascript
Scenario: Preview a question and submit a partially correct response.
When I click on "Preview" "link" in the "essay-001" "table_row"
And I switch to "questionpreview" window
And I set the field "How questions behave" to "Immediate feedback"
And I press "Start again with these options"
And I should see "Please write a story about a frog."
And I switch to the main window
@javascript
Scenario: Preview a question and submit a partially correct response.
When I click on "Preview" "link" in the "essay-002" "table_row"
And I switch to "questionpreview" window
And I set the field "How questions behave" to "Immediate feedback"
And I press "Start again with these options"
And I should see "Please write a story about a frog."
And I should see "You can drag and drop files here to add them."
And I switch to the main window
@javascript
Scenario: Preview a question and submit a partially correct response.
When I click on "Preview" "link" in the "essay-003" "table_row"
And I switch to "questionpreview" window
And I set the field "How questions behave" to "Immediate feedback"
And I press "Start again with these options"
And I should see "Please write a story about a frog."
And I switch to the main window

View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<quiz>
<!-- question: 0 -->
<question type="category">
<category>
<text>$course$/Default for C1</text>
</category>
</question>
<!-- question: 114000 -->
<question type="essay">
<name>
<text>essay-001</text>
</name>
<questiontext format="html">
<text>Write an essay with 500 words.</text>
</questiontext>
<generalfeedback format="html">
<text>This is general feedback</text>
</generalfeedback>
<defaultgrade>1.0000000</defaultgrade>
<penalty>0.0000000</penalty>
<hidden>0</hidden>
<responseformat>editor</responseformat>
<responserequired>1</responserequired>
<responsefieldlines>15</responsefieldlines>
<attachments>0</attachments>
<attachmentsrequired>0</attachmentsrequired>
<graderinfo format="html">
<text></text>
</graderinfo>
<responsetemplate format="html">
<text></text>
</responsetemplate>
</question>
</quiz>

View File

@ -0,0 +1,38 @@
@qtype @qtype_match
Feature: Test creating a Matching question
As a teacher
In order to test my students
I need to be able to create a Matching question
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 |
And I log in as "teacher1"
And I follow "Course 1"
And I navigate to "Question bank" node in "Course administration"
@javascript
Scenario: Create a Matching question with 3 subquestions
When I add a "Matching" question filling the form with:
| Question name | match-001 |
| Question text | Match the country with the capital city. |
| General feedback | England=London, France=Paris and Spain=Madrid. |
| id_subquestions_0 | England |
| id_subanswers_0 | London |
| id_subquestions_1 | France |
| id_subanswers_1 | Paris |
| id_subquestions_2 | Spain |
| id_subanswers_2 | Madrid |
| For any correct response | Your answer is correct |
| For any partially correct response | Your answer is partially correct |
| For any incorrect response | Your answer is incorrect |
| Hint 1 | This is your first hint |
| Hint 2 | This is your second hint |
Then I should see "match-001"

View File

@ -0,0 +1,47 @@
@qtype @qtype_match
Feature: Test duplicating a quiz containing a Matching question
As a teacher
In order re-use my courses containing Matching questions
I need to be able to backup and restore them
Background:
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "question categories" exist:
| contextlevel | reference | name |
| Course | C1 | Test questions |
And the following "questions" exist:
| questioncategory | qtype | name | template |
| Test questions | match | matching-001 | foursubq |
And the following "activities" exist:
| activity | name | course | idnumber |
| quiz | Test quiz | C1 | quiz1 |
And quiz "Test quiz" contains the following questions:
| matching-001 | 1 |
And I log in as "admin"
And I am on site homepage
And I follow "Course 1"
@javascript
Scenario: Backup and restore a course containing a Matching question
When I backup "Course 1" course using this options:
| Confirmation | Filename | test_backup.mbz |
And I restore "test_backup.mbz" backup into a new course using this options:
| Schema | Course name | Course 2 |
And I navigate to "Question bank" node in "Course administration"
And I click on "Edit" "link" in the "matching-001" "table_row"
Then the following fields match these values:
| Question name | matching-001 |
| Question text | Classify the animals. |
| General feedback | General feedback. |
| Default mark | 1 |
| Shuffle | 1 |
| Question 1 | frog |
| Question 2 | cat |
| Question 3 | newt |
| Question 4 | |
| id_subanswers_0 | amphibian |
| id_subanswers_1 | mammal |
| id_subanswers_2 | amphibian |
| id_subanswers_3 | insect |

View File

@ -0,0 +1,50 @@
@qtype @qtype_match
Feature: Test editing a Matching question
As a teacher
In order to be able to update my Matching question
I need to edit them
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | T1 | Teacher1 | teacher1@example.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 |
And the following "question categories" exist:
| contextlevel | reference | name |
| Course | C1 | Test questions |
And the following "questions" exist:
| questioncategory | qtype | name | template |
| Test questions | match | Matching for editing | foursubq |
And I log in as "teacher1"
And I follow "Course 1"
And I navigate to "Question bank" node in "Course administration"
@javascript
Scenario: Edit a Matching question
When I click on "Edit" "link" in the "Matching for editing" "table_row"
And I set the following fields to these values:
| Question name | |
And I press "id_submitbutton"
Then I should see "You must supply a value here."
When I set the following fields to these values:
| Question name | Edited Matching name |
And I press "id_submitbutton"
Then I should see "Edited Matching name"
When I click on "Edit" "link" in the "Edited Matching name" "table_row"
And I set the following fields to these values:
| Shuffle | 0 |
| Question 2 | dog |
| Question 4 | fly |
And I press "id_submitbutton"
Then I should see "Edited Matching name"
When I click on "Preview" "link" in the "Edited Matching name" "table_row"
And I switch to "questionpreview" window
Then I should see "frog"
And I should see "dog"
And I should see "newt"
And I should see "fly"

View File

@ -0,0 +1,36 @@
@qtype @qtype_match
Feature: Test exporting Matching questions
As a teacher
In order to be able to reuse my Matching questions
I need to export them
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | T1 | Teacher1 | teacher1@example.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 |
And the following "question categories" exist:
| contextlevel | reference | name |
| Course | C1 | Test questions |
And the following "questions" exist:
| questioncategory | qtype | name | template |
| Test questions | match | matching-001 | foursubq |
And I log in as "teacher1"
And I follow "Course 1"
@javascript
Scenario: Export a Matching question
When I navigate to "Export" node in "Course administration > Question bank"
And I set the field "id_format_xml" to "1"
And I press "Export questions to file"
Then following "click here" should download between "1500" and "1600" bytes
# If the download step is the last in the scenario then we can sometimes run
# into the situation where the download page causes a http redirect but behat
# has already conducted its reset (generating an error). By putting a logout
# step we avoid behat doing the reset until we are off that page.
And I log out

View File

@ -0,0 +1,30 @@
@qtype @qtype_match
Feature: Test importing Matching questions
As a teacher
In order to reuse Matching questions
I need to import them
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | T1 | Teacher1 | teacher1@example.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 |
And I log in as "teacher1"
And I follow "Course 1"
@javascript @_file_upload
Scenario: import Matching question.
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/match/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. Classify the animals."
And I press "Continue"
And I should see "matching-001"

View File

@ -0,0 +1,79 @@
@qtype @qtype_match
Feature: Preview a Matching question
As a teacher
In order to check my Matching questions will work for students
I need to preview them
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 |
And the following "question categories" exist:
| contextlevel | reference | name |
| Course | C1 | Test questions |
And the following "questions" exist:
| questioncategory | qtype | name | template |
| Test questions | match | matching-001 | foursubq |
Given I log in as "teacher1"
And I follow "Course 1"
And I navigate to "Question bank" node in "Course administration"
@javascript
Scenario: Preview a question and submit a correct response.
When I click on "Edit" "link" in the "matching-001" "table_row"
And I set the following fields to these values:
| Shuffle | 0 |
And I press "id_submitbutton"
When I click on "Preview" "link" in the "matching-001" "table_row"
And I switch to "questionpreview" window
And I set the field "How questions behave" to "Immediate feedback"
And I press "Start again with these options"
And I set the field with xpath "//table[@class='answer']//td[@class='control']//select[contains(@id, '1_sub0')]" to "amphibian"
And I set the field with xpath "//table[@class='answer']//td[@class='control']//select[contains(@id, '1_sub1')]" to "mammal"
And I set the field with xpath "//table[@class='answer']//td[@class='control']//select[contains(@id, '1_sub2')]" to "amphibian"
And I press "Check"
Then I should see "Well done!"
And I should see "General feedback."
And I switch to the main window
@javascript
Scenario: Preview a question and submit a partially correct response.
When I click on "Edit" "link" in the "matching-001" "table_row"
And I set the following fields to these values:
| Shuffle | 0 |
And I press "id_submitbutton"
When I click on "Preview" "link" in the "matching-001" "table_row"
And I switch to "questionpreview" window
And I set the field "How questions behave" to "Immediate feedback"
And I press "Start again with these options"
And I set the field with xpath "//table[@class='answer']//td[@class='control']//select[contains(@id, '1_sub0')]" to "amphibian"
And I set the field with xpath "//table[@class='answer']//td[@class='control']//select[contains(@id, '1_sub1')]" to "insect"
And I set the field with xpath "//table[@class='answer']//td[@class='control']//select[contains(@id, '1_sub2')]" to "amphibian"
And I press "Check"
Then I should see "Parts, but only parts, of your response are correct."
And I should see "General feedback."
And I switch to the main window
@javascript
Scenario: Preview a question and submit an incorrect response.
When I click on "Edit" "link" in the "matching-001" "table_row"
And I set the following fields to these values:
| Shuffle | 0 |
And I press "id_submitbutton"
When I click on "Preview" "link" in the "matching-001" "table_row"
And I switch to "questionpreview" window
And I set the field "How questions behave" to "Immediate feedback"
And I press "Start again with these options"
And I set the field with xpath "//table[@class='answer']//td[@class='control']//select[contains(@id, '1_sub0')]" to "mammal"
And I set the field with xpath "//table[@class='answer']//td[@class='control']//select[contains(@id, '1_sub1')]" to "insect"
And I set the field with xpath "//table[@class='answer']//td[@class='control']//select[contains(@id, '1_sub2')]" to "insect"
And I press "Check"
Then I should see "That is not right at all."
And I should see "General feedback."
And I switch to the main window

View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<quiz>
<!-- question: 0 -->
<question type="category">
<category>
<text>$course$/Test questions</text>
</category>
</question>
<!-- question: 114000 -->
<question type="matching">
<name>
<text>matching-001</text>
</name>
<questiontext format="html">
<text>Classify the animals.</text>
</questiontext>
<generalfeedback format="html">
<text>General feedback.</text>
</generalfeedback>
<defaultgrade>1.0000000</defaultgrade>
<penalty>0.3333333</penalty>
<hidden>0</hidden>
<shuffleanswers>true</shuffleanswers>
<correctfeedback format="html">
<text>Well done!</text>
</correctfeedback>
<partiallycorrectfeedback format="html">
<text>Parts, but only parts, of your response are correct.</text>
</partiallycorrectfeedback>
<incorrectfeedback format="html">
<text>That is not right at all.</text>
</incorrectfeedback>
<shownumcorrect/>
<subquestion format="html">
<text>frog</text>
<answer>
<text>amphibian</text>
</answer>
</subquestion>
<subquestion format="html">
<text>cat</text>
<answer>
<text>mammal</text>
</answer>
</subquestion>
<subquestion format="html">
<text>newt</text>
<answer>
<text>amphibian</text>
</answer>
</subquestion>
<subquestion format="html">
<text></text>
<answer>
<text>insect</text>
</answer>
</subquestion>
</question>
</quiz>

View File

@ -0,0 +1,61 @@
@qtype @qtype_multichoice
Feature: Test creating a Multiple choice question
As a teacher
In order to test my students
I need to be able to create a Multiple choice question
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 |
And I log in as "teacher1"
And I follow "Course 1"
And I navigate to "Question bank" node in "Course administration"
@javascript
Scenario: Create a Multiple choice question with multiple response
When I add a "Multiple choice" question filling the form with:
| Question name | Multi-choice-001 |
| Question text | Find the capital cities in Europe. |
| General feedback | Paris and London |
| One or multiple answers? | Multiple answers allowed |
| Choice 1 | Tokyo |
| Choice 2 | Spain |
| Choice 3 | London |
| Choice 4 | Barcelona |
| Choice 5 | Paris |
| id_fraction_0 | None |
| id_fraction_1 | None |
| id_fraction_2 | 50% |
| id_fraction_3 | None |
| id_fraction_4 | 50% |
| Hint 1 | First hint |
| Hint 2 | Second hint |
Then I should see "Multi-choice-001"
@javascript
Scenario: Create a Multiple choice question with single response
When I add a "Multiple choice" question filling the form with:
| Question name | Multi-choice-002 |
| Question text | Find the capital city of England. |
| General feedback | London is the capital city of England. |
| One or multiple answers? | One answer only |
| Choice 1 | Manchester |
| Choice 2 | Buckingham |
| Choice 3 | London |
| Choice 4 | Barcelona |
| Choice 5 | Paris |
| id_fraction_0 | None |
| id_fraction_1 | None |
| id_fraction_2 | 100% |
| id_fraction_3 | None |
| id_fraction_4 | None |
| Hint 1 | First hint |
| Hint 2 | Second hint |
Then I should see "Multi-choice-002"

View File

@ -0,0 +1,51 @@
@qtype @qtype_multichoice
Feature: Test duplicating a quiz containing a Multiple choice question
As a teacher
In order re-use my courses containing Multiple choice questions
I need to be able to backup and restore them
Background:
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "question categories" exist:
| contextlevel | reference | name |
| Course | C1 | Test questions |
And the following "questions" exist:
| questioncategory | qtype | name | template |
| Test questions | multichoice | Multi-choice-001 | two_of_four |
And the following "activities" exist:
| activity | name | course | idnumber |
| quiz | Test quiz | C1 | quiz1 |
And quiz "Test quiz" contains the following questions:
| Multi-choice-001 | 1 |
And I log in as "admin"
And I am on site homepage
And I follow "Course 1"
@javascript
Scenario: Backup and restore a course containing a Multiple choice question
When I backup "Course 1" course using this options:
| Confirmation | Filename | test_backup.mbz |
And I restore "test_backup.mbz" backup into a new course using this options:
| Schema | Course name | Course 2 |
And I navigate to "Question bank" node in "Course administration"
And I click on "Edit" "link" in the "Multi-choice-001" "table_row"
Then the following fields match these values:
| Question name | Multi-choice-001 |
| Question text | Which are the odd numbers? |
| General feedback | The odd numbers are One and Three. |
| Default mark | 1 |
| One or multiple answers? | Multiple answers allowed |
| Shuffle the choices? | 1 |
| Choice 1 | One |
| Choice 2 | Two |
| Choice 3 | Three |
| Choice 4 | Four |
| id_fraction_0 | 50% |
| id_fraction_1 | None |
| id_fraction_2 | 50% |
| id_fraction_3 | None |
| For any correct response | Well done! |
| For any partially correct response | Parts, but only parts, of your response are correct. |
| For any incorrect response | That is not right at all. |

View File

@ -0,0 +1,46 @@
@qtype @qtype_multichoice
Feature: Test editing a Multiple choice question
As a teacher
In order to be able to update my Multiple choice question
I need to edit them
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | T1 | Teacher1 | teacher1@example.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 |
And the following "question categories" exist:
| contextlevel | reference | name |
| Course | C1 | Test questions |
And the following "questions" exist:
| questioncategory | qtype | name | template |
| Test questions | multichoice | Multiple choice for editing | two_of_four |
| Test questions | multichoice | Single choice for editing | one_of_four |
And I log in as "teacher1"
And I follow "Course 1"
And I navigate to "Question bank" node in "Course administration"
@javascript
Scenario: Edit a Multiple choice question with multiple response (checkboxes)
When I click on "Edit" "link" in the "Multiple choice for editing" "table_row"
And I set the following fields to these values:
| Question name | |
And I press "id_submitbutton"
Then I should see "You must supply a value here."
When I set the following fields to these values:
| Question name | Edited Multiple choice name |
And I press "id_submitbutton"
Then I should see "Edited Multiple choice name"
@javascript
Scenario: Edit a Multiple choice question with single response (radio buttons)
When I click on "Edit" "link" in the "Single choice for editing" "table_row"
And I set the following fields to these values:
| Question name | Edited Single choice name |
And I press "id_submitbutton"
Then I should see "Edited Single choice name"

View File

@ -0,0 +1,37 @@
@qtype @qtype_multichoice
Feature: Test exporting Multiple choice questions
As a teacher
In order to be able to reuse my Multiple choice questions
I need to export them
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | T1 | Teacher1 | teacher1@example.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 |
And the following "question categories" exist:
| contextlevel | reference | name |
| Course | C1 | Test questions |
And the following "questions" exist:
| questioncategory | qtype | name | template |
| Test questions | multichoice | Multi-choice-001 | two_of_four |
| Test questions | multichoice | Multi-choice-002 | one_of_four |
And I log in as "teacher1"
And I follow "Course 1"
@javascript
Scenario: Export a Multiple choice question
When I navigate to "Export" node in "Course administration > Question bank"
And I set the field "id_format_xml" to "1"
And I press "Export questions to file"
Then following "click here" should download between "3750" and "3800" bytes
# If the download step is the last in the scenario then we can sometimes run
# into the situation where the download page causes a http redirect but behat
# has already conducted its reset (generating an error). By putting a logout
# step we avoid behat doing the reset until we are off that page.
And I log out

View File

@ -0,0 +1,30 @@
@qtype @qtype_multichoice
Feature: Test importing Multiple choice questions
As a teacher
In order to reuse Multiple choice questions
I need to import them
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | T1 | Teacher1 | teacher1@example.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 |
And I log in as "teacher1"
And I follow "Course 1"
@javascript @_file_upload
Scenario: import Multiple choice question.
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/multichoice/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. Find the capital cities in Europe."
And I press "Continue"
And I should see "Multi-choice-001"

View File

@ -0,0 +1,72 @@
@qtype @qtype_multichoice
Feature: Preview a Multiple choice question
As a teacher
In order to check my Multiple choice questions will work for students
I need to preview them
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 |
And the following "question categories" exist:
| contextlevel | reference | name |
| Course | C1 | Test questions |
And the following "questions" exist:
| questioncategory | qtype | name | template |
| Test questions | multichoice | Multi-choice-001 | two_of_four |
| Test questions | multichoice | Multi-choice-002 | one_of_four |
Given I log in as "teacher1"
And I follow "Course 1"
And I navigate to "Question bank" node in "Course administration"
@javascript
Scenario: Preview a question and submit a partially correct response.
When I click on "Preview" "link" in the "Multi-choice-001" "table_row"
And I switch to "questionpreview" window
And I set the field "How questions behave" to "Immediate feedback"
And I press "Start again with these options"
And I click on "One" "checkbox"
And I click on "Two" "checkbox"
And I press "Check"
Then I should see "One is odd"
And I should see "Two is even"
And I should see "Mark 0.50 out of 1.00"
And I should see "Parts, but only parts, of your response are correct."
And I switch to the main window
@javascript
Scenario: Preview a question and submit a correct response.
When I click on "Preview" "link" in the "Multi-choice-001" "table_row"
And I switch to "questionpreview" window
And I set the field "How questions behave" to "Immediate feedback"
And I press "Start again with these options"
And I click on "One" "checkbox"
And I click on "Three" "checkbox"
And I press "Check"
Then I should see "One is odd"
And I should see "Three is odd"
And I should see "Mark 1.00 out of 1.00"
And I should see "Well done!"
And I should see "The odd numbers are One and Three."
And I should see "The correct answer is: One, Three"
And I switch to the main window
@javascript
Scenario: Preview a question and submit a correct response.
When I click on "Preview" "link" in the "Multi-choice-002" "table_row"
And I switch to "questionpreview" window
And I set the field "How questions behave" to "Immediate feedback"
And I press "Start again with these options"
And I click on "One" "radio"
And I press "Check"
Then I should see "The oddest number is One."
And I should see "Mark 1.00 out of 1.00"
And I should see "Well done!"
And I should see "The correct answer is: One"
And I switch to the main window

View File

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<quiz>
<!-- question: 0 -->
<question type="category">
<category>
<text>$course$/Default for C1</text>
</category>
</question>
<!-- question: 115000 -->
<question type="multichoice">
<name>
<text>Multi-choice-001</text>
</name>
<questiontext format="html">
<text>Find the capital cities in Europe.</text>
</questiontext>
<generalfeedback format="html">
<text>Berlin, Paris and London</text>
</generalfeedback>
<defaultgrade>1.0000000</defaultgrade>
<penalty>0.3333333</penalty>
<hidden>0</hidden>
<single>false</single>
<shuffleanswers>true</shuffleanswers>
<answernumbering>abc</answernumbering>
<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/>
<answer fraction="0" format="html">
<text>Tokyo</text>
<feedback format="html">
<text></text>
</feedback>
</answer>
<answer fraction="0" format="html">
<text>Spain</text>
<feedback format="html">
<text></text>
</feedback>
</answer>
<answer fraction="50" format="html">
<text>London</text>
<feedback format="html">
<text></text>
</feedback>
</answer>
<answer fraction="0" format="html">
<text>Barcelona</text>
<feedback format="html">
<text></text>
</feedback>
</answer>
<answer fraction="50" format="html">
<text>Paris</text>
<feedback format="html">
<text></text>
</feedback>
</answer>
<hint format="html">
<text>First hint</text>
</hint>
<hint format="html">
<text>Second hint</text>
</hint>
</question>
</quiz>

View File

@ -0,0 +1,35 @@
@qtype @qtype_shortanswer
Feature: Test creating a Short answer question
As a teacher
In order to test my students
I need to be able to create a Short answer question
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 |
And I log in as "teacher1"
And I follow "Course 1"
And I navigate to "Question bank" node in "Course administration"
@javascript
Scenario: Create a Short answer question
When I add a "Short answer" question filling the form with:
| Question name | shortanswer-001 |
| Question text | What is the national langauge in France? |
| General feedback | The national langauge in France is French |
| Default mark | 1 |
| Case sensitivity | No, case is unimportant |
| id_answer_0 | French |
| id_fraction_0 | 100% |
| id_feedback_0 | Well done. French is correct. |
| id_answer_1 | * |
| id_fraction_1 | None |
| id_feedback_1 | Your answer is incorrect. |
Then I should see "shortanswer-001"

View File

@ -0,0 +1,48 @@
@qtype @qtype_short asnswer
Feature: Test duplicating a quiz containing a Short answer question
As a teacher
In order re-use my courses containing Short answer questions
I need to be able to backup and restore them
Background:
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "question categories" exist:
| contextlevel | reference | name |
| Course | C1 | Test questions |
And the following "questions" exist:
| questioncategory | qtype | name | template |
| Test questions | shortanswer | shortanswer-001 | frogtoad |
And the following "activities" exist:
| activity | name | course | idnumber |
| quiz | Test quiz | C1 | quiz1 |
And quiz "Test quiz" contains the following questions:
| shortanswer-001 | 1 |
And I log in as "admin"
And I am on site homepage
And I follow "Course 1"
@javascript
Scenario: Backup and restore a course containing a Short answer question
When I backup "Course 1" course using this options:
| Confirmation | Filename | test_backup.mbz |
And I restore "test_backup.mbz" backup into a new course using this options:
| Schema | Course name | Course 2 |
And I navigate to "Question bank" node in "Course administration"
And I click on "Edit" "link" in the "shortanswer-001" "table_row"
Then the following fields match these values:
| Question name | shortanswer-001 |
| Question text | Name an amphibian: __________ |
| General feedback | Generalfeedback: frog or toad would have been OK. |
| Default mark | 1 |
| Case sensitivity | No, case is unimportant |
| id_answer_0 | frog |
| id_fraction_0 | 100% |
| id_feedback_0 | Frog is a very good answer. |
| id_answer_1 | toad |
| id_fraction_1 | 80% |
| id_feedback_1 | Toad is an OK good answer. |
| id_answer_2 | * |
| id_fraction_2 | None |
| id_feedback_2 | That is a bad answer. |

View File

@ -0,0 +1,56 @@
@qtype @qtype_shortanswer
Feature: Test editing a Short answer question
As a teacher
In order to be able to update my Short answer question
I need to edit them
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | T1 | Teacher1 | teacher1@example.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 |
And the following "question categories" exist:
| contextlevel | reference | name |
| Course | C1 | Test questions |
And the following "questions" exist:
| questioncategory | qtype | name | template |
| Test questions | shortanswer | shortanswer-001 for editing | frogtoad |
And I log in as "teacher1"
And I follow "Course 1"
And I navigate to "Question bank" node in "Course administration"
@javascript
Scenario: Edit a Short answer question
When I click on "Edit" "link" in the "shortanswer-001 for editing" "table_row"
And I set the following fields to these values:
| Question name | |
And I press "id_submitbutton"
Then I should see "You must supply a value here."
When I set the following fields to these values:
| Question name | Edited shortanswer-001 name |
And I press "id_submitbutton"
Then I should see "Edited shortanswer-001 name"
When I click on "Edit" "link" in the "Edited shortanswer-001 name" "table_row"
And I set the following fields to these values:
| id_answer_1 | newt |
| id_fraction_1 | 70% |
| id_feedback_1 | Newt is an OK good answer. |
And I press "id_submitbutton"
Then I should see "Edited shortanswer-001 name"
When I click on "Preview" "link" in the "Edited shortanswer-001 name" "table_row"
And I switch to "questionpreview" window
Then I should see "Name an amphibian:"
# Set behaviour options
And I set the following fields to these values:
| behaviour | immediatefeedback |
And I press "Start again with these options"
And I set the field with xpath "//div[@class='qtext']//input[contains(@id, '1_answer')]" to "newt"
And I press "Check"
Then I should see "Newt is an OK good answer."
And I should see "Generalfeedback: frog or toad would have been OK."
And I should see "The correct answer is: frog"

View File

@ -0,0 +1,36 @@
@qtype @qtype_shortanswer
Feature: Test exporting Short answer questions
As a teacher
In order to be able to reuse my Short answer questions
I need to export them
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | T1 | Teacher1 | teacher1@example.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 |
And the following "question categories" exist:
| contextlevel | reference | name |
| Course | C1 | Test questions |
And the following "questions" exist:
| questioncategory | qtype | name | template |
| Test questions | shortanswer | shortanswer-001 | frogtoad |
And I log in as "teacher1"
And I follow "Course 1"
@javascript
Scenario: Export a Short answer question
When I navigate to "Export" node in "Course administration > Question bank"
And I set the field "id_format_xml" to "1"
And I press "Export questions to file"
Then following "click here" should download between "1200" and "1300" bytes
# If the download step is the last in the scenario then we can sometimes run
# into the situation where the download page causes a http redirect but behat
# has already conducted its reset (generating an error). By putting a logout
# step we avoid behat doing the reset until we are off that page.
And I log out

View File

@ -0,0 +1,30 @@
@qtype @qtype_shortanswer
Feature: Test importing Short answer questions
As a teacher
In order to reuse Short answer questions
I need to import them
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | T1 | Teacher1 | teacher1@example.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 |
And I log in as "teacher1"
And I follow "Course 1"
@javascript @_file_upload
Scenario: import Matching question.
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/shortanswer/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. Name an amphibian: __________"
And I press "Continue"
And I should see "shortanswer-001"

View File

@ -0,0 +1,71 @@
@qtype @qtype_shortanswer
Feature: Preview a Short answer question
As a teacher
In order to check my Short answer questions will work for students
I need to preview them
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 |
And the following "question categories" exist:
| contextlevel | reference | name |
| Course | C1 | Test questions |
And the following "questions" exist:
| questioncategory | qtype | name | template |
| Test questions | shortanswer | shortanswer-001 | frogtoad |
Given I log in as "teacher1"
And I follow "Course 1"
And I navigate to "Question bank" node in "Course administration"
@javascript
Scenario: Preview a Short answer question with correct answer
When I click on "Preview" "link" in the "shortanswer-001" "table_row"
And I switch to "questionpreview" window
Then I should see "Name an amphibian:"
# Set behaviour options
And I set the following fields to these values:
| behaviour | immediatefeedback |
And I press "Start again with these options"
And I set the field with xpath "//div[@class='qtext']//input[contains(@id, '1_answer')]" to "frog"
And I press "Check"
Then I should see "Frog is a very good answer."
And I should see "Generalfeedback: frog or toad would have been OK."
And I should see "The correct answer is: frog"
@javascript
Scenario: Preview a Short answer question with almost correct answer
When I click on "Preview" "link" in the "shortanswer-001" "table_row"
And I switch to "questionpreview" window
Then I should see "Name an amphibian:"
# Set behaviour options
And I set the following fields to these values:
| behaviour | immediatefeedback |
And I press "Start again with these options"
And I set the field with xpath "//div[@class='qtext']//input[contains(@id, '1_answer')]" to "toad"
And I press "Check"
Then I should see "Toad is an OK good answer."
And I should see "Generalfeedback: frog or toad would have been OK."
And I should see "The correct answer is: frog"
@javascript
Scenario: Preview a Short answer question with incorrect answer
When I click on "Preview" "link" in the "shortanswer-001" "table_row"
And I switch to "questionpreview" window
Then I should see "Name an amphibian:"
# Set behaviour options
And I set the following fields to these values:
| behaviour | immediatefeedback |
And I press "Start again with these options"
And I set the field with xpath "//div[@class='qtext']//input[contains(@id, '1_answer')]" to "cat"
And I press "Check"
Then I should see "That is a bad answer."
And I should see "Generalfeedback: frog or toad would have been OK."
And I should see "The correct answer is: frog"

View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<quiz>
<!-- question: 0 -->
<question type="category">
<category>
<text>$course$/Test questions</text>
</category>
</question>
<!-- question: 110000 -->
<question type="shortanswer">
<name>
<text>shortanswer-001</text>
</name>
<questiontext format="html">
<text>Name an amphibian: __________</text>
</questiontext>
<generalfeedback format="html">
<text>Generalfeedback: frog or toad would have been OK.</text>
</generalfeedback>
<defaultgrade>1.0000000</defaultgrade>
<penalty>0.0000000</penalty>
<hidden>0</hidden>
<usecase>0</usecase>
<answer fraction="100" format="moodle_auto_format">
<text>frog</text>
<feedback format="html">
<text>Frog is a very good answer.</text>
</feedback>
</answer>
<answer fraction="80" format="moodle_auto_format">
<text>toad</text>
<feedback format="html">
<text>Toad is an OK good answer.</text>
</feedback>
</answer>
<answer fraction="0" format="moodle_auto_format">
<text>*</text>
<feedback format="html">
<text>That is a bad answer.</text>
</feedback>
</answer>
</question>
</quiz>

View File

@ -0,0 +1,43 @@
@qtype @qtype_truefalse
Feature: Test creating a True/False question
As a teacher
In order to test my students
I need to be able to create a True/False question
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 |
And I log in as "teacher1"
And I follow "Course 1"
And I navigate to "Question bank" node in "Course administration"
@javascript
Scenario: Create a True/False question with Correct answer as False
When I add a "True/False" question filling the form with:
| Question name | true-false-001 |
| Question text | Manchester is the capital city of England. |
| Default mark | 1 |
| General feedback | London is the capital city of England. |
| Correct answer | False |
| Feedback for the response 'True'. | Well done! |
| Feedback for the response 'False'. | Read more about England. |
Then I should see "true-false-001"
@javascript
Scenario: Create a True/False question with Correct answer as True
When I add a "True/False" question filling the form with:
| Question name | true-false-002 |
| Question text | London is the capital city of England. |
| Default mark | 1 |
| General feedback | London is the capital city of England. |
| Correct answer | True |
| Feedback for the response 'True'. | Well done! |
| Feedback for the response 'False'. | Read more about England. |
Then I should see "true-false-002"

View File

@ -0,0 +1,41 @@
@qtype @qtype_truefalse
Feature: Test duplicating a quiz containing a True/False question
As a teacher
In order re-use my courses containing True/False questions
I need to be able to backup and restore them
Background:
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "question categories" exist:
| contextlevel | reference | name |
| Course | C1 | Test questions |
And the following "questions" exist:
| questioncategory | qtype | name | template |
| Test questions | truefalse | true-false-001 | true |
And the following "activities" exist:
| activity | name | course | idnumber |
| quiz | Test quiz | C1 | quiz1 |
And quiz "Test quiz" contains the following questions:
| true-false-001 | 1 |
And I log in as "admin"
And I am on site homepage
And I follow "Course 1"
@javascript
Scenario: Backup and restore a course containing a True/False question
When I backup "Course 1" course using this options:
| Confirmation | Filename | test_backup.mbz |
And I restore "test_backup.mbz" backup into a new course using this options:
| Schema | Course name | Course 2 |
And I navigate to "Question bank" node in "Course administration"
And I click on "Edit" "link" in the "true-false-001" "table_row"
Then the following fields match these values:
| Question name | true-false-001 |
| Question text | The answer is true. |
| Default mark | 1 |
| General feedback | You should have selected true. |
| Correct answer | True |
| Feedback for the response 'True'. | This is the right answer. |
| Feedback for the response 'False'. | This is the wrong answer. |

View File

@ -0,0 +1,37 @@
@qtype @qtype_truefalse
Feature: Test editing a True/False question
As a teacher
In order to be able to update my True/False question
I need to edit them
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | T1 | Teacher1 | teacher1@example.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 |
And the following "question categories" exist:
| contextlevel | reference | name |
| Course | C1 | Test questions |
And the following "questions" exist:
| questioncategory | qtype | name | template |
| Test questions | truefalse | true-false-001 | true |
And I log in as "teacher1"
And I follow "Course 1"
And I navigate to "Question bank" node in "Course administration"
@javascript
Scenario: Edit a True/False question
When I click on "Edit" "link" in the "true-false-001" "table_row"
And I set the following fields to these values:
| Question name | |
And I press "id_submitbutton"
Then I should see "You must supply a value here."
When I set the following fields to these values:
| Question name | Edited true-false-001 name |
And I press "id_submitbutton"
Then I should see "Edited true-false-001 name"

View File

@ -0,0 +1,36 @@
@qtype @qtype_truefalse
Feature: Test exporting True/False questions
As a teacher
In order to be able to reuse my True/false questions
I need to export them
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | T1 | Teacher1 | teacher1@example.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 |
And the following "question categories" exist:
| contextlevel | reference | name |
| Course | C1 | Test questions |
And the following "questions" exist:
| questioncategory | qtype | name | template |
| Test questions | truefalse | true-false-001 | true |
And I log in as "teacher1"
And I follow "Course 1"
@javascript
Scenario: Export a True/False question
When I navigate to "Export" node in "Course administration > Question bank"
And I set the field "id_format_xml" to "1"
And I press "Export questions to file"
Then following "click here" should download between "950" and "1050" bytes
# If the download step is the last in the scenario then we can sometimes run
# into the situation where the download page causes a http redirect but behat
# has already conducted its reset (generating an error). By putting a logout
# step we avoid behat doing the reset until we are off that page.
And I log out

View File

@ -0,0 +1,30 @@
@qtype @qtype_truefalse
Feature: Test importing True/False questions
As a teacher
In order to reuse True/False questions
I need to import them
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | T1 | Teacher1 | teacher1@example.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 |
And I log in as "teacher1"
And I follow "Course 1"
@javascript @_file_upload
Scenario: import a True/False question.
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/truefalse/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 "The answer is true."
And I press "Continue"
And I should see "true-false-001"

View File

@ -0,0 +1,50 @@
@qtype @qtype_truefalse
Feature: Preview a Trtue/False question
As a teacher
In order to check my True/False questions will work for students
I need to preview them
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 |
And the following "question categories" exist:
| contextlevel | reference | name |
| Course | C1 | Test questions |
And the following "questions" exist:
| questioncategory | qtype | name | template |
| Test questions | truefalse | true-false-001 | true |
Given I log in as "teacher1"
And I follow "Course 1"
And I navigate to "Question bank" node in "Course administration"
@javascript
Scenario: Preview a question and submit a correct response.
When I click on "Preview" "link" in the "true-false-001" "table_row"
And I switch to "questionpreview" window
And I set the field "How questions behave" to "Immediate feedback"
And I press "Start again with these options"
And I click on "True" "radio"
And I press "Check"
And I should see "This is the right answer."
And I should see "The correct answer is 'True'."
And I switch to the main window
@javascript
Scenario: Preview a question and submit an incorrect response.
When I click on "Preview" "link" in the "true-false-001" "table_row"
And I switch to "questionpreview" window
And I set the field "How questions behave" to "Immediate feedback"
And I press "Start again with these options"
And I click on "False" "radio"
And I press "Check"
And I should see "This is the wrong answer."
And I should see "You should have selected true."
And I should see "The correct answer is 'True'."
And I switch to the main window

View File

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<quiz>
<!-- question: 0 -->
<question type="category">
<category>
<text>$course$/Test questions</text>
</category>
</question>
<!-- question: 115000 -->
<question type="truefalse">
<name>
<text>true-false-001</text>
</name>
<questiontext format="html">
<text>The answer is true.</text>
</questiontext>
<generalfeedback format="html">
<text>You should have selected true.</text>
</generalfeedback>
<defaultgrade>1.0000000</defaultgrade>
<penalty>1.0000000</penalty>
<hidden>0</hidden>
<answer fraction="100" format="moodle_auto_format">
<text>true</text>
<feedback format="html">
<text>This is the right answer.</text>
</feedback>
</answer>
<answer fraction="0" format="moodle_auto_format">
<text>false</text>
<feedback format="html">
<text>This is the wrong answer.</text>
</feedback>
</answer>
</question>
</quiz>