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';
 
   37                 include_once 
"./Modules/TestQuestionPool/classes/class.assClozeTest.php";
 
   41                         $this->
object->loadFromDb($id);
 
   47                 if (preg_match(
"/^(removegap|addgap)_(\d+)$/", 
$cmd, $matches))
 
   50                         $this->gapIndex = $matches[2];
 
   67                 if (is_array( 
$_POST[
'gap'] ))
 
   69                         foreach (
$_POST[
'gap'] as $idx => $hidden)
 
   71                                 $clozetype = 
$_POST[
'clozetype_' . $idx];
 
   73                                 $db_gap = $this->
object->getGap($idx);
 
   74                                 if( !is_object($db_gap) || $db_gap->getType() != $clozetype )
 
   84                 $hasErrors = (!$always) ? $this->
editQuestion(
true) : 
false;
 
   87                         $question_text = 
$_POST[
'question'];
 
   89                         $_POST[
'question'] = $question_text;
 
   90                         $this->
object->setQuestion($question_text);
 
   93                         $this->
object->setClozeText(
$_POST[
"question"]);
 
   98                         if($save_return == 
false && $always == 
true)
 
  100                                 $question_text = 
$_POST[
'question'];
 
  102                                 $_POST[
'question'] = $question_text;
 
  109                 $question_text = 
$_POST[
'question'];
 
  111                 $_POST[
'question'] = $question_text;
 
  117                 if (is_array( 
$_POST[
'gap'] ))
 
  119                         if ( $this->ctrl->getCmd() != 
'createGaps' )
 
  121                                 $this->
object->clearGapAnswers();
 
  124                         foreach (
$_POST[
'gap'] as $idx => $hidden)
 
  126                                 $clozetype = 
$_POST[
'clozetype_' . $idx];
 
  128                                 $this->
object->setGapType( $idx, $clozetype );
 
  134                                                 $this->
object->setGapShuffle( $idx, 0 );
 
  136                                                 if ($this->ctrl->getCmd() != 
'createGaps')
 
  138                                                         if (is_array( 
$_POST[
'gap_' . $idx][
'answer'] ))
 
  140                                                                 foreach (
$_POST[
'gap_' . $idx][
'answer'] as $order => $value)
 
  142                                                                         $this->
object->addGapAnswer( $idx, $order, $value );
 
  147                                                                 $this->
object->addGapAnswer( $idx, 0, 
'' );
 
  151                                                 if (is_array( 
$_POST[
'gap_' . $idx][
'points'] ))
 
  153                                                         foreach (
$_POST[
'gap_' . $idx][
'points'] as $order => $value)
 
  155                                                                 $this->
object->setGapAnswerPoints( $idx, $order, $value );
 
  163                                                 $this->
object->setGapShuffle( $idx, (
int)(isset(
$_POST[
"shuffle_$idx"]) && 
$_POST[
"shuffle_$idx"]) );
 
  165                                                 if ($this->ctrl->getCmd() != 
'createGaps')
 
  167                                                         if (is_array( 
$_POST[
'gap_' . $idx][
'answer'] ))
 
  169                                                                 foreach (
$_POST[
'gap_' . $idx][
'answer'] as $order => $value)
 
  171                                                                         $this->
object->addGapAnswer( $idx, $order, $value );
 
  176                                                                 $this->
object->addGapAnswer( $idx, 0, 
'' );
 
  180                                                 if (is_array( 
$_POST[
'gap_' . $idx][
'points'] ))
 
  182                                                         foreach (
$_POST[
'gap_' . $idx][
'points'] as $order => $value)
 
  184                                                                 $this->
object->setGapAnswerPoints( $idx, $order, $value );
 
  192                                                 $this->
object->setGapShuffle( $idx, 0 );
 
  194                                                 $gap = $this->
object->getGap($idx);
 
  197                                                 $this->
object->getGap($idx)->clearItems();
 
  199                                                 if (array_key_exists( 
'gap_' . $idx . 
'_numeric', 
$_POST ))
 
  201                                                         #if ($this->ctrl->getCmd() != 'createGaps') 
  203                                                                 $this->
