I am creating a new dashboard for our Moodle site, I want to be able to display the percentage of each course progress on the dashboard. I have had a browse through some of the documentation but a lot of it is outdated. Studying the Moodle Database, I have found several tables which might allow for me to calculate a users progress however, I am struggling to understand where the tables link. I was wondering if there might be an easy way - possibly a function - which allows for us to get the users progress on a particular course which can then be displayed on the user dashboard. I figured out a way to list a users enrolled courses using the following query:
$enrolled = $DB->get_records_sql("SELECT `mdl_user_enrolments`.`id` ,`mdl_course`.`fullname` FROM `moodle`.`mdl_user_enrolments` INNER JOIN `moodle`.`mdl_enrol` ON (`mdl_user_enrolments`.`enrolid` = `mdl_enrol`.`id`) INNER JOIN `moodle`.`mdl_course` ON (`mdl_enrol`.`courseid` = `mdl_course`.`id`) INNER JOIN `moodle`.`mdl_user` ON (`mdl_user_enrolments`.`userid` = `mdl_user`.`id`) WHERE `mdl_user`.`id` = " . $USER->id . " "); print_r($enrolled);
However, I want to be able to get the progress of each of their enrolled courses.