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()); } }
/** * 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; }