object->addGapAnswer(
 
  204                                                                         $idx, 0, str_replace(
",", 
".", 
$_POST[
'gap_' . $idx . 
'_numeric'])
 
  208                                                         $this->
object->setGapAnswerLowerBound(
 
  209                                                                 $idx, 0, str_replace(
",", 
".", 
$_POST[
'gap_' . $idx . 
'_numeric_lower'])
 
  212                                                         $this->
object->setGapAnswerUpperBound(
 
  213                                                                 $idx, 0, str_replace( 
",", 
".", 
$_POST[
'gap_' . $idx . 
'_numeric_upper'])
 
  216                                                         $this->
object->setGapAnswerPoints( $idx, 0, 
$_POST[
'gap_' . $idx . 
'_numeric_points'] );
 
  220                                                         #if ($this->ctrl->getCmd() != 'createGaps') 
  222                                                                 $this->
object->addGapAnswer($idx, 0, 
'');
 
  225                                                         $this->
object->setGapAnswerLowerBound($idx, 0, 
'');
 
  227                                                         $this->
object->setGapAnswerUpperBound($idx, 0, 
'');
 
  233                         if ($this->ctrl->getCmd() != 
'createGaps')
 
  235                                 $this->
object->updateClozeTextFromGaps();
 
  242                 $this->
object->setTextgapRating( 
$_POST[
"textgap_rating"] );
 
  243                 $this->
object->setIdenticalScoring( 
$_POST[
"identical_scoring"] );
 
  244                 $this->
object->setFixedTextLength( 
$_POST[
"fixedTextLength"] );
 
  257         include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
 
  259                 $form->setFormAction($this->ctrl->getFormAction($this));
 
  261                 $form->setMultipart(FALSE);
 
  262                 $form->setTableWidth(
"100%");
 
  263                 $form->setId(
"assclozetest");
 
  269                 $q_item = $form->getItemByPostVar(
"question");
 
  271                 $q_item->setInfo($this->lng->txt(
"close_text_hint"));
 
  272                 $q_item->setTitle($this->lng->txt(
"cloze_text"));
 
  284                         $form->setValuesByPost();
 
  285                         $errors = !$form->checkInput();
 
  286                         $form->setValuesByPost();       
 
  288                         if (
$errors) $checkonly = 
false;
 
  291                 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
 
  299                 $title->
setValue($this->object->getTitle());
 
  300                 $title->setRequired(TRUE);
 
  301                 $form->addItem($title);
 
  303                 if (!$this->object->getSelfAssessmentEditingMode())
 
  306                         $author = 
new ilTextInputGUI($this->lng->txt(
"author"), 
"author");
 
  307                         $author->
setValue($this->object->getAuthor());
 
  308                         $author->setRequired(TRUE);
 
  309                         $form->addItem($author);
 
  312                         $description = 
new ilTextInputGUI($this->lng->txt(
"description"), 
"comment");
 
  313                         $description->
setValue($this->object->getComment());
 
  314                         $description->setRequired(FALSE);
 
  315                         $form->addItem($description);
 
  322                         if (trim($author) == 
"")
 
  326                         $hi->setValue($author);
 
  333                 $question->
setValue($this->object->prepareTextareaOutput($this->object->getQuestion()));
 
  334                 $question->setRequired(TRUE);
 
  335                 $question->setRows(10);
 
  336                 $question->setCols(80);
 
  337                 if (!$this->object->getSelfAssessmentEditingMode())
 
  341                                 $question->setUseRte(TRUE);
 
  342                                 include_once 
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
 
  344                                 $question->addPlugin(
"latex");
 
  345                                 $question->addButton(
"latex");
 
  346                                 $question->addButton(
"pastelatex");
 
  347                                 $question->setRTESupport($this->object->getId(), 
"qpl", 
"assessment");
 
  352                         $question->setRteTags(self::getSelfAssessmentTags());
 
  353                         $question->setUseTagsForRteOnly(
false);
 
  355                 $form->addItem($question);
 
  357                 $tpl = 
new ilTemplate(
"tpl.il_as_qpl_cloze_gap_button_code.html", TRUE, TRUE, 
"Modules/TestQuestionPool");
 
  358                 $tpl->setVariable(
'INSERT_GAP', $this->lng->txt(
'insert_gap'));
 
  359                 $tpl->setVariable(
'CREATE_GAPS', $this->lng->txt(
'create_gaps'));
 
  360                 $tpl->parseCurrentBlock();
 
  362                 $button->setHtml(
$tpl->get());
 
  363                 $form->addItem($button);
 
  365                 if (!$this->object->getSelfAssessmentEditingMode())
 
  370                         $duration->setShowMinutes(TRUE);
 
  371                         $duration->setShowSeconds(TRUE);
 
  372                         $ewt = $this->
object->getEstimatedWorkingTime();
 
  373                         $duration->setHours($ewt[
"h"]);
 
  374                         $duration->setMinutes($ewt[
"m"]);
 
  375                         $duration->setSeconds($ewt[
"s"]);
 
  376                         $duration->setRequired(FALSE);
 
  377                         $form->addItem($duration);
 
  382                         if (strlen($this->object->getNrOfTries()))
 
  384                                 $nr_tries = $this->
object->getNrOfTries();
 
  388                                 $nr_tries = $this->
object->getDefaultNrOfTries();
 
  400                         $ni = 
new ilNumberInputGUI($this->lng->txt(
"qst_nr_of_tries"), 
"nr_of_tries");
 
  405                         $ni->setMaxLength(5);
 
  406                         $ni->setRequired(
true);
 
  414                 if (!$this->object->getSelfAssessmentEditingMode())
 
  416                         $textrating   = 
new ilSelectInputGUI($this->lng->txt( 
"text_rating" ), 
"textgap_rating");
 
  417                         $text_options = array(
 
  418                                 "ci" => $this->lng->txt( 
"cloze_textgap_case_insensitive" ),
 
  419                                 "cs" => $this->lng->txt( 
"cloze_textgap_case_sensitive" ),
 
  420                                 "l1" => sprintf( $this->lng->txt( 
"cloze_textgap_levenshtein_of" ), 
"1" ),
 
  421                                 "l2" => sprintf( $this->lng->txt( 
"cloze_textgap_levenshtein_of" ), 
"2" ),
 
  422                                 "l3" => sprintf( $this->lng->txt( 
"cloze_textgap_levenshtein_of" ), 
"3" ),
 
  423                                 "l4" => sprintf( $this->lng->txt( 
"cloze_textgap_levenshtein_of" ), 
"4" ),
 
  424                                 "l5" => sprintf( $this->lng->txt( 
"cloze_textgap_levenshtein_of" ), 
"5" )
 
  426                         $textrating->setOptions( $text_options );
 
  427                         $textrating->setValue( $this->object->getTextgapRating() );
 
  431                         $fixedTextLength = 
new ilNumberInputGUI($this->lng->txt( 
"cloze_fixed_textlength" ), 
"fixedTextLength");
 
  432                         $ftl = $this->
object->getFixedTextLength();
 
  438                         $fixedTextLength->setMinValue( 0 );
 
  439                         $fixedTextLength->setSize( 3 );
 
  440                         $fixedTextLength->setMaxLength( 6 );
 
  441                         $fixedTextLength->setInfo( $this->lng->txt( 
'cloze_fixed_textlength_description' ) );
 
  442                         $fixedTextLength->setRequired( 
false );
 
  443                         $form->
addItem( $fixedTextLength );
 
  446                         $identical_scoring = 
new ilCheckboxInputGUI($this->lng->txt( 
"identical_scoring" ), 
"identical_scoring");
 
  448                         $identical_scoring->setChecked( $this->object->getIdenticalScoring() );
 
  449                         $identical_scoring->setInfo( $this->lng->txt( 
'identical_scoring_desc' ) );
 
  450                         $identical_scoring->setRequired( FALSE );
 
  451                         $form->
addItem( $identical_scoring );
 
  458                 for ($gapCounter = 0; $gapCounter < $this->
object->getGapCount(); $gapCounter++)
 
  478                 $gap    = $this->
object->getGap( $gapCounter );
 
  486                 $header->setTitle( $this->lng->txt( 
"gap" ) . 
" " . ($gapCounter + 1) );
 
  487                 $form->addItem( $header );
 
  490                 $gapcounter->setValue( $gapCounter );
 
  491                 $form->addItem( $gapcounter );
 
  493                 $gaptype = 
new ilSelectInputGUI($this->lng->txt( 
'type' ), 
"clozetype_$gapCounter");
 
  495                         0 => $this->lng->txt( 
"text_gap" ),
 
  496                         1 => $this->lng->txt( 
"select_gap" ),
 
  497                         2 => $this->lng->txt( 
"numeric_gap" )
 
  499                 $gaptype->setOptions( $options );
 
  500                 $gaptype->setValue( $gap->getType() );
 
  501                 $form->addItem( $gaptype );
 
  505                         if (count( $gap->getItemsRaw() ) == 0)
 
  514                         if (count( $gap->getItemsRaw() ) == 0)
 
  522                         if (count( $gap->getItemsRaw() ) == 0)
 
  527                         foreach ($gap->getItemsRaw() as $item)
 
  549                 include_once 
"./Modules/TestQuestionPool/classes/class.ilAnswerWizardInputGUI.php";
 
  550                 include_once 
"./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
 
  553                 $values->setQuestionObject( $this->
object );
 
  554                 $values->setSingleline( 
true );
 
  555                 $values->setAllowMove( 
false );
 
  557                 $values->setValues( $gap->getItemsRaw() );
 
  558                 $form->addItem( $values );
 
  561                 $shuffle = 
new ilCheckboxInputGUI($this->lng->txt( 
"shuffle_answers" ), 
"shuffle_" . $gapCounter . 
"");
 
  563                 $shuffle->setChecked( $gap->getShuffle() );
 
  564                 $shuffle->setRequired( FALSE );
 
  565                 $form->addItem( $shuffle );
 
  583                 include_once 
"./Modules/TestQuestionPool/classes/class.ilAnswerWizardInputGUI.php";
 
  584                 include_once 
"./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
 
  587                 $values->setQuestionObject( $this->
object );
 
  588                 $values->setSingleline( 
true );
 
  589                 $values->setAllowMove( 
false );
 
  590                 $values->setValues( $gap->getItemsRaw() );
 
  591                 $form->addItem( $values );
 
  593                 if( $this->object->getFixedTextLength() > 0 )
 
  595                         $values->setSize( $this->object->getFixedTextLength() );
 
  596                         $values->setMaxLength( $this->object->getFixedTextLength() );
 
  616                 if (!$this->object->getSelfAssessmentEditingMode())
 
  618                         $value = 
new ilFormulaInputGUI($this->lng->txt( 
'value' ), 
"gap_" . $gapCounter . 
"_numeric");
 
  621                         $lowerbound = 
new ilFormulaInputGUI($this->lng->txt( 
'range_lower_limit'), 
"gap_" . $gapCounter . 
"_numeric_lower");
 
  624                         $upperbound = 
new ilFormulaInputGUI($this->lng->txt( 
'range_upper_limit'), 
"gap_" . $gapCounter . 
"_numeric_upper");
 
  629                         $value = 
new ilNumberInputGUI($this->lng->txt( 
'value' ), 
"gap_" . $gapCounter . 
"_numeric");
 
  632                         $lowerbound = 
new ilNumberInputGUI($this->lng->txt( 
'range_lower_limit'), 
"gap_" . $gapCounter . 
"_numeric_lower");
 
  635                         $upperbound = 
new ilNumberInputGUI($this->lng->txt( 
'range_upper_limit'), 
"gap_" . $gapCounter . 
"_numeric_upper");
 
  639                 $value->setSize( 10 );
 
  641                 $value->setRequired( 
true );
 
  642                 $form->addItem( $value );
 
  644                 $lowerbound->setSize( 10 );
 
  645                 $lowerbound->setRequired( 
true );
 
  647                 $form->addItem( $lowerbound );
 
  649                 $upperbound->setSize( 10 );
 
  650                 $upperbound->setRequired( 
true );
 
  652                 $form->addItem( $upperbound );
 
  654                 if( $this->object->getFixedTextLength() > 0 )
 
  656                         $value->setSize( $this->object->getFixedTextLength() );
 
  657                         $value->setMaxLength( $this->object->getFixedTextLength() );
 
  658                         $lowerbound->setSize( $this->object->getFixedTextLength() );
 
  659                         $lowerbound->setMaxLength( $this->object->getFixedTextLength() );
 
  660                         $upperbound->setSize( $this->object->getFixedTextLength() );
 
  661                         $upperbound->setMaxLength( $this->object->getFixedTextLength() );
 
  664                 $points = 
new ilNumberInputGUI($this->lng->txt( 
'points' ), 
"gap_" . $gapCounter . 
"_numeric_points");
 
  666                 $points->setSize( 3 );
 
  667                 $points->setRequired( 
true );
 
  669                 $form->addItem( $points );
 
  679                 $this->
object->saveToDb();
 
  689                 $this->
object->deleteAnswerText($this->gapIndex, key(
$_POST[
'cmd'][
'removegap_' . $this->gapIndex]));
 
  699                 $this->
object->addGapAnswer($this->gapIndex, key(
$_POST[
'cmd'][
'addgap_' . $this->gapIndex])+1, 
"");
 
  718                                 $is_postponed = FALSE, 
 
  719                                 $use_post_solutions = FALSE
 
  722                 $test_output = $this->
getTestOutput($active_id, 
$pass, $is_postponed, $use_post_solutions); 
 
  723                 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
 
  724                 $this->tpl->setVariable(
"FORMACTION", $formaction);
 
  740                 include_once 
"./Services/UICore/classes/class.ilTemplate.php";
 
  741                 $template = 
new ilTemplate(
"tpl.il_as_qpl_cloze_question_output.html", TRUE, TRUE, 
"Modules/TestQuestionPool");
 
  742                 $output = $this->
object->getClozeText();
 
  743                 foreach ($this->object->getGaps() as $gap_index => $gap)
 
  745                         switch ($gap->getType())
 
  748                                         $gaptemplate = 
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_text.html", TRUE, TRUE, 
"Modules/TestQuestionPool");
 
  749                                         $gaptemplate->setVariable(
"TEXT_GAP_SIZE", $this->object->getFixedTextLength() ? $this->
object->getFixedTextLength() : $gap->getMaxWidth());
 
  750                                         $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
 
  751                                         $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
 
  754                                         $gaptemplate = 
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_select.html", TRUE, TRUE, 
"Modules/TestQuestionPool");
 
  755                                         foreach ($gap->getItems() as $item)
 
  757                                                 $gaptemplate->setCurrentBlock(
"select_gap_option");
 
  758                                                 $gaptemplate->setVariable(
"SELECT_GAP_VALUE", $item->getOrder());
 
  760                                                 $gaptemplate->parseCurrentBlock();
 
  762                                         $gaptemplate->setVariable(
"PLEASE_SELECT", $this->lng->txt(
"please_select"));
 
  763                                         $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
 
  764                                         $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
 
  767                                         $gaptemplate = 
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_numeric.html", TRUE, TRUE, 
"Modules/TestQuestionPool");
 
  768                                         $gaptemplate->setVariable(
"TEXT_GAP_SIZE", $this->object->getFixedTextLength() ? $this->
object->getFixedTextLength() : $gap->getMaxWidth());
 
  769                                         $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
 
  770                                         $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
 
  774                 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($output, TRUE));
 
  775                 $questionoutput = $template->get();
 
  776                 if (!$show_question_only)
 
  781                 return $questionoutput;
 
  802                                 $graphicalOutput = FALSE,
 
  803                                 $result_output = FALSE,
 
  804                                 $show_question_only = TRUE,
 
  805                                 $show_feedback = FALSE,
 
  806                                 $show_correct_solution = FALSE,
 
  807                                 $show_manual_scoring = FALSE,
 
  808                                 $show_question_text = TRUE
 
  812                 $user_solution = array();
 
  813                 if (($active_id > 0) && (!$show_correct_solution))
 
  816                         $user_solution =& $this->
