type = UNIQUE_ANSWER_IMAGE; $this->isContent = $this->getIsContent(); } /** * function which redifines Question::createAnswersForm * @param FormValidator instance */ public function createAnswersForm($form) { // Getting the exercise list $obj_ex = $this->exercise; $editor_config = array('ToolbarSet' => 'UniqueAnswerImage', 'Width' => '100%', 'Height' => '125'); //this line define how many question by default appear when creating a choice question $nb_answers = isset($_POST['nb_answers']) ? (int)$_POST['nb_answers'] : 4; // The previous default value was 2. See task #1759. $nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0)); $feedback_title = ''; $comment_title = ''; if ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_END) { $comment_title = '
'.get_lang('Number').' | '.get_lang('True').' | '.get_lang('Answer').' | '.$comment_title.' '.$feedback_title.''.get_lang('Weighting').' | ||
---|---|---|---|---|---|
{error} {element} | ',
'correct'
);
$renderer->setElementTemplate(
'{error} {element} | ',
'counter['.$i.']'
);
$renderer->setElementTemplate(
'{error} {element} | ',
'answer['.$i.']'
);
$renderer->setElementTemplate(
'{error} {element} | ',
'comment['.$i.']'
);
$renderer->setElementTemplate(
'{error} {element} | ',
'weighting['.$i.']'
);
$answer_number = $form->addElement('text', 'counter['.$i.']', null, ' value = "'.$i.'"');
$answer_number->freeze();
$form->addElement('radio', 'correct', null, null, $i, 'class="checkbox" style="margin-left: 0em;"');
$form->addElement('html_editor', 'answer['.$i.']', null, 'style="vertical-align:middle"', $editor_config);
/*
if ($obj_ex->fastEdition) {
$form->addElement('textarea', 'answer['.$i.']', null, $this->textareaSettings);
} else {
$form->addElement('html_editor', 'answer['.$i.']', null, 'style="vertical-align:middle"', $editor_config);
}*/
$form->addRule('answer['.$i.']', get_lang('ThisFieldIsRequired'), 'required');
if ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_END) {
if ($obj_ex->fastEdition) {
// feedback
$form->addElement(
'textarea',
'comment['.$i.']',
null,
$this->textareaSettings
);
} else {
// feedback
$form->addElement(
'html_editor',
'comment['.$i.']',
null,
'style="vertical-align:middle"',
$editor_config
);
}
} elseif ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
$form->addElement(
'html_editor',
'comment['.$i.']',
null,
'style="vertical-align:middle"',
$editor_config
);
// Direct feedback
//Adding extra feedback fields
$group = array();
$group['try'.$i] = $form->createElement('checkbox', 'try'.$i, null, get_lang('TryAgain'));
$group['lp'.$i] = $form->createElement(
'select',
'lp'.$i,
get_lang('SeeTheory').': ',
$select_lp_id
);
$group['destination'.$i] = $form->createElement(
'select',
'destination'.$i,
get_lang('GoToQuestion').': ',
$select_question
);
$group['url'.$i] = $form->createElement(
'text',
'url'.$i,
get_lang('Other').': ',
array('class' => 'span2', 'placeholder' => get_lang('Other'))
);
$form->addGroup($group, 'scenario');
$renderer->setElementTemplate(
'{error} {element}', 'scenario' ); } $form->addElement('text', 'weighting['.$i.']', null, array('class' => "span1", 'value' => '0')); $form->addElement('html', ' |