Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

More work on the tool return page to help the user get the tool confi…

…gured.
  • Loading branch information...
commit c4d80efeb660cdfe5736537d7a1db67f66749527 1 parent 9d57ad1
scriby scriby authored
20 mod/lti/db/access.php
View
@@ -68,4 +68,24 @@
'manager' => CAP_ALLOW
)
),
+
+ 'mod/lti:addcoursetool' => array(
+ 'captype' => 'write',
+ 'contextlevel' => CONTEXT_COURSE,
+ 'archetypes' => array(
+ 'teacher' => CAP_ALLOW,
+ 'editingteacher' => CAP_ALLOW,
+ 'manager' => CAP_ALLOW
+ )
+ ),
+
+ 'mod/lti:requesttooladd' => array(
+ 'captype' => 'write',
+ 'contextlevel' => CONTEXT_COURSE,
+ 'archetypes' => array(
+ 'teacher' => CAP_ALLOW,
+ 'editingteacher' => CAP_ALLOW,
+ 'manager' => CAP_ALLOW
+ )
+ )
);
4 mod/lti/instructor_edit_tool_type.php
View
@@ -12,6 +12,8 @@
$action = optional_param('action', null, PARAM_TEXT);
$typeid = optional_param('typeid', null, PARAM_INT);
+require_capability('mod/lti:addcoursetool', get_context_instance(CONTEXT_COURSE, $courseid));
+
if(!empty($typeid)){
$type = lti_get_type($typeid);
if($type->course != $courseid){
@@ -25,7 +27,7 @@
$data = data_submitted();
-if (confirm_sesskey() && isset($data->submitbutton)) {
+if (isset($data->submitbutton) && confirm_sesskey()) {
$type = new stdClass();
if (!empty($typeid)) {
21 mod/lti/lang/en/lti.php
View
@@ -45,6 +45,12 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
+//Permissions
+$string['lti:view'] = 'View LTI activities';
+$string['lti:grade'] = 'Grade LTI activities';
+$string['lti:addcoursetool'] = 'Grade LTI activities';
+$string['lti:requesttooladd'] = 'Submit a tool to admins for configuration';
+
$string['accept'] = 'Accept';
$string['activity'] = 'Activity';
$string['addnewapp'] = 'Enable External Application';
@@ -217,15 +223,24 @@
This error may be a result of a missing consumer key and shared secret for the tool provider.
</p>
<p>
- If you have a consumer key and shared secret, you may enter it on the
- <a href="{$a->instance_edit_url}" target="_top">external tool instance</a> (make sure advanced options are visible).<br />
- Alternatively, you may create a course level tool provider configuration <a href="{$a->course_tool_editor}" target="_top">here</a>.
+ 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).<br />
+ Alternatively, you may create a course level tool provider configuration <a href="{$a->course_tool_editor}">here</a>.
</p>
+HTML;
+$string['lti_launch_error_tool_request'] = <<<'HTML'
<p>
To submit a request for an administrator to complete the tool configuration, click <a href="{$a->admin_request_url}" target="_top">here</a>.
</p>
HTML;
+$string['lti_tool_request_added'] = <<<HTML
+ Tool configuration request successfully submitted. You may need to contact an administrator to complete the tool configuration.
+HTML;
+
+$string['lti_tool_request_existing'] = <<<HTML
+ A tool configuration for the tool domain has already been submitted.
+HTML;
+
//Instance help
$string['external_tool_type_help'] = <<<HTML
14 mod/lti/lib.php
View
@@ -384,11 +384,13 @@ function lti_grade_item_delete($basiclti) {
function lti_extend_settings_navigation($settings, $parentnode) {
global $PAGE;
- $keys = $parentnode->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]);
+ }
}
20 mod/lti/locallib.php
View
@@ -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();
44 mod/lti/request_tool.php
View
@@ -0,0 +1,44 @@
+<?php
+
+require_once('../../config.php');
+require_once($CFG->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();
22 mod/lti/return.php
View
@@ -6,8 +6,11 @@
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 @@
} 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 '<br /><br />';
- echo get_string('lti_launch_error_unsigned_help', 'lti');
+
+ $links = new stdClass();
+ $coursetooleditor = new moodle_url('/mod/lti/instructor_edit_tool_type.php', array('course' => $courseid, 'action' => 'add'));
+ $links->course_tool_editor = $coursetooleditor->out(false);
+
+ $adminrequesturl = new moodle_url('/mod/lti/request_tool.php', array('instanceid' => $instanceid));
+ $links->admin_request_url = $adminrequesturl->out(false);
+
+ echo get_string('lti_launch_error_unsigned_help', 'lti', $links);
+
+ echo get_string('lti_launch_error_tool_request', 'lti', $links);
}
echo $OUTPUT->footer();
2  mod/lti/version.php
View
@@ -46,5 +46,5 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-$module->version = 2011100701; // The current module version (Date: YYYYMMDDXX)
+$module->version = 2011101201; // The current module version (Date: YYYYMMDDXX)
$module->cron = 0; // Period for cron to check this module (secs)
2  mod/lti/view.php
View
@@ -81,7 +81,7 @@
if($tool){
$toolconfig = lti_get_type_config($tool->id);
} else {
- $toolconfig = array('launchcontainer' => LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS);
+ $toolconfig = array();
}
$PAGE->set_cm($cm, $course); // set's up global $COURSE
Please sign in to comment.
Something went wrong with that request. Please try again.