MDL-20034: add title attribute to user profile (image tag).
[moodle.git] / course / scales.php
CommitLineData
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
27require_once("../config.php");
28require_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 34if ($scaleid !== 0) {
35 $url->param('scaleid', $scaleid);
36}
37$PAGE->set_url($url);
38
39if (!$course = $DB->get_record('course', array('id'=>$id))) {
40 print_error("invalidcourseid");
41}
42
43require_login($course);
44$context = get_context_instance(CONTEXT_COURSE, $course->id);
45require_capability('moodle/course:viewscales', $context);
46
d9cb06dc 47$strscales = get_string("scales");
d9cb06dc 48$strcustomscales = get_string("scalescustom");
49$strstandardscales = get_string("scalesstandard");
d9cb06dc 50
51$PAGE->set_title($strscales);
fac9c4ef 52$PAGE->set_heading($course->fullname);
d9cb06dc 53echo $OUTPUT->header();
54
55if ($scaleid) {
56 if ($scale = $DB->get_record("scale", array('id'=>$scaleid))) {
57 if ($scale->courseid == 0 || $scale->courseid == $course->id) {
a57319b1 58
78ad5f3f 59 $scalemenu = make_menu_from_list($scale->scale);
92604dbc 60
e6db3026 61 echo $OUTPUT->box_start();
7c5286cd 62 echo $OUTPUT->heading($scale->name);
78ad5f3f 63 echo "<center>";
593a43b6 64 echo html_writer::select($scalemenu, 'unused');
78ad5f3f 65 echo "</center>";
66 echo text_to_html($scale->description);
e6db3026 67 echo $OUTPUT->box_end();
d9cb06dc 68 echo $OUTPUT->close_window_button();
69 echo $OUTPUT->footer();
70 exit;
9c002633 71 }
d9cb06dc 72 }
73}
9c002633 74
8bdc9cac
SH
75$systemcontext = get_context_instance(CONTEXT_SYSTEM);
76
d9cb06dc 77if ($scales = $DB->get_records("scale", array("courseid"=>$course->id), "name ASC")) {
78 echo $OUTPUT->heading($strcustomscales);
79
80 if (has_capability('moodle/course:managescales', $context)) {
81 echo "<p align=\"center\">(";
82 print_string('scalestip2');
83 echo ")</p>";
9c002633 84 }
85
d9cb06dc 86 foreach ($scales as $scale) {
8bdc9cac 87
64f93798 88 $scale->description = file_rewrite_pluginfile_urls($scale->description, 'pluginfile.php', $systemcontext->id, 'grade', 'scale', $scale->id);
8bdc9cac 89
d9cb06dc 90 $scalemenu = make_menu_from_list($scale->scale);
91
92 echo $OUTPUT->box_start();
93 echo $OUTPUT->heading($scale->name);
94 echo "<center>";
593a43b6 95 echo html_writer::select($scalemenu, 'unused');
d9cb06dc 96 echo "</center>";
97 echo text_to_html($scale->description);
98 echo $OUTPUT->box_end();
99 echo "<hr />";
100 }
9c002633 101
d9cb06dc 102} else {
103 if (has_capability('moodle/course:managescales', $context)) {
104 echo "<p align=\"center\">(";
f854cfae 105 print_string("scalestip2");
d9cb06dc 106 echo ")</p>";
107 }
108}
109
110if ($scales = $DB->get_records("scale", array("courseid"=>0), "name ASC")) {
111 echo $OUTPUT->heading($strstandardscales);
112 foreach ($scales as $scale) {
8bdc9cac 113
64f93798 114 $scale->description = file_rewrite_pluginfile_urls($scale->description, 'pluginfile.php', $systemcontext->id, 'grade', 'scale', $scale->id);
8bdc9cac 115
d9cb06dc 116 $scalemenu = make_menu_from_list($scale->scale);
117
118 echo $OUTPUT->box_start();
119 echo $OUTPUT->heading($scale->name);
120 echo "<center>";
593a43b6 121 echo html_writer::select($scalemenu, 'unused');
d9cb06dc 122 echo "</center>";
123 echo text_to_html($scale->description);
124 echo $OUTPUT->box_end();
125 echo "<hr />";
9c002633 126 }
d9cb06dc 127}
9c002633 128
d9cb06dc 129echo $OUTPUT->close_window_button();
130echo $OUTPUT->footer();
a57319b1 131