Skip to content

Commit

Permalink
MDL-75719 completion: Fix unit tests and Behat tests.
Browse files Browse the repository at this point in the history
Fix tests since we changed behavior of completions (completion
state an UI).
  • Loading branch information
ilyatregubov committed Mar 2, 2023
1 parent 3ebd25f commit 23915a3
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
24 changes: 24 additions & 0 deletions lib/tests/completionlib_test.php
Expand Up @@ -1319,6 +1319,30 @@ public function test_internal_get_grade_state() {
$this->assertEquals(
COMPLETION_COMPLETE,
completion_info::internal_get_grade_state($item, $grade));

// Item is hidden, but returnpassfail is true and the grade is passing.
$item->hidden = 1;
$item->gradepass = 4;
$grade->finalgrade = 5.0;
$this->assertEquals(
COMPLETION_COMPLETE_PASS,
completion_info::internal_get_grade_state($item, $grade, true));

// Item is hidden, but returnpassfail is true and the grade is failing.
$item->hidden = 1;
$item->gradepass = 4;
$grade->finalgrade = 3.0;
$this->assertEquals(
COMPLETION_COMPLETE_FAIL_HIDDEN,
completion_info::internal_get_grade_state($item, $grade, true));

// Item is not hidden, but returnpassfail is true and the grade is failing.
$item->hidden = 0;
$item->gradepass = 4;
$grade->finalgrade = 3.0;
$this->assertEquals(
COMPLETION_COMPLETE_FAIL,
completion_info::internal_get_grade_state($item, $grade, true));
}

/**
Expand Down
17 changes: 12 additions & 5 deletions mod/quiz/tests/behat/quiz_activity_completion_unlocked.feature
Expand Up @@ -31,7 +31,7 @@ Feature: Activity completion in the quiz activity with unlocked and re-grading.
| idnumber | quiz1 |
| name | Test quiz name |
| section | 1 |
| gradepass | 10.00 |
| gradepass | 8 |
| grade | 10 |
| grademethod | 1 |
| completion | 2 |
Expand All @@ -54,14 +54,21 @@ Feature: Activity completion in the quiz activity with unlocked and re-grading.
And I am on "Course 1" course homepage
And I follow "Test quiz name"
And the "Receive a grade" completion condition of "Test quiz name" is displayed as "done"
And the "Receive a passing grade" completion condition of "Test quiz name" is displayed as "failed"
And the "Receive a passing grade" completion condition of "Test quiz name" is displayed as "done"
And I log out
When I am on the "Test quiz name" "quiz activity" page logged in as teacher1
When I am on the "Course 1" course page logged in as teacher1
And I navigate to "Reports > Activity completion" in current page administration
And "Completed (achieved pass grade)" "icon" should exist in the "Student 1" "table_row"
And I am on the "Test quiz name" "quiz activity" page
And I navigate to "Settings" in current page administration
And I expand all fieldsets
And I press "Unlock completion settings"
And I set the following fields to these values:
| gradepass | 8 |
| gradepass | 10 |
And I press "Save and return to course"
And I navigate to "Reports > Activity completion" in current page administration
Then "Completed (achieved pass grade)" "icon" should exist in the "Student 1" "table_row"
Then "Completed (achieved pass grade)" "icon" should not exist in the "Student 1" "table_row"
And I log out
And I am on the "Test quiz name" "quiz activity" page logged in as student1
And the "Receive a grade" completion condition of "Test quiz name" is displayed as "done"
And the "Receive a passing grade" completion condition of "Test quiz name" is displayed as "failed"

0 comments on commit 23915a3

Please sign in to comment.