MDL-30192 restore - prevent any extra info to be created for deleted users
[moodle.git] / course / scales.php
blob07bf4fabb3cfe52e92371ddeabe0398b7e4ac2e8
1 <?php
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.
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/>.
18 /**
19 * Allows a creator to edit custom scales, and also display help about scales
21 * @copyright 1999 Martin Dougiamas http://dougiamas.com
22 * @deprecated - TODO remove this file or replace it with an alternative solution for scales overview
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 * @package course
27 require_once("../config.php");
28 require_once("lib.php");
30 $id = required_param('id', PARAM_INT); // course id
31 $scaleid = optional_param('scaleid', 0, PARAM_INT); // scale id (show only this one)
33 $url = new moodle_url('/course/scales.php', array('id'=>$id));
34 if ($scaleid !== 0) {
35 $url->param('scaleid', $scaleid);
37 $PAGE->set_url($url);
39 $context = null;
40 if ($course = $DB->get_record('course', array('id'=>$id))) {
41 require_login($course);
42 $context = get_context_instance(CONTEXT_COURSE, $course->id);
43 } else {
44 //$id will be 0 for site level scales
45 require_login();
46 $context = get_context_instance(CONTEXT_SYSTEM);
49 $PAGE->set_context($context);
50 require_capability('moodle/course:viewscales', $context);
52 $strscales = get_string("scales");
53 $strcustomscales = get_string("scalescustom");
54 $strstandardscales = get_string("scalesstandard");
56 $PAGE->set_title($strscales);
57 if (!empty($course)) {
58 $PAGE->set_heading($course->fullname);
59 } else {
60 $PAGE->set_heading($SITE->fullname);
62 echo $OUTPUT->header();
64 if ($scaleid) {
65 if ($scale = $DB->get_record("scale", array('id'=>$scaleid))) {
66 if ($scale->courseid == 0 || $scale->courseid == $course->id) {
68 $scalemenu = make_menu_from_list($scale->scale);
70 echo $OUTPUT->box_start();
71 echo $OUTPUT->heading($scale->name);
72 echo "<center>";
73 echo html_writer::select($scalemenu, 'unused');
74 echo "</center>";
75 echo text_to_html($scale->description);
76 echo $OUTPUT->box_end();
77 echo $OUTPUT->close_window_button();
78 echo $OUTPUT->footer();
79 exit;
84 $systemcontext = get_context_instance(CONTEXT_SYSTEM);
86 if ($scales = $DB->get_records("scale", array("courseid"=>$course->id), "name ASC")) {
87 echo $OUTPUT->heading($strcustomscales);
89 if (has_capability('moodle/course:managescales', $context)) {
90 echo "<p align=\"center\">(";
91 print_string('scalestip2');
92 echo ")</p>";
95 foreach ($scales as $scale) {
97 $scale->description = file_rewrite_pluginfile_urls($scale->description, 'pluginfile.php', $systemcontext->id, 'grade', 'scale', $scale->id);
99 $scalemenu = make_menu_from_list($scale->scale);
101 echo $OUTPUT->box_start();
102 echo $OUTPUT->heading($scale->name);
103 echo "<center>";
104 echo html_writer::select($scalemenu, 'unused');
105 echo "</center>";
106 echo text_to_html($scale->description);
107 echo $OUTPUT->box_end();
108 echo "<hr />";
111 } else {
112 if (has_capability('moodle/course:managescales', $context)) {
113 echo "<p align=\"center\">(";
114 print_string("scalestip2");
115 echo ")</p>";
119 if ($scales = $DB->get_records("scale", array("courseid"=>0), "name ASC")) {
120 echo $OUTPUT->heading($strstandardscales);
121 foreach ($scales as $scale) {
123 $scale->description = file_rewrite_pluginfile_urls($scale->description, 'pluginfile.php', $systemcontext->id, 'grade', 'scale', $scale->id);
125 $scalemenu = make_menu_from_list($scale->scale);
127 echo $OUTPUT->box_start();
128 echo $OUTPUT->heading($scale->name);
129 echo "<center>";
130 echo html_writer::select($scalemenu, 'unused');
131 echo "</center>";
132 echo text_to_html($scale->description);
133 echo $OUTPUT->box_end();
134 echo "<hr />";
138 echo $OUTPUT->close_window_button();
139 echo $OUTPUT->footer();