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';
38 parent::__construct();
39 include_once
"./Modules/TestQuestionPool/classes/class.assClozeTest.php";
43 $this->
object->loadFromDb($id);
49 if (preg_match(
"/^(removegap|addgap)_(\d+)$/",
$cmd, $matches))
52 $this->gapIndex = $matches[2];
67 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
70 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
72 $cloze_text = $this->
object->getHtmlQuestionContentPurifier()->purify(
$_POST[
'cloze_text']);
75 $_POST[
'cloze_text'] = $cloze_text;
76 $this->
object->setQuestion(
$_POST[
'question']);
79 $this->
object->setClozeText(
$_POST[
"cloze_text"]);
87 $cloze_text =
$_POST[
'cloze_text'];
89 $_POST[
'cloze_text'] = $cloze_text;
95 if (is_array(
$_POST[
'gap'] ))
97 if ( $this->ctrl->getCmd() !=
'createGaps' )
99 $this->
object->clearGapAnswers();
102 foreach (
$_POST[
'gap'] as $idx => $hidden)
104 $clozetype =
$_POST[
'clozetype_' . $idx];
106 $this->
object->setGapType( $idx, $clozetype );
112 $this->
object->setGapShuffle( $idx, 0 );
114 if ($this->ctrl->getCmd() !=
'createGaps')
116 if (is_array(
$_POST[
'gap_' . $idx][
'answer'] ))
118 foreach (
$_POST[
'gap_' . $idx][
'answer'] as $order => $value)
120 $this->
object->addGapAnswer( $idx, $order, $value );
125 $this->
object->addGapAnswer( $idx, 0,
'' );
129 if (is_array(
$_POST[
'gap_' . $idx][
'points'] ))
131 foreach (
$_POST[
'gap_' . $idx][
'points'] as $order => $value)
133 $this->
object->setGapAnswerPoints( $idx, $order, $value );
137 if (array_key_exists(
'gap_' . $idx .
'_gapsize',
$_POST ))
139 $this->
object->setGapSize($idx, $order,
$_POST[
'gap_' . $idx .
'_gapsize'] );
146 $this->
object->setGapShuffle( $idx, (
int)(isset(
$_POST[
"shuffle_$idx"]) &&
$_POST[
"shuffle_$idx"]) );
148 if ($this->ctrl->getCmd() !=
'createGaps')
150 if (is_array(
$_POST[
'gap_' . $idx][
'answer'] ))
152 foreach (
$_POST[
'gap_' . $idx][
'answer'] as $order => $value)
154 $this->
object->addGapAnswer( $idx, $order, $value );
159 $this->
object->addGapAnswer( $idx, 0,
'' );
163 if (is_array(
$_POST[
'gap_' . $idx][
'points'] ))
165 foreach (
$_POST[
'gap_' . $idx][
'points'] as $order => $value)
167 $this->
object->setGapAnswerPoints( $idx, $order, $value );
174 $this->
object->setGapShuffle( $idx, 0 );
176 $gap = $this->
object->getGap($idx);
179 $this->
object->getGap($idx)->clearItems();
181 if (array_key_exists(
'gap_' . $idx .
'_numeric',
$_POST ))
183 if ($this->ctrl->getCmd() !=
'createGaps')
185 $this->
object->addGapAnswer(
186 $idx, 0, str_replace(
",",
".",
$_POST[
'gap_' . $idx .
'_numeric'])
190 $this->
object->setGapAnswerLowerBound(
191 $idx, 0, str_replace(
",",
".",
$_POST[
'gap_' . $idx .
'_numeric_lower'])
194 $this->
object->setGapAnswerUpperBound(
195 $idx, 0, str_replace(
",",
".",
$_POST[
'gap_' . $idx .
'_numeric_upper'])
198 $this->
object->setGapAnswerPoints( $idx, 0,
$_POST[
'gap_' . $idx .
'_numeric_points'] );
202 if ($this->ctrl->getCmd() !=
'createGaps')
204 $this->
object->addGapAnswer($idx, 0,
'');
207 $this->
object->setGapAnswerLowerBound($idx, 0,
'');
209 $this->
object->setGapAnswerUpperBound($idx, 0,
'');
212 if (array_key_exists(
'gap_' . $idx .
'_gapsize',
$_POST ))
214 $this->
object->setGapSize($idx, $order,
$_POST[
'gap_' . $idx .
'_gapsize'] );
219 $assClozeGapCombinationObject->clearGapCombinationsFromDb($this->object->getId());
220 if(count(
$_POST[
'gap_combination']) > 0)
225 if ($this->ctrl->getCmd() !=
'createGaps')
227 $this->
object->updateClozeTextFromGaps();
234 $this->
object->setClozeText(
$_POST[
'cloze_text'] );
235 $this->
object->setTextgapRating(
$_POST[
"textgap_rating"] );
236 $this->
object->setIdenticalScoring(
$_POST[
"identical_scoring"] );
237 $this->
object->setFixedTextLength(
$_POST[
"fixedTextLength"] );
250 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
252 $form->setFormAction($this->ctrl->getFormAction($this));
254 $form->setMultipart(FALSE);
255 $form->setTableWidth(
"100%");
256 $form->setId(
"assclozetest");
270 $form->setValuesByPost();
271 $errors = !$form->checkInput();
272 $form->setValuesByPost();
274 if (
$errors) $checkonly =
false;
277 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
286 $title->setValue($this->object->getTitle());
287 $title->setRequired(TRUE);
288 $form->addItem($title);
290 if (!$this->object->getSelfAssessmentEditingMode())
293 $author =
new ilTextInputGUI($this->lng->txt(
"author"),
"author");
294 $author->
setValue($this->object->getAuthor());
295 $author->setRequired(TRUE);
296 $form->addItem($author);
299 $description =
new ilTextInputGUI($this->lng->txt(
"description"),
"comment");
300 $description->
setValue($this->object->getComment());
301 $description->setRequired(FALSE);
302 $form->addItem($description);
309 if (trim($author) ==
"")
313 $hi->setValue($author);
320 $question->
setValue($this->object->prepareTextareaOutput($this->object->getQuestion()));
321 $question->setRequired(TRUE);
322 $question->setRows(10);
323 $question->setCols(80);
324 if (!$this->object->getSelfAssessmentEditingMode())
328 $question->setUseRte(TRUE);
329 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
331 $question->addPlugin(
"latex");
332 $question->addButton(
"latex");
333 $question->addButton(
"pastelatex");
334 $question->setRTESupport($this->object->getId(),
"qpl",
"assessment");
339 require_once
'Modules/TestQuestionPool/classes/questions/class.ilAssSelfAssessmentQuestionFormatter.php';
341 $question->setUseTagsForRteOnly(
false);
343 $form->addItem($question);
353 if (!$this->object->getSelfAssessmentEditingMode())
358 $duration->setShowMinutes(TRUE);
359 $duration->setShowSeconds(TRUE);
360 $ewt = $this->
object->getEstimatedWorkingTime();
361 $duration->setHours($ewt[
"h"]);
362 $duration->setMinutes($ewt[
"m"]);
363 $duration->setSeconds($ewt[
"s"]);
364 $duration->setRequired(FALSE);
365 $form->addItem($duration);
370 if (strlen($this->object->getNrOfTries()))
372 $nr_tries = $this->
object->getNrOfTries();
376 $nr_tries = $this->
object->getDefaultNrOfTries();
388 $ni =
new ilNumberInputGUI($this->lng->txt(
"qst_nr_of_tries"),
"nr_of_tries");
393 $ni->setMaxLength(5);
394 $ni->setRequired(
true);
405 $cloze_text->setInfo($this->lng->txt(
"close_text_hint"));
406 $cloze_text->setRows( 10 );
407 $cloze_text->setCols( 80 );
408 if (!$this->object->getSelfAssessmentEditingMode())
412 $cloze_text->setUseRte(TRUE);
413 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
415 $cloze_text->addPlugin(
"latex");
416 $cloze_text->addButton(
"latex");
417 $cloze_text->addButton(
"pastelatex");
422 require_once
'Modules/TestQuestionPool/classes/questions/class.ilAssSelfAssessmentQuestionFormatter.php';
424 $cloze_text->setUseTagsForRteOnly(
false);
426 $cloze_text->setRTESupport($this->object->getId(),
"qpl",
"assessment");
429 $tpl =
new ilTemplate(
"tpl.il_as_qpl_cloze_gap_button_code.html", TRUE, TRUE,
"Modules/TestQuestionPool");
430 $tpl->setVariable(
'INSERT_GAP', $this->lng->txt(
'insert_gap'));
431 $tpl->setVariable(
'CREATE_GAPS', $this->lng->txt(
'create_gaps'));
432 $tpl->parseCurrentBlock();
434 $button->setHtml(
$tpl->get());
438 if (!$this->object->getSelfAssessmentEditingMode())
440 $textrating =
new ilSelectInputGUI($this->lng->txt(
"text_rating" ),
"textgap_rating");
441 $text_options = array(
442 "ci" => $this->lng->txt(
"cloze_textgap_case_insensitive" ),
443 "cs" => $this->lng->txt(
"cloze_textgap_case_sensitive" ),
444 "l1" => sprintf( $this->lng->txt(
"cloze_textgap_levenshtein_of" ),
"1" ),
445 "l2" => sprintf( $this->lng->txt(
"cloze_textgap_levenshtein_of" ),
"2" ),
446 "l3" => sprintf( $this->lng->txt(
"cloze_textgap_levenshtein_of" ),
"3" ),
447 "l4" => sprintf( $this->lng->txt(
"cloze_textgap_levenshtein_of" ),
"4" ),
448 "l5" => sprintf( $this->lng->txt(
"cloze_textgap_levenshtein_of" ),
"5" )
450 $textrating->setOptions( $text_options );
451 $textrating->setValue( $this->object->getTextgapRating() );
455 $fixedTextLength =
new ilNumberInputGUI($this->lng->txt(
"cloze_fixed_textlength" ),
"fixedTextLength");
456 $ftl = $this->
object->getFixedTextLength();
458 $fixedTextLength->
setValue( $ftl > 0 ? $ftl :
'' );
459 $fixedTextLength->setMinValue( 0 );
460 $fixedTextLength->setSize( 3 );
461 $fixedTextLength->setMaxLength( 6 );
462 $fixedTextLength->setInfo( $this->lng->txt(
'cloze_fixed_textlength_description' ) );
463 $fixedTextLength->setRequired(
false );
464 $form->
addItem( $fixedTextLength );
467 $identical_scoring =
new ilCheckboxInputGUI($this->lng->txt(
"identical_scoring" ),
"identical_scoring");
469 $identical_scoring->setChecked( $this->object->getIdenticalScoring() );
470 $identical_scoring->setInfo( $this->lng->txt(
'identical_scoring_desc' ) );
471 $identical_scoring->setRequired( FALSE );
472 $form->
addItem( $identical_scoring );
479 if(self::OLD_CLOZE_TEST_UI)
481 for ($gapCounter = 0; $gapCounter < $this->
object->getGapCount(); $gapCounter++)
489 require_once
'Modules/TestQuestionPool/classes/Form/class.ilClozeGapInputBuilderGUI.php';
492 $combination_exists = $assClozeGapCombinationObject->combinationExistsForQid($this->object->id);
493 if($combination_exists)
495 $combinations = $assClozeGapCombinationObject->loadFromDb($this->object->id);
500 $new_builder->setValueByArray($json);
501 $new_builder->setValueCombinationFromDb($combinations);
509 $gap = $this->
object->getGaps();
515 $translate_type=array(
'text',
'select',
'numeric');
517 foreach ($gap as $content)
520 $value=$content->getItemsRaw();
522 for($j=0;$j<count($value);$j++)
524 if($content->getType()==2)
527 'answer' => $value[$j]->getAnswerText(),
528 'lower' => $value[$j]->getLowerBound(),
529 'upper' => $value[$j]->getUpperBound(),
530 'points' => $value[$j]->getPoints(),
537 'answer' => $value[$j]->getAnswerText(),
538 'points' => $value[$j]->getPoints(),
542 if($content->getType()==1)
544 $shuffle=$content->getShuffle();
549 'type' => $translate_type[$content->getType()] ,
551 'shuffle' => $shuffle,
552 'text_field_length' => $content->getGapSize() > 0 ? $content->getGapSize() :
'',
553 'used_in_gap_combination' =>
true);
571 $gap = $this->
object->getGap( $gapCounter );
579 $header->setTitle( $this->lng->txt(
"gap" ) .
" " . ($gapCounter + 1) );
583 $gapcounter->setValue( $gapCounter );
584 $form->addItem( $gapcounter );
586 $gaptype =
new ilSelectInputGUI($this->lng->txt(
'type' ),
"clozetype_$gapCounter");
588 0 => $this->lng->txt(
"text_gap" ),
589 1 => $this->lng->txt(
"select_gap" ),
590 2 => $this->lng->txt(
"numeric_gap" )
592 $gaptype->setOptions( $options );
593 $gaptype->setValue( $gap->getType() );
594 $form->addItem( $gaptype );
600 if (count( $gap->getItemsRaw() ) == 0)
606 if (count( $gap->getItemsRaw() ) == 0)
614 if (count( $gap->getItemsRaw() ) == 0)
616 foreach ($gap->getItemsRaw() as $item)
631 $gapSizeFormItem =
new ilNumberInputGUI($this->lng->txt(
'cloze_fixed_textlength'),
"gap_".$gapCounter.
'_gapsize');
633 $gapSizeFormItem->allowDecimals(
false);
634 $gapSizeFormItem->setMinValue(0);
635 $gapSizeFormItem->setSize( 3 );
636 $gapSizeFormItem->setMaxLength( 6 );
637 $gapSizeFormItem->setInfo($this->lng->txt(
'cloze_gap_size_info'));
638 $gapSizeFormItem->setValue($gap->getGapSize());
639 $form->addItem($gapSizeFormItem);
658 include_once
"./Modules/TestQuestionPool/classes/class.ilAnswerWizardInputGUI.php";
659 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
662 $values->setQuestionObject( $this->
object );
663 $values->setSingleline(
true );
664 $values->setAllowMove(
false );
666 $values->setValues( $gap->getItemsRaw() );
667 $form->addItem( $values );
670 $shuffle =
new ilCheckboxInputGUI($this->lng->txt(
"shuffle_answers" ),
"shuffle_" . $gapCounter .
"");
672 $shuffle->setChecked( $gap->getShuffle() );
673 $shuffle->setRequired( FALSE );
674 $form->addItem( $shuffle );
692 include_once
"./Modules/TestQuestionPool/classes/class.ilAnswerWizardInputGUI.php";
693 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
696 $values->setQuestionObject( $this->
object );
697 $values->setSingleline(
true );
698 $values->setAllowMove(
false );
699 $values->setValues( $gap->getItemsRaw() );
700 $form->addItem( $values );
702 if( $this->object->getFixedTextLength() > 0 )
704 $values->setSize( $this->object->getFixedTextLength() );
705 $values->setMaxLength( $this->object->getFixedTextLength() );
725 if (!$this->object->getSelfAssessmentEditingMode())
727 $value =
new ilFormulaInputGUI($this->lng->txt(
'value' ),
"gap_" . $gapCounter .
"_numeric");
730 $lowerbound =
new ilFormulaInputGUI($this->lng->txt(
'range_lower_limit'),
"gap_" . $gapCounter .
"_numeric_lower");
733 $upperbound =
new ilFormulaInputGUI($this->lng->txt(
'range_upper_limit'),
"gap_" . $gapCounter .
"_numeric_upper");
738 $value =
new ilNumberInputGUI($this->lng->txt(
'value' ),
"gap_" . $gapCounter .
"_numeric");
741 $lowerbound =
new ilNumberInputGUI($this->lng->txt(
'range_lower_limit'),
"gap_" . $gapCounter .
"_numeric_lower");
744 $upperbound =
new ilNumberInputGUI($this->lng->txt(
'range_upper_limit'),
"gap_" . $gapCounter .
"_numeric_upper");
748 $value->setSize( 10 );
750 $value->setRequired(
true );
751 $form->addItem( $value );
753 $lowerbound->setSize( 10 );
754 $lowerbound->setRequired(
true );
756 $form->addItem( $lowerbound );
758 $upperbound->setSize( 10 );
759 $upperbound->setRequired(
true );
761 $form->addItem( $upperbound );
763 if( $this->object->getFixedTextLength() > 0 )
765 $value->setSize( $this->object->getFixedTextLength() );
766 $value->setMaxLength( $this->object->getFixedTextLength() );
767 $lowerbound->setSize( $this->object->getFixedTextLength() );
768 $lowerbound->setMaxLength( $this->object->getFixedTextLength() );
769 $upperbound->setSize( $this->object->getFixedTextLength() );
770 $upperbound->setMaxLength( $this->object->getFixedTextLength() );
773 $points =
new ilNumberInputGUI($this->lng->txt(
'points' ),
"gap_" . $gapCounter .
"_numeric_points");
775 $points->setSize( 3 );
776 $points->setRequired(
true );
778 $form->addItem( $points );
788 $this->
object->saveToDb();
798 $this->
object->deleteAnswerText($this->gapIndex, key(
$_POST[
'cmd'][
'removegap_' . $this->gapIndex]));
808 $this->
object->addGapAnswer($this->gapIndex, key(
$_POST[
'cmd'][
'addgap_' . $this->gapIndex])+1,
"");
820 function getPreview($show_question_only = FALSE, $showInlineFeedback =
false)
825 include_once
"./Services/UICore/classes/class.ilTemplate.php";
826 $template =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
827 $output = $this->
object->getClozeText();
828 foreach ($this->object->getGaps() as $gap_index => $gap)
830 switch ($gap->getType())
833 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_text.html", TRUE, TRUE,
"Modules/TestQuestionPool");
835 $gap_size = $gap->getGapSize() > 0 ? $gap->getGapSize() : $this->
object->getFixedTextLength();
838 $gaptemplate->setCurrentBlock(
'size_and_maxlength');
839 $gaptemplate->setVariable(
"TEXT_GAP_SIZE", $gap_size);
840 $gaptemplate->parseCurrentBlock();
842 $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
843 foreach ($user_solution as $val1 => $val2)
845 if (strcmp($val1, $gap_index) == 0)
850 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
853 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_select.html", TRUE, TRUE,
"Modules/TestQuestionPool");
854 foreach ($gap->getItems($this->object->getShuffler()) as $item)
856 $gaptemplate->setCurrentBlock(
"select_gap_option");
857 $gaptemplate->setVariable(
"SELECT_GAP_VALUE", $item->getOrder());
859 foreach ($user_solution as $val1 => $val2)
861 if (strcmp($val1, $gap_index) == 0)
863 if (strcmp($val2, $item->getOrder()) == 0)
865 $gaptemplate->setVariable(
"SELECT_GAP_SELECTED",
" selected=\"selected\"");
869 $gaptemplate->parseCurrentBlock();
871 $gaptemplate->setVariable(
"PLEASE_SELECT", $this->lng->txt(
"please_select"));
872 $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
873 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
876 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_numeric.html", TRUE, TRUE,
"Modules/TestQuestionPool");
877 $gap_size = $gap->getGapSize() > 0 ? $gap->getGapSize() : $this->
object->getFixedTextLength();
880 $gaptemplate->setCurrentBlock(
'size_and_maxlength');
881 $gaptemplate->setVariable(
"TEXT_GAP_SIZE", $gap_size);
882 $gaptemplate->parseCurrentBlock();
884 $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
885 foreach ($user_solution as $val1 => $val2)
887 if (strcmp($val1, $gap_index) == 0)
892 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
896 $template->setVariable(
"QUESTIONTEXT",$this->object->prepareTextareaOutput( $this->object->getQuestion(),
true));
897 $template->setVariable(
"CLOZETEXT", $this->object->prepareTextareaOutput($output, TRUE));
898 $questionoutput = $template->get();
899 if (!$show_question_only)
904 return $questionoutput;
925 $graphicalOutput = FALSE,
926 $result_output = FALSE,
927 $show_question_only = TRUE,
928 $show_feedback = FALSE,
929 $show_correct_solution = FALSE,
930 $show_manual_scoring = FALSE,
931 $show_question_text = TRUE
935 $user_solution = array();
936 if (($active_id > 0) && (!$show_correct_solution))
939 $user_solution =& $this->
object->getSolutionValues($active_id,
$pass);
940 if(!is_array($user_solution))
942 $user_solution = array();
946 include_once
"./Services/UICore/classes/class.ilTemplate.php";
947 $template =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
948 $output = $this->
object->getClozeText();
949 foreach ($this->object->getGaps() as $gap_index => $gap)
951 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_output_solution_gap.html", TRUE, TRUE,
"Modules/TestQuestionPool");
953 foreach ($user_solution as $solutionarray)
955 if ($solutionarray[
"value1"] == $gap_index) $found = $solutionarray;
960 if ($graphicalOutput)
963 $details = $this->
object->calculateReachedPoints($active_id,
$pass,
true, TRUE);
964 $check = $details[$gap_index];
967 $check_for_gap_combinations = $assClozeGapCombinationObject->loadFromDb($this->object->getId());
968 if(count($check_for_gap_combinations) != 0)
970 $gaps_used_in_combination = $assClozeGapCombinationObject->getGapsWhichAreUsedInCombination($this->object->getId());
971 $custom_user_solution = array();
972 if(array_key_exists($gap_index, $gaps_used_in_combination))
974 $combination_id = $gaps_used_in_combination[$gap_index];
975 foreach($gaps_used_in_combination as $key => $value)
978 if($value == $combination_id)
981 foreach($user_solution as $solution_key => $solution_value)
983 if($solution_value[
'value1'] == $key)
985 $result_row = array();
986 $result_row[
'gap_id'] = $solution_value[
'value1'];
987 $result_row[
'value'] = $solution_value[
'value2'];
988 array_push($custom_user_solution, $result_row);
993 $points_array = $this->
object->calculateCombinationResult($custom_user_solution);
994 $max_combination_points = $assClozeGapCombinationObject->getMaxPointsForCombination($this->object->getId(), $combination_id);
995 if($points_array[0] == $max_combination_points)
998 $gaptemplate->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
1000 else if($points_array[0] > 0)
1003 $gaptemplate->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
1008 $gaptemplate->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
1016 $gaptemplate->setCurrentBlock(
"icon_ok");
1018 $gaptemplate->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
1019 $gaptemplate->parseCurrentBlock();
1023 $gaptemplate->setCurrentBlock(
"icon_not_ok");
1024 if ($check[
"positive"])
1027 $gaptemplate->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
1032 $gaptemplate->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
1034 $gaptemplate->parseCurrentBlock();
1042 $gaptemplate->setCurrentBlock(
"icon_ok");
1044 $gaptemplate->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
1045 $gaptemplate->parseCurrentBlock();
1049 $gaptemplate->setCurrentBlock(
"icon_not_ok");
1050 if ($check[
"positive"])
1053 $gaptemplate->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
1058 $gaptemplate->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
1060 $gaptemplate->parseCurrentBlock();
1068 $points = $this->
object->getMaximumGapPoints($gap_index);
1069 $resulttext = ($points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
1070 $gaptemplate->setCurrentBlock(
"result_output");
1071 $gaptemplate->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $points));
1072 $gaptemplate->parseCurrentBlock();
1074 switch ($gap->getType())
1078 if (($active_id > 0) && (!$show_correct_solution))
1080 if ((count($found) == 0) || (strlen(trim($found[
"value2"])) == 0))
1082 for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++)
1084 $solutiontext .=
" ";
1095 $this->object->getShuffler()
1099 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
1103 if (($active_id > 0) && (!$show_correct_solution))
1105 if ((count($found) == 0) || (strlen(trim($found[
"value2"])) == 0))
1107 for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++)
1109 $solutiontext .=
" ";
1114 $item = $gap->getItem($found[
"value2"]);
1115 if (is_object($item))
1121 for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++)
1123 $solutiontext .=
" ";
1131 $this->object->getShuffler()
1135 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
1139 if (($active_id > 0) && (!$show_correct_solution))
1141 if ((count($found) == 0) || (strlen(trim($found[
"value2"])) == 0))
1143 for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++)
1145 $solutiontext .=
" ";
1156 $this->object->getShuffler()
1160 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
1165 if ($show_question_text)
1167 $template->setVariable(
1168 "QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(),
true)
1172 $template->setVariable(
"CLOZETEXT", $this->object->prepareTextareaOutput($output, TRUE));
1174 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
1175 $questionoutput = $template->get();
1183 $feedback .= strlen($fb) ? $fb :
'';
1187 $feedback .= strlen($fb) ? $fb :
'';
1189 if (strlen($feedback))
1195 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
1196 $solutiontemplate->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput( $feedback,
true ));
1199 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
1201 $solutionoutput = $solutiontemplate->get();
1203 if (!$show_question_only)
1206 $solutionoutput = $this->
getILIASPage($solutionoutput);
1209 return $solutionoutput;
1214 include_once
"./Modules/Test/classes/class.ilObjTest.php";
1216 if (strlen($manual_feedback))
1218 return $manual_feedback;
1221 $correct_feedback = $this->
object->feedbackOBJ->getGenericFeedbackTestPresentation($this->object->getId(),
true);
1222 $incorrect_feedback = $this->
object->feedbackOBJ->getGenericFeedbackTestPresentation($this->object->getId(),
false);
1223 if (strlen($correct_feedback.$incorrect_feedback))
1225 $reached_points = $this->
object->calculateReachedPoints($active_id,
$pass, (
bool)$useAuthorizedSolution);
1226 $max_points = $this->
object->getMaximumPoints();
1227 if ($reached_points == $max_points)
1229 $output .= $correct_feedback;
1233 $output .= $incorrect_feedback;
1237 return $this->
object->prepareTextareaOutput($output, TRUE);
1245 $is_postponed = FALSE,
1246 $use_post_solutions = FALSE,
1247 $show_feedback = FALSE
1251 $user_solution = array();
1255 #include_once "./Modules/Test/classes/class.ilObjTest.php"; 1256 #if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) 1258 # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id); 1262 if (!is_array($user_solution))
1264 $user_solution = array();
1269 include_once
"./Services/UICore/classes/class.ilTemplate.php";
1270 $template =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1271 $output = $this->
object->getClozeText();
1272 foreach ($this->object->getGaps() as $gap_index => $gap)
1274 switch ($gap->getType())
1277 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_text.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1278 $gap_size = $gap->getGapSize() > 0 ? $gap->getGapSize() : $this->
object->getFixedTextLength();
1282 $gaptemplate->setCurrentBlock(
'size_and_maxlength');
1283 $gaptemplate->setVariable(
"TEXT_GAP_SIZE", $gap_size);
1284 $gaptemplate->parseCurrentBlock();
1287 $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
1288 foreach ($user_solution as $solution)
1290 if (strcmp($solution[
"value1"], $gap_index) == 0)
1295 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
1298 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_select.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1299 foreach ($gap->getItems($this->object->getShuffler()) as $item)
1301 $gaptemplate->setCurrentBlock(
"select_gap_option");
1302 $gaptemplate->setVariable(
"SELECT_GAP_VALUE", $item->getOrder());
1304 foreach ($user_solution as $solution)
1306 if (strcmp($solution[
"value1"], $gap_index) == 0)
1308 if (strcmp($solution[
"value2"], $item->getOrder()) == 0)
1310 $gaptemplate->setVariable(
"SELECT_GAP_SELECTED",
" selected=\"selected\"");
1314 $gaptemplate->parseCurrentBlock();
1316 $gaptemplate->setVariable(
"PLEASE_SELECT", $this->lng->txt(
"please_select"));
1317 $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
1318 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
1321 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_numeric.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1322 $gap_size = $gap->getGapSize() > 0 ? $gap->getGapSize() : $this->
object->getFixedTextLength();
1325 $gaptemplate->setCurrentBlock(
'size_and_maxlength');
1326 $gaptemplate->setVariable(
"TEXT_GAP_SIZE", $gap_size);
1327 $gaptemplate->parseCurrentBlock();
1330 $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
1331 foreach ($user_solution as $solution)
1333 if (strcmp($solution[
"value1"], $gap_index) == 0)
1338 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
1343 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(),
true));
1344 $template->setVariable(
"CLOZETEXT", $this->object->prepareTextareaOutput($output, TRUE));
1345 $questionoutput = $template->get();
1346 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
1359 global $rbacsystem, $ilTabs;
1361 $ilTabs->clearTargets();
1363 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
1364 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
1365 $q_type = $this->
object->getQuestionType();
1367 if (strlen($q_type))
1369 $classname = $q_type .
"GUI";
1370 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
1371 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
1372 # $this->ctrl->setParameterByClass(strtolower($classname), 'prev_qid', $_REQUEST['prev_qid']); 1377 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
1380 $ilTabs->addTarget(
"edit_page",
1381 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
1382 array(
"edit",
"insert",
"exec_pg"),
1383 "",
"", $force_active);
1389 $force_active =
false;
1390 $commands =
$_POST[
"cmd"];
1391 if (is_array($commands))
1393 foreach ($commands as $key => $value)
1395 if (preg_match(
"/^removegap_.*/", $key, $matches) ||
1396 preg_match(
"/^addgap_.*/", $key, $matches)
1399 $force_active =
true;
1403 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
1406 if ($classname)
$url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
1408 $ilTabs->addTarget(
"edit_question",
1410 array(
"editQuestion",
"originalSyncForm",
"save",
"createGaps",
"saveEdit"),
1411 $classname,
"", $force_active);
1426 $ilTabs->addTarget(
"statistics",
1427 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
1428 array(
"assessment"),
1437 if( !$this->object->feedbackOBJ->specificAnswerFeedbackExists(array_values($this->object->gaps)) )
1444 $feedback =
'<table class="test_specific_feedback"><tbody>';
1446 foreach ($this->object->gaps as $index => $answer)
1448 $caption = $lng->txt(
'gap').
' '.($index+1) .
': ';
1450 $feedback .=
'<tr><td>';
1452 $feedback .= $caption .
'</td><td>';
1453 $feedback .= $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
1454 $this->object->getId(), $index
1457 $feedback .=
'</tbody></table>';
1459 return $this->
object->prepareTextareaOutput($feedback, TRUE);
1500 $overview = array();
1501 $aggregation = array();
1502 foreach ($relevant_answers as $answer)
1504 $overview[$answer[
'active_fi']][$answer[
'pass']][$answer[
'value1']] = $answer[
'value2'];
1507 foreach($overview as $active)
1509 foreach ($active as $answer)
1511 foreach ($answer as $option => $value)
1513 $aggregation[$option][$value] = $aggregation[$option][$value] + 1;
1520 foreach ($this->object->getGaps() as $gap)
1524 $html .=
'<p>Gap '. ($i+1) .
' - SELECT</p>';
1527 foreach($gap->getItems($this->object->getShuffler()) as $gap_item)
1529 $aggregate = $aggregation[$i];
1530 $html .=
'<li>' . $gap_item->getAnswerText() .
' - ' . ($aggregate[$j] ? $aggregate[$j] : 0) .
'</li>';
1538 $present_elements = array();
1542 $present_elements[] = $item->getAnswertext();
1545 $html .=
'<p>Gap ' . ($i+1) .
' - TEXT</p>';
1547 $aggregate = (array)$aggregation[$i];
1548 foreach($aggregate as $answer => $count)
1551 if(in_array($answer, $present_elements))
1553 $show_mover =
' style="display: none;" ';
1556 $html .=
'<li>' . $answer .
' - ' . $count
1557 .
' <button class="clone_fields_add btn btn-link" ' . $show_mover .
' data-answer="'.$answer.
'" name="add_gap_'.$i.
'_0"> 1558 <span class="sr-only"></span><span class="glyphicon glyphicon-plus"></span></button> 1566 $html .=
'<p>Gap ' . ($i+1) .
' - NUMERIC</p>';
1569 foreach($gap->getItems($this->object->getShuffler()) as $gap_item)
1571 $aggregate = (array)$aggregation[$i];
1572 foreach($aggregate as $answer => $count)
1574 $html .=
'<li>' . $answer .
' - ' . $count .
'</li>';
1590 $parts = explode(
'[gap', $question_text );
1592 $question_text =
'';
1593 foreach ( $parts as $part )
1597 $question_text .= $part;
1601 $question_text .=
'[gap ' . $i . $part;
1605 return $question_text;
1610 $parts = preg_split(
'/\[gap \d*\]/', $question_text );
1611 $question_text = implode(
'[gap]', $parts );
1612 return $question_text;
1623 $gaptemplate->setCurrentBlock(
'gap_span');
1624 $gaptemplate->setVariable(
'SPAN_SOLUTION', $solutiontext);
1628 $gaptemplate->setCurrentBlock(
'gap_select');
1629 $gaptemplate->setVariable(
'SELECT_SOLUTION', $solutiontext);
1633 $gap_size = $gap->getGapSize() > 0 ? $gap->getGapSize() : $this->
object->getFixedTextLength();
1637 $gaptemplate->setCurrentBlock(
'gap_size');
1638 $gaptemplate->setVariable(
"GAP_SIZE", $gap_size);
1639 $gaptemplate->parseCurrentBlock();
1642 $gaptemplate->setCurrentBlock(
'gap_input');
1643 $gaptemplate->setVariable(
'INPUT_SOLUTION', $solutiontext);
1647 $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.
writePostData()
Evaluates a posted edit form and writes the form data in the question object.
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
removeIndizesFromGapText( $question_text)
getAnswerFeedbackOutput($active_id, $pass)
const CLOZE_TEXT
Cloze question constants.
isLastSolutionSubmitAuthorized($active_id, $pass)
fetches solutions from database and prefers intermediate solutions, but falls back to authorized solu...
getTestOutputSolutions($activeId, $pass)
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.
editQuestion($checkonly=FALSE)
Creates an output of the edit form for the question.
populateTaxonomyFormSection(ilPropertyFormGUI $form)
getAfterParticipationSuppressionQuestionPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
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(!is_array($argv)) $options
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)
getTestOutput( $active_id, $pass, $is_postponed=FALSE, $use_post_solutions=FALSE, $show_feedback=FALSE)
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)
Evaluates a posted edit form and writes the form data in the question object.
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
setMaxLength($a_maxlength)
Set Max Length.
const CSS_CLASS_FEEDBACK_WRONG
isContentEditingOutputMode()
Basic GUI class for assessment questions.
applyIndizesToGapText( $question_text)
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.
removegap()
Remove a gap answer.
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.
saveTaxonomyAssignments()
__construct($id=-1)
assClozeTestGUI constructor
& _getUsedHTMLTags($a_module="")
Returns an array of all allowed HTML tags for text editing.
This class represents a text area property in a property form.
addBackTab(ilTabsGUI $ilTabs)
setInlineStyle($a_style)
Set inline style.
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.
addTab_SuggestedSolution(ilTabsGUI $tabs, $classname)
addQuestionFormCommandButtons($form)
Add the command buttons of a question properties form.