From 8968f51fabc781eaf6e0073199bc1f43dbee7cf0 Mon Sep 17 00:00:00 2001 From: jamiesensei Date: Wed, 24 Sep 2008 10:43:45 +0000 Subject: [PATCH] MDL-16610 "Warnings when a question has a grade of 0" not seeing this issue in HEAD but committing some code to make code for generating html for response cell more robust. --- mod/quiz/report/responses/responses_table.php | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/mod/quiz/report/responses/responses_table.php b/mod/quiz/report/responses/responses_table.php index db7d1f3cb22..9c0bac15a1f 100644 --- a/mod/quiz/report/responses/responses_table.php +++ b/mod/quiz/report/responses/responses_table.php @@ -152,20 +152,18 @@ class quiz_report_responses_table extends table_sql { $question = $this->questions[$questionid]; restore_question_state($question, $stateforqinattempt); - $responses = get_question_actual_response($question, $stateforqinattempt); - $response = (!empty($responses)? implode('; ',$responses) : '-'); - $grade = $stateforqinattempt->grade - / $this->questions[$questionid]->maxgrade; + if ($responses = get_question_actual_response($question, $stateforqinattempt)){ + $response = (!empty($responses)? implode('; ',$responses) : '-'); + } else { + $response = ''; + } if (!$this->is_downloading()) { - $format_options = new stdClass; - $format_options->para = false; - $format_options->noclean = true; - $format_options->newlines = false; - $qclass = question_get_feedback_class($grade); - $feedbackimg = question_get_feedback_image($grade); - $questionclass = "que"; - $response = format_text($response, FORMAT_MOODLE, $format_options); if ($response){ + $format_options = new stdClass; + $format_options->para = false; + $format_options->noclean = true; + $format_options->newlines = false; + $response = format_text($response, FORMAT_MOODLE, $format_options); if (strlen($response) > QUIZ_REPORT_RESPONSES_MAX_LEN_TO_DISPLAY){ $response = shorten_text($response, QUIZ_REPORT_RESPONSES_MAX_LEN_TO_DISPLAY); } @@ -173,7 +171,13 @@ class quiz_report_responses_table extends table_sql { $attempt->attempt . '&question=' . $question->id, 'reviewquestion', $response, 450, 650, get_string('reviewresponse', 'quiz'), 'none', true); - if (question_state_is_graded($stateforqinattempt)){ + if (question_state_is_graded($stateforqinattempt) + && ($this->questions[$questionid]->maxgrade != 0)){ + $grade = $stateforqinattempt->grade + / $this->questions[$questionid]->maxgrade; + $qclass = question_get_feedback_class($grade); + $feedbackimg = question_get_feedback_image($grade); + $questionclass = "que"; return "".$response."$feedbackimg"; } else { return $response;