Permalink
Browse files

MDL-36916 quiz/questions: simplify code after MDL-36638.

  • Loading branch information...
1 parent e4d7ec6 commit 6e4a2acf93064f333707c819bd147b23d04b17a5 @timhunt timhunt committed Nov 29, 2012
Showing with 5 additions and 21 deletions.
  1. +2 −10 mod/quiz/report/attemptsreport_table.php
  2. +3 −11 question/type/rendererbase.php
@@ -272,16 +272,8 @@ public function make_review_link($data, $attempt, $slot) {
protected function icon_for_fraction($fraction) {
global $OUTPUT;
- $state = question_state::graded_state_for_fraction($fraction);
- if ($state == question_state::$gradedright) {
- $icon = 'i/grade_correct';
- } else if ($state == question_state::$gradedpartial) {
- $icon = 'i/grade_partiallycorrect';
- } else {
- $icon = 'i/grade_incorrect';
- }
-
- return $OUTPUT->pix_icon($icon, get_string($state->get_feedback_class(), 'question'),
+ $feedbackclass = question_state::graded_state_for_fraction($fraction)->get_feedback_class();
+ return $OUTPUT->pix_icon('i/grade_' . $feedbackclass, get_string($feedbackclass, 'question'),
'moodle', array('class' => 'icon'));
}
@@ -226,19 +226,11 @@ protected function feedback_class($fraction) {
* @return string html fragment.
*/
protected function feedback_image($fraction, $selected = true) {
- $state = question_state::graded_state_for_fraction($fraction);
-
- if ($state == question_state::$gradedright) {
- $icon = 'grade_correct';
- } else if ($state == question_state::$gradedpartial) {
- $icon = 'grade_partiallycorrect';
- } else {
- $icon = 'grade_incorrect';
- }
+ $feedbackclass = question_state::graded_state_for_fraction($fraction)->get_feedback_class();
$attributes = array(
- 'src' => $this->output->pix_url('i/' . $icon),
- 'alt' => get_string($state->get_feedback_class(), 'question'),
+ 'src' => $this->output->pix_url('i/grade_' . $feedbackclass),
+ 'alt' => get_string($feedbackclass, 'question'),
'class' => 'questioncorrectnessicon',
);

0 comments on commit 6e4a2ac

Please sign in to comment.