Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Updates to lti plugin & progress on instructor management of course t…

…ools.
  • Loading branch information...
commit 996b0fd9613de8cdd04d2f42528ad4d343e56993 1 parent dbb0fec
scriby authored September 16, 2011
9  mod/lti/OAuthBody.php
@@ -72,10 +72,11 @@ function getOAuthKeyFromHeaders()
72 72
     return false;
73 73
 }
74 74
  
75  
-function handleOAuthBodyPOST($oauth_consumer_key, $oauth_consumer_secret) 
  75
+function handleOAuthBodyPOST($oauth_consumer_key, $oauth_consumer_secret, $body, $request_headers = null) 
76 76
 {
77  
-    $request_headers = OAuthUtil::get_headers();
78  
-    // print_r($request_headers);
  77
+    if($request_headers == null){
  78
+        $request_headers = OAuthUtil::get_headers();
  79
+    }
79 80
 
80 81
     // Must reject application/x-www-form-urlencoded
81 82
     if ($request_headers['Content-type'] == 'application/x-www-form-urlencoded' ) {
@@ -112,7 +113,7 @@ function handleOAuthBodyPOST($oauth_consumer_key, $oauth_consumer_secret)
112 113
         throw new Exception("OAuth signature failed: " . $message);
113 114
     }
114 115
 
115  
-    $postdata = file_get_contents('php://input');
  116
+    $postdata = $body;
116 117
     // echo($postdata);
117 118
 
118 119
     $hash = base64_encode(sha1($postdata, TRUE));
4  mod/lti/basiclti.js
@@ -53,6 +53,4 @@ function basicltiDebugToggle() {
53 53
     else {
54 54
         ele.style.display = 'block';
55 55
     }
56  
-}
57  
-
58  
-alert('a');
  56
+}
325  mod/lti/edit_form.php
... ...
@@ -1,159 +1,166 @@
1  
-<?php
2  
-// This file is part of BasicLTI4Moodle
3  
-//
4  
-// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
5  
-// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
6  
-// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
7  
-// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
8  
-// are already supporting or going to support BasicLTI. This project Implements the consumer
9  
-// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
10  
-// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
11  
-// at the GESSI research group at UPC.
12  
-// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
13  
-// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
14  
-// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
15  
-//
16  
-// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
17  
-// of the Universitat Politecnica de Catalunya http://www.upc.edu
18  
-// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
19  
-//
20  
-// Moodle is free software: you can redistribute it and/or modify
21  
-// it under the terms of the GNU General Public License as published by
22  
-// the Free Software Foundation, either version 3 of the License, or
23  
-// (at your option) any later version.
24  
-//
25  
-// Moodle is distributed in the hope that it will be useful,
26  
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
27  
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28  
-// GNU General Public License for more details.
29  
-//
30  
-// You should have received a copy of the GNU General Public License
31  
-// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
32  
-
33  
-/**
34  
- * This file defines de main basiclti configuration form
35  
- *
36  
- * @package lti
37  
- * @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
38  
- *  marc.alier@upc.edu
39  
- * @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
40  
- *
41  
- * @author Marc Alier
42  
- * @author Jordi Piguillem
43  
- * @author Nikolas Galanis
44  
- * @author Charles Severance
45  
- *
46  
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
47  
- */
48  
-
49  
-defined('MOODLE_INTERNAL') || die;
50  
-
51  
-require_once($CFG->libdir.'/formslib.php');
52  
-
53  
-class mod_lti_edit_types_form extends moodleform{
54  
-
55  
-    function definition() {
56  
-        $mform    =& $this->_form;
57  
-
58  
-//-------------------------------------------------------------------------------
59  
-        // Add basiclti elements
60  
-        $mform->addElement('header', 'setup', get_string('tool_settings', 'lti'));
61  
-        
62  
-        $mform->addElement('text', 'lti_typename', get_string('typename', 'lti'));
63  
-        $mform->setType('lti_typename', PARAM_INT);
64  
-//        $mform->addHelpButton('lti_typename', 'typename','lti');
65  
-        $mform->addRule('lti_typename', null, 'required', null, 'client');
66  
-
67  
-        $mform->addElement('text', 'lti_toolurl', get_string('toolurl', 'lti'), array('size'=>'64'));
68  
-        $mform->setType('lti_toolurl', PARAM_TEXT);
69  
-//        $mform->addHelpButton('lti_toolurl', 'toolurl', 'lti');
70  
-        $mform->addRule('lti_toolurl', null, 'required', null, 'client');
71  
-
72  
-        $mform->addElement('text', 'lti_resourcekey', get_string('resourcekey', 'lti'));
73  
-        $mform->setType('lti_resourcekey', PARAM_TEXT);
74  
-
75  
-        $mform->addElement('passwordunmask', 'lti_password', get_string('password', 'lti'));
76  
-        $mform->setType('lti_password', PARAM_TEXT);
77  
-
78  
-        $mform->addElement('textarea', 'lti_customparameters', get_string('custom', 'lti'), array('rows'=>4, 'cols'=>60));
79  
-        $mform->setType('lti_customparameters', PARAM_TEXT);
80  
-        
81  
-        $mform->addElement('checkbox', 'lti_coursevisible', '&nbsp;', ' ' . get_string('show_in_course', 'lti'));
82  
-        
83  
-        $launchoptions=array();
84  
-        $launchoptions[LTI_LAUNCH_CONTAINER_EMBED] = get_string('embed', 'lti');
85  
-        $launchoptions[LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS] = get_string('embed_no_blocks', 'lti');
86  
-        $launchoptions[LTI_LAUNCH_CONTAINER_WINDOW] = get_string('new_window', 'lti');
87  
-
88  
-        $mform->addElement('select', 'lti_launchcontainer', get_string('default_launch_container', 'lti'), $launchoptions);
89  
-        $mform->setDefault('lti_launchcontainer', LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS);
90  
-//        $mform->addHelpButton('lti_launchinpopup', 'launchinpopup', 'lti');
91  
-        
92  
-        // Add privacy preferences fieldset where users choose whether to send their data
93  
-        $mform->addElement('header', 'privacy', get_string('privacy', 'lti'));
94  
-
95  
-        $options=array();
96  
-        $options[0] = get_string('never', 'lti');
97  
-        $options[1] = get_string('always', 'lti');
98  
-        $options[2] = get_string('delegate_yes', 'lti');
99  
-        $options[3] = get_string('delegate_no', 'lti');
100  
-
101  
-        $mform->addElement('select', 'lti_sendname', get_string('sendname', 'lti'), $options);
102  
-        $mform->setDefault('lti_sendname', '2');
103  
-//        $mform->addHelpButton('lti_sendname', 'sendname', 'lti');
104  
-
105  
-        $mform->addElement('select', 'lti_sendemailaddr', get_string('sendemailaddr', 'lti'), $options);
106  
-        $mform->setDefault('lti_sendemailaddr', '2');
107  
-//        $mform->addHelpButton('lti_sendemailaddr', 'sendemailaddr', 'lti');
108  
-
109  
-//-------------------------------------------------------------------------------
110  
-        // LTI Extensions
111  
-
112  
-        // Add grading preferences fieldset where the tool is allowed to return grades
113  
-        $mform->addElement('select', 'lti_acceptgrades', get_string('acceptgrades', 'lti'), $options);
114  
-        $mform->setDefault('lti_acceptgrades', '2');
115  
-//        $mform->addHelpButton('lti_acceptgrades', 'acceptgrades', 'lti');
116  
-
117  
-        // Add grading preferences fieldset where the tool is allowed to retrieve rosters
118  
-        $mform->addElement('select', 'lti_allowroster', get_string('allowroster', 'lti'), $options);
119  
-        $mform->setDefault('lti_allowroster', '2');
120  
-//        $mform->addHelpButton('lti_allowroster', 'allowroster', 'lti');
121  
-
122  
-                
123  
-//-------------------------------------------------------------------------------
124  
-        // Add setup parameters fieldset
125  
-        $mform->addElement('header', 'setupoptions', get_string('miscellaneous', 'lti'));
126  
-
127  
-        // Adding option to change id that is placed in context_id
128  
-        $idoptions = array();
129  
-        $idoptions[0] = get_string('id', 'lti');
130  
-        $idoptions[1] = get_string('courseid', 'lti');
131  
-
132  
-        $mform->addElement('text', 'lti_organizationid', get_string('organizationid', 'lti'));
133  
-        $mform->setType('lti_organizationid', PARAM_TEXT);
134  
-//        $mform->addHelpButton('lti_organizationid', 'organizationid', 'lti');
135  
-
136  
-        $mform->addElement('text', 'lti_organizationurl', get_string('organizationurl', 'lti'));
137  
-        $mform->setType('lti_organizationurl', PARAM_TEXT);
138  
-//        $mform->addHelpButton('lti_organizationurl', 'organizationurl', 'lti');
139  
-
140  
-        /* Suppress this for now - Chuck
141  
-        $mform->addElement('text', 'lti_organizationdescr', get_string('organizationdescr', 'lti'));
142  
-        $mform->setType('lti_organizationdescr', PARAM_TEXT);
143  
-        $mform->addHelpButton('lti_organizationdescr', 'organizationdescr', 'lti');
144  
-        */
145  
-
146  
-//-------------------------------------------------------------------------------
147  
-        // Add a hidden element to signal a tool fixing operation after a problematic backup - restore process
148  
-        $mform->addElement('hidden', 'lti_fix');
149  
-        
150  
-        $tab = optional_param('tab', '', PARAM_ALPHAEXT);
151  
-        $mform->addElement('hidden', 'tab', $tab);
152  
-        
153  
-
154  
-//-------------------------------------------------------------------------------
155  
-        // Add standard buttons, common to all modules
156  
-        $this->add_action_buttons();
157  
-
158  
-    }
159  
-}
  1
