Skip to content

Commit

Permalink
Experimental improvement:
Browse files Browse the repository at this point in the history
  • Loading branch information
cbadusch committed Jan 29, 2025
1 parent c959c2a commit 70d08ec
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
4 changes: 3 additions & 1 deletion classes/course_completion/conditions/course_completed.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use completion_info;
use core_completion\progress;
use local_adele\course_completion\course_completion;
use local_adele\learning_path_update;

defined('MOODLE_INTERNAL') || die();

Expand Down Expand Up @@ -148,7 +149,8 @@ public function get_completion_status($node, $userid) {
}
$isinbetween = false;
foreach ($courses as $courseid) {
$course = get_course($courseid);
$course = learning_path_update::get_course($courseid);
// $course = get_course($courseid);
$completed = false;
if ($course->enablecompletion) {
// Get the course completion instance.
Expand Down
20 changes: 20 additions & 0 deletions classes/learning_path_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,26 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class learning_path_update {

/**
* All courses
* @var array
*/
public static $courses = [];

/**
* Return single course from id
*
* @param int $courseid
*/
public static function get_course($courseid) {
if (!isset(self::$courses[$courseid])) {
$course = get_course($courseid);
self::$courses[$courseid] = $course;
}
return self::$courses[$courseid];
}

/**
* Observer for course completed
*
Expand Down

0 comments on commit 70d08ec

Please sign in to comment.