aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Michel Vedrine <vedrine@vedrine.org>2019-05-24 19:48:26 +0200
committerJean-Michel Vedrine <vedrine@vedrine.org>2019-05-28 17:39:31 +0200
commit2b7ff15f16d6ae55ed51ce70b55f396830615a86 (patch)
tree94ba41c2c040861456ba094462aa749b1569bcb8
parentab5128112dece685aa1d62c668f29d7b863905ae (diff)
Add behat test for combinable
-rw-r--r--.travis.yml24
-rw-r--r--tests/behat/combinable.feature136
-rw-r--r--tests/behat/export.feature2
3 files changed, 154 insertions, 8 deletions
diff --git a/.travis.yml b/.travis.yml
index 2c19281..4ce567e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,7 +4,7 @@ sudo: required
addons:
firefox: "47.0.1"
- postgresql: "9.4"
+ postgresql: "9.6"
apt:
packages:
- openjdk-8-jre-headless
@@ -14,13 +14,22 @@ cache:
- $HOME/.composer/cache
- $HOME/.npm
-php:
- - 7.0
- - 7.1
- - 7.2
+matrix:
+ include:
+ - php: 7.2
+ env:
+ - MOODLE_BRANCH=master
+ - DB=pgsql
-env:
- - MOODLE_BRANCH=MOODLE_34_STABLE DB=pgsql IGNORE_PATHS=mobile_src
+ - php: 7.1
+ env:
+ - MOODLE_BRANCH=MOODLE_35_STABLE
+ - DB=mysqli
+
+ - php: 7.1
+ env:
+ - MOODLE_BRANCH=MOODLE_34_STABLE
+ - DB=pgsql
before_install:
- phpenv config-rm xdebug.ini
@@ -31,6 +40,7 @@ before_install:
- export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH"
install:
+ - moodle-plugin-ci add-plugin moodleou/moodle-qtype_combined
- moodle-plugin-ci install
script:
diff --git a/tests/behat/combinable.feature b/tests/behat/combinable.feature
new file mode 100644
index 0000000..213d806
--- /dev/null
+++ b/tests/behat/combinable.feature
@@ -0,0 +1,136 @@
+@qtype @qtype_algebra
+Feature: Test algebra questions in combined question
+ In order to evaluate students responses, As a teacher I need to
+ create and preview combined (Combined) questions with algebra subquestions.
+
+ 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 and preview a combined question.
+ Given I log in as "teacher1"
+ And I am on "Course 1" course homepage
+ And I navigate to "Question bank" in current page administration
+ Then I press "Create a new question ..."
+ And I set the field "Combined" to "1"
+ And I click on "Add" "button" in the "Choose a question type to add" "dialogue"
+ Then I should see "Adding a combined question"
+ And I set the field "Question name" to "Combined 001"
+ And I set the field "Question text" to "What is the square of 2xy? [[1:algebra]].<br/> What is the derivative of the function f(x) = x^2 f'(x) = [[2:algebra]]."
+ Then I set the field "General feedback" to "The square of 2*x*y is 4*x^2*y^2 and the derivative of x^2 is 2*x."
+ And I press "Verify the question text and update the form"
+
+ # Follow sub questions (The order of sub questions comes from the question text).
+ Then I follow "'algebra' input '1'"
+ And I press "Blanks for 1 More Variables"
+ And I set the following fields to these values:
+ | id_subqalgebra1defaultmark | 50% |
+ | id_subqalgebra1compareby | Evaluation |
+ | id_subqalgebra1variable_0 | x |
+ | id_subqalgebra1varmin_0 | -5 |
+ | id_subqalgebra1varmax_0 | 5 |
+ | id_subqalgebra1variable_1 | y |
+ | id_subqalgebra1varmin_1 | -8 |
+ | id_subqalgebra1varmax_1 | 8 |
+ | id_subqalgebra1answer_0 | 4*x^2*y^2 |
+ | id_subqalgebra1generalfeedback | Your square is incorrect |
+
+ Then I follow "'algebra' input '2'"
+ And I set the following fields to these values:
+ | id_subqalgebra2defaultmark | 50% |
+ | id_subqalgebra2compareby | Evaluation |
+ | id_subqalgebra2variable_0 | x |
+ | id_subqalgebra2varmin_0 | -5 |
+ | id_subqalgebra2varmax_0 | 5 |
+ | id_subqalgebra2answer_0 | 2*x |
+ | id_subqalgebra2generalfeedback | Your derivative is incorrect |
+
+ # Set hints for Multiple tries
+ And I follow "Multiple tries"
+ And I set the field "Hint 1" to "First hint"
+ And I set the field "Hint 2" to "Second hint"
+
+ And I press "id_submitbutton"
+ Then I should see "Combined 001"
+
+ # Preview it.
+ When I click on "Preview" "link" in the "Combined 001" "table_row"
+ And I switch to "questionpreview" window
+
+ # 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"
+
+ # Attempt the question
+ # Test html editor for answer field in Combined MultiResponse.
+ And I set the field "Answer 1" to "4*x^2*y^2"
+ And I set the field "Answer 2" to "x"
+ And I press "Check"
+ Then I should see "Your answer is partially correct."
+ And I should see "Your derivative is incorrect"
+ And I should see "First hint"
+
+ When I press "Try again"
+ And I set the following fields to these values:
+ | Answer 2 | 2*x |
+ Then I press "Check"
+ And I should see "Your answer is correct."
+ And I should see "The square of 2*x*y is 4*x^2*y^2 and the derivative of x^2 is 2*x."
+ 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" in current page administration
+ Then I should see "Combined 001"
+
+ # Edit the copy and verify the form field contents.
+ When I click on "Edit" "link" in the "Combined 001" "table_row"
+ Then the following fields match these values:
+ | Question name | Combined 001 |
+ | Question text | What is the square of 2xy? [[1:algebra]].<br/> What is the derivative of the function f(x) = x^2 f'(x) = [[2:algebra]]. |
+
+ | id_subqalgebra1defaultmark | 50% |
+ | id_subqalgebra1compareby | Evaluation |
+ | id_subqalgebra1variable_0 | x |
+ | id_subqalgebra1varmin_0 | -5 |
+ | id_subqalgebra1varmax_0 | 5 |
+ | id_subqalgebra1variable_1 | y |
+ | id_subqalgebra1varmin_1 | -8 |
+ | id_subqalgebra1varmax_1 | 8 |
+ | id_subqalgebra1answer_0 | 4*x^2*y^2 |
+ | id_subqalgebra1generalfeedback | Your square is incorrect |
+
+ | id_subqalgebra2defaultmark | 50% |
+ | id_subqalgebra2compareby | Evaluation |
+ | id_subqalgebra2variable_0 | x |
+ | id_subqalgebra2varmin_0 | -5 |
+ | id_subqalgebra2varmax_0 | 5 |
+ | id_subqalgebra2answer_0 | 2*x |
+ | id_subqalgebra2generalfeedback | Your derivative is incorrect |
+
+ | 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"
diff --git a/tests/behat/export.feature b/tests/behat/export.feature
index 10057ff..21c02fb 100644
--- a/tests/behat/export.feature
+++ b/tests/behat/export.feature
@@ -27,7 +27,7 @@ Feature: Test exporting Algebra questions
When I navigate to "Question bank > Export" in current page administration
And I set the field "id_format_xml" to "1"
And I press "Export questions to file"
- Then following "click here" should download between "1100" and "1200" bytes
+ Then following "click here" should download between "1100" 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