当前位置: 首页>>代码示例>>PHP>>正文


PHP lti_add_type函数代码示例

本文整理汇总了PHP中lti_add_type函数的典型用法代码示例。如果您正苦于以下问题:PHP lti_add_type函数的具体用法?PHP lti_add_type怎么用?PHP lti_add_type使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了lti_add_type函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: moodle_url

$url = new moodle_url('/mod/lti/request_tool.php', array('instanceid' => $instanceid));
$PAGE->set_url($url);

$pagetitle = strip_tags($course->shortname);
$PAGE->set_title($pagetitle);
$PAGE->set_heading($course->fullname);

$PAGE->set_pagelayout('incourse');

echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($lti->name, true, array('context' => $context)));

// Add a tool type if one does not exist already.
if (!lti_get_tool_by_url_match($lti->toolurl, $lti->course, LTI_TOOL_STATE_ANY)) {
    // There are no tools (active, pending, or rejected) for the launch URL. Create a new pending tool.
    $tooltype = new stdClass();
    $toolconfig = new stdClass();

    $toolconfig->lti_toolurl = lti_get_domain_from_url($lti->toolurl);
    $toolconfig->lti_typename = $toolconfig->lti_toolurl;

    lti_add_type($tooltype, $toolconfig);

    echo get_string('lti_tool_request_added', 'lti');
} else {
    echo get_string('lti_tool_request_existing', 'lti');
}

echo $OUTPUT->footer();
开发者ID:jtibbetts,项目名称:moodle,代码行数:29,代码来源:request_tool.php

示例2: mod_lti_edit_types_form

    }
}
if (lti_request_is_using_ssl() && !empty($type->lti_secureicon)) {
    $type->oldicon = $type->lti_secureicon;
} else {
    $type->oldicon = $type->lti_icon;
}
$form = new mod_lti_edit_types_form($pageurl, (object) array('isadmin' => true, 'istool' => true));
if ($data = $form->get_data()) {
    $type = new stdClass();
    if (!empty($id)) {
        $type->id = $id;
        lti_update_type($type, $data);
    } else {
        $type->state = LTI_TOOL_STATE_CONFIGURED;
        lti_add_type($type, $data);
    }
    redirect($redirect);
} else {
    if ($form->is_cancelled()) {
        redirect($redirect);
    }
}
$PAGE->set_title(format_string($SITE->shortname) . ': ' . get_string('toolsetup', 'lti'));
$PAGE->navbar->add(get_string('lti_administration', 'lti'), $CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=modsettinglti');
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('toolsetup', 'lti'));
echo $OUTPUT->box_start('generalbox');
if ($action == 'update') {
    $form->set_data($type);
}
开发者ID:alanaipe2015,项目名称:moodle,代码行数:31,代码来源:toolssettings.php

