MDL-20534 lti: A3, copyright and DOS lf fixed
[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 *
61eb12d4
CS
38 * @package mod
39 * @subpackage lti
40 * @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
996b0fd9 41 * marc.alier@upc.edu
61eb12d4
CS
42 * @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
43 * @author Marc Alier
44 * @author Jordi Piguillem
45 * @author Nikolas Galanis
46 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
996b0fd9
CS
47 */
48
49defined('MOODLE_INTERNAL') || die;
50
6831c7cd 51global $PAGE, $CFG, $SITE;
996b0fd9
CS
52
53require_once($CFG->dirroot.'/mod/lti/locallib.php');
54
996b0fd9 55if ($ADMIN->fulltree) {
996b0fd9
CS
56 $configuredtoolshtml = '';
57 $pendingtoolshtml = '';
58 $rejectedtoolshtml = '';
59
60 $active = get_string('active', 'lti');
61 $pending = get_string('pending', 'lti');
62 $rejected = get_string('rejected', 'lti');
63 $typename = get_string('typename', 'lti');
64 $baseurl = get_string('baseurl', 'lti');
65 $action = get_string('action', 'lti');
66 $createdon = get_string('createdon', 'lti');
67
6831c7cd 68 $types = lti_filter_get_types($SITE->id);
996b0fd9
CS
69
70 $configuredtools = array_filter($types, function($value){
71 return $value->state == LTI_TOOL_STATE_CONFIGURED;
72 });
73
74 $configuredtoolshtml = lti_get_tool_table($configuredtools, 'lti_configured');
75
76 $pendingtools = array_filter($types, function($value){
77 return $value->state == LTI_TOOL_STATE_PENDING;
78 });
79
80 $pendingtoolshtml = lti_get_tool_table($pendingtools, 'lti_pending');
81
82 $rejectedtools = array_filter($types, function($value){
83 return $value->state == LTI_TOOL_STATE_REJECTED;
84 });
85
86 $rejectedtoolshtml = lti_get_tool_table($rejectedtools, 'lti_rejected');
87
88 $tab = optional_param('tab', '', PARAM_ALPHAEXT);
89 $activeselected = '';
90 $pendingselected = '';
91 $rejectedselected = '';
92 switch($tab){
93 case 'lti_pending':
94 $pendingselected = 'class="selected"';
95 break;
96 case 'lti_rejected':
97 $rejectedselected = 'class="selected"';
98 break;
99 default:
100 $activeselected = 'class="selected"';
101 break;
102 }
103
104 $template = <<<HTML
105<div id="lti_tabs" class="yui-navset">
106 <ul id="lti_tab_heading" class="yui-nav" style="display:none">
107 <li {$activeselected}>
108 <a href="#tab1">
109 <em>$active</em>
110 </a>
111 </li>
112 <li {$pendingselected}>
113 <a href="#tab2">
114 <em>$pending</em>
115 </a>
116 </li>
117 <li {$rejectedselected}>
118 <a href="#tab3">
119 <em>$rejected</em>
120 </a>
121 </li>
122 </ul>
123 <div class="yui-content">
124 <div>
125 $configuredtoolshtml
126 </div>
127 <div>
128 $pendingtoolshtml
129 </div>
130 <div>
131 $rejectedtoolshtml
132 </div>
133 </div>
134</div>
135
136<script type='text/javascript'>
137//<![CDATA[
138 (function(){
139 //If javascript is disabled, they will just see the three tabs one after another
140 var lti_tab_heading = document.getElementById('lti_tab_heading');
141 lti_tab_heading.style.display = '';
142
143 new YAHOO.widget.TabView('lti_tabs');
144
145 var setupTools = function(id, sort){
146 var lti_tools = YAHOO.util.Dom.get(id + "_tools");
147
148 if(lti_tools){
149 var dataSource = new YAHOO.util.DataSource(lti_tools);
150
151 var configuredColumns = [
152 {key:"name", label:"$typename", sortable:true},
153 {key:"baseURL", label:"$baseurl", sortable:true},
154 {key:"timecreated", label:"$createdon", sortable:true, formatter:YAHOO.widget.DataTable.formatDate},
155 {key:"action", label:"$action"}
156 ];
157
158 dataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE;
159 dataSource.responseSchema = {
160 fields: [
161 {key:"name"},
162 {key:"baseURL"},
163 {key:"timecreated", parser:"date"},
164 {key:"action"}
165 ]
166 };
167
168 new YAHOO.widget.DataTable(id + "_container", configuredColumns, dataSource,
169 {
170 sortedBy: sort
171 }
172 );
173 }
174 };
175
176 setupTools('lti_configured', {key:"name", dir:"asc"});
177 setupTools('lti_pending', {key:"timecreated", dir:"desc"});
178 setupTools('lti_rejected', {key:"timecreated", dir:"desc"});
179 })();
180//]]
181</script>
182HTML;
183
184 $PAGE->requires->yui2_lib('tabview');
185 $PAGE->requires->yui2_lib('datatable');
186
b26dc53c 187 $settings->add(new admin_setting_heading('lti_types', get_string('external_tool_types', 'lti') . $OUTPUT->help_icon('main_admin', 'lti'), $template));
996b0fd9 188}