. /** * Prints an instance of colab. * * @package colab * @copyright 2020 Your Name * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require(__DIR__.'/../../config.php'); require_once(__DIR__.'/lib.php'); // Course_module ID, or $id = optional_param('id', 0, PARAM_INT); // ... module instance id. $c = optional_param('c', 0, PARAM_INT); if ($id) { $cm = get_coursemodule_from_id('colab', $id, 0, false, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $moduleinstance = $DB->get_record('colab', array('id' => $cm->instance), '*', MUST_EXIST); } else if ($c) { $moduleinstance = $DB->get_record('colab', array('id' => $n), '*', MUST_EXIST); $course = $DB->get_record('course', array('id' => $moduleinstance->course), '*', MUST_EXIST); $cm = get_coursemodule_from_instance('colab', $moduleinstance->id, $course->id, false, MUST_EXIST); } else { print_error(get_string('missingidandcmid', colab)); } require_login($course, true, $cm); $modulecontext = context_module::instance($cm->id); $event = \mod_colab\event\course_module_viewed::create(array( 'objectid' => $moduleinstance->id, 'context' => $modulecontext )); $event->add_record_snapshot('course', $course); $event->add_record_snapshot('colab', $moduleinstance); $event->trigger(); $PAGE->set_url('/mod/colab/view.php', array('id' => $cm->id)); $PAGE->set_title(format_string($moduleinstance->name)); $PAGE->set_heading(format_string($course->fullname)); $PAGE->set_context($modulecontext); echo $OUTPUT->header(); echo $OUTPUT->footer();