public function populateAnswerSpecificFormPart(\ilPropertyFormGUI $form)
 {
     // points
     $points = new ilNumberInputGUI($this->lng->txt("points"), "points");
     $points->allowDecimals(true);
     $points->setValue($this->object->getPoints() > 0 ? $this->object->getPoints() : '');
     $points->setRequired(TRUE);
     $points->setSize(3);
     $points->setMinValue(0.0);
     $points->setMinvalueShouldBeGreater(true);
     $form->addItem($points);
     $header = new ilFormSectionHeaderGUI();
     $header->setTitle($this->lng->txt("range"));
     $form->addItem($header);
     // lower bound
     $lower_limit = new ilFormulaInputGUI($this->lng->txt("range_lower_limit"), "lowerlimit");
     $lower_limit->setSize(25);
     $lower_limit->setMaxLength(20);
     $lower_limit->setRequired(true);
     $lower_limit->setValue($this->object->getLowerLimit());
     $form->addItem($lower_limit);
     // upper bound
     $upper_limit = new ilFormulaInputGUI($this->lng->txt("range_upper_limit"), "upperlimit");
     $upper_limit->setSize(25);
     $upper_limit->setMaxLength(20);
     $upper_limit->setRequired(true);
     $upper_limit->setValue($this->object->getUpperLimit());
     $form->addItem($upper_limit);
     // reset input length, if max chars are set
     if ($this->object->getMaxChars() > 0) {
         $lower_limit->setSize($this->object->getMaxChars());
         $lower_limit->setMaxLength($this->object->getMaxChars());
         $upper_limit->setSize($this->object->getMaxChars());
         $upper_limit->setMaxLength($this->object->getMaxChars());
     }
 }
 /**
  * Populates the form-part for a numeric gap.
  * 
  * This includes: The type selector, value, lower bound, upper bound and points.
  * 
  * @param $form			ilPropertyFormGUI	Reference to the form, that receives the point.
  * @param $gap			mixed				Raw numeric gap item.
  * @param $gapCounter	integer				Ordinal number of the gap in the sequence of gaps.
  * 
  * @return ilPropertyFormGUI
  */
 protected function populateNumericGapFormPart($form, $gap, $gapCounter)
 {
     // #8944: the js-based ouput in self-assessment cannot support formulas
     if (!$this->object->getSelfAssessmentEditingMode()) {
         $value = new ilFormulaInputGUI($this->lng->txt('value'), "gap_" . $gapCounter . "_numeric");
         $value->setInlineStyle('text-align: right;');
         $lowerbound = new ilFormulaInputGUI($this->lng->txt('range_lower_limit'), "gap_" . $gapCounter . "_numeric_lower");
         $lowerbound->setInlineStyle('text-align: right;');
         $upperbound = new ilFormulaInputGUI($this->lng->txt('range_upper_limit'), "gap_" . $gapCounter . "_numeric_upper");
         $upperbound->setInlineStyle('text-align: right;');
     } else {
         $value = new ilNumberInputGUI($this->lng->txt('value'), "gap_" . $gapCounter . "_numeric");
         $value->allowDecimals(true);
         $lowerbound = new ilNumberInputGUI($this->lng->txt('range_lower_limit'), "gap_" . $gapCounter . "_numeric_lower");
         $lowerbound->allowDecimals(true);
         $upperbound = new ilNumberInputGUI($this->lng->txt('range_upper_limit'), "gap_" . $gapCounter . "_numeric_upper");
         $upperbound->allowDecimals(true);
     }
     $value->setSize(10);
     $value->setValue(ilUtil::prepareFormOutput($gap->getAnswertext()));
     $value->setRequired(true);
     $form->addItem($value);
     $lowerbound->setSize(10);
     $lowerbound->setRequired(true);
     $lowerbound->setValue(ilUtil::prepareFormOutput($gap->getLowerBound()));
     $form->addItem($lowerbound);
     $upperbound->setSize(10);
     $upperbound->setRequired(true);
     $upperbound->setValue(ilUtil::prepareFormOutput($gap->getUpperBound()));
     $form->addItem($upperbound);
     $points = new ilNumberInputGUI($this->lng->txt('points'), "gap_" . $gapCounter . "_numeric_points");
     $points->setSize(3);
     $points->setRequired(true);
     $points->setValue(ilUtil::prepareFormOutput($gap->getPoints()));
     $form->addItem($points);
     return $form;
 }
 /**
  * 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;
 }
 /**
  * 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(TRUE);
     $form->setTableWidth("100%");
     $form->setId("assnumeric");
     $this->addBasicQuestionFormProperties($form);
     // maxchars
     $maxchars = new ilNumberInputGUI($this->lng->txt("maxchars"), "maxchars");
     $maxchars->setSize(10);
     $maxchars->setDecimals(0);
     $maxchars->setMinValue(1);
     $maxchars->setRequired(true);
     if ($this->object->getMaxChars() > 0) {
         $maxchars->setValue($this->object->getMaxChars());
     }
     $form->addItem($maxchars);
     // points
     $points = new ilNumberInputGUI($this->lng->txt("points"), "points");
     $points->setValue($this->object->getPoints() > 0 ? $this->object->getPoints() : '');
     $points->setRequired(TRUE);
     $points->setSize(3);
     $points->setMinValue(0.0);
     $points->setMinvalueShouldBeGreater(true);
     $form->addItem($points);
     $header = new ilFormSectionHeaderGUI();
     $header->setTitle($this->lng->txt("range"));
     $form->addItem($header);
     // lower bound
     $lower_limit = new ilFormulaInputGUI($this->lng->txt("range_lower_limit"), "lowerlimit");
     $lower_limit->setSize(25);
     $lower_limit->setMaxLength(20);
     $lower_limit->setRequired(true);
     $lower_limit->setValue($this->object->getLowerLimit());
     $form->addItem($lower_limit);
     // upper bound
     $upper_limit = new ilFormulaInputGUI($this->lng->txt("range_upper_limit"), "upperlimit");
     $upper_limit->setSize(25);
     $upper_limit->setMaxLength(20);
     $upper_limit->setRequired(true);
     $upper_limit->setValue($this->object->getUpperLimit());
     $form->addItem($upper_limit);
     $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;
 }