MDL-20808 "Create AMF test client" Some updates to client
[moodle.git] / course / scales.php
blob8be8272f2da421e395eaa4af60e7accb58174803
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 if (!$course = $DB->get_record('course', array('id'=>$id))) {
40 print_error("invalidcourseid");
43 require_login($course);
44 $context = get_context_instance(CONTEXT_COURSE, $course->id);
45 require_capability('moodle/course:viewscales', $context);
47 $strscales = get_string("scales");
48 $strcustomscales = get_string("scalescustom");
49 $strstandardscales = get_string("scalesstandard");
51 $PAGE->set_title($strscales);
52 echo $OUTPUT->header();
54 if ($scaleid) {
55 if ($scale = $DB->get_record("scale", array('id'=>$scaleid))) {
56 if ($scale->courseid == 0 || $scale->courseid == $course->id) {
58 $scalemenu = make_menu_from_list($scale->scale);
60 echo $OUTPUT->box_start();
61 echo $OUTPUT->heading($scale->name);
62 echo "<center>";
63 echo html_writer::select($scalemenu, 'unused');
64 echo "</center>";
65 echo text_to_html($scale->description);
66 echo $OUTPUT->box_end();
67 echo $OUTPUT->close_window_button();
68 echo $OUTPUT->footer();
69 exit;
74 $systemcontext = get_context_instance(CONTEXT_SYSTEM);
76 if ($scales = $DB->get_records("scale", array("courseid"=>$course->id), "name ASC")) {
77 echo $OUTPUT->heading($strcustomscales);
79 if (has_capability('moodle/course:managescales', $context)) {
80 echo "<p align=\"center\">(";
81 print_string('scalestip2');
82 echo ")</p>";
85 foreach ($scales as $scale) {
87 $scale->description = file_rewrite_pluginfile_urls($scale->description, 'pluginfile.php', $systemcontext->id, 'grade', 'scale', $scale->id);
89 $scalemenu = make_menu_from_list($scale->scale);
91 echo $OUTPUT->box_start();
92 echo $OUTPUT->heading($scale->name);
93 echo "<center>";
94 echo html_writer::select($scalemenu, 'unused');
95 echo "</center>";
96 echo text_to_html($scale->description);
97 echo $OUTPUT->box_end();
98 echo "<hr />";
101 } else {
102 if (has_capability('moodle/course:managescales', $context)) {
103 echo "<p align=\"center\">(";
104 print_string("scalestip2");
105 echo ")</p>";
109 if ($scales = $DB->get_records("scale", array("courseid"=>0), "name ASC")) {
110 echo $OUTPUT->heading($strstandardscales);
111 foreach ($scales as $scale) {
113 $scale->description = file_rewrite_pluginfile_urls($scale->description, 'pluginfile.php', $systemcontext->id, 'grade', 'scale', $scale->id);
115 $scalemenu = make_menu_from_list($scale->scale);
117 echo $OUTPUT->box_start();
118 echo $OUTPUT->heading($scale->name);
119 echo "<center>";
120 echo html_writer::select($scalemenu, 'unused');
121 echo "</center>";
122 echo text_to_html($scale->description);
123 echo $OUTPUT->box_end();
124 echo "<hr />";
128 echo $OUTPUT->close_window_button();
129 echo $OUTPUT->footer();