type = MULTIPLE_ANSWER_TRUE_FALSE; $this->isContent = $this->getIsContent(); $this->options = array(1 => get_lang('True'), 2 => get_lang('False'), 3 => get_lang('DoubtScore')); } /** * function which redefines Question::createAnswersForm * @param FormValidator instance * @param the answers number to display */ public function createAnswersForm($form) { $nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 4; // The previous default value was 2. See task #1759. $nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0)); $course_id = api_get_course_int_id(); $obj_ex = $this->exercise; $renderer = & $form->defaultRenderer(); $defaults = array(); $html = '
'.get_lang('Number').' | '.get_lang('True').' | '.get_lang('False').' | '.get_lang('Answer').' | '; // show column comment when feedback is enable if ($obj_ex->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) { $html .= ''.get_lang('Comment').' | '; } $html .= '{error} {element} | ',
'correct['.$i.']'
);
$renderer->setElementTemplate(
'{error} {element} | ',
'counter['.$i.']'
);
$renderer->setElementTemplate(
'{error} {element} | ',
'answer['.$i.']'
);
$renderer->setElementTemplate(
'{error} {element} | ',
'comment['.$i.']'
);
$answer_number = $form->addElement('text', 'counter['.$i.']', null, 'value="'.$i.'"');
$answer_number->freeze();
if (isset($answer) && is_object($answer)) {
$answer_id = $answer->getRealAnswerIdFromList($i);
$defaults['answer['.$i.']'] = $answer->answer[$answer_id];
$defaults['comment['.$i.']'] = $answer->comment[$answer_id];
$correct = $answer->correct[$answer_id];
$defaults['correct['.$i.']'] = $correct;
$j = 1;
if (!empty($option_data)) {
foreach ($option_data as $id => $data) {
$form->addElement('radio', 'correct['.$i.']', null, null, $id);
$j++;
if ($j == 3) {
break;
}
}
}
} else {
$form->addElement('radio', 'correct['.$i.']', null, null, 1);
$form->addElement('radio', 'correct['.$i.']', null, null, 2);
$defaults['answer['.$i.']'] = '';
$defaults['comment['.$i.']'] = '';
$defaults['correct['.$i.']'] = '';
}
$boxes_names[] = 'correct['.$i.']';
if ($obj_ex->fastEdition) {
$form->addElement(
'textarea',
'answer['.$i.']',
null,
$this->textareaSettings
);
} else {
$form->addElement(
'html_editor',
'answer['.$i.']',
null,
'style="vertical-align:middle"',
array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100')
);
}
$form->addRule('answer['.$i.']', get_lang('ThisFieldIsRequired'), 'required');
// show comment when feedback is enable
if ($obj_ex->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
if ($obj_ex->fastEdition) {
$form->addElement(
'textarea',
'comment['.$i.']',
null,
$this->textareaSettings
);
} else {
$form->addElement(
'html_editor',
'comment['.$i.']',
null,
'style="vertical-align:middle"',
array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100')
);
}
}
$form->addElement('html', '');
}
$form->addElement('html', '
---|
'.get_lang('Correct').' | '.get_lang('Wrong').' | '.get_lang( 'DoubtScore' ).' | ||
*'.get_lang( 'Score' ).' | {element} {error} | ',
'option[1]'
);
$renderer->setElementTemplate(
'{element} {error} | ',
'option[2]'
);
$renderer->setElementTemplate(
'{element} {error} | ',
'option[3]'
);
// 3 scores
$form->addElement('text', 'option[1]', get_lang('Correct'), array('class' => 'span1', 'value' => '1'));
$form->addElement('text', 'option[2]', get_lang('Wrong'), array('class' => 'span1', 'value' => '-0.5'));
$form->addElement('text', 'option[3]', get_lang('DoubtScore'), array('class' => 'span1', 'value' => '0'));
$form->addRule('option[1]', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('option[2]', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('option[3]', get_lang('ThisFieldIsRequired'), 'required');
$form->addElement('html', '
'.get_lang("Choice").' | '.get_lang("ExpectedChoice").' | '.get_lang("Answer").' | '; if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { $header .= ''.get_lang("Comment").' | '; } else { $header .= ''; } $header .= ' |
---|