You are here

function theme_multichoice_answer_node_view in Quiz 6.4

Same name and namespace in other branches
  1. 8.6 question_types/quiz_multichoice/theme/multichoice.theme.inc \theme_multichoice_answer_node_view()
  2. 8.4 question_types/multichoice/multichoice.theme.inc \theme_multichoice_answer_node_view()
  3. 8.5 question_types/quiz_multichoice/theme/multichoice.theme.inc \theme_multichoice_answer_node_view()
  4. 7.6 question_types/multichoice/theme/multichoice.theme.inc \theme_multichoice_answer_node_view()
  5. 7 question_types/multichoice/theme/multichoice.theme.inc \theme_multichoice_answer_node_view()
  6. 7.4 question_types/multichoice/theme/multichoice.theme.inc \theme_multichoice_answer_node_view()
  7. 7.5 question_types/multichoice/theme/multichoice.theme.inc \theme_multichoice_answer_node_view()

Theme the answer part of the node view

Parameters

$alternatives: Array of alternatives. Each alternative is also an array with all the data for each alternative.

$show_correct: True if the user is allowed to view the solution

1 theme call to theme_multichoice_answer_node_view()
MultichoiceQuestion::getNodeView in question_types/multichoice/multichoice.classes.inc
Implementation of getNodeView

File

question_types/multichoice/theme/multichoice.theme.inc, line 43
The theme file for multichoice.

Code

function theme_multichoice_answer_node_view($alternatives, $show_correct) {
  $header = array(
    '',
    '',
  );
  foreach ($alternatives as $i => $short) {
    $answer_markup = check_markup($short['answer'], $short['answer_format'], FALSE);

    // Find the is_correct status
    $is_correct = $short['score_if_chosen'] > $short['score_if_not_chosen'];
    $p = drupal_get_path('module', 'multichoice');
    $image = $is_correct ? 'correct' : 'wrong';
    if (!$show_correct) {
      $image = 'unknown';
    }
    $rows[] = array(
      array(
        'data' => theme('image', "{$p}/theme/images/{$image}.png", t($image), $show_correct ? t('Score if chosen: @sc Score if not chosen: @nc', array(
          '@sc' => $short['score_if_chosen'],
          '@nc' => $short['score_if_not_chosen'],
        )) : t('You are not allowed to view the solution for this question')),
        'width' => 35,
      ),
      $answer_markup,
    );
  }
  return theme('table', $header, $rows);
}