Commit | Line | Data |
---|---|---|
d9cb06dc | 1 | <?php |
2 | ||
3 | // This file is part of Moodle - http://moodle.org/ | |
4 | // | |
5 | // Moodle is free software: you can redistribute it and/or modify | |
6 | // it under the terms of the GNU General Public License as published by | |
7 | // the Free Software Foundation, either version 3 of the License, or | |
8 | // (at your option) any later version. | |
9 | // | |
10 | // Moodle is distributed in the hope that it will be useful, | |
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | // GNU General Public License for more details. | |
14 | // | |
15 | // You should have received a copy of the GNU General Public License | |
16 | // along with Moodle. If not, see <http://www.gnu.org/licenses/>. | |
17 | ||
18 | /** | |
19 | * Allows a creator to edit custom scales, and also display help about scales | |
20 | * | |
21 | * @copyright 1999 Martin Dougiamas http://dougiamas.com | |
096ec8d6 | 22 | * @deprecated - TODO remove this file or replace it with an alternative solution for scales overview |
d9cb06dc | 23 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
24 | * @package course | |
25 | */ | |
26 | ||
27 | require_once("../config.php"); | |
28 | require_once("lib.php"); | |
29 | ||
30 | $id = required_param('id', PARAM_INT); // course id | |
31 | $scaleid = optional_param('scaleid', 0, PARAM_INT); // scale id (show only this one) | |
32 | ||
a6855934 | 33 | $url = new moodle_url('/course/scales.php', array('id'=>$id)); |
d9cb06dc | 34 | if ($scaleid !== 0) { |
35 | $url->param('scaleid', $scaleid); | |
36 | } | |
37 | $PAGE->set_url($url); | |
38 | ||
b97af597 AD |
39 | $context = null; |
40 | if ($course = $DB->get_record('course', array('id'=>$id))) { | |
41 | require_login($course); | |
9a5e297b | 42 | $context = context_course::instance($course->id); |
b97af597 AD |
43 | } else { |
44 | //$id will be 0 for site level scales | |
45 | require_login(); | |
9a5e297b | 46 | $context = context_system::instance(); |
d9cb06dc | 47 | } |
48 | ||
b97af597 | 49 | $PAGE->set_context($context); |
d9cb06dc | 50 | require_capability('moodle/course:viewscales', $context); |
51 | ||
d9cb06dc | 52 | $strscales = get_string("scales"); |
d9cb06dc | 53 | $strcustomscales = get_string("scalescustom"); |
54 | $strstandardscales = get_string("scalesstandard"); | |
d9cb06dc | 55 | |
56 | $PAGE->set_title($strscales); | |
b97af597 AD |
57 | if (!empty($course)) { |
58 | $PAGE->set_heading($course->fullname); | |
59 | } else { | |
60 | $PAGE->set_heading($SITE->fullname); | |
61 | } | |
d9cb06dc | 62 | echo $OUTPUT->header(); |
63 | ||
64 | if ($scaleid) { | |
65 | if ($scale = $DB->get_record("scale", array('id'=>$scaleid))) { | |
66 | if ($scale->courseid == 0 || $scale->courseid == $course->id) { | |
a57319b1 | 67 | |
78ad5f3f | 68 | $scalemenu = make_menu_from_list($scale->scale); |
92604dbc | 69 | |
e6db3026 | 70 | echo $OUTPUT->box_start(); |
7c5286cd | 71 | echo $OUTPUT->heading($scale->name); |
78ad5f3f | 72 | echo "<center>"; |
70ad5136 RW |
73 | echo html_writer::label(get_string('scales'), 'scaleunused'. $scaleid, false, array('class' => 'accesshide')); |
74 | echo html_writer::select($scalemenu, 'unused', '', array('' => 'choosedots'), array('id' => 'scaleunused'.$scaleid)); | |
78ad5f3f | 75 | echo "</center>"; |
76 | echo text_to_html($scale->description); | |
e6db3026 | 77 | echo $OUTPUT->box_end(); |
d9cb06dc | 78 | echo $OUTPUT->close_window_button(); |
79 | echo $OUTPUT->footer(); | |
80 | exit; | |
9c002633 | 81 | } |
d9cb06dc | 82 | } |
83 | } | |
9c002633 | 84 | |
9a5e297b | 85 | $systemcontext = context_system::instance(); |
8bdc9cac | 86 | |
d9cb06dc | 87 | if ($scales = $DB->get_records("scale", array("courseid"=>$course->id), "name ASC")) { |
88 | echo $OUTPUT->heading($strcustomscales); | |
89 | ||
90 | if (has_capability('moodle/course:managescales', $context)) { | |
91 | echo "<p align=\"center\">("; | |
92 | print_string('scalestip2'); | |
93 | echo ")</p>"; | |
9c002633 | 94 | } |
95 | ||
d9cb06dc | 96 | foreach ($scales as $scale) { |
8bdc9cac | 97 | |
64f93798 | 98 | $scale->description = file_rewrite_pluginfile_urls($scale->description, 'pluginfile.php', $systemcontext->id, 'grade', 'scale', $scale->id); |
8bdc9cac | 99 | |
d9cb06dc | 100 | $scalemenu = make_menu_from_list($scale->scale); |
101 | ||
102 | echo $OUTPUT->box_start(); | |
103 | echo $OUTPUT->heading($scale->name); | |
104 | echo "<center>"; | |
70ad5136 RW |
105 | echo html_writer::label(get_string('scales'), 'courseunused' . $scale->id, false, array('class' => 'accesshide')); |
106 | echo html_writer::select($scalemenu, 'unused', '', array('' => 'choosedots'), array('id' => 'courseunused' . $scale->id)); | |
d9cb06dc | 107 | echo "</center>"; |
108 | echo text_to_html($scale->description); | |
109 | echo $OUTPUT->box_end(); | |
110 | echo "<hr />"; | |
111 | } | |
9c002633 | 112 | |
d9cb06dc | 113 | } else { |
114 | if (has_capability('moodle/course:managescales', $context)) { | |
115 | echo "<p align=\"center\">("; | |
f854cfae | 116 | print_string("scalestip2"); |
d9cb06dc | 117 | echo ")</p>"; |
118 | } | |
119 | } | |
120 | ||
121 | if ($scales = $DB->get_records("scale", array("courseid"=>0), "name ASC")) { | |
122 | echo $OUTPUT->heading($strstandardscales); | |
123 | foreach ($scales as $scale) { | |
8bdc9cac | 124 | |
64f93798 | 125 | $scale->description = file_rewrite_pluginfile_urls($scale->description, 'pluginfile.php', $systemcontext->id, 'grade', 'scale', $scale->id); |
8bdc9cac | 126 | |
d9cb06dc | 127 | $scalemenu = make_menu_from_list($scale->scale); |
128 | ||
129 | echo $OUTPUT->box_start(); | |
130 | echo $OUTPUT->heading($scale->name); | |
131 | echo "<center>"; | |
70ad5136 RW |
132 | echo html_writer::label(get_string('scales'), 'sitescale' . $scale->id, false, array('class' => 'accesshide')); |
133 | echo html_writer::select($scalemenu, 'unused', '', array('' => 'choosedots'), array('id' => 'sitescale' . $scale->id)); | |
d9cb06dc | 134 | echo "</center>"; |
135 | echo text_to_html($scale->description); | |
136 | echo $OUTPUT->box_end(); | |
137 | echo "<hr />"; | |
9c002633 | 138 | } |
d9cb06dc | 139 | } |
9c002633 | 140 | |
d9cb06dc | 141 | echo $OUTPUT->close_window_button(); |
142 | echo $OUTPUT->footer(); | |
a57319b1 | 143 |