Skip to content

Commit b97af59

Browse files
author
Andrew Davis
committed
rating MDL-24513 made scales.php work with site level (not course level) scales
1 parent 29cf663 commit b97af59

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

course/scales.php

+14-5
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,29 @@
3636
}
3737
$PAGE->set_url($url);
3838

39-
if (!$course = $DB->get_record('course', array('id'=>$id))) {
40-
print_error("invalidcourseid");
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);
4147
}
4248

43-
require_login($course);
44-
$context = get_context_instance(CONTEXT_COURSE, $course->id);
49+
$PAGE->set_context($context);
4550
require_capability('moodle/course:viewscales', $context);
4651

4752
$strscales = get_string("scales");
4853
$strcustomscales = get_string("scalescustom");
4954
$strstandardscales = get_string("scalesstandard");
5055

5156
$PAGE->set_title($strscales);
52-
$PAGE->set_heading($course->fullname);
57+
if (!empty($course)) {
58+
$PAGE->set_heading($course->fullname);
59+
} else {
60+
$PAGE->set_heading($SITE->fullname);
61+
}
5362
echo $OUTPUT->header();
5463

5564
if ($scaleid) {

0 commit comments

Comments
 (0)