type = MULTIPLE_ANSWER_TRUE_FALSE; $this->isContent = $this->getIsContent(); $this->options = [1 => 'True', 2 => 'False', 3 => 'DoubtScore']; } /** * {@inheritdoc} */ 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 = []; $html = '
'.get_lang('N°').' | '; $html .= ''.get_lang('True').' | '; $html .= ''.get_lang('False').' | '; $html .= ''.get_lang('Answer').' | '; // show column comment when feedback is enable if ($obj_ex->getFeedbackType() != 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.']'] = '';
}
$form->addHtmlEditor(
"answer[$i]",
get_lang('Required field'),
true,
false,
['ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100']
);
// show comment when feedback is enable
if ($obj_ex->getFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
$form->addElement(
'html_editor',
'comment['.$i.']',
null,
[],
[
'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('Don\'t know').' {element}'; $doubtScoreInputTemplate .= '{error}'; $doubtScoreInputTemplate .= ' | ';
$doubtScoreInputTemplate .= '
'.get_lang('Your choice').' | '; if ($exercise->showExpectedChoiceColumn()) { $header .= ''.get_lang('ExpectedYour choice').' | '; } } $header .= ''.get_lang('Answer').' | '; if ($exercise->showExpectedChoice()) { $header .= ''.get_lang('Status').' | '; } if ($exercise->getFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM || in_array( $exercise->results_disabled, [ RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER, RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS_AND_RANKING, ] ) ) { $header .= ''.get_lang('Comment').' | '; } $header .= '
---|