Created
August 12, 2017 22:08
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require('../../config.php'); // adjust as needed | |
require_once($CFG->dirroot.'/course/format/lib.php'); | |
require_once($CFG->libdir.'/modinfolib.php'); | |
$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)); | |
$index++; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment