When it came to deciding which courses to display on the dashboard, we checked which courses included course progress blocks. However, this time around we need to display all courses a learner is enrolled on and attempt to determine their progress. Luckily, we can reuse the code from the completion progress block to determine the learner's progress through a course (but more on that later).
First, we need to obtain a list of courses the current user is enrolled on:
$courses = enrol_get_my_courses(); // Show a message when the user is not enrolled in any courses. if (($this->page->user_is_editing() || is_siteadmin()) && empty($courses)) { $this->content->text = get_string('nocourses', 'block_courses_available'); return ...