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 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 $question->setRteTags(self::getSelfAssessmentTags());
340 $question->setUseTagsForRteOnly(
false);
342 $form->addItem($question);
352 if (!$this->object->getSelfAssessmentEditingMode())
357 $duration->setShowMinutes(TRUE);
358 $duration->setShowSeconds(TRUE);
359 $ewt = $this->
object->getEstimatedWorkingTime();
360 $duration->setHours($ewt[
"h"]);
361 $duration->setMinutes($ewt[
"m"]);
362 $duration->setSeconds($ewt[
"s"]);
363 $duration->setRequired(FALSE);
364 $form->addItem($duration);
369 if (strlen($this->object->getNrOfTries()))
371 $nr_tries = $this->
object->getNrOfTries();
375 $nr_tries = $this->
object->getDefaultNrOfTries();
387 $ni =
new ilNumberInputGUI($this->lng->txt(
"qst_nr_of_tries"),
"nr_of_tries");
392 $ni->setMaxLength(5);
393 $ni->setRequired(
true);
404 $cloze_text->setInfo($this->lng->txt(
"close_text_hint"));
405 $cloze_text->setRows( 10 );
406 $cloze_text->setCols( 80 );
407 if (!$this->object->getSelfAssessmentEditingMode())
411 $cloze_text->setUseRte(TRUE);
412 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
414 $cloze_text->addPlugin(
"latex");
415 $cloze_text->addButton(
"latex");
416 $cloze_text->addButton(
"pastelatex");
421 $cloze_text->setRteTags(self::getSelfAssessmentTags());
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");
428 $tpl->setVariable(
'INSERT_GAP', $this->lng->txt(
'insert_gap'));
429 $tpl->setVariable(
'CREATE_GAPS', $this->lng->txt(
'create_gaps'));
430 $tpl->parseCurrentBlock();
432 $button->setHtml(
$tpl->get());
436 if (!$this->object->getSelfAssessmentEditingMode())
438 $textrating =
new ilSelectInputGUI($this->lng->txt(
"text_rating" ),
"textgap_rating");
439 $text_options = array(
440 "ci" => $this->lng->txt(
"cloze_textgap_case_insensitive" ),
441 "cs" => $this->lng->txt(
"cloze_textgap_case_sensitive" ),
442 "l1" => sprintf( $this->lng->txt(
"cloze_textgap_levenshtein_of" ),
"1" ),
443 "l2" => sprintf( $this->lng->txt(
"cloze_textgap_levenshtein_of" ),
"2" ),
444 "l3" => sprintf( $this->lng->txt(
"cloze_textgap_levenshtein_of" ),
"3" ),
445 "l4" => sprintf( $this->lng->txt(
"cloze_textgap_levenshtein_of" ),
"4" ),
446 "l5" => sprintf( $this->lng->txt(
"cloze_textgap_levenshtein_of" ),
"5" )
448 $textrating->setOptions( $text_options );
449 $textrating->setValue( $this->object->getTextgapRating() );
453 $fixedTextLength =
new ilNumberInputGUI($this->lng->txt(
"cloze_fixed_textlength" ),
"fixedTextLength");
454 $ftl = $this->
object->getFixedTextLength();
456 $fixedTextLength->
setValue( $ftl > 0 ? $ftl :
'' );
457 $fixedTextLength->setMinValue( 0 );
458 $fixedTextLength->setSize( 3 );
459 $fixedTextLength->setMaxLength( 6 );
460 $fixedTextLength->setInfo( $this->lng->txt(
'cloze_fixed_textlength_description' ) );
461 $fixedTextLength->setRequired(
false );
462 $form->
addItem( $fixedTextLength );
465 $identical_scoring =
new ilCheckboxInputGUI($this->lng->txt(
"identical_scoring" ),
"identical_scoring");
467 $identical_scoring->setChecked( $this->object->getIdenticalScoring() );
468 $identical_scoring->setInfo( $this->lng->txt(
'identical_scoring_desc' ) );
469 $identical_scoring->setRequired( FALSE );
470 $form->
addItem( $identical_scoring );
477 if(self::OLD_CLOZE_TEST_UI)
479 for ($gapCounter = 0; $gapCounter < $this->
object->getGapCount(); $gapCounter++)
487 require_once
'Modules/TestQuestionPool/classes/Form/class.ilClozeGapInputBuilderGUI.php';
490 $combination_exists = $assClozeGapCombinationObject->combinationExistsForQid($this->object->id);
491 if($combination_exists)
493 $combinations = $assClozeGapCombinationObject->loadFromDb($this->object->id);
498 $new_builder->setValueByArray($json);
499 $new_builder->setValueCombinationFromDb($combinations);
507 $gap = $this->
object->getGaps();
513 $translate_type=array(
'text',
'select',
'numeric');
515 foreach ($gap as $content)
518 $value=$content->getItemsRaw();
520 for($j=0;$j<count($value);$j++)
522 if($content->getType()==2)
525 'answer' => $value[$j]->getAnswerText(),
526 'lower' => $value[$j]->getLowerBound(),
527 'upper' => $value[$j]->getUpperBound(),
528 'points' => $value[$j]->getPoints(),
535 'answer' => $value[$j]->getAnswerText(),
536 'points' => $value[$j]->getPoints(),
540 if($content->getType()==1)
542 $shuffle=$content->getShuffle();
547 'type' => $translate_type[$content->getType()] ,
549 'shuffle' => $shuffle,
550 'text_field_length' => $content->getGapSize() > 0 ? $content->getGapSize() :
'',
551 'used_in_gap_combination' =>
true);
569 $gap = $this->
object->getGap( $gapCounter );
577 $header->setTitle( $this->lng->txt(
"gap" ) .
" " . ($gapCounter + 1) );
578 $form->addItem( $header );
581 $gapcounter->setValue( $gapCounter );
582 $form->addItem( $gapcounter );
584 $gaptype =
new ilSelectInputGUI($this->lng->txt(
'type' ),
"clozetype_$gapCounter");
586 0 => $this->lng->txt(
"text_gap" ),
587 1 => $this->lng->txt(
"select_gap" ),
588 2 => $this->lng->txt(
"numeric_gap" )
590 $gaptype->setOptions( $options );
591 $gaptype->setValue( $gap->getType() );
592 $form->addItem( $gaptype );
598 if (count( $gap->getItemsRaw() ) == 0)
604 if (count( $gap->getItemsRaw() ) == 0)
612 if (count( $gap->getItemsRaw() ) == 0)
614 foreach ($gap->getItemsRaw() as $item)
629 $gapSizeFormItem =
new ilNumberInputGUI($this->lng->txt(
'cloze_fixed_textlength'),
"gap_".$gapCounter.
'_gapsize');
631 $gapSizeFormItem->allowDecimals(
false);
632 $gapSizeFormItem->setMinValue(0);
633 $gapSizeFormItem->setSize( 3 );
634 $gapSizeFormItem->setMaxLength( 6 );
635 $gapSizeFormItem->setInfo($this->lng->txt(
'cloze_gap_size_info'));
636 $gapSizeFormItem->setValue($gap->getGapSize());
637 $form->addItem($gapSizeFormItem);
656 include_once
"./Modules/TestQuestionPool/classes/class.ilAnswerWizardInputGUI.php";
657 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
660 $values->setQuestionObject( $this->
object );
661 $values->setSingleline(
true );
662 $values->setAllowMove(
false );
664 $values->setValues( $gap->getItemsRaw() );
665 $form->addItem( $values );
668 $shuffle =
new ilCheckboxInputGUI($this->lng->txt(
"shuffle_answers" ),
"shuffle_" . $gapCounter .
"");
670 $shuffle->setChecked( $gap->getShuffle() );
671 $shuffle->setRequired( FALSE );
672 $form->addItem( $shuffle );
690 include_once
"./Modules/TestQuestionPool/classes/class.ilAnswerWizardInputGUI.php";
691 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
694 $values->setQuestionObject( $this->
object );
695 $values->setSingleline(
true );
696 $values->setAllowMove(
false );
697 $values->setValues( $gap->getItemsRaw() );
698 $form->addItem( $values );
700 if( $this->object->getFixedTextLength() > 0 )
702 $values->setSize( $this->object->getFixedTextLength() );
703 $values->setMaxLength( $this->object->getFixedTextLength() );
723 if (!$this->object->getSelfAssessmentEditingMode())
725 $value =
new ilFormulaInputGUI($this->lng->txt(
'value' ),
"gap_" . $gapCounter .
"_numeric");
728 $lowerbound =
new ilFormulaInputGUI($this->lng->txt(
'range_lower_limit'),
"gap_" . $gapCounter .
"_numeric_lower");
731 $upperbound =
new ilFormulaInputGUI($this->lng->txt(
'range_upper_limit'),
"gap_" . $gapCounter .
"_numeric_upper");
736 $value =
new ilNumberInputGUI($this->lng->txt(
'value' ),
"gap_" . $gapCounter .
"_numeric");
739 $lowerbound =
new ilNumberInputGUI($this->lng->txt(
'range_lower_limit'),
"gap_" . $gapCounter .
"_numeric_lower");
742 $upperbound =
new ilNumberInputGUI($this->lng->txt(
'range_upper_limit'),
"gap_" . $gapCounter .
"_numeric_upper");
746 $value->setSize( 10 );
748 $value->setRequired(
true );
749 $form->addItem( $value );
751 $lowerbound->setSize( 10 );
752 $lowerbound->setRequired(
true );
754 $form->addItem( $lowerbound );
756 $upperbound->setSize( 10 );
757 $upperbound->setRequired(
true );
759 $form->addItem( $upperbound );
761 if( $this->object->getFixedTextLength() > 0 )
763 $value->setSize( $this->object->getFixedTextLength() );
764 $value->setMaxLength( $this->object->getFixedTextLength() );
765 $lowerbound->setSize( $this->object->getFixedTextLength() );
766 $lowerbound->setMaxLength( $this->object->getFixedTextLength() );
767 $upperbound->setSize( $this->object->getFixedTextLength() );
768 $upperbound->setMaxLength( $this->object->getFixedTextLength() );
771 $points =
new ilNumberInputGUI($this->lng->txt(
'points' ),
"gap_" . $gapCounter .
"_numeric_points");
773 $points->setSize( 3 );
774 $points->setRequired(
true );
776 $form->addItem( $points );
786 $this->
object->saveToDb();
796 $this->
object->deleteAnswerText($this->gapIndex, key(
$_POST[
'cmd'][
'removegap_' . $this->gapIndex]));
806 $this->
object->addGapAnswer($this->gapIndex, key(
$_POST[
'cmd'][
'addgap_' . $this->gapIndex])+1,
"");
818 function getPreview($show_question_only = FALSE, $showInlineFeedback =
false)
823 include_once
"./Services/UICore/classes/class.ilTemplate.php";
824 $template =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
825 $output = $this->
object->getClozeText();
826 foreach ($this->object->getGaps() as $gap_index => $gap)
828 switch ($gap->getType())
831 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_text.html", TRUE, TRUE,
"Modules/TestQuestionPool");
833 $gap_size = $gap->getGapSize() > 0 ? $gap->getGapSize() : $this->
object->getFixedTextLength();
836 $gaptemplate->setCurrentBlock(
'size_and_maxlength');
837 $gaptemplate->setVariable(
"TEXT_GAP_SIZE", $gap_size);
838 $gaptemplate->parseCurrentBlock();
840 $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
841 foreach ($user_solution as $val1 => $val2)
843 if (strcmp($val1, $gap_index) == 0)
848 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
851 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_select.html", TRUE, TRUE,
"Modules/TestQuestionPool");
852 foreach ($gap->getItems() as $item)
854 $gaptemplate->setCurrentBlock(
"select_gap_option");
855 $gaptemplate->setVariable(
"SELECT_GAP_VALUE", $item->getOrder());
857 foreach ($user_solution as $val1 => $val2)
859 if (strcmp($val1, $gap_index) == 0)
861 if (strcmp($val2, $item->getOrder()) == 0)
863 $gaptemplate->setVariable(
"SELECT_GAP_SELECTED",
" selected=\"selected\"");
867 $gaptemplate->parseCurrentBlock();
869 $gaptemplate->setVariable(
"PLEASE_SELECT", $this->lng->txt(
"please_select"));
870 $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
871 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
874 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_numeric.html", TRUE, TRUE,
"Modules/TestQuestionPool");
875 $gap_size = $gap->getGapSize() > 0 ? $gap->getGapSize() : $this->
object->getFixedTextLength();
878 $gaptemplate->setCurrentBlock(
'size_and_maxlength');
879 $gaptemplate->setVariable(
"TEXT_GAP_SIZE", $gap_size);
880 $gaptemplate->parseCurrentBlock();
882 $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
883 foreach ($user_solution as $val1 => $val2)
885 if (strcmp($val1, $gap_index) == 0)
890 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
894 $template->setVariable(
"QUESTIONTEXT",$this->object->prepareTextareaOutput( $this->object->getQuestion(),
true));
895 $template->setVariable(
"CLOZETEXT", $this->object->prepareTextareaOutput($output, TRUE));
896 $questionoutput = $template->get();
897 if (!$show_question_only)
902 return $questionoutput;
923 $graphicalOutput = FALSE,
924 $result_output = FALSE,
925 $show_question_only = TRUE,
926 $show_feedback = FALSE,
927 $show_correct_solution = FALSE,
928 $show_manual_scoring = FALSE,
929 $show_question_text = TRUE
933 $user_solution = array();
934 if (($active_id > 0) && (!$show_correct_solution))
937 $user_solution =& $this->
object->getSolutionValues($active_id,
$pass);
938 if(!is_array($user_solution))
940 $user_solution = array();
944 include_once
"./Services/UICore/classes/class.ilTemplate.php";
945 $template =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
946 $output = $this->
object->getClozeText();
947 foreach ($this->object->getGaps() as $gap_index => $gap)
949 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_output_solution_gap.html", TRUE, TRUE,
"Modules/TestQuestionPool");
951 foreach ($user_solution as $solutionarray)
953 if ($solutionarray[
"value1"] == $gap_index) $found = $solutionarray;
958 if ($graphicalOutput)
961 $details = $this->
object->calculateReachedPoints($active_id,
$pass, TRUE);
962 $check = $details[$gap_index];
965 $check_for_gap_combinations = $assClozeGapCombinationObject->loadFromDb($this->object->getId());
966 if(count($check_for_gap_combinations) != 0)
968 $gaps_used_in_combination = $assClozeGapCombinationObject->getGapsWhichAreUsedInCombination($this->object->getId());
969 $custom_user_solution = array();
970 if(array_key_exists($gap_index, $gaps_used_in_combination))
972 $combination_id = $gaps_used_in_combination[$gap_index];
973 foreach($gaps_used_in_combination as $key => $value)
976 if($value == $combination_id)
979 foreach($user_solution as $solution_key => $solution_value)
981 if($solution_value[
'value1'] == $key)
983 $result_row = array();
984 $result_row[
'gap_id'] = $solution_value[
'value1'];
985 $result_row[
'value'] = $solution_value[
'value2'];
986 array_push($custom_user_solution, $result_row);
991 $points_array = $this->
object->calculateCombinationResult($custom_user_solution);
992 $max_combination_points = $assClozeGapCombinationObject->getMaxPointsForCombination($this->object->getId(), $combination_id);
993 if($points_array[0] == $max_combination_points)
996 $gaptemplate->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
998 else if($points_array[0] > 0)
1001 $gaptemplate->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
1006 $gaptemplate->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
1014 $gaptemplate->setCurrentBlock(
"icon_ok");
1016 $gaptemplate->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
1017 $gaptemplate->parseCurrentBlock();
1021 $gaptemplate->setCurrentBlock(
"icon_not_ok");
1022 if ($check[
"positive"])
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"));
1032 $gaptemplate->parseCurrentBlock();
1040 $gaptemplate->setCurrentBlock(
"icon_ok");
1042 $gaptemplate->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
1043 $gaptemplate->parseCurrentBlock();
1047 $gaptemplate->setCurrentBlock(
"icon_not_ok");
1048 if ($check[
"positive"])
1051 $gaptemplate->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
1056 $gaptemplate->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
1058 $gaptemplate->parseCurrentBlock();
1066 $points = $this->
object->getMaximumGapPoints($gap_index);
1067 $resulttext = ($points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
1068 $gaptemplate->setCurrentBlock(
"result_output");
1069 $gaptemplate->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $points));
1070 $gaptemplate->parseCurrentBlock();
1072 switch ($gap->getType())
1076 if (($active_id > 0) && (!$show_correct_solution))
1078 if ((count($found) == 0) || (strlen(trim($found[
"value2"])) == 0))
1080 for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++)
1082 $solutiontext .=
" ";
1094 $gaptemplate->setVariable(
"SOLUTION", $solutiontext);
1095 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
1099 if (($active_id > 0) && (!$show_correct_solution))
1101 if ((count($found) == 0) || (strlen(trim($found[
"value2"])) == 0))
1103 for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++)
1105 $solutiontext .=
" ";
1110 $item = $gap->getItem($found[
"value2"]);
1111 if (is_object($item))
1117 for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++)
1119 $solutiontext .=
" ";
1128 $gaptemplate->setVariable(
"SOLUTION", $solutiontext);
1129 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
1133 if (($active_id > 0) && (!$show_correct_solution))
1135 if ((count($found) == 0) || (strlen(trim($found[
"value2"])) == 0))
1137 for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++)
1139 $solutiontext .=
" ";
1151 $gaptemplate->setVariable(
"SOLUTION", $solutiontext);
1152 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
1157 if ($show_question_text)
1159 $template->setVariable(
1160 "QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(),
true)
1164 $template->setVariable(
"CLOZETEXT", $this->object->prepareTextareaOutput($output, TRUE));
1166 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
1167 $questionoutput = $template->get();
1173 $feedback .= strlen($fb) ? $fb :
'';
1176 $feedback .= strlen($fb) ? $fb :
'';
1178 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $feedback);
1180 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
1182 $solutionoutput = $solutiontemplate->get();
1185 $check_for_gap_combinations = $assClozeGapCombinationObject->loadFromDb($this->object->getId());
1186 if(count($check_for_gap_combinations) != 0)
1188 $solutionoutput .=
'<i>Best Combination is: ' . $assClozeGapCombinationObject->getBestSolutionCombination($this->object->getId()) .
'</i>';
1190 if (!$show_question_only)
1193 $solutionoutput = $this->
getILIASPage($solutionoutput);
1196 return $solutionoutput;
1201 include_once
"./Modules/Test/classes/class.ilObjTest.php";
1203 if (strlen($manual_feedback))
1205 return $manual_feedback;
1207 $correct_feedback = $this->
object->feedbackOBJ->getGenericFeedbackTestPresentation($this->object->getId(),
true);
1208 $incorrect_feedback = $this->
object->feedbackOBJ->getGenericFeedbackTestPresentation($this->object->getId(),
false);
1209 if (strlen($correct_feedback.$incorrect_feedback))
1211 $reached_points = $this->
object->calculateReachedPoints($active_id,
$pass);
1212 $max_points = $this->
object->getMaximumPoints();
1213 if ($reached_points == $max_points)
1215 $output .= $correct_feedback;
1219 $output .= $incorrect_feedback;
1223 return $this->
object->prepareTextareaOutput($output, TRUE);
1229 $is_postponed = FALSE,
1230 $use_post_solutions = FALSE,
1231 $show_feedback = FALSE
1235 $user_solution = array();
1238 include_once
"./Modules/Test/classes/class.ilObjTest.php";
1243 $user_solution =& $this->
object->getSolutionValues($active_id,
$pass);
1244 if (!is_array($user_solution))
1246 $user_solution = array();
1251 include_once
"./Services/UICore/classes/class.ilTemplate.php";
1252 $template =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1253 $output = $this->
object->getClozeText();
1254 foreach ($this->object->getGaps() as $gap_index => $gap)
1256 switch ($gap->getType())
1259 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_text.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1260 $gap_size = $gap->getGapSize() > 0 ? $gap->getGapSize() : $this->
object->getFixedTextLength();
1264 $gaptemplate->setCurrentBlock(
'size_and_maxlength');
1265 $gaptemplate->setVariable(
"TEXT_GAP_SIZE", $gap_size);
1266 $gaptemplate->parseCurrentBlock();
1269 $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
1270 foreach ($user_solution as $solution)
1272 if (strcmp($solution[
"value1"], $gap_index) == 0)
1277 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
1280 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_select.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1281 foreach ($gap->getItems() as $item)
1283 $gaptemplate->setCurrentBlock(
"select_gap_option");
1284 $gaptemplate->setVariable(
"SELECT_GAP_VALUE", $item->getOrder());
1286 foreach ($user_solution as $solution)
1288 if (strcmp($solution[
"value1"], $gap_index) == 0)
1290 if (strcmp($solution[
"value2"], $item->getOrder()) == 0)
1292 $gaptemplate->setVariable(
"SELECT_GAP_SELECTED",
" selected=\"selected\"");
1296 $gaptemplate->parseCurrentBlock();
1298 $gaptemplate->setVariable(
"PLEASE_SELECT", $this->lng->txt(
"please_select"));
1299 $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
1300 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
1303 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_numeric.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1304 $gap_size = $gap->getGapSize() > 0 ? $gap->getGapSize() : $this->
object->getFixedTextLength();
1307 $gaptemplate->setCurrentBlock(
'size_and_maxlength');
1308 $gaptemplate->setVariable(
"TEXT_GAP_SIZE", $gap_size);
1309 $gaptemplate->parseCurrentBlock();
1312 $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
1313 foreach ($user_solution as $solution)
1315 if (strcmp($solution[
"value1"], $gap_index) == 0)
1320 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
1325 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(),
true));
1326 $template->setVariable(
"CLOZETEXT", $this->object->prepareTextareaOutput($output, TRUE));
1327 $questionoutput = $template->get();
1328 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
1341 global $rbacsystem, $ilTabs;
1343 $ilTabs->clearTargets();
1345 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
1346 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
1347 $q_type = $this->
object->getQuestionType();
1349 if (strlen($q_type))
1351 $classname = $q_type .
"GUI";
1352 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
1353 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
1354 # $this->ctrl->setParameterByClass(strtolower($classname), 'prev_qid', $_REQUEST['prev_qid']);
1359 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
1362 $ilTabs->addTarget(
"edit_page",
1363 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
1364 array(
"edit",
"insert",
"exec_pg"),
1365 "",
"", $force_active);
1371 $force_active =
false;
1372 $commands =
$_POST[
"cmd"];
1373 if (is_array($commands))
1375 foreach ($commands as $key => $value)
1377 if (preg_match(
"/^removegap_.*/", $key, $matches) ||
1378 preg_match(
"/^addgap_.*/", $key, $matches)
1381 $force_active =
true;
1385 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
1388 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
1390 $ilTabs->addTarget(
"edit_question",
1392 array(
"editQuestion",
"originalSyncForm",
"save",
"createGaps",
"saveEdit"),
1393 $classname,
"", $force_active);
1408 $ilTabs->addTarget(
"statistics",
1409 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
1410 array(
"assessment"),
1419 if( !$this->object->feedbackOBJ->specificAnswerFeedbackExists(array_values($this->object->gaps)) )
1426 $feedback =
'<table class="test_specific_feedback"><tbody>';
1428 foreach ($this->object->gaps as $index => $answer)
1430 $caption = $lng->txt(
'gap').
' '.($index+1) .
': ';
1432 $feedback .=
'<tr><td>';
1434 $feedback .= $caption .
'</td><td>';
1435 $feedback .= $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
1436 $this->object->getId(), $index
1439 $feedback .=
'</tbody></table>';
1441 return $this->
object->prepareTextareaOutput($feedback, TRUE);
1482 $overview = array();
1483 $aggregation = array();
1484 foreach ($relevant_answers as $answer)
1486 $overview[$answer[
'active_fi']][$answer[
'pass']][$answer[
'value1']] = $answer[
'value2'];
1489 foreach($overview as $active)
1491 foreach ($active as $answer)
1493 foreach ($answer as $option => $value)
1495 $aggregation[$option][$value] = $aggregation[$option][$value] + 1;
1502 foreach ($this->object->getGaps() as $gap)
1506 $html .=
'<p>Gap '.$i .
' - SELECT</p>';
1509 foreach($gap->getItems() as $gap_item)
1511 $aggregate = $aggregation[$i];
1512 $html .=
'<li>' . $gap_item->getAnswerText() .
' - ' . ($aggregate[$j] ? $aggregate[$j] : 0) .
'</li>';
1520 $html .=
'<p>Gap '.$i .
' - TEXT</p>';
1522 $aggregate = (array)$aggregation[$i];
1523 foreach($aggregate as $answer => $count)
1525 $html .=
'<li>' . $answer .
' - ' . $count .
'</li>';
1532 $html .=
'<p>Gap '.$i .
' - NUMERIC</p>';
1535 foreach($gap->getItems() as $gap_item)
1537 $aggregate = (array)$aggregation[$i];
1538 foreach($aggregate as $answer => $count)
1540 $html .=
'<li>' . $answer .
' - ' . $count .
'</li>';
1556 $parts = explode(
'[gap', $question_text );
1558 $question_text =
'';
1559 foreach ( $parts as $part )
1563 $question_text .= $part;
1567 $question_text .=
'[gap ' . $i . $part;
1571 return $question_text;
1576 $parts = preg_split(
'/\[gap \d*\]/', $question_text );
1577 $question_text = implode(
'[gap]', $parts );
1578 return $question_text;