object->getSolutionValues($active_id, 
$pass);
 
  817                         if (!is_array($user_solution)) 
 
  819                                 $user_solution = array();
 
  822                         foreach ($this->object->gaps as $index => $gap)
 
  824                                 $user_solution = array();
 
  829                 include_once 
"./Services/UICore/classes/class.ilTemplate.php";
 
  830                 $template = 
new ilTemplate(
"tpl.il_as_qpl_cloze_question_output_solution.html", TRUE, TRUE, 
"Modules/TestQuestionPool");
 
  831                 $output = $this->
object->getClozeText();
 
  832                 foreach ($this->object->getGaps() as $gap_index => $gap)
 
  834                         $gaptemplate = 
new ilTemplate(
"tpl.il_as_qpl_cloze_question_output_solution_gap.html", TRUE, TRUE, 
"Modules/TestQuestionPool");
 
  836                         foreach ($user_solution as $solutionarray)
 
  838                                 if ($solutionarray[
"value1"] == $gap_index) $found = $solutionarray;
 
  843                                 if ($graphicalOutput)
 
  846                                         $details = $this->
object->calculateReachedPoints($active_id, 
$pass, TRUE);
 
  847                                         $check = $details[$gap_index];
 
  850                                                 $gaptemplate->setCurrentBlock(
"icon_ok");
 
  852                                                 $gaptemplate->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
 
  853                                                 $gaptemplate->parseCurrentBlock();
 
  857                                                 $gaptemplate->setCurrentBlock(
"icon_not_ok");
 
  858                                                 if ($check[
"positive"])
 
  861                                                         $gaptemplate->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
 
  866                                                         $gaptemplate->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
 
  868                                                 $gaptemplate->parseCurrentBlock();
 
  874                                 $points = $this->
