I wanted to display the given answers only for multiple choice questions. Together with feedback, this is enough for my case.

I accomplished this by 1) changing ../quiz/question_types/multichoice/theme/multichoice.theme.inc, function theme_multichoice_response (lin 83 till end) and 2) add some css.

This solution is a little bit dirty because the display of the table cells only is set to none. A better solution is to set the display of the entire row to none. However I don't know a way to realise that in a simple way. As far as I know, my solution works.

Details:

1) Change of the function

/**
* Theme function for the multichoice report
*
* @param $data
* Array of data to be presented in the report
*/
function theme_multichoice_response($variables) {
static $css_added;
if (!$css_added) {
drupal_add_css(drupal_get_path('module', 'multichoice') . '/theme/multichoice.css');
$css_added = TRUE;
}

$rows = array();
foreach ($variables['data'] as &$alternative) {
if ($alternative['is_chosen']) {
//Patch
$choice='chosen';
switch ($alternative['is_correct']) {
case 0:
$icon = '';
break;
case 1:
$icon = '';
break;
case 2:
$icon = '';
break;
}
}
else {
//Patch
$choice='not-chosen';
$icon = $alternative['is_correct'] == 2 ? '' : '';
}
$rowspan = $alternative['feedback'] ? 2 : 1;
$rows[] = array(
array(
'data' => $icon,
'rowspan' => $rowspan,
'class' => 'selector-td multichoice-icon-cell '.$choice,
),
//PATCH
array(
'data' => $alternative['answer'],
'rowspan' => $rowspan,
'class' => $choice,
)
);
if ($rowspan == 2) {
$rows[] = array('

' . t('Feedback') . ':
' . $alternative['feedback'] . '

');
}
}
return theme('table', array('header' => NULL, 'rows' => $rows));
}

2) Change of the css

I have a site specific css file and I added this line:

.page-node-take .not-chosen {
display:none;
}

Comments

djdevin’s picture

Status: Active » Closed (won't fix)

Fixed in 5.x.