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


PHP lti_get_tool_by_url_match函数代码示例

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


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

示例1: lti_get_domain_from_url

$baseurl = lti_get_domain_from_url($lti->toolurl);

$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,代码行数:31,代码来源:request_tool.php

示例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;
}
开发者ID:Gavinthisisit,项目名称:Moodle,代码行数:56,代码来源:lib.php

示例3: required_param

$courseid = required_param('course', PARAM_INT);
$context = context_course::instance($courseid);
require_login($courseid, false);
$action = required_param('action', PARAM_TEXT);
$response = new stdClass();
switch ($action) {
    case 'find_tool_config':
        $toolurl = required_param('toolurl', PARAM_RAW);
        $toolid = optional_param('toolid', 0, PARAM_INT);
        require_capability('moodle/course:manageactivities', $context);
        require_capability('mod/lti:addinstance', $context);
        if (!empty($toolurl) && lti_is_cartridge($toolurl)) {
            $response->cartridge = true;
        } else {
            if (empty($toolid) && !empty($toolurl)) {
                $tool = lti_get_tool_by_url_match($toolurl, $courseid);
                if (!empty($tool)) {
                    $toolid = $tool->id;
                    $response->toolid = $tool->id;
                    $response->toolname = s($tool->name);
                    $response->tooldomain = s($tool->tooldomain);
                }
            } else {
                $response->toolid = $toolid;
            }
            if (!empty($toolid)) {
                // Look up privacy settings.
                $query = '
                    SELECT name, value
                    FROM {lti_types_config}
                    WHERE
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:ajax.php

示例4: optional_param

require_once $CFG->dirroot . '/mod/lti/lib.php';
require_once $CFG->dirroot . '/mod/lti/locallib.php';
$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
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:31,代码来源:view.php

示例5: lti_view

/**
 * Prints a Basic LTI activity
 *
 * $param int $basicltiid       Basic LTI activity id
 */
function lti_view($instance) {
    global $PAGE, $CFG;

    if (empty($instance->typeid)) {
        $tool = lti_get_tool_by_url_match($instance->toolurl, $instance->course);
        if ($tool) {
            $typeid = $tool->id;
        } else {
            $typeid = null;
        }
    } else {
        $typeid = $instance->typeid;
    }

    if ($typeid) {
        $typeconfig = lti_get_type_config($typeid);
    } else {
        //There is no admin configuration for this tool. Use configuration in the lti instance record plus some defaults.
        $typeconfig = (array)$instance;

        $typeconfig['sendname'] = $instance->instructorchoicesendname;
        $typeconfig['sendemailaddr'] = $instance->instructorchoicesendemailaddr;
        $typeconfig['customparameters'] = $instance->instructorcustomparameters;
        $typeconfig['acceptgrades'] = $instance->instructorchoiceacceptgrades;
        $typeconfig['allowroster'] = $instance->instructorchoiceallowroster;
        $typeconfig['forcessl'] = '0';
    }

    //Default the organizationid if not specified
    if (empty($typeconfig['organizationid'])) {
        $urlparts = parse_url($CFG->wwwroot);

        $typeconfig['organizationid'] = $urlparts['host'];
    }

    if (!empty($instance->resourcekey)) {
        $key = $instance->resourcekey;
    } else if (!empty($typeconfig['resourcekey'])) {
        $key = $typeconfig['resourcekey'];
    } else {
        $key = '';
    }

    if (!empty($instance->password)) {
        $secret = $instance->password;
    } else if (!empty($typeconfig['password'])) {
        $secret = $typeconfig['password'];
    } else {
        $secret = '';
    }

    $endpoint = !empty($instance->toolurl) ? $instance->toolurl : $typeconfig['toolurl'];
    $endpoint = trim($endpoint);

    //If the current request is using SSL and a secure tool URL is specified, use it
    if (lti_request_is_using_ssl() && !empty($instance->securetoolurl)) {
        $endpoint = trim($instance->securetoolurl);
    }

    //If SSL is forced, use the secure tool url if specified. Otherwise, make sure https is on the normal launch URL.
    if ($typeconfig['forcessl'] == '1') {
        if (!empty($instance->securetoolurl)) {
            $endpoint = trim($instance->securetoolurl);
        }

        $endpoint = lti_ensure_url_is_https($endpoint);
    } else {
        if (!strstr($endpoint, '://')) {
            $endpoint = 'http://' . $endpoint;
        }
    }

    $orgid = $typeconfig['organizationid'];

    $course = $PAGE->course;
    $requestparams = lti_build_request($instance, $typeconfig, $course);

    $launchcontainer = lti_get_launch_container($instance, $typeconfig);
    $returnurlparams = array('course' => $course->id, 'launch_container' => $launchcontainer, 'instanceid' => $instance->id);

    if ( $orgid ) {
        $requestparams["tool_consumer_instance_guid"] = $orgid;
    }

    if (empty($key) || empty($secret)) {
        $returnurlparams['unsigned'] = '1';

        //Add the return URL. We send the launch container along to help us avoid frames-within-frames when the user returns
        $url = new moodle_url('/mod/lti/return.php', $returnurlparams);
        $returnurl = $url->out(false);

        if ($typeconfig['forcessl'] == '1') {
            $returnurl = lti_ensure_url_is_https($returnurl);
        }

//.........这里部分代码省略.........
开发者ID:numbas,项目名称:moodle,代码行数:101,代码来源:locallib.php

示例6: optional_param

$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);

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();
}

$PAGE->set_cm($cm, $course); // Set's up global $COURSE.
$context = context_module::instance($cm->id);
$PAGE->set_context($context);

require_login($course, true, $cm);
require_capability('mod/lti:view', $context);

$url = new moodle_url('/mod/lti/view.php', array('id' => $cm->id));
$PAGE->set_url($url);
开发者ID:rezaies,项目名称:moodle,代码行数:30,代码来源:view.php

示例7: 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();
}
开发者ID:reconnectmedia,项目名称:moodle,代码行数:22,代码来源:locallib.php


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