General developer forum

Building course activites navigation

This discussion has been locked because a year has elapsed since the last post. Please start a new discussion topic.
Re: Building course activites navigation
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developers

$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
$modinfo = get_fast_modinfo($course);

$modinfo->get_sections();   // Array of sectionnum => array of course module ids

$modinfo->get_cms(); // Array of cm_info objects - with info about each course module in the course

$modinfo->get_cm($cmid); // Get info about one course module, based on its ID

For more info, take a look in lib/modinfolib.php (which lists the rest of the functions found in the 'course_modinfo' class that get_fast_modinfo returns + the contents of the 'cm_info' class that get_cms and get_cm return).

Average of ratings: Useful (1)