type = UNIQUE_ANSWER; $this->isContent = $this->getIsContent(); } /** * @inheritdoc */ public function createAnswersForm($form) { // Getting the exercise list $obj_ex = Session::read('objExercise'); $editor_config = [ 'ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '125' ]; //this line defines how many questions by default appear when creating a choice question // The previous default value was 2. See task #1759. $nb_answers = isset($_POST['nb_answers']) ? (int) $_POST['nb_answers'] : 4; $nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0)); /* Types of Feedback $feedback_option[0]=get_lang('Feedback'); $feedback_option[1]=get_lang('DirectFeedback'); $feedback_option[2]=get_lang('NoFeedback'); */ $feedback_title = ''; if ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { //Scenario $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"'
);
$form->addHtmlEditor('answer['.$i.']', null, null, false, $editor_config);
$form->addRule(
'answer['.$i.']',
get_lang('ThisFieldIsRequired'),
'required'
);
if ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
$form->addHtmlEditor(
'comment['.$i.']',
null,
null,
false,
$editor_config
);
// Direct feedback
//Adding extra feedback fields
$group = [];
$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').': ',
[
'class' => 'col-md-2',
'placeholder' => get_lang('Other')
]
);
$form->addGroup($group, 'scenario');
$renderer->setElementTemplate(
'{error} {element}', 'scenario' ); } else { $form->addHtmlEditor('comment['.$i.']', null, null, false, $editor_config); } $form->addText('weighting['.$i.']', null, null, ['value' => '0']); $form->addHtml(' |
'.get_lang("Choice").' | '.get_lang("ExpectedChoice").' | '.get_lang("Answer").' | '; $header .= ''.get_lang("Comment").' | '; $header .= '
---|