Skip to content

Commit

Permalink
Behat tesing and helper class improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
mkassaei committed Oct 10, 2023
1 parent 6aa8e09 commit 84d5754
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 29 deletions.
2 changes: 1 addition & 1 deletion tests/behat/backup_and_restore.feature
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Feature: Test duplicating a quiz containing a Numerical question
| General feedback | We are recognising different type of animals. |
| Default mark | 1 |
| id_inputtype | Single choice |
| id_shuffleanswers | 1 |
| id_shuffleanswers | 0 |
| id_columnname_0 | Insects |
| id_columnname_1 | Fish |
| id_columnname_2 | Birds |
Expand Down
54 changes: 32 additions & 22 deletions tests/behat/preview.feature
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,15 @@ Feature: Preview a Numerical question
And I set the field with xpath "//input[@type='radio' and @aria-labelledby='col2 row2']" to "1"
And I set the field with xpath "//input[@type='radio' and @aria-labelledby='col3 row3']" to "1"
When I click on "Submit and finish" "button"
Then I should see "Fly, Bee and Spider are insects."

# Sub-question(row) specific feedback.
Then I should see "Feedback"
And I should see "Fly, Bee and Spider are insects."
And I should see "Cod, Salmon and Trout are fish."
And I should see "Gull and Owl are birds."
And I should see "Cow, Dog and Horse are mammals."

# General feedback.
And I should see "Well done!"
And I should see "We are recognising different type of animals."
And I should see "The correct answers are:"
Expand All @@ -43,24 +48,29 @@ Feature: Preview a Numerical question
And I should see "Seagull → Birds"
And I should see "Dog → Mammals"

# @javascript
# Scenario: Preview a Matrix(multiple) question and submit correct responses.
# Given I am on the "Multiple matrix 001" "core_question > preview" page logged in as teacher
# And I pause
# And I should see "Animal classification. Please answer the sub questions in all 4 rows."
# And I set the field with xpath "//input[@type='radio' and @aria-labelledby='col0 row0']" to "1"
# And I set the field with xpath "//input[@type='radio' and @aria-labelledby='col1 row1']" to "1"
# And I set the field with xpath "//input[@type='radio' and @aria-labelledby='col2 row2']" to "1"
# And I set the field with xpath "//input[@type='radio' and @aria-labelledby='col3 row3']" to "1"
# When I click on "Submit and finish" "button"
# Then I should see "Fly, Bee and Spider are insects."
# And I should see "Cod, Salmon and Trout are fish."
# And I should see "Gull and Owl are birds."
# And I should see "Cow, Dog and Horse are mammals."
# And I should see "Well done!"
# And I should see "We are recognising different type of animals."
# And I should see "The correct answers are:"
# And I should see "Bee → Insects"
# And I should see "Salmon → Fish"
# And I should see "Seagull → Birds"
# And I should see "Dog → Mammals"
@javascript
Scenario: Preview a Matrix(multiple) question and submit correct responses.
Given I am on the "Multiple matrix 001" "core_question > preview" page logged in as teacher
And I should see "Please classify the list of food item as Proteins, Vegetables, Fats."
And I set the field with xpath "//input[@type='checkbox' and @aria-labelledby='col0 row0']" to "1"
And I set the field with xpath "//input[@type='checkbox' and @aria-labelledby='col2 row0']" to "1"
And I set the field with xpath "//input[@type='checkbox' and @aria-labelledby='col5 row0']" to "1"
And I set the field with xpath "//input[@type='checkbox' and @aria-labelledby='col1 row1']" to "1"
And I set the field with xpath "//input[@type='checkbox' and @aria-labelledby='col3 row1']" to "1"
And I set the field with xpath "//input[@type='checkbox' and @aria-labelledby='col6 row1']" to "1"
And I set the field with xpath "//input[@type='checkbox' and @aria-labelledby='col4 row2']" to "1"
When I click on "Submit and finish" "button"

# Sub-question(row) specific feedback.
Then I should see "Feedback"
And I should see "Chicken, fish and red meat containing proteins."
And I should see "Carrot, Asparagus, Potato are vegetables."
And I should see "Olive oil contains fat."

# General feedback.
And I should see "Well done!"
And I should see "A delicious and healthy meal is a balanced one."
And I should see "The correct answers are:"
And I should see "Proteins → Chicken breast, Salmon fillet, Steak"
And I should see "Vegetables → Carrot, Asparagus, Potato"
And I should see "Fats → Olive oil"
20 changes: 14 additions & 6 deletions tests/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,16 +399,24 @@ public static function get_oumatrix_question_form_data_food_multiple() {
];
$qfdata->rowanswersa1 = [
0 => "1",
2 => "1",
5 => "1",
];
$qfdata->rowanswersa2 = [
1 => "1",
3 => "1",
6 => "1",
1 => "1"
];
$qfdata->rowanswersa3 = [
4 => "1"
0 => "1"
];
$qfdata->rowanswersa4 = [
1 => "1"
];
$qfdata->rowanswersa5 = [
2 => "1"
];
$qfdata->rowanswersa6 = [
0 => "1"
];
$qfdata->rowanswersa7 = [
1 => "1"
];
$qfdata->hint = [
0 => ['text' => 'Hint 1.', 'format' => FORMAT_HTML],
Expand Down

0 comments on commit 84d5754

Please sign in to comment.