4 require_once
'./Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
5 require_once
'./Modules/TestQuestionPool/interfaces/interface.ilGuiQuestionScoringAdjustable.php';
6 require_once
'./Modules/TestQuestionPool/interfaces/interface.ilGuiAnswerScoringAdjustable.php';
39 parent::__construct();
40 include_once
"./Modules/TestQuestionPool/classes/class.assClozeTest.php";
43 $this->
object->loadFromDb(
$id);
49 if (preg_match(
"/^(removegap|addgap)_(\d+)$/", $cmd, $matches)) {
51 $this->gapIndex = $matches[2];
61 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
63 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
65 $cloze_text = $this->
object->getHtmlQuestionContentPurifier()->purify(
$_POST[
'cloze_text']);
68 $_POST[
'cloze_text'] = $cloze_text;
69 $this->
object->setQuestion(
$_POST[
'question']);
72 $this->
object->setClozeText(
$_POST[
"cloze_text"]);
80 $cloze_text =
$_POST[
'cloze_text'];
82 $_POST[
'cloze_text'] = $cloze_text;
88 if (is_array(
$_POST[
'gap'])) {
89 if ($this->ctrl->getCmd() !=
'createGaps') {
90 $this->
object->clearGapAnswers();
93 foreach (
$_POST[
'gap'] as $idx => $hidden) {
94 $clozetype =
$_POST[
'clozetype_' . $idx];
96 $this->
object->setGapType($idx, $clozetype);
101 $this->
object->setGapShuffle($idx, 0);
103 if ($this->ctrl->getCmd() !=
'createGaps') {
104 if (is_array(
$_POST[
'gap_' . $idx][
'answer'])) {
105 foreach (
$_POST[
'gap_' . $idx][
'answer'] as $order => $value) {
106 $this->
object->addGapAnswer($idx, $order, $value);
109 $this->
object->addGapAnswer($idx, 0,
'');
113 if (is_array(
$_POST[
'gap_' . $idx][
'points'])) {
114 foreach (
$_POST[
'gap_' . $idx][
'points'] as $order => $value) {
115 $this->
object->setGapAnswerPoints($idx, $order, $value);
119 if (array_key_exists(
'gap_' . $idx .
'_gapsize',
$_POST)) {
120 $this->
object->setGapSize($idx, $order,
$_POST[
'gap_' . $idx .
'_gapsize']);
127 $this->
object->setGapShuffle($idx, (
int) (isset(
$_POST[
"shuffle_$idx"]) &&
$_POST[
"shuffle_$idx"]));
129 if ($this->ctrl->getCmd() !=
'createGaps') {
130 if (is_array(
$_POST[
'gap_' . $idx][
'answer'])) {
131 foreach (
$_POST[
'gap_' . $idx][
'answer'] as $order => $value) {
132 $this->
object->addGapAnswer($idx, $order, $value);
135 $this->
object->addGapAnswer($idx, 0,
'');
139 if (is_array(
$_POST[
'gap_' . $idx][
'points'])) {
140 foreach (
$_POST[
'gap_' . $idx][
'points'] as $order => $value) {
141 $this->
object->setGapAnswerPoints($idx, $order, $value);
148 $this->
object->setGapShuffle($idx, 0);
150 $gap = $this->
object->getGap($idx);
155 $this->
object->getGap($idx)->clearItems();
157 if (array_key_exists(
'gap_' . $idx .
'_numeric',
$_POST)) {
158 if ($this->ctrl->getCmd() !=
'createGaps') {
159 $this->
object->addGapAnswer(
162 str_replace(
",",
".",
$_POST[
'gap_' . $idx .
'_numeric'])
166 $this->
object->setGapAnswerLowerBound(
169 str_replace(
",",
".",
$_POST[
'gap_' . $idx .
'_numeric_lower'])
172 $this->
object->setGapAnswerUpperBound(
175 str_replace(
",",
".",
$_POST[
'gap_' . $idx .
'_numeric_upper'])
178 $this->
object->setGapAnswerPoints($idx, 0,
$_POST[
'gap_' . $idx .
'_numeric_points']);
180 if ($this->ctrl->getCmd() !=
'createGaps') {
181 $this->
object->addGapAnswer($idx, 0,
'');
184 $this->
object->setGapAnswerLowerBound($idx, 0,
'');
186 $this->
object->setGapAnswerUpperBound($idx, 0,
'');
189 if (array_key_exists(
'gap_' . $idx .
'_gapsize',
$_POST)) {
190 $this->
object->setGapSize($idx, $order,
$_POST[
'gap_' . $idx .
'_gapsize']);
195 $assClozeGapCombinationObject->clearGapCombinationsFromDb($this->
object->getId());
196 if (is_array(
$_POST[
'gap_combination']) && count(
$_POST[
'gap_combination']) > 0) {
200 if ($this->ctrl->getCmd() !=
'createGaps') {
201 $this->
object->updateClozeTextFromGaps();
208 $this->
object->setClozeText(
$_POST[
'cloze_text']);
209 $this->
object->setTextgapRating(
$_POST[
"textgap_rating"]);
210 $this->
object->setIdenticalScoring(
$_POST[
"identical_scoring"]);
211 $this->
object->setFixedTextLength(
$_POST[
"fixedTextLength"]);
224 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
226 $this->editForm =
$form;
228 $form->setFormAction($this->ctrl->getFormAction($this));
230 $form->setMultipart(
false);
231 $form->setTableWidth(
"100%");
232 $form->setId(
"assclozetest");
245 $form->setValuesByPost();
247 $form->setValuesByPost();
255 $this->tpl->setVariable(
"QUESTION_DATA",
$form->getHTML());
264 $title->setMaxLength(100);
266 $title->setRequired(
true);
269 if (!$this->
object->getSelfAssessmentEditingMode()) {
271 $author =
new ilTextInputGUI($this->lng->txt(
"author"),
"author");
273 $author->setRequired(
true);
274 $form->addItem($author);
285 if (trim($author) ==
"") {
288 $hi->setValue($author);
294 $question->
setValue($this->
object->prepareTextareaOutput($this->object->getQuestion()));
295 $question->setRequired(
true);
296 $question->setRows(10);
297 $question->setCols(80);
298 if (!$this->
object->getSelfAssessmentEditingMode()) {
300 $question->setUseRte(
true);
301 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
303 $question->addPlugin(
"latex");
304 $question->addButton(
"latex");
305 $question->addButton(
"pastelatex");
306 $question->setRTESupport($this->
object->getId(),
"qpl",
"assessment");
309 require_once
'Modules/TestQuestionPool/classes/questions/class.ilAssSelfAssessmentQuestionFormatter.php';
311 $question->setUseTagsForRteOnly(
false);
313 $form->addItem($question);
323 if (!$this->
object->getSelfAssessmentEditingMode()) {
327 $duration->setShowMinutes(
true);
328 $duration->setShowSeconds(
true);
329 $ewt = $this->
object->getEstimatedWorkingTime();
330 $duration->setHours($ewt[
"h"]);
331 $duration->setMinutes($ewt[
"m"]);
332 $duration->setSeconds($ewt[
"s"]);
333 $duration->setRequired(
false);
334 $form->addItem($duration);
337 if (strlen($this->
object->getNrOfTries())) {
338 $nr_tries = $this->
object->getNrOfTries();
340 $nr_tries = $this->
object->getDefaultNrOfTries();
351 $ni =
new ilNumberInputGUI($this->lng->txt(
"qst_nr_of_tries"),
"nr_of_tries");
356 $ni->setMaxLength(5);
357 $ni->setRequired(
true);
368 $cloze_text->setInfo($this->lng->txt(
"close_text_hint"));
369 $cloze_text->setRows(10);
370 $cloze_text->setCols(80);
371 if (!$this->
object->getSelfAssessmentEditingMode()) {
373 $cloze_text->setUseRte(
true);
374 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
376 $cloze_text->addPlugin(
"latex");
377 $cloze_text->addButton(
"latex");
378 $cloze_text->addButton(
"pastelatex");
381 require_once
'Modules/TestQuestionPool/classes/questions/class.ilAssSelfAssessmentQuestionFormatter.php';
383 $cloze_text->setUseTagsForRteOnly(
false);
385 $cloze_text->setRTESupport($this->
object->getId(),
"qpl",
"assessment");
388 $tpl =
new ilTemplate(
"tpl.il_as_qpl_cloze_gap_button_code.html",
true,
true,
"Modules/TestQuestionPool");
391 require_once
'Services/UIComponent/SplitButton/classes/class.ilSplitButtonGUI.php';
392 require_once
'Services/UIComponent/Button/classes/class.ilJsLinkButton.php';
396 $sb_text_gap->setCaption(
'text_gap');
397 $sb_text_gap->setName(
'gapbutton');
398 $sb_text_gap->setId(
'gaptrigger_text');
399 $action_button->setDefaultButton($sb_text_gap);
402 $sb_sel_gap->setCaption(
'select_gap');
403 $sb_sel_gap->setName(
'gapbutton_select');
404 $sb_sel_gap->setId(
'gaptrigger_select');
408 $sb_num_gap->setCaption(
'numeric_gap');
409 $sb_num_gap->setName(
'gapbutton_numeric');
410 $sb_num_gap->setId(
'gaptrigger_numeric');
413 $tpl->setVariable(
'BUTTON', $action_button->render());
414 $tpl->parseCurrentBlock();
416 $button->setHtml(
$tpl->get());
420 if (!$this->
object->getSelfAssessmentEditingMode()) {
421 $textrating =
new ilSelectInputGUI($this->lng->txt(
"text_rating"),
"textgap_rating");
422 $text_options =
array(
423 "ci" => $this->lng->txt(
"cloze_textgap_case_insensitive"),
424 "cs" => $this->lng->txt(
"cloze_textgap_case_sensitive"),
425 "l1" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"1"),
426 "l2" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"2"),
427 "l3" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"3"),
428 "l4" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"4"),
429 "l5" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"5")
431 $textrating->setOptions($text_options);
432 $textrating->setValue($this->
object->getTextgapRating());
436 $fixedTextLength =
new ilNumberInputGUI($this->lng->txt(
"cloze_fixed_textlength"),
"fixedTextLength");
437 $ftl = $this->
object->getFixedTextLength();
439 $fixedTextLength->
setValue($ftl > 0 ? $ftl :
'');
440 $fixedTextLength->setMinValue(0);
441 $fixedTextLength->setSize(3);
442 $fixedTextLength->setMaxLength(6);
443 $fixedTextLength->setInfo($this->lng->txt(
'cloze_fixed_textlength_description'));
444 $fixedTextLength->setRequired(
false);
445 $form->
addItem($fixedTextLength);
448 $identical_scoring =
new ilCheckboxInputGUI($this->lng->txt(
"identical_scoring"),
"identical_scoring");
450 $identical_scoring->setChecked($this->
object->getIdenticalScoring());
451 $identical_scoring->setInfo($this->lng->txt(
'identical_scoring_desc'));
452 $identical_scoring->setRequired(
false);
453 $form->
addItem($identical_scoring);
460 if (self::OLD_CLOZE_TEST_UI) {
461 for ($gapCounter = 0; $gapCounter < $this->
object->getGapCount(); $gapCounter++) {
466 require_once
'Modules/TestQuestionPool/classes/Form/class.ilClozeGapInputBuilderGUI.php';
469 $combination_exists = $assClozeGapCombinationObject->combinationExistsForQid($this->
object->id);
470 if ($combination_exists) {
471 $combinations = $assClozeGapCombinationObject->loadFromDb($this->
object->id);
476 $new_builder->setValueByArray($json);
477 $new_builder->setValueCombinationFromDb($combinations);
485 $gap = $this->
object->getGaps();
490 $translate_type=
array(
'text',
'select',
'numeric');
492 foreach ($gap as $content) {
494 $value=$content->getItemsRaw();
496 for ($j=0;$j<count($value);$j++) {
497 if ($content->getType()==2) {
499 'answer' => $value[$j]->getAnswerText(),
500 'lower' => $value[$j]->getLowerBound(),
501 'upper' => $value[$j]->getUpperBound(),
502 'points' => $value[$j]->getPoints(),
507 'answer' => $value[$j]->getAnswerText(),
508 'points' => $value[$j]->getPoints(),
512 if ($content->getType()==1) {
513 $shuffle=$content->getShuffle();
518 'type' => $translate_type[$content->getType()] ,
520 'shuffle' => $shuffle,
521 'text_field_length' => $content->getGapSize() > 0 ? $content->getGapSize() :
'',
522 'used_in_gap_combination' =>
true);
540 $gap = $this->
object->getGap($gapCounter);
547 $header->setTitle($this->lng->txt(
"gap") .
" " . ($gapCounter + 1));
551 $gapcounter->setValue($gapCounter);
552 $form->addItem($gapcounter);
554 $gaptype =
new ilSelectInputGUI($this->lng->txt(
'type'),
"clozetype_$gapCounter");
556 0 => $this->lng->txt(
"text_gap"),
557 1 => $this->lng->txt(
"select_gap"),
558 2 => $this->lng->txt(
"numeric_gap")
560 $gaptype->setOptions($options);
561 $gaptype->setValue($gap->getType());
562 $form->addItem($gaptype);
567 if (count($gap->getItemsRaw()) == 0) {
572 if (count($gap->getItemsRaw()) == 0) {
579 if (count($gap->getItemsRaw()) == 0) {
582 foreach ($gap->getItemsRaw() as $item) {
596 $gapSizeFormItem =
new ilNumberInputGUI($this->lng->txt(
'cloze_fixed_textlength'),
"gap_" . $gapCounter .
'_gapsize');
599 $gapSizeFormItem->setMinValue(0);
600 $gapSizeFormItem->setSize(3);
601 $gapSizeFormItem->setMaxLength(6);
602 $gapSizeFormItem->setInfo($this->lng->txt(
'cloze_gap_size_info'));
603 $gapSizeFormItem->setValue($gap->getGapSize());
604 $form->addItem($gapSizeFormItem);
623 include_once
"./Modules/TestQuestionPool/classes/class.ilAnswerWizardInputGUI.php";
624 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
627 $values->setQuestionObject($this->
object);
628 $values->setSingleline(
true);
629 $values->setAllowMove(
false);
631 $values->setValues($gap->getItemsRaw());
632 $form->addItem($values);
635 $shuffle =
new ilCheckboxInputGUI($this->lng->txt(
"shuffle_answers"),
"shuffle_" . $gapCounter .
"");
637 $shuffle->setChecked($gap->getShuffle());
638 $shuffle->setRequired(
false);
639 $form->addItem($shuffle);
657 include_once
"./Modules/TestQuestionPool/classes/class.ilAnswerWizardInputGUI.php";
658 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
661 $values->setQuestionObject($this->
object);
662 $values->setSingleline(
true);
663 $values->setAllowMove(
false);
664 $values->setValues($gap->getItemsRaw());
665 $form->addItem($values);
667 if ($this->
object->getFixedTextLength() > 0) {
668 $values->setSize($this->
object->getFixedTextLength());
669 $values->setMaxLength($this->
object->getFixedTextLength());
689 if (!$this->
object->getSelfAssessmentEditingMode()) {
690 $value =
new ilFormulaInputGUI($this->lng->txt(
'value'),
"gap_" . $gapCounter .
"_numeric");
693 $lowerbound =
new ilFormulaInputGUI($this->lng->txt(
'range_lower_limit'),
"gap_" . $gapCounter .
"_numeric_lower");
696 $upperbound =
new ilFormulaInputGUI($this->lng->txt(
'range_upper_limit'),
"gap_" . $gapCounter .
"_numeric_upper");
699 $value =
new ilNumberInputGUI($this->lng->txt(
'value'),
"gap_" . $gapCounter .
"_numeric");
702 $lowerbound =
new ilNumberInputGUI($this->lng->txt(
'range_lower_limit'),
"gap_" . $gapCounter .
"_numeric_lower");
705 $upperbound =
new ilNumberInputGUI($this->lng->txt(
'range_upper_limit'),
"gap_" . $gapCounter .
"_numeric_upper");
711 $value->setRequired(
true);
712 $form->addItem($value);
714 $lowerbound->setSize(10);
715 $lowerbound->setRequired(
true);
717 $form->addItem($lowerbound);
719 $upperbound->setSize(10);
720 $upperbound->setRequired(
true);
722 $form->addItem($upperbound);
724 if ($this->
object->getFixedTextLength() > 0) {
725 $value->setSize($this->
object->getFixedTextLength());
726 $value->setMaxLength($this->
object->getFixedTextLength());
727 $lowerbound->setSize($this->
object->getFixedTextLength());
728 $lowerbound->setMaxLength($this->
object->getFixedTextLength());
729 $upperbound->setSize($this->
object->getFixedTextLength());
730 $upperbound->setMaxLength($this->
object->getFixedTextLength());
733 $points =
new ilNumberInputGUI($this->lng->txt(
'points'),
"gap_" . $gapCounter .
"_numeric_points");
736 $points->setRequired(
true);
738 $form->addItem($points);
748 $this->
object->saveToDb();
758 $this->
object->deleteAnswerText($this->gapIndex, key(
$_POST[
'cmd'][
'removegap_' . $this->gapIndex]));
768 $this->
object->addGapAnswer($this->gapIndex, key(
$_POST[
'cmd'][
'addgap_' . $this->gapIndex])+1,
"");
780 public function getPreview($show_question_only =
false, $showInlineFeedback =
false)
785 include_once
"./Services/UICore/classes/class.ilTemplate.php";
786 $template =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_output.html",
true,
true,
"Modules/TestQuestionPool");
787 $output = $this->
object->getClozeText();
788 foreach ($this->
object->getGaps() as $gap_index => $gap) {
789 switch ($gap->getType()) {
791 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_text.html",
true,
true,
"Modules/TestQuestionPool");
793 $gap_size = $gap->getGapSize() > 0 ? $gap->getGapSize() : $this->
object->getFixedTextLength();
795 $gaptemplate->setCurrentBlock(
'size_and_maxlength');
796 $gaptemplate->setVariable(
"TEXT_GAP_SIZE", $gap_size);
797 $gaptemplate->parseCurrentBlock();
799 $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
800 foreach ($user_solution as $val1 => $val2) {
801 if (strcmp($val1, $gap_index) == 0) {
805 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(),
$output, 1);
808 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_select.html",
true,
true,
"Modules/TestQuestionPool");
809 foreach ($gap->getItems($this->object->getShuffler()) as $item) {
810 $gaptemplate->setCurrentBlock(
"select_gap_option");
811 $gaptemplate->setVariable(
"SELECT_GAP_VALUE", $item->getOrder());
813 foreach ($user_solution as $val1 => $val2) {
814 if (strcmp($val1, $gap_index) == 0) {
815 if (strcmp($val2, $item->getOrder()) == 0) {
816 $gaptemplate->setVariable(
"SELECT_GAP_SELECTED",
" selected=\"selected\"");
820 $gaptemplate->parseCurrentBlock();
822 $gaptemplate->setVariable(
"PLEASE_SELECT", $this->lng->txt(
"please_select"));
823 $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
824 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(),
$output, 1);
827 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_numeric.html",
true,
true,
"Modules/TestQuestionPool");
828 $gap_size = $gap->getGapSize() > 0 ? $gap->getGapSize() : $this->
object->getFixedTextLength();
830 $gaptemplate->setCurrentBlock(
'size_and_maxlength');
831 $gaptemplate->setVariable(
"TEXT_GAP_SIZE", $gap_size);
832 $gaptemplate->parseCurrentBlock();
834 $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
835 foreach ($user_solution as $val1 => $val2) {
836 if (strcmp($val1, $gap_index) == 0) {
840 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(),
$output, 1);
844 $template->setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($this->object->getQuestion(),
true));
847 if (!$show_question_only) {
851 return $questionoutput;
872 $graphicalOutput =
false,
873 $result_output =
false,
874 $show_question_only =
true,
875 $show_feedback =
false,
876 $show_correct_solution =
false,
877 $show_manual_scoring =
false,
878 $show_question_text =
true 881 $user_solution =
array();
882 if (($active_id > 0) && (!$show_correct_solution)) {
884 $user_solution =&$this->
object->getSolutionValues($active_id,
$pass);
885 if (!is_array($user_solution)) {
886 $user_solution =
array();
890 include_once
"./Services/UICore/classes/class.ilTemplate.php";
891 $template =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_output_solution.html",
true,
true,
"Modules/TestQuestionPool");
892 $output = $this->
object->getClozeText();
894 $check_for_gap_combinations = $assClozeGapCombinationObject->loadFromDb($this->
object->getId());
896 foreach ($this->
object->getGaps() as $gap_index => $gap) {
897 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_output_solution_gap.html",
true,
true,
"Modules/TestQuestionPool");
899 foreach ($user_solution as $solutionarray) {
900 if ($solutionarray[
"value1"] == $gap_index) {
901 $found = $solutionarray;
906 if ($graphicalOutput) {
908 $details = $this->
object->calculateReachedPoints($active_id,
$pass,
true,
true);
909 $check = $details[$gap_index];
911 if (count($check_for_gap_combinations) != 0) {
912 $gaps_used_in_combination = $assClozeGapCombinationObject->getGapsWhichAreUsedInCombination($this->
object->getId());
913 $custom_user_solution =
array();
914 if (array_key_exists($gap_index, $gaps_used_in_combination)) {
915 $combination_id = $gaps_used_in_combination[$gap_index];
916 foreach ($gaps_used_in_combination as
$key => $value) {
918 if ($value == $combination_id) {
919 foreach ($user_solution as $solution_key => $solution_value) {
920 if ($solution_value[
'value1'] ==
$key) {
921 $result_row =
array();
922 $result_row[
'gap_id'] = $solution_value[
'value1'];
923 $result_row[
'value'] = $solution_value[
'value2'];
924 array_push($custom_user_solution, $result_row);
929 $points_array = $this->
object->calculateCombinationResult($custom_user_solution);
930 $max_combination_points = $assClozeGapCombinationObject->getMaxPointsForCombination($this->
object->getId(), $combination_id);
931 if ($points_array[0] == $max_combination_points) {
933 $gaptemplate->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
934 } elseif ($points_array[0] > 0) {
936 $gaptemplate->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
939 $gaptemplate->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
942 if ($check[
"best"]) {
943 $gaptemplate->setCurrentBlock(
"icon_ok");
945 $gaptemplate->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
946 $gaptemplate->parseCurrentBlock();
948 $gaptemplate->setCurrentBlock(
"icon_not_ok");
949 if ($check[
"positive"]) {
951 $gaptemplate->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
954 $gaptemplate->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
956 $gaptemplate->parseCurrentBlock();
960 if ($check[
"best"]) {
961 $gaptemplate->setCurrentBlock(
"icon_ok");
963 $gaptemplate->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
964 $gaptemplate->parseCurrentBlock();
966 $gaptemplate->setCurrentBlock(
"icon_not_ok");
967 if ($check[
"positive"]) {
969 $gaptemplate->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
972 $gaptemplate->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
974 $gaptemplate->parseCurrentBlock();
979 if ($result_output) {
980 $points = $this->
object->getMaximumGapPoints($gap_index);
981 $resulttext = ($points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
982 $gaptemplate->setCurrentBlock(
"result_output");
983 $gaptemplate->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $points));
984 $gaptemplate->parseCurrentBlock();
987 switch ($gap->getType()) {
990 if (($active_id > 0) && (!$show_correct_solution)) {
991 if ((count($found) == 0) || (strlen(trim($found[
"value2"])) == 0)) {
992 for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++) {
993 $solutiontext .=
" ";
999 $solutiontext = $this->
getBestSolutionText($gap, $gap_index, $check_for_gap_combinations);
1002 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(),
$output, 1);
1006 if (($active_id > 0) && (!$show_correct_solution)) {
1007 if ((count($found) == 0) || (strlen(trim($found[
"value2"])) == 0)) {
1008 for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++) {
1009 $solutiontext .=
" ";
1012 $item = $gap->getItem($found[
"value2"]);
1013 if (is_object($item)) {
1016 for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++) {
1017 $solutiontext .=
" ";
1022 $solutiontext = $this->
getBestSolutionText($gap, $gap_index, $check_for_gap_combinations);
1025 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(),
$output, 1);
1029 if (($active_id > 0) && (!$show_correct_solution)) {
1030 if ((count($found) == 0) || (strlen(trim($found[
"value2"])) == 0)) {
1031 for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++) {
1032 $solutiontext .=
" ";
1038 $solutiontext = $this->
getBestSolutionText($gap, $gap_index, $check_for_gap_combinations);
1041 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(),
$output, 1);
1046 if ($show_question_text) {
1049 $this->
object->prepareTextareaOutput($this->object->getQuestion(),
true)
1055 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",
true,
true,
"Modules/TestQuestionPool");
1059 if ($show_feedback) {
1062 $feedback .= strlen($fb) ? $fb :
'';
1066 $feedback .= strlen($fb) ? $fb :
'';
1068 if (strlen($feedback)) {
1074 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
1075 $solutiontemplate->setVariable(
"FEEDBACK", $this->
object->prepareTextareaOutput($feedback,
true));
1078 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
1080 $solutionoutput = $solutiontemplate->get();
1082 if (!$show_question_only) {
1084 $solutionoutput = $this->
getILIASPage($solutionoutput);
1087 return $solutionoutput;
1098 $combination = null;
1099 foreach ((
array) $gap_combinations as $combiGapSolRow) {
1100 if ($combiGapSolRow[
'gap_fi'] == $gap_index) {
1101 $combination = $combiGapSolRow;
1106 $this->object->getShuffler(),
1109 return $best_solution_text;
1114 include_once
"./Modules/Test/classes/class.ilObjTest.php";
1116 if (strlen($manual_feedback)) {
1117 return $manual_feedback;
1119 $correct_feedback = $this->
object->feedbackOBJ->getGenericFeedbackTestPresentation($this->
object->getId(),
true);
1120 $incorrect_feedback = $this->
object->feedbackOBJ->getGenericFeedbackTestPresentation($this->
object->getId(),
false);
1121 if (strlen($correct_feedback . $incorrect_feedback)) {
1122 $reached_points = $this->
object->calculateReachedPoints($active_id,
$pass);
1123 $max_points = $this->
object->getMaximumPoints();
1124 if ($reached_points == $max_points) {
1127 $output .= $incorrect_feedback;
1131 return $this->
object->prepareTextareaOutput(
$output,
true);
1139 $is_postponed =
false,
1140 $use_post_solutions =
false,
1141 $show_feedback =
false 1144 $user_solution =
array();
1145 if ($use_post_solutions !==
false) {
1146 $indexedSolution = $this->
object->fetchSolutionSubmit($use_post_solutions);
1147 $user_solution = $this->
object->fetchValuePairsFromIndexedValues($indexedSolution);
1148 } elseif ($active_id) {
1150 #include_once "./Modules/Test/classes/class.ilObjTest.php"; 1151 #if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) 1153 # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id); 1155 $user_solution = $this->
object->getTestOutputSolutions($active_id,
$pass);
1157 if (!is_array($user_solution)) {
1158 $user_solution =
array();
1163 include_once
"./Services/UICore/classes/class.ilTemplate.php";
1164 $template =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_output.html",
true,
true,
"Modules/TestQuestionPool");
1165 $output = $this->
object->getClozeText();
1166 foreach ($this->
object->getGaps() as $gap_index => $gap) {
1167 switch ($gap->getType()) {
1169 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_text.html",
true,
true,
"Modules/TestQuestionPool");
1170 $gap_size = $gap->getGapSize() > 0 ? $gap->getGapSize() : $this->
object->getFixedTextLength();
1172 if ($gap_size > 0) {
1173 $gaptemplate->setCurrentBlock(
'size_and_maxlength');
1174 $gaptemplate->setVariable(
"TEXT_GAP_SIZE", $gap_size);
1175 $gaptemplate->parseCurrentBlock();
1178 $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
1179 foreach ($user_solution as $solution) {
1180 if (strcmp($solution[
"value1"], $gap_index) == 0) {
1184 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(),
$output, 1);
1187 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_select.html",
true,
true,
"Modules/TestQuestionPool");
1188 foreach ($gap->getItems($this->object->getShuffler()) as $item) {
1189 $gaptemplate->setCurrentBlock(
"select_gap_option");
1190 $gaptemplate->setVariable(
"SELECT_GAP_VALUE", $item->getOrder());
1192 foreach ($user_solution as $solution) {
1193 if (strcmp($solution[
"value1"], $gap_index) == 0) {
1194 if (strcmp($solution[
"value2"], $item->getOrder()) == 0) {
1195 $gaptemplate->setVariable(
"SELECT_GAP_SELECTED",
" selected=\"selected\"");
1199 $gaptemplate->parseCurrentBlock();
1201 $gaptemplate->setVariable(
"PLEASE_SELECT", $this->lng->txt(
"please_select"));
1202 $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
1203 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(),
$output, 1);
1206 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_numeric.html",
true,
true,
"Modules/TestQuestionPool");
1207 $gap_size = $gap->getGapSize() > 0 ? $gap->getGapSize() : $this->
object->getFixedTextLength();
1208 if ($gap_size > 0) {
1209 $gaptemplate->setCurrentBlock(
'size_and_maxlength');
1210 $gaptemplate->setVariable(
"TEXT_GAP_SIZE", $gap_size);
1211 $gaptemplate->parseCurrentBlock();
1214 $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
1215 foreach ($user_solution as $solution) {
1216 if (strcmp($solution[
"value1"], $gap_index) == 0) {
1220 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(),
$output, 1);
1225 $template->setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($this->object->getQuestion(),
true));
1228 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
1241 global $rbacsystem, $ilTabs;
1243 $ilTabs->clearTargets();
1245 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
1246 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
1247 $q_type = $this->
object->getQuestionType();
1249 if (strlen($q_type)) {
1250 $classname = $q_type .
"GUI";
1251 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
1252 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
1253 # $this->ctrl->setParameterByClass(strtolower($classname), 'prev_qid', $_REQUEST['prev_qid']); 1256 if (
$_GET[
"q_id"]) {
1257 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"])) {
1261 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
1262 array(
"edit",
"insert",
"exec_pg"),
1272 $force_active =
false;
1273 $commands =
$_POST[
"cmd"];
1274 if (is_array($commands)) {
1275 foreach ($commands as
$key => $value) {
1276 if (preg_match(
"/^removegap_.*/",
$key, $matches) ||
1277 preg_match(
"/^addgap_.*/",
$key, $matches)
1279 $force_active =
true;
1283 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"])) {
1286 $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
1292 array(
"editQuestion",
"originalSyncForm",
"save",
"createGaps",
"saveEdit"),
1309 if (
$_GET[
"q_id"]) {
1312 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
1313 array(
"assessment"),
1324 if (!$this->
object->feedbackOBJ->specificAnswerFeedbackExists(array_values($this->
object->gaps))) {
1330 $feedback =
'<table class="test_specific_feedback"><tbody>';
1333 $caption = $lng->txt(
'gap') .
' ' . (
$index+1) .
': ';
1335 $feedback .=
'<tr><td>';
1337 $feedback .= $caption .
'</td><td>';
1338 $feedback .= $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
1343 $feedback .=
'</tbody></table>';
1345 return $this->
object->prepareTextareaOutput($feedback,
true);
1386 $overview =
array();
1387 $aggregation =
array();
1388 foreach ($relevant_answers as $answer) {
1389 $overview[$answer[
'active_fi']][$answer[
'pass']][$answer[
'value1']] = $answer[
'value2'];
1392 foreach ($overview as $active) {
1393 foreach ($active as $answer) {
1394 foreach ($answer as $option => $value) {
1395 $aggregation[$option][$value] = $aggregation[$option][$value] + 1;
1402 foreach ($this->
object->getGaps() as $gap) {
1404 $html .=
'<p>Gap ' . (
$i+1) .
' - SELECT</p>';
1407 foreach ($gap->getItems($this->object->getShuffler()) as $gap_item) {
1408 $aggregate = $aggregation[
$i];
1416 $present_elements =
array();
1419 $present_elements[] = $item->getAnswertext();
1422 $html .=
'<p>Gap ' . (
$i+1) .
' - TEXT</p>';
1424 $aggregate = (
array) $aggregation[
$i];
1425 foreach ($aggregate as $answer => $count) {
1427 if (in_array($answer, $present_elements)) {
1428 $show_mover =
' style="display: none;" ';
1432 .
' <button class="clone_fields_add btn btn-link" ' . $show_mover .
' data-answer="' .
ilUtil::prepareFormOutput($answer) .
'" name="add_gap_' .
$i .
'_0"> 1433 <span class="sr-only"></span><span class="glyphicon glyphicon-plus"></span></button> 1440 $html .=
'<p>Gap ' . (
$i+1) .
' - NUMERIC</p>';
1443 foreach ($gap->getItems($this->object->getShuffler()) as $gap_item) {
1444 $aggregate = (
array) $aggregation[
$i];
1445 foreach ($aggregate as $answer => $count) {
1462 $parts = explode(
'[gap', $question_text);
1464 $question_text =
'';
1465 foreach ($parts as $part) {
1467 $question_text .= $part;
1469 $question_text .=
'[gap ' .
$i . $part;
1473 return $question_text;
1478 $parts = preg_split(
'/\[gap \d*\]/', $question_text);
1479 $question_text = implode(
'[gap]', $parts);
1480 return $question_text;
1490 $gaptemplate->setCurrentBlock(
'gap_span');
1491 $gaptemplate->setVariable(
'SPAN_SOLUTION', $solutiontext);
1493 $gaptemplate->setCurrentBlock(
'gap_select');
1494 $gaptemplate->setVariable(
'SELECT_SOLUTION', $solutiontext);
1496 $gap_size = $gap->getGapSize() > 0 ? $gap->getGapSize() : $this->
object->getFixedTextLength();
1498 if ($gap_size > 0) {
1499 $gaptemplate->setCurrentBlock(
'gap_size');
1500 $gaptemplate->setVariable(
"GAP_SIZE", $gap_size);
1501 $gaptemplate->parseCurrentBlock();
1504 $gaptemplate->setCurrentBlock(
'gap_input');
1505 $gaptemplate->setVariable(
'INPUT_SOLUTION', $solutiontext);
1509 $gaptemplate->parseCurrentBlock();
isTestPresentationContext()
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
hasCorrectSolution($activeId, $passIndex)
addTab_QuestionPreview(ilTabsGUI $tabsGUI)
Class for cloze question numeric answers.
getSpecificFeedbackOutput($active_id, $pass)
getAfterParticipationSuppressionAnswerPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
addTab_QuestionHints(ilTabsGUI $tabs)
adds the hints tab to ilTabsGUI
getAnswerFeedbackOutput($active_id, $pass)
const CLOZE_TEXT
Cloze question constants.
getTestOutput( $active_id, $pass, $is_postponed=false, $use_post_solutions=false, $show_feedback=false)
static _getUsedHTMLTags($a_module="")
Returns an array of all allowed HTML tags for text editing.
if(!array_key_exists('StateId', $_REQUEST)) $id
setValue($a_value)
Set Value.
populateTextGapFormPart($form, $gap, $gapCounter)
Populates the form-part for a text gap.
setQuestionTabs()
Sets the ILIAS tabs for this question type.
populateSolutiontextToGapTpl($gaptemplate, $gap, $solutiontext)
getQuestionTemplate()
get question template
const CSS_CLASS_FEEDBACK_CORRECT
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from $_POST and applies them to the data object.
populateTaxonomyFormSection(ilPropertyFormGUI $form)
getBestSolutionText($gap, $gap_index, $gap_combinations)
getAfterParticipationSuppressionQuestionPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
Cloze test question GUI representation.
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from $_POST and applies them to the data object.
populateQuestionSpecificFormPart(ilPropertyFormGUI $form)
Adds the question specific forms parts to a question property form gui.
createGaps()
Create gaps from cloze text.
writeQuestionGenericPostData()
if(isset($_POST['submit'])) $form
getILIASPage($html="")
Returns the ILIAS Page around a question.
getAggregatedAnswersView($relevant_answers)
Returns an html string containing a question specific representation of the answers so far given in t...
populateGapFormPart($form, $gapCounter)
Populates a gap form-part.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
populateAnswerSpecificFormPart(ilPropertyFormGUI $form)
Adds the answer specific form parts to a question property form gui.
static getManualFeedback($active_id, $question_id, $pass)
Retrieves the manual feedback for a question in a test.
special template class to simplify handling of ITX/PEAR
writePostData($always=false)
{}
static stripSlashesRecursive($a_data, $a_strip_html=true, $a_allow="")
Strip slashes from array and sub-arrays.
This class represents a text property in a property form.
populateGapSizeFormPart($form, $gap, $gapCounter)
addTab_QuestionFeedback(ilTabsGUI $tabs)
adds the feedback tab to ilTabsGUI
const CSS_CLASS_FEEDBACK_WRONG
Basic GUI class for assessment questions.
removegap()
Remove a gap answer.
Create styles array
The data for the language used.
addgap()
Add a gap answer.
const ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT
constant for additional content editing mode "default"
populateNumericGapFormPart($form, $gap, $gapCounter)
Populates the form-part for a numeric gap.
populateSelectGapFormPart($form, $gap, $gapCounter)
Populates the form-part for a select gap.
getSolutionOutput( $active_id, $pass=null, $graphicalOutput=false, $result_output=false, $show_question_only=true, $show_feedback=false, $show_correct_solution=false, $show_manual_scoring=false, $show_question_text=true)
Get the question solution output.
saveTaxonomyAssignments()
__construct($id=-1)
assClozeTestGUI constructor
Create new PHPExcel object
obj_idprivate
applyIndizesToGapText($question_text)
This class represents a text area property in a property form.
addBackTab(ilTabsGUI $ilTabs)
setInlineStyle($a_style)
Set inline style.
isRenderPurposePrintPdf()
Interface ilGuiAnswerScoringAdjustable.
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="")
output question page
addBasicQuestionFormProperties($form)
$gapIndex
A temporary variable to store gap indexes of ilCtrl commands in the getCommand method.
getGenericFeedbackOutput($active_id, $pass)
Returns the answer specific feedback for the question.
Interface ilGuiQuestionScoringAdjustable.
setValue($a_value)
Set Value.
getPreview($show_question_only=false, $showInlineFeedback=false)
Creates a preview output of the question.
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
removeIndizesFromGapText($question_text)
addTab_SuggestedSolution(ilTabsGUI $tabs, $classname)
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
addQuestionFormCommandButtons($form)
Add the command buttons of a question properties form.
renderPurposeSupportsFormHtml()