You are here

function theme_quiz_answer_result in Quiz 7.5

Same name and namespace in other branches
  1. 7.6 quiz.pages.inc \theme_quiz_answer_result()

Pass the correct mark to the theme so that theme authors can use an image.

2 theme calls to theme_quiz_answer_result()
MatchingResponse::getFeedbackValues in question_types/matching/matching.classes.inc
Implementation of getFeedbackValues().
quiz_icon in question_types/quiz_question/quiz_question.module
Helper function to facilitate icon display, like "correct" or "selected".

File

./quiz.theme.inc, line 13
quiz.theme.inc Quiz theme functions.

Code

function theme_quiz_answer_result($variables) {
  $options = array();
  $type = $variables['type'];
  switch ($type) {
    case 'correct':
      $options['path'] = 'check_008000_64.png';
      $options['alt'] = t('Correct');
      break;
    case 'incorrect':
      $options['path'] = 'times_ff0000_64.png';
      $options['alt'] = t('Incorrect');
      break;
    case 'unknown':
      $options['path'] = 'question_808080_64.png';
      $options['alt'] = t('Unknown');
      break;
    case 'should':
      $options['path'] = 'check_808080_64.png';
      $options['alt'] = t('Should have chosen');
      break;
    case 'should-not':
      $options['path'] = 'times_808080_64.png';
      $options['alt'] = t('Should not have chosen');
      break;
    case 'almost':
      $options['path'] = 'check_ffff00_64.png';
      $options['alt'] = t('Almost');
      break;
    case 'selected':
      $options['path'] = 'arrow-right_808080_64.png';
      $options['alt'] = t('Selected');
      break;
    case 'unselected':
      $options['path'] = 'circle-o_808080_64.png';
      $options['alt'] = t('Unselected');
      break;
    default:
      $options['path'] = '';
      $options['alt'] = '';
  }
  if (!empty($options['path'])) {
    $options['path'] = drupal_get_path('module', 'quiz') . '/images/' . $options['path'];
  }
  if (!empty($options['alt'])) {
    $options['title'] = $options['alt'];
  }
  $image = theme('image', $options);
  return '<div class="quiz-score-icon ' . $type . '">' . $image . '</div>';
}