示例#1
0
/**
 * Loads the cartridge information into the new tool, if the launch url is for a cartridge file
 *
 * @param stdClass $lti The tools config
 * @since Moodle 3.1
 */
function lti_load_tool_if_cartridge($lti)
{
    if (!empty($lti->toolurl) && lti_is_cartridge($lti->toolurl)) {
        lti_load_tool_from_cartridge($lti->toolurl, $lti);
    }
}
示例#2
0
文件: ajax.php 项目: evltuma/moodle
 */
define('AJAX_SCRIPT', true);
require_once __DIR__ . "/../../config.php";
require_once $CFG->dirroot . '/mod/lti/locallib.php';
$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.
示例#3
0
 /**
  * Determine if the url to a tool is for a cartridge.
  *
  * @param string $url Url that may or may not be an xml cartridge
  * @return bool True if the url is for a cartridge.
  * @since Moodle 3.1
  * @throws moodle_exception
  */
 public static function is_cartridge($url)
 {
     $params = self::validate_parameters(self::is_cartridge_parameters(), array('url' => $url));
     $url = $params['url'];
     $context = context_system::instance();
     self::validate_context($context);
     require_capability('moodle/site:config', $context);
     $iscartridge = lti_is_cartridge($url);
     return array('iscartridge' => $iscartridge);
 }