1
0
mirror of https://github.com/moodle/moodle.git synced 2025-04-11 11:23:52 +02:00

MDL-80589 behat: fixes and improvements to new tests

This commit is contained in:
Simey Lameze 2024-05-02 12:28:25 +08:00
parent 49b4f795ec
commit 49212ac96c
No known key found for this signature in database
GPG Key ID: A32F8A3AF63EBEF4
3 changed files with 66 additions and 80 deletions
question/type/numerical/tests/behat

@ -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? <img src="http://download.moodle.org/unittest/test.jpg"> |
| Default mark | 1 |
| General feedback | The correct answer is $17 <img src="http://download.moodle.org/unittest/test.jpg"> |
| 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 |

@ -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? <img src="/lib/tests/fixtures/gd-logo.png" alt="aaa" width="100" height="75"/> |
| Default mark | 1 |
| General feedback | The correct answer is Php27950 <img src="/lib/tests/fixtures/gd-logo.png" alt="aaa" width="100" height="75"/> |
| 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? <img src="/lib/tests/fixtures/gd-logo.png" alt="aaa" width="100" height="75"/> |
| Default mark | 1 |
| General feedback | The correct answer is Php27950 <img src="/lib/tests/fixtures/gd-logo.png" alt="aaa" width="100" height="75"/> |
| 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 |

@ -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? <img src="/lib/tests/fixtures/gd-logo.png" alt="img1" width="100" height="75"/> |
| Default mark | 1 |
| General feedback | The correct answer is Php27950 <img src="/lib/tests/fixtures/gd-logo.png" alt="img1" width="100" height="75"/> |
| 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