public function getValues()
 {
     $formValues = parent::getValues();
     $modelValues = array();
     foreach ($formValues as $formValue) {
         $expression = new ilAssQuestionSolutionComparisonExpression();
         $expression->setExpression($formValue->getAnswertext());
         $expression->setPoints($formValue->getPoints());
         $expression->setOrderIndex($formValue->getOrder() + 1);
         $modelValues[] = $expression;
     }
     return $modelValues;
 }
 /**
  * Creates an output of the edit form for the question
  *
  * @access public
  */
 public function editQuestion($checkonly = FALSE)
 {
     $save = $this->isSaveCommand();
     $this->getQuestionTemplate();
     #		if ($_REQUEST['prev_qid']) {
     #		    $this->ctrl->setParameter($this, 'prev_qid', $_REQUEST['prev_qid']);
     #		}
     include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
     $form = new ilPropertyFormGUI();
     $form->setFormAction($this->ctrl->getFormAction($this));
     $form->setTitle($this->outQuestionType());
     $form->setMultipart(FALSE);
     $form->setTableWidth("100%");
     $form->setId("assclozetest");
     // title, author, description, question, working time (assessment mode)
     $this->addBasicQuestionFormProperties($form);
     $q_item = $form->getItemByPostVar("question");
     $q_item->setInfo($this->lng->txt("close_text_hint"));
     $q_item->setTitle($this->lng->txt("cloze_text"));
     // text rating
     if (!$this->getSelfAssessmentEditingMode()) {
         $textrating = new ilSelectInputGUI($this->lng->txt("text_rating"), "textgap_rating");
         $text_options = array("ci" => $this->lng->txt("cloze_textgap_case_insensitive"), "cs" => $this->lng->txt("cloze_textgap_case_sensitive"), "l1" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "1"), "l2" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "2"), "l3" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "3"), "l4" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "4"), "l5" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "5"));
         $textrating->setOptions($text_options);
         $textrating->setValue($this->object->getTextgapRating());
         $form->addItem($textrating);
         // text field length
         $fixedTextLength = new ilNumberInputGUI($this->lng->txt("cloze_fixed_textlength"), "fixedTextLength");
         $fixedTextLength->setValue(ilUtil::prepareFormOutput($this->object->getFixedTextLength()));
         $fixedTextLength->setMinValue(0);
         $fixedTextLength->setSize(3);
         $fixedTextLength->setMaxLength(6);
         $fixedTextLength->setInfo($this->lng->txt('cloze_fixed_textlength_description'));
         $fixedTextLength->setRequired(false);
         $form->addItem($fixedTextLength);
         // identical scoring
         $identical_scoring = new ilCheckboxInputGUI($this->lng->txt("identical_scoring"), "identical_scoring");
         $identical_scoring->setValue(1);
         $identical_scoring->setChecked($this->object->getIdenticalScoring());
         $identical_scoring->setInfo($this->lng->txt('identical_scoring_desc'));
         $identical_scoring->setRequired(FALSE);
         $form->addItem($identical_scoring);
     }
     for ($i = 0; $i < $this->object->getGapCount(); $i++) {
         $gap = $this->object->getGap($i);
         $header = new ilFormSectionHeaderGUI();
         $header->setTitle($this->lng->txt("gap") . " " . ($i + 1));
         $form->addItem($header);
         $gapcounter = new ilHiddenInputGUI("gap[{$i}]");
         $gapcounter->setValue($i);
         $form->addItem($gapcounter);
         $gaptype = new ilSelectInputGUI($this->lng->txt('type'), "clozetype_{$i}");
         $options = array(0 => $this->lng->txt("text_gap"), 1 => $this->lng->txt("select_gap"), 2 => $this->lng->txt("numeric_gap"));
         $gaptype->setOptions($options);
         $gaptype->setValue($gap->getType());
         $form->addItem($gaptype);
         if ($gap->getType() == CLOZE_TEXT) {
             // Choices
             include_once "./Modules/TestQuestionPool/classes/class.ilAnswerWizardInputGUI.php";
             include_once "./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
             $values = new ilAnswerWizardInputGUI($this->lng->txt("values"), "gap_" . $i . "");
             $values->setRequired(true);
             $values->setQuestionObject($this->object);
             $values->setSingleline(true);
             $values->setAllowMove(false);
             if (count($gap->getItemsRaw()) == 0) {
                 $gap->addItem(new assAnswerCloze("", 0, 0));
             }
             $values->setValues($gap->getItemsRaw());
             $form->addItem($values);
         } else {
             if ($gap->getType() == CLOZE_SELECT) {
                 include_once "./Modules/TestQuestionPool/classes/class.ilAnswerWizardInputGUI.php";
                 include_once "./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
                 $values = new ilAnswerWizardInputGUI($this->lng->txt("values"), "gap_" . $i . "");
                 $values->setRequired(true);
                 $values->setQuestionObject($this->object);
                 $values->setSingleline(true);
                 $values->setAllowMove(false);
                 if (count($gap->getItemsRaw()) == 0) {
                     $gap->addItem(new assAnswerCloze("", 0, 0));
                 }
                 $values->setValues($gap->getItemsRaw());
                 $form->addItem($values);
                 // shuffle
                 $shuffle = new ilCheckboxInputGUI($this->lng->txt("shuffle_answers"), "shuffle_" . $i . "");
                 $shuffle->setValue(1);
                 $shuffle->setChecked($gap->getShuffle());
                 $shuffle->setRequired(FALSE);
                 $form->addItem($shuffle);
             } else {
                 if ($gap->getType() == CLOZE_NUMERIC) {
                     if (count($gap->getItemsRaw()) == 0) {
                         $gap->addItem(new assAnswerCloze("", 0, 0));
                     }
                     foreach ($gap->getItemsRaw() as $item) {
                         // #8944: the js-based ouput in self-assessment cannot support formulas
                         if (!$this->getSelfAssessmentEditingMode()) {
                             $value = new ilFormulaInputGUI($this->lng->txt('value'), "gap_" . $i . "_numeric");
                             $value->setInlineStyle('text-align: right;');
                             $lowerbound = new ilFormulaInputGUI($this->lng->txt('range_lower_limit'), "gap_" . $i . "_numeric_lower");
                             $lowerbound->setInlineStyle('text-align: right;');
                             $upperbound = new ilFormulaInputGUI($this->lng->txt('range_upper_limit'), "gap_" . $i . "_numeric_upper");
                             $upperbound->setInlineStyle('text-align: right;');
                         } else {
                             $value = new ilNumberInputGUI($this->lng->txt('value'), "gap_" . $i . "_numeric");
                             $value->allowDecimals(true);
                             $lowerbound = new ilNumberInputGUI($this->lng->txt('range_lower_limit'), "gap_" . $i . "_numeric_lower");
                             $lowerbound->allowDecimals(true);
                             $upperbound = new ilNumberInputGUI($this->lng->txt('range_upper_limit'), "gap_" . $i . "_numeric_upper");
                             $upperbound->allowDecimals(true);
                         }
                         $value->setSize(10);
                         $value->setValue(ilUtil::prepareFormOutput($item->getAnswertext()));
                         $value->setRequired(true);
                         $form->addItem($value);
                         $lowerbound->setSize(10);
                         $lowerbound->setRequired(true);
                         $lowerbound->setValue(ilUtil::prepareFormOutput($item->getLowerBound()));
                         $form->addItem($lowerbound);
                         $upperbound->setSize(10);
                         $upperbound->setRequired(true);
                         $upperbound->setValue(ilUtil::prepareFormOutput($item->getUpperBound()));
                         $form->addItem($upperbound);
                         $points = new ilNumberInputGUI($this->lng->txt('points'), "gap_" . $i . "_numeric_points");
                         $points->setSize(3);
                         $points->setRequired(true);
                         $points->setValue(ilUtil::prepareFormOutput($item->getPoints()));
                         $form->addItem($points);
                     }
                 }
             }
         }
     }
     $form->addCommandButton('createGaps', $this->lng->txt('create_gaps'));
     $this->addQuestionFormCommandButtons($form);
     $errors = false;
     if ($save) {
         $form->setValuesByPost();
         $errors = !$form->checkInput();
         $form->setValuesByPost();
         // again, because checkInput now performs the whole stripSlashes handling and we need this if we don't want to have duplication of backslashes
         if ($errors) {
             $checkonly = false;
         }
     }
     if (!$checkonly) {
         $this->tpl->setVariable("QUESTION_DATA", $form->getHTML());
     }
     return $errors;
 }
 /**
  * Populates the form-part for a text gap.
  * 
  * This includes: The AnswerWizardGUI for the individual text answers and points.
  * 
  * @param $form			ilPropertyFormGUI	Reference to the form, that receives the point.
  * @param $gap			mixed				Raw text gap item.
  * @param $gapCounter	integer				Ordinal number of the gap in the sequence of gaps
  *
  * @return ilPropertyFormGUI
  */
 protected function populateTextGapFormPart($form, $gap, $gapCounter)
 {
     // Choices
     include_once "./Modules/TestQuestionPool/classes/class.ilAnswerWizardInputGUI.php";
     include_once "./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
     $values = new ilAnswerWizardInputGUI($this->lng->txt("values"), "gap_" . $gapCounter . "");
     $values->setRequired(true);
     $values->setQuestionObject($this->object);
     $values->setSingleline(true);
     $values->setAllowMove(false);
     $values->setValues($gap->getItemsRaw());
     $form->addItem($values);
     return $form;
 }
 /**
  * Creates an output of the edit form for the question
  *
  * @access public
  */
 public function editQuestion($checkonly = FALSE)
 {
     $save = $this->isSaveCommand();
     $this->getQuestionTemplate();
     include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
     $form = new ilPropertyFormGUI();
     $form->setFormAction($this->ctrl->getFormAction($this));
     $form->setTitle($this->outQuestionType());
     $form->setMultipart(FALSE);
     $form->setTableWidth("100%");
     $form->setId("asstextsubset");
     $this->addBasicQuestionFormProperties($form);
     // number of requested answers
     $correctanswers = new ilNumberInputGUI($this->lng->txt("nr_of_correct_answers"), "correctanswers");
     $correctanswers->setMinValue(1);
     $correctanswers->setDecimals(0);
     $correctanswers->setSize(3);
     $correctanswers->setValue($this->object->getCorrectAnswers());
     $correctanswers->setRequired(true);
     $form->addItem($correctanswers);
     // maximum available points
     $points = new ilNumberInputGUI($this->lng->txt("maximum_points"), "points");
     $points->setMinValue(0.25);
     $points->setSize(6);
     $points->setDisabled(true);
     $points->setValue($this->object->getMaximumPoints());
     $points->setRequired(false);
     $form->addItem($points);
     // text rating
     $textrating = new ilSelectInputGUI($this->lng->txt("text_rating"), "text_rating");
     $text_options = array("ci" => $this->lng->txt("cloze_textgap_case_insensitive"), "cs" => $this->lng->txt("cloze_textgap_case_sensitive"));
     if (!$this->getSelfAssessmentEditingMode()) {
         $text_options["l1"] = sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "1");
         $text_options["l2"] = sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "2");
         $text_options["l3"] = sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "3");
         $text_options["l4"] = sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "4");
         $text_options["l5"] = sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "5");
     }
     $textrating->setOptions($text_options);
     $textrating->setValue($this->object->getTextRating());
     $form->addItem($textrating);
     // Choices
     include_once "./Modules/TestQuestionPool/classes/class.ilAnswerWizardInputGUI.php";
     $choices = new ilAnswerWizardInputGUI($this->lng->txt("answers"), "answers");
     $choices->setRequired(true);
     $choices->setQuestionObject($this->object);
     $choices->setSingleline(true);
     $choices->setAllowMove(false);
     if ($this->object->getAnswerCount() == 0) {
         $this->object->addAnswer("", 0, 0);
     }
     $choices->setValues($this->object->getAnswers());
     $form->addItem($choices);
     $this->addQuestionFormCommandButtons($form);
     $errors = false;
     if ($save) {
         $form->setValuesByPost();
         $points->setValue($this->object->getMaximumPoints());
         $errors = !$form->checkInput();
         $form->setValuesByPost();
         // again, because checkInput now performs the whole stripSlashes handling and we need this if we don't want to have duplication of backslashes
         if ($errors) {
             $checkonly = false;
         }
     }
     if (!$checkonly) {
         $this->tpl->setVariable("QUESTION_DATA", $form->getHTML());
     }
     return $errors;
 }
 public function populateAnswerSpecificFormPart(\ilPropertyFormGUI $form)
 {
     // Choices
     include_once "./Modules/TestQuestionPool/classes/class.ilAnswerWizardInputGUI.php";
     $choices = new ilAnswerWizardInputGUI($this->lng->txt("answers"), "answers");
     $choices->setRequired(true);
     $choices->setQuestionObject($this->object);
     $choices->setSingleline(true);
     $choices->setAllowMove(false);
     $choices->setMinValue(0.0);
     if ($this->object->getAnswerCount() == 0) {
         $this->object->addAnswer("", 0, 0);
     }
     $choices->setValues($this->object->getAnswers());
     $form->addItem($choices);
     return $form;
 }