diff --git a/completion/classes/api.php b/completion/classes/api.php index 4912f514cfe..edec5a49e8a 100644 --- a/completion/classes/api.php +++ b/completion/classes/api.php @@ -151,7 +151,6 @@ class api { AND ( mc.completionstate = :completionstate OR mc.completionstate = :completionstatepass - OR mc.completionstate = :completionstatefail )"; $params = [ @@ -159,7 +158,6 @@ class api { 'contextlevel' => CONTEXT_COURSE, 'completionstate' => COMPLETION_COMPLETE, 'completionstatepass' => COMPLETION_COMPLETE_PASS, - 'completionstatefail' => COMPLETION_COMPLETE_FAIL ]; if ($userdata) { diff --git a/completion/classes/progress.php b/completion/classes/progress.php index 49702f4d4fd..c95352259f5 100644 --- a/completion/classes/progress.php +++ b/completion/classes/progress.php @@ -80,7 +80,11 @@ class progress { $completed = 0; foreach ($modules as $module) { $data = $completion->get_data($module, true, $userid); - $completed += $data->completionstate == COMPLETION_INCOMPLETE ? 0 : 1; + if (($data->completionstate == COMPLETION_INCOMPLETE) || ($data->completionstate == COMPLETION_COMPLETE_FAIL)) { + $completed += 0; + } else { + $completed += 1; + }; } return ($completed / $count) * 100; diff --git a/completion/tests/behat/course_completion_activity_criteria.feature b/completion/tests/behat/course_completion_activity_criteria.feature new file mode 100644 index 00000000000..3d1b69b5cf7 --- /dev/null +++ b/completion/tests/behat/course_completion_activity_criteria.feature @@ -0,0 +1,90 @@ +@block @block_completionstatus @javascript +Feature: Course completion state should match completion criteria + In order to understand the configuration or status of an course's completion + As a user + I need to see the appropriate completion information on course and dashboard pages + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | idnumber | + | teacher1 | Teacher | 1 | teacher1@example.com | T1 | + | teacher2 | Teacher | 2 | teacher1@example.com | T2 | + | student1 | Student | 1 | student1@example.com | S1 | + And the following "courses" exist: + | fullname | shortname | category | enablecompletion | showcompletionconditions | + | Course 1 | C1 | 0 | 1 | 1 | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + | teacher2 | C1 | teacher | + | student1 | C1 | student | + And the following "activity" exists: + | activity | assign | + | course | C1 | + | section | 1 | + | name | Test assignment name | + | intro | Submit your online text | + | completion | 1 | + | assignsubmission_onlinetext_enabled | 1 | + | grade[modgrade_type] | Point | + | grade[modgrade_point] | 100 | + And I log in as "teacher1" + And I am on "Course 1" course homepage with editing mode on + And I navigate to "Course completion" in current page administration + And I click on "Condition: Activity completion" "link" + And I set the field "Assignment - Test assignment name" to "1" + And I press "Save changes" + And I add the "Course completion status" block + And I am on the "Test assignment name" "assign activity" page + And I navigate to "Settings" in current page administration + And I set the following fields to these values: + | Completion tracking | Show activity as complete when conditions are met | + | completionusegrade | 1 | + | completionpassgrade | 1 | + | gradepass | 70 | + And I press "Save and return to course" + And I log out + + Scenario: Completion status show match completion criteria. + Given I log in as "student1" + And I am on "Course 1" course homepage + And the "Receive a grade" completion condition of "Test assignment name" is displayed as "todo" + And the "Receive a passing grade" completion condition of "Test assignment name" is displayed as "todo" + And I should see "Status: Not yet started" in the "Course completion status" "block" + And I am on the "Test assignment name" "assign activity" page + And I press "Add submission" + And I set the following fields to these values: + | Online text | I'm the student1 submission | + And I press "Save changes" + And I press "Submit assignment" + And I press "Continue" + And I log out + And I am on the "Test assignment name" "assign activity" page logged in as teacher1 + And I follow "View all submissions" + And I click on "Grade" "link" in the "Student 1" "table_row" + And I set the following fields to these values: + | Grade out of 100 | 50.0 | + And I press "Save changes" + And I log out + When I log in as "student1" + And I am on "Course 1" course homepage + And I should see "Status: Pending" in the "Course completion status" "block" + And the "Receive a grade" completion condition of "Test assignment name" is displayed as "done" + And the "Receive a passing grade" completion condition of "Test assignment name" is displayed as "failed" + And I am on the "My courses" page + And I should not see "100%" in the "Course overview" "block" + And I log out + And I am on the "Test assignment name" "assign activity" page logged in as teacher1 + And I follow "View all submissions" + And I click on "Grade" "link" in the "Student 1" "table_row" + And I set the following fields to these values: + | Grade out of 100 | 75.0 | + And I press "Save changes" + And I log out + And I log in as "student1" + And I am on "Course 1" course homepage + And I should see "Status: Complete" in the "Course completion status" "block" + And the "Receive a grade" completion condition of "Test assignment name" is displayed as "done" + And the "Receive a passing grade" completion condition of "Test assignment name" is displayed as "done" + And I am on the "My courses" page + Then I should see "100%" in the "Course overview" "block"