+<?php
  2
+// This file is part of BasicLTI4Moodle
  3
+//
  4
+// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
  5
+// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
  6
+// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
  7
+// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
  8
+// are already supporting or going to support BasicLTI. This project Implements the consumer
  9
+// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
  10
+// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
  11
+// at the GESSI research group at UPC.
  12
+// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
  13
+// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
  14
+// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
  15
+//
  16
+// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
  17
+// of the Universitat Politecnica de Catalunya http://www.upc.edu
  18
+// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
  19
+//
  20
+// Moodle is free software: you can redistribute it and/or modify
  21
+// it under the terms of the GNU General Public License as published by
  22
+// the Free Software Foundation, either version 3 of the License, or
  23
+// (at your option) any later version.
  24
+//
  25
+// Moodle is distributed in the hope that it will be useful,
  26
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
  27
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  28
+// GNU General Public License for more details.
  29
+//
  30
+// You should have received a copy of the GNU General Public License
  31
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
  32
+
  33
+/**
  34
+ * This file defines de main basiclti configuration form
  35
+ *
  36
+ * @package lti
  37
+ * @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
  38
+ *  marc.alier@upc.edu
  39
+ * @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
  40
+ *
  41
+ * @author Marc Alier
  42
+ * @author Jordi Piguillem
  43
+ * @author Nikolas Galanis
  44
+ * @author Charles Severance
  45
+ *
  46
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  47
+ */
  48
+
  49
+defined('MOODLE_INTERNAL') || die;
  50
+
  51
+require_once($CFG->libdir.'/formslib.php');
  52
+require_once($CFG->dirroot.'/mod/lti/locallib.php');
  53
+
  54
