MDL-71162 mod_quiz: Improve behat testing for completion conditions

This commit is contained in:
Michael Hawkins
2021-04-29 00:41:07 +08:00
parent 9fec71fe27
commit b7289dfd80
4 changed files with 71 additions and 6 deletions
@@ -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"
@@ -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"
@@ -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
@@ -0,0 +1,48 @@
@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:
| username | firstname | lastname | email |
| student1 | Student | 1 | student1@example.com |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "courses" exist:
| fullname | shortname | category | enablecompletion |
| Course 1 | C1 | 0 | 1 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And the following config values are set as admin:
| grade_item_advanced | hiddenuntil |
And the following "question categories" exist:
| contextlevel | reference | name |
| Course | C1 | Test questions |
And the following "questions" exist:
| questioncategory | qtype | name | questiontext |
| Test questions | truefalse | First question | Answer the first question |
And the following "activities" exist:
| 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 |
@javascript
Scenario: Use manual completion
When I log in as "teacher1"
# Teacher view.
And I am on "Course 1" course homepage
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 I follow "Test quiz name"
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"