本文整理汇总了PHP中core_availability\info_module::is_available_for_all方法的典型用法代码示例。如果您正苦于以下问题:PHP info_module::is_available_for_all方法的具体用法?PHP info_module::is_available_for_all怎么用?PHP info_module::is_available_for_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_availability\info_module
的用法示例。
在下文中一共展示了info_module::is_available_for_all方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Execute the request for this resource.
*
* @param mod_lti\local\ltiservice\response $response Response object for this request.
*/
public function execute($response)
{
global $CFG, $DB;
$params = $this->parse_template();
$linkid = $params['link_id'];
$role = optional_param('role', '', PARAM_TEXT);
$limitnum = optional_param('limit', 0, PARAM_INT);
$limitfrom = optional_param('from', 0, PARAM_INT);
if ($limitnum <= 0) {
$limitfrom = 0;
}
try {
if (empty($linkid)) {
throw new \Exception(null, 404);
}
if (!($lti = $DB->get_record('lti', array('id' => $linkid), 'id,course,typeid,servicesalt', IGNORE_MISSING))) {
throw new \Exception(null, 404);
}
$tool = $DB->get_record('lti_types', array('id' => $lti->typeid));
$toolproxy = $DB->get_record('lti_tool_proxies', array('id' => $tool->toolproxyid));
if (!$this->check_tool_proxy($toolproxy->guid, $response->get_request_data())) {
throw new \Exception(null, 401);
}
if (!($course = $DB->get_record('course', array('id' => $lti->course), 'id', IGNORE_MISSING))) {
throw new \Exception(null, 404);
}
if (!($context = \context_course::instance($lti->course))) {
throw new \Exception(null, 404);
}
$modinfo = get_fast_modinfo($course);
$cm = get_coursemodule_from_instance('lti', $linkid, $lti->course, false, MUST_EXIST);
$cm = $modinfo->get_cm($cm->id);
$info = new info_module($cm);
if ($info->is_available_for_all()) {
$info = null;
}
$json = memberships::get_users_json($this, $context, $lti->course, $tool, $role, $limitfrom, $limitnum, $lti, $info);
$response->set_content_type($this->formats[0]);
$response->set_body($json);
} catch (\Exception $e) {
$response->set_code($e->getCode());
}
}