+class mod_lti_edit_types_form extends moodleform{
  55
+    function definition() {
  56
+        $mform    =& $this->_form;
  57
+
  58
+//-------------------------------------------------------------------------------
  59
+        // Add basiclti elements
  60
+        $mform->addElement('header', 'setup', get_string('tool_settings', 'lti'));
  61
+        
  62
+        $mform->addElement('text', 'lti_typename', get_string('typename', 'lti'));
  63
+        $mform->setType('lti_typename', PARAM_INT);
  64
+//        $mform->addHelpButton('lti_typename', 'typename','lti');
  65
+        $mform->addRule('lti_typename', null, 'required', null, 'client');
  66
+
  67
+        $mform->addElement('text', 'lti_toolurl', get_string('toolurl', 'lti'), array('size'=>'64'));
  68
+        $mform->setType('lti_toolurl', PARAM_TEXT);
  69
+//        $mform->addHelpButton('lti_toolurl', 'toolurl', 'lti');
  70
+        $mform->addRule('lti_toolurl', null, 'required', null, 'client');
  71
+
  72
+        $mform->addElement('text', 'lti_resourcekey', get_string('resourcekey', 'lti'));
  73
+        $mform->setType('lti_resourcekey', PARAM_TEXT);
  74
+
  75
+        $mform->addElement('passwordunmask', 'lti_password', get_string('password', 'lti'));
  76
+        $mform->setType('lti_password', PARAM_TEXT);
  77
+
  78
+        $mform->addElement('textarea', 'lti_customparameters', get_string('custom', 'lti'), array('rows'=>4, 'cols'=>60));
  79
+        $mform->setType('lti_customparameters', PARAM_TEXT);
  80
+        
  81
+        if(!empty($this->_customdata->isadmin)){
  82
+            $mform->addElement('checkbox', 'lti_coursevisible', '&nbsp;', ' ' . get_string('show_in_course', 'lti'));
  83
+        } else {
  84
+            $mform->addElement('hidden', 'lti_coursevisible', '1');
  85
+        }
  86
+        
  87
+        $launchoptions=array();
  88
+        $launchoptions[LTI_LAUNCH_CONTAINER_EMBED] = get_string('embed', 'lti');
  89
+        $launchoptions[LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS] = get_string('embed_no_blocks', 'lti');
  90
+        $launchoptions[LTI_LAUNCH_CONTAINER_WINDOW] = get_string('new_window', 'lti');
  91
+
  92
+        $mform->addElement('select', 'lti_launchcontainer', get_string('default_launch_container', 'lti'), $launchoptions);
  93
+        $mform->setDefault('lti_launchcontainer', LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS);
  94
+//        $mform->addHelpButton('lti_launchinpopup', 'launchinpopup', 'lti');
  95
+        
  96
+        // Add privacy preferences fieldset where users choose whether to send their data
  97
+        $mform->addElement('header', 'privacy', get_string('privacy', 'lti'));
  98
+
  99
+        $options=array();
  100
+        $options[0] = get_string('never', 'lti');
  101
+        $options[1] = get_string('always', 'lti');
  102
+        $options[2] = get_string('delegate', 'lti');
  103
+
  104
+        $mform->addElement('select', 'lti_sendname', get_string('sendname', 'lti'), $options);
  105
+        $mform->setDefault('lti_sendname', '2');
  106
+//        $mform->addHelpButton('lti_sendname', 'sendname', 'lti');
  107
+
  108
+        $mform->addElement('select', 'lti_sendemailaddr', get_string('sendemailaddr', 'lti'), $options);
  109
+        $mform->setDefault('lti_sendemailaddr', '2');
  110
+//        $mform->addHelpButton('lti_sendemailaddr', 'sendemailaddr', 'lti');
  111
+
  112
+//-------------------------------------------------------------------------------
  113
+        // LTI Extensions
  114
+
  115
+        // Add grading preferences fieldset where the tool is allowed to return grades
  116
+        $mform->addElement('select', 'lti_acceptgrades', get_string('acceptgrades', 'lti'), $options);
  117
+        $mform->setDefault('lti_acceptgrades', '2');
  118
+//        $mform->addHelpButton('lti_acceptgrades', 'acceptgrades', 'lti');
  119
+
  120
+        // Add grading preferences fieldset where the tool is allowed to retrieve rosters
  121
+        $mform->addElement('select', 'lti_allowroster', get_string('allowroster', 'lti'), $options);
  122
+        $mform->setDefault('lti_allowroster', '2');
  123
+//        $mform->addHelpButton('lti_allowroster', 'allowroster', 'lti');
  124
+
  125
+          
  126
+        if(!empty($this->_customdata->isadmin)){
  127
+            //-------------------------------------------------------------------------------
  128
+            // Add setup parameters fieldset
  129
+            $mform->addElement('header', 'setupoptions', get_string('miscellaneous', 'lti'));
  130
+
  131
+            // Adding option to change id that is placed in context_id
  132
+            $idoptions = array();
  133
+            $idoptions[0] = get_string('id', 'lti');
  134
+            $idoptions[1] = get_string('courseid', 'lti');
  135
+
  136
+            $mform->addElement('text', 'lti_organizationid', get_string('organizationid', 'lti'));
  137
+            $mform->setType('lti_organizationid', PARAM_TEXT);
  138
+    //        $mform->addHelpButton('lti_organizationid', 'organizationid', 'lti');
  139
+
  140
+            $mform->addElement('text', 'lti_organizationurl', get_string('organizationurl', 'lti'));
  141
+            $mform->setType('lti_organizationurl', PARAM_TEXT);
  142
+    //        $mform->addHelpButton('lti_organizationurl', 'organizationurl', 'lti');
  143
+        }
  144
+        
  145
+        /* Suppress this for now - Chuck
  146
+        $mform->addElement('text', 'lti_organizationdescr', get_string('organizationdescr', 'lti'));
  147
+        $mform->setType('lti_organizationdescr', PARAM_TEXT);
  148
+        $mform->addHelpButton('lti_organizationdescr', 'organizationdescr', 'lti');
  149
+        */
  150
+
  151
+//-------------------------------------------------------------------------------
  152
+        // Add a hidden element to signal a tool fixing operation after a problematic backup - restore process
  153
+        //$mform->addElement('hidden', 'lti_fix');
  154
+        
  155
+        $tab = optional_param('tab', '', PARAM_ALPHAEXT);
  156
+        $mform->addElement('hidden', 'tab', $tab);
  157
+        
  158
+        $courseid = optional_param('course', 1, PARAM_INT);
  159
+        $mform->addElement('hidden', 'course', $courseid);
  160
+        
  161
+//-------------------------------------------------------------------------------
  162
+        // Add standard buttons, common to all modules
  163
+        $this->add_action_buttons();
  164
+
  165
+    }
  166
+}
93  mod/lti/instructor_edit_tool_type.php
... ...
@@ -0,0 +1,93 @@
  1
+<?php
  2
+require_once('../../config.php');
  3
+require_once($CFG->dirroot.'/mod/lti/edit_form.php');
  4
+
  5
+$courseid = required_param('course', PARAM_INT);
  6
+
  7
+require_login($courseid, false);
  8
+$url = new moodle_url('/mod/lti/instructor_edit_tool_type.php');
  9
+$PAGE->set_url($url);
  10
+$PAGE->set_pagelayout('popup');
  11
+
  12
+$action = optional_param('action', null, PARAM_TEXT);
  13
+$typeid = optional_param('typeid', null, PARAM_INT);
  14
+
  15
+if(!empty($typeid)){
  16
+    $type = lti_get_type($typeid);
  17
+    if($type->course != $courseid){
  18
+        throw new Exception('You do not have permissions to edit this tool type.');
  19
+        
  20
+        die;
  21
+    }
  22
+}
  23
+
  24
+echo $OUTPUT->header();
  25
+
  26
+$data = data_submitted();
  27
+
  28
+if (confirm_sesskey() && isset($data->submitbutton)) {
  29
+    $type = new stdClass();
  30
+    
  31
+    if (isset($id)) {
  32
+        /*$type->id = $id;
  33
+
  34
+        lti_update_type($type, $data);
  35
+        $script = <<<SCRIPT
  36
+            <script type="text/javascript">
  37
+                window.opener.M.mod_lti.editor.updateToolType({$name}, '{$id}');
  38
+                
  39
+                window.close();
  40
+            </script>
  41
+SCRIPT;*/
  42
+        
  43
+        die;
  44
+    } else {
  45
+        $type->state = LTI_TOOL_STATE_CONFIGURED;
  46
+        $type->course = $COURSE->id;
  47
+        
  48
+        $id = lti_add_type($type, $data);
  49
+        $name = json_encode($type->name);
  50
+        
  51
+        $script = <<<SCRIPT
  52
+            <script type="text/javascript">
  53
+                window.opener.M.mod_lti.editor.addToolType({$name}, '{$id}');
  54
+                
  55
+                window.close();
  56
+            </script>
  57
+SCRIPT;
  58
+        
  59
+        echo $script;
  60
+        
  61
+        die;
  62
+    }
  63
+} else if(isset($data->cancel)){
  64
+        $script = <<<SCRIPT
  65
+            <script type="text/javascript">
  66
+                window.close();
  67
+            </script>
  68
+SCRIPT;
  69
+        
  70
+        echo $script;
  71
+    die;
  72
+}
  73
+
  74
+//Delete action is called via ajax
  75
