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 redifines Question::createAnswersForm * @param the formvalidator instance * @param the answers number to display */ 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['objExercise']; $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 (is_object($answer)) {
$defaults['answer['.$i.']'] = $answer -> answer[$i];
$defaults['comment['.$i.']'] = $answer -> comment[$i];
//$defaults['weighting['.$i.']'] = float_format($answer -> weighting[$i], 1);
$correct = $answer->correct[$i];
$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.']'] = '';
}
//$form->addElement('select', 'correct['.$i.']',null, $this->options, array('id'=>$i,'onchange'=>'multiple_answer_true_false_onchange(this)'));
$boxes_names[] = 'correct['.$i.']';
$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) {
$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 .= ' |
---|