type = MULTIPLE_ANSWER_TRUE_FALSE; $this->isContent = $this-> getIsContent(); $this->options = array(1 => 'True', 2 => 'False', 3 => 'DoubtScore'); } /** * function which redefines Question::createAnswersForm * @param FormValidator $form */ 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 = Session::read('objExercise'); $renderer = & $form->defaultRenderer(); $defaults = array(); $html = '
' . get_lang('Number') . ' | '; $html .= '' . get_lang('True') . ' | '; $html .= '' . get_lang('False') . ' | '; $html .= '' . 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 (is_object($answer)) {
$defaults['answer[' . $i . ']'] = $answer->answer[$i];
$defaults['comment[' . $i . ']'] = $answer->comment[$i];
$correct = $answer->correct[$i];
$defaults['correct[' . $i . ']'] = $correct;
$j = 1;
if (!empty($optionData)) {
foreach ($optionData 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 . ']';
$form->addHtmlEditor(
"answer[$i]",
get_lang('ThisFieldIsRequired'),
true,
true,
['ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100']
);
// show comment when feedback is enable
if ($obj_ex->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
$form->addHtmlEditor(
'comment[' . $i . ']',
null,
array(),
array(
'ToolbarSet' => 'TestProposedAnswer',
'Width' => '100%',
'Height' => '100',
)
);
}
$form->addHtml('
'; $correctInputTemplate .= get_lang('Correct') . '{element}'; $correctInputTemplate .= '{error}'; $correctInputTemplate .= ' | '; $wrongInputTemplate = ''; $wrongInputTemplate .= get_lang('Wrong') . '{element}'; $wrongInputTemplate .= '{error}'; $wrongInputTemplate .= ' | '; $doubtScoreInputTemplate = '' . get_lang('DoubtScore') . ' {element}'; $doubtScoreInputTemplate .= '{error}'; $doubtScoreInputTemplate .= ' | ';
$doubtScoreInputTemplate .= '
'.get_lang("Choice").' | '. get_lang("ExpectedChoice").' | '. get_lang("Answer").' | '; if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { $header .= ''.get_lang("Comment").' | '; } else { $header .= ''; } $header .= ' |
---|