+if ($action == 'delete'){
  76
+    lti_delete_type($typeid);
  77
+    
  78
+    die;
  79
+}
  80
+
  81
+echo $OUTPUT->heading(get_string('toolsetup', 'lti'));
  82
+
  83
+if($action == 'add') {
  84
+    $form = new mod_lti_edit_types_form();
  85
+    $form->display();
  86
+} else if($action == 'edit'){
  87
+    $form = new mod_lti_edit_types_form();
  88
+    $type = lti_get_type_type_config($typeid);
  89
+    $form->set_data($type);
  90
+    $form->display();
  91
+}
  92
+
  93
+echo $OUTPUT->footer();
394  mod/lti/lang/en/lti.php
... ...
@@ -1,198 +1,196 @@
1  
-<?php
2  
-// This file is part of BasicLTI4Moodle
3  
-//
4  
-// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
5  
-// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
6  
-// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
7  
-// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
8  
-// are already supporting or going to support BasicLTI. This project Implements the consumer
9  
-// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
10  
-// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
11  
-// at the GESSI research group at UPC.
12  
-// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
13  
-// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
14  
-// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
15  
-//
16  
-// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
17  
-// of the Universitat Politecnica de Catalunya http://www.upc.edu
18  
-// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
19  
-//
20  
-// Moodle is free software: you can redistribute it and/or modify
21  
-// it under the terms of the GNU General Public License as published by
22  
-// the Free Software Foundation, either version 3 of the License, or
23  
-// (at your option) any later version.
24  
-//
25  
-// Moodle is distributed in the hope that it will be useful,
26  
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
27  
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28  
-// GNU General Public License for more details.
29  
-//
30  
-// You should have received a copy of the GNU General Public License
31  
-// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
32  
-
33  
-/**
34  
- * This file contains en_utf8 translation of the Basic LTI module
35  
- *
36  
- * @package basiclti
37  
- * @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
38  
- *  marc.alier@upc.edu
39  
- * @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
40  
- *
41  
- * @author Marc Alier
42  
- * @author Jordi Piguillem
43  
- * @author Nikolas Galanis
44  
- *
45  
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
46  
- */
47  
-
48  
-$string['accept'] = 'Accept';
49  
-$string['acceptgrades'] = 'Accept grades from tool';
50  
-$string['activity'] = 'Activity';
51  
-$string['addnewapp'] = 'Enable External Application';
52  
-$string['addserver'] = 'Add new trusted server';
53  
-$string['addtype'] = 'Add External Tool Configuration';
54  
-$string['allow'] = 'Allow';
55  
-$string['allowinstructorcustom'] = 'Allow instructors to add custom parameters';
56  
-$string['allowroster'] = 'Tool may access course roster';
57  
-$string['allowsetting'] = 'Allow tool to store 8K of settings in Moodle';
58  
-$string['always'] = 'Always';
59  
-$string['lti'] = 'Basic LTI';
60  
-$string['basiclti'] = 'Basic LTI';
61  
-$string['basiclti_base_string'] = 'Basic LTI OAuth Base String';
62  
-$string['basiclti_in_new_window'] = 'Your activity has opened in a new window';
63  
-$string['basiclti_endpoint'] = 'Basic LTI Launch Endpoint';
64  
-$string['basiclti_parameters'] = 'Basic LTI Launch Parameters';
65  
-$string['basicltiactivities'] = 'Basic LTI Activities';
66  
-$string['basicltifieldset'] = 'Custom example fieldset';
67  
-$string['basicltiintro'] = 'Activity Description';
68  
-$string['basicltiname'] = 'Activity Name';
69  
-$string['basicltisettings'] = 'Basic Learning Tool Interoperability Settings';
70  
-$string['comment'] = 'Comment';
71  
-$string['configpassword'] = 'Default Remote Tool Password';
72  
-$string['configpreferheight'] = 'Default preferred height';
73  
-$string['configpreferwidget'] = 'Set widget as default launch';
74  
-$string['configpreferwidth'] = 'Default preferred width';
75  
-$string['configresourceurl'] = 'Default Resource URL';
76  
-$string['configtoolurl'] = 'Default Remote Tool URL';
77  
-$string['configtypes'] = 'Enable Basic LTI Applications';
78  
-$string['courseid'] = 'Course id number';
79  
-$string['coursemisconf'] = 'Course is misconfigured';
80  
-$string['curllibrarymissing'] = 'PHP Curl library must be installed to use LTI';
81  
-$string['custom'] = 'Custom parameters';
82  
-$string['custominstr'] = 'Custom parameters';
83  
-$string['debuglaunch'] = 'Debug Option';
84  
-$string['debuglaunchoff'] = 'Normal launch';
85  
-$string['debuglaunchon'] = 'Debug launch';
86  
-$string['delegate'] = 'Delegate to Professor';
87  
-$string['donot'] = 'Do not send';
88  
-$string['donotaccept'] = 'Do not accept';
89  
-$string['donotallow'] = 'Do not allow';
90  
-$string['enableemailnotification'] = 'Send notification emails';
91  
-$string['enableemailnotification_help'] = 'If enabled, students will receive email notification when their tool submissions are graded.';
92  
-$string['errormisconfig'] = 'Misconfigured tool. Please ask your Moodle administrator to fix the configuration of the tool.';
93  
-$string['extensions'] = 'Basic LTI Extension Services';
94  
-$string['failedtoconnect'] = 'Moodle was unable to communicate with the \"$a\" system';
95  
-$string['filterconfig'] = 'Basic LTI administration';
96  
-$string['filtername'] = 'Basic LTI';
97  
-$string['filter_basiclti_configlink'] = 'Configure your preferred sites and their passwords';
98  
-$string['filter_basiclti_password'] = 'Password is mandatory';
99  
-$string['fixexistingconf'] = 'Use an existing configuration for the misconfigured instance';
100  
-$string['fixnew'] = 'New Configuration';
101  
-$string['fixnewconf'] = 'Define a new configuration for the misconfigured instance';
102  
-$string['fixold'] = 'Use Existing';
103  
-$string['grading'] = 'Grade Routing';
104  
-$string['id'] = 'id';
105  
-$string['imsroleadmin'] = 'Instructor,Administrator';
106  
-$string['imsroleinstructor'] = 'Instructor';
107  
-$string['imsrolelearner'] = 'Learner';
108  
-$string['invalidid'] = 'basic LTI ID was incorrect';
109  
-$string['launch_in_moodle'] = 'Launch tool in moodle';
110  
-$string['launch_in_popup'] = 'Launch tool in a pop-up';
111  
-$string['launchinpopup'] = 'Launch Container';
112  
-$string['launchoptions'] = 'Launch Options';
113  
-$string['lti_errormsg'] = 'The tool returned the following error message: \"$a\"';
114  
-$string['misconfiguredtools'] = 'Misconfigured tool instances were detected';
115  
-$string['missingparameterserror'] = 'The page is misconfigured: \"$a\"';
116  
-$string['module_class_type'] = 'Moodle module type';
117  
-$string['modulename'] = 'External Tool';
118  
-$string['modulenameplural'] = 'basicltis';
119  
-$string['modulenamepluralformatted'] = 'Basic LTI Instances';
120  
-$string['never'] = 'Never';
121  
-$string['noattempts'] = 'No attempts have been made on this tool instance';
122  
-$string['noservers'] = 'No servers found';
123  
-$string['notypes'] = 'There are currently no LTI tools setup in Moodle. Click the Install link above to add some.';
124  
-$string['noviewusers'] = 'No users were found with permissions to use this tool';
125  
-$string['optionalsettings'] = 'Optional settings';
126  
-$string['organization'] ='Organization details';
127  
-$string['organizationdescr'] ='Organization Description';
128  
-$string['organizationid'] ='Organization ID';
129  
-$string['organizationurl'] ='Organization URL';
130  
-$string['pagesize'] = 'Submissions shown per page';
131  
-$string['password'] = 'Shared Secret';
132  
-$string['pluginadministration'] = 'Basic LTI administration';
133  
-$string['pluginname'] = 'LTI';
134  
-$string['preferheight'] = 'Preferred Height';
135  
-$string['preferwidget'] = 'Prefer Widget Launch';
136  
-$string['preferwidth'] = 'Preferred Width';
137  
-$string['press_to_submit'] = 'Press to launch this activity';
138  
-$string['privacy'] = 'Privacy';
139  
-$string['quickgrade'] = 'Allow quick grading';
140  
-$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.';
141  
-$string['redirect'] = 'You will be redirected in few seconds. If you are not, press the button.';
142  
-$string['resource'] = 'Resource';
143  
-$string['resourcekey'] = 'Consumer Key';
144  
-$string['resourceurl'] = 'Resource URL';
145  
-$string['saveallfeedback'] = 'Save all my feedback';
146  
-$string['send'] = 'Send';
147  
-$string['sendemailaddr'] = 'Share launcher\'s email with tool';
148  
-$string['sendname'] = 'Share launcher\'s name with tool';
149  
-$string['setdefault'] = 'Set a default value for the professor if delegating';
150  
-$string['setupbox'] = 'Basic LTI Tool Setup Box';
151  
-$string['setupoptions'] = 'Setup Options';
152  
-$string['size'] = 'Size parameters';
153  
-$string['submission'] = 'Submission';
154  
-$string['toggle_debug_data'] = 'Toggle Debug Data';
155  
-$string['toolsetup'] = 'Basic LTI Tool Setup';
156  
-$string['toolurl'] = 'Tool Base URL';
157  
-$string['typename'] = 'Tool Name';
158  
-$string['types'] = 'Types';
159  
-$string['validurl'] = 'A valid URL must start with http(s)://';
160  
-$string['viewsubmissions'] = 'View submissions and grading screen';
161  
-
162  
-//New admin strings
163  
-
164  
-$string['show_in_course'] = 'Show tool type when creating tool instances';
165  
-$string['delegate_yes'] = 'Delegate to Instructor (Default: Yes)';
166  
-$string['delegate_no'] = 'Delegate to Instructor (Default: No)';
167  
-$string['tool_settings'] = 'Tool Settings';
168  
-$string['miscellaneous'] = 'Miscellaneous';
169  
-$string['embed'] = 'Embed';
170  
-$string['embed_no_blocks'] = 'Embed, without blocks';
171  
-$string['new_window'] = 'New window';
172  
-$string['default_launch_container'] = 'Default Launch Container';
173  
-$string['active'] = 'Active';
174  
-$string['pending'] = 'Pending';
175  
-$string['rejected'] = 'Rejected';
176  
-$string['baseurl'] = 'Base URL';
177  
-$string['action'] = 'Action';
178  
-$string['createdon'] = 'Created On';
179  
-$string['accept'] = 'Accept';
180  
-$string['update'] = 'Update';
181  
-$string['delete'] = 'Delete';
182  
-$string['reject'] = 'Reject';
183  
-$string['external_tool_types'] = 'External Tool Types';
184  
-$string['no_lti_configured'] = 'There are no active External Tools configured.';
185  
-$string['no_lti_pending'] = 'There are no pending External Tools.';
186  
-$string['no_lti_rejected'] = 'There are no rejected External Tools.';
187  
-
188  
-//New instructor strings
189  
-$string['display_name'] = 'Display activity name when launched';
190  
-$string['display_description'] = 'Display activity description when launched';
191  
-$string['external_tool_type'] = 'External tool type';
192  
-$string['launch_url'] = 'Launch URL';
193  
-$string['share_name'] = 'Share launcher\'s name with the tool';
194  
-$string['share_email'] = 'Share launcher\'s email with the tool';
195  
-$string['accept_grades'] = 'Accept grades from the tool';
196  
-$string['share_roster'] = 'Allow the tool to access this course\'s roster';
197  
-$string['automatic'] = 'Automatic, based on Launch URL';
198  
-$string['default'] = 'Default';
  1
