本文整理汇总了PHP中lti_get_type_config函数的典型用法代码示例。如果您正苦于以下问题:PHP lti_get_type_config函数的具体用法?PHP lti_get_type_config怎么用?PHP lti_get_type_config使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了lti_get_type_config函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: optional_param
$id = optional_param('id', 0, PARAM_INT);
// Course Module ID, or
$l = optional_param('l', 0, PARAM_INT);
// lti ID
if ($l) {
// Two ways to specify the module
$lti = $DB->get_record('lti', array('id' => $l), '*', MUST_EXIST);
$cm = get_coursemodule_from_instance('lti', $lti->id, $lti->course, false, MUST_EXIST);
} else {
$cm = get_coursemodule_from_id('lti', $id, 0, false, MUST_EXIST);
$lti = $DB->get_record('lti', array('id' => $cm->instance), '*', MUST_EXIST);
}
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
$tool = lti_get_tool_by_url_match($lti->toolurl);
if ($tool) {
$toolconfig = lti_get_type_config($tool->id);
} else {
$toolconfig = array();
}
$PAGE->set_cm($cm, $course);
// set's up global $COURSE
$context = context_module::instance($cm->id);
$PAGE->set_context($context);
$url = new moodle_url('/mod/lti/view.php', array('id' => $cm->id));
$PAGE->set_url($url);
$launchcontainer = lti_get_launch_container($lti, $toolconfig);
if ($launchcontainer == LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS) {
$PAGE->set_pagelayout('frametop');
//Most frametops don't include footer, and pre-post blocks
$PAGE->blocks->show_only_fake_blocks();
//Disable blocks for layouts which do include pre-post blocks
示例2: lti_get_coursemodule_info
/**
* Given a coursemodule object, this function returns the extra
* information needed to print this activity in various places.
* For this module we just need to support external urls as
* activity icons
*
* @param stdClass $coursemodule
* @return cached_cm_info info
*/
function lti_get_coursemodule_info($coursemodule)
{
global $DB, $CFG;
require_once $CFG->dirroot . '/mod/lti/locallib.php';
if (!($lti = $DB->get_record('lti', array('id' => $coursemodule->instance), 'icon, secureicon, intro, introformat, name, typeid, toolurl, launchcontainer'))) {
return null;
}
$info = new cached_cm_info();
if ($coursemodule->showdescription) {
// Convert intro to html. Do not filter cached version, filters run at display time.
$info->content = format_module_intro('lti', $lti, $coursemodule->id, false);
}
if (!empty($lti->typeid)) {
$toolconfig = lti_get_type_config($lti->typeid);
} else {
if ($tool = lti_get_tool_by_url_match($lti->toolurl)) {
$toolconfig = lti_get_type_config($tool->id);
} else {
$toolconfig = array();
}
}
// We want to use the right icon based on whether the
// current page is being requested over http or https.
if (lti_request_is_using_ssl() && (!empty($lti->secureicon) || isset($toolconfig['secureicon']) && !empty($toolconfig['secureicon']))) {
if (!empty($lti->secureicon)) {
$info->iconurl = new moodle_url($lti->secureicon);
} else {
$info->iconurl = new moodle_url($toolconfig['secureicon']);
}
} else {
if (!empty($lti->icon)) {
$info->iconurl = new moodle_url($lti->icon);
} else {
if (isset($toolconfig['icon']) && !empty($toolconfig['icon'])) {
$info->iconurl = new moodle_url($toolconfig['icon']);
}
}
}
// Does the link open in a new window?
$launchcontainer = lti_get_launch_container($lti, $toolconfig);
if ($launchcontainer == LTI_LAUNCH_CONTAINER_WINDOW) {
$launchurl = new moodle_url('/mod/lti/launch.php', array('id' => $coursemodule->id));
$info->onclick = "window.open('" . $launchurl->out(false) . "', 'lti'); return false;";
}
$info->name = $lti->name;
return $info;
}
示例3: definition
public function definition()
{
global $PAGE, $OUTPUT, $COURSE;
if ($type = optional_param('type', false, PARAM_ALPHA)) {
component_callback("ltisource_{$type}", 'add_instance_hook');
}
$this->typeid = 0;
$mform =& $this->_form;
// Adding the "general" fieldset, where all the common settings are shown.
$mform->addElement('header', 'general', get_string('general', 'form'));
// Adding the standard "name" field.
$mform->addElement('text', 'name', get_string('basicltiname', 'lti'), array('size' => '64'));
$mform->setType('name', PARAM_TEXT);
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
// Adding the optional "intro" and "introformat" pair of fields.
$this->standard_intro_elements(get_string('basicltiintro', 'lti'));
$mform->setAdvanced('introeditor');
// Display the label to the right of the checkbox so it looks better & matches rest of the form.
if ($mform->elementExists('showdescription')) {
$coursedesc = $mform->getElement('showdescription');
if (!empty($coursedesc)) {
$coursedesc->setText(' ' . $coursedesc->getLabel());
$coursedesc->setLabel(' ');
}
}
$mform->setAdvanced('showdescription');
$mform->addElement('checkbox', 'showtitlelaunch', ' ', ' ' . get_string('display_name', 'lti'));
$mform->setAdvanced('showtitlelaunch');
$mform->setDefault('showtitlelaunch', true);
$mform->addHelpButton('showtitlelaunch', 'display_name', 'lti');
$mform->addElement('checkbox', 'showdescriptionlaunch', ' ', ' ' . get_string('display_description', 'lti'));
$mform->setAdvanced('showdescriptionlaunch');
$mform->addHelpButton('showdescriptionlaunch', 'display_description', 'lti');
// Tool settings.
$attributes = array();
if ($update = optional_param('update', false, PARAM_INT)) {
$attributes['disabled'] = 'disabled';
}
$attributes['class'] = 'lti_contentitem';
$tooltypes = $mform->addElement('select', 'typeid', get_string('external_tool_type', 'lti'), array(), $attributes);
$typeid = optional_param('typeid', false, PARAM_INT);
$mform->getElement('typeid')->setValue($typeid);
$mform->addHelpButton('typeid', 'external_tool_type', 'lti');
$toolproxy = array();
// Array of tool type IDs that don't support ContentItemSelectionRequest.
$noncontentitemtypes = [];
foreach (lti_get_types_for_add_instance() as $id => $type) {
if (!empty($type->toolproxyid)) {
$toolproxy[] = $type->id;
$attributes = array('globalTool' => 1, 'toolproxy' => 1);
$enabledcapabilities = explode("\n", $type->enabledcapability);
if (!in_array('Result.autocreate', $enabledcapabilities)) {
$attributes['nogrades'] = 1;
}
if (!in_array('Person.name.full', $enabledcapabilities) && !in_array('Person.name.family', $enabledcapabilities) && !in_array('Person.name.given', $enabledcapabilities)) {
$attributes['noname'] = 1;
}
if (!in_array('Person.email.primary', $enabledcapabilities)) {
$attributes['noemail'] = 1;
}
} else {
if ($type->course == $COURSE->id) {
$attributes = array('editable' => 1, 'courseTool' => 1, 'domain' => $type->tooldomain);
} else {
if ($id != 0) {
$attributes = array('globalTool' => 1, 'domain' => $type->tooldomain);
} else {
$attributes = array();
}
}
}
if (!$update && $id) {
$config = lti_get_type_config($id);
if (!empty($config['contentitem'])) {
$attributes['data-contentitem'] = 1;
$attributes['data-id'] = $id;
} else {
$noncontentitemtypes[] = $id;
}
}
$tooltypes->addOption($type->name, $id, $attributes);
}
// Add button that launches the content-item selection dialogue.
// Set contentitem URL.
$contentitemurl = new moodle_url('/mod/lti/contentitem.php');
$contentbuttonattributes['data-contentitemurl'] = $contentitemurl->out(false);
$mform->addElement('button', 'selectcontent', get_string('selectcontent', 'lti'), $contentbuttonattributes);
if ($update) {
$mform->disabledIf('selectcontent', 'typeid', 'neq', 0);
} else {
// Disable select content button if the selected tool doesn't support content item or it's set to Automatic.
$allnoncontentitemtypes = $noncontentitemtypes;
$allnoncontentitemtypes[] = '0';
// Add option value for "Automatic, based on launch URL".
$mform->disabledIf('selectcontent', 'typeid', 'in', $allnoncontentitemtypes);
}
$mform->addElement('text', 'toolurl', get_string('launch_url', 'lti'), array('size' => '64'));
$mform->setType('toolurl', PARAM_URL);
$mform->addHelpButton('toolurl', 'launch_url', 'lti');
//.........这里部分代码省略.........
示例4: lti_get_type_type_config
/**
* Generates some of the tool configuration based on the admin configuration details
*
* @param int $id
*
* @return Configuration details
*/
function lti_get_type_type_config($id) {
global $DB;
$basicltitype = $DB->get_record('lti_types', array('id' => $id));
$config = lti_get_type_config($id);
$type = new stdClass();
$type->lti_typename = $basicltitype->name;
$type->typeid = $basicltitype->id;
$type->lti_toolurl = $basicltitype->baseurl;
if (isset($config['resourcekey'])) {
$type->lti_resourcekey = $config['resourcekey'];
}
if (isset($config['password'])) {
$type->lti_password = $config['password'];
}
if (isset($config['sendname'])) {
$type->lti_sendname = $config['sendname'];
}
if (isset($config['instructorchoicesendname'])) {
$type->lti_instructorchoicesendname = $config['instructorchoicesendname'];
}
if (isset($config['sendemailaddr'])) {
$type->lti_sendemailaddr = $config['sendemailaddr'];
}
if (isset($config['instructorchoicesendemailaddr'])) {
$type->lti_instructorchoicesendemailaddr = $config['instructorchoicesendemailaddr'];
}
if (isset($config['acceptgrades'])) {
$type->lti_acceptgrades = $config['acceptgrades'];
}
if (isset($config['instructorchoiceacceptgrades'])) {
$type->lti_instructorchoiceacceptgrades = $config['instructorchoiceacceptgrades'];
}
if (isset($config['allowroster'])) {
$type->lti_allowroster = $config['allowroster'];
}
if (isset($config['instructorchoiceallowroster'])) {
$type->lti_instructorchoiceallowroster = $config['instructorchoiceallowroster'];
}
if (isset($config['customparameters'])) {
$type->lti_customparameters = $config['customparameters'];
}
if (isset($config['forcessl'])) {
$type->lti_forcessl = $config['forcessl'];
}
if (isset($config['organizationid'])) {
$type->lti_organizationid = $config['organizationid'];
}
if (isset($config['organizationurl'])) {
$type->lti_organizationurl = $config['organizationurl'];
}
if (isset($config['organizationdescr'])) {
$type->lti_organizationdescr = $config['organizationdescr'];
}
if (isset($config['launchcontainer'])) {
$type->lti_launchcontainer = $config['launchcontainer'];
}
if (isset($config['coursevisible'])) {
$type->lti_coursevisible = $config['coursevisible'];
}
if (isset($config['debuglaunch'])) {
$type->lti_debuglaunch = $config['debuglaunch'];
}
if (isset($config['module_class_type'])) {
$type->lti_module_class_type = $config['module_class_type'];
}
return $type;
}
示例5: lti_get_type_config_by_instance
/**
* Fetches LTI type configuration for an LTI instance
*
* @param stdClass $instance
* @return array Can be empty if no type is found
*/
function lti_get_type_config_by_instance($instance)
{
$typeid = null;
if (empty($instance->typeid)) {
$tool = lti_get_tool_by_url_match($instance->toolurl, $instance->course);
if ($tool) {
$typeid = $tool->id;
}
} else {
$typeid = $instance->typeid;
}
if (!empty($typeid)) {
return lti_get_type_config($typeid);
}
return array();
}
示例6: test_mod_lti_create_tool_type
public function test_mod_lti_create_tool_type()
{
$type = mod_lti_external::create_tool_type($this->getExternalTestFileUrl('/ims_cartridge_basic_lti_link.xml'), '', '');
$this->assertEquals('Example tool', $type['name']);
$this->assertEquals('Example tool description', $type['description']);
$this->assertEquals($this->getExternalTestFileUrl('/test.jpg', true), $type['urls']['icon']);
$typeentry = lti_get_type($type['id']);
$this->assertEquals('http://www.example.com/lti/provider.php', $typeentry->baseurl);
$config = lti_get_type_config($type['id']);
$this->assertTrue(isset($config['sendname']));
$this->assertTrue(isset($config['sendemailaddr']));
$this->assertTrue(isset($config['acceptgrades']));
$this->assertTrue(isset($config['forcessl']));
}
示例7: test_lti_build_content_item_selection_request
/**
* Tests for lti_build_content_item_selection_request().
*/
public function test_lti_build_content_item_selection_request()
{
$this->resetAfterTest();
$this->setAdminUser();
// 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();
$data->lti_contentitem = true;
$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);
$typeconfig = lti_get_type_config($typeid);
$course = $this->getDataGenerator()->create_course();
$returnurl = new moodle_url('/');
// Default parameters.
$result = lti_build_content_item_selection_request($typeid, $course, $returnurl);
$this->assertNotEmpty($result);
$this->assertNotEmpty($result->params);
$this->assertNotEmpty($result->url);
$params = $result->params;
$url = $result->url;
$this->assertEquals($typeconfig['toolurl'], $url);
$this->assertEquals('ContentItemSelectionRequest', $params['lti_message_type']);
$this->assertEquals(LTI_VERSION_2, $params['lti_version']);
$this->assertEquals('application/vnd.ims.lti.v1.ltilink', $params['accept_media_types']);
$this->assertEquals('frame,iframe,window', $params['accept_presentation_document_targets']);
$this->assertEquals($returnurl->out(false), $params['content_item_return_url']);
$this->assertEquals('false', $params['accept_unsigned']);
$this->assertEquals('false', $params['accept_multiple']);
$this->assertEquals('false', $params['accept_copy_advice']);
$this->assertEquals('false', $params['auto_create']);
$this->assertEquals($type->name, $params['title']);
$this->assertFalse(isset($params['resource_link_id']));
$this->assertFalse(isset($params['resource_link_title']));
$this->assertFalse(isset($params['resource_link_description']));
$this->assertFalse(isset($params['launch_presentation_return_url']));
$this->assertFalse(isset($params['lis_result_sourcedid']));
// Custom parameters.
$title = 'My custom title';
$text = 'This is the tool description';
$mediatypes = ['image/*', 'video/*'];
$targets = ['embed', 'iframe'];
$result = lti_build_content_item_selection_request($typeid, $course, $returnurl, $title, $text, $mediatypes, $targets, true, true, true, true, true);
$this->assertNotEmpty($result);
$this->assertNotEmpty($result->params);
$this->assertNotEmpty($result->url);
$params = $result->params;
$this->assertEquals(implode(',', $mediatypes), $params['accept_media_types']);
$this->assertEquals(implode(',', $targets), $params['accept_presentation_document_targets']);
$this->assertEquals('true', $params['accept_unsigned']);
$this->assertEquals('true', $params['accept_multiple']);
$this->assertEquals('true', $params['accept_copy_advice']);
$this->assertEquals('true', $params['auto_create']);
$this->assertEquals($title, $params['title']);
$this->assertEquals($text, $params['text']);
// Invalid flag values.
$result = lti_build_content_item_selection_request($typeid, $course, $returnurl, $title, $text, $mediatypes, $targets, 'aa', -1, 0, 1, 0xabc);
$this->assertNotEmpty($result);
$this->assertNotEmpty($result->params);
$this->assertNotEmpty($result->url);
$params = $result->params;
$this->assertEquals(implode(',', $mediatypes), $params['accept_media_types']);
$this->assertEquals(implode(',', $targets), $params['accept_presentation_document_targets']);
$this->assertEquals('false', $params['accept_unsigned']);
$this->assertEquals('false', $params['accept_multiple']);
$this->assertEquals('false', $params['accept_copy_advice']);
$this->assertEquals('false', $params['auto_create']);
$this->assertEquals($title, $params['title']);
$this->assertEquals($text, $params['text']);
}