diff --git a/question/type/numerical/tests/behat/add.feature b/question/type/numerical/tests/behat/add.feature index 6444da83c6a..5318ad02136 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,31 @@ 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 | + + Scenario: Create 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 Question (optional) | + | Question text | How many meter is 1m + 20cm + 50mm? | + | Default mark | 1 | + | General feedback | The correct answer is 1.25m | + | id_answer_0 | 1.25 | + | id_tolerance_0 | 0 | + | id_fraction_0 | 100% | + | id_answer_1 | 125 | + | id_tolerance_1 | 0 | + | id_fraction_1 | 0% | + | id_unitrole | Units are optional. | + | id_unitsleft | on the right, for example 1.00cm or 1.00km | + | id_unit_0 | m | + # Confirm that the numerical question with optional units is added successfully. + When I choose "Edit question" action for "Numerical Question (optional)" in the question bank + Then the following fields match these values: + | Question name | Numerical Question (optional) | + | Question text | How many meter is 1m + 20cm + 50mm? | + | Default mark | 1 | + | General feedback | The correct answer is 1.25m | + | 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 right, for example 1.00cm or 1.00km | + | id_unit_0 | m | diff --git a/question/type/numerical/tests/behat/edit.feature b/question/type/numerical/tests/behat/edit.feature index a70da10c6ed..63de4496ceb 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 + Given I am on the "Numerical for editing" "core_question > edit" page logged in as teacher + # Edit the existing numerical question, changing the unit to optional. + And I set the following fields to these values: + | Question name | Numerical Question (optional) | + | Question text | How many meter is 1m + 20cm + 50mm? | + | Default mark | 1 | + | General feedback | The correct answer is 1.25m | + | id_answer_0 | 1.25 | + | id_tolerance_0 | 0 | + | id_fraction_0 | 100% | + | id_answer_1 | 125 | + | id_tolerance_1 | 0 | + | id_fraction_1 | 0% | + | id_unitrole | Units are optional. | + | id_unitsleft | on the right, for example 1.00cm or 1.00km | + | id_unit_0 | m | + And I press "submitbutton" + When I choose "Edit question" action for "Numerical Question (optional)" in the question bank + # Confirm that the numerical question with optional unit is updated accordingly. + Then the following fields match these values: + | Question name | Numerical Question (optional) | + | Question text | How many meter is 1m + 20cm + 50mm? | + | Default mark | 1 | + | General feedback | The correct answer is 1.25m | + | 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 right, for example 1.00cm or 1.00km | + | id_unit_0 | m | diff --git a/question/type/numerical/tests/behat/preview.feature b/question/type/numerical/tests/behat/preview.feature index 6538a411284..445d8f0d6bf 100644 --- a/question/type/numerical/tests/behat/preview.feature +++ b/question/type/numerical/tests/behat/preview.feature @@ -45,3 +45,25 @@ 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 "Numerical-001" "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 name | Numerical Question (optional) | + | Question text | How many meter is 1m + 20cm + 50mm? | + | Default mark | 1 | + | General feedback | The correct answer is 1.25m | + | id_answer_0 | 1.25 | + | id_tolerance_0 | 0 | + | id_fraction_0 | 100% | + | id_answer_1 | 125 | + | id_tolerance_1 | 0 | + | id_fraction_1 | 0% | + | id_unitrole | Units are optional. | + | id_unitsleft | on the right, for example 1.00cm or 1.00km | + | id_unit_0 | m | + And I press "submitbutton" + When I choose "Preview" action for "Numerical Question (optional)" in the question bank + # Unit is optional, so the unit select box should not be exist. + Then "Select one unit" "select" should not exist