+<?php
  2
+// This file is part of BasicLTI4Moodle
  3
+//
  4
+// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
  5
+// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
  6
+// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
  7
+// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
  8
+// are already supporting or going to support BasicLTI. This project Implements the consumer
  9
+// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
  10
+// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
  11
+// at the GESSI research group at UPC.
  12
+// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
  13
+// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
  14
+// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
  15
+//
  16
+// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
  17
+// of the Universitat Politecnica de Catalunya http://www.upc.edu
  18
+// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
  19
+//
  20
+// Moodle is free software: you can redistribute it and/or modify
  21
+// it under the terms of the GNU General Public License as published by
  22
+// the Free Software Foundation, either version 3 of the License, or
  23
+// (at your option) any later version.
  24
+//
  25
+// Moodle is distributed in the hope that it will be useful,
  26
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
  27
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  28
+// GNU General Public License for more details.
  29
+//
  30
+// You should have received a copy of the GNU General Public License
  31
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
  32
+
  33
+/**
  34
+ * This file contains en_utf8 translation of the Basic LTI module
  35
+ *
  36
+ * @package basiclti
  37
+ * @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
  38
+ *  marc.alier@upc.edu
  39
+ * @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
  40
+ *
  41
+ * @author Marc Alier
  42
+ * @author Jordi Piguillem
  43
+ * @author Nikolas Galanis
  44
+ *
  45
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  46
+ */
  47
+
  48
+$string['accept'] = 'Accept';
  49
+$string['acceptgrades'] = 'Accept grades from tool';
  50
+$string['activity'] = 'Activity';
  51
+$string['addnewapp'] = 'Enable External Application';
  52
+$string['addserver'] = 'Add new trusted server';
  53
+$string['addtype'] = 'Add External Tool Configuration';
  54
+$string['allow'] = 'Allow';
  55
+$string['allowinstructorcustom'] = 'Allow instructors to add custom parameters';
  56
+$string['allowroster'] = 'Tool may access course roster';
  57
+$string['allowsetting'] = 'Allow tool to store 8K of settings in Moodle';
  58