object->getMaximumGapPoints($gap_index);
 
  875                                 $resulttext = ($points == 1) ? 
"(%s " . $this->lng->txt(
"point") . 
")" : 
"(%s " . $this->lng->txt(
"points") . 
")"; 
 
  876                                 $gaptemplate->setCurrentBlock(
"result_output");
 
  877                                 $gaptemplate->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $points));
 
  878                                 $gaptemplate->parseCurrentBlock();
 
  880                         switch ($gap->getType())
 
  884                                         if (($active_id > 0) && (!$show_correct_solution))
 
  886                                                 if ((count($found) == 0) || (strlen(trim($found[
"value2"])) == 0))
 
  888                                                         for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++)
 
  890                                                                 $solutiontext .= 
" ";
 
  902                                         $gaptemplate->setVariable(
"SOLUTION", $solutiontext);
 
  903                                         $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
 
  907                                         if (($active_id > 0) && (!$show_correct_solution))
 
  909                                                 if ((count($found) == 0) || (strlen(trim($found[
"value2"])) == 0))
 
  911                                                         for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++)
 
  913                                                                 $solutiontext .= 
" ";
 
  918                                                         $item = $gap->getItem($found[
"value2"]);
 
  919                                                         if (is_object($item))
 
  925                                                                 for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++)
 
  927                                                                         $solutiontext .= 
