weekly on-sync release 2.8dev
[moodle.git] / mod / lti / settings.php
CommitLineData
996b0fd9 1<?php
61eb12d4
CS
2// This file is part of Moodle - http://moodle.org/
3//
4// Moodle is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Moodle is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16//
996b0fd9
CS
17// This file is part of BasicLTI4Moodle
18//
19// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
20// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
21// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
22// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
23// are already supporting or going to support BasicLTI. This project Implements the consumer
24// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
25// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
26// at the GESSI research group at UPC.
27// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
28// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
29// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
30//
31// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
32// of the Universitat Politecnica de Catalunya http://www.upc.edu
33// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
996b0fd9
CS
34
35/**
61eb12d4 36 * This file defines the global lti administration form
996b0fd9 37 *
2b17ec3d 38 * @package mod_lti
61eb12d4 39 * @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
996b0fd9 40 * marc.alier@upc.edu
61eb12d4
CS
41 * @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
42 * @author Marc Alier
43 * @author Jordi Piguillem
44 * @author Nikolas Galanis
8f45215d 45 * @author Chris Scribner
61eb12d4 46 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
996b0fd9
CS
47 */
48
49defined('MOODLE_INTERNAL') || die;
50
996b0fd9 51if ($ADMIN->fulltree) {
b9fbe554
EL
52 require_once($CFG->dirroot.'/mod/lti/locallib.php');
53
996b0fd9
CS
54 $configuredtoolshtml = '';
55 $pendingtoolshtml = '';
56 $rejectedtoolshtml = '';
57
58 $active = get_string('active', 'lti');
59 $pending = get_string('pending', 'lti');
60 $rejected = get_string('rejected', 'lti');
61 $typename = get_string('typename', 'lti');
62 $baseurl = get_string('baseurl', 'lti');
63 $action = get_string('action', 'lti');
64 $createdon = get_string('createdon', 'lti');
e27cb316 65
b9fbe554 66 $types = lti_filter_get_types(get_site()->id);
e27cb316 67
d81a603e 68 $configuredtools = lti_filter_tool_types($types, LTI_TOOL_STATE_CONFIGURED);
e27cb316 69
996b0fd9
CS
70 $configuredtoolshtml = lti_get_tool_table($configuredtools, 'lti_configured');
71
d81a603e 72 $pendingtools = lti_filter_tool_types($types, LTI_TOOL_STATE_PENDING);
e27cb316 73
996b0fd9 74 $pendingtoolshtml = lti_get_tool_table($pendingtools, 'lti_pending');
e27cb316 75
d81a603e 76 $rejectedtools = lti_filter_tool_types($types, LTI_TOOL_STATE_REJECTED);
e27cb316 77
996b0fd9 78 $rejectedtoolshtml = lti_get_tool_table($rejectedtools, 'lti_rejected');
e27cb316 79
996b0fd9
CS
80 $tab = optional_param('tab', '', PARAM_ALPHAEXT);
81 $activeselected = '';
82 $pendingselected = '';
83 $rejectedselected = '';
ea04a9f9 84 switch ($tab) {
996b0fd9
CS
85 case 'lti_pending':
86 $pendingselected = 'class="selected"';
87 break;
88 case 'lti_rejected':
89 $rejectedselected = 'class="selected"';
90 break;
91 default:
92 $activeselected = 'class="selected"';
93 break;
94 }
e27cb316 95
5de15b83
CS
96 $template = "
97<div id=\"lti_tabs\" class=\"yui-navset\">
98 <ul id=\"lti_tab_heading\" class=\"yui-nav\" style=\"display:none\">
996b0fd9 99 <li {$activeselected}>
5de15b83 100 <a href=\"#tab1\">
996b0fd9
CS
101 <em>$active</em>
102 </a>
103 </li>
104 <li {$pendingselected}>
5de15b83 105 <a href=\"#tab2\">
996b0fd9
CS
106 <em>$pending</em>
107 </a>
108 </li>
109 <li {$rejectedselected}>
5de15b83 110 <a href=\"#tab3\">
996b0fd9
CS
111 <em>$rejected</em>
112 </a>
113 </li>
114 </ul>
5de15b83 115 <div class=\"yui-content\">
996b0fd9
CS
116 <div>
117 $configuredtoolshtml
118 </div>
119 <div>
120 $pendingtoolshtml
121 </div>
122 <div>
123 $rejectedtoolshtml
124 </div>
125 </div>
126</div>
127
5de15b83 128<script type=\"text/javascript\">
996b0fd9 129//<![CDATA[
426f2d5b 130 YUI().use('yui2-tabview', 'yui2-datatable', function(Y) {
996b0fd9
CS
131 //If javascript is disabled, they will just see the three tabs one after another
132 var lti_tab_heading = document.getElementById('lti_tab_heading');
133 lti_tab_heading.style.display = '';
134
426f2d5b 135 new Y.YUI2.widget.TabView('lti_tabs');
e27cb316 136
996b0fd9 137 var setupTools = function(id, sort){
426f2d5b 138 var lti_tools = Y.YUI2.util.Dom.get(id + '_tools');
e27cb316 139
996b0fd9 140 if(lti_tools){
426f2d5b 141 var dataSource = new Y.YUI2.util.DataSource(lti_tools);
e27cb316 142
996b0fd9 143 var configuredColumns = [
5de15b83
CS
144 {key:'name', label:'$typename', sortable:true},
145 {key:'baseURL', label:'$baseurl', sortable:true},
101ec5fd 146 {key:'timecreated', label:'$createdon', sortable:true},
5de15b83 147 {key:'action', label:'$action'}
996b0fd9
CS
148 ];
149
426f2d5b 150 dataSource.responseType = Y.YUI2.util.DataSource.TYPE_HTMLTABLE;
996b0fd9
CS
151 dataSource.responseSchema = {
152 fields: [
5de15b83
CS
153 {key:'name'},
154 {key:'baseURL'},
101ec5fd 155 {key:'timecreated'},
5de15b83 156 {key:'action'}
996b0fd9
CS
157 ]
158 };
159
426f2d5b 160 new Y.YUI2.widget.DataTable(id + '_container', configuredColumns, dataSource,
996b0fd9
CS
161 {
162 sortedBy: sort
163 }
164 );
165 }
166 };
167
5de15b83
CS
168 setupTools('lti_configured', {key:'name', dir:'asc'});
169 setupTools('lti_pending', {key:'timecreated', dir:'desc'});
170 setupTools('lti_rejected', {key:'timecreated', dir:'desc'});
426f2d5b 171 });
996b0fd9
CS
172//]]
173</script>
5de15b83 174";
b26dc53c 175 $settings->add(new admin_setting_heading('lti_types', get_string('external_tool_types', 'lti') . $OUTPUT->help_icon('main_admin', 'lti'), $template));
996b0fd9 176}