mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 17:06:53 +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
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();
|
Loading…
Add table
Add a link
Reference in a new issue