示例3: create_tool_type

 /**
  * Creates a tool type.
  *
  * @param string $cartridgeurl Url of the xml cartridge representing the LTI tool
  * @param string $key The consumer key to identify this consumer
  * @param string $secret The secret
  * @return array created tool type
  * @since Moodle 3.1
  * @throws moodle_exception If the tool type could not be created
  */
 public static function create_tool_type($cartridgeurl, $key, $secret)
 {
     $params = self::validate_parameters(self::create_tool_type_parameters(), array('cartridgeurl' => $cartridgeurl, 'key' => $key, 'secret' => $secret));
     $cartridgeurl = $params['cartridgeurl'];
     $key = $params['key'];
     $secret = $params['secret'];
     $context = context_system::instance();
     self::validate_context($context);
     require_capability('moodle/site:config', $context);
     $id = null;
     if (!empty($cartridgeurl)) {
         $type = new stdClass();
         $data = new stdClass();
         $type->state = LTI_TOOL_STATE_CONFIGURED;
         $data->lti_coursevisible = 1;
         $data->lti_sendname = LTI_SETTING_DELEGATE;
         $data->lti_sendemailaddr = LTI_SETTING_DELEGATE;
         $data->lti_acceptgrades = LTI_SETTING_DELEGATE;
         $data->lti_forcessl = 0;
         if (!empty($key)) {
             $data->lti_resourcekey = $key;
         }
         if (!empty($secret)) {
             $data->lti_password = $secret;
         }
         lti_load_type_from_cartridge($cartridgeurl, $data);
         if (empty($data->lti_toolurl)) {
             throw new moodle_exception('unabletocreatetooltype', 'mod_lti');
         } else {
             $id = lti_add_type($type, $data);
         }
     }
     if (!empty($id)) {
         $type = lti_get_type($id);
         return serialise_tool_type($type);
     } else {
         throw new moodle_exception('unabletocreatetooltype', 'mod_lti');
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:49,代码来源:external.php

示例4: execute


//.........这里部分代码省略.........
                    $classname = explode('\\', get_class($aservice));
                    if (empty($aservice) || !in_array($classname[count($classname) - 1], $offeredservices)) {
                        $errors[] = $service->service;
                    }
                }
            }
            if (count($errors) > 0) {
                $ok = false;
                debugging('Tool proxy contains services which were not offered: ' . implode(', ', $errors));
            }
        }
        // Extract all launchable tools from the resource handlers.
        if ($ok) {
            $resources = $toolproxyjson->tool_profile->resource_handler;
            foreach ($resources as $resource) {
                $found = false;
                $tool = new \stdClass();
                foreach ($resource->message as $message) {
                    if ($message->message_type == 'basic-lti-launch-request') {
                        $found = true;
                        $tool->path = $message->path;
                        $tool->enabled_capability = $message->enabled_capability;
                        $tool->parameter = $message->parameter;
                        break;
                    }
                }
                if (!$found) {
                    continue;
                }
                $tool->name = $resource->resource_name->default_value;
                $tools[] = $tool;
            }
            $ok = count($tools) > 0;
            if (!$ok) {
                debugging('No launchable messages found in tool proxy');
            }
        }
        // Add tools and custom parameters.
        if ($ok) {
            $baseurl = '';
            if (isset($toolproxyjson->tool_profile->base_url_choice[0]->default_base_url)) {
                $baseurl = $toolproxyjson->tool_profile->base_url_choice[0]->default_base_url;
            }
            $securebaseurl = '';
            if (isset($toolproxyjson->tool_profile->base_url_choice[0]->secure_base_url)) {
                $securebaseurl = $toolproxyjson->tool_profile->base_url_choice[0]->secure_base_url;
            }
            foreach ($tools as $tool) {
                $config = new \stdClass();
                $config->lti_toolurl = "{$baseurl}{$tool->path}";
                $config->lti_typename = $tool->name;
                $config->lti_coursevisible = 1;
                $config->lti_forcessl = 0;
                $type = new \stdClass();
                $type->state = LTI_TOOL_STATE_PENDING;
                $type->toolproxyid = $toolproxy->id;
                $type->enabledcapability = implode("\n", $tool->enabled_capability);
                $type->parameter = self::lti_extract_parameters($tool->parameter);
                if (isset($resource->icon_info[0]->default_location->path)) {
                    $iconpath = $resource->icon_info[0]->default_location->path;
                    $type->icon = "{$baseurl}{$iconpath}";
                    if (!empty($securebaseurl)) {
                        $type->secureicon = "{$securebaseurl}{$iconpath}";
                    }
                }
                $ok = $ok && lti_add_type($type, $config) !== false;
            }
            if (isset($toolproxyjson->custom)) {
                lti_set_tool_settings($toolproxyjson->custom, $toolproxy->id);
            }
        }
        if (!empty($toolproxy)) {
            if ($ok) {
                // If all went OK accept the tool proxy.
                $toolproxy->state = LTI_TOOL_PROXY_STATE_ACCEPTED;
                $toolproxy->toolproxy = $response->get_request_data();
                $toolproxy->secret = $toolproxyjson->security_contract->shared_secret;
                $toolproxy->vendorcode = $toolproxyjson->tool_profile->product_instance->product_info->product_family->vendor->code;
                $url = $this->get_endpoint();
                $body = <<<EOD
{
  "@context" : "http://purl.imsglobal.org/ctx/lti/v2/ToolProxyId",
  "@type" : "ToolProxy",
  "@id" : "{$url}",
  "tool_proxy_guid" : "{$toolproxy->guid}"
}
EOD;
                $response->set_code(201);
                $response->set_content_type('application/vnd.ims.lti.v2.toolproxy.id+json');
                $response->set_body($body);
            } else {
                // Otherwise reject the tool proxy.
                $toolproxy->state = LTI_TOOL_PROXY_STATE_REJECTED;
                $response->set_code(400);
            }
            lti_update_tool_proxy($toolproxy);
        } else {
            $response->set_code(400);
        }
    }
开发者ID:evltuma,项目名称:moodle,代码行数:101,代码来源:toolproxy.php

示例5: test_mod_lti_get_tool_types

 public function test_mod_lti_get_tool_types()
 {
     // Create a tool proxy.
     $proxy = mod_lti_external::create_tool_proxy('Test proxy', $this->getExternalTestFileUrl('/test.html'), array(), array());
     // Create a tool type, associated with that proxy.
     $type = new stdClass();
     $data = new stdClass();
     $type->state = LTI_TOOL_STATE_CONFIGURED;
     $type->name = "Test tool";
     $type->description = "Example description";
     $type->toolproxyid = $proxy->id;
     $type->baseurl = $this->getExternalTestFileUrl('/test.html');
     $typeid = lti_add_type($type, $data);
     $types = mod_lti_external::get_tool_types($proxy->id);
     $this->assertEquals(1, count($types));
     $type = $types[0];
     $this->assertEquals('Test tool', $type['name']);
     $this->assertEquals('Example description', $type['description']);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:19,代码来源:externallib_test.php

示例6: test_lti_build_content_item_selection_request_invalid_presentationtargets

 /**
  * Test for lti_build_content_item_selection_request() with invalid presentation targets parameter.
  */
 public function test_lti_build_content_item_selection_request_invalid_presentationtargets()
 {
     $this->resetAfterTest();
     $this->setAdminUser();
     // Create a tool type, associated with that proxy.
     $type = new stdClass();
     $data = new stdClass();
     $data->lti_contentitem = true;
     $type->state = LTI_TOOL_STATE_CONFIGURED;
     $type->name = "Test tool";
     $type->description = "Example description";
     $type->baseurl = $this->getExternalTestFileUrl('/test.html');
     $typeid = lti_add_type($type, $data);
     $course = $this->getDataGenerator()->create_course();
     $returnurl = new moodle_url('/');
     // Should throw coding_exception on non-array presentation targets.
     $targets = 'frame,iframe';
     $this->expectException('coding_exception');
     lti_build_content_item_selection_request($typeid, $course, $returnurl, '', '', [], $targets);
 }
开发者ID:janeklb,项目名称:moodle,代码行数:23,代码来源:locallib_test.php

示例7: execute

    public function execute($response) {

        $ok = $this->get_service()->check_tool_proxy(null, $response->get_request_data());
        $toolproxy = $this->get_service()->get_tool_proxy();
        if ($ok) {
            $toolproxyjson = json_decode($response->get_request_data());
            $ok = !is_null($toolproxyjson);
            $ok = $ok && isset($toolproxyjson->tool_profile->product_instance->product_info->product_family->vendor->code);
            $ok = $ok && isset($toolproxyjson->security_contract->shared_secret);
            $ok = $ok && isset($toolproxyjson->tool_profile->resource_handler);
        }
        if ($ok) {
            $baseurl = '';
            if (isset($toolproxyjson->tool_profile->base_url_choice[0]->default_base_url)) {
                $baseurl = $toolproxyjson->tool_profile->base_url_choice[0]->default_base_url;
            }
            $securebaseurl = '';
            if (isset($toolproxyjson->tool_profile->base_url_choice[0]->secure_base_url)) {
                $securebaseurl = $toolproxyjson->tool_profile->base_url_choice[0]->secure_base_url;
            }
            $resources = $toolproxyjson->tool_profile->resource_handler;
            foreach ($resources as $resource) {
                $icon = new \stdClass();
                if (isset($resource->icon_info[0]->default_location->path)) {
                    $icon->path = $resource->icon_info[0]->default_location->path;
                }
                $tool = new \stdClass();
                $tool->name = $resource->resource_name->default_value;
                $messages = $resource->message;
                foreach ($messages as $message) {
                    if ($message->message_type == 'basic-lti-launch-request') {
                        $tool->path = $message->path;
                        $tool->enabled_capability = $message->enabled_capability;
                        $tool->parameter = $message->parameter;
                    }
                }
                $config = new \stdClass();
                $config->lti_toolurl = "{$baseurl}{$tool->path}";
                $config->lti_typename = $tool->name;
                $config->lti_coursevisible = 1;
                $config->lti_forcessl = 0;

                $type = new \stdClass();
                $type->state = LTI_TOOL_STATE_PENDING;
                $type->toolproxyid = $toolproxy->id;
                $type->enabledcapability = implode("\n", $tool->enabled_capability);
                $type->parameter = self::lti_extract_parameters($tool->parameter);
                if (!empty($icon->path)) {
                    $type->icon = "{$baseurl}{$icon->path}";
                    if (!empty($securebaseurl)) {
                        $type->secureicon = "{$securebaseurl}{$icon->path}";
                    }
                }
                $ok = (lti_add_type($type, $config) !== false);
            }
            if (isset($toolproxyjson->custom)) {
                lti_set_tool_settings($toolproxyjson->custom, $toolproxy->id);
            }
        }
        if ($ok) {
            $toolproxy->state = LTI_TOOL_PROXY_STATE_ACCEPTED;
            $toolproxy->toolproxy = $response->get_request_data();
            $toolproxy->secret = $toolproxyjson->security_contract->shared_secret;
            $toolproxy->vendorcode = $toolproxyjson->tool_profile->product_instance->product_info->product_family->vendor->code;

            $url = $this->get_endpoint();
            $body = <<< EOD
{
  "@context" : "http://purl.imsglobal.org/ctx/lti/v2/ToolProxyId",
  "@type" : "ToolProxy",
  "@id" : "{$url}",
  "tool_proxy_guid" : "{$toolproxy->guid}"
}
EOD;
            $response->set_code(201);
            $response->set_content_type('application/vnd.ims.lti.v2.toolproxy.id+json');
            $response->set_body($body);
        } else {
            $toolproxy->state = LTI_TOOL_PROXY_STATE_REJECTED;
            $response->set_code(400);
        }
        lti_update_tool_proxy($toolproxy);
    }
开发者ID:jtibbetts,项目名称:moodle,代码行数:83,代码来源:toolproxy.php


注:本文中的lti_add_type函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。