本文整理汇总了PHP中core_availability\info::get_course_module方法的典型用法代码示例。如果您正苦于以下问题:PHP info::get_course_module方法的具体用法?PHP info::get_course_module怎么用?PHP info::get_course_module使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_availability\info
的用法示例。
在下文中一共展示了info::get_course_module方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_description
/**
* Obtains a string describing this restriction (whether or not
* it actually applies). Used to obtain information that is displayed to
* students if the activity is not available to them, and for staff to see
* what conditions are.
*
* The $full parameter can be used to distinguish between 'staff' cases
* (when displaying all information about the activity) and 'student' cases
* (when displaying only conditions they don't meet).
*
* If implementations require a course or modinfo, they should use
* the get methods in $info.
*
* The special string <AVAILABILITY_CMNAME_123/> can be returned, where
* 123 is any number. It will be replaced with the correctly-formatted
* name for that activity.
*
* @param bool $full Set true if this is the 'full information' view
* @param bool $not Set true if we are inverting the condition
* @param info $info Item we're checking
* @return string Information string (for admin) about all restrictions on
* this item
*/
public function get_description($full, $not, info $info)
{
global $USER, $PAGE;
static $jsadded = false;
if (!$info instanceof info_module) {
return '';
// Should only be possible against activities, not sections.
}
$cm = $info->get_course_module();
if ($not) {
$str = get_string('requires_nopassword', 'availability_password');
} else {
$str = get_string('requires_password', 'availability_password');
}
if (!$full || !$this->is_available($not, $info, false, $USER->id)) {
$url = new \moodle_url('/availability/condition/password/index.php', array('id' => $cm->id));
$str = \html_writer::link($url, $str, array('class' => 'availability_password-popup'));
if (!$jsadded) {
$PAGE->requires->strings_for_js(['enterpassword', 'wrongpassword', 'passwordintro'], 'availability_password');
$PAGE->requires->strings_for_js(['submit', 'cancel'], 'core');
$jsadded = true;
$PAGE->requires->yui_module('moodle-availability_password-popup', 'M.availability_password.popup.init');
}
}
return $str;
}
示例2: get_grouping_id
/**
* Gets the actual grouping id for the condition. This is either a specified
* id, or a special flag indicating that we use the one for the current cm.
*
* @param \core_availability\info $info Info about context cm
* @return int Grouping id
* @throws \coding_exception If it's set to use a cm but there isn't grouping
*/
protected function get_grouping_id(\core_availability\info $info)
{
if ($this->activitygrouping) {
$groupingid = $info->get_course_module()->groupingid;
if (!$groupingid) {
throw new \coding_exception('Not supposed to be able to turn on activitygrouping when no grouping');
}
return $groupingid;
} else {
return $this->groupingid;
}
}