本文整理汇总了PHP中core_availability\info_module::get_course_module方法的典型用法代码示例。如果您正苦于以下问题:PHP info_module::get_course_module方法的具体用法?PHP info_module::get_course_module怎么用?PHP info_module::get_course_module使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_availability\info_module
的用法示例。
在下文中一共展示了info_module::get_course_module方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: users_to_json
/**
* Get the JSON representation of the users.
*
* Note that when a limit is set and the exclude array is not empty, then the number of memberships
* returned may be less than the limit.
*
* @param \mod_lti\local\ltiservice\resource_base $resource Resource handling the request
* @param array $users Array of user records
* @param string $id Course ID
* @param object $tool Tool instance object
* @param array $exclude Array of user records to be excluded from the response
* @param int $limitfrom Position of first record to be returned
* @param int $limitnum Maximum number of records to be returned
* @param object $lti LTI instance record
* @param \core_availability\info_module $info Conditional availability information for LTI instance
*
* @return string
*/
private static function users_to_json($resource, $users, $id, $tool, $exclude, $limitfrom, $limitnum, $lti, $info)
{
$nextpage = 'null';
if ($limitnum > 0) {
$limitfrom += $limitnum;
$nextpage = "\"{$resource->get_endpoint()}?limit={$limitnum}&from={$limitfrom}\"";
}
$json = <<<EOD
{
"@context" : "http://purl.imsglobal.org/ctx/lis/v2/MembershipContainer",
"@type" : "Page",
"@id" : "{$resource->get_endpoint()}",
"nextPage" : {$nextpage},
"pageOf" : {
"@type" : "LISMembershipContainer",
"membershipSubject" : {
"@type" : "Context",
"contextId" : "{$id}",
"membership" : [
EOD;
$enabledcapabilities = lti_get_enabled_capabilities($tool);
$sep = ' ';
foreach ($users as $user) {
$include = !in_array($user->id, $exclude);
if ($include && !empty($info)) {
$include = $info->is_user_visible($info->get_course_module(), $user->id);
}
if ($include) {
$member = new \stdClass();
if (in_array('User.id', $enabledcapabilities)) {
$member->userId = $user->id;
}
if (in_array('Person.sourcedId', $enabledcapabilities)) {
$member->sourcedId = format_string($user->idnumber);
}
if (in_array('Person.name.full', $enabledcapabilities)) {
$member->name = format_string("{$user->firstname} {$user->lastname}");
}
if (in_array('Person.name.given', $enabledcapabilities)) {
$member->givenName = format_string($user->firstname);
}
if (in_array('Person.name.family', $enabledcapabilities)) {
$member->familyName = format_string($user->lastname);
}
if (in_array('Person.email.primary', $enabledcapabilities)) {
$member->email = format_string($user->email);
}
if (in_array('Result.sourcedId', $enabledcapabilities) && !empty($lti) && !empty($lti->servicesalt)) {
$member->resultSourcedId = json_encode(lti_build_sourcedid($lti->id, $user->id, $lti->servicesalt, $lti->typeid));
}
$roles = explode(',', lti_get_ims_role($user->id, null, $id, true));
$membership = new \stdClass();
$membership->status = 'Active';
$membership->member = $member;
$membership->role = $roles;
$json .= $sep . json_encode($membership);
$sep = ",\n ";
}
}
$json .= <<<EOD
]
}
}
}
EOD;
return $json;
}