O'Reilly logo

Moodle 3.x Developer's Guide by Ian Wild

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Determining progress

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required