function theme_multichoice_response in Quiz 8.4
Same name and namespace in other branches
- 6.4 question_types/multichoice/theme/multichoice.theme.inc \theme_multichoice_response()
- 7 question_types/multichoice/theme/multichoice.theme.inc \theme_multichoice_response()
- 7.4 question_types/multichoice/theme/multichoice.theme.inc \theme_multichoice_response()
Theme function for the multichoice report
Parameters
$data: Array of data to be presented in the report
1 theme call to theme_multichoice_response()
- MultichoiceResponse::getReportFormResponse in question_types/
multichoice/ lib/ Drupal/ multichoice/ MultichoiceResponse.php - Implementation of getReportFormResponse
File
- question_types/
multichoice/ multichoice.theme.inc, line 98 - The theme file for multichoice.
Code
function theme_multichoice_response($variables) {
static $css_added;
if (!$css_added) {
drupal_add_css(drupal_get_path('module', 'multichoice') . '/css/multichoice.css');
$css_added = TRUE;
}
$rows = array();
foreach ($variables['data'] as &$alternative) {
if ($alternative['is_chosen']) {
switch ($alternative['is_correct']) {
case 0:
$icon = '<span class="multichoice-icon wrong" title="' . t('This option is wrong.') . '"></span>';
break;
case 1:
$icon = '<span class="multichoice-icon almost" title="' . t('This option is correct, but there is another that gives a higher score.') . '"></span>';
break;
case 2:
$icon = '<span class="multichoice-icon correct" title="' . t('This option is correct.') . '"></span>';
break;
}
}
else {
$icon = $alternative['is_correct'] == 2 ? '<span class="multichoice-icon should" title="' . t("This option is correct, but you didn't select it.") . '"></span>' : '';
}
$rowspan = $alternative['feedback'] ? 2 : 1;
$rows[] = array(
array(
'data' => $icon,
'rowspan' => $rowspan,
'class' => 'selector-td multichoice-icon-cell',
),
$alternative['answer'],
);
if ($rowspan == 2) {
$rows[] = array(
'<div class="multichoice-label">' . t('Feedback') . ':</div><div class="multichoice-feedback">' . $alternative['feedback'] . '</div>',
);
}
}
return theme('table', array(
'header' => NULL,
'rows' => $rows,
));
}