Commit | Line | Data |
---|---|---|
b7e436b0 CS |
1 | <?php\r |
2 | // This file is part of BasicLTI4Moodle\r | |
3 | //\r | |
4 | // BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)\r | |
5 | // consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web\r | |
6 | // based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI\r | |
7 | // specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS\r | |
8 | // are already supporting or going to support BasicLTI. This project Implements the consumer\r | |
9 | // for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.\r | |
10 | // BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem\r | |
11 | // at the GESSI research group at UPC.\r | |
12 | // SimpleLTI consumer for Moodle is an implementation of the early specification of LTI\r | |
13 | // by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a\r | |
14 | // Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.\r | |
15 | //\r | |
16 | // BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis\r | |
17 | // of the Universitat Politecnica de Catalunya http://www.upc.edu\r | |
18 | // Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu\r | |
19 | //\r | |
20 | // Moodle is free software: you can redistribute it and/or modify\r | |
21 | // it under the terms of the GNU General Public License as published by\r | |
22 | // the Free Software Foundation, either version 3 of the License, or\r | |
23 | // (at your option) any later version.\r | |
24 | //\r | |
25 | // Moodle is distributed in the hope that it will be useful,\r | |
26 | // but WITHOUT ANY WARRANTY; without even the implied warranty of\r | |
27 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r | |
28 | // GNU General Public License for more details.\r | |
29 | //\r | |
30 | // You should have received a copy of the GNU General Public License\r | |
31 | // along with Moodle. If not, see <http://www.gnu.org/licenses/>.\r | |
32 | \r | |
33 | /**\r | |
34 | * This file contains the script used to clone Moodle admin setting page.\r | |
35 | * It is used to create a new form used to pre-configure basiclti\r | |
36 | * activities\r | |
37 | *\r | |
73300339 | 38 | * @package lti\r |
b7e436b0 CS |
39 | * @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis\r |
40 | * marc.alier@upc.edu\r | |
41 | * @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu\r | |
42 | *\r | |
43 | * @author Marc Alier\r | |
44 | * @author Jordi Piguillem\r | |
45 | * @author Nikolas Galanis\r | |
46 | *\r | |
47 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r | |
48 | */\r | |
49 | \r | |
50 | require_once('../../config.php');\r | |
51 | require_once($CFG->libdir.'/adminlib.php');\r | |
73300339 CS |
52 | require_once($CFG->dirroot.'/mod/lti/edit_form.php');\r |
53 | require_once($CFG->dirroot.'/mod/lti/locallib.php');\r | |
b7e436b0 | 54 | \r |
73300339 | 55 | $section = 'modsettinglti';\r |
b7e436b0 CS |
56 | $return = optional_param('return', '', PARAM_ALPHA);\r |
57 | $adminediting = optional_param('adminedit', -1, PARAM_BOOL);\r | |
58 | $action = optional_param('action', null, PARAM_TEXT);\r | |
59 | $id = optional_param('id', null, PARAM_INT);\r | |
60 | $useexisting = optional_param('useexisting', null, PARAM_INT);\r | |
61 | $definenew = optional_param('definenew', null, PARAM_INT);\r | |
62 | \r | |
63 | /// no guest autologin\r | |
64 | require_login(0, false);\r | |
73300339 | 65 | $url = new moodle_url('/mod/lti/typesettings.php');\r |
b7e436b0 CS |
66 | $PAGE->set_url($url);\r |
67 | \r | |
68 | admin_externalpage_setup('managemodules'); // Hacky solution for printing the admin page\r | |
69 | \r | |
a4a07996 CS |
70 | $tab = optional_param('tab', '', PARAM_ALPHAEXT);\r |
71 | $redirect = "$CFG->wwwroot/$CFG->admin/settings.php?section=modsettinglti&tab={$tab}";\r | |
72 | \r | |
b7e436b0 CS |
73 | /// WRITING SUBMITTED DATA (IF ANY) -------------------------------------------------------------------------------\r |
74 | \r | |
75 | $statusmsg = '';\r | |
76 | $errormsg = '';\r | |
77 | $focus = '';\r | |
78 | \r | |
a4a07996 CS |
79 | $data = data_submitted();\r |
80 | \r | |
81 | if (confirm_sesskey() && isset($data->submitbutton)) {\r | |
285f8250 | 82 | $type = new StdClass();\r |
0d8afb44 | 83 | \r |
b7e436b0 | 84 | if (isset($id)) {\r |
b7e436b0 | 85 | $type->id = $id;\r |
879e97bd CS |
86 | \r |
87 | lti_update_type($type, $data);\r | |
285f8250 | 88 | \r |
a4a07996 | 89 | redirect($redirect);\r |
b7e436b0 CS |
90 | die;\r |
91 | } else {\r | |
a4a07996 | 92 | $type->state = LTI_TOOL_STATE_CONFIGURED;\r |
879e97bd CS |
93 | \r |
94 | lti_add_type($type, $data);\r | |
285f8250 | 95 | \r |
a4a07996 | 96 | redirect($redirect);\r |
b7e436b0 CS |
97 | die;\r |
98 | }\r | |
a4a07996 CS |
99 | } else if(isset($data->cancel)){\r |
100 | redirect($redirect);\r | |
101 | die;\r | |
b7e436b0 CS |
102 | }\r |
103 | \r | |
a4a07996 CS |
104 | if ($action == 'accept') {\r |
105 | lti_set_state_for_type($id, LTI_TOOL_STATE_CONFIGURED);\r | |
106 | redirect($redirect);\r | |
b7e436b0 CS |
107 | die;\r |
108 | }\r | |
109 | \r | |
a4a07996 CS |
110 | if ($action == 'reject') {\r |
111 | lti_set_state_for_type($id, LTI_TOOL_STATE_REJECTED);\r | |
112 | redirect($redirect);\r | |
113 | die;\r | |
114 | }\r | |
115 | \r | |
116 | if ($action == 'delete') {\r | |
117 | lti_delete_type($id);\r | |
118 | redirect($redirect);\r | |
b7e436b0 CS |
119 | die;\r |
120 | }\r | |
121 | \r | |
122 | /// print header stuff ------------------------------------------------------------\r | |
123 | $PAGE->set_focuscontrol($focus);\r | |
124 | if (empty($SITE->fullname)) {\r | |
125 | $PAGE->set_title($settingspage->visiblename);\r | |
126 | $PAGE->set_heading($settingspage->visiblename);\r | |
127 | \r | |
73300339 | 128 | $PAGE->navbar->add('Basic LTI Administration', $CFG->wwwroot.'/admin/settings.php?section=modsettinglti');\r |
b7e436b0 CS |
129 | \r |
130 | echo $OUTPUT->header();\r | |
131 | \r | |
132 | echo $OUTPUT->box(get_string('configintrosite', 'admin'));\r | |
133 | \r | |
134 | if ($errormsg !== '') {\r | |
135 | echo $OUTPUT->notification($errormsg);\r | |
136 | \r | |
137 | } else if ($statusmsg !== '') {\r | |
138 | echo $OUTPUT->notification($statusmsg, 'notifysuccess');\r | |
139 | }\r | |
140 | \r | |
141 | // ---------------------------------------------------------------------------------------------------------------\r | |
142 | \r | |
143 | echo '<form action="typesettings.php" method="post" id="'.$id.'" >';\r | |
144 | echo '<div class="settingsform clearfix">';\r | |
145 | echo html_writer::input_hidden_params($PAGE->url);\r | |
146 | echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';\r | |
147 | echo '<input type="hidden" name="return" value="'.$return.'" />';\r | |
148 | \r | |
149 | echo $settingspage->output_html();\r | |
150 | \r | |
151 | echo '<div class="form-buttons"><input class="form-submit" type="submit" value="'.get_string('savechanges', 'admin').'" /></div>';\r | |
152 | \r | |
153 | echo '</div>';\r | |
154 | echo '</form>';\r | |
155 | \r | |
156 | } else {\r | |
157 | if ($PAGE->user_allowed_editing()) {\r | |
158 | $url = clone($PAGE->url);\r | |
159 | if ($PAGE->user_is_editing()) {\r | |
160 | $caption = get_string('blockseditoff');\r | |
161 | $url->param('adminedit', 'off');\r | |
162 | } else {\r | |
163 | $caption = get_string('blocksediton');\r | |
164 | $url->param('adminedit', 'on');\r | |
165 | }\r | |
166 | $buttons = $OUTPUT->single_button($url, $caption, 'get');\r | |
167 | }\r | |
168 | \r | |
73300339 | 169 | $PAGE->set_title("$SITE->shortname: " . get_string('toolsetup', 'lti'));\r |
b7e436b0 | 170 | \r |
73300339 | 171 | $PAGE->navbar->add('Basic LTI Administration', $CFG->wwwroot.'/admin/settings.php?section=modsettinglti');\r |
b7e436b0 CS |
172 | \r |
173 | echo $OUTPUT->header();\r | |
174 | \r | |
b7e436b0 CS |
175 | if ($errormsg !== '') {\r |
176 | echo $OUTPUT->notification($errormsg);\r | |
177 | \r | |
178 | } else if ($statusmsg !== '') {\r | |
179 | echo $OUTPUT->notification($statusmsg, 'notifysuccess');\r | |
180 | }\r | |
181 | \r | |
182 | // ---------------------------------------------------------------------------------------------------------------\r | |
73300339 | 183 | echo $OUTPUT->heading(get_string('toolsetup', 'lti'));\r |
b7e436b0 CS |
184 | echo $OUTPUT->box_start('generalbox');\r |
185 | if ($action == 'add') {\r | |
73300339 | 186 | $form = new mod_lti_edit_types_form();\r |
b7e436b0 CS |
187 | $form->display();\r |
188 | } else if ($action == 'update') {\r | |
73300339 CS |
189 | $form = new mod_lti_edit_types_form('typessettings.php?id='.$id);\r |
190 | $type = lti_get_type_type_config($id);\r | |
b7e436b0 CS |
191 | $form->set_data($type);\r |
192 | $form->display();\r | |
b7e436b0 CS |
193 | }\r |
194 | \r | |
195 | echo $OUTPUT->box_end();\r | |
196 | }\r | |
197 | \r | |
198 | echo $OUTPUT->footer();\r |