Beispiel #1
0
/**
 * Called when viewing course page. Shows extra details after the link if
 * enabled.
 *
 * @param cm_info $cm Course module information
 */
function resource_cm_info_view(cm_info $cm) {
    $details = $cm->get_custom_data();
    if ($details) {
        $cm->set_after_link(' ' . html_writer::tag('span', $details,
                array('class' => 'resourcelinkdetails')));
    }
}
Beispiel #2
0
/**
 * Overwrites the content in the course-module object with the folder files list
 * if folder.display == FOLDER_DISPLAY_INLINE
 *
 * @param cm_info $cm
 */
function folder_cm_info_view(cm_info $cm)
{
    global $PAGE;
    if ($cm->uservisible && $cm->get_custom_data() && has_capability('mod/folder:view', $cm->context)) {
        // Restore folder object from customdata.
        // Note the field 'customdata' is not empty IF AND ONLY IF we display contens inline.
        // Otherwise the content is default.
        $folder = $cm->get_custom_data();
        $folder->id = (int) $cm->instance;
        $folder->course = (int) $cm->course;
        $folder->display = FOLDER_DISPLAY_INLINE;
        $folder->name = $cm->name;
        if (empty($folder->intro)) {
            $folder->intro = '';
        }
        if (empty($folder->introformat)) {
            $folder->introformat = FORMAT_MOODLE;
        }
        // display folder
        $renderer = $PAGE->get_renderer('mod_folder');
        $cm->set_content($renderer->display_folder($folder));
    }
}
 /**
  * Obtains the forum type based on its 'info' object in modinfo (e.g. from
  * $modinfo->instances['forumng'][1234]). Usually this comes from the
  * custom data in the cm_info object.
  *
  * @param object $info Info object (either cm_info or something else)
  * @return string Forum type
  */
 private static function get_type_from_modinfo_info(cm_info $info)
 {
     if (isset($info->forumtype)) {
         // Only set when using get_modinfo_special for shared activity modules.
         return $info->forumtype;
     }
     return $info->get_custom_data()->type;
 }