+$string['always'] = 'Always';
  59
+$string['lti'] = 'Basic LTI';
  60
+$string['basiclti'] = 'Basic LTI';
  61
+$string['basiclti_base_string'] = 'Basic LTI OAuth Base String';
  62
+$string['basiclti_in_new_window'] = 'Your activity has opened in a new window';
  63
+$string['basiclti_endpoint'] = 'Basic LTI Launch Endpoint';
  64
+$string['basiclti_parameters'] = 'Basic LTI Launch Parameters';
  65
+$string['basicltiactivities'] = 'Basic LTI Activities';
  66
+$string['basicltifieldset'] = 'Custom example fieldset';
  67
+$string['basicltiintro'] = 'Activity Description';
  68
+$string['basicltiname'] = 'Activity Name';
  69
+$string['basicltisettings'] = 'Basic Learning Tool Interoperability Settings';
  70
+$string['comment'] = 'Comment';
  71
+$string['configpassword'] = 'Default Remote Tool Password';
  72
+$string['configpreferheight'] = 'Default preferred height';
  73
+$string['configpreferwidget'] = 'Set widget as default launch';
  74
+$string['configpreferwidth'] = 'Default preferred width';
  75
+$string['configresourceurl'] = 'Default Resource URL';
  76
+$string['configtoolurl'] = 'Default Remote Tool URL';
  77
+$string['configtypes'] = 'Enable Basic LTI Applications';
  78
+$string['courseid'] = 'Course id number';
  79
+$string['coursemisconf'] = 'Course is misconfigured';
  80
+$string['curllibrarymissing'] = 'PHP Curl library must be installed to use LTI';
  81
+$string['custom'] = 'Custom parameters';
  82
+$string['custominstr'] = 'Custom parameters';
  83
+$string['debuglaunch'] = 'Debug Option';
  84
+$string['debuglaunchoff'] = 'Normal launch';
  85
+$string['debuglaunchon'] = 'Debug launch';
  86
+$string['donot'] = 'Do not send';
  87
+$string['donotaccept'] = 'Do not accept';
  88
+$string['donotallow'] = 'Do not allow';
  89
+$string['enableemailnotification'] = 'Send notification emails';
  90
+$string['enableemailnotification_help'] = 'If enabled, students will receive email notification when their tool submissions are graded.';
  91
+$string['errormisconfig'] = 'Misconfigured tool. Please ask your Moodle administrator to fix the configuration of the tool.';
  92
+$string['extensions'] = 'Basic LTI Extension Services';
  93
+$string['failedtoconnect'] = 'Moodle was unable to communicate with the \"$a\" system';
  94
+$string['filterconfig'] = 'Basic LTI administration';
  95
+$string['filtername'] = 'Basic LTI';
  96
+$string['filter_basiclti_configlink'] = 'Configure your preferred sites and their passwords';
  97
+$string['filter_basiclti_password'] = 'Password is mandatory';
  98
+$string['fixexistingconf'] = 'Use an existing configuration for the misconfigured instance';
  99
+$string['fixnew'] = 'New Configuration';
  100
+$string['fixnewconf'] = 'Define a new configuration for the misconfigured instance';
  101
+$string['fixold'] = 'Use Existing';
  102
+$string['grading'] = 'Grade Routing';
  103
+$string['id'] = 'id';
  104
+$string['imsroleadmin'] = 'Instructor,Administrator';
  105
+$string['imsroleinstructor'] = 'Instructor';
  106
+$string['imsrolelearner'] = 'Learner';
  107
+$string['invalidid'] = 'basic LTI ID was incorrect';
  108
+$string['launch_in_moodle'] = 'Launch tool in moodle';
  109
+$string['launch_in_popup'] = 'Launch tool in a pop-up';
  110
+$string['launchinpopup'] = 'Launch Container';
  111
+$string['launchoptions'] = 'Launch Options';
  112
+$string['lti_errormsg'] = 'The tool returned the following error message: \"$a\"';
  113
+$string['misconfiguredtools'] = 'Misconfigured tool instances were detected';
  114
+$string['missingparameterserror'] = 'The page is misconfigured: \"$a\"';
  115
+$string['module_class_type'] = 'Moodle module type';
  116
+$string['modulename'] = 'External Tool';
  117
+$string['modulenameplural'] = 'basicltis';
  118
+$string['modulenamepluralformatted'] = 'Basic LTI Instances';
  119
+$string['never'] = 'Never';
  120
+$string['noattempts'] = 'No attempts have been made on this tool instance';
  121
+$string['noservers'] = 'No servers found';
  122
+$string['notypes'] = 'There are currently no LTI tools setup in Moodle. Click the Install link above to add some.';
  123
+$string['noviewusers'] = 'No users were found with permissions to use this tool';
  124
+$string['optionalsettings'] = 'Optional settings';
  125
+$string['organization'] ='Organization details';
  126
+$string['organizationdescr'] ='Organization Description';
  127
+$string['organizationid'] ='Organization ID';
  128
+$string['organizationurl'] ='Organization URL';
  129
+$string['pagesize'] = 'Submissions shown per page';
  130
+$string['password'] = 'Shared Secret';
  131
+$string['pluginadministration'] = 'Basic LTI administration';
  132
+$string['pluginname'] = 'LTI';
  133
+$string['preferheight'] = 'Preferred Height';
  134
+$string['preferwidget'] = 'Prefer Widget Launch';
  135
+$string['preferwidth'] = 'Preferred Width';
  136
+$string['press_to_submit'] = 'Press to launch this activity';
  137
+$string['privacy'] = 'Privacy';
  138
+$string['quickgrade'] = 'Allow quick grading';
  139
+$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.';
  140
+$string['redirect'] = 'You will be redirected in few seconds. If you are not, press the button.';
  141
+$string['resource'] = 'Resource';
  142
+$string['resourcekey'] = 'Consumer Key';
  143
+$string['resourceurl'] = 'Resource URL';
  144
+$string['saveallfeedback'] = 'Save all my feedback';
  145
+$string['send'] = 'Send';
  146
+$string['sendemailaddr'] = 'Share launcher\'s email with tool';
  147
+$string['sendname'] = 'Share launcher\'s name with tool';
  148
+$string['setdefault'] = 'Set a default value for the professor if delegating';
  149
+$string['setupbox'] = 'Basic LTI Tool Setup Box';
  150
+$string['setupoptions'] = 'Setup Options';
  151
+$string['size'] = 'Size parameters';
  152
+$string['submission'] = 'Submission';
  153
+$string['toggle_debug_data'] = 'Toggle Debug Data';
  154
+$string['toolsetup'] = 'External Tool Configuration';
  155
+$string['toolurl'] = 'Tool Base URL';
  156
+$string['typename'] = 'Tool Name';
  157
+$string['types'] = 'Types';
  158
+$string['validurl'] = 'A valid URL must start with http(s)://';
  159
+$string['viewsubmissions'] = 'View submissions and grading screen';
  160
+
  161
+//New admin strings
  162
+
  163
