diff --git a/block_pickup.php b/block_pickup.php index 55ba44f..b09b735 100644 --- a/block_pickup.php +++ b/block_pickup.php @@ -122,7 +122,7 @@ public function fetch_recent_courses(): array { global $USER, $DB; // Get recent courses. - $sql = "SELECT c.id, c.fullname, c.visible, cc.name as catname + $sql = "SELECT c.id, c.fullname, c.visible, c.enablecompletion, cc.name as catname FROM {user_lastaccess} ula JOIN {course} c ON c.id = ula.courseid JOIN {course_categories} cc ON cc.id = c.category @@ -152,11 +152,16 @@ public function fetch_recent_courses(): array { $course->coursecategory = $cr->catname; /* Progress. */ - if ($percentage = progress::get_course_progress_percentage($cr, $USER->id)) { - $percentage = floor($percentage); - $course->progress = $percentage; + if ($cr->enablecompletion) { + $course->progressenabled = true; + $course->progress = "0"; // Default. + if ($percentage = progress::get_course_progress_percentage($cr, $USER->id)) { + $percentage = floor($percentage); + $course->progress = $percentage; + } } + /* Course image. */ $course->courseimage = course_summary_exporter::get_course_image($cr); $template->courses[] = $course; diff --git a/templates/content.mustache b/templates/content.mustache index a0c79e9..e2c1045 100644 --- a/templates/content.mustache +++ b/templates/content.mustache @@ -54,7 +54,7 @@ } }}