Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions classes/completion/custom_completion.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function get_state(string $rule): int {
// Check if the referenced course is completed.
$coursecompletion = new \completion_completion(['userid' => $this->userid, 'course' => $subcourse->refcourse]);

return $coursecompletion->is_complete();
return $coursecompletion->is_complete() ? COMPLETION_COMPLETE : COMPLETION_INCOMPLETE;
}

/**
Expand All @@ -78,6 +78,10 @@ public function get_custom_rule_descriptions(): array {
* @return array
*/
public function get_sort_order(): array {
return ['completioncourse'];
return [
'completionview',
'completionusegrade',
'completioncourse',
];
}
}
9 changes: 7 additions & 2 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,8 @@ function subcourse_get_coursemodule_info($coursemodule) {
global $CFG, $DB;

$subcourse = $DB->get_record('subcourse', ['id' => $coursemodule->instance],
'id, name, intro, introformat, instantredirect, blankwindow, coursepageprintgrade, coursepageprintprogress');
'id, name, intro, introformat, instantredirect, blankwindow, coursepageprintgrade, coursepageprintprogress, ' .
'completioncourse');

if (!$subcourse) {
return null;
Expand All @@ -387,6 +388,10 @@ function subcourse_get_coursemodule_info($coursemodule) {
$info->content = format_module_intro('subcourse', $subcourse, $coursemodule->id, false);
}

if ($coursemodule->completion == COMPLETION_TRACKING_AUTOMATIC) {
$info->customdata->customcompletionrules['completioncourse'] = $subcourse->completioncourse;
}

return $info;
}

Expand Down Expand Up @@ -433,7 +438,7 @@ function subcourse_update_grades($subcourse, $userid=0, $nullifnone=true) {
// Prevent empty referenced course id coding error.
return GRADE_UPDATE_FAILED;
}

if ($refgrades && $refgrades->grades) {
if (!empty($refgrades->localremotescale)) {
// Unable to fetch remote grades - local scale is used in the remote course.
Expand Down
2 changes: 1 addition & 1 deletion tests/behat/completion_course.feature
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Feature: Completing the referenced course can lead to completing the subcourse a
And I wait "1" seconds
When I run the scheduled task "core\task\completion_regular_task"
And I am on "MainCourse" course homepage
Then the "Complete the activity" completion condition of "Unit course 1" is displayed as "done"
Then the "Require course completed" completion condition of "Unit course 1" is displayed as "done"
And I log out
And I log in as "teacher1"
And I am on "MainCourse" course homepage
Expand Down
36 changes: 18 additions & 18 deletions tests/behat/fetch_percentage_grades.feature
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ Feature: Grades can be fetched either a real values or as percentages
And I navigate to "View > Grader report" in the course gradebook
And I turn editing mode off
And the following should exist in the "user-grades" table:
| Email address | -7- |
| [email protected] | 20.00 (66.67 %) |
| [email protected] | 20.00 (100.00 %) |
| [email protected] | 15.00 (75.00 %) |
| [email protected] | 0.00 (0.00 %) |
| [email protected] | - |
| -1- | -3- | -7- |
| Student 1 | [email protected] | 20.00 (66.67 %) |
| Student 2 | [email protected] | 20.00 (100.00 %) |
| Student 3 | [email protected] | 15.00 (75.00 %) |
| Student 4 | [email protected] | 0.00 (0.00 %) |
| Student 5 | [email protected] | - |

@javascript
Scenario: Grades are fetched as real values by default
Expand All @@ -137,12 +137,12 @@ Feature: Grades can be fetched either a real values or as percentages
And I am on "MainCourse" course homepage
And I navigate to "View > Grader report" in the course gradebook
Then the following should exist in the "user-grades" table:
| Email address | -4- |
| [email protected] | 20.00 (66.67 %) |
| [email protected] | 20.00 (66.67 %) |
| [email protected] | 15.00 (50.00 %) |
| [email protected] | 0.00 (0.00 %) |
| [email protected] | - |
| -1- | -3- | -4- |
| Student 1 | [email protected] | 20.00 (66.67 %) |
| Student 2 | [email protected] | 20.00 (66.67 %) |
| Student 3 | [email protected] | 15.00 (50.00 %) |
| Student 4 | [email protected] | 0.00 (0.00 %) |
| Student 5 | [email protected] | - |

@javascript
Scenario: Grades can be fetched as percentual values
Expand All @@ -168,9 +168,9 @@ Feature: Grades can be fetched either a real values or as percentages
And I am on the "MainCourse" course page logged in as "teacher1"
And I navigate to "View > Grader report" in the course gradebook
Then the following should exist in the "user-grades" table:
| Email address | -4- |
| [email protected] | 20.00 (66.67 %) |
| [email protected] | 30.00 (100.00 %) |
| [email protected] | 22.50 (75.00 %) |
| [email protected] | 0.00 (0.00 %) |
| [email protected] | - |
| -1- | -3- | -4- |
| Student 1 | [email protected] | 20.00 (66.67 %) |
| Student 2 | [email protected] | 30.00 (100.00 %) |
| Student 3 | [email protected] | 22.50 (75.00 %) |
| Student 4 | [email protected] | 0.00 (0.00 %) |
| Student 5 | [email protected] | - |
12 changes: 6 additions & 6 deletions tests/behat/hidden_grades.feature
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ Feature: Course final grades hidden in the referenced course are hidden in the t
And I am on "MainCourse" course homepage
And I navigate to "View > Grader report" in the course gradebook
Then the following should exist in the "user-grades" table:
| Email address | -4- |
| [email protected] | 5.00 |
| [email protected] | 8.00 |
| -1- | -3- | -4- |
| Student 1 | [email protected] | 5.00 |
| Student 2 | [email protected] | 8.00 |
And I log out
#
# Student 1 should not see the grade in the referenced course.
Expand Down Expand Up @@ -103,9 +103,9 @@ Feature: Course final grades hidden in the referenced course are hidden in the t
And I am on "MainCourse" course homepage
And I navigate to "View > Grader report" in the course gradebook
Then the following should exist in the "user-grades" table:
| Email address | -4- |
| [email protected] | 5.00 |
| [email protected] | 8.00 |
| -1- | -3- | -4- |
| Student 1 | [email protected] | 5.00 |
| Student 2 | [email protected] | 8.00 |
And I log out
#
# Student 1 should not see the grade in the referenced course.
Expand Down
Loading