From c4d80efeb660cdfe5736537d7a1db67f66749527 Mon Sep 17 00:00:00 2001
From: Chris Scribner
- If you have a consumer key and shared secret, you may enter it on the
- external tool instance (make sure advanced options are visible).
- Alternatively, you may create a course level tool provider configuration here.
+ If you have a consumer key and shared secret, you may enter it when editing the external tool instance (make sure advanced options are visible).
+ Alternatively, you may create a course level tool provider configuration here.
To submit a request for an administrator to complete the tool configuration, click here.
HTML; +$string['lti_tool_request_added'] = <<get_children_key_list(); + if(has_capability('mod/lti:grade', get_context_instance(CONTEXT_MODULE, $PAGE->cm->id))){ + $keys = $parentnode->get_children_key_list(); - $node = navigation_node::create('Submissions', - new moodle_url('/mod/lti/grade.php', array('id'=>$PAGE->cm->id)), - navigation_node::TYPE_SETTING, null, 'mod_lti_submissions'); - - $parentnode->add_node($node, $keys[1]); + $node = navigation_node::create('Submissions', + new moodle_url('/mod/lti/grade.php', array('id'=>$PAGE->cm->id)), + navigation_node::TYPE_SETTING, null, 'mod_lti_submissions'); + + $parentnode->add_node($node, $keys[1]); + } } \ No newline at end of file diff --git a/mod/lti/locallib.php b/mod/lti/locallib.php index 60233e32c8f..a2239f39fce 100644 --- a/mod/lti/locallib.php +++ b/mod/lti/locallib.php @@ -139,7 +139,7 @@ function lti_view($instance) { $requestparams = lti_build_request($instance, $typeconfig, $course); $launchcontainer = lti_get_launch_container($instance, $typeconfig); - $returnurlparams = array('course' => $course->id, 'launch_container' => $launchcontainer); + $returnurlparams = array('course' => $course->id, 'launch_container' => $launchcontainer, 'instanceid' => $instance->id); if ( $orgid ) { $requestparams["tool_consumer_instance_guid"] = $orgid; @@ -149,8 +149,8 @@ function lti_view($instance) { $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); - $parms['launch_presentation_return_url'] = $url->out(false); + $url = new moodle_url('/mod/lti/return.php', $returnurlparams); + $requestparams['launch_presentation_return_url'] = $url->out(false); } if(!empty($key) && !empty($secret)){ @@ -1102,9 +1102,17 @@ function lti_get_type($typeid){ } function lti_get_launch_container($lti, $toolconfig){ - $launchcontainer = $lti->launchcontainer == LTI_LAUNCH_CONTAINER_DEFAULT ? - $toolconfig['launchcontainer'] : - $lti->launchcontainer; + if($lti->launchcontainer == LTI_LAUNCH_CONTAINER_DEFAULT){ + if(isset($toolconfig['launchcontainer'])){ + $launchcontainer = $toolconfig['launchcontainer']; + } + } else { + $launchcontainer = $lti->launchcontainer; + } + + if(empty($launchcontainer) || $launchcontainer == LTI_LAUNCH_CONTAINER_DEFAULT){ + $launchcontainer = LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS; + } $devicetype = get_device_type(); diff --git a/mod/lti/request_tool.php b/mod/lti/request_tool.php new file mode 100644 index 00000000000..80e50af7499 --- /dev/null +++ b/mod/lti/request_tool.php @@ -0,0 +1,44 @@ +dirroot.'/mod/lti/lib.php'); + +$instanceid = required_param('instanceid', PARAM_INT); + +$lti = $DB->get_record('lti', array('id' => $instanceid)); +$course = $DB->get_record('course', array('id' => $lti->course)); + +require_login($course); + +require_capability('mod/lti:requesttooladd', get_context_instance(CONTEXT_COURSE, $lti->course)); + +$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(); + +//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(); \ No newline at end of file diff --git a/mod/lti/return.php b/mod/lti/return.php index 87719617d80..fe84ac4e869 100644 --- a/mod/lti/return.php +++ b/mod/lti/return.php @@ -6,8 +6,11 @@ require_once('../../config.php'); require_once($CFG->dirroot.'/mod/lti/lib.php'); $courseid = required_param('course', PARAM_INT); +$instanceid = required_param('instanceid', PARAM_INT); + $errormsg = optional_param('lti_errormsg', '', PARAM_RAW); $unsigned = optional_param('unsigned', '0', PARAM_INT); + $launchcontainer = optional_param('launch_container', LTI_LAUNCH_CONTAINER_WINDOW, PARAM_INT); $course = $DB->get_record('course', array('id' => $courseid)); @@ -28,17 +31,28 @@ if(!empty($errormsg)){ } else { $PAGE->set_pagelayout('incourse'); } - + echo $OUTPUT->header(); echo get_string('lti_launch_error', 'lti'); - //TODO: Add some help around this error message. echo htmlspecialchars($errormsg); - if($unsigned == 1){ + $canaddtools = has_capability('mod/lti:addcoursetool', get_context_instance(CONTEXT_COURSE, $courseid)); + + if($unsigned == 1 && $canaddtools){ echo '