/** * Returns a list of configured types in the given course * * @param int $courseid The id of the course to retieve types for * @param int $sectionreturn section to return to for forming the URLs * @return array Array of lti types. Each element is object with properties: name, title, icon, help, link */ function lti_get_configured_types($courseid, $sectionreturn = 0) { global $OUTPUT; $types = array(); $admintypes = lti_get_lti_types_by_course($courseid); foreach ($admintypes as $ltitype) { $type = new stdClass(); $type->modclass = MOD_CLASS_ACTIVITY; $type->name = 'lti_type_' . $ltitype->id; $type->title = $ltitype->name; if (empty($ltitype->icon)) { $type->icon = $OUTPUT->pix_icon('icon', '', 'lti', array('class' => 'icon')); } else { $type->icon = html_writer::empty_tag('img', array('src' => $ltitype->icon, 'alt' => $ltitype->name, 'class' => 'icon')); } $type->link = new moodle_url('/course/modedit.php', array('add' => 'lti', 'return' => 0, 'course' => $courseid, 'sr' => $sectionreturn, 'typeid' => $ltitype->id)); $types[] = $type; } return $types; }
/** * Returns a list of configured types in the given course * * @param int $courseid The id of the course to retieve types for * @param int $sectionreturn section to return to for forming the URLs * @return array Array of lti types. Each element is object with properties: name, title, icon, help, helplink, link */ function lti_get_configured_types($courseid, $sectionreturn = 0) { global $OUTPUT; $types = array(); $admintypes = lti_get_lti_types_by_course($courseid, [LTI_COURSEVISIBLE_ACTIVITYCHOOSER]); foreach ($admintypes as $ltitype) { $type = new stdClass(); $type->modclass = MOD_CLASS_ACTIVITY; $type->name = 'lti_type_' . $ltitype->id; // Clean the name. We don't want tags here. $type->title = clean_param($ltitype->name, PARAM_NOTAGS); $trimmeddescription = trim($ltitype->description); if ($trimmeddescription != '') { // Clean the description. We don't want tags here. $type->help = clean_param($trimmeddescription, PARAM_NOTAGS); $type->helplink = get_string('modulename_shortcut_link', 'lti'); } if (empty($ltitype->icon)) { $type->icon = $OUTPUT->pix_icon('icon', '', 'lti', array('class' => 'icon')); } else { $type->icon = html_writer::empty_tag('img', array('src' => $ltitype->icon, 'alt' => $ltitype->name, 'class' => 'icon')); } $type->link = new moodle_url('/course/modedit.php', array('add' => 'lti', 'return' => 0, 'course' => $courseid, 'sr' => $sectionreturn, 'typeid' => $ltitype->id)); $types[] = $type; } return $types; }