diff --git a/grade/report/grader/lib.php b/grade/report/grader/lib.php index aba460fb9e0f8..5156001d6ee41 100644 --- a/grade/report/grader/lib.php +++ b/grade/report/grader/lib.php @@ -589,9 +589,16 @@ public function get_left_rows($displayaverages) { $rows = array(); $showuserimage = $this->get_pref('showuserimage'); - $canseeuserreport = has_capability('gradereport/'.$CFG->grade_profilereport.':view', $this->context); - $canseesingleview = has_all_capabilities(array('gradereport/singleview:view', 'moodle/grade:viewall', + // FIXME: MDL-52678 This get_capability_info is hacky and we should have an API for inserting grade row links instead. + $canseeuserreport = false; + $canseesingleview = false; + if (get_capability_info('gradereport/'.$CFG->grade_profilereport.':view')) { + $canseeuserreport = has_capability('gradereport/'.$CFG->grade_profilereport.':view', $this->context); + } + if (get_capability_info('gradereport/singleview:view')) { + $canseesingleview = has_all_capabilities(array('gradereport/singleview:view', 'moodle/grade:viewall', 'moodle/grade:edit'), $this->context); + } $hasuserreportcell = $canseeuserreport || $canseesingleview; $strfeedback = $this->get_lang_string("feedback"); @@ -838,17 +845,21 @@ public function get_right_rows($displayaverages) { } $singleview = ''; - if (has_all_capabilities(array('gradereport/singleview:view', 'moodle/grade:viewall', - 'moodle/grade:edit'), $this->context)) { - - $url = new moodle_url('/grade/report/singleview/index.php', array( - 'id' => $this->course->id, - 'item' => 'grade', - 'itemid' => $element['object']->id)); - $singleview = $OUTPUT->action_icon( - $url, - new pix_icon('t/editstring', get_string('singleview', 'grades', $element['object']->get_name())) - ); + + // FIXME: MDL-52678 This is extremely hacky we should have an API for inserting grade column links. + if (get_capability_info('gradereport/singleview:view')) { + if (has_all_capabilities(array('gradereport/singleview:view', 'moodle/grade:viewall', + 'moodle/grade:edit'), $this->context)) { + + $url = new moodle_url('/grade/report/singleview/index.php', array( + 'id' => $this->course->id, + 'item' => 'grade', + 'itemid' => $element['object']->id)); + $singleview = $OUTPUT->action_icon( + $url, + new pix_icon('t/editstring', get_string('singleview', 'grades', $element['object']->get_name())) + ); + } } $itemcell->colspan = $colspan;