" ";
 
  936                                         $gaptemplate->setVariable(
"SOLUTION", $solutiontext);
 
  937                                         $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
 
  941                                         if (($active_id > 0) && (!$show_correct_solution))
 
  943                                                 if ((count($found) == 0) || (strlen(trim($found[
"value2"])) == 0))
 
  945                                                         for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++)
 
  947                                                                 $solutiontext .= 
" ";
 
  959                                         $gaptemplate->setVariable(
"SOLUTION", $solutiontext);
 
  960                                         $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
 
  965                 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($output, TRUE));
 
  967                 $solutiontemplate = 
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE, 
"Modules/TestQuestionPool");
 
  968                 $questionoutput = $template->get();
 
  974                         $feedback .=  strlen($fb) ? $fb : 
'';
 
  977                         $feedback .=  strlen($fb) ? $fb : 
'';
 
  979                 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $feedback);
 
  981                 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
 
  983                 $solutionoutput = $solutiontemplate->get(); 
 
  985                 if (!$show_question_only)
 
  988                         $solutionoutput = 
'<div class="ilc_question_Standard">'.$solutionoutput.
"</div>";
 
  991                 return $solutionoutput;
 
  996                 include_once 
"./Modules/Test/classes/class.ilObjTest.php";
 
  998                 if (strlen($manual_feedback))
 
 1000                         return $manual_feedback;
 
 1002                 $correct_feedback = $this->
