|
|
|
@ -129,26 +129,20 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question |
|
|
|
|
|
|
|
|
|
|
|
if (is_object($answer)) { |
|
|
|
if (is_object($answer)) { |
|
|
|
$defaults['answer['.$i.']'] = isset($answer->answer[$i]) ? $answer->answer[$i] : ''; |
|
|
|
$defaults['answer['.$i.']'] = isset($answer->answer[$i]) ? $answer->answer[$i] : ''; |
|
|
|
if (isset($_POST['answer']) && isset($_POST['answer'][$i])) { |
|
|
|
|
|
|
|
$defaults['answer['.$i.']'] = Security::remove_XSS($_POST['answer'][$i]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$defaults['comment['.$i.']'] = isset($answer->comment[$i]) ? $answer->comment[$i] : ''; |
|
|
|
$defaults['comment['.$i.']'] = isset($answer->comment[$i]) ? $answer->comment[$i] : ''; |
|
|
|
if (isset($_POST['comment']) && isset($_POST['comment'][$i])) { |
|
|
|
|
|
|
|
$defaults['comment['.$i.']'] = Security::remove_XSS($_POST['comment'][$i]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$defaults['weighting['.$i.']'] = isset($answer->weighting[$i]) ? float_format($answer->weighting[$i], 1) : ''; |
|
|
|
$defaults['weighting['.$i.']'] = isset($answer->weighting[$i]) ? float_format($answer->weighting[$i], 1) : ''; |
|
|
|
$correct = isset($answer->correct[$i]) ? $answer->correct[$i] : ''; |
|
|
|
$correct = isset($answer->correct[$i]) ? $answer->correct[$i] : ''; |
|
|
|
$defaults['correct['.$i.']'] = $correct; |
|
|
|
$defaults['correct['.$i.']'] = $correct; |
|
|
|
if (isset($_POST['correct']) && isset($_POST['correct'][$i])) { |
|
|
|
|
|
|
|
$defaults['correct['.$i.']'] = Security::remove_XSS($_POST['correct'][$i]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$j = 1; |
|
|
|
$j = 1; |
|
|
|
if (!empty($optionData)) { |
|
|
|
if (!empty($optionData)) { |
|
|
|
foreach ($optionData as $id => $data) { |
|
|
|
foreach ($optionData as $id => $data) { |
|
|
|
$form->addElement('radio', 'correct['.$i.']', null, null, $id); |
|
|
|
$rdoCorrect = $form->addElement('radio', 'correct['.$i.']', null, null, $id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($_POST['correct']) && isset($_POST['correct'][$i]) && $id == $_POST['correct'][$i]) { |
|
|
|
|
|
|
|
$rdoCorrect->setValue(Security::remove_XSS($_POST['correct'][$i])); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$j++; |
|
|
|
$j++; |
|
|
|
if ($j == 3) { |
|
|
|
if ($j == 3) { |
|
|
|
break; |
|
|
|
break; |
|
|
|
@ -161,7 +155,7 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$boxesNames[] = 'correct['.$i.']'; |
|
|
|
$boxesNames[] = 'correct['.$i.']'; |
|
|
|
$form->addElement( |
|
|
|
$txtAnswer = $form->addElement( |
|
|
|
'html_editor', |
|
|
|
'html_editor', |
|
|
|
'answer['.$i.']', |
|
|
|
'answer['.$i.']', |
|
|
|
null, |
|
|
|
null, |
|
|
|
@ -170,15 +164,23 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question |
|
|
|
); |
|
|
|
); |
|
|
|
$form->addRule('answer['.$i.']', get_lang('ThisFieldIsRequired'), 'required'); |
|
|
|
$form->addRule('answer['.$i.']', get_lang('ThisFieldIsRequired'), 'required'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($_POST['answer']) && isset($_POST['answer'][$i])) { |
|
|
|
|
|
|
|
$txtAnswer->setValue(Security::remove_XSS($_POST['answer'][$i])); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// show comment when feedback is enable |
|
|
|
// show comment when feedback is enable |
|
|
|
if ($objEx->getFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) { |
|
|
|
if ($objEx->getFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) { |
|
|
|
$form->addElement( |
|
|
|
$txtComment = $form->addElement( |
|
|
|
'html_editor', |
|
|
|
'html_editor', |
|
|
|
'comment['.$i.']', |
|
|
|
'comment['.$i.']', |
|
|
|
null, |
|
|
|
null, |
|
|
|
['style' => 'vertical-align:middle;'], |
|
|
|
['style' => 'vertical-align:middle;'], |
|
|
|
['ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100'] |
|
|
|
['ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100'] |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($_POST['comment']) && isset($_POST['comment'][$i])) { |
|
|
|
|
|
|
|
$txtComment->setValue(Security::remove_XSS($_POST['comment'][$i])); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
$form->addElement('html', '</tr>'); |
|
|
|
$form->addElement('html', '</tr>'); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -187,8 +189,8 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question |
|
|
|
$form->addElement('html', '<br />'); |
|
|
|
$form->addElement('html', '<br />'); |
|
|
|
|
|
|
|
|
|
|
|
// 3 scores |
|
|
|
// 3 scores |
|
|
|
$form->addElement('text', 'option[1]', get_lang('Correct'), ['class' => 'span1', 'value' => '1']); |
|
|
|
$txtOption1 = $form->addElement('text', 'option[1]', get_lang('Correct'), ['value' => '1']); |
|
|
|
$form->addElement('text', 'option[2]', get_lang('Wrong'), ['class' => 'span1', 'value' => '-0.5']); |
|
|
|
$txtOption2 = $form->addElement('text', 'option[2]', get_lang('Wrong'), ['value' => '-0.5']); |
|
|
|
|
|
|
|
|
|
|
|
$form->addElement('hidden', 'option[3]', 0); |
|
|
|
$form->addElement('hidden', 'option[3]', 0); |
|
|
|
|
|
|
|
|
|
|
|
@ -203,9 +205,8 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question |
|
|
|
if (!empty($this->extra)) { |
|
|
|
if (!empty($this->extra)) { |
|
|
|
$scores = explode(':', $this->extra); |
|
|
|
$scores = explode(':', $this->extra); |
|
|
|
if (!empty($scores)) { |
|
|
|
if (!empty($scores)) { |
|
|
|
for ($i = 1; $i <= 3; $i++) { |
|
|
|
$txtOption1->setValue($scores[0]); |
|
|
|
$defaults['option['.$i.']'] = $scores[$i - 1]; |
|
|
|
$txtOption2->setValue($scores[1]); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -220,13 +221,11 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question |
|
|
|
$renderer->setElementTemplate('{element} ', 'submitQuestion'); |
|
|
|
$renderer->setElementTemplate('{element} ', 'submitQuestion'); |
|
|
|
$renderer->setElementTemplate('{element} ', 'moreAnswers'); |
|
|
|
$renderer->setElementTemplate('{element} ', 'moreAnswers'); |
|
|
|
$form->addElement('html', '</div></div>'); |
|
|
|
$form->addElement('html', '</div></div>'); |
|
|
|
$defaults['correct'] = $correct; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!empty($this->id)) { |
|
|
|
if (!empty($this->id) && !$form->isSubmitted()) { |
|
|
|
$form->setDefaults($defaults); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$form->setDefaults($defaults); |
|
|
|
$form->setDefaults($defaults); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$form->setConstants(['nb_answers' => $nbAnswers]); |
|
|
|
$form->setConstants(['nb_answers' => $nbAnswers]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|