From 49212ac96c4805d9d4768677c7e10e0b3519180c Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Thu, 2 May 2024 12:28:25 +0800 Subject: [PATCH] MDL-80589 behat: fixes and improvements to new tests --- .../type/numerical/tests/behat/add.feature | 40 +++++++------ .../type/numerical/tests/behat/edit.feature | 48 +++++++-------- .../numerical/tests/behat/preview.feature | 58 ++++++------------- 3 files changed, 66 insertions(+), 80 deletions(-) diff --git a/question/type/numerical/tests/behat/add.feature b/question/type/numerical/tests/behat/add.feature index 140b2d13665..5318ad02136 100644 --- a/question/type/numerical/tests/behat/add.feature +++ b/question/type/numerical/tests/behat/add.feature @@ -71,24 +71,30 @@ Feature: Test creating a Numerical question | 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 + 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 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 | + | 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. - Then I should see "Numerical Question 1" + 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 e1c97c18f11..63de4496ceb 100644 --- a/question/type/numerical/tests/behat/edit.feature +++ b/question/type/numerical/tests/behat/edit.feature @@ -57,30 +57,30 @@ Feature: Test editing a Numerical question | 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. + 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 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 | + | 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" - And I choose "Edit question" action for "Numerical for editing" in the question bank - # Confirm that the numerical question is updated accordingly. + 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 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 | + | 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 02ca6393992..445d8f0d6bf 100644 --- a/question/type/numerical/tests/behat/preview.feature +++ b/question/type/numerical/tests/behat/preview.feature @@ -47,43 +47,23 @@ Feature: Preview a Numerical question 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. + 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: - | 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 + | 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