mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
More work on the tool return page to help the user get the tool configured.
This commit is contained in:
parent
9d57ad1737
commit
c4d80efeb6
9 changed files with 127 additions and 22 deletions
|
@ -68,4 +68,24 @@ $capabilities = array(
|
|||
'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
|
||||
)
|
||||
)
|
||||
);
|
||||
|
|
|
@ -12,6 +12,8 @@ $PAGE->set_pagelayout('popup');
|
|||
$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 @@ echo $OUTPUT->header();
|
|||
|
||||
$data = data_submitted();
|
||||
|
||||
if (confirm_sesskey() && isset($data->submitbutton)) {
|
||||
if (isset($data->submitbutton) && confirm_sesskey()) {
|
||||
$type = new stdClass();
|
||||
|
||||
if (!empty($typeid)) {
|
||||
|
|
|
@ -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 @@ $string['lti_launch_error_unsigned_help'] = <<<'HTML'
|
|||
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
|
||||
|
|
|
@ -384,6 +384,7 @@ function lti_grade_item_delete($basiclti) {
|
|||
function lti_extend_settings_navigation($settings, $parentnode) {
|
||||
global $PAGE;
|
||||
|
||||
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',
|
||||
|
@ -391,4 +392,5 @@ function lti_extend_settings_navigation($settings, $parentnode) {
|
|||
navigation_node::TYPE_SETTING, null, 'mod_lti_submissions');
|
||||
|
||||
$parentnode->add_node($node, $keys[1]);
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
@ -150,7 +150,7 @@ function lti_view($instance) {
|
|||
|
||||
//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);
|
||||
$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
Normal file
44
mod/lti/request_tool.php
Normal file
|
@ -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();
|
|
@ -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));
|
||||
|
@ -33,12 +36,23 @@ if(!empty($errormsg)){
|
|||
|
||||
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();
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -81,7 +81,7 @@ $tool = lti_get_tool_by_url_match($basiclti->toolurl);
|
|||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue