choice-alternative.tpl.php in Quiz 6.6
Handles the layout of the choice creation form.
Variables available:
- $form
1 theme call to choice-alternative.tpl.php
- ChoiceQuestion::getQuestionForm in question_types/
choice/ choice.classes.inc - Generates the question form.
File
question_types/choice/theme/choice-alternative.tpl.phpView source
<?php
/**
* @file
* Handles the layout of the choice creation form.
*
*
* Variables available:
* - $form
*/
$p = drupal_get_path('module', 'choice');
drupal_add_css($p . '/theme/choice.css', 'module', 'all');
if ($form['#taking_quiz']) {
print "\n<script type=text/javascript>Drupal.behaviors.choiceAlternativeBehavior = function(context) {\n \$('.choice_row')\n .filter(':has(:checkbox:checked)')\n .addClass('selected')\n .end()\n .click(function(event) {\n \$(this).toggleClass('selected');\n if (event.target.type !== 'checkbox') {\n \$(':checkbox', this).attr('checked', function() {\n return !this.checked;\n });\n \$(':radio', this).attr('checked', true);\n if (\$(':radio', this).html() != null) {\n \$('.choice_row').removeClass('selected');\n \t \$(this).addClass('selected');\n }\n }\n });\n};</SCRIPT>";
//drupal_add_js can't be used with ajax quiz :/
//drupal_add_js($p .'/theme/choice-alternative.js', 'module');
}
$options = $form['#options'];
$fullOptions = array();
$titles = array();
foreach ($options as $key => $value) {
$fullOptions[$key] = $form[$key];
$titles[$key] = $form[$key]['#title'];
$fullOptions[$key]['#title'] = '';
unset($form[$key]);
}
unset($form['#options']);
print drupal_render($form);
foreach ($titles as $key => $value) {
$row = array();
if ($form['#taking_quiz']) {
$row[] = array(
'data' => drupal_render($fullOptions[$key]),
'width' => 35,
);
}
else {
if ($form['#correct_choice'][$key]) {
$row[] = array(
'data' => theme('image', "{$p}./theme/images/correct.png", t('Correct'), t('This alternative is correct')),
'width' => 35,
);
}
else {
$row[] = array(
'data' => theme('image', "{$p}./theme/images/wrong.png", t('Wrong'), t('This alternative is wrong')),
'width' => 35,
);
}
}
$row[] = $value;
$rows[] = array(
'data' => $row,
'class' => 'choice_row',
);
}
print theme('table', NULL, $rows);