-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathindex.php
109 lines (88 loc) · 4.32 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* List the tool provided in a course
*
* @package local
* @subpackage ltiprovider
* @copyright 2011 Juan Leyva <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(__FILE__) . '/../../config.php');
require_once($CFG->dirroot.'/local/ltiprovider/lib.php');
$courseid = required_param('courseid', PARAM_INT);
if (! ($course = $DB->get_record('course', array('id'=>$courseid)))) {
print_error('invalidcourseid', 'error');
}
$PAGE->set_url('/local/ltiprovider/index.php', array('courseid' => $courseid));
context_helper::preload_course($course->id);
if (!$context = context_course::instance($course->id)) {
print_error('nocontext');
}
require_login($course);
require_capability('local/ltiprovider:view', $context);
// $PAGE->navbar->add(get_string('toolsprovided', 'local_ltiprovider'));
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('toolsprovided', 'local_ltiprovider'));
$tools = $DB->get_records('local_ltiprovider', array('courseid' => $course->id));
$data = array();
foreach ($tools as $tool) {
if (!$toolcontext = context::instance_by_id($tool->contextid, IGNORE_MISSING)) {
local_ltiprovider_delete_tool($tool);
continue;
}
$line = array();
$line[] = $toolcontext->get_context_name();
$line[] = $tool->secret;
$line[] = new moodle_url('/local/ltiprovider/tool.php', array('id' => $tool->id));
if (has_capability('local/ltiprovider:manage', $context)) {
$buttons = array();
$buttons[] = html_writer::link(new moodle_url('/local/ltiprovider/edit.php', array('id'=>$tool->id, 'delete'=>1, 'sesskey'=>sesskey())), $OUTPUT->pix_icon('t/delete', get_string('delete')));
$buttons[] = html_writer::link(new moodle_url('/local/ltiprovider/edit.php', array('id'=>$tool->id, 'sesskey'=>sesskey())), $OUTPUT->pix_icon('t/edit', get_string('edit')));
if ($tool->disabled) {
$buttons[] = html_writer::link(new moodle_url('/local/ltiprovider/edit.php', array('id'=>$tool->id, 'show'=>1, 'sesskey'=>sesskey())), $OUTPUT->pix_icon('t/show', get_string('show')));
} else {
$buttons[] = html_writer::link(new moodle_url('/local/ltiprovider/edit.php', array('id'=>$tool->id, 'hide'=>1, 'sesskey'=>sesskey())), $OUTPUT->pix_icon('t/hide', get_string('hide')));
}
if ($tool->sendgrades) {
$buttons[] = html_writer::link(new moodle_url('/local/ltiprovider/syncreport.php', array('id'=>$tool->id)), $OUTPUT->pix_icon('i/grades', get_string('gradessyncreport', 'local_ltiprovider')));
}
if ($tool->syncmembers) {
$buttons[] = html_writer::link(new moodle_url('/local/ltiprovider/syncmembers.php', array('id'=>$tool->id)), $OUTPUT->pix_icon('i/users', get_string('forcesyncmembers', 'local_ltiprovider')));
}
$line[] = implode(' ', $buttons);
} else {
$line[] = '';
}
$data[] = $line;
}
// Moodle 2.2 and onwards
if (isset($CFG->allowframembedding) and !$CFG->allowframembedding) {
echo $OUTPUT->box(get_string('allowframembedding', 'local_ltiprovider'));
}
$table = new html_table();
$table->head = array(
get_string('name', 'local_ltiprovider'),
get_string('secret', 'local_ltiprovider'),
get_string('url', 'local_ltiprovider'),
get_string('edit'));
$table->size = array('20%', '20%', '50%', '10%');
$table->align = array('left', 'left', 'left', 'center');
$table->width = '99%';
$table->data = $data;
echo html_writer::table($table);
echo $OUTPUT->single_button(new moodle_url('/local/ltiprovider/edit.php', array('id' => -1, 'courseid' => $course->id)), get_string('add'));
echo $OUTPUT->footer();