From 9d19157b08e75026a7463e0f2cfa854188ca97d6 Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Fri, 15 Dec 2023 16:35:27 +0100 Subject: [PATCH] MDL-68124 lesson: Fix random behat error with Oracle This random error was caused because when reviewing an attempt, the first pageid to display is calculated based on the timeseen field in the lesson_attempst table. In Oracle, sometimes it returned the second pageid (because both had the same timeseen), so which led to these random failures. Apart from adding 1-second wait when the attempt is created (to guarantee the first page is returned properly), a few more improvements have been also made, like removing manual steps for setting the lesson activity or adding some extra checks to confirm the information displayed is expected. --- mod/lesson/tests/behat/lesson_review.feature | 61 ++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 18 deletions(-) diff --git a/mod/lesson/tests/behat/lesson_review.feature b/mod/lesson/tests/behat/lesson_review.feature index 7169af8adb2..a03adf89ced 100644 --- a/mod/lesson/tests/behat/lesson_review.feature +++ b/mod/lesson/tests/behat/lesson_review.feature @@ -16,51 +16,76 @@ Feature: In a lesson activity, students can review the answers they gave to ques | user | course | role | | teacher1 | C1 | editingteacher | | student1 | C1 | student | - And the following "activity" exist: - | activity | name | course | idnumber | - | lesson | Test lesson name | C1 | lesson1 | + And the following "activity" exists: + | activity | lesson | + | name | Test lesson name | + | course | C1 | + | idnumber | lesson1 | + # Display ongoing score = Yes + | ongoing | 1 | + # Slideshow = Yes + | slideshow | 1 | + # Maximum number of answers = 10 + | maxanswers | 10 | + # Allow student review = Yes + | modattempts | 1 | + # Maximum number of attempts per question + | maxattempts | 3 | + # Custom scoring = No + | custom | 0 | + # Re-takes allowed = Yes + | retake | 1 | And the following "mod_lesson > pages" exist: | lesson | qtype | title | content | | Test lesson name | numeric | Hardest question ever | 1 + 1? | | Test lesson name | truefalse | Next question | Paper is made from trees. | And the following "mod_lesson > answers" exist: - | page | answer | response | jumpto | score | - | Hardest question ever | 2 | Correct answer | Next page | 1 | - | Hardest question ever | 1 | Incorrect answer | This page | 0 | - | Next question | True | Correct | Next page | 1 | - | Next question | False | Wrong | This page | 0 | - And I am on the "Test lesson name" "lesson activity editing" page logged in as teacher1 - And I set the following fields to these values: - | Display ongoing score | Yes | - | Slideshow | Yes | - | Maximum number of answers | 10 | - | Allow student review | Yes | - | Maximum number of attempts per question | 3 | - | Custom scoring | No | - | Re-takes allowed | Yes | - And I press "Save and display" + | page | answer | response | jumpto | score | + | Hardest question ever | 2 | Correct answer 1 | Next page | 1 | + | Hardest question ever | 1 | Incorrect answer 1 | This page | 0 | + | Next question | True | Correct answer 2 | Next page | 1 | + | Next question | False | Incorrect answer 2 | This page | 0 | And I am on the "Test lesson name" "lesson activity" page logged in as student1 And I should see "You have answered 0 correctly out of 0 attempts." + And I should see "1 + 1?" + And I wait "1" seconds And I set the following fields to these values: | Your answer | 1 | And I press "Submit" And I should see "You have answered 0 correctly out of 1 attempts." And I press "Continue" + And I should see "1 + 1?" + And I wait "1" seconds And I set the following fields to these values: | Your answer | 2 | And I press "Submit" And I should see "You have answered 1 correctly out of 2 attempts." And I press "Continue" + And I should see "Paper is made from trees." + And I wait "1" seconds And I set the following fields to these values: | True | 1 | And I press "Submit" And I should see "You have answered 2 correctly out of 3 attempts." + And I should see "Paper is made from trees." And I press "Continue" + And I should see "Congratulations - end of lesson reached" + And I should see "Number of questions answered: 2" + And I should see "Number of correct answers: 2" + And I should see "Your score is 2 (out of 3)." When I follow "Review lesson" Then I should see "You have answered 2 correctly out of 3 attempts." + And I should see "1 + 1?" And I press "Next page" And I should see "You have answered 2 correctly out of 3 attempts." + And I should see "1 + 1?" + And I should see "Correct answer 1" And I press "Continue" And I should see "You have answered 2 correctly out of 3 attempts." + And I should see "Paper is made from trees." And I press "Next page" And I should see "You have answered 2 correctly out of 3 attempts." + And I should see "Paper is made from trees." + And I should see "Correct answer 2" + And I press "Continue" + And I should see "Congratulations - end of lesson reached" -- 2.11.4.GIT