+$string['show_in_course'] = 'Show tool type when creating tool instances';
  164
+$string['delegate'] = 'Delegate to Instructor';
  165
+$string['tool_settings'] = 'Tool Settings';
  166
+$string['miscellaneous'] = 'Miscellaneous';
  167
+$string['embed'] = 'Embed';
  168
+$string['embed_no_blocks'] = 'Embed, without blocks';
  169
+$string['new_window'] = 'New window';
  170
+$string['default_launch_container'] = 'Default Launch Container';
  171
+$string['active'] = 'Active';
  172
+$string['pending'] = 'Pending';
  173
+$string['rejected'] = 'Rejected';
  174
+$string['baseurl'] = 'Base URL';
  175
+$string['action'] = 'Action';
  176
+$string['createdon'] = 'Created On';
  177
+$string['accept'] = 'Accept';
  178
+$string['update'] = 'Update';
  179
+$string['delete'] = 'Delete';
  180
+$string['reject'] = 'Reject';
  181
+$string['external_tool_types'] = 'External Tool Types';
  182
+$string['no_lti_configured'] = 'There are no active External Tools configured.';
  183
+$string['no_lti_pending'] = 'There are no pending External Tools.';
  184
+$string['no_lti_rejected'] = 'There are no rejected External Tools.';
  185
+
  186
+//New instructor strings
  187
+$string['display_name'] = 'Display activity name when launched';
  188
+$string['display_description'] = 'Display activity description when launched';
  189
+$string['external_tool_type'] = 'External tool type';
  190
+$string['launch_url'] = 'Launch URL';
  191
+$string['share_name'] = 'Share launcher\'s name with the tool';
  192
+$string['share_email'] = 'Share launcher\'s email with the tool';
  193
+$string['accept_grades'] = 'Accept grades from the tool';
  194
+$string['share_roster'] = 'Allow the tool to access this course\'s roster';
  195
+$string['automatic'] = 'Automatic, based on Launch URL';
  196
+$string['default'] = 'Default';
62  mod/lti/locallib.php
@@ -129,6 +129,23 @@ function lti_view($instance, $makeobject=false) {
129 129
     echo $content;
130 130
 }
131 131
 
  132
+function lti_build_sourcedid($instanceid, $userid, $servicesalt){
  133
+    $data = new stdClass();
  134
+        
  135
+    $data->instanceid = $instanceid;
  136
+    $data->userid = $userid;
  137
+
  138
+    $json = json_encode($data);
  139
+
  140
+    $hash = hash('sha256', $json . $servicesalt, false);
  141
+
  142
+    $container = new stdClass();
  143
+    $container->data = $data;
  144
+    $container->hash = $hash;
  145
+
  146
+    return $container;
  147
+}
  148
+
132 149
 /**
133 150
  * This function builds the request that must be sent to the tool producer
134 151
  *
@@ -168,20 +185,7 @@ function lti_build_request($instance, $typeconfig, $course) {
168 185
     $placementsecret = $instance->servicesalt;
169 186
         
170 187
     if ( isset($placementsecret) ) {
171  
-        $data = new stdClass();
172  
-        
173  
-        $data->instanceid = $instance->id;
174  
-        $data->userid = $USER->id;
175  
-        
176  
-        $json = json_encode($data);
177  
-        
178  
-        $hash = hash('sha256', $json . $placementsecret, false);
179  
-        
180  
-        $container = new stdClass();
181  
-        $container->data = $data;
182  
-        $container->hash = $hash;
183  
-        
184  
-        $sourcedid = json_encode($container);
  188
+        $sourcedid = json_encode(lti_build_sourcedid($instance->id, $USER->id, $placementsecret));
185 189
     }
186 190
 
187 191
     if ( isset($placementsecret) &&
@@ -338,10 +342,10 @@ function lti_get_type_config($typeid) {
338 342
     return $typeconfig;
339 343
 }
340 344
 
341  
-function lti_get_tools_by_url($url, $state){
  345
+function lti_get_tools_by_url($url, $state, $courseid = null){
342 346
     $domain = lti_get_domain_from_url($url);
343 347
     
344  
-    return lti_get_tools_by_domain($domain, $state);
  348
+    return lti_get_tools_by_domain($domain, $state, $courseid);
345 349
 }
346 350
 
347 351
 function lti_get_tools_by_domain($domain, $state = null, $courseid = null){
@@ -387,14 +391,23 @@ function lti_filter_get_types() {
387 391
 }
388 392
 
389 393
 function lti_get_types_for_add_instance(){
390  
-    global $DB;
391  
-    $admintypes = $DB->get_records('lti_types', array('coursevisible' => 1));
  394
+    global $DB, $SITE, $COURSE;
  395
+    
  396
+    $query = <<<QUERY
  397
+            SELECT *
  398
+            FROM {lti_types}
  399
+            WHERE
  400
+                coursevisible = 1
  401
+            AND (course = :siteid OR course = :courseid)
  402
+QUERY;
  403
+    
  404
+    $admintypes = $DB->get_records_sql($query, array('siteid' => $SITE->id, 'courseid' => $COURSE->id));
392 405
     
393 406
     $types = array();
394  
-    $types[0] = get_string('automatic', 'lti');
  407
+    $types[0] = (object)array('name' => get_string('automatic', 'lti'), 'course' => $SITE->id);
395 408
     
396 409
     foreach($admintypes as $type) {
397  
-        $types[$type->id] = $type->name;
  410
+        $types[$type->id] = (object)array('name' => $type->name, 'course' => $type->course);
398 411
     }
399 412
     
400 413
     return $types;
@@ -409,7 +422,7 @@ function lti_get_domain_from_url($url){
409 422
 }
410 423
 
411 424
 function lti_get_tool_by_url_match($url, $courseid = null, $state = LTI_TOOL_STATE_CONFIGURED){
412  
-    $possibletools = lti_get_tools_by_url($url, $state, $courseid);
  425
+    $possibletools = lti_get_tools_by_url($url, $courseid, $state);
413 426
     
414 427
     return lti_get_best_tool_by_url($url, $possibletools);
415 428
 }
@@ -729,6 +742,8 @@ function lti_add_type($type, $config){
729 742
             }
730 743
         }
731 744
     }
  745
+    
  746
+    return $id;
732 747
 }
733 748
 
734 749
 /**
@@ -923,3 +938,8 @@ function lti_submittedlink($cm, $allgroups=false) {
923 938
     return $submitted;
924 939
 }
925 940
 
  941
+function lti_get_type($typeid){
  942
+    global $DB;
  943
+    
  944
+    return $DB->get_record('lti_types', array('id' => $typeid));
  945
+}
124  mod/lti/mod_form.js
... ...
@@ -0,0 +1,124 @@
  1
+M.mod_lti = M.mod_lti || {};
  2
+
  3
+M.mod_lti.editor = {
  4
+    init: function(Y, settings){
  5
+        this.Y = Y;
  6
+        var self = this;
  7
+        this.settings = Y.JSON.parse(settings);
  8
+
  9
+        var typeSelector = Y.one('#id_typeid');
  10
+        typeSelector.on('change', function(e){
  11
+            self.toggleEditButtons();
  12
+        });
  13
+
  14
+        this.createTypeEditorButtons();
  15
+        
  16
+        this.toggleEditButtons();
  17
+    },
  18
+    
  19
+    getSelectedToolTypeOption: function(){
  20
+        var Y = this.Y;
  21
+        var typeSelector = Y.one('#id_typeid');
  22
+        
  23
+        return typeSelector.one('option[value=' + typeSelector.get('value') + ']');
  24
+    },
  25
+    
  26
+    /**
  27
+     * Adds buttons for creating, editing, and deleting tool types
  28
+     */
  29
+    createTypeEditorButtons: function(){
  30
+        var Y = this.Y;
  31
+        var self = this;
  32
+        
  33
+        var typeSelector = Y.one('#id_typeid');
  34
+        
  35
+        var createIcon = function(id, tooltip, iconUrl){
  36
+            return Y.Node.create('<a />') 
  37
+                    .set('id', id)
  38
+                    .set('title', tooltip)
  39
+                    .setStyle('margin-left', '.5em')
  40
+                    .set('href', 'javascript:void(0);')
  41
+                    .append(Y.Node.create('<img src="' + iconUrl + '" />'));
  42
+        }
  43
+        
  44
+        var addIcon = createIcon('lti_add_tool_type', 'Add new tool type', this.settings.add_icon_url);
  45
+        var editIcon = createIcon('lti_edit_tool_type', 'Edit new tool type', this.settings.edit_icon_url);
  46
+        var deleteIcon  = createIcon('lti_delete_tool_type', 'Delete tool type', this.settings.delete_icon_url);
  47
+        
  48
+        editIcon.on('click', function(e){
  49
+            var toolTypeId = typeSelector.get('value');
  50
+            
  51
+            if(self.getSelectedToolTypeOption().getAttribute('editable')){
  52
+                window.open(self.settings.instructor_tool_type_edit_url + '&action=edit&typeid=' + toolTypeId, 'edit_tool');
  53
+            }
  54
+        });
  55
+        
  56
+        addIcon.on('click', function(e){
  57
+            window.open(self.settings.instructor_tool_type_edit_url + '&action=add', 'add_tool');
  58
+        });
  59
+        
  60
+        deleteIcon.on('click', function(e){
  61
+            var toolTypeId = typeSelector.get('value');
  62
+            
  63
+            if(self.getSelectedToolTypeOption().getAttribute('editable')){
  64
+                Y.io(self.settings.instructor_tool_type_edit_url + '&action=delete&typeid=' + toolTypeId, {
  65
+                    on: {
  66
+                        success: function(){
  67
+                            getSelectedOption().remove();
  68
+                        },
  69
+                        failure: function(){
  70
+
  71
+                        }
  72
+                    }
  73
+                });
  74
+            }
  75
+        });
  76
+        
  77
+        typeSelector.insert(addIcon, 'after');
  78
+        addIcon.insert(editIcon, 'after');
  79
+        editIcon.insert(deleteIcon, 'after');
  80
+    },
  81
+    
  82
+    toggleEditButtons: function(){
  83
+        var Y = this.Y;
  84
+        
  85
+        var lti_edit_tool_type = Y.one('#lti_edit_tool_type');
  86
+        var lti_delete_tool_type = Y.one('#lti_delete_tool_type');
  87
+        
  88
+        if(this.getSelectedToolTypeOption().getAttribute('editable')){
  89
+            lti_edit_tool_type.setStyle('opacity', '1');
  90
+            lti_delete_tool_type.setStyle('opacity', '1');
  91
+        } else {
  92
+            lti_edit_tool_type.setStyle('opacity', '.2');
  93
+            lti_delete_tool_type.setStyle('opacity', '.2');
  94
+        }
  95
+    },
  96
+    
  97
+    addToolType: function(text, value){
  98
+        var Y = this.Y;
  99
+        var typeSelector = Y.one('#id_typeid');
  100
+        
  101
+        var option = Y.Node.create('<option />')
  102
+                        .set('text', text)
  103
+                        .set('value', value)
  104
+                        .set('selected', 'selected');
  105
+                        
  106
+        typeSelector.append(option);
  107
+    },
  108
+    
  109
+    updateToolType: function(text, value){
  110
+        var Y = this.Y;
  111
+        var typeSelector = Y.one('#id_typeid');
  112
+        
  113
+        var option = Y.Node.create('<option />')
  114
+                        .set('text', text)
  115
+                        .set('value', value)
  116
+                        .set('selected', 'selected');
  117
+                        
  118
+        typeSelector.append(option);
  119
+    }
  120
+
  121
+};
  122
+
  123
+
  124
+
615  mod/lti/mod_form.php
... ...
@@ -1,416 +1,199 @@
1  
-<?php
2  
-// This file is part of BasicLTI4Moodle
3  
-//
4  
-// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
5  
-// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
6  
-// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
7  
-// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
8  
-// are already supporting or going to support BasicLTI. This project Implements the consumer
9  
-// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
10  
-// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
11  
-// at the GESSI research group at UPC.
12  
-// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
13  
-// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
14  
-// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
15  
-//
16  
-// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
17  
-// of the Universitat Politecnica de Catalunya http://www.upc.edu
18  
-// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
19  
-//
20  
-// Moodle is free software: you can redistribute it and/or modify
21  
-// it under the terms of the GNU General Public License as published by
22  
-// the Free Software Foundation, either version 3 of the License, or
23  
-// (at your option) any later version.
24  
-//
25  
-// Moodle is distributed in the hope that it will be useful,
26  
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
27  
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28  
-// GNU General Public License for more details.
29  
-//
30  
-// You should have received a copy of the GNU General Public License
31  
-// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
32  
-
33  
-/**
34  
- * This file defines the main basiclti configuration form
35  
- *
36  
- * @package lti
37  
- * @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
38  
- *  marc.alier@upc.edu
39  
- * @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
40  
- *
41  
- * @author Marc Alier
42  
- * @author Jordi Piguillem
43  
- * @author Nikolas Galanis
44  
- *
45  
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
46  
- */
47  
-
48  
-defined('MOODLE_INTERNAL') || die;
49  
-
50  
-require_once($CFG->dirroot.'/course/moodleform_mod.php');
51  
-require_once($CFG->dirroot.'/mod/lti/locallib.php');
52  
-
53  
-class mod_lti_mod_form extends moodleform_mod {
54  
-
55  
-    function definition() {
56  
-        global $DB;
57  
-
58  
-        $typename = optional_param('type', false, PARAM_ALPHA);
59  
-
60  
-        if (empty($typename)) {
61  
-            //Updating instance
62  
-            if (!empty($this->_instance)) {
63  
-                $basiclti = $DB->get_record('lti', array('id' => $this->_instance));
64  
-                $this->typeid = $basiclti->typeid;
65  
-
66  
-                $typeconfig = lti_get_config($basiclti);