function theme_multichoice_response in Quiz 7
Same name and namespace in other branches
- 8.4 question_types/multichoice/multichoice.theme.inc \theme_multichoice_response()
- 6.4 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/ multichoice.classes.inc - Implementation of getReportFormResponse
File
- question_types/
multichoice/ theme/ multichoice.theme.inc, line 89 - The theme file for multichoice.
Code
function theme_multichoice_response($variables) {
$data = $variables['data'];
$rows = array();
$p = drupal_get_path('module', 'multichoice') . '/theme/images';
foreach ($data as $id => $alternative) {
$cols = array();
$rowspan = drupal_strlen($alternative['feedback']) > 0 ? 2 : 1;
$not = '';
if ($alternative['is_chosen']) {
switch ($alternative['is_correct']) {
case 0:
$cols[] = array(
'data' => theme('image', array(
'path' => "{$p}/wrong.png",
'alt' => t('Wrong'),
'title' => t('This answer is wrong'),
'attributes' => array(
'class' => 'feedback-icon',
),
)),
'width' => 35,
'rowspan' => $rowspan,
'class' => 'selector-td',
);
break;
case 1:
$cols[] = array(
'data' => theme('image', array(
'path' => "{$p}/almost.png",
'alt' => t('Almost correct'),
'title' => t('This answer is correct, but there is an answer that gives a higher score'),
'attributes' => array(
'class' => 'feedback-icon',
),
)),
'width' => 35,
'rowspan' => $rowspan,
'class' => 'selector-td',
);
break;
case 2:
$cols[] = array(
'data' => theme('image', array(
'path' => "{$p}/correct.png",
'alt' => t('Correct'),
'title' => t('This answer is correct'),
'attributes' => array(
'class' => 'feedback-icon',
),
)),
'width' => 35,
'rowspan' => $rowspan,
'class' => 'selector-td',
);
break;
}
}
else {
if ($alternative['is_correct'] == 2) {
$cols[] = array(
'data' => theme('image', array(
'path' => "{$p}/should.png",
'alt' => t('Should have chosen'),
'title' => t("This answer is correct, but you didn't choose it"),
'attributes' => array(
'class' => 'feedback-icon',
),
)),
'width' => 35,
'rowspan' => $rowspan,
'class' => 'selector-td',
);
}
else {
$cols[] = array(
'data' => '',
'width' => 35,
'rowspan' => $rowspan,
'class' => 'selector-td',
);
}
}
$cols[] = $alternative['answer'];
$rows[] = $cols;
if ($rowspan == 2) {
$rows[] = array(
'<strong>' . t('Feedback:') . '</strong><div class="quiz_answer_feedback">' . $alternative['feedback'] . '</div>',
);
}
}
return theme('table', array(
'header' => NULL,
'rows' => $rows,
));
}