From fff85efe4b1d6d8dc6a1f9d3eb2386071d0b39d3 Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Fri, 29 Jun 2012 16:06:25 +0100 Subject: [PATCH] MDL-34054 quiz reports: missing context. quiz_report_should_show_grades needs to know the context, so pass it through. --- mod/quiz/report/attemptsreport_options.php | 2 +- mod/quiz/report/reportlib.php | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/mod/quiz/report/attemptsreport_options.php b/mod/quiz/report/attemptsreport_options.php index cca3d30465d..ffd4287cc18 100644 --- a/mod/quiz/report/attemptsreport_options.php +++ b/mod/quiz/report/attemptsreport_options.php @@ -105,7 +105,7 @@ class mod_quiz_attempts_report_options { $this->cm = $cm; $this->course = $course; - $this->usercanseegrades = quiz_report_should_show_grades($quiz); + $this->usercanseegrades = quiz_report_should_show_grades($quiz, context_module::instance($cm->id)); } /** diff --git a/mod/quiz/report/reportlib.php b/mod/quiz/report/reportlib.php index 9bfa402fad3..d3e4e998d14 100644 --- a/mod/quiz/report/reportlib.php +++ b/mod/quiz/report/reportlib.php @@ -401,9 +401,10 @@ function quiz_no_questions_message($quiz, $cm, $context) { * Should the grades be displayed in this report. That depends on the quiz * display options, and whether the quiz is graded. * @param object $quiz the quiz settings. + * @param context $context the quiz context. * @return bool */ -function quiz_report_should_show_grades($quiz) { +function quiz_report_should_show_grades($quiz, context $context) { if ($quiz->timeclose && time() > $quiz->timeclose) { $when = mod_quiz_display_options::AFTER_CLOSE; } else { @@ -413,5 +414,5 @@ function quiz_report_should_show_grades($quiz) { return quiz_has_grades($quiz) && ($reviewoptions->marks >= question_display_options::MARK_AND_MAX || - has_capability('moodle/grade:viewhidden', $this->context)); + has_capability('moodle/grade:viewhidden', $context)); }