return false;
}
-function handleOAuthBodyPOST($oauth_consumer_key, $oauth_consumer_secret)
+function handleOAuthBodyPOST($oauth_consumer_key, $oauth_consumer_secret, $body, $request_headers = null)
{
- $request_headers = OAuthUtil::get_headers();
- // print_r($request_headers);
+ if($request_headers == null){
+ $request_headers = OAuthUtil::get_headers();
+ }
// Must reject application/x-www-form-urlencoded
if ($request_headers['Content-type'] == 'application/x-www-form-urlencoded' ) {
throw new Exception("OAuth signature failed: " . $message);
}
- $postdata = file_get_contents('php://input');
+ $postdata = $body;
// echo($postdata);
$hash = base64_encode(sha1($postdata, TRUE));
else {
ele.style.display = 'block';
}
-}
-
-alert('a');
\ No newline at end of file
+}
\ No newline at end of file
-<?php\r
-// This file is part of BasicLTI4Moodle\r
-//\r
-// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)\r
-// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web\r
-// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI\r
-// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS\r
-// are already supporting or going to support BasicLTI. This project Implements the consumer\r
-// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.\r
-// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem\r
-// at the GESSI research group at UPC.\r
-// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI\r
-// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a\r
-// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.\r
-//\r
-// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis\r
-// of the Universitat Politecnica de Catalunya http://www.upc.edu\r
-// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu\r
-//\r
-// Moodle is free software: you can redistribute it and/or modify\r
-// it under the terms of the GNU General Public License as published by\r
-// the Free Software Foundation, either version 3 of the License, or\r
-// (at your option) any later version.\r
-//\r
-// Moodle is distributed in the hope that it will be useful,\r
-// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-// GNU General Public License for more details.\r
-//\r
-// You should have received a copy of the GNU General Public License\r
-// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\r
-\r
-/**\r
- * This file defines de main basiclti configuration form\r
- *\r
- * @package lti\r
- * @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis\r
- * marc.alier@upc.edu\r
- * @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu\r
- *\r
- * @author Marc Alier\r
- * @author Jordi Piguillem\r
- * @author Nikolas Galanis\r
- * @author Charles Severance\r
- *\r
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r
- */\r
-\r
-defined('MOODLE_INTERNAL') || die;\r
-\r
-require_once($CFG->libdir.'/formslib.php');\r
-\r
-class mod_lti_edit_types_form extends moodleform{\r
-\r
- function definition() {\r
- $mform =& $this->_form;\r
-\r
-//-------------------------------------------------------------------------------\r
- // Add basiclti elements\r
- $mform->addElement('header', 'setup', get_string('tool_settings', 'lti'));\r
- \r
- $mform->addElement('text', 'lti_typename', get_string('typename', 'lti'));\r
- $mform->setType('lti_typename', PARAM_INT);\r
-// $mform->addHelpButton('lti_typename', 'typename','lti');\r
- $mform->addRule('lti_typename', null, 'required', null, 'client');\r
-\r
- $mform->addElement('text', 'lti_toolurl', get_string('toolurl', 'lti'), array('size'=>'64'));\r
- $mform->setType('lti_toolurl', PARAM_TEXT);\r
-// $mform->addHelpButton('lti_toolurl', 'toolurl', 'lti');\r
- $mform->addRule('lti_toolurl', null, 'required', null, 'client');\r
-\r
- $mform->addElement('text', 'lti_resourcekey', get_string('resourcekey', 'lti'));\r
- $mform->setType('lti_resourcekey', PARAM_TEXT);\r
-\r
- $mform->addElement('passwordunmask', 'lti_password', get_string('password', 'lti'));\r
- $mform->setType('lti_password', PARAM_TEXT);\r
-\r
- $mform->addElement('textarea', 'lti_customparameters', get_string('custom', 'lti'), array('rows'=>4, 'cols'=>60));\r
- $mform->setType('lti_customparameters', PARAM_TEXT);\r
- \r
- $mform->addElement('checkbox', 'lti_coursevisible', ' ', ' ' . get_string('show_in_course', 'lti'));\r
- \r
- $launchoptions=array();\r
- $launchoptions[LTI_LAUNCH_CONTAINER_EMBED] = get_string('embed', 'lti');\r
- $launchoptions[LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS] = get_string('embed_no_blocks', 'lti');\r
- $launchoptions[LTI_LAUNCH_CONTAINER_WINDOW] = get_string('new_window', 'lti');\r
-\r
- $mform->addElement('select', 'lti_launchcontainer', get_string('default_launch_container', 'lti'), $launchoptions);\r
- $mform->setDefault('lti_launchcontainer', LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS);\r
-// $mform->addHelpButton('lti_launchinpopup', 'launchinpopup', 'lti');\r
- \r
- // Add privacy preferences fieldset where users choose whether to send their data\r
- $mform->addElement('header', 'privacy', get_string('privacy', 'lti'));\r
-\r
- $options=array();\r
- $options[0] = get_string('never', 'lti');\r
- $options[1] = get_string('always', 'lti');\r
- $options[2] = get_string('delegate_yes', 'lti');\r
- $options[3] = get_string('delegate_no', 'lti');\r
-\r
- $mform->addElement('select', 'lti_sendname', get_string('sendname', 'lti'), $options);\r
- $mform->setDefault('lti_sendname', '2');\r
-// $mform->addHelpButton('lti_sendname', 'sendname', 'lti');\r
-\r
- $mform->addElement('select', 'lti_sendemailaddr', get_string('sendemailaddr', 'lti'), $options);\r
- $mform->setDefault('lti_sendemailaddr', '2');\r
-// $mform->addHelpButton('lti_sendemailaddr', 'sendemailaddr', 'lti');\r
-\r
-//-------------------------------------------------------------------------------\r
- // LTI Extensions\r
-\r
- // Add grading preferences fieldset where the tool is allowed to return grades\r
- $mform->addElement('select', 'lti_acceptgrades', get_string('acceptgrades', 'lti'), $options);\r
- $mform->setDefault('lti_acceptgrades', '2');\r
-// $mform->addHelpButton('lti_acceptgrades', 'acceptgrades', 'lti');\r
-\r
- // Add grading preferences fieldset where the tool is allowed to retrieve rosters\r
- $mform->addElement('select', 'lti_allowroster', get_string('allowroster', 'lti'), $options);\r
- $mform->setDefault('lti_allowroster', '2');\r
-// $mform->addHelpButton('lti_allowroster', 'allowroster', 'lti');\r
-\r
- \r
-//-------------------------------------------------------------------------------\r
- // Add setup parameters fieldset\r
- $mform->addElement('header', 'setupoptions', get_string('miscellaneous', 'lti'));\r
-\r
- // Adding option to change id that is placed in context_id\r
- $idoptions = array();\r
- $idoptions[0] = get_string('id', 'lti');\r
- $idoptions[1] = get_string('courseid', 'lti');\r
-\r
- $mform->addElement('text', 'lti_organizationid', get_string('organizationid', 'lti'));\r
- $mform->setType('lti_organizationid', PARAM_TEXT);\r
-// $mform->addHelpButton('lti_organizationid', 'organizationid', 'lti');\r
-\r
- $mform->addElement('text', 'lti_organizationurl', get_string('organizationurl', 'lti'));\r
- $mform->setType('lti_organizationurl', PARAM_TEXT);\r
-// $mform->addHelpButton('lti_organizationurl', 'organizationurl', 'lti');\r
-\r
- /* Suppress this for now - Chuck\r
- $mform->addElement('text', 'lti_organizationdescr', get_string('organizationdescr', 'lti'));\r
- $mform->setType('lti_organizationdescr', PARAM_TEXT);\r
- $mform->addHelpButton('lti_organizationdescr', 'organizationdescr', 'lti');\r
- */\r
-\r
-//-------------------------------------------------------------------------------\r
- // Add a hidden element to signal a tool fixing operation after a problematic backup - restore process\r
- $mform->addElement('hidden', 'lti_fix');\r
- \r
- $tab = optional_param('tab', '', PARAM_ALPHAEXT);\r
- $mform->addElement('hidden', 'tab', $tab);\r
- \r
-\r
-//-------------------------------------------------------------------------------\r
- // Add standard buttons, common to all modules\r
- $this->add_action_buttons();\r
-\r
- }\r
-}\r
+<?php
+// This file is part of BasicLTI4Moodle
+//
+// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
+// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
+// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
+// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
+// are already supporting or going to support BasicLTI. This project Implements the consumer
+// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
+// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
+// at the GESSI research group at UPC.
+// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
+// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
+// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
+//
+// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
+// of the Universitat Politecnica de Catalunya http://www.upc.edu
+// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * This file defines de main basiclti configuration form
+ *
+ * @package lti
+ * @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
+ * marc.alier@upc.edu
+ * @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
+ *
+ * @author Marc Alier
+ * @author Jordi Piguillem
+ * @author Nikolas Galanis
+ * @author Charles Severance
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die;
+
+require_once($CFG->libdir.'/formslib.php');
+require_once($CFG->dirroot.'/mod/lti/locallib.php');
+
+class mod_lti_edit_types_form extends moodleform{
+ function definition() {
+ $mform =& $this->_form;
+
+//-------------------------------------------------------------------------------
+ // Add basiclti elements
+ $mform->addElement('header', 'setup', get_string('tool_settings', 'lti'));
+
+ $mform->addElement('text', 'lti_typename', get_string('typename', 'lti'));
+ $mform->setType('lti_typename', PARAM_INT);
+// $mform->addHelpButton('lti_typename', 'typename','lti');
+ $mform->addRule('lti_typename', null, 'required', null, 'client');
+
+ $mform->addElement('text', 'lti_toolurl', get_string('toolurl', 'lti'), array('size'=>'64'));
+ $mform->setType('lti_toolurl', PARAM_TEXT);
+// $mform->addHelpButton('lti_toolurl', 'toolurl', 'lti');
+ $mform->addRule('lti_toolurl', null, 'required', null, 'client');
+
+ $mform->addElement('text', 'lti_resourcekey', get_string('resourcekey', 'lti'));
+ $mform->setType('lti_resourcekey', PARAM_TEXT);
+
+ $mform->addElement('passwordunmask', 'lti_password', get_string('password', 'lti'));
+ $mform->setType('lti_password', PARAM_TEXT);
+
+ $mform->addElement('textarea', 'lti_customparameters', get_string('custom', 'lti'), array('rows'=>4, 'cols'=>60));
+ $mform->setType('lti_customparameters', PARAM_TEXT);
+
+ if(!empty($this->_customdata->isadmin)){
+ $mform->addElement('checkbox', 'lti_coursevisible', ' ', ' ' . get_string('show_in_course', 'lti'));
+ } else {
+ $mform->addElement('hidden', 'lti_coursevisible', '1');
+ }
+
+ $launchoptions=array();
+ $launchoptions[LTI_LAUNCH_CONTAINER_EMBED] = get_string('embed', 'lti');
+ $launchoptions[LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS] = get_string('embed_no_blocks', 'lti');
+ $launchoptions[LTI_LAUNCH_CONTAINER_WINDOW] = get_string('new_window', 'lti');
+
+ $mform->addElement('select', 'lti_launchcontainer', get_string('default_launch_container', 'lti'), $launchoptions);
+ $mform->setDefault('lti_launchcontainer', LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS);
+// $mform->addHelpButton('lti_launchinpopup', 'launchinpopup', 'lti');
+
+ // Add privacy preferences fieldset where users choose whether to send their data
+ $mform->addElement('header', 'privacy', get_string('privacy', 'lti'));
+
+ $options=array();
+ $options[0] = get_string('never', 'lti');
+ $options[1] = get_string('always', 'lti');
+ $options[2] = get_string('delegate', 'lti');
+
+ $mform->addElement('select', 'lti_sendname', get_string('sendname', 'lti'), $options);
+ $mform->setDefault('lti_sendname', '2');
+// $mform->addHelpButton('lti_sendname', 'sendname', 'lti');
+
+ $mform->addElement('select', 'lti_sendemailaddr', get_string('sendemailaddr', 'lti'), $options);
+ $mform->setDefault('lti_sendemailaddr', '2');
+// $mform->addHelpButton('lti_sendemailaddr', 'sendemailaddr', 'lti');
+
+//-------------------------------------------------------------------------------
+ // LTI Extensions
+
+ // Add grading preferences fieldset where the tool is allowed to return grades
+ $mform->addElement('select', 'lti_acceptgrades', get_string('acceptgrades', 'lti'), $options);
+ $mform->setDefault('lti_acceptgrades', '2');
+// $mform->addHelpButton('lti_acceptgrades', 'acceptgrades', 'lti');
+
+ // Add grading preferences fieldset where the tool is allowed to retrieve rosters
+ $mform->addElement('select', 'lti_allowroster', get_string('allowroster', 'lti'), $options);
+ $mform->setDefault('lti_allowroster', '2');
+// $mform->addHelpButton('lti_allowroster', 'allowroster', 'lti');
+
+
+ if(!empty($this->_customdata->isadmin)){
+ //-------------------------------------------------------------------------------
+ // Add setup parameters fieldset
+ $mform->addElement('header', 'setupoptions', get_string('miscellaneous', 'lti'));
+
+ // Adding option to change id that is placed in context_id
+ $idoptions = array();
+ $idoptions[0] = get_string('id', 'lti');
+ $idoptions[1] = get_string('courseid', 'lti');
+
+ $mform->addElement('text', 'lti_organizationid', get_string('organizationid', 'lti'));
+ $mform->setType('lti_organizationid', PARAM_TEXT);
+ // $mform->addHelpButton('lti_organizationid', 'organizationid', 'lti');
+
+ $mform->addElement('text', 'lti_organizationurl', get_string('organizationurl', 'lti'));
+ $mform->setType('lti_organizationurl', PARAM_TEXT);
+ // $mform->addHelpButton('lti_organizationurl', 'organizationurl', 'lti');
+ }
+
+ /* Suppress this for now - Chuck
+ $mform->addElement('text', 'lti_organizationdescr', get_string('organizationdescr', 'lti'));
+ $mform->setType('lti_organizationdescr', PARAM_TEXT);
+ $mform->addHelpButton('lti_organizationdescr', 'organizationdescr', 'lti');
+ */
+
+//-------------------------------------------------------------------------------
+ // Add a hidden element to signal a tool fixing operation after a problematic backup - restore process
+ //$mform->addElement('hidden', 'lti_fix');
+
+ $tab = optional_param('tab', '', PARAM_ALPHAEXT);
+ $mform->addElement('hidden', 'tab', $tab);
+
+ $courseid = optional_param('course', 1, PARAM_INT);
+ $mform->addElement('hidden', 'course', $courseid);
+
+//-------------------------------------------------------------------------------
+ // Add standard buttons, common to all modules
+ $this->add_action_buttons();
+
+ }
+}
--- /dev/null
+<?php
+require_once('../../config.php');
+require_once($CFG->dirroot.'/mod/lti/edit_form.php');
+
+$courseid = required_param('course', PARAM_INT);
+
+require_login($courseid, false);
+$url = new moodle_url('/mod/lti/instructor_edit_tool_type.php');
+$PAGE->set_url($url);
+$PAGE->set_pagelayout('popup');
+
+$action = optional_param('action', null, PARAM_TEXT);
+$typeid = optional_param('typeid', null, PARAM_INT);
+
+if(!empty($typeid)){
+ $type = lti_get_type($typeid);
+ if($type->course != $courseid){
+ throw new Exception('You do not have permissions to edit this tool type.');
+
+ die;
+ }
+}
+
+echo $OUTPUT->header();
+
+$data = data_submitted();
+
+if (confirm_sesskey() && isset($data->submitbutton)) {
+ $type = new stdClass();
+
+ if (isset($id)) {
+ /*$type->id = $id;
+
+ lti_update_type($type, $data);
+ $script = <<<SCRIPT
+ <script type="text/javascript">
+ window.opener.M.mod_lti.editor.updateToolType({$name}, '{$id}');
+
+ window.close();
+ </script>
+SCRIPT;*/
+
+ die;
+ } else {
+ $type->state = LTI_TOOL_STATE_CONFIGURED;
+ $type->course = $COURSE->id;
+
+ $id = lti_add_type($type, $data);
+ $name = json_encode($type->name);
+
+ $script = <<<SCRIPT
+ <script type="text/javascript">
+ window.opener.M.mod_lti.editor.addToolType({$name}, '{$id}');
+
+ window.close();
+ </script>
+SCRIPT;
+
+ echo $script;
+
+ die;
+ }
+} else if(isset($data->cancel)){
+ $script = <<<SCRIPT
+ <script type="text/javascript">
+ window.close();
+ </script>
+SCRIPT;
+
+ echo $script;
+ die;
+}
+
+//Delete action is called via ajax
+if ($action == 'delete'){
+ lti_delete_type($typeid);
+
+ die;
+}
+
+echo $OUTPUT->heading(get_string('toolsetup', 'lti'));
+
+if($action == 'add') {
+ $form = new mod_lti_edit_types_form();
+ $form->display();
+} else if($action == 'edit'){
+ $form = new mod_lti_edit_types_form();
+ $type = lti_get_type_type_config($typeid);
+ $form->set_data($type);
+ $form->display();
+}
+
+echo $OUTPUT->footer();
-<?php\r
-// This file is part of BasicLTI4Moodle\r
-//\r
-// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)\r
-// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web\r
-// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI\r
-// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS\r
-// are already supporting or going to support BasicLTI. This project Implements the consumer\r
-// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.\r
-// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem\r
-// at the GESSI research group at UPC.\r
-// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI\r
-// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a\r
-// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.\r
-//\r
-// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis\r
-// of the Universitat Politecnica de Catalunya http://www.upc.edu\r
-// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu\r
-//\r
-// Moodle is free software: you can redistribute it and/or modify\r
-// it under the terms of the GNU General Public License as published by\r
-// the Free Software Foundation, either version 3 of the License, or\r
-// (at your option) any later version.\r
-//\r
-// Moodle is distributed in the hope that it will be useful,\r
-// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-// GNU General Public License for more details.\r
-//\r
-// You should have received a copy of the GNU General Public License\r
-// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\r
-\r
-/**\r
- * This file contains en_utf8 translation of the Basic LTI module\r
- *\r
- * @package basiclti\r
- * @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis\r
- * marc.alier@upc.edu\r
- * @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu\r
- *\r
- * @author Marc Alier\r
- * @author Jordi Piguillem\r
- * @author Nikolas Galanis\r
- *\r
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r
- */\r
-\r
-$string['accept'] = 'Accept';\r
-$string['acceptgrades'] = 'Accept grades from tool';\r
-$string['activity'] = 'Activity';\r
-$string['addnewapp'] = 'Enable External Application';\r
-$string['addserver'] = 'Add new trusted server';\r
-$string['addtype'] = 'Add External Tool Configuration';\r
-$string['allow'] = 'Allow';\r
-$string['allowinstructorcustom'] = 'Allow instructors to add custom parameters';\r
-$string['allowroster'] = 'Tool may access course roster';\r
-$string['allowsetting'] = 'Allow tool to store 8K of settings in Moodle';\r
-$string['always'] = 'Always';\r
-$string['lti'] = 'Basic LTI';\r
-$string['basiclti'] = 'Basic LTI';\r
-$string['basiclti_base_string'] = 'Basic LTI OAuth Base String';\r
-$string['basiclti_in_new_window'] = 'Your activity has opened in a new window';\r
-$string['basiclti_endpoint'] = 'Basic LTI Launch Endpoint';\r
-$string['basiclti_parameters'] = 'Basic LTI Launch Parameters';\r
-$string['basicltiactivities'] = 'Basic LTI Activities';\r
-$string['basicltifieldset'] = 'Custom example fieldset';\r
-$string['basicltiintro'] = 'Activity Description';\r
-$string['basicltiname'] = 'Activity Name';\r
-$string['basicltisettings'] = 'Basic Learning Tool Interoperability Settings';\r
-$string['comment'] = 'Comment';\r
-$string['configpassword'] = 'Default Remote Tool Password';\r
-$string['configpreferheight'] = 'Default preferred height';\r
-$string['configpreferwidget'] = 'Set widget as default launch';\r
-$string['configpreferwidth'] = 'Default preferred width';\r
-$string['configresourceurl'] = 'Default Resource URL';\r
-$string['configtoolurl'] = 'Default Remote Tool URL';\r
-$string['configtypes'] = 'Enable Basic LTI Applications';\r
-$string['courseid'] = 'Course id number';\r
-$string['coursemisconf'] = 'Course is misconfigured';\r
-$string['curllibrarymissing'] = 'PHP Curl library must be installed to use LTI';\r
-$string['custom'] = 'Custom parameters';\r
-$string['custominstr'] = 'Custom parameters';\r
-$string['debuglaunch'] = 'Debug Option';\r
-$string['debuglaunchoff'] = 'Normal launch';\r
-$string['debuglaunchon'] = 'Debug launch';\r
-$string['delegate'] = 'Delegate to Professor';\r
-$string['donot'] = 'Do not send';\r
-$string['donotaccept'] = 'Do not accept';\r
-$string['donotallow'] = 'Do not allow';\r
-$string['enableemailnotification'] = 'Send notification emails';\r
-$string['enableemailnotification_help'] = 'If enabled, students will receive email notification when their tool submissions are graded.';\r
-$string['errormisconfig'] = 'Misconfigured tool. Please ask your Moodle administrator to fix the configuration of the tool.';\r
-$string['extensions'] = 'Basic LTI Extension Services';\r
-$string['failedtoconnect'] = 'Moodle was unable to communicate with the \"$a\" system';\r
-$string['filterconfig'] = 'Basic LTI administration';\r
-$string['filtername'] = 'Basic LTI';\r
-$string['filter_basiclti_configlink'] = 'Configure your preferred sites and their passwords';\r
-$string['filter_basiclti_password'] = 'Password is mandatory';\r
-$string['fixexistingconf'] = 'Use an existing configuration for the misconfigured instance';\r
-$string['fixnew'] = 'New Configuration';\r
-$string['fixnewconf'] = 'Define a new configuration for the misconfigured instance';\r
-$string['fixold'] = 'Use Existing';\r
-$string['grading'] = 'Grade Routing';\r
-$string['id'] = 'id';\r
-$string['imsroleadmin'] = 'Instructor,Administrator';\r
-$string['imsroleinstructor'] = 'Instructor';\r
-$string['imsrolelearner'] = 'Learner';\r
-$string['invalidid'] = 'basic LTI ID was incorrect';\r
-$string['launch_in_moodle'] = 'Launch tool in moodle';\r
-$string['launch_in_popup'] = 'Launch tool in a pop-up';\r
-$string['launchinpopup'] = 'Launch Container';\r
-$string['launchoptions'] = 'Launch Options';\r
-$string['lti_errormsg'] = 'The tool returned the following error message: \"$a\"';\r
-$string['misconfiguredtools'] = 'Misconfigured tool instances were detected';\r
-$string['missingparameterserror'] = 'The page is misconfigured: \"$a\"';\r
-$string['module_class_type'] = 'Moodle module type';\r
-$string['modulename'] = 'External Tool';\r
-$string['modulenameplural'] = 'basicltis';\r
-$string['modulenamepluralformatted'] = 'Basic LTI Instances';\r
-$string['never'] = 'Never';\r
-$string['noattempts'] = 'No attempts have been made on this tool instance';\r
-$string['noservers'] = 'No servers found';\r
-$string['notypes'] = 'There are currently no LTI tools setup in Moodle. Click the Install link above to add some.';\r
-$string['noviewusers'] = 'No users were found with permissions to use this tool';\r
-$string['optionalsettings'] = 'Optional settings';\r
-$string['organization'] ='Organization details';\r
-$string['organizationdescr'] ='Organization Description';\r
-$string['organizationid'] ='Organization ID';\r
-$string['organizationurl'] ='Organization URL';\r
-$string['pagesize'] = 'Submissions shown per page';\r
-$string['password'] = 'Shared Secret';\r
-$string['pluginadministration'] = 'Basic LTI administration';\r
-$string['pluginname'] = 'LTI';\r
-$string['preferheight'] = 'Preferred Height';\r
-$string['preferwidget'] = 'Prefer Widget Launch';\r
-$string['preferwidth'] = 'Preferred Width';\r
-$string['press_to_submit'] = 'Press to launch this activity';\r
-$string['privacy'] = 'Privacy';\r
-$string['quickgrade'] = 'Allow quick grading';\r
-$string['quickgrade_help'] = 'If enabled, multiple tools can be graded on one page. Add grades and comments then click the "Save all my feedback" button to save all changes for that page.';\r
-$string['redirect'] = 'You will be redirected in few seconds. If you are not, press the button.';\r
-$string['resource'] = 'Resource';\r
-$string['resourcekey'] = 'Consumer Key';\r
-$string['resourceurl'] = 'Resource URL';\r
-$string['saveallfeedback'] = 'Save all my feedback';\r
-$string['send'] = 'Send';\r
-$string['sendemailaddr'] = 'Share launcher\'s email with tool';\r
-$string['sendname'] = 'Share launcher\'s name with tool';\r
-$string['setdefault'] = 'Set a default value for the professor if delegating';\r
-$string['setupbox'] = 'Basic LTI Tool Setup Box';\r
-$string['setupoptions'] = 'Setup Options';\r
-$string['size'] = 'Size parameters';\r
-$string['submission'] = 'Submission';\r
-$string['toggle_debug_data'] = 'Toggle Debug Data';\r
-$string['toolsetup'] = 'Basic LTI Tool Setup';\r
-$string['toolurl'] = 'Tool Base URL';\r
-$string['typename'] = 'Tool Name';\r
-$string['types'] = 'Types';\r
-$string['validurl'] = 'A valid URL must start with http(s)://';\r
-$string['viewsubmissions'] = 'View submissions and grading screen';\r
-\r
-//New admin strings\r
-\r
-$string['show_in_course'] = 'Show tool type when creating tool instances';\r
-$string['delegate_yes'] = 'Delegate to Instructor (Default: Yes)';\r
-$string['delegate_no'] = 'Delegate to Instructor (Default: No)';\r
-$string['tool_settings'] = 'Tool Settings';\r
-$string['miscellaneous'] = 'Miscellaneous';\r
-$string['embed'] = 'Embed';\r
-$string['embed_no_blocks'] = 'Embed, without blocks';\r
-$string['new_window'] = 'New window';\r
-$string['default_launch_container'] = 'Default Launch Container';\r
-$string['active'] = 'Active';\r
-$string['pending'] = 'Pending';\r
-$string['rejected'] = 'Rejected';\r
-$string['baseurl'] = 'Base URL';\r
-$string['action'] = 'Action';\r
-$string['createdon'] = 'Created On';\r
-$string['accept'] = 'Accept';\r
-$string['update'] = 'Update';\r
-$string['delete'] = 'Delete';\r
-$string['reject'] = 'Reject';\r
-$string['external_tool_types'] = 'External Tool Types';\r
-$string['no_lti_configured'] = 'There are no active External Tools configured.';\r
-$string['no_lti_pending'] = 'There are no pending External Tools.';\r
-$string['no_lti_rejected'] = 'There are no rejected External Tools.';\r
-\r
-//New instructor strings\r
-$string['display_name'] = 'Display activity name when launched';\r
-$string['display_description'] = 'Display activity description when launched';\r
-$string['external_tool_type'] = 'External tool type';\r
-$string['launch_url'] = 'Launch URL';\r
-$string['share_name'] = 'Share launcher\'s name with the tool';\r
-$string['share_email'] = 'Share launcher\'s email with the tool';\r
-$string['accept_grades'] = 'Accept grades from the tool';\r
-$string['share_roster'] = 'Allow the tool to access this course\'s roster';\r
-$string['automatic'] = 'Automatic, based on Launch URL';\r
-$string['default'] = 'Default';\r
+<?php
+// This file is part of BasicLTI4Moodle
+//
+// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
+// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
+// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
+// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
+// are already supporting or going to support BasicLTI. This project Implements the consumer
+// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
+// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
+// at the GESSI research group at UPC.
+// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
+// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
+// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
+//
+// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
+// of the Universitat Politecnica de Catalunya http://www.upc.edu
+// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * This file contains en_utf8 translation of the Basic LTI module
+ *
+ * @package basiclti
+ * @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
+ * marc.alier@upc.edu
+ * @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
+ *
+ * @author Marc Alier
+ * @author Jordi Piguillem
+ * @author Nikolas Galanis
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+$string['accept'] = 'Accept';
+$string['acceptgrades'] = 'Accept grades from tool';
+$string['activity'] = 'Activity';
+$string['addnewapp'] = 'Enable External Application';
+$string['addserver'] = 'Add new trusted server';
+$string['addtype'] = 'Add External Tool Configuration';
+$string['allow'] = 'Allow';
+$string['allowinstructorcustom'] = 'Allow instructors to add custom parameters';
+$string['allowroster'] = 'Tool may access course roster';
+$string['allowsetting'] = 'Allow tool to store 8K of settings in Moodle';
+$string['always'] = 'Always';
+$string['lti'] = 'Basic LTI';
+$string['basiclti'] = 'Basic LTI';
+$string['basiclti_base_string'] = 'Basic LTI OAuth Base String';
+$string['basiclti_in_new_window'] = 'Your activity has opened in a new window';
+$string['basiclti_endpoint'] = 'Basic LTI Launch Endpoint';
+$string['basiclti_parameters'] = 'Basic LTI Launch Parameters';
+$string['basicltiactivities'] = 'Basic LTI Activities';
+$string['basicltifieldset'] = 'Custom example fieldset';
+$string['basicltiintro'] = 'Activity Description';
+$string['basicltiname'] = 'Activity Name';
+$string['basicltisettings'] = 'Basic Learning Tool Interoperability Settings';
+$string['comment'] = 'Comment';
+$string['configpassword'] = 'Default Remote Tool Password';
+$string['configpreferheight'] = 'Default preferred height';
+$string['configpreferwidget'] = 'Set widget as default launch';
+$string['configpreferwidth'] = 'Default preferred width';
+$string['configresourceurl'] = 'Default Resource URL';
+$string['configtoolurl'] = 'Default Remote Tool URL';
+$string['configtypes'] = 'Enable Basic LTI Applications';
+$string['courseid'] = 'Course id number';
+$string['coursemisconf'] = 'Course is misconfigured';
+$string['curllibrarymissing'] = 'PHP Curl library must be installed to use LTI';
+$string['custom'] = 'Custom parameters';
+$string['custominstr'] = 'Custom parameters';
+$string['debuglaunch'] = 'Debug Option';
+$string['debuglaunchoff'] = 'Normal launch';
+$string['debuglaunchon'] = 'Debug launch';
+$string['donot'] = 'Do not send';
+$string['donotaccept'] = 'Do not accept';
+$string['donotallow'] = 'Do not allow';
+$string['enableemailnotification'] = 'Send notification emails';
+$string['enableemailnotification_help'] = 'If enabled, students will receive email notification when their tool submissions are graded.';
+$string['errormisconfig'] = 'Misconfigured tool. Please ask your Moodle administrator to fix the configuration of the tool.';
+$string['extensions'] = 'Basic LTI Extension Services';
+$string['failedtoconnect'] = 'Moodle was unable to communicate with the \"$a\" system';
+$string['filterconfig'] = 'Basic LTI administration';
+$string['filtername'] = 'Basic LTI';
+$string['filter_basiclti_configlink'] = 'Configure your preferred sites and their passwords';
+$string['filter_basiclti_password'] = 'Password is mandatory';
+$string['fixexistingconf'] = 'Use an existing configuration for the misconfigured instance';
+$string['fixnew'] = 'New Configuration';
+$string['fixnewconf'] = 'Define a new configuration for the misconfigured instance';
+$string['fixold'] = 'Use Existing';
+$string['grading'] = 'Grade Routing';
+$string['id'] = 'id';
+$string['imsroleadmin'] = 'Instructor,Administrator';
+$string['imsroleinstructor'] = 'Instructor';
+$string['imsrolelearner'] = 'Learner';
+$string['invalidid'] = 'basic LTI ID was incorrect';
+$string['launch_in_moodle'] = 'Launch tool in moodle';
+$string['launch_in_popup'] = 'Launch tool in a pop-up';
+$string['launchinpopup'] = 'Launch Container';
+$string['launchoptions'] = 'Launch Options';
+$string['lti_errormsg'] = 'The tool returned the following error message: \"$a\"';
+$string['misconfiguredtools'] = 'Misconfigured tool instances were detected';
+$string['missingparameterserror'] = 'The page is misconfigured: \"$a\"';
+$string['module_class_type'] = 'Moodle module type';
+$string['modulename'] = 'External Tool';
+$string['modulenameplural'] = 'basicltis';
+$string['modulenamepluralformatted'] = 'Basic LTI Instances';
+$string['never'] = 'Never';
+$string['noattempts'] = 'No attempts have been made on this tool instance';
+$string['noservers'] = 'No servers found';
+$string['notypes'] = 'There are currently no LTI tools setup in Moodle. Click the Install link above to add some.';
+$string['noviewusers'] = 'No users were found with permissions to use this tool';
+$string['optionalsettings'] = 'Optional settings';
+$string['organization'] ='Organization details';
+$string['organizationdescr'] ='Organization Description';
+$string['organizationid'] ='Organization ID';
+$string['organizationurl'] ='Organization URL';
+$string['pagesize'] = 'Submissions shown per page';
+$string['password'] = 'Shared Secret';
+$string['pluginadministration'] = 'Basic LTI administration';
+$string['pluginname'] = 'LTI';
+$string['preferheight'] = 'Preferred Height';
+$string['preferwidget'] = 'Prefer Widget Launch';
+$string['preferwidth'] = 'Preferred Width';
+$string['press_to_submit'] = 'Press to launch this activity';
+$string['privacy'] = 'Privacy';
+$string['quickgrade'] = 'Allow quick grading';
+$string['quickgrade_help'] = 'If enabled, multiple tools can be graded on one page. Add grades and comments then click the "Save all my feedback" button to save all changes for that page.';
+$string['redirect'] = 'You will be redirected in few seconds. If you are not, press the button.';
+$string['resource'] = 'Resource';
+$string['resourcekey'] = 'Consumer Key';
+$string['resourceurl'] = 'Resource URL';
+$string['saveallfeedback'] = 'Save all my feedback';
+$string['send'] = 'Send';
+$string['sendemailaddr'] = 'Share launcher\'s email with tool';
+$string['sendname'] = 'Share launcher\'s name with tool';
+$string['setdefault'] = 'Set a default value for the professor if delegating';
+$string['setupbox'] = 'Basic LTI Tool Setup Box';
+$string['setupoptions'] = 'Setup Options';
+$string['size'] = 'Size parameters';
+$string['submission'] = 'Submission';
+$string['toggle_debug_data'] = 'Toggle Debug Data';
+$string['toolsetup'] = 'External Tool Configuration';
+$string['toolurl'] = 'Tool Base URL';
+$string['typename'] = 'Tool Name';
+$string['types'] = 'Types';
+$string['validurl'] = 'A valid URL must start with http(s)://';
+$string['viewsubmissions'] = 'View submissions and grading screen';
+
+//New admin strings
+
+$string['show_in_course'] = 'Show tool type when creating tool instances';
+$string['delegate'] = 'Delegate to Instructor';
+$string['tool_settings'] = 'Tool Settings';
+$string['miscellaneous'] = 'Miscellaneous';
+$string['embed'] = 'Embed';
+$string['embed_no_blocks'] = 'Embed, without blocks';
+$string['new_window'] = 'New window';
+$string['default_launch_container'] = 'Default Launch Container';
+$string['active'] = 'Active';
+$string['pending'] = 'Pending';
+$string['rejected'] = 'Rejected';
+$string['baseurl'] = 'Base URL';
+$string['action'] = 'Action';
+$string['createdon'] = 'Created On';
+$string['accept'] = 'Accept';
+$string['update'] = 'Update';
+$string['delete'] = 'Delete';
+$string['reject'] = 'Reject';
+$string['external_tool_types'] = 'External Tool Types';
+$string['no_lti_configured'] = 'There are no active External Tools configured.';
+$string['no_lti_pending'] = 'There are no pending External Tools.';
+$string['no_lti_rejected'] = 'There are no rejected External Tools.';
+
+//New instructor strings
+$string['display_name'] = 'Display activity name when launched';
+$string['display_description'] = 'Display activity description when launched';
+$string['external_tool_type'] = 'External tool type';
+$string['launch_url'] = 'Launch URL';
+$string['share_name'] = 'Share launcher\'s name with the tool';
+$string['share_email'] = 'Share launcher\'s email with the tool';
+$string['accept_grades'] = 'Accept grades from the tool';
+$string['share_roster'] = 'Allow the tool to access this course\'s roster';
+$string['automatic'] = 'Automatic, based on Launch URL';
+$string['default'] = 'Default';
echo $content;
}
+function lti_build_sourcedid($instanceid, $userid, $servicesalt){
+ $data = new stdClass();
+
+ $data->instanceid = $instanceid;
+ $data->userid = $userid;
+
+ $json = json_encode($data);
+
+ $hash = hash('sha256', $json . $servicesalt, false);
+
+ $container = new stdClass();
+ $container->data = $data;
+ $container->hash = $hash;
+
+ return $container;
+}
+
/**
* This function builds the request that must be sent to the tool producer
*
$placementsecret = $instance->servicesalt;
if ( isset($placementsecret) ) {
- $data = new stdClass();
-
- $data->instanceid = $instance->id;
- $data->userid = $USER->id;
-
- $json = json_encode($data);
-
- $hash = hash('sha256', $json . $placementsecret, false);
-
- $container = new stdClass();
- $container->data = $data;
- $container->hash = $hash;
-
- $sourcedid = json_encode($container);
+ $sourcedid = json_encode(lti_build_sourcedid($instance->id, $USER->id, $placementsecret));
}
if ( isset($placementsecret) &&
return $typeconfig;
}
-function lti_get_tools_by_url($url, $state){
+function lti_get_tools_by_url($url, $state, $courseid = null){
$domain = lti_get_domain_from_url($url);
- return lti_get_tools_by_domain($domain, $state);
+ return lti_get_tools_by_domain($domain, $state, $courseid);
}
function lti_get_tools_by_domain($domain, $state = null, $courseid = null){
}
function lti_get_types_for_add_instance(){
- global $DB;
- $admintypes = $DB->get_records('lti_types', array('coursevisible' => 1));
+ global $DB, $SITE, $COURSE;
+
+ $query = <<<QUERY
+ SELECT *
+ FROM {lti_types}
+ WHERE
+ coursevisible = 1
+ AND (course = :siteid OR course = :courseid)
+QUERY;
+
+ $admintypes = $DB->get_records_sql($query, array('siteid' => $SITE->id, 'courseid' => $COURSE->id));
$types = array();
- $types[0] = get_string('automatic', 'lti');
+ $types[0] = (object)array('name' => get_string('automatic', 'lti'), 'course' => $SITE->id);
foreach($admintypes as $type) {
- $types[$type->id] = $type->name;
+ $types[$type->id] = (object)array('name' => $type->name, 'course' => $type->course);
}
return $types;
}
function lti_get_tool_by_url_match($url, $courseid = null, $state = LTI_TOOL_STATE_CONFIGURED){
- $possibletools = lti_get_tools_by_url($url, $state, $courseid);
+ $possibletools = lti_get_tools_by_url($url, $courseid, $state);
return lti_get_best_tool_by_url($url, $possibletools);
}
}
}
}
+
+ return $id;
}
/**
return $submitted;
}
+function lti_get_type($typeid){
+ global $DB;
+
+ return $DB->get_record('lti_types', array('id' => $typeid));
+}
\ No newline at end of file
--- /dev/null
+M.mod_lti = M.mod_lti || {};
+
+M.mod_lti.editor = {
+ init: function(Y, settings){
+ this.Y = Y;
+ var self = this;
+ this.settings = Y.JSON.parse(settings);
+
+ var typeSelector = Y.one('#id_typeid');
+ typeSelector.on('change', function(e){
+ self.toggleEditButtons();
+ });
+
+ this.createTypeEditorButtons();
+
+ this.toggleEditButtons();
+ },
+
+ getSelectedToolTypeOption: function(){
+ var Y = this.Y;
+ var typeSelector = Y.one('#id_typeid');
+
+ return typeSelector.one('option[value=' + typeSelector.get('value') + ']');
+ },
+
+ /**
+ * Adds buttons for creating, editing, and deleting tool types
+ */
+ createTypeEditorButtons: function(){
+ var Y = this.Y;
+ var self = this;
+
+ var typeSelector = Y.one('#id_typeid');
+
+ var createIcon = function(id, tooltip, iconUrl){
+ return Y.Node.create('<a />')
+ .set('id', id)
+ .set('title', tooltip)
+ .setStyle('margin-left', '.5em')
+ .set('href', 'javascript:void(0);')
+ .append(Y.Node.create('<img src="' + iconUrl + '" />'));
+ }
+
+ var addIcon = createIcon('lti_add_tool_type', 'Add new tool type', this.settings.add_icon_url);
+ var editIcon = createIcon('lti_edit_tool_type', 'Edit new tool type', this.settings.edit_icon_url);
+ var deleteIcon = createIcon('lti_delete_tool_type', 'Delete tool type', this.settings.delete_icon_url);
+
+ editIcon.on('click', function(e){
+ var toolTypeId = typeSelector.get('value');
+
+ if(self.getSelectedToolTypeOption().getAttribute('editable')){
+ window.open(self.settings.instructor_tool_type_edit_url + '&action=edit&typeid=' + toolTypeId, 'edit_tool');
+ }
+ });
+
+ addIcon.on('click', function(e){
+ window.open(self.settings.instructor_tool_type_edit_url + '&action=add', 'add_tool');
+ });
+
+ deleteIcon.on('click', function(e){
+ var toolTypeId = typeSelector.get('value');
+
+ if(self.getSelectedToolTypeOption().getAttribute('editable')){
+ Y.io(self.settings.instructor_tool_type_edit_url + '&action=delete&typeid=' + toolTypeId, {
+ on: {
+ success: function(){
+ getSelectedOption().remove();
+ },
+ failure: function(){
+
+ }
+ }
+ });
+ }
+ });
+
+ typeSelector.insert(addIcon, 'after');
+ addIcon.insert(editIcon, 'after');
+ editIcon.insert(deleteIcon, 'after');
+ },
+
+ toggleEditButtons: function(){
+ var Y = this.Y;
+
+ var lti_edit_tool_type = Y.one('#lti_edit_tool_type');
+ var lti_delete_tool_type = Y.one('#lti_delete_tool_type');
+
+ if(this.getSelectedToolTypeOption().getAttribute('editable')){
+ lti_edit_tool_type.setStyle('opacity', '1');
+ lti_delete_tool_type.setStyle('opacity', '1');
+ } else {
+ lti_edit_tool_type.setStyle('opacity', '.2');
+ lti_delete_tool_type.setStyle('opacity', '.2');
+ }
+ },
+
+ addToolType: function(text, value){
+ var Y = this.Y;
+ var typeSelector = Y.one('#id_typeid');
+
+ var option = Y.Node.create('<option />')
+ .set('text', text)
+ .set('value', value)
+ .set('selected', 'selected');
+
+ typeSelector.append(option);
+ },
+
+ updateToolType: function(text, value){
+ var Y = this.Y;
+ var typeSelector = Y.one('#id_typeid');
+
+ var option = Y.Node.create('<option />')
+ .set('text', text)
+ .set('value', value)
+ .set('selected', 'selected');
+
+ typeSelector.append(option);
+ }
+
+};
+
+
+
-<?php\r
-// This file is part of BasicLTI4Moodle\r
-//\r
-// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)\r
-// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web\r
-// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI\r
-// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS\r
-// are already supporting or going to support BasicLTI. This project Implements the consumer\r
-// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.\r
-// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem\r
-// at the GESSI research group at UPC.\r
-// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI\r
-// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a\r
-// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.\r
-//\r
-// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis\r
-// of the Universitat Politecnica de Catalunya http://www.upc.edu\r
-// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu\r
-//\r
-// Moodle is free software: you can redistribute it and/or modify\r
-// it under the terms of the GNU General Public License as published by\r
-// the Free Software Foundation, either version 3 of the License, or\r
-// (at your option) any later version.\r
-//\r
-// Moodle is distributed in the hope that it will be useful,\r
-// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-// GNU General Public License for more details.\r
-//\r
-// You should have received a copy of the GNU General Public License\r
-// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\r
-\r
-/**\r
- * This file defines the main basiclti configuration form\r
- *\r
- * @package lti\r
- * @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis\r
- * marc.alier@upc.edu\r
- * @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu\r
- *\r
- * @author Marc Alier\r
- * @author Jordi Piguillem\r
- * @author Nikolas Galanis\r
- *\r
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r
- */\r
-\r
-defined('MOODLE_INTERNAL') || die;\r
-\r
-require_once($CFG->dirroot.'/course/moodleform_mod.php');\r
-require_once($CFG->dirroot.'/mod/lti/locallib.php');\r
-\r
-class mod_lti_mod_form extends moodleform_mod {\r
-\r
- function definition() {\r
- global $DB;\r
-\r
- $typename = optional_param('type', false, PARAM_ALPHA);\r
-\r
- if (empty($typename)) {\r
- //Updating instance\r
- if (!empty($this->_instance)) {\r
- $basiclti = $DB->get_record('lti', array('id' => $this->_instance));\r
- $this->typeid = $basiclti->typeid;\r
-\r
- $typeconfig = lti_get_config($basiclti);\r
- $this->typeconfig = $typeconfig;\r
-\r
- } else { // New not pre-configured instance\r
- $this->typeid = 0;\r
- }\r
- } else {\r
- // New pre-configured instance\r
- $basicltitype = $DB->get_record('lti_types', array('rawname' => $typename));\r
- $this->typeid = $basicltitype->id;\r
-\r
- $typeconfig = lti_get_type_config($this->typeid);\r
- $this->typeconfig = $typeconfig;\r
- }\r
-\r
- $mform =& $this->_form;\r
-//-------------------------------------------------------------------------------\r
- /// Adding the "general" fieldset, where all the common settings are shown\r
- $mform->addElement('header', 'general', get_string('general', 'form'));\r
- /// Adding the standard "name" field\r
- $mform->addElement('text', 'name', get_string('basicltiname', 'lti'), array('size'=>'64'));\r
- $mform->setType('name', PARAM_TEXT);\r
- $mform->addRule('name', null, 'required', null, 'client');\r
- /// Adding the optional "intro" and "introformat" pair of fields\r
- $this->add_intro_editor(false, get_string('basicltiintro', 'lti'));\r
- $mform->setAdvanced('introeditor');\r
-\r
- $mform->addElement('checkbox', 'showtitle', ' ', ' ' . get_string('display_name', 'lti'));\r
- $mform->setAdvanced('showtitle');\r
- \r
- $mform->addElement('checkbox', 'showdescription', ' ', ' ' . get_string('display_description', 'lti'));\r
- $mform->setAdvanced('showdescription');\r
- \r
- //Tool settings\r
- $mform->addElement('select', 'typeid', get_string('external_tool_type', 'lti'), lti_get_types_for_add_instance());\r
- //$mform->setDefault('typeid', '0');\r
- \r
- $mform->addElement('text', 'toolurl', get_string('launch_url', 'lti'), array('size'=>'64'));\r
- $mform->setType('toolurl', PARAM_TEXT);\r
- \r
- $launchoptions=array();\r
- $launchoptions[LTI_LAUNCH_CONTAINER_DEFAULT] = get_string('default', 'lti');\r
- $launchoptions[LTI_LAUNCH_CONTAINER_EMBED] = get_string('embed', 'lti');\r
- $launchoptions[LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS] = get_string('embed_no_blocks', 'lti');\r
- $launchoptions[LTI_LAUNCH_CONTAINER_WINDOW] = get_string('new_window', 'lti');\r
-\r
- $mform->addElement('select', 'launchcontainer', get_string('launchinpopup', 'lti'), $launchoptions);\r
- $mform->setDefault('launchcontainer', LTI_LAUNCH_CONTAINER_DEFAULT);\r
- \r
- $mform->addElement('text', 'resourcekey', get_string('resourcekey', 'lti'));\r
- $mform->setType('resourcekey', PARAM_TEXT);\r
- $mform->setAdvanced('resourcekey');\r
-\r
- $mform->addElement('passwordunmask', 'password', get_string('password', 'lti'));\r
- $mform->setType('password', PARAM_TEXT);\r
- $mform->setAdvanced('password');\r
- \r
- $mform->addElement('textarea', 'instructorcustomparameters', get_string('custom', 'lti'), array('rows'=>4, 'cols'=>60));\r
- $mform->setType('instructorcustomparameters', PARAM_TEXT);\r
- $mform->setAdvanced('instructorcustomparameters');\r
- \r
-//-------------------------------------------------------------------------------\r
- //$mform->addElement('hidden', 'typeid', $this->typeid);\r
- //$mform->addElement('hidden', 'toolurl', $this->typeconfig['toolurl']);\r
- $mform->addElement('hidden', 'type', $typename);\r
-\r
-//-------------------------------------------------------------------------------\r
- // Add privacy preferences fieldset where users choose whether to send their data\r
- $mform->addElement('header', 'privacy', get_string('privacy', 'lti'));\r
-\r
- $mform->addElement('checkbox', 'instructorchoicesendname', ' ', ' ' . get_string('share_name', 'lti'));\r
- $mform->setDefault('instructorchoicesendname', '1');\r
- \r
- $mform->addElement('checkbox', 'instructorchoicesendemailaddr', ' ', ' ' . get_string('share_email', 'lti'));\r
- $mform->setDefault('instructorchoicesendemailaddr', '1');\r
- \r
- $mform->addElement('checkbox', 'instructorchoiceacceptgrades', ' ', ' ' . get_string('accept_grades', 'lti'));\r
- $mform->setDefault('instructorchoiceacceptgrades', '1');\r
- \r
- $mform->addElement('checkbox', 'instructorchoiceallowroster', ' ', ' ' . get_string('share_roster', 'lti'));\r
- $mform->setDefault('instructorchoiceallowroster', '1');\r
-\r
-//-------------------------------------------------------------------------------\r
-\r
-/* $debugoptions=array();\r
- $debugoptions[0] = get_string('debuglaunchoff', 'lti');\r
- $debugoptions[1] = get_string('debuglaunchon', 'lti');\r
-\r
- $mform->addElement('select', 'debuglaunch', get_string('debuglaunch', 'lti'), $debugoptions);\r
-\r
- if (isset($this->typeconfig['debuglaunch'])) {\r
- if ($this->typeconfig['debuglaunch'] == 0) {\r
- $mform->setDefault('debuglaunch', '0');\r
- } else if ($this->typeconfig['debuglaunch'] == 1) {\r
- $mform->setDefault('debuglaunch', '1');\r
- }\r
- }\r
-*/\r
-\r
-//-------------------------------------------------------------------------------\r
- // add standard elements, common to all modules\r
- $this->standard_coursemodule_elements();\r
- \r
- $mform->setAdvanced('cmidnumber');\r
-//-------------------------------------------------------------------------------\r
- // add standard buttons, common to all modules\r
- $this->add_action_buttons();\r
- }\r
-\r
- /**\r
- * Make fields editable or non-editable depending on the administrator choices\r
- * @see moodleform_mod::definition_after_data()\r
- */\r
- function definition_after_data() {\r
- parent::definition_after_data();\r
- /* $mform =& $this->_form;\r
- $typeid =& $mform->getElement('typeid');\r
- $typeidvalue = $mform->getElementValue('typeid');\r
-\r
- //Depending on the selection of the administrator\r
- //we don't want to have these appear as possible selections in the form but\r
- //we want the form to display them if they are set.\r
- if (!empty($typeidvalue)) {\r
- $typeconfig = lti_get_type_config($typeidvalue);\r
-\r
- if ($typeconfig["sendname"] != 2) {\r
- $field =& $mform->getElement('instructorchoicesendname');\r
- $mform->setDefault('instructorchoicesendname', $typeconfig["sendname"]);\r
- $field->freeze();\r
- $field->setPersistantFreeze(true);\r
- }\r
- if ($typeconfig["sendemailaddr"] != 2) {\r
- $field =& $mform->getElement('instructorchoicesendemailaddr');\r
- $mform->setDefault('instructorchoicesendemailaddr', $typeconfig["sendemailaddr"]);\r
- $field->freeze();\r
- $field->setPersistantFreeze(true);\r
- }\r
- if ($typeconfig["acceptgrades"] != 2) {\r
- $field =& $mform->getElement('instructorchoiceacceptgrades');\r
- $mform->setDefault('instructorchoiceacceptgrades', $typeconfig["acceptgrades"]);\r
- $field->freeze();\r
- $field->setPersistantFreeze(true);\r
- }\r
- if ($typeconfig["allowroster"] != 2) {\r
- $field =& $mform->getElement('instructorchoiceallowroster');\r
- $mform->setDefault('instructorchoiceallowroster', $typeconfig["allowroster"]);\r
- $field->freeze();\r
- $field->setPersistantFreeze(true);\r
- }\r
- if ($typeconfig["allowsetting"] != 2) {\r
- $field =& $mform->getElement('instructorchoiceallowsetting');\r
- $mform->setDefault('instructorchoiceallowsetting', $typeconfig["allowsetting"]);\r
- $field->freeze();\r
- $field->setPersistantFreeze(true);\r
- }\r
- }*/\r
- }\r
-\r
- /**\r
- * Function overwritten to change default values using\r
- * global configuration\r
- *\r
- * @param array $default_values passed by reference\r
- */\r
- function data_preprocessing(&$default_values) {\r
-/* global $CFG;\r
- $default_values['typeid'] = $this->typeid;\r
-\r
- if (!isset($default_values['toolurl'])) {\r
- if (isset($this->typeconfig['toolurl'])) {\r
- $default_values['toolurl'] = $this->typeconfig['toolurl'];\r
- } else if (isset($CFG->lti_toolurl)) {\r
- $default_values['toolurl'] = $CFG->lti_toolurl;\r
- }\r
- }\r
-\r
- if (!isset($default_values['resourcekey'])) {\r
- if (isset($this->typeconfig['resourcekey'])) {\r
- $default_values['resourcekey'] = $this->typeconfig['resourcekey'];\r
- } else if (isset($CFG->lti_resourcekey)) {\r
- $default_values['resourcekey'] = $CFG->lti_resourcekey;\r
- }\r
- }\r
-\r
- if (!isset($default_values['password'])) {\r
- if (isset($this->typeconfig['password'])) {\r
- $default_values['password'] = $this->typeconfig['password'];\r
- } else if (isset($CFG->lti_password)) {\r
- $default_values['password'] = $CFG->lti_password;\r
- }\r
- }\r
-\r
- if (!isset($default_values['preferheight'])) {\r
- if (isset($this->typeconfig['preferheight'])) {\r
- $default_values['preferheight'] = $this->typeconfig['preferheight'];\r
- } else if (isset($CFG->lti_preferheight)) {\r
- $default_values['preferheight'] = $CFG->lti_preferheight;\r
- }\r
- }\r
-\r
- if (!isset($default_values['sendname'])) {\r
- if (isset($this->typeconfig['sendname'])) {\r
- $default_values['sendname'] = $this->typeconfig['sendname'];\r
- } else if (isset($CFG->lti_sendname)) {\r
- $default_values['sendname'] = $CFG->lti_sendname;\r
- }\r
- }\r
-\r
- if (!isset($default_values['instructorchoicesendname'])) {\r
- if (isset($this->typeconfig['instructorchoicesendname'])) {\r
- $default_values['instructorchoicesendname'] = $this->typeconfig['instructorchoicesendname'];\r
- } else {\r
- if ($this->typeconfig['sendname'] == 2) {\r
- $default_values['instructorchoicesendname'] = $CFG->lti_instructorchoicesendname;\r
- } else {\r
- $default_values['instructorchoicesendname'] = $this->typeconfig['sendname'];\r
- }\r
- }\r
- }\r
-\r
- if (!isset($default_values['sendemailaddr'])) {\r
- if (isset($this->typeconfig['sendemailaddr'])) {\r
- $default_values['sendemailaddr'] = $this->typeconfig['sendemailaddr'];\r
- } else if (isset($CFG->lti_sendemailaddr)) {\r
- $default_values['sendemailaddr'] = $CFG->lti_sendemailaddr;\r
- }\r
- }\r
-\r
- if (!isset($default_values['instructorchoicesendemailaddr'])) {\r
- if (isset($this->typeconfig['instructorchoicesendemailaddr'])) {\r
- $default_values['instructorchoicesendemailaddr'] = $this->typeconfig['instructorchoicesendemailaddr'];\r
- } else {\r
- if ($this->typeconfig['sendemailaddr'] == 2) {\r
- $default_values['instructorchoicesendemailaddr'] = $CFG->lti_instructorchoicesendemailaddr;\r
- } else {\r
- $default_values['instructorchoicesendemailaddr'] = $this->typeconfig['sendemailaddr'];\r
- }\r
- }\r
- }\r
-\r
- if (!isset($default_values['acceptgrades'])) {\r
- if (isset($this->typeconfig['acceptgrades'])) {\r
- $default_values['acceptgrades'] = $this->typeconfig['acceptgrades'];\r
- } else if (isset($CFG->lti_acceptgrades)) {\r
- $default_values['acceptgrades'] = $CFG->lti_acceptgrades;\r
- }\r
- }\r
-\r
- if (!isset($default_values['instructorchoiceacceptgrades'])) {\r
- if (isset($this->typeconfig['instructorchoiceacceptgrades'])) {\r
- $default_values['instructorchoiceacceptgrades'] = $this->typeconfig['instructorchoiceacceptgrades'];\r
- } else {\r
- if ($this->typeconfig['acceptgrades'] == 2) {\r
- $default_values['instructorchoiceacceptgrades'] = $CFG->lti_instructorchoiceacceptgrades;\r
- } else {\r
- $default_values['instructorchoiceacceptgrades'] = $this->typeconfig['acceptgrades'];\r
- }\r
- }\r
- }\r
-\r
- if (!isset($default_values['allowroster'])) {\r
- if (isset($this->typeconfig['allowroster'])) {\r
- $default_values['allowroster'] = $this->typeconfig['allowroster'];\r
- } else if (isset($CFG->lti_allowroster)) {\r
- $default_values['allowroster'] = $CFG->lti_allowroster;\r
- }\r
- }\r
-\r
- if (!isset($default_values['instructorchoiceallowroster'])) {\r
- if (isset($this->typeconfig['instructorchoiceallowroster'])) {\r
- $default_values['instructorchoiceallowroster'] = $this->typeconfig['instructorchoiceallowroster'];\r
- } else {\r
- if ($this->typeconfig['allowroster'] == 2) {\r
- $default_values['instructorchoiceallowroster'] = $CFG->lti_instructorchoiceallowroster;\r
- } else {\r
- $default_values['instructorchoiceallowroster'] = $this->typeconfig['allowroster'];\r
- }\r
- }\r
- }\r
-\r
- if (!isset($default_values['allowsetting'])) {\r
- if (isset($this->typeconfig['allowsetting'])) {\r
- $default_values['allowsetting'] = $this->typeconfig['allowsetting'];\r
- } else if (isset($CFG->lti_allowsetting)) {\r
- $default_values['allowsetting'] = $CFG->lti_allowsetting;\r
- }\r
- }\r
-\r
- if (!isset($default_values['instructorchoiceallowsetting'])) {\r
- if (isset($this->typeconfig['instructorchoiceallowsetting'])) {\r
- $default_values['instructorchoiceallowsetting'] = $this->typeconfig['instructorchoiceallowsetting'];\r
- } else {\r
- if ($this->typeconfig['allowsetting'] == 2) {\r
- $default_values['instructorchoiceallowsetting'] = $CFG->lti_instructorchoiceallowsetting;\r
- } else {\r
- $default_values['instructorchoiceallowsetting'] = $this->typeconfig['allowsetting'];\r
- }\r
- }\r
- }\r
-\r
- if (!isset($default_values['customparameters'])) {\r
- if (isset($this->typeconfig['customparameters'])) {\r
- $default_values['customparameters'] = $this->typeconfig['customparameters'];\r
- } else if (isset($CFG->lti_customparameters)) {\r
- $default_values['customparameters'] = $CFG->lti_customparameters;\r
- }\r
- }\r
-\r
- if (!isset($default_values['allowinstructorcustom'])) {\r
- if (isset($this->typeconfig['allowinstructorcustom'])) {\r
- $default_values['allowinstructorcustom'] = $this->typeconfig['allowinstructorcustom'];\r
- } else if (isset($CFG->lti_allowinstructorcustom)) {\r
- $default_values['allowinstructorcustom'] = $CFG->lti_allowinstructorcustom;\r
- }\r
- }\r
-\r
- if (!isset($default_values['organizationid'])) {\r
- if (isset($this->typeconfig['organizationid'])) {\r
- $default_values['organizationid'] = $this->typeconfig['organizationid'];\r
- } else if (isset($CFG->lti_organizationid)) {\r
- $default_values['organizationid'] = $CFG->lti_organizationid;\r
- }\r
- }\r
-\r
- if (!isset($default_values['organizationurl'])) {\r
- if (isset($this->typeconfig['organizationurl'])) {\r
- $default_values['organizationurl'] = $this->typeconfig['organizationurl'];\r
- } else if (isset($CFG->lti_organizationurl)) {\r
- $default_values['organizationurl'] = $CFG->lti_organizationurl;\r
- }\r
- }\r
-\r
- if (!isset($default_values['organizationdescr'])) {\r
- if (isset($this->typeconfig['organizationdescr'])) {\r
- $default_values['organizationdescr'] = $this->typeconfig['organizationdescr'];\r
- } else if (isset($CFG->lti_organizationdescr)) {\r
- $default_values['organizationdescr'] = $CFG->lti_organizationdescr;\r
- }\r
- }\r
-\r
- if (!isset($default_values['launchinpopup'])) {\r
- if (isset($this->typeconfig['launchinpopup'])) {\r
- $default_values['launchinpopup'] = $this->typeconfig['launchinpopup'];\r
- } else if (isset($CFG->lti_launchinpopup)) {\r
- $default_values['launchinpopup'] = $CFG->lti_launchinpopup;\r
- }\r
- }\r
-*/\r
- }\r
-}\r
-\r
+<?php
+// This file is part of BasicLTI4Moodle
+//
+// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
+// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
+// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
+// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
+// are already supporting or going to support BasicLTI. This project Implements the consumer
+// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
+// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
+// at the GESSI research group at UPC.
+// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
+// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
+// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
+//
+// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
+// of the Universitat Politecnica de Catalunya http://www.upc.edu
+// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * This file defines the main basiclti configuration form
+ *
+ * @package lti
+ * @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
+ * marc.alier@upc.edu
+ * @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
+ *
+ * @author Marc Alier
+ * @author Jordi Piguillem
+ * @author Nikolas Galanis
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die;
+
+require_once($CFG->dirroot.'/course/moodleform_mod.php');
+require_once($CFG->dirroot.'/mod/lti/locallib.php');
+
+class mod_lti_mod_form extends moodleform_mod {
+
+ function definition() {
+ global $DB, $PAGE, $OUTPUT, $USER, $COURSE;
+
+ $this->typeid = 0;
+
+ $mform =& $this->_form;
+//-------------------------------------------------------------------------------
+ /// Adding the "general" fieldset, where all the common settings are shown
+ $mform->addElement('header', 'general', get_string('general', 'form'));
+ /// Adding the standard "name" field
+ $mform->addElement('text', 'name', get_string('basicltiname', 'lti'), array('size'=>'64'));
+ $mform->setType('name', PARAM_TEXT);
+ $mform->addRule('name', null, 'required', null, 'client');
+ /// Adding the optional "intro" and "introformat" pair of fields
+ $this->add_intro_editor(false, get_string('basicltiintro', 'lti'));
+ $mform->setAdvanced('introeditor');
+
+ $mform->addElement('checkbox', 'showtitle', ' ', ' ' . get_string('display_name', 'lti'));
+ $mform->setAdvanced('showtitle');
+
+ $mform->addElement('checkbox', 'showdescription', ' ', ' ' . get_string('display_description', 'lti'));
+ $mform->setAdvanced('showdescription');
+
+ //Tool settings
+ $tooltypes = $mform->addElement('select', 'typeid', get_string('external_tool_type', 'lti'), array());
+
+ foreach(lti_get_types_for_add_instance() as $id => $type){
+ if($type->course == $COURSE->id) {
+ $attributes = array( 'editable' => 1 );
+ } else {
+ $attributes = array();
+ }
+
+ $tooltypes->addOption($type->name, $id, $attributes);
+ }
+
+ $mform->addElement('text', 'toolurl', get_string('launch_url', 'lti'), array('size'=>'64'));
+ $mform->setType('toolurl', PARAM_TEXT);
+
+ $launchoptions=array();
+ $launchoptions[LTI_LAUNCH_CONTAINER_DEFAULT] = get_string('default', 'lti');
+ $launchoptions[LTI_LAUNCH_CONTAINER_EMBED] = get_string('embed', 'lti');
+ $launchoptions[LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS] = get_string('embed_no_blocks', 'lti');
+ $launchoptions[LTI_LAUNCH_CONTAINER_WINDOW] = get_string('new_window', 'lti');
+
+ $mform->addElement('select', 'launchcontainer', get_string('launchinpopup', 'lti'), $launchoptions);
+ $mform->setDefault('launchcontainer', LTI_LAUNCH_CONTAINER_DEFAULT);
+
+ $mform->addElement('text', 'resourcekey', get_string('resourcekey', 'lti'));
+ $mform->setType('resourcekey', PARAM_TEXT);
+ $mform->setAdvanced('resourcekey');
+
+ $mform->addElement('passwordunmask', 'password', get_string('password', 'lti'));
+ $mform->setType('password', PARAM_TEXT);
+ $mform->setAdvanced('password');
+
+ $mform->addElement('textarea', 'instructorcustomparameters', get_string('custom', 'lti'), array('rows'=>4, 'cols'=>60));
+ $mform->setType('instructorcustomparameters', PARAM_TEXT);
+ $mform->setAdvanced('instructorcustomparameters');
+
+//-------------------------------------------------------------------------------
+ //$mform->addElement('hidden', 'typeid', $this->typeid);
+ //$mform->addElement('hidden', 'toolurl', $this->typeconfig['toolurl']);
+ //$mform->addElement('hidden', 'type', $typename);
+
+//-------------------------------------------------------------------------------
+ // Add privacy preferences fieldset where users choose whether to send their data
+ $mform->addElement('header', 'privacy', get_string('privacy', 'lti'));
+
+ $mform->addElement('checkbox', 'instructorchoicesendname', ' ', ' ' . get_string('share_name', 'lti'));
+ $mform->setDefault('instructorchoicesendname', '1');
+
+ $mform->addElement('checkbox', 'instructorchoicesendemailaddr', ' ', ' ' . get_string('share_email', 'lti'));
+ $mform->setDefault('instructorchoicesendemailaddr', '1');
+
+ $mform->addElement('checkbox', 'instructorchoiceacceptgrades', ' ', ' ' . get_string('accept_grades', 'lti'));
+ $mform->setDefault('instructorchoiceacceptgrades', '1');
+
+ $mform->addElement('checkbox', 'instructorchoiceallowroster', ' ', ' ' . get_string('share_roster', 'lti'));
+ $mform->setDefault('instructorchoiceallowroster', '1');
+
+//-------------------------------------------------------------------------------
+
+/* $debugoptions=array();
+ $debugoptions[0] = get_string('debuglaunchoff', 'lti');
+ $debugoptions[1] = get_string('debuglaunchon', 'lti');
+
+ $mform->addElement('select', 'debuglaunch', get_string('debuglaunch', 'lti'), $debugoptions);
+
+ if (isset($this->typeconfig['debuglaunch'])) {
+ if ($this->typeconfig['debuglaunch'] == 0) {
+ $mform->setDefault('debuglaunch', '0');
+ } else if ($this->typeconfig['debuglaunch'] == 1) {
+ $mform->setDefault('debuglaunch', '1');
+ }
+ }
+*/
+
+//-------------------------------------------------------------------------------
+ // add standard elements, common to all modules
+ $this->standard_coursemodule_elements();
+
+ $mform->setAdvanced('cmidnumber');
+//-------------------------------------------------------------------------------
+ // add standard buttons, common to all modules
+ $this->add_action_buttons();
+
+ $url = new moodle_url("/mod/lti/instructor_edit_tool_type.php?sesskey={$USER->sesskey}&course={$COURSE->id}");
+ $jsinfo = (object)array(
+ 'edit_icon_url' => (string)$OUTPUT->pix_url('t/edit'),
+ 'add_icon_url' => (string)$OUTPUT->pix_url('t/add'),
+ 'delete_icon_url' => (string)$OUTPUT->pix_url('t/delete'),
+ 'instructor_tool_type_edit_url' => $url->out(false)
+ );
+
+ $module = array(
+ 'name' => 'mod_lti_edit',
+ 'fullpath' => '/mod/lti/mod_form.js',
+ 'requires' => array('base', 'io', 'node', 'event', 'json-parse'),
+ 'strings' => array(),
+ );
+
+ $PAGE->requires->js_init_call('M.mod_lti.editor.init', array(json_encode($jsinfo)), true, $module);
+ }
+
+ /**
+ * Make fields editable or non-editable depending on the administrator choices
+ * @see moodleform_mod::definition_after_data()
+ */
+ function definition_after_data() {
+ parent::definition_after_data();
+
+ }
+
+ /**
+ * Function overwritten to change default values using
+ * global configuration
+ *
+ * @param array $default_values passed by reference
+ */
+ function data_preprocessing(&$default_values) {
+
+ }
+}
+
<?php
-require_once("../../config.php");
-require_once($CFG->dirroot.'/mod/lti/OAuthBody.php');
+require_once(dirname(__FILE__) . "/../../config.php");
require_once($CFG->dirroot.'/mod/lti/locallib.php');
+require_once($CFG->dirroot.'/mod/lti/servicelib.php');
-define('LTI_ITEM_TYPE', 'mod');
-define('LTI_ITEM_MODULE', 'lti');
-define('LTI_SOURCE', 'mod/lti');
-
-function lti_get_response_xml($codemajor, $description, $messageref, $messagetype){
- $xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><imsx_POXEnvelopeResponse />');
- $xml->addAttribute('xmlns', 'http://www.imsglobal.org/lis/oms1p0/pox');
-
- $headerinfo = $xml->addChild('imsx_POXHeader')
- ->addChild('imsx_POXResponseHeaderInfo');
-
- $headerinfo->addChild('imsx_version', 'V1.0');
- $headerinfo->addChild('imsx_messageIdentifier', (string)mt_rand());
-
- $statusinfo = $headerinfo->addChild('imsx_statusInfo');
- $statusinfo->addchild('imsx_codeMajor', $codemajor);
- $statusinfo->addChild('imsx_severity', 'status');
- $statusinfo->addChild('imsx_description', $description);
- $statusinfo->addChild('imsx_messageRefIdentifier', $messageref);
-
- $xml->addChild('imsx_POXBody')
- ->addChild($messagetype);
-
- return $xml;
-}
-
-function lti_parse_message_id($xml){
- $node = $xml->imsx_POXHeader->imsx_POXRequestHeaderInfo->imsx_messageIdentifier;
- $messageid = (string)$node;
-
- return $messageid;
-}
-
-function lti_parse_grade_replace_message($xml){
- $node = $xml->imsx_POXBody->replaceResultRequest->resultRecord->sourcedGUID->sourcedId;
- $resultjson = json_decode((string)$node);
-
- $node = $xml->imsx_POXBody->replaceResultRequest->resultRecord->result->resultScore->textString;
- $grade = floatval((string)$node);
-
- $parsed = new stdClass();
- $parsed->gradeval = $grade * 100;
- $parsed->instanceid = $resultjson->data->instanceid;
- $parsed->userid = $resultjson->data->userid;
- $parsed->messageid = lti_parse_message_id($xml);
-
- return $parsed;
-}
-
-function lti_parse_grade_read_message($xml){
- $node = $xml->imsx_POXBody->readResultRequest->resultRecord->sourcedGUID->sourcedId;
- $resultjson = json_decode((string)$node);
-
- $parsed = new stdClass();
- $parsed->instanceid = $resultjson->data->instanceid;
- $parsed->userid = $resultjson->data->userid;
- $parsed->messageid = lti_parse_message_id($xml);
-
- return $parsed;
-}
-
-function lti_parse_grade_delete_message($xml){
- $node = $xml->imsx_POXBody->deleteResultRequest->resultRecord->sourcedGUID->sourcedId;
- $resultjson = json_decode((string)$node);
-
- $parsed = new stdClass();
- $parsed->instanceid = $resultjson->data->instanceid;
- $parsed->userid = $resultjson->data->userid;
- $parsed->messageid = lti_parse_message_id($xml);
-
- return $parsed;
-}
-
-function lti_update_grade($ltiinstance, $userid, $gradeval){
- global $CFG;
- require_once($CFG->libdir . '/gradelib.php');
-
- $params = array();
- $params['itemname'] = $ltiinstance->name;
-
- $grade = new stdClass();
- $grade->userid = $userid;
- $grade->rawgrade = $gradeval;
-
- $status = grade_update(LTI_SOURCE, $ltiinstance->course, LTI_ITEM_TYPE, LTI_ITEM_MODULE, $ltiinstance->id, 0, $grade, $params);
-
- return $status == GRADE_UPDATE_OK;
-}
-
-function lti_read_grade($ltiinstance, $userid){
- global $CFG;
- require_once($CFG->libdir . '/gradelib.php');
-
- $grades = grade_get_grades($ltiinstance->course, LTI_ITEM_TYPE, LTI_ITEM_MODULE, $ltiinstance->id, $userid);
-
- if (isset($grades) && is_array($grades->items[0]->grades)) {
- foreach ($grades->items[0]->grades as $agrade) {
- $grade = $agrade->grade;
- break;
- }
- }
-
- if(isset($grade)){
- return $grade;
- }
-}
-
-function lti_delete_grade($ltiinstance, $userid){
- $grade = new stdClass();
- $grade->userid = $userid;
- $grade->rawgrade = null;
-
- $status = grade_update(LTI_SOURCE, $ltiinstance->course, LTI_ITEM_TYPE, LTI_ITEM_MODULE, $ltiinstance->id, 0, $grade, array('deleted'=>1));
-
- return $status == GRADE_UPDATE_OK || $status == GRADE_UPDATE_ITEM_DELETED; //grade_update seems to return ok now, but could reasonably return deleted in the future
-}
-
-function lti_verify_message($ltiinstance){
- //Use the key / secret configured on the tool, or look it up from the admin config
- if(empty($ltiinstance->resourcekey) || empty($ltiinstance->password)){
- if($ltiinstance->typeid){
- $typeid = $ltiinstance->typeid;
- } else {
- $tool = lti_get_tool_by_url_match($ltiinstance->toolurl);
-
- if(!$tool){
- throw new Exception('Tool configuration not found for tool instance ' . $ltiinstance->id);
- }
-
- $typeid = $tool->id;
- }
-
- $typeconfig = lti_get_type_config($typeid);//Consider only fetching the 2 necessary settings here
-
- $key = $typeconfig['resourcekey'];
- $secret = $typeconfig['password'];
- } else {
- $key = $ltiinstance->resourcekey;
- $secret = $ltiinstance->password;
- }
-
- handleOAuthBodyPOST($key, $secret);
-}
-
-$xmlfragment = file_get_contents("php://input");
-$xml = new SimpleXMLElement($xmlfragment);
+$rawbody = file_get_contents("php://input");
+$xml = new SimpleXMLElement($rawbody);
$body = $xml->imsx_POXBody;
foreach($body->children() as $child){
$ltiinstance = $DB->get_record('lti', array('id' => $parsed->instanceid));
- lti_verify_message($ltiinstance);
+ lti_verify_sourcedid($ltiinstance, $parsed);
+ lti_verify_message($ltiinstance, $rawbody);
$gradestatus = lti_update_grade($ltiinstance, $parsed->userid, $parsed->gradeval);
$ltiinstance = $DB->get_record('lti', array('id' => $parsed->instanceid));
- lti_verify_message($ltiinstance);
+ lti_verify_sourcedid($ltiinstance, $parsed);
+ lti_verify_message($ltiinstance, $rawbody);
$grade = lti_read_grade($ltiinstance, $parsed->userid);
$ltiinstance = $DB->get_record('lti', array('id' => $parsed->instanceid));
- lti_verify_message($ltiinstance);
+ lti_verify_sourcedid($ltiinstance, $parsed);
+ lti_verify_message($ltiinstance, $rawbody);
$gradestatus = lti_delete_grade($ltiinstance, $parsed->userid);
}
-//echo print_r(apache_request_headers(), true);
+echo print_r(apache_request_headers(), true);
-//echo '<br />';
+echo '<br />';
-//echo file_get_contents("php://input");
\ No newline at end of file
+echo file_get_contents("php://input");
\ No newline at end of file
--- /dev/null
+<?php
+
+require_once($CFG->dirroot.'/mod/lti/OAuthBody.php');
+
+define('LTI_ITEM_TYPE', 'mod');
+define('LTI_ITEM_MODULE', 'lti');
+define('LTI_SOURCE', 'mod/lti');
+
+function lti_get_response_xml($codemajor, $description, $messageref, $messagetype){
+ $xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><imsx_POXEnvelopeResponse />');
+ $xml->addAttribute('xmlns', 'http://www.imsglobal.org/lis/oms1p0/pox');
+
+ $headerinfo = $xml->addChild('imsx_POXHeader')
+ ->addChild('imsx_POXResponseHeaderInfo');
+
+ $headerinfo->addChild('imsx_version', 'V1.0');
+ $headerinfo->addChild('imsx_messageIdentifier', (string)mt_rand());
+
+ $statusinfo = $headerinfo->addChild('imsx_statusInfo');
+ $statusinfo->addchild('imsx_codeMajor', $codemajor);
+ $statusinfo->addChild('imsx_severity', 'status');
+ $statusinfo->addChild('imsx_description', $description);
+ $statusinfo->addChild('imsx_messageRefIdentifier', $messageref);
+
+ $xml->addChild('imsx_POXBody')
+ ->addChild($messagetype);
+
+ return $xml;
+}
+
+function lti_parse_message_id($xml){
+ $node = $xml->imsx_POXHeader->imsx_POXRequestHeaderInfo->imsx_messageIdentifier;
+ $messageid = (string)$node;
+
+ return $messageid;
+}
+
+function lti_parse_grade_replace_message($xml){
+ $node = $xml->imsx_POXBody->replaceResultRequest->resultRecord->sourcedGUID->sourcedId;
+ $resultjson = json_decode((string)$node);
+
+ $node = $xml->imsx_POXBody->replaceResultRequest->resultRecord->result->resultScore->textString;
+ $grade = floatval((string)$node);
+
+ $parsed = new stdClass();
+ $parsed->gradeval = $grade * 100;
+
+ $parsed->instanceid = $resultjson->data->instanceid;
+ $parsed->userid = $resultjson->data->userid;
+ $parsed->sourcedidhash = $resultjson->hash;
+
+ $parsed->messageid = lti_parse_message_id($xml);
+
+ return $parsed;
+}
+
+function lti_parse_grade_read_message($xml){
+ $node = $xml->imsx_POXBody->readResultRequest->resultRecord->sourcedGUID->sourcedId;
+ $resultjson = json_decode((string)$node);
+
+ $parsed = new stdClass();
+ $parsed->instanceid = $resultjson->data->instanceid;
+ $parsed->userid = $resultjson->data->userid;
+ $parsed->sourcedidhash = $resultjson->hash;
+
+ $parsed->messageid = lti_parse_message_id($xml);
+
+ return $parsed;
+}
+
+function lti_parse_grade_delete_message($xml){
+ $node = $xml->imsx_POXBody->deleteResultRequest->resultRecord->sourcedGUID->sourcedId;
+ $resultjson = json_decode((string)$node);
+
+ $parsed = new stdClass();
+ $parsed->instanceid = $resultjson->data->instanceid;
+ $parsed->userid = $resultjson->data->userid;
+ $parsed->sourcedidhash = $resultjson->hash;
+
+ $parsed->messageid = lti_parse_message_id($xml);
+
+ return $parsed;
+}
+
+function lti_update_grade($ltiinstance, $userid, $gradeval){
+ global $CFG;
+ require_once($CFG->libdir . '/gradelib.php');
+
+ $params = array();
+ $params['itemname'] = $ltiinstance->name;
+
+ $grade = new stdClass();
+ $grade->userid = $userid;
+ $grade->rawgrade = $gradeval;
+
+ $status = grade_update(LTI_SOURCE, $ltiinstance->course, LTI_ITEM_TYPE, LTI_ITEM_MODULE, $ltiinstance->id, 0, $grade, $params);
+
+ return $status == GRADE_UPDATE_OK;
+}
+
+function lti_read_grade($ltiinstance, $userid){
+ global $CFG;
+ require_once($CFG->libdir . '/gradelib.php');
+
+ $grades = grade_get_grades($ltiinstance->course, LTI_ITEM_TYPE, LTI_ITEM_MODULE, $ltiinstance->id, $userid);
+
+ if (isset($grades) && is_array($grades->items[0]->grades)) {
+ foreach ($grades->items[0]->grades as $agrade) {
+ $grade = $agrade->grade;
+ break;
+ }
+ }
+
+ if(isset($grade)){
+ return $grade;
+ }
+}
+
+function lti_delete_grade($ltiinstance, $userid){
+ $grade = new stdClass();
+ $grade->userid = $userid;
+ $grade->rawgrade = null;
+
+ $status = grade_update(LTI_SOURCE, $ltiinstance->course, LTI_ITEM_TYPE, LTI_ITEM_MODULE, $ltiinstance->id, 0, $grade, array('deleted'=>1));
+
+ return $status == GRADE_UPDATE_OK || $status == GRADE_UPDATE_ITEM_DELETED; //grade_update seems to return ok now, but could reasonably return deleted in the future
+}
+
+function lti_verify_message($ltiinstance, $body, $headers = null){
+ //Use the key / secret configured on the tool, or look it up from the admin config
+ if(empty($ltiinstance->resourcekey) || empty($ltiinstance->password)){
+ if($ltiinstance->typeid){
+ $typeid = $ltiinstance->typeid;
+ } else {
+ $tool = lti_get_tool_by_url_match($ltiinstance->toolurl, $ltiinstance->course);
+
+ if(!$tool){
+ throw new Exception('Tool configuration not found for tool instance ' . $ltiinstance->id);
+ }
+
+ $typeid = $tool->id;
+ }
+
+ $typeconfig = lti_get_type_config($typeid);//Consider only fetching the 2 necessary settings here
+
+ $key = $typeconfig['resourcekey'];
+ $secret = $typeconfig['password'];
+ } else {
+ $key = $ltiinstance->resourcekey;
+ $secret = $ltiinstance->password;
+ }
+
+ handleOAuthBodyPOST($key, $secret, $body, $headers);
+}
+
+function lti_verify_sourcedid($ltiinstance, $parsed){
+ $sourceid = lti_build_sourcedid($parsed->instanceid, $parsed->userid, $ltiinstance->servicesalt);
+
+ if($sourceid->hash != $parsed->sourcedidhash){
+ throw new Exception('SourcedId hash not valid');
+ }
+}
+
+?>
-<?php\r
-// This file is part of BasicLTI4Moodle\r
-//\r
-// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)\r
-// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web\r
-// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI\r
-// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS\r
-// are already supporting or going to support BasicLTI. This project Implements the consumer\r
-// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.\r
-// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem\r
-// at the GESSI research group at UPC.\r
-// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI\r
-// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a\r
-// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.\r
-//\r
-// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis\r
-// of the Universitat Politecnica de Catalunya http://www.upc.edu\r
-// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu\r
-//\r
-// Moodle is free software: you can redistribute it and/or modify\r
-// it under the terms of the GNU General Public License as published by\r
-// the Free Software Foundation, either version 3 of the License, or\r
-// (at your option) any later version.\r
-//\r
-// Moodle is distributed in the hope that it will be useful,\r
-// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-// GNU General Public License for more details.\r
-//\r
-// You should have received a copy of the GNU General Public License\r
-// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\r
-\r
-/**\r
- * This file defines the global basiclti administration form\r
- *\r
- * @package lti\r
- * @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis\r
- * marc.alier@upc.edu\r
- * @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu\r
- *\r
- * @author Marc Alier\r
- * @author Jordi Piguillem\r
- * @author Nikolas Galanis\r
- *\r
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r
- */\r
-\r
-defined('MOODLE_INTERNAL') || die;\r
-\r
-global $PAGE, $CFG;\r
-\r
-require_once($CFG->dirroot.'/mod/lti/locallib.php');\r
-\r
-function blti_get_tool_table($tools, $id){\r
- global $CFG, $USER;\r
- $html = '';\r
- \r
- $typename = get_string('typename', 'lti');\r
- $baseurl = get_string('baseurl', 'lti');\r
- $action = get_string('action', 'lti');\r
- $createdon = get_string('createdon', 'lti');\r
- \r
- if($id == 'lti_configured'){\r
- $html .= '<div><a style="margin-top:.25em" href="'.$CFG->wwwroot.'/mod/lti/typessettings.php?action=add&sesskey='.$USER->sesskey.'">'.get_string('addtype', 'lti').'</a></div>';\r
- }\r
- \r
- if (!empty($tools)) {\r
- $html .= <<<HTML\r
- <div id="{$id}_container" style="margin-top:.5em;margin-bottom:.5em">\r
- <table id="{$id}_tools">\r
- <thead>\r
- <tr>\r
- <th>$typename</th>\r
- <th>$baseurl</th>\r
- <th>$createdon</th>\r
- <th>$action</th>\r
- </tr>\r
- </thead>\r
-HTML;\r
- \r
- foreach ($tools as $type) {\r
- $date = userdate($type->timecreated);\r
- $accept = get_string('accept', 'lti');\r
- $update = get_string('update', 'lti');\r
- $delete = get_string('delete', 'lti');\r
- \r
- $accepthtml = <<<HTML\r
- <a class="editing_accept" href="{$CFG->wwwroot}/mod/lti/typessettings.php?action=accept&id={$type->id}&sesskey={$USER->sesskey}&tab={$id}" title="{$accept}">\r
- <img class="iconsmall" alt="{$accept}" src="{$CFG->wwwroot}/pix/t/clear.gif"/>\r
- </a>\r
-HTML;\r
-\r
- $deleteaction = 'delete';\r
- \r
- if($type->state == LTI_TOOL_STATE_CONFIGURED){\r
- $accepthtml = '';\r
- }\r
- \r
- if($type->state != LTI_TOOL_STATE_REJECTED) {\r
- $deleteaction = 'reject';\r
- $delete = get_string('reject', 'lti');\r
- }\r
- \r
- $html .= <<<HTML\r
- <tr>\r
- <td>\r
- {$type->name}\r
- </td>\r
- <td>\r
- {$type->baseurl}\r
- </td>\r
- <td>\r
- {$date}\r
- </td>\r
- <td align="center">\r
- {$accepthtml}\r
- <a class="editing_update" href="{$CFG->wwwroot}/mod/lti/typessettings.php?action=update&id={$type->id}&sesskey={$USER->sesskey}&tab={$id}" title="{$update}">\r
- <img class="iconsmall" alt="{$update}" src="{$CFG->wwwroot}/pix/t/edit.gif"/>\r
- </a>\r
- <a class="editing_delete" href="{$CFG->wwwroot}/mod/lti/typessettings.php?action={$deleteaction}&id={$type->id}&sesskey={$USER->sesskey}&tab={$id}" title="{$delete}">\r
- <img class="iconsmall" alt="{$delete}" src="{$CFG->wwwroot}/pix/t/delete.gif"/>\r
- </a>\r
- </td>\r
- </tr>\r
-HTML;\r
- }\r
- $html .= '</table></div>';\r
- } else {\r
- $html .= get_string('no_' . $id, 'lti');\r
- }\r
- \r
- return $html;\r
-}\r
-\r
-if ($ADMIN->fulltree) {\r
- require_once($CFG->dirroot.'/mod/lti/locallib.php');\r
-\r
- $configuredtoolshtml = '';\r
- $pendingtoolshtml = '';\r
- $rejectedtoolshtml = '';\r
-\r
- $active = get_string('active', 'lti');\r
- $pending = get_string('pending', 'lti');\r
- $rejected = get_string('rejected', 'lti');\r
- $typename = get_string('typename', 'lti');\r
- $baseurl = get_string('baseurl', 'lti');\r
- $action = get_string('action', 'lti');\r
- $createdon = get_string('createdon', 'lti');\r
- \r
- $types = lti_filter_get_types();\r
- \r
- $configuredtools = array_filter($types, function($value){\r
- return $value->state == LTI_TOOL_STATE_CONFIGURED;\r
- });\r
- \r
- $configuredtoolshtml = blti_get_tool_table($configuredtools, 'lti_configured');\r
-\r
- $pendingtools = array_filter($types, function($value){\r
- return $value->state == LTI_TOOL_STATE_PENDING;\r
- });\r
- \r
- $pendingtoolshtml = blti_get_tool_table($pendingtools, 'lti_pending');\r
- \r
- $rejectedtools = array_filter($types, function($value){\r
- return $value->state == LTI_TOOL_STATE_REJECTED;\r
- });\r
- \r
- $rejectedtoolshtml = blti_get_tool_table($rejectedtools, 'lti_rejected');\r
- \r
- $tab = optional_param('tab', '', PARAM_ALPHAEXT);\r
- $activeselected = '';\r
- $pendingselected = '';\r
- $rejectedselected = '';\r
- switch($tab){\r
- case 'lti_pending':\r
- $pendingselected = 'class="selected"';\r
- break;\r
- case 'lti_rejected':\r
- $rejectedselected = 'class="selected"';\r
- break;\r
- default:\r
- $activeselected = 'class="selected"';\r
- break;\r
- }\r
- \r
- $template = <<<HTML\r
-<div id="lti_tabs" class="yui-navset">\r
- <ul id="lti_tab_heading" class="yui-nav" style="display:none">\r
- <li {$activeselected}>\r
- <a href="#tab1">\r
- <em>$active</em>\r
- </a>\r
- </li>\r
- <li {$pendingselected}>\r
- <a href="#tab2">\r
- <em>$pending</em>\r
- </a>\r
- </li>\r
- <li {$rejectedselected}>\r
- <a href="#tab3">\r
- <em>$rejected</em>\r
- </a>\r
- </li>\r
- </ul>\r
- <div class="yui-content">\r
- <div>\r
- $configuredtoolshtml\r
- </div>\r
- <div>\r
- $pendingtoolshtml\r
- </div>\r
- <div>\r
- $rejectedtoolshtml\r
- </div>\r
- </div>\r
-</div>\r
-\r
-<script type='text/javascript'>\r
-//<![CDATA[\r
- (function(){\r
- //If javascript is disabled, they will just see the three tabs one after another\r
- var lti_tab_heading = document.getElementById('lti_tab_heading');\r
- lti_tab_heading.style.display = '';\r
-\r
- new YAHOO.widget.TabView('lti_tabs');\r
- \r
- var setupTools = function(id, sort){\r
- var lti_tools = YAHOO.util.Dom.get(id + "_tools");\r
- \r
- if(lti_tools){\r
- var dataSource = new YAHOO.util.DataSource(lti_tools);\r
- \r
- var configuredColumns = [\r
- {key:"name", label:"$typename", sortable:true},\r
- {key:"baseURL", label:"$baseurl", sortable:true},\r
- {key:"timecreated", label:"$createdon", sortable:true, formatter:YAHOO.widget.DataTable.formatDate},\r
- {key:"action", label:"$action"}\r
- ];\r
-\r
- dataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE;\r
- dataSource.responseSchema = {\r
- fields: [\r
- {key:"name"},\r
- {key:"baseURL"},\r
- {key:"timecreated", parser:"date"},\r
- {key:"action"}\r
- ]\r
- };\r
-\r
- new YAHOO.widget.DataTable(id + "_container", configuredColumns, dataSource,\r
- {\r
- sortedBy: sort\r
- }\r
- );\r
- }\r
- };\r
-\r
- setupTools('lti_configured', {key:"name", dir:"asc"});\r
- setupTools('lti_pending', {key:"timecreated", dir:"desc"});\r
- setupTools('lti_rejected', {key:"timecreated", dir:"desc"});\r
- })();\r
-//]]\r
-</script>\r
-HTML;\r
- \r
- $PAGE->requires->yui2_lib('tabview');\r
- $PAGE->requires->yui2_lib('datatable');\r
- \r
- $settings->add(new admin_setting_heading('lti_types', get_string('external_tool_types', 'lti'), $template /* $str*/));\r
-}\r
+<?php
+// This file is part of BasicLTI4Moodle
+//
+// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
+// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
+// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
+// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
+// are already supporting or going to support BasicLTI. This project Implements the consumer
+// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
+// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
+// at the GESSI research group at UPC.
+// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
+// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
+// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
+//
+// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
+// of the Universitat Politecnica de Catalunya http://www.upc.edu
+// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * This file defines the global basiclti administration form
+ *
+ * @package lti
+ * @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
+ * marc.alier@upc.edu
+ * @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
+ *
+ * @author Marc Alier
+ * @author Jordi Piguillem
+ * @author Nikolas Galanis
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die;
+
+global $PAGE, $CFG;
+
+require_once($CFG->dirroot.'/mod/lti/locallib.php');
+
+function lti_get_tool_table($tools, $id){
+ global $CFG, $USER;
+ $html = '';
+
+ $typename = get_string('typename', 'lti');
+ $baseurl = get_string('baseurl', 'lti');
+ $action = get_string('action', 'lti');
+ $createdon = get_string('createdon', 'lti');
+
+ if($id == 'lti_configured'){
+ $html .= '<div><a style="margin-top:.25em" href="'.$CFG->wwwroot.'/mod/lti/typessettings.php?action=add&sesskey='.$USER->sesskey.'">'.get_string('addtype', 'lti').'</a></div>';
+ }
+
+ if (!empty($tools)) {
+ $html .= <<<HTML
+ <div id="{$id}_container" style="margin-top:.5em;margin-bottom:.5em">
+ <table id="{$id}_tools">
+ <thead>
+ <tr>
+ <th>$typename</th>
+ <th>$baseurl</th>
+ <th>$createdon</th>
+ <th>$action</th>
+ </tr>
+ </thead>
+HTML;
+
+ foreach ($tools as $type) {
+ $date = userdate($type->timecreated);
+ $accept = get_string('accept', 'lti');
+ $update = get_string('update', 'lti');
+ $delete = get_string('delete', 'lti');
+
+ $accepthtml = <<<HTML
+ <a class="editing_accept" href="{$CFG->wwwroot}/mod/lti/typessettings.php?action=accept&id={$type->id}&sesskey={$USER->sesskey}&tab={$id}" title="{$accept}">
+ <img class="iconsmall" alt="{$accept}" src="{$CFG->wwwroot}/pix/t/clear.gif"/>
+ </a>
+HTML;
+
+ $deleteaction = 'delete';
+
+ if($type->state == LTI_TOOL_STATE_CONFIGURED){
+ $accepthtml = '';
+ }
+
+ if($type->state != LTI_TOOL_STATE_REJECTED) {
+ $deleteaction = 'reject';
+ $delete = get_string('reject', 'lti');
+ }
+
+ $html .= <<<HTML
+ <tr>
+ <td>
+ {$type->name}
+ </td>
+ <td>
+ {$type->baseurl}
+ </td>
+ <td>
+ {$date}
+ </td>
+ <td align="center">
+ {$accepthtml}
+ <a class="editing_update" href="{$CFG->wwwroot}/mod/lti/typessettings.php?action=update&id={$type->id}&sesskey={$USER->sesskey}&tab={$id}" title="{$update}">
+ <img class="iconsmall" alt="{$update}" src="{$CFG->wwwroot}/pix/t/edit.gif"/>
+ </a>
+ <a class="editing_delete" href="{$CFG->wwwroot}/mod/lti/typessettings.php?action={$deleteaction}&id={$type->id}&sesskey={$USER->sesskey}&tab={$id}" title="{$delete}">
+ <img class="iconsmall" alt="{$delete}" src="{$CFG->wwwroot}/pix/t/delete.gif"/>
+ </a>
+ </td>
+ </tr>
+HTML;
+ }
+ $html .= '</table></div>';
+ } else {
+ $html .= get_string('no_' . $id, 'lti');
+ }
+
+ return $html;
+}
+
+if ($ADMIN->fulltree) {
+ require_once($CFG->dirroot.'/mod/lti/locallib.php');
+
+ $configuredtoolshtml = '';
+ $pendingtoolshtml = '';
+ $rejectedtoolshtml = '';
+
+ $active = get_string('active', 'lti');
+ $pending = get_string('pending', 'lti');
+ $rejected = get_string('rejected', 'lti');
+ $typename = get_string('typename', 'lti');
+ $baseurl = get_string('baseurl', 'lti');
+ $action = get_string('action', 'lti');
+ $createdon = get_string('createdon', 'lti');
+
+ $types = lti_filter_get_types();
+
+ $configuredtools = array_filter($types, function($value){
+ return $value->state == LTI_TOOL_STATE_CONFIGURED;
+ });
+
+ $configuredtoolshtml = lti_get_tool_table($configuredtools, 'lti_configured');
+
+ $pendingtools = array_filter($types, function($value){
+ return $value->state == LTI_TOOL_STATE_PENDING;
+ });
+
+ $pendingtoolshtml = lti_get_tool_table($pendingtools, 'lti_pending');
+
+ $rejectedtools = array_filter($types, function($value){
+ return $value->state == LTI_TOOL_STATE_REJECTED;
+ });
+
+ $rejectedtoolshtml = lti_get_tool_table($rejectedtools, 'lti_rejected');
+
+ $tab = optional_param('tab', '', PARAM_ALPHAEXT);
+ $activeselected = '';
+ $pendingselected = '';
+ $rejectedselected = '';
+ switch($tab){
+ case 'lti_pending':
+ $pendingselected = 'class="selected"';
+ break;
+ case 'lti_rejected':
+ $rejectedselected = 'class="selected"';
+ break;
+ default:
+ $activeselected = 'class="selected"';
+ break;
+ }
+
+ $template = <<<HTML
+<div id="lti_tabs" class="yui-navset">
+ <ul id="lti_tab_heading" class="yui-nav" style="display:none">
+ <li {$activeselected}>
+ <a href="#tab1">
+ <em>$active</em>
+ </a>
+ </li>
+ <li {$pendingselected}>
+ <a href="#tab2">
+ <em>$pending</em>
+ </a>
+ </li>
+ <li {$rejectedselected}>
+ <a href="#tab3">
+ <em>$rejected</em>
+ </a>
+ </li>
+ </ul>
+ <div class="yui-content">
+ <div>
+ $configuredtoolshtml
+ </div>
+ <div>
+ $pendingtoolshtml
+ </div>
+ <div>
+ $rejectedtoolshtml
+ </div>
+ </div>
+</div>
+
+<script type='text/javascript'>
+//<![CDATA[
+ (function(){
+ //If javascript is disabled, they will just see the three tabs one after another
+ var lti_tab_heading = document.getElementById('lti_tab_heading');
+ lti_tab_heading.style.display = '';
+
+ new YAHOO.widget.TabView('lti_tabs');
+
+ var setupTools = function(id, sort){
+ var lti_tools = YAHOO.util.Dom.get(id + "_tools");
+
+ if(lti_tools){
+ var dataSource = new YAHOO.util.DataSource(lti_tools);
+
+ var configuredColumns = [
+ {key:"name", label:"$typename", sortable:true},
+ {key:"baseURL", label:"$baseurl", sortable:true},
+ {key:"timecreated", label:"$createdon", sortable:true, formatter:YAHOO.widget.DataTable.formatDate},
+ {key:"action", label:"$action"}
+ ];
+
+ dataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE;
+ dataSource.responseSchema = {
+ fields: [
+ {key:"name"},
+ {key:"baseURL"},
+ {key:"timecreated", parser:"date"},
+ {key:"action"}
+ ]
+ };
+
+ new YAHOO.widget.DataTable(id + "_container", configuredColumns, dataSource,
+ {
+ sortedBy: sort
+ }
+ );
+ }
+ };
+
+ setupTools('lti_configured', {key:"name", dir:"asc"});
+ setupTools('lti_pending', {key:"timecreated", dir:"desc"});
+ setupTools('lti_rejected', {key:"timecreated", dir:"desc"});
+ })();
+//]]
+</script>
+HTML;
+
+ $PAGE->requires->yui2_lib('tabview');
+ $PAGE->requires->yui2_lib('datatable');
+
+ $settings->add(new admin_setting_heading('lti_types', get_string('external_tool_types', 'lti'), $template));
+}
}
require_once($CFG->dirroot . '/mod/lti/locallib.php');
+require_once($CFG->dirroot . '/mod/lti/servicelib.php');
class lti_locallib_test extends UnitTestCase {
public static $includecoverage = array('mod/lti/locallib.php');
+
function test_split_custom_parameters() {
- $this->assertEqual(lti_split_custom_parameters("x=1\ny=2"),
- array('custom_x' => '1', 'custom_y'=> '2'));
- $this->assertEqual(lti_split_custom_parameters('x=1;y=2'),
- array('custom_x' => '1', 'custom_y'=> '2'));
- $this->assertEqual(lti_split_custom_parameters('Review:Chapter=1.2.56'),
- array('custom_review_chapter' => '1.2.56'));
- $this->assertEqual(lti_split_custom_parameters('Complex!@#$^*(){}[]KEY=Complex!@#$^*(){}[]Value'),
- array('custom_complex____________key' => 'Complex!@#$^*(){}[]Value'));
- $this->assertEqual(5, 5);
+ $this->assertEqual(lti_split_custom_parameters("x=1\ny=2"),
+ array('custom_x' => '1', 'custom_y'=> '2'));
+
+ $this->assertEqual(lti_split_custom_parameters('x=1;y=2'),
+ array('custom_x' => '1', 'custom_y'=> '2'));
+
+ $this->assertEqual(lti_split_custom_parameters('Review:Chapter=1.2.56'),
+ array('custom_review_chapter' => '1.2.56'));
+
+ $this->assertEqual(lti_split_custom_parameters('Complex!@#$^*(){}[]KEY=Complex!@#$^*(){}[]Value'),
+ array('custom_complex____________key' => 'Complex!@#$^*(){}[]Value'));
}
function test_sign_parameters() {
$this->assertEqual($parms, $correct);
}
+ function test_parse_grade_replace_message(){
+ $message = <<<XML
+ <imsx_POXEnvelopeRequest xmlns = "http://www.imsglobal.org/lis/oms1p0/pox">
+ <imsx_POXHeader>
+ <imsx_POXRequestHeaderInfo>
+ <imsx_version>V1.0</imsx_version>
+ <imsx_messageIdentifier>999998123</imsx_messageIdentifier>
+ </imsx_POXRequestHeaderInfo>
+ </imsx_POXHeader>
+ <imsx_POXBody>
+ <replaceResultRequest>
+ <resultRecord>
+ <sourcedGUID>
+ <sourcedId>{"data":{"instanceid":"2","userid":"2"},"hash":"0b5078feab59b9938c333ceaae21d8e003a7b295e43cdf55338445254421076b"}</sourcedId>
+ </sourcedGUID>
+ <result>
+ <resultScore>
+ <language>en-us</language>
+ <textString>0.92</textString>
+ </resultScore>
+ </result>
+ </resultRecord>
+ </replaceResultRequest>
+ </imsx_POXBody>
+ </imsx_POXEnvelopeRequest>
+XML;
+
+ $parsed = lti_parse_grade_replace_message(new SimpleXMLElement($message));
+
+ $this->assertEqual($parsed->userid, '2');
+ $this->assertEqual($parsed->instanceid, '2');
+ $this->assertEqual($parsed->sourcedidhash, '0b5078feab59b9938c333ceaae21d8e003a7b295e43cdf55338445254421076b');
+
+ $ltiinstance = (object)array('servicesalt' => '4e5fcc06de1d58.44963230');
+
+ lti_verify_sourcedid($ltiinstance, $parsed);
+ }
}
-<?php\r
-// This file is part of BasicLTI4Moodle\r
-//\r
-// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)\r
-// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web\r
-// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI\r
-// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS\r
-// are already supporting or going to support BasicLTI. This project Implements the consumer\r
-// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.\r
-// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem\r
-// at the GESSI research group at UPC.\r
-// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI\r
-// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a\r
-// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.\r
-//\r
-// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis\r
-// of the Universitat Politecnica de Catalunya http://www.upc.edu\r
-// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu\r
-//\r
-// Moodle is free software: you can redistribute it and/or modify\r
-// it under the terms of the GNU General Public License as published by\r
-// the Free Software Foundation, either version 3 of the License, or\r
-// (at your option) any later version.\r
-//\r
-// Moodle is distributed in the hope that it will be useful,\r
-// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-// GNU General Public License for more details.\r
-//\r
-// You should have received a copy of the GNU General Public License\r
-// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\r
-\r
-/**\r
- * This file contains the script used to clone Moodle admin setting page.\r
- * It is used to create a new form used to pre-configure basiclti\r
- * activities\r
- *\r
- * @package lti\r
- * @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis\r
- * marc.alier@upc.edu\r
- * @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu\r
- *\r
- * @author Marc Alier\r
- * @author Jordi Piguillem\r
- * @author Nikolas Galanis\r
- *\r
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r
- */\r
-\r
-require_once('../../config.php');\r
-require_once($CFG->libdir.'/adminlib.php');\r
-require_once($CFG->dirroot.'/mod/lti/edit_form.php');\r
-require_once($CFG->dirroot.'/mod/lti/locallib.php');\r
-\r
-$section = 'modsettinglti';\r
-$return = optional_param('return', '', PARAM_ALPHA);\r
-$adminediting = optional_param('adminedit', -1, PARAM_BOOL);\r
-$action = optional_param('action', null, PARAM_TEXT);\r
-$id = optional_param('id', null, PARAM_INT);\r
-$useexisting = optional_param('useexisting', null, PARAM_INT);\r
-$definenew = optional_param('definenew', null, PARAM_INT);\r
-\r
-/// no guest autologin\r
-require_login(0, false);\r
-$url = new moodle_url('/mod/lti/typesettings.php');\r
-$PAGE->set_url($url);\r
-\r
-admin_externalpage_setup('managemodules'); // Hacky solution for printing the admin page\r
-\r
-$tab = optional_param('tab', '', PARAM_ALPHAEXT);\r
-$redirect = "$CFG->wwwroot/$CFG->admin/settings.php?section=modsettinglti&tab={$tab}";\r
-\r
-/// WRITING SUBMITTED DATA (IF ANY) -------------------------------------------------------------------------------\r
-\r
-$statusmsg = '';\r
-$errormsg = '';\r
-$focus = '';\r
-\r
-$data = data_submitted();\r
-\r
-if (confirm_sesskey() && isset($data->submitbutton)) {\r
- $type = new StdClass();\r
- \r
- if (isset($id)) {\r
- $type->id = $id;\r
-\r
- lti_update_type($type, $data);\r
- \r
- redirect($redirect);\r
- die;\r
- } else {\r
- $type->state = LTI_TOOL_STATE_CONFIGURED;\r
- \r
- lti_add_type($type, $data);\r
- \r
- redirect($redirect);\r
- die;\r
- }\r
-} else if(isset($data->cancel)){\r
- redirect($redirect);\r
- die;\r
-}\r
-\r
-if ($action == 'accept') {\r
- lti_set_state_for_type($id, LTI_TOOL_STATE_CONFIGURED);\r
- redirect($redirect);\r
- die;\r
-}\r
-\r
-if ($action == 'reject') {\r
- lti_set_state_for_type($id, LTI_TOOL_STATE_REJECTED);\r
- redirect($redirect);\r
- die;\r
-}\r
-\r
-if ($action == 'delete') {\r
- lti_delete_type($id);\r
- redirect($redirect);\r
- die;\r
-}\r
-\r
-/// print header stuff ------------------------------------------------------------\r
-$PAGE->set_focuscontrol($focus);\r
-if (empty($SITE->fullname)) {\r
- $PAGE->set_title($settingspage->visiblename);\r
- $PAGE->set_heading($settingspage->visiblename);\r
-\r
- $PAGE->navbar->add('Basic LTI Administration', $CFG->wwwroot.'/admin/settings.php?section=modsettinglti');\r
-\r
- echo $OUTPUT->header();\r
-\r
- echo $OUTPUT->box(get_string('configintrosite', 'admin'));\r
-\r
- if ($errormsg !== '') {\r
- echo $OUTPUT->notification($errormsg);\r
-\r
- } else if ($statusmsg !== '') {\r
- echo $OUTPUT->notification($statusmsg, 'notifysuccess');\r
- }\r
-\r
- // ---------------------------------------------------------------------------------------------------------------\r
-\r
- echo '<form action="typesettings.php" method="post" id="'.$id.'" >';\r
- echo '<div class="settingsform clearfix">';\r
- echo html_writer::input_hidden_params($PAGE->url);\r
- echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';\r
- echo '<input type="hidden" name="return" value="'.$return.'" />';\r
-\r
- echo $settingspage->output_html();\r
-\r
- echo '<div class="form-buttons"><input class="form-submit" type="submit" value="'.get_string('savechanges', 'admin').'" /></div>';\r
-\r
- echo '</div>';\r
- echo '</form>';\r
-\r
-} else {\r
- if ($PAGE->user_allowed_editing()) {\r
- $url = clone($PAGE->url);\r
- if ($PAGE->user_is_editing()) {\r
- $caption = get_string('blockseditoff');\r
- $url->param('adminedit', 'off');\r
- } else {\r
- $caption = get_string('blocksediton');\r
- $url->param('adminedit', 'on');\r
- }\r
- $buttons = $OUTPUT->single_button($url, $caption, 'get');\r
- }\r
-\r
- $PAGE->set_title("$SITE->shortname: " . get_string('toolsetup', 'lti'));\r
-\r
- $PAGE->navbar->add('Basic LTI Administration', $CFG->wwwroot.'/admin/settings.php?section=modsettinglti');\r
-\r
- echo $OUTPUT->header();\r
-\r
- if ($errormsg !== '') {\r
- echo $OUTPUT->notification($errormsg);\r
-\r
- } else if ($statusmsg !== '') {\r
- echo $OUTPUT->notification($statusmsg, 'notifysuccess');\r
- }\r
-\r
- // ---------------------------------------------------------------------------------------------------------------\r
- echo $OUTPUT->heading(get_string('toolsetup', 'lti'));\r
- echo $OUTPUT->box_start('generalbox');\r
- if ($action == 'add') {\r
- $form = new mod_lti_edit_types_form();\r
- $form->display();\r
- } else if ($action == 'update') {\r
- $form = new mod_lti_edit_types_form('typessettings.php?id='.$id);\r
- $type = lti_get_type_type_config($id);\r
- $form->set_data($type);\r
- $form->display();\r
- }\r
-\r
- echo $OUTPUT->box_end();\r
-}\r
-\r
-echo $OUTPUT->footer();\r
+<?php
+// This file is part of BasicLTI4Moodle
+//
+// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
+// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
+// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
+// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
+// are already supporting or going to support BasicLTI. This project Implements the consumer
+// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
+// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
+// at the GESSI research group at UPC.
+// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
+// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
+// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
+//
+// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
+// of the Universitat Politecnica de Catalunya http://www.upc.edu
+// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * This file contains the script used to clone Moodle admin setting page.
+ * It is used to create a new form used to pre-configure basiclti
+ * activities
+ *
+ * @package lti
+ * @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
+ * marc.alier@upc.edu
+ * @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
+ *
+ * @author Marc Alier
+ * @author Jordi Piguillem
+ * @author Nikolas Galanis
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+require_once('../../config.php');
+require_once($CFG->libdir.'/adminlib.php');
+require_once($CFG->dirroot.'/mod/lti/edit_form.php');
+require_once($CFG->dirroot.'/mod/lti/locallib.php');
+
+$section = 'modsettinglti';
+$return = optional_param('return', '', PARAM_ALPHA);
+$adminediting = optional_param('adminedit', -1, PARAM_BOOL);
+$action = optional_param('action', null, PARAM_TEXT);
+$id = optional_param('id', null, PARAM_INT);
+$useexisting = optional_param('useexisting', null, PARAM_INT);
+$definenew = optional_param('definenew', null, PARAM_INT);
+
+/// no guest autologin
+require_login(0, false);
+$url = new moodle_url('/mod/lti/typesettings.php');
+$PAGE->set_url($url);
+
+admin_externalpage_setup('managemodules'); // Hacky solution for printing the admin page
+
+$tab = optional_param('tab', '', PARAM_ALPHAEXT);
+$redirect = "$CFG->wwwroot/$CFG->admin/settings.php?section=modsettinglti&tab={$tab}";
+
+/// WRITING SUBMITTED DATA (IF ANY) -------------------------------------------------------------------------------
+
+$statusmsg = '';
+$errormsg = '';
+$focus = '';
+
+$data = data_submitted();
+
+if (confirm_sesskey() && isset($data->submitbutton)) {
+ $type = new stdClass();
+
+ if (isset($id)) {
+ $type->id = $id;
+
+ lti_update_type($type, $data);
+
+ redirect($redirect);
+ die;
+ } else {
+ $type->state = LTI_TOOL_STATE_CONFIGURED;
+
+ lti_add_type($type, $data);
+
+ redirect($redirect);
+ die;
+ }
+} else if(isset($data->cancel)){
+ redirect($redirect);
+ die;
+}
+
+if ($action == 'accept') {
+ lti_set_state_for_type($id, LTI_TOOL_STATE_CONFIGURED);
+ redirect($redirect);
+ die;
+}
+
+if ($action == 'reject') {
+ lti_set_state_for_type($id, LTI_TOOL_STATE_REJECTED);
+ redirect($redirect);
+ die;
+}
+
+if ($action == 'delete') {
+ lti_delete_type($id);
+ redirect($redirect);
+ die;
+}
+
+/// print header stuff ------------------------------------------------------------
+$PAGE->set_focuscontrol($focus);
+if (empty($SITE->fullname)) {
+ $PAGE->set_title($settingspage->visiblename);
+ $PAGE->set_heading($settingspage->visiblename);
+
+ $PAGE->navbar->add('Basic LTI Administration', $CFG->wwwroot.'/admin/settings.php?section=modsettinglti');
+
+ echo $OUTPUT->header();
+
+ echo $OUTPUT->box(get_string('configintrosite', 'admin'));
+
+ if ($errormsg !== '') {
+ echo $OUTPUT->notification($errormsg);
+
+ } else if ($statusmsg !== '') {
+ echo $OUTPUT->notification($statusmsg, 'notifysuccess');
+ }
+
+ // ---------------------------------------------------------------------------------------------------------------
+
+ echo '<form action="typesettings.php" method="post" id="'.$id.'" >';
+ echo '<div class="settingsform clearfix">';
+ echo html_writer::input_hidden_params($PAGE->url);
+ echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
+ echo '<input type="hidden" name="return" value="'.$return.'" />';
+
+ echo $settingspage->output_html();
+
+ echo '<div class="form-buttons"><input class="form-submit" type="submit" value="'.get_string('savechanges', 'admin').'" /></div>';
+
+ echo '</div>';
+ echo '</form>';
+
+} else {
+ if ($PAGE->user_allowed_editing()) {
+ $url = clone($PAGE->url);
+ if ($PAGE->user_is_editing()) {
+ $caption = get_string('blockseditoff');
+ $url->param('adminedit', 'off');
+ } else {
+ $caption = get_string('blocksediton');
+ $url->param('adminedit', 'on');
+ }
+ $buttons = $OUTPUT->single_button($url, $caption, 'get');
+ }
+
+ $PAGE->set_title("$SITE->shortname: " . get_string('toolsetup', 'lti'));
+
+ $PAGE->navbar->add('Basic LTI Administration', $CFG->wwwroot.'/admin/settings.php?section=modsettinglti');
+
+ echo $OUTPUT->header();
+
+ if ($errormsg !== '') {
+ echo $OUTPUT->notification($errormsg);
+
+ } else if ($statusmsg !== '') {
+ echo $OUTPUT->notification($statusmsg, 'notifysuccess');
+ }
+
+ // ---------------------------------------------------------------------------------------------------------------
+ echo $OUTPUT->heading(get_string('toolsetup', 'lti'));
+ echo $OUTPUT->box_start('generalbox');
+ if ($action == 'add') {
+ $form = new mod_lti_edit_types_form(null, (object)array('isadmin' => true));
+ $form->display();
+ } else if ($action == 'update') {
+ $form = new mod_lti_edit_types_form('typessettings.php?id='.$id, (object)array('isadmin' => true));
+ $type = lti_get_type_type_config($id);
+ $form->set_data($type);
+ $form->display();
+ }
+
+ echo $OUTPUT->box_end();
+}
+
+echo $OUTPUT->footer();