question MDL-19820 Replaced deprecated functions
[moodle.git] / course / scales.php
CommitLineData
24f2b65a 1<?php // $Id$
a57319b1 2 // Allows a creator to edit custom scales, and also display help about scales
3
9c002633 4 require_once("../config.php");
5 require_once("lib.php");
a57319b1 6
78ad5f3f 7 $id = required_param('id', PARAM_INT); // course id
ddd9cd01 8 $scaleid = optional_param('scaleid', 0, PARAM_INT); // scale id (show only this one)
a57319b1 9
579d45b4 10 if (!$course = $DB->get_record('course', array('id'=>$id))) {
ba6018a9 11 print_error("invalidcourseid");
a57319b1 12 }
13
78ad5f3f 14 require_login($course);
61240489 15 $context = get_context_instance(CONTEXT_COURSE, $course->id);
78ad5f3f 16 require_capability('moodle/course:viewscales', $context);
a57319b1 17
18 $strscale = get_string("scale");
19 $strscales = get_string("scales");
9c002633 20 $strcustomscale = get_string("scalescustom");
21 $strstandardscale = get_string("scalesstandard");
a57319b1 22 $strcustomscales = get_string("scalescustom");
23 $strstandardscales = get_string("scalesstandard");
24 $strname = get_string("name");
25 $strdescription = get_string("description");
9c002633 26 $strhelptext = get_string("helptext");
27 $stractivities = get_string("activities");
9c002633 28
0a122046 29 $PAGE->set_title($strscales);
30 echo $OUTPUT->header();
9c002633 31
ddd9cd01 32 if ($scaleid) {
878af9ad 33 if ($scale = $DB->get_record("scale", array('id'=>$scaleid))) {
ddd9cd01 34 if ($scale->courseid == 0 || $scale->courseid == $course->id) {
35
36 $scalemenu = make_menu_from_list($scale->scale);
37
e6db3026 38 echo $OUTPUT->box_start();
7c5286cd 39 echo $OUTPUT->heading($scale->name);
ddd9cd01 40 echo "<center>";
5387640a 41 echo $OUTPUT->select(html_select::make($scalemenu));
ddd9cd01 42 echo "</center>";
43 echo text_to_html($scale->description);
e6db3026 44 echo $OUTPUT->box_end();
bb0b9075 45 echo $OUTPUT->close_window_button();
d60c1124 46 echo $OUTPUT->footer();
ddd9cd01 47 exit;
48 }
49 }
50 }
51
6bb08163 52 if ($scales = $DB->get_records("scale", array("courseid"=>$course->id), "name ASC")) {
7c5286cd 53 echo $OUTPUT->heading($strcustomscales);
0ae88327 54
78ad5f3f 55 if (has_capability('moodle/course:managescales', $context)) {
56 echo "<p align=\"center\">(";
853a3eef 57 print_string('scalestip2');
78ad5f3f 58 echo ")</p>";
9c002633 59 }
60
78ad5f3f 61 foreach ($scales as $scale) {
62 $scalemenu = make_menu_from_list($scale->scale);
92604dbc 63
e6db3026 64 echo $OUTPUT->box_start();
7c5286cd 65 echo $OUTPUT->heading($scale->name);
78ad5f3f 66 echo "<center>";
5387640a 67 echo $OUTPUT->select(html_select::make($scalemenu));
78ad5f3f 68 echo "</center>";
69 echo text_to_html($scale->description);
e6db3026 70 echo $OUTPUT->box_end();
78ad5f3f 71 echo "<hr />";
9c002633 72 }
73
78ad5f3f 74 } else {
75 if (has_capability('moodle/course:managescales', $context)) {
76 echo "<p align=\"center\">(";
77 print_string("scalestip");
78 echo ")</p>";
9c002633 79 }
9c002633 80 }
81
6bb08163 82 if ($scales = $DB->get_records("scale", array("courseid"=>0), "name ASC")) {
7c5286cd 83 echo $OUTPUT->heading($strstandardscales);
78ad5f3f 84 foreach ($scales as $scale) {
85 $scalemenu = make_menu_from_list($scale->scale);
9c002633 86
e6db3026 87 echo $OUTPUT->box_start();
7c5286cd 88 echo $OUTPUT->heading($scale->name);
78ad5f3f 89 echo "<center>";
e6db3026 90 echo $OUTPUT->select(html_select::make($scalemenu, ''));
78ad5f3f 91 echo "</center>";
92 echo text_to_html($scale->description);
e6db3026 93 echo $OUTPUT->box_end();
78ad5f3f 94 echo "<hr />";
9c002633 95 }
96 }
97
bb0b9075 98 echo $OUTPUT->close_window_button();
d60c1124 99 echo $OUTPUT->footer();
a57319b1 100
101?>