diff --git a/question/type/numerical/tests/behat/add.feature b/question/type/numerical/tests/behat/add.feature index 6444da83c6a..140b2d13665 100644 --- a/question/type/numerical/tests/behat/add.feature +++ b/question/type/numerical/tests/behat/add.feature @@ -37,7 +37,7 @@ Feature: Test creating a Numerical question Then I should see "Numerical-001" @javascript - Scenario: Create a Numerical question with units + Scenario: Create a Numerical question with required units When I am on the "Course 1" "core_question > course question bank" page logged in as teacher And I add a "Numerical" question filling the form with: | Question name | Numerical-002 | @@ -70,3 +70,25 @@ Feature: Test creating a Numerical question | id_unitgradingtypes | as a fraction (0-1) of the question grade | | id_multichoicedisplay | a drop-down menu | | id_unitsleft | on the right, for example 1.00cm or 1.00km | + + @javascript + Scenario: Create a Numerical question with optional units + When I am on the "Course 1" "core_question > course question bank" page logged in as teacher + # Add the numerical question with optional units. + And I add a "Numerical" question filling the form with: + | Question name | Numerical Question 1 | + | Question text | What is the sum of $8 + $9? | + | Default mark | 1 | + | General feedback | The correct answer is $17 | + | id_answer_0 | 17 | + | id_tolerance_0 | 0 | + | id_fraction_0 | 100% | + | id_answer_1 | * | + | id_tolerance_1 | 0 | + | id_fraction_1 | 0% | + | id_unitrole | Units are optional. If a unit is entered, it is used to convert the response to Unit 1 before grading. | + | id_unitsleft | on the left, for example $1.00 or £1.00 | + | id_unit_0 | $ | + | id_multiplier_0 | 1 | + # Confirm that the numerical question with optional units is added successfully. + Then I should see "Numerical Question 1" diff --git a/question/type/numerical/tests/behat/edit.feature b/question/type/numerical/tests/behat/edit.feature index a70da10c6ed..e1c97c18f11 100644 --- a/question/type/numerical/tests/behat/edit.feature +++ b/question/type/numerical/tests/behat/edit.feature @@ -55,3 +55,32 @@ Feature: Test editing a Numerical question Then the following fields match these values: | id_answer_0 | 0.00000123456789 | | id_tolerance_1 | 0.0000123456789 | + + Scenario: Edit a Numerical question with optional units + When I am on the "Numerical for editing" "core_question > edit" page logged in as teacher + # Edit the existing numerical question, add in the optional units. + And I set the following fields to these values: + | Question text | What's $500 in Php? aaa | + | Default mark | 1 | + | General feedback | The correct answer is Php27950 aaa | + | id_unitrole | Units are optional. If a unit is entered, it is used to convert the response to Unit 1 before grading. | + | id_unitsleft | on the left, for example $1.00 or £1.00 | + | id_answer_0 | 27950 | + | id_tolerance_0 | 0 | + | id_fraction_0 | 100% | + | id_unit_0 | Php | + | id_multiplier_0 | 55.9 | + And I press "submitbutton" + And I choose "Edit question" action for "Numerical for editing" in the question bank + # Confirm that the numerical question is updated accordingly. + Then the following fields match these values: + | Question text | What's $500 in Php? aaa | + | Default mark | 1 | + | General feedback | The correct answer is Php27950 aaa | + | id_unitrole | Units are optional. If a unit is entered, it is used to convert the response to Unit 1 before grading. | + | id_unitsleft | on the left, for example $1.00 or £1.00 | + | id_answer_0 | 27950 | + | id_tolerance_0 | 0 | + | id_fraction_0 | 100% | + | id_unit_0 | Php | + | id_multiplier_0 | 55.9 | diff --git a/question/type/numerical/tests/behat/preview.feature b/question/type/numerical/tests/behat/preview.feature index 6538a411284..02ca6393992 100644 --- a/question/type/numerical/tests/behat/preview.feature +++ b/question/type/numerical/tests/behat/preview.feature @@ -45,3 +45,45 @@ Feature: Preview a Numerical question And I press "Check" And I should see "Very good." And I should see "Mark 1#00 out of 1#00" + + Scenario: Preview a Numerical question with optional units + Given I am on the "Course 1" "core_question > course question bank" page logged in as teacher + # Add the numerical question with optional units + And I add a "Numerical" question filling the form with: + | Question name | Numerical 1 | + | Question text | What's $500 in Php? img1 | + | Default mark | 1 | + | General feedback | The correct answer is Php27950 img1 | + | id_answer_0 | 27950 | + | id_tolerance_0 | 0 | + | id_fraction_0 | 100% | + | id_feedback_0 | Correct! | + | id_answer_1 | * | + | id_tolerance_1 | 0 | + | id_fraction_1 | 0% | + | id_feedback_1 | Wrong! | + | id_unitrole | Units are optional. If a unit is entered, it is used to convert the response to Unit 1 before grading. | + | id_unitsleft | on the left, for example $1.00 or £1.00 | + | id_unit_0 | Php | + | id_multiplier_0 | 1 | + # Confirm numerical question can be previewed. + When I am on the "Numerical 1" "core_question > preview" page logged in as teacher + Then I should see "Numerical 1" + And I should see "What's $500 in Php?" + # Answer question correctly. + And I set the following fields to these values: + | Answer | 27950 | + And I press "Submit and finish" + # Confirm that corresponding feedback is displayed. + And I should see "The correct answer is Php27950" + And I should see "Correct!" + And "//img[contains(@src, 'gd-logo.png')]" "xpath_element" should exist + And I press "Start again" + # Answer question incorrectly. + And I set the following fields to these values: + | Answer | 27961 | + And I press "Submit and finish" + # Confirm that corresponding feedback is displayed. + And I should see "The correct answer is Php27950" + And I should see "Wrong!" + And "//img[contains(@src, 'gd-logo.png')]" "xpath_element" should exist