object->feedbackOBJ->getGenericFeedbackTestPresentation($this->object->getId(), 
true);
 
 1003                 $incorrect_feedback = $this->
object->feedbackOBJ->getGenericFeedbackTestPresentation($this->object->getId(), 
false);
 
 1004                 if (strlen($correct_feedback.$incorrect_feedback))
 
 1006                         $reached_points = $this->
object->calculateReachedPoints($active_id, 
$pass);
 
 1007                         $max_points = $this->
object->getMaximumPoints();
 
 1008                         if ($reached_points == $max_points)
 
 1010                                 $output .= $correct_feedback;
 
 1014                                 $output .= $incorrect_feedback;
 
 1018                 return $this->
object->prepareTextareaOutput($output, TRUE);             
 
 1024                                 $is_postponed = FALSE, 
 
 1025                                 $use_post_solutions = FALSE, 
 
 1026                                 $show_feedback = FALSE
 
 1030                 $user_solution = array();
 
 1033                         include_once 
"./Modules/Test/classes/class.ilObjTest.php";
 
 1038                         $user_solution =& $this->
object->getSolutionValues($active_id, 
$pass);
 
 1039                         if (!is_array($user_solution)) 
 
 1041                                 $user_solution = array();
 
 1046                 include_once 
"./Services/UICore/classes/class.ilTemplate.php";
 
 1047                 $template = 
new ilTemplate(
"tpl.il_as_qpl_cloze_question_output.html", TRUE, TRUE, 
"Modules/TestQuestionPool");
 
 1048                 $output = $this->
object->getClozeText();
 
 1049                 foreach ($this->object->getGaps() as $gap_index => $gap)
 
 1051                         switch ($gap->getType())
 
 1054                                         $gaptemplate = 
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_text.html", TRUE, TRUE, 
"Modules/TestQuestionPool");
 
 1055                                         $gaptemplate->setVariable(
"TEXT_GAP_SIZE", $this->object->getFixedTextLength() ? $this->
object->getFixedTextLength() : $gap->getMaxWidth());
 
 1056                                         $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
 
 1057                                         foreach ($user_solution as $solution)
 
 1059                                                 if (strcmp($solution[
"value1"], $gap_index) == 0)
 
 1064                                         $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
 
 1067                                         $gaptemplate = 
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_select.html", TRUE, TRUE, 
"Modules/TestQuestionPool");
 
 1068                                         foreach ($gap->getItems() as $item)
 
 1070                                                 $gaptemplate->setCurrentBlock(
"select_gap_option");
 
 1071                                                 $gaptemplate->setVariable(
"SELECT_GAP_VALUE", $item->getOrder());
 
 1073                                                 foreach ($user_solution as $solution)
 
 1075                                                         if (strcmp($solution[
"value1"], $gap_index) == 0)
 
 1077                                                                 if (strcmp($solution[
"value2"], $item->getOrder()) == 0)
 
 1079                                                                         $gaptemplate->setVariable(
"SELECT_GAP_SELECTED", 
" selected=\"selected\"");
 
 1083                                                 $gaptemplate->parseCurrentBlock();
 
 1085                                         $gaptemplate->setVariable(
"PLEASE_SELECT", $this->lng->txt(
"please_select"));
 
 1086                                         $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
 
 1087                                         $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
 
 1090                                         $gaptemplate = 
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_numeric.html", TRUE, TRUE, 
"Modules/TestQuestionPool");
 
 1091                                         $gaptemplate->setVariable(
"TEXT_GAP_SIZE", $this->object->getFixedTextLength() ? $this->
object->getFixedTextLength() : $gap->getMaxWidth());
 
 1092                                         $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
 
 1093                                         foreach ($user_solution as $solution)
 
 1095                                                 if (strcmp($solution[
"value1"], $gap_index) == 0)
 
 1100                                         $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
 
 1105                 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($output, TRUE));
 
 1106                 $questionoutput = $template->get();
 
 1107                 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
 
 1120                 global $rbacsystem, $ilTabs;
 
 1122                 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI", 
"q_id", 
$_GET[
"q_id"]);
 
 1123                 include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
 1124                 $q_type = $this->
object->getQuestionType();
 
 1126                 if (strlen($q_type))
 
 1128                         $classname = $q_type . 
"GUI";
 
 1129                         $this->ctrl->setParameterByClass(strtolower($classname), 
"sel_question_types", $q_type);
 
 1130                         $this->ctrl->setParameterByClass(strtolower($classname), 
"q_id", 
$_GET[
"q_id"]);
 
 1131 #                       $this->ctrl->setParameterByClass(strtolower($classname), 'prev_qid', $_REQUEST['prev_qid']); 
 1136                         if ($rbacsystem->checkAccess(
'write', 
$_GET[
"ref_id"]))
 
 1139                                 $ilTabs->addTarget(
"edit_page",
 
 1140                                         $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI", 
"edit"),
 
 1141                                         array(
"edit", 
"insert", 
"exec_pg"),
 
 1142                                         "", 
