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";
44 $this->
object->loadFromDb($id);
50 if (preg_match(
"/^(removegap|addgap)_(\d+)$/",
$cmd, $matches))
53 $this->gapIndex = $matches[2];
63 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
66 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
68 $cloze_text = $this->
object->getHtmlQuestionContentPurifier()->purify(
$_POST[
'cloze_text']);
71 $_POST[
'cloze_text'] = $cloze_text;
72 $this->
object->setQuestion(
$_POST[
'question']);
75 $this->
object->setClozeText(
$_POST[
"cloze_text"]);
83 $cloze_text =
$_POST[
'cloze_text'];
85 $_POST[
'cloze_text'] = $cloze_text;
91 if (is_array(
$_POST[
'gap'] ))
93 if ( $this->ctrl->getCmd() !=
'createGaps' )
95 $this->
object->clearGapAnswers();
98 foreach (
$_POST[
'gap'] as $idx => $hidden)
100 $clozetype =
$_POST[
'clozetype_' . $idx];
102 $this->
object->setGapType( $idx, $clozetype );
108 $this->
object->setGapShuffle( $idx, 0 );
110 if ($this->ctrl->getCmd() !=
'createGaps')
112 if (is_array(
$_POST[
'gap_' . $idx][
'answer'] ))
114 foreach (
$_POST[
'gap_' . $idx][
'answer'] as $order => $value)
116 $this->
object->addGapAnswer( $idx, $order, $value );
121 $this->
object->addGapAnswer( $idx, 0,
'' );
125 if (is_array(
$_POST[
'gap_' . $idx][
'points'] ))
127 foreach (
$_POST[
'gap_' . $idx][
'points'] as $order => $value)
129 $this->
object->setGapAnswerPoints( $idx, $order, $value );
133 if (array_key_exists(
'gap_' . $idx .
'_gapsize',
$_POST ))
135 $this->
object->setGapSize($idx, $order,
$_POST[
'gap_' . $idx .
'_gapsize'] );
142 $this->
object->setGapShuffle( $idx, (
int)(isset(
$_POST[
"shuffle_$idx"]) &&
$_POST[
"shuffle_$idx"]) );
144 if ($this->ctrl->getCmd() !=
'createGaps')
146 if (is_array(
$_POST[
'gap_' . $idx][
'answer'] ))
148 foreach (
$_POST[
'gap_' . $idx][
'answer'] as $order => $value)
150 $this->
object->addGapAnswer( $idx, $order, $value );
155 $this->
object->addGapAnswer( $idx, 0,
'' );
159 if (is_array(
$_POST[
'gap_' . $idx][
'points'] ))
161 foreach (
$_POST[
'gap_' . $idx][
'points'] as $order => $value)
163 $this->
object->setGapAnswerPoints( $idx, $order, $value );
170 $this->
object->setGapShuffle( $idx, 0 );
172 $gap = $this->
object->getGap($idx);
175 $this->
object->getGap($idx)->clearItems();
177 if (array_key_exists(
'gap_' . $idx .
'_numeric',
$_POST ))
179 if ($this->ctrl->getCmd() !=
'createGaps')
181 $this->
object->addGapAnswer(
182 $idx, 0, str_replace(
",",
".",
$_POST[
'gap_' . $idx .
'_numeric'])
186 $this->
object->setGapAnswerLowerBound(
187 $idx, 0, str_replace(
",",
".",
$_POST[
'gap_' . $idx .
'_numeric_lower'])
190 $this->
object->setGapAnswerUpperBound(
191 $idx, 0, str_replace(
",",
".",
$_POST[
'gap_' . $idx .
'_numeric_upper'])
194 $this->
object->setGapAnswerPoints( $idx, 0,
$_POST[
'gap_' . $idx .
'_numeric_points'] );
198 if ($this->ctrl->getCmd() !=
'createGaps')
200 $this->
object->addGapAnswer($idx, 0,
'');
203 $this->
object->setGapAnswerLowerBound($idx, 0,
'');
205 $this->
object->setGapAnswerUpperBound($idx, 0,
'');
208 if (array_key_exists(
'gap_' . $idx .
'_gapsize',
$_POST ))
210 $this->
object->setGapSize($idx, $order,
$_POST[
'gap_' . $idx .
'_gapsize'] );
215 $assClozeGapCombinationObject->clearGapCombinationsFromDb($this->
object->getId());
216 if(is_array(
$_POST[
'gap_combination']) && count(
$_POST[
'gap_combination']) > 0)
221 if ($this->ctrl->getCmd() !=
'createGaps')
223 $this->
object->updateClozeTextFromGaps();
230 $this->
object->setClozeText(
$_POST[
'cloze_text'] );
231 $this->
object->setTextgapRating(
$_POST[
"textgap_rating"] );
232 $this->
object->setIdenticalScoring(
$_POST[
"identical_scoring"] );
233 $this->
object->setFixedTextLength(
$_POST[
"fixedTextLength"] );
246 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
248 $this->editForm = $form;
250 $form->setFormAction($this->ctrl->getFormAction($this));
252 $form->setMultipart(FALSE);
253 $form->setTableWidth(
"100%");
254 $form->setId(
"assclozetest");
268 $form->setValuesByPost();
269 $errors = !$form->checkInput();
270 $form->setValuesByPost();
272 if (
$errors) $checkonly =
false;
275 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
283 $title->setMaxLength(100);
285 $title->setRequired(TRUE);
288 if (!$this->
object->getSelfAssessmentEditingMode())
291 $author =
new ilTextInputGUI($this->lng->txt(
"author"),
"author");
293 $author->setRequired(TRUE);
294 $form->addItem($author);
297 $description =
new ilTextInputGUI($this->lng->txt(
"description"),
"comment");
299 $description->setRequired(FALSE);
300 $form->addItem($description);
307 if (trim($author) ==
"")
311 $hi->setValue($author);
318 $question->
setValue($this->
object->prepareTextareaOutput($this->object->getQuestion()));
319 $question->setRequired(TRUE);
320 $question->setRows(10);
321 $question->setCols(80);
322 if (!$this->
object->getSelfAssessmentEditingMode())
326 $question->setUseRte(TRUE);
327 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
329 $question->addPlugin(
"latex");
330 $question->addButton(
"latex");
331 $question->addButton(
"pastelatex");
332 $question->setRTESupport($this->
object->getId(),
"qpl",
"assessment");
337 require_once
'Modules/TestQuestionPool/classes/questions/class.ilAssSelfAssessmentQuestionFormatter.php';
339 $question->setUseTagsForRteOnly(
false);
341 $form->addItem($question);
351 if (!$this->
object->getSelfAssessmentEditingMode())
358 $ewt = $this->
object->getEstimatedWorkingTime();
368 if (strlen($this->
object->getNrOfTries()))
370 $nr_tries = $this->
object->getNrOfTries();
374 $nr_tries = $this->
object->getDefaultNrOfTries();
386 $ni =
new ilNumberInputGUI($this->lng->txt(
"qst_nr_of_tries"),
"nr_of_tries");
391 $ni->setMaxLength(5);
392 $ni->setRequired(
true);
403 $cloze_text->setInfo($this->lng->txt(
"close_text_hint"));
404 $cloze_text->setRows( 10 );
405 $cloze_text->setCols( 80 );
406 if (!$this->
object->getSelfAssessmentEditingMode())
410 $cloze_text->setUseRte(TRUE);
411 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
413 $cloze_text->addPlugin(
"latex");
414 $cloze_text->addButton(
"latex");
415 $cloze_text->addButton(
"pastelatex");
420 require_once
'Modules/TestQuestionPool/classes/questions/class.ilAssSelfAssessmentQuestionFormatter.php';
422 $cloze_text->setUseTagsForRteOnly(
false);
424 $cloze_text->setRTESupport($this->
object->getId(),
"qpl",
"assessment");
427 $tpl =
new ilTemplate(
"tpl.il_as_qpl_cloze_gap_button_code.html", TRUE, TRUE,
"Modules/TestQuestionPool");
430 require_once
'Services/UIComponent/SplitButton/classes/class.ilSplitButtonGUI.php';
431 require_once
'Services/UIComponent/Button/classes/class.ilJsLinkButton.php';
435 $sb_text_gap->setCaption(
'text_gap');
436 $sb_text_gap->setName(
'gapbutton');
437 $sb_text_gap->setId(
'gaptrigger_text');
438 $action_button->setDefaultButton($sb_text_gap);
441 $sb_sel_gap->setCaption(
'select_gap');
442 $sb_sel_gap->setName(
'gapbutton_select');
443 $sb_sel_gap->setId(
'gaptrigger_select');
447 $sb_num_gap->setCaption(
'numeric_gap');
448 $sb_num_gap->setName(
'gapbutton_numeric');
449 $sb_num_gap->setId(
'gaptrigger_numeric');
452 $tpl->setVariable(
'BUTTON', $action_button->render());
453 $tpl->parseCurrentBlock();
455 $button->setHtml(
$tpl->get());
459 if (!$this->
object->getSelfAssessmentEditingMode())
461 $textrating =
new ilSelectInputGUI($this->lng->txt(
"text_rating" ),
"textgap_rating");
462 $text_options =
array(
463 "ci" => $this->lng->txt(
"cloze_textgap_case_insensitive" ),
464 "cs" => $this->lng->txt(
"cloze_textgap_case_sensitive" ),
465 "l1" => sprintf( $this->lng->txt(
"cloze_textgap_levenshtein_of" ),
"1" ),
466 "l2" => sprintf( $this->lng->txt(
"cloze_textgap_levenshtein_of" ),
"2" ),
467 "l3" => sprintf( $this->lng->txt(
"cloze_textgap_levenshtein_of" ),
"3" ),
468 "l4" => sprintf( $this->lng->txt(
"cloze_textgap_levenshtein_of" ),
"4" ),
469 "l5" => sprintf( $this->lng->txt(
"cloze_textgap_levenshtein_of" ),
"5" )
471 $textrating->setOptions( $text_options );
472 $textrating->setValue( $this->
object->getTextgapRating() );
476 $fixedTextLength =
new ilNumberInputGUI($this->lng->txt(
"cloze_fixed_textlength" ),
"fixedTextLength");
477 $ftl = $this->
object->getFixedTextLength();
479 $fixedTextLength->
setValue( $ftl > 0 ? $ftl :
'' );
480 $fixedTextLength->setMinValue( 0 );
481 $fixedTextLength->setSize( 3 );
482 $fixedTextLength->setMaxLength( 6 );
483 $fixedTextLength->setInfo( $this->lng->txt(
'cloze_fixed_textlength_description' ) );
484 $fixedTextLength->setRequired(
false );
485 $form->
addItem( $fixedTextLength );
488 $identical_scoring =
new ilCheckboxInputGUI($this->lng->txt(
"identical_scoring" ),
"identical_scoring");
490 $identical_scoring->setChecked( $this->
object->getIdenticalScoring() );
491 $identical_scoring->setInfo( $this->lng->txt(
'identical_scoring_desc' ) );
492 $identical_scoring->setRequired( FALSE );
493 $form->
addItem( $identical_scoring );
500 if(self::OLD_CLOZE_TEST_UI)
502 for ($gapCounter = 0; $gapCounter < $this->
object->getGapCount(); $gapCounter++)
510 require_once
'Modules/TestQuestionPool/classes/Form/class.ilClozeGapInputBuilderGUI.php';
513 $combination_exists = $assClozeGapCombinationObject->combinationExistsForQid($this->
object->id);
514 if($combination_exists)
516 $combinations = $assClozeGapCombinationObject->loadFromDb($this->
object->id);
521 $new_builder->setValueByArray($json);
522 $new_builder->setValueCombinationFromDb($combinations);
530 $gap = $this->
object->getGaps();
536 $translate_type=
array(
'text',
'select',
'numeric');
538 foreach ($gap as $content)
541 $value=$content->getItemsRaw();
543 for($j=0;$j<count($value);$j++)
545 if($content->getType()==2)
548 'answer' => $value[$j]->getAnswerText(),
549 'lower' => $value[$j]->getLowerBound(),
550 'upper' => $value[$j]->getUpperBound(),
551 'points' => $value[$j]->getPoints(),
558 'answer' => $value[$j]->getAnswerText(),
559 'points' => $value[$j]->getPoints(),
563 if($content->getType()==1)
565 $shuffle=$content->getShuffle();
570 'type' => $translate_type[$content->getType()] ,
572 'shuffle' => $shuffle,
573 'text_field_length' => $content->getGapSize() > 0 ? $content->getGapSize() :
'',
574 'used_in_gap_combination' =>
true);
592 $gap = $this->
object->getGap( $gapCounter );
600 $header->setTitle( $this->lng->txt(
"gap" ) .
" " . ($gapCounter + 1) );
604 $gapcounter->setValue( $gapCounter );
605 $form->addItem( $gapcounter );
607 $gaptype =
new ilSelectInputGUI($this->lng->txt(
'type' ),
"clozetype_$gapCounter");
609 0 => $this->lng->txt(
"text_gap" ),
610 1 => $this->lng->txt(
"select_gap" ),
611 2 => $this->lng->txt(
"numeric_gap" )
613 $gaptype->setOptions( $options );
614 $gaptype->setValue( $gap->getType() );
615 $form->addItem( $gaptype );
621 if (count( $gap->getItemsRaw() ) == 0)
627 if (count( $gap->getItemsRaw() ) == 0)
635 if (count( $gap->getItemsRaw() ) == 0)
637 foreach ($gap->getItemsRaw() as $item)
652 $gapSizeFormItem =
new ilNumberInputGUI($this->lng->txt(
'cloze_fixed_textlength'),
"gap_".$gapCounter.
'_gapsize');
654 $gapSizeFormItem->allowDecimals(
false);
655 $gapSizeFormItem->setMinValue(0);
656 $gapSizeFormItem->setSize( 3 );
657 $gapSizeFormItem->setMaxLength( 6 );
658 $gapSizeFormItem->setInfo($this->lng->txt(
'cloze_gap_size_info'));
659 $gapSizeFormItem->setValue($gap->getGapSize());
660 $form->addItem($gapSizeFormItem);
679 include_once
"./Modules/TestQuestionPool/classes/class.ilAnswerWizardInputGUI.php";
680 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
683 $values->setQuestionObject( $this->
object );
684 $values->setSingleline(
true );
685 $values->setAllowMove(
false );
687 $values->setValues( $gap->getItemsRaw() );
688 $form->addItem( $values );
691 $shuffle =
new ilCheckboxInputGUI($this->lng->txt(
"shuffle_answers" ),
"shuffle_" . $gapCounter .
"");
693 $shuffle->setChecked( $gap->getShuffle() );
694 $shuffle->setRequired( FALSE );
695 $form->addItem( $shuffle );
713 include_once
"./Modules/TestQuestionPool/classes/class.ilAnswerWizardInputGUI.php";
714 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
717 $values->setQuestionObject( $this->
object );
718 $values->setSingleline(
true );
719 $values->setAllowMove(
false );
720 $values->setValues( $gap->getItemsRaw() );
721 $form->addItem( $values );
723 if( $this->
object->getFixedTextLength() > 0 )
725 $values->setSize( $this->
object->getFixedTextLength() );
726 $values->setMaxLength( $this->
object->getFixedTextLength() );
746 if (!$this->
object->getSelfAssessmentEditingMode())
748 $value =
new ilFormulaInputGUI($this->lng->txt(
'value' ),
"gap_" . $gapCounter .
"_numeric");
751 $lowerbound =
new ilFormulaInputGUI($this->lng->txt(
'range_lower_limit'),
"gap_" . $gapCounter .
"_numeric_lower");
754 $upperbound =
new ilFormulaInputGUI($this->lng->txt(
'range_upper_limit'),
"gap_" . $gapCounter .
"_numeric_upper");
759 $value =
new ilNumberInputGUI($this->lng->txt(
'value' ),
"gap_" . $gapCounter .
"_numeric");
762 $lowerbound =
new ilNumberInputGUI($this->lng->txt(
'range_lower_limit'),
"gap_" . $gapCounter .
"_numeric_lower");
765 $upperbound =
new ilNumberInputGUI($this->lng->txt(
'range_upper_limit'),
"gap_" . $gapCounter .
"_numeric_upper");
769 $value->setSize( 10 );
771 $value->setRequired(
true );
772 $form->addItem( $value );
774 $lowerbound->setSize( 10 );
775 $lowerbound->setRequired(
true );
777 $form->addItem( $lowerbound );
779 $upperbound->setSize( 10 );
780 $upperbound->setRequired(
true );
782 $form->addItem( $upperbound );
784 if( $this->
object->getFixedTextLength() > 0 )
786 $value->setSize( $this->
object->getFixedTextLength() );
787 $value->setMaxLength( $this->
object->getFixedTextLength() );
788 $lowerbound->setSize( $this->
object->getFixedTextLength() );
789 $lowerbound->setMaxLength( $this->
object->getFixedTextLength() );
790 $upperbound->setSize( $this->
object->getFixedTextLength() );
791 $upperbound->setMaxLength( $this->
object->getFixedTextLength() );
794 $points =
new ilNumberInputGUI($this->lng->txt(
'points' ),
"gap_" . $gapCounter .
"_numeric_points");
796 $points->setSize( 3 );
797 $points->setRequired(
true );
799 $form->addItem( $points );
809 $this->
object->saveToDb();
819 $this->
object->deleteAnswerText($this->gapIndex, key(
$_POST[
'cmd'][
'removegap_' . $this->gapIndex]));
829 $this->
object->addGapAnswer($this->gapIndex, key(
$_POST[
'cmd'][
'addgap_' . $this->gapIndex])+1,
"");
841 function getPreview($show_question_only = FALSE, $showInlineFeedback =
false)
846 include_once
"./Services/UICore/classes/class.ilTemplate.php";
847 $template =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
848 $output = $this->
object->getClozeText();
849 foreach ($this->
object->getGaps() as $gap_index => $gap)
851 switch ($gap->getType())
854 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_text.html", TRUE, TRUE,
"Modules/TestQuestionPool");
856 $gap_size = $gap->getGapSize() > 0 ? $gap->getGapSize() : $this->
object->getFixedTextLength();
859 $gaptemplate->setCurrentBlock(
'size_and_maxlength');
860 $gaptemplate->setVariable(
"TEXT_GAP_SIZE", $gap_size);
861 $gaptemplate->parseCurrentBlock();
863 $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
864 foreach ($user_solution as $val1 => $val2)
866 if (strcmp($val1, $gap_index) == 0)
871 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(),
$output, 1);
874 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_select.html", TRUE, TRUE,
"Modules/TestQuestionPool");
875 foreach ($gap->getItems($this->object->getShuffler()) as $item)
877 $gaptemplate->setCurrentBlock(
"select_gap_option");
878 $gaptemplate->setVariable(
"SELECT_GAP_VALUE", $item->getOrder());
880 foreach ($user_solution as $val1 => $val2)
882 if (strcmp($val1, $gap_index) == 0)
884 if (strcmp($val2, $item->getOrder()) == 0)
886 $gaptemplate->setVariable(
"SELECT_GAP_SELECTED",
" selected=\"selected\"");
890 $gaptemplate->parseCurrentBlock();
892 $gaptemplate->setVariable(
"PLEASE_SELECT", $this->lng->txt(
"please_select"));
893 $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
894 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(),
$output, 1);
897 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_numeric.html", TRUE, TRUE,
"Modules/TestQuestionPool");
898 $gap_size = $gap->getGapSize() > 0 ? $gap->getGapSize() : $this->
object->getFixedTextLength();
901 $gaptemplate->setCurrentBlock(
'size_and_maxlength');
902 $gaptemplate->setVariable(
"TEXT_GAP_SIZE", $gap_size);
903 $gaptemplate->parseCurrentBlock();
905 $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
906 foreach ($user_solution as $val1 => $val2)
908 if (strcmp($val1, $gap_index) == 0)
913 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(),
$output, 1);
917 $template->setVariable(
"QUESTIONTEXT",$this->
object->prepareTextareaOutput( $this->object->getQuestion(),
true));
918 $template->setVariable(
"CLOZETEXT", $this->
object->prepareTextareaOutput(
$output, TRUE));
919 $questionoutput = $template->get();
920 if (!$show_question_only)
925 return $questionoutput;
946 $graphicalOutput = FALSE,
947 $result_output = FALSE,
948 $show_question_only = TRUE,
949 $show_feedback = FALSE,
950 $show_correct_solution = FALSE,
951 $show_manual_scoring = FALSE,
952 $show_question_text = TRUE
956 $user_solution =
array();
957 if (($active_id > 0) && (!$show_correct_solution))
960 $user_solution =& $this->
object->getSolutionValues($active_id,
$pass);
961 if(!is_array($user_solution))
963 $user_solution =
array();
967 include_once
"./Services/UICore/classes/class.ilTemplate.php";
968 $template =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
969 $output = $this->
object->getClozeText();
971 $check_for_gap_combinations = $assClozeGapCombinationObject->loadFromDb($this->
object->getId());
973 foreach ($this->
object->getGaps() as $gap_index => $gap)
975 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_output_solution_gap.html", TRUE, TRUE,
"Modules/TestQuestionPool");
977 foreach ($user_solution as $solutionarray)
979 if ($solutionarray[
"value1"] == $gap_index) $found = $solutionarray;
984 if ($graphicalOutput)
987 $details = $this->
object->calculateReachedPoints($active_id,
$pass,
true, TRUE);
988 $check = $details[$gap_index];
990 if(count($check_for_gap_combinations) != 0)
992 $gaps_used_in_combination = $assClozeGapCombinationObject->getGapsWhichAreUsedInCombination($this->
object->getId());
993 $custom_user_solution =
array();
994 if(array_key_exists($gap_index, $gaps_used_in_combination))
996 $combination_id = $gaps_used_in_combination[$gap_index];
997 foreach($gaps_used_in_combination as $key => $value)
1000 if($value == $combination_id)
1003 foreach($user_solution as $solution_key => $solution_value)
1005 if($solution_value[
'value1'] == $key)
1007 $result_row =
array();
1008 $result_row[
'gap_id'] = $solution_value[
'value1'];
1009 $result_row[
'value'] = $solution_value[
'value2'];
1010 array_push($custom_user_solution, $result_row);
1015 $points_array = $this->
object->calculateCombinationResult($custom_user_solution);
1016 $max_combination_points = $assClozeGapCombinationObject->getMaxPointsForCombination($this->
object->getId(), $combination_id);
1017 if($points_array[0] == $max_combination_points)
1020 $gaptemplate->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
1022 else if($points_array[0] > 0)
1025 $gaptemplate->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
1030 $gaptemplate->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
1038 $gaptemplate->setCurrentBlock(
"icon_ok");
1040 $gaptemplate->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
1041 $gaptemplate->parseCurrentBlock();
1045 $gaptemplate->setCurrentBlock(
"icon_not_ok");
1046 if ($check[
"positive"])
1049 $gaptemplate->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
1054 $gaptemplate->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
1056 $gaptemplate->parseCurrentBlock();
1064 $gaptemplate->setCurrentBlock(
"icon_ok");
1066 $gaptemplate->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
1067 $gaptemplate->parseCurrentBlock();
1071 $gaptemplate->setCurrentBlock(
"icon_not_ok");
1072 if ($check[
"positive"])
1075 $gaptemplate->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
1080 $gaptemplate->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
1082 $gaptemplate->parseCurrentBlock();
1090 $points = $this->
object->getMaximumGapPoints($gap_index);
1091 $resulttext = ($points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
1092 $gaptemplate->setCurrentBlock(
"result_output");
1093 $gaptemplate->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $points));
1094 $gaptemplate->parseCurrentBlock();
1096 $combination = null;
1097 switch ($gap->getType())
1101 if (($active_id > 0) && (!$show_correct_solution))
1103 if ((count($found) == 0) || (strlen(trim($found[
"value2"])) == 0))
1105 for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++)
1107 $solutiontext .=
" ";
1117 $solutiontext = $this->
getBestSolutionText($gap, $gap_index, $check_for_gap_combinations);
1120 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(),
$output, 1);
1124 if (($active_id > 0) && (!$show_correct_solution))
1126 if ((count($found) == 0) || (strlen(trim($found[
"value2"])) == 0))
1128 for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++)
1130 $solutiontext .=
" ";
1135 $item = $gap->getItem($found[
"value2"]);
1136 if (is_object($item))
1142 for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++)
1144 $solutiontext .=
" ";
1151 $solutiontext = $this->
getBestSolutionText($gap, $gap_index, $check_for_gap_combinations);
1154 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(),
$output, 1);
1158 if (($active_id > 0) && (!$show_correct_solution))
1160 if ((count($found) == 0) || (strlen(trim($found[
"value2"])) == 0))
1162 for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++)
1164 $solutiontext .=
" ";
1174 $solutiontext = $this->
getBestSolutionText($gap, $gap_index, $check_for_gap_combinations);
1177 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(),
$output, 1);
1182 if ($show_question_text)
1184 $template->setVariable(
1185 "QUESTIONTEXT", $this->
object->prepareTextareaOutput($this->object->getQuestion(),
true)
1189 $template->setVariable(
"CLOZETEXT", $this->
object->prepareTextareaOutput(
$output, TRUE));
1191 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
1192 $questionoutput = $template->get();
1200 $feedback .= strlen($fb) ? $fb :
'';
1204 $feedback .= strlen($fb) ? $fb :
'';
1206 if (strlen($feedback))
1212 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
1213 $solutiontemplate->setVariable(
"FEEDBACK", $this->
object->prepareTextareaOutput( $feedback,
true ));
1216 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
1218 $solutionoutput = $solutiontemplate->get();
1220 if (!$show_question_only)
1223 $solutionoutput = $this->
getILIASPage($solutionoutput);
1226 return $solutionoutput;
1237 $combination = null;
1238 foreach((
array)$gap_combinations as $combiGapSolRow)
1240 if($combiGapSolRow[
'gap_fi'] == $gap_index)
1242 $combination = $combiGapSolRow;
1247 $this->object->getShuffler(), $combination
1249 return $best_solution_text;
1254 include_once
"./Modules/Test/classes/class.ilObjTest.php";
1256 if (strlen($manual_feedback))
1258 return $manual_feedback;
1260 $correct_feedback = $this->
object->feedbackOBJ->getGenericFeedbackTestPresentation($this->
object->getId(),
true);
1261 $incorrect_feedback = $this->
object->feedbackOBJ->getGenericFeedbackTestPresentation($this->
object->getId(),
false);
1262 if (strlen($correct_feedback.$incorrect_feedback))
1264 $reached_points = $this->
object->calculateReachedPoints($active_id,
$pass);
1265 $max_points = $this->
object->getMaximumPoints();
1266 if ($reached_points == $max_points)
1272 $output .= $incorrect_feedback;
1276 return $this->
object->prepareTextareaOutput(
$output, TRUE);
1284 $is_postponed = FALSE,
1285 $use_post_solutions = FALSE,
1286 $show_feedback = FALSE
1290 $user_solution =
array();
1291 if($use_post_solutions !==
false)
1293 $indexedSolution = $this->
object->fetchSolutionSubmit($use_post_solutions);
1294 $user_solution = $this->
object->fetchValuePairsFromIndexedValues($indexedSolution);
1299 #include_once "./Modules/Test/classes/class.ilObjTest.php"; 1300 #if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) 1302 # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id); 1304 $user_solution = $this->
object->getTestOutputSolutions($active_id,
$pass);
1306 if (!is_array($user_solution))
1308 $user_solution =
array();
1313 include_once
"./Services/UICore/classes/class.ilTemplate.php";
1314 $template =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1315 $output = $this->
object->getClozeText();
1316 foreach ($this->
object->getGaps() as $gap_index => $gap)
1318 switch ($gap->getType())
1321 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_text.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1322 $gap_size = $gap->getGapSize() > 0 ? $gap->getGapSize() : $this->
object->getFixedTextLength();
1326 $gaptemplate->setCurrentBlock(
'size_and_maxlength');
1327 $gaptemplate->setVariable(
"TEXT_GAP_SIZE", $gap_size);
1328 $gaptemplate->parseCurrentBlock();
1331 $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
1332 foreach ($user_solution as $solution)
1334 if (strcmp($solution[
"value1"], $gap_index) == 0)
1339 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(),
$output, 1);
1342 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_select.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1343 foreach ($gap->getItems($this->object->getShuffler()) as $item)
1345 $gaptemplate->setCurrentBlock(
"select_gap_option");
1346 $gaptemplate->setVariable(
"SELECT_GAP_VALUE", $item->getOrder());
1348 foreach ($user_solution as $solution)
1350 if (strcmp($solution[
"value1"], $gap_index) == 0)
1352 if (strcmp($solution[
"value2"], $item->getOrder()) == 0)
1354 $gaptemplate->setVariable(
"SELECT_GAP_SELECTED",
" selected=\"selected\"");
1358 $gaptemplate->parseCurrentBlock();
1360 $gaptemplate->setVariable(
"PLEASE_SELECT", $this->lng->txt(
"please_select"));
1361 $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
1362 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(),
$output, 1);
1365 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_numeric.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1366 $gap_size = $gap->getGapSize() > 0 ? $gap->getGapSize() : $this->
object->getFixedTextLength();
1369 $gaptemplate->setCurrentBlock(
'size_and_maxlength');
1370 $gaptemplate->setVariable(
"TEXT_GAP_SIZE", $gap_size);
1371 $gaptemplate->parseCurrentBlock();
1374 $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
1375 foreach ($user_solution as $solution)
1377 if (strcmp($solution[
"value1"], $gap_index) == 0)
1382 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(),
$output, 1);
1387 $template->setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($this->object->getQuestion(),
true));
1388 $template->setVariable(
"CLOZETEXT", $this->
object->prepareTextareaOutput(
$output, TRUE));
1389 $questionoutput = $template->get();
1390 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
1403 global $rbacsystem, $ilTabs;
1405 $ilTabs->clearTargets();
1407 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
1408 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
1409 $q_type = $this->
object->getQuestionType();
1411 if (strlen($q_type))
1413 $classname = $q_type .
"GUI";
1414 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
1415 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
1416 # $this->ctrl->setParameterByClass(strtolower($classname), 'prev_qid', $_REQUEST['prev_qid']); 1421 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
1424 $ilTabs->addTarget(
"edit_page",
1425 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
1426 array(
"edit",
"insert",
"exec_pg"),
1427 "",
"", $force_active);
1433 $force_active =
false;
1434 $commands =
$_POST[
"cmd"];
1435 if (is_array($commands))
1437 foreach ($commands as $key => $value)
1439 if (preg_match(
"/^removegap_.*/", $key, $matches) ||
1440 preg_match(
"/^addgap_.*/", $key, $matches)
1443 $force_active =
true;
1447 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
1450 if ($classname)
$url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
1452 $ilTabs->addTarget(
"edit_question",
1454 array(
"editQuestion",
"originalSyncForm",
"save",
"createGaps",
"saveEdit"),
1455 $classname,
"", $force_active);
1470 $ilTabs->addTarget(
"statistics",
1471 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
1472 array(
"assessment"),
1481 if( !$this->
object->feedbackOBJ->specificAnswerFeedbackExists(array_values($this->
object->gaps)) )
1488 $feedback =
'<table class="test_specific_feedback"><tbody>';
1490 foreach ($this->
object->gaps as $index => $answer)
1492 $caption = $lng->txt(
'gap').
' '.($index+1) .
': ';
1494 $feedback .=
'<tr><td>';
1496 $feedback .= $caption .
'</td><td>';
1497 $feedback .= $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
1498 $this->
object->getId(), $index
1501 $feedback .=
'</tbody></table>';
1503 return $this->
object->prepareTextareaOutput($feedback, TRUE);
1544 $overview =
array();
1545 $aggregation =
array();
1546 foreach ($relevant_answers as $answer)
1548 $overview[$answer[
'active_fi']][$answer[
'pass']][$answer[
'value1']] = $answer[
'value2'];
1551 foreach($overview as $active)
1553 foreach ($active as $answer)
1555 foreach ($answer as $option => $value)
1557 $aggregation[$option][$value] = $aggregation[$option][$value] + 1;
1564 foreach ($this->
object->getGaps() as $gap)
1568 $html .=
'<p>Gap '. ($i+1) .
' - SELECT</p>';
1571 foreach($gap->getItems($this->object->getShuffler()) as $gap_item)
1573 $aggregate = $aggregation[$i];
1582 $present_elements =
array();
1586 $present_elements[] = $item->getAnswertext();
1589 $html .=
'<p>Gap ' . ($i+1) .
' - TEXT</p>';
1591 $aggregate = (
array)$aggregation[$i];
1592 foreach($aggregate as $answer => $count)
1595 if(in_array($answer, $present_elements))
1597 $show_mover =
' style="display: none;" ';
1601 .
' <button class="clone_fields_add btn btn-link" ' . $show_mover .
' data-answer="'.ilUtil::prepareFormOutput($answer).
'" name="add_gap_'.$i.
'_0"> 1602 <span class="sr-only"></span><span class="glyphicon glyphicon-plus"></span></button> 1610 $html .=
'<p>Gap ' . ($i+1) .
' - NUMERIC</p>';
1613 foreach($gap->getItems($this->object->getShuffler()) as $gap_item)
1615 $aggregate = (
array)$aggregation[$i];
1616 foreach($aggregate as $answer => $count)
1634 $parts = explode(
'[gap', $question_text );
1636 $question_text =
'';
1637 foreach ( $parts as $part )
1641 $question_text .= $part;
1645 $question_text .=
'[gap ' . $i . $part;
1649 return $question_text;
1654 $parts = preg_split(
'/\[gap \d*\]/', $question_text );
1655 $question_text = implode(
'[gap]', $parts );
1656 return $question_text;
1667 $gaptemplate->setCurrentBlock(
'gap_span');
1668 $gaptemplate->setVariable(
'SPAN_SOLUTION', $solutiontext);
1672 $gaptemplate->setCurrentBlock(
'gap_select');
1673 $gaptemplate->setVariable(
'SELECT_SOLUTION', $solutiontext);
1677 $gap_size = $gap->getGapSize() > 0 ? $gap->getGapSize() : $this->
object->getFixedTextLength();
1681 $gaptemplate->setCurrentBlock(
'gap_size');
1682 $gaptemplate->setVariable(
"GAP_SIZE", $gap_size);
1683 $gaptemplate->parseCurrentBlock();
1686 $gaptemplate->setCurrentBlock(
'gap_input');
1687 $gaptemplate->setVariable(
'INPUT_SOLUTION', $solutiontext);
1691 $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
removeIndizesFromGapText( $question_text)
getAnswerFeedbackOutput($active_id, $pass)
const CLOZE_TEXT
Cloze question constants.
static _getUsedHTMLTags($a_module="")
Returns an array of all allowed HTML tags for text editing.
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)
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(!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)
{}
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.
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.
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.
saveTaxonomyAssignments()
__construct($id=-1)
assClozeTestGUI constructor
Create new PHPExcel object
obj_idprivate
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.
addTab_SuggestedSolution(ilTabsGUI $tabs, $classname)
addQuestionFormCommandButtons($form)
Add the command buttons of a question properties form.
renderPurposeSupportsFormHtml()