From ef3b5d92979a1edb961a4d0a80d1dd406c15cc03 Mon Sep 17 00:00:00 2001 From: Michael Hawkins Date: Wed, 21 Apr 2021 13:51:42 +0800 Subject: [PATCH] MDL-71162 mod_quiz: Improve behat testing for completion conditions --- .../completion_condition_attempts_used.feature | 8 ++++- .../completion_condition_minimum_attempts.feature | 7 +++- .../completion_condition_passing_grade.feature | 14 +++++--- ..._attempts.feature => completion_manual.feature} | 40 +++++++++------------- 4 files changed, 39 insertions(+), 30 deletions(-) copy mod/quiz/tests/behat/{completion_condition_minimum_attempts.feature => completion_manual.feature} (51%) diff --git a/mod/quiz/tests/behat/completion_condition_attempts_used.feature b/mod/quiz/tests/behat/completion_condition_attempts_used.feature index 49d6e257454..dea3fc19586 100644 --- a/mod/quiz/tests/behat/completion_condition_attempts_used.feature +++ b/mod/quiz/tests/behat/completion_condition_attempts_used.feature @@ -1,4 +1,4 @@ -@mod @mod_quiz +@mod @mod_quiz @core_completion Feature: Set a quiz to be marked complete when the student uses all attempts allowed In order to ensure a student has learned the material before being marked complete As a teacher @@ -47,8 +47,14 @@ Feature: Set a quiz to be marked complete when the student uses all attempts all And I am on "Course 1" course homepage Then the "Receive a grade" completion condition of "Test quiz name" is displayed as "failed" And the "Receive a pass grade or complete all available attempts" completion condition of "Test quiz name" is displayed as "done" + And I follow "Test quiz name" + And the "Receive a grade" completion condition of "Test quiz name" is displayed as "failed" + And the "Receive a pass grade or complete all available attempts" completion condition of "Test quiz name" is displayed as "done" And I log out And I log in as "teacher1" And I am on "Course 1" course homepage + And I follow "Test quiz name" + And "Test quiz name" should have the "Receive a pass grade or complete all available attempts" completion condition + And I am on "Course 1" course homepage And I navigate to "Reports > Activity completion" in current page administration And "Completed" "icon" should exist in the "Student 1" "table_row" diff --git a/mod/quiz/tests/behat/completion_condition_minimum_attempts.feature b/mod/quiz/tests/behat/completion_condition_minimum_attempts.feature index a066a36ac8e..499e68ab8d8 100644 --- a/mod/quiz/tests/behat/completion_condition_minimum_attempts.feature +++ b/mod/quiz/tests/behat/completion_condition_minimum_attempts.feature @@ -1,4 +1,4 @@ -@mod @mod_quiz +@mod @mod_quiz @core_completion Feature: Set a quiz to be marked complete when the student completes a minimum amount of attempts In order to ensure a student has completed the quiz before being marked complete As a teacher @@ -49,8 +49,13 @@ Feature: Set a quiz to be marked complete when the student completes a minimum a And I press "Submit all and finish" And I am on "Course 1" course homepage Then the "Make attempts: 2" completion condition of "Test quiz name" is displayed as "done" + And I follow "Test quiz name" + And the "Make attempts: 2" completion condition of "Test quiz name" is displayed as "done" And I log out And I log in as "teacher1" And I am on "Course 1" course homepage + And I follow "Test quiz name" + And "Test quiz name" should have the "Make attempts: 2" completion condition + And I am on "Course 1" course homepage And I navigate to "Reports > Activity completion" in current page administration And "Completed" "icon" should exist in the "Student 1" "table_row" diff --git a/mod/quiz/tests/behat/completion_condition_passing_grade.feature b/mod/quiz/tests/behat/completion_condition_passing_grade.feature index 2684ffa1d4b..4c435129c4f 100644 --- a/mod/quiz/tests/behat/completion_condition_passing_grade.feature +++ b/mod/quiz/tests/behat/completion_condition_passing_grade.feature @@ -1,4 +1,4 @@ -@mod @mod_quiz +@mod @mod_quiz @core_completion Feature: Set a quiz to be marked complete when the student passes In order to ensure a student has learned the material before being marked complete As a teacher @@ -25,8 +25,8 @@ Feature: Set a quiz to be marked complete when the student passes | questioncategory | qtype | name | questiontext | | Test questions | truefalse | First question | Answer the first question | And the following "activities" exist: - | activity | name | course | idnumber | attempts | gradepass | completion | completionusegrade | completionpass | - | quiz | Test quiz name | C1 | quiz1 | 4 | 5.00 | 2 | 1 | 1 | + | activity | name | course | idnumber | attempts | gradepass | completion | completionusegrade | completionpass | completionview | + | quiz | Test quiz name | C1 | quiz1 | 4 | 5.00 | 2 | 1 | 1 | 1 | And quiz "Test quiz name" contains the following questions: | question | page | | First question | 1 | @@ -36,12 +36,18 @@ Feature: Set a quiz to be marked complete when the student passes And I am on "Course 1" course homepage And the "Receive a grade" completion condition of "Test quiz name" is displayed as "todo" And the "Receive a pass grade" completion condition of "Test quiz name" is displayed as "todo" + And the "View" completion condition of "Test quiz name" is displayed as "todo" And user "student1" has attempted "Test quiz name" with responses: | slot | response | | 1 | True | - And I am on "Course 1" course homepage + And I follow "Test quiz name" Then the "Receive a grade" completion condition of "Test quiz name" is displayed as "done" And the "Receive a pass grade" completion condition of "Test quiz name" is displayed as "done" + And the "View" completion condition of "Test quiz name" is displayed as "done" + And I am on "Course 1" course homepage + And the "Receive a grade" completion condition of "Test quiz name" is displayed as "done" + And the "Receive a pass grade" completion condition of "Test quiz name" is displayed as "done" + And the "View" completion condition of "Test quiz name" is displayed as "done" And I log out And I log in as "teacher1" And I am on "Course 1" course homepage diff --git a/mod/quiz/tests/behat/completion_condition_minimum_attempts.feature b/mod/quiz/tests/behat/completion_manual.feature similarity index 51% copy from mod/quiz/tests/behat/completion_condition_minimum_attempts.feature copy to mod/quiz/tests/behat/completion_manual.feature index a066a36ac8e..de63ece55fa 100644 --- a/mod/quiz/tests/behat/completion_condition_minimum_attempts.feature +++ b/mod/quiz/tests/behat/completion_manual.feature @@ -1,8 +1,8 @@ -@mod @mod_quiz -Feature: Set a quiz to be marked complete when the student completes a minimum amount of attempts - In order to ensure a student has completed the quiz before being marked complete - As a teacher - I need to set a quiz to complete when the student completes a certain amount of attempts +@mod @mod_quiz @core_completion +Feature: Manually complete a quiz + In order to meet manual quiz completion requirements + As a student + I need to be able to view and modify my quiz manual completion status Background: Given the following "users" exist: @@ -25,32 +25,24 @@ Feature: Set a quiz to be marked complete when the student completes a minimum a | questioncategory | qtype | name | questiontext | | Test questions | truefalse | First question | Answer the first question | And the following "activities" exist: - | activity | name | course | idnumber | completion | completionminattemptsenabled | completionminattempts | - | quiz | Test quiz name | C1 | quiz1 | 2 | 1 | 2 | + | activity | name | course | idnumber | completion | + | quiz | Test quiz name | C1 | quiz1 | 1 | And quiz "Test quiz name" contains the following questions: | question | page | | First question | 1 | - And user "student1" has attempted "Test quiz name" with responses: - | slot | response | - | 1 | False | - Scenario: student1 uses up both attempts without passing + @javascript + Scenario: Use manual completion When I log in as "teacher1" + # Teacher view. And I am on "Course 1" course homepage - And "Completed: Test quiz name" "icon" should not exist in the "Test quiz name" "list_item" + And I follow "Test quiz name" + And the manual completion button for "Test quiz name" should be disabled And I log out + # Student view. And I log in as "student1" And I am on "Course 1" course homepage - And the "Make attempts: 2" completion condition of "Test quiz name" is displayed as "todo" And I follow "Test quiz name" - And I press "Re-attempt quiz" - And I set the field "False" to "1" - And I press "Finish attempt ..." - And I press "Submit all and finish" - And I am on "Course 1" course homepage - Then the "Make attempts: 2" completion condition of "Test quiz name" is displayed as "done" - And I log out - And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Reports > Activity completion" in current page administration - And "Completed" "icon" should exist in the "Student 1" "table_row" + Then the manual completion button of "Test quiz name" is displayed as "Mark as done" + And I toggle the manual completion state of "Test quiz name" + And the manual completion button of "Test quiz name" is displayed as "Done" -- 2.11.4.GIT