"", $force_active);
 
 1146                         $ilTabs->addTarget(
"preview",
 
 1147                                 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI", 
"preview"),
 
 1149                                 "ilAssQuestionPageGUI", 
"", $force_active);
 
 1152                 $force_active = 
false;
 
 1153                 $commands = 
$_POST[
"cmd"];
 
 1154                 if (is_array($commands))
 
 1156                         foreach ($commands as $key => $value)
 
 1158                                 if (preg_match(
"/^removegap_.*/", $key, $matches) || 
 
 1159                                         preg_match(
"/^addgap_.*/", $key, $matches)
 
 1162                                         $force_active = 
true;
 
 1166                 if ($rbacsystem->checkAccess(
'write', 
$_GET[
"ref_id"]))
 
 1169                         if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname, 
"editQuestion");
 
 1171                         $ilTabs->addTarget(
"edit_question",
 
 1173                                 array(
"editQuestion", 
"originalSyncForm", 
"save", 
"createGaps", 
"saveEdit"),
 
 1174                                 $classname, 
"", $force_active);
 
 1185                         $ilTabs->addTarget(
"solution_hint",
 
 1186                                 $this->ctrl->getLinkTargetByClass($classname, 
"suggestedsolution"),
 
 1187                                 array(
"suggestedsolution", 
"saveSuggestedSolution", 
"outSolutionExplorer", 
"cancel", 
 
 1188                                 "addSuggestedSolution",
"cancelExplorer", 
"linkChilds", 
"removeSuggestedSolution" 
 1198                         $ilTabs->addTarget(
"statistics",
 
 1199                                 $this->ctrl->getLinkTargetByClass($classname, 
"assessment"),
 
 1200                                 array(
"assessment"),
 
 1204                 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
 
 1209                         global $___test_express_mode;
 
 1211                         if (!
$_GET[
'test_express_mode'] && !$___test_express_mode) {
 
 1212                             $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"), 
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
 
 1216                             $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"), $link);
 
 1221                         $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui", 
"questions"));
 
 1227                 if( !$this->object->feedbackOBJ->specificAnswerFeedbackExists(array_values($this->object->gaps)) )
 
 1234                 $feedback = 
'<table><tbody>';
 
 1236                 foreach ($this->object->gaps as $index => $answer)
 
 1238                         $caption = $lng->txt(
'gap').
' '.($index+1) .
': ';
 
 1240                         $feedback .= 
'<tr><td>';
 
 1242                         $feedback .= $caption .
'</td><td>';
 
 1243                         $feedback .= $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
 
 1244                                         $this->object->getId(), $index
 
 1247                 $feedback .= 
'</tbody></table>';
 
 1249                 return $this->
object->prepareTextareaOutput($feedback, TRUE);
 
 1255                 $parts  = explode( 
'[gap', $question_text );
 
 1257                 $question_text = 
'';
 
 1258                 foreach ( $parts as $part )
 
 1262                                 $question_text .= $part;
 
 1266                                 $question_text .= 
'[gap ' . $i . $part;
 
 1270                 return $question_text;
 
 1275                 $parts         = preg_split( 
'/\[gap \d*\]/', $question_text );
 
 1276                 $question_text = implode( 
'[gap]', $parts );
 
 1277                 return $question_text;
 
 1305                 return array(
'fixedTextLength');
 
 1314                         $value = $type_selector->getValue();
 
 1319                                 $the_gap = $this->
object->getGap($gapindex);
 
 1320                                 foreach($the_gap->getItemsRaw() as $itemindex => $answer_cloze)
 
 1322                                         $_POST[
'gap_'.$gapindex][
'answer'][$itemindex] = $answer_cloze->getAnswertext();
 
 1326                                 $element->setValues($the_gap->getItemsRaw());
 
 1330                                 $element->setChecked($the_gap->getShuffle());
 
 1339                 foreach($relevant_answers as 
$pass)
 
 1341                         $passes[$pass[
'active_fi'].
'-'.$pass[
'pass']] = 
'-';
 
 1343                 $passcount = count($passes);
 
 1345                 foreach($relevant_answers as $pass)
 
 1347                         $actives[$pass[
'active_fi']] = $pass[
'active_fi'];
 
 1349                 $usercount = count($actives);
 
 1350                 $tpl = 
new ilTemplate(
'tpl.il_as_aggregated_answers_header.html', 
true, 
true, 
"Modules/TestQuestionPool");
 
 1351                 $tpl->setVariable(
'HEADERTEXT', $this->lng->txt(
'overview'));
 
 1352                 $tpl->setVariable(
'NUMBER_OF_USERS_INFO', $this->lng->txt(
'number_of_users'));
 
 1353                 $tpl->setVariable(
'NUMBER_OF_USERS', $usercount);
 
 1354                 $tpl->setVariable(
'NUMBER_OF_PASSES_INFO', $this->lng->txt(
'number_of_passes'));
 
 1355                 $tpl->setVariable(
'NUMBER_OF_PASSES', $passcount);
 
 1364                 foreach($relevant_answers_chosen as $answer)
 
 1366                         $gaps[$answer[
'value1']][] = $answer;
 
 1380                 foreach($aggregate as $index => $gap)
 
 1382                         $tpl = 
new ilTemplate(
'tpl.il_as_aggregated_answers_table.html', 
true, 
true, 
"Modules/TestQuestionPool");
 
 1383                         $tpl->setVariable( 
'OPTION_HEADER', $this->lng->txt(
'answer') );
 
 1384                         $tpl->setVariable( 
'COUNT_HEADER', $this->lng->txt(
'count') );
 
 1386                         $current_gap_definition = $this->
object->getGap($index);
 
 1387                         switch ($current_gap_definition->getType())
 
 1390                                         $gaptype = $this->lng->txt(
'text_gap');
 
 1394                                         $gaptype = $this->lng->txt(
'select_gap');
 
 1398                                         $gaptype = $this->lng->txt(
'numeric_gap');
 
 1402                         $tpl->setVariable( 
'AGGREGATION_HEADER', 
 
 1403                                                            $this->lng->txt(
'gap')
 
 1404                                                            . 
' ' . ($index+1) 
 
 1405                                                            . 
' <small>(' . $gaptype . 
')</small>');
 
 1406                         $html .= 
$tpl->get();
 
 1414                 $the_gap = $this->
object->getGap($gap_answers[0][
'value1']);
 
 1415                 foreach($the_gap->getItems() as $answer)
 
 1417                         $answer_texts[] = $answer->getAnswertext();
 
 1420                 foreach($gap_answers as $answer)
 
 1422                         if(isset($gapdata[$answer[
'value2']]))
 
 1424                                 $gapdata[$answer[
'value2']]++;
 
 1426                                 $gapdata[$answer[
'value2']] = 1;
 
 1430                 foreach($gapdata as $answer => $count)
 
 1432                         $tpl->setCurrentBlock( 
'aggregaterow' );
 
 1433                         $tpl->setVariable( 
'OPTION', 
'<p id="text_answer_' . $index . 
'_' . $temp_counter . 
'">' . $answer . 
'</p>');
 
 1434                         if(!in_array($answer, $answer_texts))
 
 1436                                    $tpl->setVariable( 
'ACTION', 
'<input class="add_correction_answer submit" for="text_answer_' . $index . 
 
 1437                                                                           '_' . $temp_counter . 
'"  name="' . $index . 
'" value="Add"/>' );
 
 1438                                    $tpl->setVariable( 
'POINTS', 
'<input type="text" id="text_points_' . $index . 
'_' . $temp_counter . 
'" value="0"/>' );
 
 1440                         $tpl->setVariable( 
'COUNT', $count );
 
 1441                         $tpl->parseCurrentBlock();
 
 1444                 $tpl->touchBlock(
'js_cloze');
 
 1451                 foreach($gap as $answer)
 
 1453                         $current_gap = $this->
object->getGap($answer[
'value1']);
 
 1454                         $items=$current_gap->getItemsRaw();
 
 1455                         $item = $items[$answer[
'value2']];
 
 1456                         $text = $item->getAnswertext();
 
 1457                         if(isset($gapdata[$text]))
 
 1461                                 $gapdata[$text] = 1;
 
 1465                 foreach($gapdata as $answer => $count)
 
 1467                         $tpl->setCurrentBlock( 
'aggregaterow' );
 
 1468                         $tpl->setVariable( 
'OPTION', $answer );
 
 1469                         $tpl->setVariable( 
'COUNT', $count );
 
 1470                         $tpl->parseCurrentBlock();
 
 1478                 foreach($gap as $answer)
 
 1480                         if(isset($gapdata[$answer[
'value2']]))
 
 1482                                 $gapdata[$answer[
'value2']]++;
 
 1484                                 $gapdata[$answer[
'value2']] = 1;
 
 1488                 foreach($gapdata as $answer => $count)
 
 1490                         $tpl->setCurrentBlock( 
'aggregaterow' );
 
 1491                         $tpl->setVariable( 
'OPTION', $answer );
 
 1492                         $tpl->setVariable( 
'COUNT', $count );
 
 1493                         $tpl->parseCurrentBlock();
 
 1504                         $type_selector->setDisabled(
true);
 
 1505                         $value = $type_selector->getValue();
 
 1511                                         $this->disableSelectGapFields($form, $gapindex);
 
 1520         public function disableSelectGapFields($form, $gapindex)
 
 1522                 $element = $form->getItemByPostvar(
'gap_'.$gapindex);
 
 1523                 $element->setDisableActions(
true);
 
 1524                 $element->setDisableText(
true);
 
 1527                 $element = $form->getItemByPostvar(
'shuffle_'.$gapindex);
 
 1528                 $element->setDisabled(
true);