type = FILL_IN_BLANKS;
$this->isContent = $this->getIsContent();
}
/**
* function which redifines Question::createAnswersForm
* @param \FormValidator instance
*/
public function createAnswersForm($form)
{
$defaults = array();
$a_weightings = null;
if (!empty($this->id)) {
$objAnswer = new Answer($this->id);
// the question is encoded like this.
// [A] B [C] D [E] F::10,10,10@1
// number 1 before the "@" means that is a switchable fill in blank question
// [A] B [C] D [E] F::10,10,10@ or [A] B [C] D [E] F::10,10,10
// means that is a normal fill blank question
$answer_id = $objAnswer->getRealAnswerIdFromList(1);
$pre_array = explode('::', $objAnswer->selectAnswer($answer_id));
//make sure we only take the last bit to find special marks
$sz = count($pre_array);
$is_set_switchable = explode('@', $pre_array[$sz - 1]);
if ($is_set_switchable[1]) {
$defaults['multiple_answer'] = 1;
} else {
$defaults['multiple_answer'] = 0;
}
//take the complete string except after the last '::'
$defaults['answer'] = '';
for ($i = 0; $i < ($sz - 1); $i++) {
$defaults['answer'] .= $pre_array[$i];
}
$a_weightings = explode(',', $is_set_switchable[0]);
} else {
$defaults['answer'] = get_lang('DefaultTextInBlanks');
}
// javascript
echo '';
// answer
$form->addElement(
'label',
null,
'
'.get_lang('TypeTextBelow').', '.get_lang('And').' '.get_lang('UseTagForBlank')
);
$form->addElement('html_editor','answer', Display::return_icon('fill_field.png'), 'id="answer" cols="122" rows="6" onkeyup="javascript: updateBlanks(this);"', array('ToolbarSet' => 'TestQuestionDescription', 'Width' => '100%', 'Height' => '350'));
$form->addRule('answer', get_lang('GiveText'), 'required');
$form->addRule('answer', get_lang('DefineBlanks'), 'regex', '/\[.*\]/');
//added multiple answers
$form->addElement('checkbox', 'multiple_answer', '', get_lang('FillInBlankSwitchable'));
$form->addElement('html', '
'.get_lang("Answer").' |
---|