Merge commit 'catalyst/MOODLE_19_STABLE' into mdl19-linuxchix
[moodle-linuxchix.git] / course / scales.php
blob9017c1ba2dd04c783aeba7123908748462f2ab52
1 <?php // $Id$
2 // Allows a creator to edit custom scales, and also display help about scales
4 require_once("../config.php");
5 require_once("lib.php");
7 $id = required_param('id', PARAM_INT); // course id
8 $scaleid = optional_param('scaleid', 0, PARAM_INT); // scale id (show only this one)
10 if (! $course = get_record("course", "id", $id)) {
11 error("Course ID was incorrect");
14 require_login($course);
15 $context = get_context_instance(CONTEXT_COURSE, $course->id);
16 require_capability('moodle/course:viewscales', $context);
18 $strscale = get_string("scale");
19 $strscales = get_string("scales");
20 $strcustomscale = get_string("scalescustom");
21 $strstandardscale = get_string("scalesstandard");
22 $strcustomscales = get_string("scalescustom");
23 $strstandardscales = get_string("scalesstandard");
24 $strname = get_string("name");
25 $strdescription = get_string("description");
26 $strhelptext = get_string("helptext");
27 $stractivities = get_string("activities");
29 print_header($strscales);
31 if ($scaleid) {
32 if ($scale = get_record("scale", 'id', $scaleid)) {
33 if ($scale->courseid == 0 || $scale->courseid == $course->id) {
35 $scalemenu = make_menu_from_list($scale->scale);
37 print_simple_box_start("center");
38 print_heading($scale->name);
39 echo "<center>";
40 choose_from_menu($scalemenu, "", "", "");
41 echo "</center>";
42 echo text_to_html($scale->description);
43 print_simple_box_end();
44 close_window_button();
45 exit;
50 if ($scales = get_records("scale", "courseid", "$course->id", "name ASC")) {
51 print_heading($strcustomscales);
53 if (has_capability('moodle/course:managescales', $context)) {
54 echo "<p align=\"center\">(";
55 print_string("scalestip");
56 echo ")</p>";
59 foreach ($scales as $scale) {
60 $scalemenu = make_menu_from_list($scale->scale);
62 print_simple_box_start("center");
63 print_heading($scale->name);
64 echo "<center>";
65 choose_from_menu($scalemenu, "", "", "");
66 echo "</center>";
67 echo text_to_html($scale->description);
68 print_simple_box_end();
69 echo "<hr />";
72 } else {
73 if (has_capability('moodle/course:managescales', $context)) {
74 echo "<p align=\"center\">(";
75 print_string("scalestip");
76 echo ")</p>";
80 if ($scales = get_records("scale", "courseid", "0", "name ASC")) {
81 print_heading($strstandardscales);
82 foreach ($scales as $scale) {
83 $scalemenu = make_menu_from_list($scale->scale);
85 print_simple_box_start("center");
86 print_heading($scale->name);
87 echo "<center>";
88 choose_from_menu($scalemenu, "", "", "");
89 echo "</center>";
90 echo text_to_html($scale->description);
91 print_simple_box_end();
92 echo "<hr />";
96 close_window_button();
97 exit;