本文整理匯總了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'));
}
}
}