-
Notifications
You must be signed in to change notification settings - Fork 4
/
showclassified.php
127 lines (114 loc) · 3.77 KB
/
showclassified.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?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/>.
/**
* @package mod_customlabel
* @category mod
* @author Valery Fremaux <valery.fremaux@gmail.com>
* @copyright (C) 2008 onwards Valery Fremaux (http://www.mylearningfactory.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
*/
require_once('../../config.php');
if (is_dir($CFG->dirroot.'/blocks/course_status')) {
include_once($CFG->dirroot.'/blocks/course_status/xlib.php');
}
$value = optional_param('value', 0, PARAM_INT);
$type = optional_param('typeid', 0, PARAM_INT);
$params = array('value' => $value, 'typeid' => $type);
$url = new moodle_url('/mod/customlabel/adminmetadata.php', $params);
$context = context_system::instance();
$PAGE->set_url($url);
$PAGE->set_context($context);
require_login();
require_capability('moodle/site:config', $context);
if ($value == 0 && $type == 0) {
echo "<br/>";
echo $OUTPUT->notification("no input given");
echo "<br/>";
echo $OUTPUT->continue_button($url);
exit;
}
if ($value != 0) {
$sql = "
SELECT
c.id,
c.shortname,
c.fullname
FROM
{course} c,
{customlabel_course_metadata} ccm,
{customlabel_mtd_value} v
WHERE
c.id = ccm.courseid AND
ccm.valueid = v.id AND
v.id = $value
ORDER BY
c.fullname
";
if (!$courses = $DB->get_records_sql($sql)) {
$courses = array();
}
} else if ($type != 0) {
$sql = "
SELECT
c.id,
c.shortname,
c.fullname
FROM
{course} c,
{customlabel_course_metadata} ccm,
{customlabel_mtd_value} v,
{customlabel_mtd_value} t
WHERE
c.id = ccm.courseid AND
ccm.valueid = v.id AND
v.typeid = t.id AND
t.id = $type
ORDER BY
c.fullname
";
if (!$courses = $DB->get_records_sql($sql)) {
$courses = array();
}
}
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('lpclassificationhdr', 'customlabel'));
if (!empty($courses)) {
$strcourse = get_string('course');
$strstatus = get_string('status');
$table = new html_table();
$table->head = array("<b>$strcourse</b>", "<b>$strstatus</b>");
$table->size = array('70%', '30%');
$table->width = '90%';
$table->align = array('left', 'center');
foreach ($courses as $acourse) {
$curl = new moodle_url('/course/view.php', array('id' => $acourse->id));
$courselink = '<a target="_blanck" href="'.$curl.'">'.format_string($acourse->fullname).'</a>';
if (function_exists('ext_course_status_get_desc')) {
$table->data[] = array($courselink, ext_course_status_get_desc($acourse));
} else {
$table->data[] = array($courselink, '');
}
}
echo html_writer::table($table);
if ($value != 0) {
echo $OUTPUT->continue_button($url."?view=metadata&type={$type}");
} else {
echo $OUTPUT->continue_button($url."?view=classifiers");
}
} else {
echo $OUTPUT->continue_button($url);
}
echo $OUTPUT->footer();