Skip to content

Instantly share code, notes, and snippets.

Created August 12, 2017 22:08
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save frumbert/bde8da383c3e0530559b54ccf21096c2 to your computer and use it in GitHub Desktop.
In moodle, get a list of activities that are available and their index (order from the top down)
require('../../config.php'); // adjust as needed
$courseid = 26; // the numerical id of the course we are looking in
$index = 1;
$course = get_course($courseId); // in course/format/lib.php
$modinfo = get_fast_modinfo($course); // in lib/modinfolib.php
foreach ($modinfo->get_cms() as $cmid => $cm) {
if ($cm->uservisible && $cm->available) {
echo PHP_EOL . $index, ". ", $cmid, " name=", $cm->modname, ", name=" . $cm->name;// $cm is a cm_info;
// $url = new moodle_url("/mod/" . $cm->modname . "/view.php", array("id" => $cmid));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment