Commit | Line | Data |
---|---|---|
996b0fd9 CS |
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, $PAGE, $OUTPUT, $USER, $COURSE; | |
57 | ||
58 | $this->typeid = 0; | |
59 | ||
60 | $mform =& $this->_form; | |
61 | //------------------------------------------------------------------------------- | |
62 | /// Adding the "general" fieldset, where all the common settings are shown | |
63 | $mform->addElement('header', 'general', get_string('general', 'form')); | |
64 | /// Adding the standard "name" field | |
65 | $mform->addElement('text', 'name', get_string('basicltiname', 'lti'), array('size'=>'64')); | |
66 | $mform->setType('name', PARAM_TEXT); | |
67 | $mform->addRule('name', null, 'required', null, 'client'); | |
68 | /// Adding the optional "intro" and "introformat" pair of fields | |
69 | $this->add_intro_editor(false, get_string('basicltiintro', 'lti')); | |
70 | $mform->setAdvanced('introeditor'); | |
71 | ||
72 | $mform->addElement('checkbox', 'showtitle', ' ', ' ' . get_string('display_name', 'lti')); | |
73 | $mform->setAdvanced('showtitle'); | |
74 | ||
75 | $mform->addElement('checkbox', 'showdescription', ' ', ' ' . get_string('display_description', 'lti')); | |
76 | $mform->setAdvanced('showdescription'); | |
77 | ||
78 | //Tool settings | |
79 | $tooltypes = $mform->addElement('select', 'typeid', get_string('external_tool_type', 'lti'), array()); | |
80 | ||
81 | foreach(lti_get_types_for_add_instance() as $id => $type){ | |
82 | if($type->course == $COURSE->id) { | |
16e8f130 | 83 | $attributes = array( 'editable' => 1, 'courseTool' => 1, 'domain' => $type->tooldomain ); |
6831c7cd | 84 | } else if($id != 0) { |
16e8f130 | 85 | $attributes = array( 'globalTool' => 1, 'domain' => $type->tooldomain); |
996b0fd9 CS |
86 | } else { |
87 | $attributes = array(); | |
88 | } | |
89 | ||
90 | $tooltypes->addOption($type->name, $id, $attributes); | |
91 | } | |
92 | ||
93 | $mform->addElement('text', 'toolurl', get_string('launch_url', 'lti'), array('size'=>'64')); | |
94 | $mform->setType('toolurl', PARAM_TEXT); | |
95 | ||
96 | $launchoptions=array(); | |
97 | $launchoptions[LTI_LAUNCH_CONTAINER_DEFAULT] = get_string('default', 'lti'); | |
98 | $launchoptions[LTI_LAUNCH_CONTAINER_EMBED] = get_string('embed', 'lti'); | |
99 | $launchoptions[LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS] = get_string('embed_no_blocks', 'lti'); | |
100 | $launchoptions[LTI_LAUNCH_CONTAINER_WINDOW] = get_string('new_window', 'lti'); | |
101 | ||
102 | $mform->addElement('select', 'launchcontainer', get_string('launchinpopup', 'lti'), $launchoptions); | |
103 | $mform->setDefault('launchcontainer', LTI_LAUNCH_CONTAINER_DEFAULT); | |
104 | ||
105 | $mform->addElement('text', 'resourcekey', get_string('resourcekey', 'lti')); | |
106 | $mform->setType('resourcekey', PARAM_TEXT); | |
107 | $mform->setAdvanced('resourcekey'); | |
108 | ||
109 | $mform->addElement('passwordunmask', 'password', get_string('password', 'lti')); | |
110 | $mform->setType('password', PARAM_TEXT); | |
111 | $mform->setAdvanced('password'); | |
112 | ||
113 | $mform->addElement('textarea', 'instructorcustomparameters', get_string('custom', 'lti'), array('rows'=>4, 'cols'=>60)); | |
114 | $mform->setType('instructorcustomparameters', PARAM_TEXT); | |
115 | $mform->setAdvanced('instructorcustomparameters'); | |
116 | ||
117 | //------------------------------------------------------------------------------- | |
118 | //$mform->addElement('hidden', 'typeid', $this->typeid); | |
119 | //$mform->addElement('hidden', 'toolurl', $this->typeconfig['toolurl']); | |
120 | //$mform->addElement('hidden', 'type', $typename); | |
121 | ||
122 | //------------------------------------------------------------------------------- | |
123 | // Add privacy preferences fieldset where users choose whether to send their data | |
124 | $mform->addElement('header', 'privacy', get_string('privacy', 'lti')); | |
125 | ||
126 | $mform->addElement('checkbox', 'instructorchoicesendname', ' ', ' ' . get_string('share_name', 'lti')); | |
127 | $mform->setDefault('instructorchoicesendname', '1'); | |
128 | ||
129 | $mform->addElement('checkbox', 'instructorchoicesendemailaddr', ' ', ' ' . get_string('share_email', 'lti')); | |
130 | $mform->setDefault('instructorchoicesendemailaddr', '1'); | |
131 | ||
132 | $mform->addElement('checkbox', 'instructorchoiceacceptgrades', ' ', ' ' . get_string('accept_grades', 'lti')); | |
133 | $mform->setDefault('instructorchoiceacceptgrades', '1'); | |
134 | ||
135 | $mform->addElement('checkbox', 'instructorchoiceallowroster', ' ', ' ' . get_string('share_roster', 'lti')); | |
136 | $mform->setDefault('instructorchoiceallowroster', '1'); | |
137 | ||
138 | //------------------------------------------------------------------------------- | |
139 | ||
140 | /* $debugoptions=array(); | |
141 | $debugoptions[0] = get_string('debuglaunchoff', 'lti'); | |
142 | $debugoptions[1] = get_string('debuglaunchon', 'lti'); | |
143 | ||
144 | $mform->addElement('select', 'debuglaunch', get_string('debuglaunch', 'lti'), $debugoptions); | |
145 | ||
146 | if (isset($this->typeconfig['debuglaunch'])) { | |
147 | if ($this->typeconfig['debuglaunch'] == 0) { | |
148 | $mform->setDefault('debuglaunch', '0'); | |
149 | } else if ($this->typeconfig['debuglaunch'] == 1) { | |
150 | $mform->setDefault('debuglaunch', '1'); | |
151 | } | |
152 | } | |
153 | */ | |
154 | ||
155 | //------------------------------------------------------------------------------- | |
156 | // add standard elements, common to all modules | |
157 | $this->standard_coursemodule_elements(); | |
158 | ||
159 | $mform->setAdvanced('cmidnumber'); | |
160 | //------------------------------------------------------------------------------- | |
161 | // add standard buttons, common to all modules | |
162 | $this->add_action_buttons(); | |
163 | ||
6831c7cd CS |
164 | $editurl = new moodle_url("/mod/lti/instructor_edit_tool_type.php?sesskey={$USER->sesskey}&course={$COURSE->id}"); |
165 | $ajaxurl = new moodle_url('/mod/lti/ajax.php'); | |
166 | ||
996b0fd9 CS |
167 | $jsinfo = (object)array( |
168 | 'edit_icon_url' => (string)$OUTPUT->pix_url('t/edit'), | |
169 | 'add_icon_url' => (string)$OUTPUT->pix_url('t/add'), | |
170 | 'delete_icon_url' => (string)$OUTPUT->pix_url('t/delete'), | |
6831c7cd | 171 | 'green_check_icon_url' => (string)$OUTPUT->pix_url('i/tick_green_small'), |
16e8f130 | 172 | 'warning_icon_url' => (string)$OUTPUT->pix_url('warning', 'lti'), |
6831c7cd CS |
173 | 'instructor_tool_type_edit_url' => $editurl->out(false), |
174 | 'ajax_url' => $ajaxurl->out(true), | |
175 | 'courseId' => $COURSE->id | |
996b0fd9 CS |
176 | ); |
177 | ||
178 | $module = array( | |
179 | 'name' => 'mod_lti_edit', | |
180 | 'fullpath' => '/mod/lti/mod_form.js', | |
6831c7cd CS |
181 | 'requires' => array('base', 'io', 'querystring-stringify-simple', 'node', 'event', 'json-parse'), |
182 | 'strings' => array( | |
183 | array('addtype', 'lti'), | |
184 | array('edittype', 'lti'), | |
185 | array('deletetype', 'lti'), | |
186 | array('delete_confirmation', 'lti'), | |
187 | array('cannot_edit', 'lti'), | |
188 | array('cannot_delete', 'lti'), | |
189 | array('global_tool_types', 'lti'), | |
16e8f130 CS |
190 | array('course_tool_types', 'lti'), |
191 | array('using_tool_configuration', 'lti'), | |
192 | array('domain_mismatch', 'lti'), | |
193 | array('custom_config', 'lti'), | |
194 | array('tool_config_not_found', 'lti') | |
6831c7cd | 195 | ), |
996b0fd9 CS |
196 | ); |
197 | ||
198 | $PAGE->requires->js_init_call('M.mod_lti.editor.init', array(json_encode($jsinfo)), true, $module); | |
199 | } | |
200 | ||
201 | /** | |
202 | * Make fields editable or non-editable depending on the administrator choices | |
203 | * @see moodleform_mod::definition_after_data() | |
204 | */ | |
205 | function definition_after_data() { | |
206 | parent::definition_after_data(); | |
207 | ||
208 | } | |
209 | ||
210 | /** | |
211 | * Function overwritten to change default values using | |
212 | * global configuration | |
213 | * | |
214 | * @param array $default_values passed by reference | |
215 | */ | |
216 | function data_preprocessing(&$default_values) { | |
217 | ||
218 | } | |
219 | } | |
220 |