Skip to content

Commit

Permalink
fix backport not used by get_instance
Browse files Browse the repository at this point in the history
  • Loading branch information
Glutamat42 committed Sep 3, 2024
1 parent 57b9ea8 commit be39156
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions classes/local/backport/backport_cm_completion_details.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace local_adler\local\backport;


use cm_info;
use core_completion\cm_completion_details as core_cm_completion_details;

if (get_config('moodle', 'version') < 2023100900) {
Expand Down Expand Up @@ -48,6 +49,22 @@ public function is_overall_complete(): bool {

return in_array($this->get_overall_completion(), $completionstates);
}

/**
* From Moodle 4.4 to make backports work, as otherwise the baseclass is returned by this method.
*
* Generates an instance of this class.
*
* @param cm_info $cminfo The course module info instance.
* @param int $userid The user ID that we're fetching completion details for.
* @param bool $returndetails Whether to return completion details or not.
* @return core_cm_completion_details
*/
public static function get_instance(cm_info $cminfo, int $userid, bool $returndetails = true): core_cm_completion_details {
$course = $cminfo->get_course();
$completioninfo = new \completion_info($course);
return new self($completioninfo, $cminfo, $userid, $returndetails);
}
}
} else {
class backport_cm_completion_details extends core_cm_completion_details {
Expand Down

0 comments on commit be39156

Please sign in to comment.