public function ClozeResponse::getReportForm in Cloze 7
Implementation of getReportForm()
See also
QuizQuestionResponse#getReportForm($showpoints, $showfeedback, $allow_scoring)
File
- ./
cloze.classes.inc, line 355 - The main classes for the cloze question type. These inherit or implement code found in quiz_question.classes.inc.
Class
- ClozeResponse
- Extension of QuizQuestionResponse
Code
public function getReportForm($showpoints = TRUE, $showfeedback = TRUE, $allow_scoring = FALSE) {
$form = parent::getReportForm($showpoints, $showfeedback, $allow_scoring);
$question = strip_tags($form['question']['#markup']);
$question_form['open_wrapper'] = array(
'#markup' => '<div class="cloze-question">',
);
foreach (_cloze_get_question_chunks($question) as $position => $chunk) {
if (strpos($chunk, '[') === FALSE) {
// this "tries[foobar]" hack is needed becaues response handler engine checks for input field
// with name tries
$question_form['tries[' . $position . ']'] = array(
'#markup' => str_replace("\n", "<br/>", $chunk),
'#prefix' => '<div class="form-item">',
'#suffix' => '</div>',
);
}
else {
$chunk = str_replace(array(
'[',
']',
), '', $chunk);
$choices = explode(',', $chunk);
if (count($choices) > 1) {
$question_form['tries[' . $position . ']'] = array(
'#type' => 'select',
'#title' => '',
'#options' => _cloze_shuffle_choices(drupal_map_assoc($choices)),
'#required' => FALSE,
);
}
else {
$question_form['tries[' . $position . ']'] = array(
'#type' => 'textfield',
'#title' => '',
'#size' => 32,
'#required' => FALSE,
'#attributes' => array(
'autocomplete' => 'off',
),
);
}
}
}
$question_form['close_wrapper'] = array(
'#markup' => '</div>',
);
$form['question']['#markup'] = drupal_render($question_form);
return $form;
}