本文整理汇总了PHP中cm_info::set_icon_url方法的典型用法代码示例。如果您正苦于以下问题:PHP cm_info::set_icon_url方法的具体用法?PHP cm_info::set_icon_url怎么用?PHP cm_info::set_icon_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cm_info
的用法示例。
在下文中一共展示了cm_info::set_icon_url方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mod_subcourse_cm_info_dynamic
/**
* This will change the activity module icon to represent the grade percentage.
*
* @param cm_info $cm
* @return void
*/
function mod_subcourse_cm_info_dynamic(cm_info $cm)
{
global $USER;
$currentgrade = grade_get_grades($cm->course, 'mod', 'subcourse', $cm->instance, $USER->id);
$gradepass = $currentgrade->items[0]->gradepass;
// Use the maximum grade if there is no passing grade set
if ($gradepass == 0) {
$gradepass = $currentgrade->items[0]->grademax;
}
if (!empty($currentgrade->items[0]->grades)) {
$currentgrade = reset($currentgrade->items[0]->grades);
if (isset($currentgrade->grade) and !$currentgrade->hidden) {
$grade = $currentgrade->grade;
// Convert the percent complete to a whole fraction of 20 to match the icon images.
$gradeicon = floor(subcourse_percent_complete($gradepass, $grade) / 5);
$cm->set_icon_url(new moodle_url('/mod/subcourse/pix/icon-' . $gradeicon . '.svg'));
}
}
}