4require_once 
'./Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
 
    5require_once 
'./Modules/TestQuestionPool/interfaces/interface.ilGuiQuestionScoringAdjustable.php';
 
    6require_once 
'./Modules/TestQuestionPool/interfaces/interface.ilGuiAnswerScoringAdjustable.php';
 
   39        parent::__construct();
 
   40        include_once 
"./Modules/TestQuestionPool/classes/class.assClozeTest.php";
 
   43            $this->
object->loadFromDb(
$id);
 
   49        if (preg_match(
"/^(removegap|addgap)_(\d+)$/", $cmd, $matches)) {
 
   51            $this->gapIndex = $matches[2];
 
   61        $hasErrors = (!$always) ? $this->
editQuestion(
true) : 
false;
 
   63            require_once 
'Services/Form/classes/class.ilPropertyFormGUI.php';
 
   65            $cloze_text = $this->
object->getHtmlQuestionContentPurifier()->purify(
$_POST[
'cloze_text']);
 
   68            $_POST[
'cloze_text'] = $cloze_text;
 
   69            $this->
object->setQuestion(
$_POST[
'question']);
 
   72            $this->
object->setClozeText(
$_POST[
"cloze_text"]);
 
   80        $cloze_text = 
$_POST[
'cloze_text'];
 
   82        $_POST[
'cloze_text'] = $cloze_text;
 
   88        if (is_array(
$_POST[
'gap'])) {
 
   89            if ($this->ctrl->getCmd() != 
'createGaps') {
 
   90                $this->
object->clearGapAnswers();
 
   93            foreach (
$_POST[
'gap'] as $idx => $hidden) {
 
   94                $clozetype = 
$_POST[
'clozetype_' . $idx];
 
   96                $this->
object->setGapType($idx, $clozetype);
 
  101                        $this->
object->setGapShuffle($idx, 0);
 
  103                        if ($this->ctrl->getCmd() != 
'createGaps') {
 
  104                            if (is_array(
$_POST[
'gap_' . $idx][
'answer'])) {
 
  105                                foreach (
$_POST[
'gap_' . $idx][
'answer'] as $order => $value) {
 
  106                                    $this->
object->addGapAnswer($idx, $order, $value);
 
  109                                $this->
object->addGapAnswer($idx, 0, 
'');
 
  113                        if (is_array(
$_POST[
'gap_' . $idx][
'points'])) {
 
  114                            foreach (
$_POST[
'gap_' . $idx][
'points'] as $order => $value) {
 
  115                                $this->
object->setGapAnswerPoints($idx, $order, $value);
 
  119                        if (array_key_exists(
'gap_' . $idx . 
'_gapsize', 
$_POST)) {
 
  120                            $this->
object->setGapSize($idx, $order, 
$_POST[
'gap_' . $idx . 
'_gapsize']);
 
  127                        $this->
object->setGapShuffle($idx, (
int) (isset(
$_POST[
"shuffle_$idx"]) && 
$_POST[
"shuffle_$idx"]));
 
  129                        if ($this->ctrl->getCmd() != 
'createGaps') {
 
  130                            if (is_array(
$_POST[
'gap_' . $idx][
'answer'])) {
 
  131                                foreach (
$_POST[
'gap_' . $idx][
'answer'] as $order => $value) {
 
  132                                    $this->
object->addGapAnswer($idx, $order, $value);
 
  135                                $this->
object->addGapAnswer($idx, 0, 
'');
 
  139                        if (is_array(
$_POST[
'gap_' . $idx][
'points'])) {
 
  140                            foreach (
$_POST[
'gap_' . $idx][
'points'] as $order => $value) {
 
  141                                $this->
object->setGapAnswerPoints($idx, $order, $value);
 
  148                        $this->
object->setGapShuffle($idx, 0);
 
  150                        $gap = $this->
object->getGap($idx);
 
  155                        $this->
object->getGap($idx)->clearItems();
 
  157                        if (array_key_exists(
'gap_' . $idx . 
'_numeric', 
$_POST)) {
 
  158                            if ($this->ctrl->getCmd() != 
'createGaps') {
 
  159                                $this->
object->addGapAnswer(
 
  162                                    str_replace(
",", 
".", 
$_POST[
'gap_' . $idx . 
'_numeric'])
 
  166                            $this->
object->setGapAnswerLowerBound(
 
  169                                str_replace(
",", 
".", 
$_POST[
'gap_' . $idx . 
'_numeric_lower'])
 
  172                            $this->
object->setGapAnswerUpperBound(
 
  175                                str_replace(
",", 
".", 
$_POST[
'gap_' . $idx . 
'_numeric_upper'])
 
  178                            $this->
object->setGapAnswerPoints($idx, 0, 
$_POST[
'gap_' . $idx . 
'_numeric_points']);
 
  180                            if ($this->ctrl->getCmd() != 
'createGaps') {
 
  181                                $this->
object->addGapAnswer($idx, 0, 
'');
 
  184                            $this->
object->setGapAnswerLowerBound($idx, 0, 
'');
 
  186                            $this->
object->setGapAnswerUpperBound($idx, 0, 
'');
 
  189                        if (array_key_exists(
'gap_' . $idx . 
'_gapsize', 
$_POST)) {
 
  190                            $this->
object->setGapSize($idx, $order, 
$_POST[
'gap_' . $idx . 
'_gapsize']);
 
  195                $assClozeGapCombinationObject->clearGapCombinationsFromDb($this->object->getId());
 
  197                    isset(
$_POST[
'gap_combination']) &&
 
  198                    is_array(
$_POST[
'gap_combination']) &&
 
  199                    count(
$_POST[
'gap_combination']) > 0
 
  201                    $assClozeGapCombinationObject->saveGapCombinationToDb(
 
  202                        $this->object->getId(),
 
  208            if ($this->ctrl->getCmd() != 
'createGaps') {
 
  209                $this->
object->updateClozeTextFromGaps();
 
  216        $this->
object->setClozeText(
$_POST[
'cloze_text']);
 
  217        $this->
object->setTextgapRating(
$_POST[
"textgap_rating"]);
 
  218        $this->
object->setIdenticalScoring(
$_POST[
"identical_scoring"]);
 
  219        $this->
object->setFixedTextLength(
$_POST[
"fixedTextLength"]);
 
  232        include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
 
  234        $this->editForm = 
$form;
 
  236        $form->setFormAction($this->ctrl->getFormAction($this));
 
  238        $form->setMultipart(
false);
 
  239        $form->setTableWidth(
"100%");
 
  240        $form->setId(
"assclozetest");
 
  253            $form->setValuesByPost();
 
  255            $form->setValuesByPost();   
 
  263            $this->tpl->setVariable(
"QUESTION_DATA", 
$form->getHTML());
 
  272        $title->setMaxLength(100);
 
  273        $title->setValue($this->object->getTitle());
 
  274        $title->setRequired(
true);
 
  277        if (!$this->object->getSelfAssessmentEditingMode()) {
 
  279            $author = 
new ilTextInputGUI($this->lng->txt(
"author"), 
"author");
 
  280            $author->setValue($this->object->getAuthor());
 
  281            $author->setRequired(
true);
 
  282            $form->addItem($author);
 
  293            if (trim($author) == 
"") {
 
  296            $hi->setValue($author);
 
  302        $question->setValue($this->object->prepareTextareaOutput($this->object->getQuestion()));
 
  303        $question->setRequired(
true);
 
  304        $question->setRows(10);
 
  305        $question->setCols(80);
 
  306        if (!$this->object->getSelfAssessmentEditingMode()) {
 
  308                $question->setUseRte(
true);
 
  309                include_once 
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
 
  311                $question->addPlugin(
"latex");
 
  312                $question->addButton(
"latex");
 
  313                $question->addButton(
"pastelatex");
 
  314                $question->setRTESupport($this->object->getId(), 
"qpl", 
"assessment");
 
  317            require_once 
'Modules/TestQuestionPool/classes/questions/class.ilAssSelfAssessmentQuestionFormatter.php';
 
  319            $question->setUseTagsForRteOnly(
false);
 
  321        $form->addItem($question);
 
  331        if (!$this->object->getSelfAssessmentEditingMode()) {
 
  334            $duration->setShowHours(
true);
 
  335            $duration->setShowMinutes(
true);
 
  336            $duration->setShowSeconds(
true);
 
  337            $ewt = $this->
object->getEstimatedWorkingTime();
 
  338            $duration->setHours($ewt[
"h"]);
 
  339            $duration->setMinutes($ewt[
"m"]);
 
  340            $duration->setSeconds($ewt[
"s"]);
 
  341            $duration->setRequired(
false);
 
  342            $form->addItem($duration);
 
  345            if (strlen($this->object->getNrOfTries())) {
 
  346                $nr_tries = $this->
object->getNrOfTries();
 
  348                $nr_tries = $this->
object->getDefaultNrOfTries();
 
  359            $ni = 
new ilNumberInputGUI($this->lng->txt(
"qst_nr_of_tries"), 
"nr_of_tries");
 
  360            $ni->setValue($nr_tries);
 
  364            $ni->setMaxLength(5);
 
  365            $ni->setRequired(
true);
 
  374        $cloze_text->setRequired(
true);
 
  376        $cloze_text->setInfo($this->lng->txt(
"close_text_hint"));
 
  377        $cloze_text->setRows(10);
 
  378        $cloze_text->setCols(80);
 
  379        if (!$this->object->getSelfAssessmentEditingMode()) {
 
  381                $cloze_text->setUseRte(
true);
 
  382                include_once 
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
 
  384                $cloze_text->addPlugin(
"latex");
 
  385                $cloze_text->addButton(
"latex");
 
  386                $cloze_text->addButton(
"pastelatex");
 
  389            require_once 
'Modules/TestQuestionPool/classes/questions/class.ilAssSelfAssessmentQuestionFormatter.php';
 
  391            $cloze_text->setUseTagsForRteOnly(
false);
 
  393        $cloze_text->setRTESupport($this->object->getId(), 
"qpl", 
"assessment");
 
  394        $form->addItem($cloze_text);
 
  396        $tpl = 
new ilTemplate(
"tpl.il_as_qpl_cloze_gap_button_code.html", 
true, 
true, 
"Modules/TestQuestionPool");
 
  399        require_once 
'Services/UIComponent/SplitButton/classes/class.ilSplitButtonGUI.php';
 
  400        require_once 
'Services/UIComponent/Button/classes/class.ilJsLinkButton.php';
 
  404        $sb_text_gap->setCaption(
'text_gap');
 
  405        $sb_text_gap->setName(
'gapbutton');
 
  406        $sb_text_gap->setId(
'gaptrigger_text');
 
  407        $action_button->setDefaultButton($sb_text_gap);
 
  410        $sb_sel_gap->setCaption(
'select_gap');
 
  411        $sb_sel_gap->setName(
'gapbutton_select');
 
  412        $sb_sel_gap->setId(
'gaptrigger_select');
 
  416        $sb_num_gap->setCaption(
'numeric_gap');
 
  417        $sb_num_gap->setName(
'gapbutton_numeric');
 
  418        $sb_num_gap->setId(
'gaptrigger_numeric');
 
  421        $tpl->setVariable(
'BUTTON', $action_button->render());
 
  422        $tpl->parseCurrentBlock();
 
  424        $button->setHtml(
$tpl->get());
 
  425        $form->addItem($button);
 
  428        if (!$this->object->getSelfAssessmentEditingMode()) {
 
  429            $textrating = 
new ilSelectInputGUI($this->lng->txt(
"text_rating"), 
"textgap_rating");
 
  430            $text_options = array(
 
  431                "ci" => $this->lng->txt(
"cloze_textgap_case_insensitive"),
 
  432                "cs" => $this->lng->txt(
"cloze_textgap_case_sensitive"),
 
  433                "l1" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"), 
"1"),
 
  434                "l2" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"), 
"2"),
 
  435                "l3" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"), 
"3"),
 
  436                "l4" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"), 
"4"),
 
  437                "l5" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"), 
"5")
 
  439            $textrating->setOptions($text_options);
 
  440            $textrating->setValue($this->object->getTextgapRating());
 
  441            $form->addItem($textrating);
 
  444            $fixedTextLength = 
new ilNumberInputGUI($this->lng->txt(
"cloze_fixed_textlength"), 
"fixedTextLength");
 
  445            $ftl = $this->
object->getFixedTextLength();
 
  447            $fixedTextLength->setValue($ftl > 0 ? $ftl : 
'');
 
  448            $fixedTextLength->setMinValue(0);
 
  449            $fixedTextLength->setSize(3);
 
  450            $fixedTextLength->setMaxLength(6);
 
  451            $fixedTextLength->setInfo($this->lng->txt(
'cloze_fixed_textlength_description'));
 
  452            $fixedTextLength->setRequired(
false);
 
  453            $form->addItem($fixedTextLength);
 
  456            $identical_scoring = 
new ilCheckboxInputGUI($this->lng->txt(
"identical_scoring"), 
"identical_scoring");
 
  457            $identical_scoring->setValue(1);
 
  458            $identical_scoring->setChecked($this->object->getIdenticalScoring());
 
  459            $identical_scoring->setInfo($this->lng->txt(
'identical_scoring_desc'));
 
  460            $identical_scoring->setRequired(
false);
 
  461            $form->addItem($identical_scoring);
 
  468        if (self::OLD_CLOZE_TEST_UI) {
 
  469            for ($gapCounter = 0; $gapCounter < $this->
object->getGapCount(); $gapCounter++) {
 
  474            require_once 
'Modules/TestQuestionPool/classes/Form/class.ilClozeGapInputBuilderGUI.php';
 
  477            $combination_exists = $assClozeGapCombinationObject->combinationExistsForQid($this->object->id);
 
  478            if ($combination_exists) {
 
  479                $combinations = $assClozeGapCombinationObject->loadFromDb($this->object->id);
 
  484            $new_builder->setValueByArray($json);
 
  485            $new_builder->setValueCombinationFromDb($combinations);
 
  486            $form->addItem($new_builder);
 
  493        $gap = $this->
object->getGaps();
 
  498        $translate_type = array(
'text',
'select',
'numeric');
 
  500        foreach ($gap as $content) {
 
  502            $value = $content->getItemsRaw();
 
  504            for ($j = 0;$j < count($value);$j++) {
 
  505                if ($content->getType() == 2) {
 
  507                        'answer' => $value[$j]->getAnswerText(),
 
  508                        'lower' => $value[$j]->getLowerBound(),
 
  509                        'upper' => $value[$j]->getUpperBound(),
 
  510                        'points' => $value[$j]->getPoints(),
 
  515                        'answer' => $value[$j]->getAnswerText(),
 
  516                        'points' => $value[$j]->getPoints(),
 
  520                    if ($content->getType() == 1) {
 
  521                        $shuffle = $content->getShuffle();
 
  525            $answers[
$i] = array(
 
  526            'type' => $translate_type[$content->getType()] ,
 
  528            'shuffle' => $shuffle,
 
  529            'text_field_length' => $content->getGapSize() > 0 ? $content->getGapSize() :  
'',
 
  530            'used_in_gap_combination' => 
true);
 
  548        $gap = $this->
object->getGap($gapCounter);
 
  555        $header->setTitle($this->lng->txt(
"gap") . 
" " . ($gapCounter + 1));
 
  559        $gapcounter->setValue($gapCounter);
 
  560        $form->addItem($gapcounter);
 
  562        $gaptype = 
new ilSelectInputGUI($this->lng->txt(
'type'), 
"clozetype_$gapCounter");
 
  564            0 => $this->lng->txt(
"text_gap"),
 
  565            1 => $this->lng->txt(
"select_gap"),
 
  566            2 => $this->lng->txt(
"numeric_gap")
 
  569        $gaptype->setValue($gap->getType());
 
  570        $form->addItem($gaptype);
 
  575            if (count($gap->getItemsRaw()) == 0) {
 
  580            if (count($gap->getItemsRaw()) == 0) {
 
  587            if (count($gap->getItemsRaw()) == 0) {
 
  590            foreach ($gap->getItemsRaw() as $item) {
 
  604        $gapSizeFormItem = 
new ilNumberInputGUI($this->lng->txt(
'cloze_fixed_textlength'), 
"gap_" . $gapCounter . 
'_gapsize');
 
  606        $gapSizeFormItem->allowDecimals(
false);
 
  607        $gapSizeFormItem->setMinValue(0);
 
  608        $gapSizeFormItem->setSize(3);
 
  609        $gapSizeFormItem->setMaxLength(6);
 
  610        $gapSizeFormItem->setInfo($this->lng->txt(
'cloze_gap_size_info'));
 
  611        $gapSizeFormItem->setValue($gap->getGapSize());
 
  612        $form->addItem($gapSizeFormItem);
 
  631        include_once 
"./Modules/TestQuestionPool/classes/class.ilAnswerWizardInputGUI.php";
 
  632        include_once 
"./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
 
  635        $values->setQuestionObject($this->
object);
 
  639        $values->setValues($gap->getItemsRaw());
 
  643        $shuffle = 
new ilCheckboxInputGUI($this->lng->txt(
"shuffle_answers"), 
"shuffle_" . $gapCounter . 
"");
 
  644        $shuffle->setValue(1);
 
  645        $shuffle->setChecked($gap->getShuffle());
 
  646        $shuffle->setRequired(
false);
 
  647        $form->addItem($shuffle);
 
  665        include_once 
"./Modules/TestQuestionPool/classes/class.ilAnswerWizardInputGUI.php";
 
  666        include_once 
"./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
 
  669        $values->setQuestionObject($this->
object);
 
  672        $values->setValues($gap->getItemsRaw());
 
  675        if ($this->object->getFixedTextLength() > 0) {
 
  676            $values->setSize($this->object->getFixedTextLength());
 
  677            $values->setMaxLength($this->object->getFixedTextLength());
 
  697        if (!$this->object->getSelfAssessmentEditingMode()) {
 
  698            $value = 
new ilFormulaInputGUI($this->lng->txt(
'value'), 
"gap_" . $gapCounter . 
"_numeric");
 
  699            $value->setInlineStyle(
'text-align: right;');
 
  701            $lowerbound = 
new ilFormulaInputGUI($this->lng->txt(
'range_lower_limit'), 
"gap_" . $gapCounter . 
"_numeric_lower");
 
  702            $lowerbound->setInlineStyle(
'text-align: right;');
 
  704            $upperbound = 
new ilFormulaInputGUI($this->lng->txt(
'range_upper_limit'), 
"gap_" . $gapCounter . 
"_numeric_upper");
 
  705            $upperbound->setInlineStyle(
'text-align: right;');
 
  707            $value = 
new ilNumberInputGUI($this->lng->txt(
'value'), 
"gap_" . $gapCounter . 
"_numeric");
 
  708            $value->allowDecimals(
true);
 
  710            $lowerbound = 
new ilNumberInputGUI($this->lng->txt(
'range_lower_limit'), 
"gap_" . $gapCounter . 
"_numeric_lower");
 
  711            $lowerbound->allowDecimals(
true);
 
  713            $upperbound = 
new ilNumberInputGUI($this->lng->txt(
'range_upper_limit'), 
"gap_" . $gapCounter . 
"_numeric_upper");
 
  714            $upperbound->allowDecimals(
true);
 
  719        $value->setRequired(
true);
 
  720        $form->addItem($value);
 
  722        $lowerbound->setSize(10);
 
  723        $lowerbound->setRequired(
true);
 
  725        $form->addItem($lowerbound);
 
  727        $upperbound->setSize(10);
 
  728        $upperbound->setRequired(
true);
 
  730        $form->addItem($upperbound);
 
  732        if ($this->object->getFixedTextLength() > 0) {
 
  733            $value->setSize($this->object->getFixedTextLength());
 
  734            $value->setMaxLength($this->object->getFixedTextLength());
 
  735            $lowerbound->setSize($this->object->getFixedTextLength());
 
  736            $lowerbound->setMaxLength($this->object->getFixedTextLength());
 
  737            $upperbound->setSize($this->object->getFixedTextLength());
 
  738            $upperbound->setMaxLength($this->object->getFixedTextLength());
 
  741        $points = 
new ilNumberInputGUI($this->lng->txt(
'points'), 
"gap_" . $gapCounter . 
"_numeric_points");
 
  742        $points->allowDecimals(
true);
 
  744        $points->setRequired(
true);
 
  746        $form->addItem($points);
 
  756        $this->
object->saveToDb();
 
  766        $this->
object->deleteAnswerText($this->gapIndex, key(
$_POST[
'cmd'][
'removegap_' . $this->gapIndex]));
 
  776        $this->
object->addGapAnswer($this->gapIndex, key(
$_POST[
'cmd'][
'addgap_' . $this->gapIndex]) + 1, 
"");
 
  788    public function getPreview($show_question_only = 
false, $showInlineFeedback = 
false)
 
  793        include_once 
"./Services/UICore/classes/class.ilTemplate.php";
 
  794        $template = 
new ilTemplate(
"tpl.il_as_qpl_cloze_question_output.html", 
true, 
true, 
"Modules/TestQuestionPool");
 
  795        $output = $this->
object->getClozeText();
 
  796        foreach ($this->object->getGaps() as $gap_index => $gap) {
 
  797            switch ($gap->getType()) {
 
  799                    $gaptemplate = 
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_text.html", 
true, 
true, 
"Modules/TestQuestionPool");
 
  801                    $gap_size = $gap->getGapSize() > 0 ? $gap->getGapSize() : $this->
object->getFixedTextLength();
 
  803                        $gaptemplate->setCurrentBlock(
'size_and_maxlength');
 
  804                        $gaptemplate->setVariable(
"TEXT_GAP_SIZE", $gap_size);
 
  805                        $gaptemplate->parseCurrentBlock();
 
  807                    $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
 
  808                    foreach ($user_solution as $val1 => $val2) {
 
  809                        if (strcmp($val1, $gap_index) == 0) {
 
  814                                        $output  = $this->
object->replaceFirstGap(
$output, $gaptemplate->get());
 
  818                    $gaptemplate = 
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_select.html", 
true, 
true, 
"Modules/TestQuestionPool");
 
  819                    foreach ($gap->getItems($this->object->getShuffler()) as $item) {
 
  820                        $gaptemplate->setCurrentBlock(
"select_gap_option");
 
  821                        $gaptemplate->setVariable(
"SELECT_GAP_VALUE", $item->getOrder());
 
  823                        foreach ($user_solution as $val1 => $val2) {
 
  824                            if (strcmp($val1, $gap_index) == 0) {
 
  825                                if (strcmp($val2, $item->getOrder()) == 0) {
 
  826                                    $gaptemplate->setVariable(
"SELECT_GAP_SELECTED", 
" selected=\"selected\"");
 
  830                        $gaptemplate->parseCurrentBlock();
 
  832                    $gaptemplate->setVariable(
"PLEASE_SELECT", $this->lng->txt(
"please_select"));
 
  833                    $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
 
  834                    $output = $this->
object->replaceFirstGap(
$output, $gaptemplate->get());
 
  838                    $gaptemplate = 
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_numeric.html", 
true, 
true, 
"Modules/TestQuestionPool");
 
  839                    $gap_size = $gap->getGapSize() > 0 ? $gap->getGapSize() : $this->
object->getFixedTextLength();
 
  841                        $gaptemplate->setCurrentBlock(
'size_and_maxlength');
 
  842                        $gaptemplate->setVariable(
"TEXT_GAP_SIZE", $gap_size);
 
  843                        $gaptemplate->parseCurrentBlock();
 
  845                    $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
 
  846                    foreach ($user_solution as $val1 => $val2) {
 
  847                        if (strcmp($val1, $gap_index) == 0) {
 
  852                                        $output  = $this->
object->replaceFirstGap(
$output, $gaptemplate->get());
 
  857        $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), 
true));
 
  858        $template->setVariable(
"CLOZETEXT", $this->object->prepareTextareaOutput(
$output, 
true));
 
  860        if (!$show_question_only) {
 
  864        return $questionoutput;
 
  895        $graphicalOutput = 
false,
 
  896        $result_output = 
false,
 
  897        $show_question_only = 
true,
 
  898        $show_feedback = 
false,
 
  899        $show_correct_solution = 
false,
 
  900        $show_manual_scoring = 
false,
 
  901        $show_question_text = 
true 
  904        $user_solution = array();
 
  905        if (($active_id > 0) && (!$show_correct_solution)) {
 
  908            if (!is_array($user_solution)) {
 
  909                $user_solution = array();
 
  913        include_once 
"./Services/UICore/classes/class.ilTemplate.php";
 
  914        $template = 
new ilTemplate(
"tpl.il_as_qpl_cloze_question_output_solution.html", 
true, 
true, 
"Modules/TestQuestionPool");
 
  915        $output = $this->
object->getClozeText();
 
  917        $check_for_gap_combinations = $assClozeGapCombinationObject->loadFromDb($this->object->getId());
 
  919        foreach ($this->object->getGaps() as $gap_index => $gap) {
 
  920            $gaptemplate = 
new ilTemplate(
"tpl.il_as_qpl_cloze_question_output_solution_gap.html", 
true, 
true, 
"Modules/TestQuestionPool");
 
  922            foreach ($user_solution as $solutionarray) {
 
  923                if ($solutionarray[
"value1"] == $gap_index) {
 
  924                    $found = $solutionarray;
 
  929                if ($graphicalOutput) {
 
  931                    $details = $this->
object->calculateReachedPoints($active_id, 
$pass, 
true, 
true);
 
  932                    $check = $details[$gap_index];
 
  934                    if (count($check_for_gap_combinations) != 0) {
 
  935                        $gaps_used_in_combination = $assClozeGapCombinationObject->getGapsWhichAreUsedInCombination($this->object->getId());
 
  936                        $custom_user_solution = array();
 
  937                        if (array_key_exists($gap_index, $gaps_used_in_combination)) {
 
  938                            $combination_id = $gaps_used_in_combination[$gap_index];
 
  939                            foreach ($gaps_used_in_combination as 
$key => $value) {
 
  941                                if ($value == $combination_id) {
 
  942                                    foreach ($user_solution as $solution_key => $solution_value) {
 
  943                                        if ($solution_value[
'value1'] == 
$key) {
 
  944                                            $result_row = array();
 
  945                                            $result_row[
'gap_id'] = $solution_value[
'value1'];
 
  946                                            $result_row[
'value'] = $solution_value[
'value2'];
 
  947                                            array_push($custom_user_solution, $result_row);
 
  952                            $points_array = $this->
object->calculateCombinationResult($custom_user_solution);
 
  953                            $max_combination_points = $assClozeGapCombinationObject->getMaxPointsForCombination($this->object->getId(), $combination_id);
 
  954                            if ($points_array[0] == $max_combination_points) {
 
  956                                $gaptemplate->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
 
  957                            } elseif ($points_array[0] > 0) {
 
  959                                $gaptemplate->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
 
  962                                $gaptemplate->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
 
  965                            if ($check[
"best"]) {
 
  966                                $gaptemplate->setCurrentBlock(
"icon_ok");
 
  968                                $gaptemplate->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
 
  969                                $gaptemplate->parseCurrentBlock();
 
  971                                $gaptemplate->setCurrentBlock(
"icon_not_ok");
 
  972                                if ($check[
"positive"]) {
 
  974                                    $gaptemplate->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
 
  977                                    $gaptemplate->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
 
  979                                $gaptemplate->parseCurrentBlock();
 
  983                        if ($check[
"best"]) {
 
  984                            $gaptemplate->setCurrentBlock(
"icon_ok");
 
  986                            $gaptemplate->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
 
  987                            $gaptemplate->parseCurrentBlock();
 
  989                            $gaptemplate->setCurrentBlock(
"icon_not_ok");
 
  990                            if ($check[
"positive"]) {
 
  992                                $gaptemplate->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
 
  995                                $gaptemplate->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
 
  997                            $gaptemplate->parseCurrentBlock();
 
 1002            if ($result_output) {
 
 1003                $points = $this->
object->getMaximumGapPoints($gap_index);
 
 1004                $resulttext = ($points == 1) ? 
"(%s " . $this->lng->txt(
"point") . 
")" : 
"(%s " . $this->lng->txt(
"points") . 
")";
 
 1005                $gaptemplate->setCurrentBlock(
"result_output");
 
 1006                $gaptemplate->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $points));
 
 1007                $gaptemplate->parseCurrentBlock();
 
 1009            $combination = 
null;
 
 1010            switch ($gap->getType()) {
 
 1013                    if (($active_id > 0) && (!$show_correct_solution)) {
 
 1014                        if ((count($found) == 0) || (strlen(trim($found[
"value2"])) == 0)) {
 
 1015                            for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++) {
 
 1016                                $solutiontext .= 
" ";
 
 1022                        $solutiontext = $this-> 
getBestSolutionText($gap, $gap_index, $check_for_gap_combinations);
 
 1026                                        $output  = $this->
object->replaceFirstGap(
$output, $gaptemplate->get());
 
 1031                    if (($active_id > 0) && (!$show_correct_solution)) {
 
 1032                        if ((count($found) == 0) || (strlen(trim($found[
"value2"])) == 0)) {
 
 1033                            for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++) {
 
 1034                                $solutiontext .= 
" ";
 
 1037                            $item = $gap->getItem($found[
"value2"]);
 
 1038                            if (is_object($item)) {
 
 1041                                for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++) {
 
 1042                                    $solutiontext .= 
" ";
 
 1047                        $solutiontext = $this-> 
getBestSolutionText($gap, $gap_index, $check_for_gap_combinations);
 
 1051                                        $output  = $this->
object->replaceFirstGap(
$output, $gaptemplate->get());
 
 1056                    if (($active_id > 0) && (!$show_correct_solution)) {
 
 1057                        if ((count($found) == 0) || (strlen(trim($found[
"value2"])) == 0)) {
 
 1058                            for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++) {
 
 1059                                $solutiontext .= 
" ";
 
 1065                        $solutiontext = $this-> 
getBestSolutionText($gap, $gap_index, $check_for_gap_combinations);
 
 1069                                        $output  = $this->
object->replaceFirstGap(
$output, $gaptemplate->get());
 
 1075        if ($show_question_text) {
 
 1078                $this->object->prepareTextareaOutput($this->object->getQuestion(), 
true)
 
 1082        $template->setVariable(
"CLOZETEXT", $this->object->prepareTextareaOutput(
$output, 
true));
 
 1084        $solutiontemplate = 
new ilTemplate(
"tpl.il_as_tst_solution_output.html", 
true, 
true, 
"Modules/TestQuestionPool");
 
 1088        if ($show_feedback) {
 
 1091                $feedback .= strlen($fb) ? $fb : 
'';
 
 1095                $this->object->fetchIndexedValuesFromValuePairs($user_solution)
 
 1097            $feedback .= strlen($fb) ? $fb : 
'';
 
 1099        if (strlen($feedback)) {
 
 1105            $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
 
 1106            $solutiontemplate->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput($feedback, 
true));
 
 1109        $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
 
 1111        $solutionoutput = $solutiontemplate->get();
 
 1113        if (!$show_question_only) {
 
 1115            $solutionoutput = $this->
getILIASPage($solutionoutput);
 
 1118        return $solutionoutput;
 
 1129        $combination = 
null;
 
 1130        foreach ((array) $gap_combinations as $combiGapSolRow) {
 
 1131            if ($combiGapSolRow[
'gap_fi'] == $gap_index && $combiGapSolRow[
'best_solution']) {
 
 1132                $combination = $combiGapSolRow;
 
 1137            $this->object->getShuffler(),
 
 1140        return $best_solution_text;
 
 1145        include_once 
"./Modules/Test/classes/class.ilObjTest.php";
 
 1147        if (strlen($manual_feedback)) {
 
 1148            return $manual_feedback;
 
 1150        $correct_feedback = $this->
object->feedbackOBJ->getGenericFeedbackTestPresentation($this->object->getId(), 
true);
 
 1151        $incorrect_feedback = $this->
object->feedbackOBJ->getGenericFeedbackTestPresentation($this->object->getId(), 
false);
 
 1152        if (strlen($correct_feedback . $incorrect_feedback)) {
 
 1153            $reached_points = $this->
object->calculateReachedPoints($active_id, 
$pass);
 
 1154            $max_points = $this->
object->getMaximumPoints();
 
 1155            if ($reached_points == $max_points) {
 
 1158                $output .= $incorrect_feedback;
 
 1162        return $this->
object->prepareTextareaOutput(
$output, 
true);
 
 1170                $is_postponed = 
false,
 
 1171        $use_post_solutions = 
false,
 
 1172        $show_feedback = 
false 
 1175        $user_solution = array();
 
 1176        if ($use_post_solutions !== 
false) {
 
 1177            $indexedSolution = $this->
object->fetchSolutionSubmit($use_post_solutions);
 
 1178            $user_solution = $this->
object->fetchValuePairsFromIndexedValues($indexedSolution);
 
 1179        } elseif ($active_id) {
 
 1181            #include_once "./Modules/Test/classes/class.ilObjTest.php";
 
 1182            #if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) 
 1184            #   if (is_null($pass)) $pass = ilObjTest::_getPass($active_id); 
 1186            $user_solution = $this->
object->getTestOutputSolutions($active_id, 
$pass);
 
 1188            if (!is_array($user_solution)) {
 
 1189                $user_solution = array();
 
 1194        include_once 
"./Services/UICore/classes/class.ilTemplate.php";
 
 1195        $template = 
new ilTemplate(
"tpl.il_as_qpl_cloze_question_output.html", 
true, 
true, 
"Modules/TestQuestionPool");
 
 1196        $output = $this->
object->getClozeText();
 
 1197        foreach ($this->object->getGaps() as $gap_index => $gap) {
 
 1198            switch ($gap->getType()) {
 
 1200                    $gaptemplate = 
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_text.html", 
true, 
true, 
"Modules/TestQuestionPool");
 
 1201                    $gap_size = $gap->getGapSize() > 0 ? $gap->getGapSize() : $this->
object->getFixedTextLength();
 
 1203                    if ($gap_size > 0) {
 
 1204                        $gaptemplate->setCurrentBlock(
'size_and_maxlength');
 
 1205                        $gaptemplate->setVariable(
"TEXT_GAP_SIZE", $gap_size);
 
 1206                        $gaptemplate->parseCurrentBlock();
 
 1209                    $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
 
 1210                    foreach ($user_solution as $solution) {
 
 1211                        if (strcmp($solution[
"value1"], $gap_index) == 0) {
 
 1216                                        $output  = $this->
object->replaceFirstGap(
$output, $gaptemplate->get());
 
 1220                    $gaptemplate = 
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_select.html", 
true, 
true, 
"Modules/TestQuestionPool");
 
 1221                    foreach ($gap->getItems($this->object->getShuffler()) as $item) {
 
 1222                        $gaptemplate->setCurrentBlock(
"select_gap_option");
 
 1223                        $gaptemplate->setVariable(
"SELECT_GAP_VALUE", $item->getOrder());
 
 1225                        foreach ($user_solution as $solution) {
 
 1226                            if (strcmp($solution[
"value1"], $gap_index) == 0) {
 
 1227                                if (strcmp($solution[
"value2"], $item->getOrder()) == 0) {
 
 1228                                    $gaptemplate->setVariable(
"SELECT_GAP_SELECTED", 
" selected=\"selected\"");
 
 1232                        $gaptemplate->parseCurrentBlock();
 
 1234                    $gaptemplate->setVariable(
"PLEASE_SELECT", $this->lng->txt(
"please_select"));
 
 1235                    $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
 
 1236                    $output = $this->
object->replaceFirstGap(
$output, $gaptemplate->get());
 
 1240                    $gaptemplate = 
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_numeric.html", 
true, 
true, 
"Modules/TestQuestionPool");
 
 1241                    $gap_size = $gap->getGapSize() > 0 ? $gap->getGapSize() : $this->
object->getFixedTextLength();
 
 1242                    if ($gap_size > 0) {
 
 1243                        $gaptemplate->setCurrentBlock(
'size_and_maxlength');
 
 1244                        $gaptemplate->setVariable(
"TEXT_GAP_SIZE", $gap_size);
 
 1245                        $gaptemplate->parseCurrentBlock();
 
 1248                    $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
 
 1249                    foreach ($user_solution as $solution) {
 
 1250                        if (strcmp($solution[
"value1"], $gap_index) == 0) {
 
 1255                                        $output  = $this->
object->replaceFirstGap(
$output, $gaptemplate->get());
 
 1261        $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), 
true));
 
 1262        $template->setVariable(
"CLOZETEXT", $this->object->prepareTextareaOutput(
$output, 
true));
 
 1264        $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
 
 1278        $rbacsystem = 
$DIC[
'rbacsystem'];
 
 1279        $ilTabs = 
$DIC[
'ilTabs'];
 
 1281        $ilTabs->clearTargets();
 
 1283        $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI", 
"q_id", 
$_GET[
"q_id"]);
 
 1284        include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
 1285        $q_type = $this->
object->getQuestionType();
 
 1287        if (strlen($q_type)) {
 
 1288            $classname = $q_type . 
"GUI";
 
 1289            $this->ctrl->setParameterByClass(strtolower($classname), 
"sel_question_types", $q_type);
 
 1290            $this->ctrl->setParameterByClass(strtolower($classname), 
"q_id", 
$_GET[
"q_id"]);
 
 1291            #                   $this->ctrl->setParameterByClass(strtolower($classname), 'prev_qid', $_REQUEST['prev_qid']); 
 1294        if (
$_GET[
"q_id"]) {
 
 1295            if ($rbacsystem->checkAccess(
'write', 
$_GET[
"ref_id"])) {
 
 1299                    $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI", 
"edit"),
 
 1300                    array(
"edit", 
"insert", 
"exec_pg"),
 
 1310        $force_active = 
false;
 
 1311        $commands = 
$_POST[
"cmd"];
 
 1312        if (is_array($commands)) {
 
 1313            foreach ($commands as 
$key => $value) {
 
 1314                if (preg_match(
"/^removegap_.*/", 
$key, $matches) ||
 
 1315                    preg_match(
"/^addgap_.*/", 
$key, $matches)
 
 1317                    $force_active = 
true;
 
 1321        if ($rbacsystem->checkAccess(
'write', 
$_GET[
"ref_id"])) {
 
 1324                $url = $this->ctrl->getLinkTargetByClass($classname, 
"editQuestion");
 
 1330                array(
"editQuestion", 
"originalSyncForm", 
"save", 
"createGaps", 
"saveEdit"),
 
 1347        if (
$_GET[
"q_id"]) {
 
 1350                $this->ctrl->getLinkTargetByClass($classname, 
"assessment"),
 
 1351                array(
"assessment"),
 
 1362        if (!$this->object->feedbackOBJ->specificAnswerFeedbackExists()) {
 
 1369        $feedback = 
'<table class="test_specific_feedback"><tbody>';
 
 1371        foreach ($this->object->gaps as 
$gapIndex => $gap) {
 
 1372            $answerValue = $this->
object->fetchAnswerValueForGap($userSolution, 
$gapIndex);
 
 1373            $answerIndex = $this->
object->feedbackOBJ->determineAnswerIndexForAnswerValue($gap, $answerValue);
 
 1374            $fb = $this->
object->feedbackOBJ->determineTestOutputGapFeedback(
$gapIndex, $answerIndex);
 
 1377            $feedback .= 
'<tr><td>';
 
 1378            $feedback .= $caption . 
'</td><td>';
 
 1379            $feedback .= $fb . 
'</td> </tr>';
 
 1381        $feedback .= 
'</tbody></table>';
 
 1383        return $this->
object->prepareTextareaOutput($feedback, 
true);
 
 1424        $overview = array();
 
 1425        $aggregation = array();
 
 1426        foreach ($relevant_answers as $answer) {
 
 1427            $overview[$answer[
'active_fi']][$answer[
'pass']][$answer[
'value1']] = $answer[
'value2'];
 
 1430        foreach ($overview as $active) {
 
 1431            foreach ($active as $answer) {
 
 1432                foreach ($answer as $option => $value) {
 
 1433                    $aggregation[$option][$value] = $aggregation[$option][$value] + 1;
 
 1440        foreach ($this->object->getGaps() as $gap) {
 
 1442                $html .= 
'<p>Gap ' . (
$i + 1) . 
' - SELECT</p>';
 
 1445                foreach ($gap->getItems($this->object->getShuffler()) as $gap_item) {
 
 1446                    $aggregate = $aggregation[
$i];
 
 1447                    $html .= 
'<li>' . $gap_item->getAnswerText() . 
' - ' . ($aggregate[$j] ? $aggregate[$j] : 0) . 
'</li>';
 
 1454                $present_elements = array();
 
 1457                    $present_elements[] = $item->getAnswertext();
 
 1460                $html .= 
'<p>Gap ' . (
$i + 1) . 
' - TEXT</p>';
 
 1462                $aggregate = (array) $aggregation[
$i];
 
 1463                foreach ($aggregate as $answer => $count) {
 
 1465                    if (in_array($answer, $present_elements)) {
 
 1466                        $show_mover = 
' style="display: none;" ';
 
 1469                    $html .= 
'<li>' . $answer . 
' - ' . $count
 
 1470                        . 
' <button class="clone_fields_add btn btn-link" ' . $show_mover . 
' data-answer="' . $answer . 
'" name="add_gap_' . 
$i . 
'_0"> 
 1471                                                <span class="sr-only"></span><span class="glyphicon glyphicon-plus"></span></button> 
 1478                $html .= 
'<p>Gap ' . (
$i + 1) . 
' - NUMERIC</p>';
 
 1481                foreach ($gap->getItems($this->object->getShuffler()) as $gap_item) {
 
 1482                    $aggregate = (array) $aggregation[
$i];
 
 1483                    foreach ($aggregate as $answer => $count) {
 
 1484                        $html .= 
'<li>' . $answer . 
' - ' . $count . 
'</li>';
 
 1500        $parts = explode(
'[gap', $question_text);
 
 1502        $question_text = 
'';
 
 1503        foreach ($parts as $part) {
 
 1505                $question_text .= $part;
 
 1507                $question_text .= 
'[gap ' . 
$i . $part;
 
 1511        return $question_text;
 
 1516        $parts = preg_split(
'/\[gap \d*\]/', $question_text);
 
 1517        $question_text = implode(
'[gap]', $parts);
 
 1518        return $question_text;
 
 1528            $gaptemplate->setCurrentBlock(
'gap_span');
 
 1529            $gaptemplate->setVariable(
'SPAN_SOLUTION', $solutiontext);
 
 1531            $gaptemplate->setCurrentBlock(
'gap_select');
 
 1532            $gaptemplate->setVariable(
'SELECT_SOLUTION', $solutiontext);
 
 1534            $gap_size = $gap->getGapSize() > 0 ? $gap->getGapSize() : $this->
object->getFixedTextLength();
 
 1536            if ($gap_size > 0) {
 
 1537                $gaptemplate->setCurrentBlock(
'gap_size');
 
 1538                $gaptemplate->setVariable(
"GAP_SIZE", $gap_size);
 
 1539                $gaptemplate->parseCurrentBlock();
 
 1542            $gaptemplate->setCurrentBlock(
'gap_input');
 
 1543            $gaptemplate->setVariable(
'INPUT_SOLUTION', $solutiontext);
 
 1547        $gaptemplate->parseCurrentBlock();
 
 1553            if (isset($answer[
'actions'])) {
 
 1565        $table = parent::getAnswerFrequencyTableGUI(
 
 1572        $table->setTitle(sprintf(
 
 1573            $DIC->language()->txt(
'tst_corrections_answers_tbl_subindex'),
 
 1574            $DIC->language()->txt(
'gap') . 
' ' . ($questionIndex + 1)
 
 1578            $table->addColumn(
'', 
'', 
'200');
 
 1586        return array_keys($this->object->getGaps());
 
 1591        $gap = $this->
object->getGap(
$gapIndex);
 
 1593        switch ($gap->type) {
 
 1601                return $items[$answer]->getAnswertext();
 
 1607        $gap = $this->
object->getGap($questionIndex);
 
 1613        foreach ($answers as 
$key => $ans) {
 
 1617                if ($ans[
'answer'] !== $item->getAnswerText()) {
 
 1626                $answers[
$key][
'addable'] = 
true;
 
 1637        foreach ($relevant_answers as 
$row) {
 
 1638            if (
$row[
'value1'] != $questionIndex) {
 
 1642            if (!isset($answers[
$row[
'value2']])) {
 
 1645                $answers[
$row[
'value2']] = array(
 
 1646                    'answer' => $label, 
'frequency' => 0
 
 1650            $answers[
$row[
'value2']][
'frequency']++;
 
 1660        foreach ($this->object->getGapCombinations() as $combination) {
 
 1661            if ($combination[
'gap_fi'] != 
$gapIndex) {
 
 1673        $combinations = array();
 
 1675        foreach ($this->object->getGapCombinations() as 
$c) {
 
 1676            if (!isset($combinations[
$c[
'cid']])) {
 
 1677                $combinations[
$c[
'cid']] = array();
 
 1680            if (!isset($combinations[
$c[
'cid']][
$c[
'row_id']])) {
 
 1681                $combinations[
$c[
'cid']][
$c[
'row_id']] = array(
 
 1682                    'gaps' => array(), 
'points' => 
$c[
'points'],
 
 1686            if (!isset($combinations[
$c[
'cid']][
$c[
'row_id']][
'gaps'][
$c[
'gap_fi']])) {
 
 1687                $combinations[
$c[
'cid']][
$c[
'row_id']][
'gaps'][
$c[
'gap_fi']] = array();
 
 1690            $combinations[
$c[
'cid']][
$c[
'row_id']][
'gaps'][
$c[
'gap_fi']] = 
$c[
'answer'];
 
 1693        return $combinations;
 
 1698        foreach ($this->object->getGaps() as 
$gapIndex => $gap) {
 
 1707        if ($this->object->getGapCombinationsExists()) {
 
 1717        $header->setTitle(
"Gap Combination " . ($combiIndex + 1));
 
 1720        require_once 
'Modules/TestQuestionPool/classes/forms/class.ilAssClozeTestCombinationVariantsInputGUI.php';
 
 1722        $inp->setValues($gapCombi);
 
 1723        $form->addItem($inp);
 
 1740            foreach ($gap->getItemsRaw() as $item) {
 
 1748        require_once 
"Modules/TestQuestionPool/classes/forms/class.ilAssAnswerCorrectionsInputGUI.php";
 
 1750        $values->setHidePointsEnabled($hidePoints);
 
 1752        $values->setQuestionObject($this->
object);
 
 1753        $values->setValues($gap->getItemsRaw());
 
 1760        $value->allowDecimals(
true);
 
 1761        $value->setSize(10);
 
 1763        $value->setRequired(
true);
 
 1764        $form->addItem($value);
 
 1767        $lowerbound->allowDecimals(
true);
 
 1768        $lowerbound->setSize(10);
 
 1769        $lowerbound->setRequired(
true);
 
 1771        $form->addItem($lowerbound);
 
 1774        $upperbound->allowDecimals(
true);
 
 1775        $upperbound->setSize(10);
 
 1776        $upperbound->setRequired(
true);
 
 1778        $form->addItem($upperbound);
 
 1782            $points->allowDecimals(
true);
 
 1783            $points->setSize(3);
 
 1784            $points->setRequired(
true);
 
 1786            $form->addItem($points);
 
 1795        foreach ($this->object->getGaps() as 
$gapIndex => $gap) {
 
 1803        if ($this->object->getGapCombinationsExists()) {
 
 1821        $answers = 
$form->getItemByPostVar(
'gap_' . 
$gapIndex)->getValues();
 
 1824            $item->setPoints((
float) $answers[
$index]->getPoints());
 
 1840        $combinationPoints = array(
'points' => array(), 
'select' => array());
 
 1841        $combinationValues = array();
 
 1844            $values = 
$form->getItemByPostVar(
'combination_' . $combiId)->getValues();
 
 1846            if (!isset($combinationPoints[
'points'][$combiId])) {
 
 1847                $combinationPoints[
'points'][$combiId] = array();
 
 1848                $combinationPoints[
'select'][$combiId] = array();
 
 1849                $combinationValues[$combiId] = array();
 
 1852            foreach ($combi as $varId => $variant) {
 
 1853                $combinationPoints[
'points'][$combiId][$varId] = (float) 
$values[$varId][
'points'];
 
 1854                $combinationPoints[
'select'][$combiId] = array_keys(
$values[$varId][
'gaps']);
 
 1855                $combinationValues[$combiId][$varId] = array_values(
$values[$varId][
'gaps']);
 
 1863        $assClozeGapCombinationObject->clearGapCombinationsFromDb($this->object->getId());
 
 1865        $assClozeGapCombinationObject->saveGapCombinationToDb(
 
 1866            $this->object->getId(),
 
setAnswertext($answertext="")
Sets the answer text.
setPoints($points=0.0)
Sets the points.
An exception for terminatinating execution or to throw for unit testing.
Class for cloze question numeric answers.
setUpperBound($bound)
Sets the upper bound.
setLowerBound($bound)
Sets the lower boind.
Class for cloze question gaps.
getType()
Gets the cloze gap type.
getItemsRaw()
Gets the items of a cloze gap.
Cloze test question GUI representation.
getAnswerFeedbackOutput($active_id, $pass)
Returns the answer generic feedback depending on the results of the question.
hasAddAnswerAction($relevantAnswers, $questionIndex)
applyIndizesToGapText($question_text)
populateGapCombinationCorrectionFormProperty(ilPropertyFormGUI $form, $gapCombi, $combiIndex)
populateTextOrSelectGapCorrectionFormProperty($form, $gap, $gapIndex, $hidePoints)
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
populateNumericGapCorrectionFormProperty($form, $item, $gapIndex, $hidePoints)
getAnswerTextLabel($gapIndex, $answer)
getAnswerFrequencyTableGUI($parentGui, $parentCmd, $relevantAnswers, $questionIndex)
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.
__construct($id=-1)
assClozeTestGUI constructor
populateSelectGapFormPart($form, $gap, $gapCounter)
Populates the form-part for a select gap.
populateNumericGapFormPart($form, $gap, $gapCounter)
Populates the form-part for a numeric gap.
createGaps()
Create gaps from cloze text.
getSpecificFeedbackOutput($userSolution)
Returns the answer specific feedback for the question.
getAfterParticipationSuppressionQuestionPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
$gapIndex
A temporary variable to store gap indexes of ilCtrl commands in the getCommand method.
removeIndizesFromGapText($question_text)
populateGapCorrectionFormProperties($form, $gap, $gapIndex, $hidePoints)
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from $_POST and applies them to the data object.
populateCorrectionsFormProperties(ilPropertyFormGUI $form)
populateQuestionSpecificFormPart(ilPropertyFormGUI $form)
Adds the question specific forms parts to a question property form gui.
populateGapSizeFormPart($form, $gap, $gapCounter)
setQuestionTabs()
Sets the ILIAS tabs for this question type.
getBestSolutionText($gap, $gap_index, $gap_combinations)
populateSolutiontextToGapTpl($gaptemplate, $gap, $solutiontext)
populateTextGapFormPart($form, $gap, $gapCounter)
Populates the form-part for a text gap.
getPreview($show_question_only=false, $showInlineFeedback=false)
Creates a preview output of the question.
isUsedInCombinations($gapIndex)
saveCorrectionsFormProperties(ilPropertyFormGUI $form)
populateGapFormPart($form, $gapCounter)
Populates a gap form-part.
addgap()
Add a gap answer.
getAfterParticipationSuppressionAnswerPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
saveGapCombinationCorrectionFormProperties(ilPropertyFormGUI $form)
supportsIntermediateSolutionOutput()
Question type specific support of intermediate solution output The function getSolutionOutput respect...
getAnswersFrequency($relevant_answers, $questionIndex)
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from $_POST and applies them to the data object.
getTestOutput( $active_id, $pass, $is_postponed=false, $use_post_solutions=false, $show_feedback=false)
saveNumericGapCorrectionFormProperty(ilPropertyFormGUI $form, assAnswerCloze $item, $gapIndex)
populateAnswerSpecificFormPart(ilPropertyFormGUI $form)
Adds the answer specific form parts to a question property form gui.
writePostData($always=false)
{Evaluates a posted edit form and writes the form data in the question object.integer A positive valu...
completeAddAnswerAction($answers, $questionIndex)
addBasicQuestionFormProperties($form)
Add basic question form properties: assessment: title, author, description, question,...
removegap()
Remove a gap answer.
saveGapCorrectionFormProperty(ilPropertyFormGUI $form, assClozeGap $gap, $gapIndex)
saveTextOrSelectGapCorrectionFormProperty(ilPropertyFormGUI $form, assClozeGap $gap, $gapIndex)
Basic GUI class for assessment questions.
populateTaxonomyFormSection(ilPropertyFormGUI $form)
addTab_QuestionHints(ilTabsGUI $tabs)
adds the hints tab to ilTabsGUI
isRenderPurposePrintPdf()
writeQuestionGenericPostData()
addQuestionFormCommandButtons($form)
Add the command buttons of a question properties form.
getILIASPage($html="")
Returns the ILIAS Page around a question.
getQuestionTemplate()
get question template
addTab_SuggestedSolution(ilTabsGUI $tabs, $classname)
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
output question page
renderPurposeSupportsFormHtml()
getUseIntermediateSolution()
Get if intermediate solution should be used for solution output.
saveTaxonomyAssignments()
addBackTab(ilTabsGUI $ilTabs)
isTestPresentationContext()
hasCorrectSolution($activeId, $passIndex)
addTab_QuestionFeedback(ilTabsGUI $tabs)
adds the feedback tab to ilTabsGUI
addTab_QuestionPreview(ilTabsGUI $tabsGUI)
getGenericFeedbackOutput($active_id, $pass)
Returns the answer specific feedback for the question.
const ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT
constant for additional content editing mode "default"
const CSS_CLASS_FEEDBACK_WRONG
const CSS_CLASS_FEEDBACK_CORRECT
static _getUsedHTMLTags($a_module="")
Returns an array of all allowed HTML tags for text editing.
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
This class represents a text area property in a property form.
This class represents a text property in a property form.
static stripSlashesRecursive($a_data, $a_strip_html=true, $a_allow="")
Strip slashes from array and sub-arrays.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
if(!array_key_exists('StateId', $_REQUEST)) $id
const CLOZE_TEXT
Cloze question constants.
Interface ilGuiAnswerScoringAdjustable.
Interface ilGuiQuestionScoringAdjustable.
getAggregatedAnswersView($relevant_answers)
Returns an html string containing a question specific representation of the answers so far given in t...
if(empty($password)) $table
if(isset($_POST['submit'])) $form