MDL-33621 rating: fixed view help error for global scale rating
authorMark Nielsen <mark@moodlerooms.com>
Mon, 15 Oct 2012 08:48:21 +0000 (16:48 +0800)
committerRossiani Wijaya <rwijaya@moodle.com>
Mon, 15 Oct 2012 08:52:17 +0000 (16:52 +0800)
lib/outputrenderers.php

index dd03dc8..b263027 100644 (file)
@@ -1638,7 +1638,13 @@ class core_renderer extends renderer_base {
             $ratinghtml .= html_writer::empty_tag('input', $attributes);
 
             if (!$rating->settings->scale->isnumeric) {
-                $ratinghtml .= $this->help_icon_scale($rating->settings->scale->courseid, $rating->settings->scale);
+                // If a global scale, try to find current course ID from the context
+                if (empty($rating->settings->scale->courseid) and $coursecontext = $rating->context->get_course_context(false)) {
+                    $courseid = $coursecontext->instanceid;
+                } else {
+                    $courseid = $rating->settings->scale->courseid;
+                }
+                $ratinghtml .= $this->help_icon_scale($courseid, $rating->settings->scale);
             }
             $ratinghtml .= html_writer::end_tag('span');
             $ratinghtml .= html_writer::end_tag('div');