コード例 #1
0
 public function populateAnswerSpecificFormPart(\ilPropertyFormGUI $form)
 {
     // Choices
     include_once "./Modules/TestQuestionPool/classes/class.ilMultipleChoiceWizardInputGUI.php";
     $choices = new ilMultipleChoiceWizardInputGUI($this->lng->txt("answers"), "choice");
     $choices->setRequired(true);
     $choices->setQuestionObject($this->object);
     $isSingleline = $this->object->lastChange == 0 && !array_key_exists('types', $_POST) ? $this->object->getMultilineAnswerSetting() ? false : true : $this->object->isSingleline;
     $choices->setSingleline($isSingleline);
     $choices->setAllowMove(false);
     if ($this->object->getSelfAssessmentEditingMode()) {
         $choices->setSize(40);
         $choices->setMaxLength(800);
     }
     if ($this->object->getAnswerCount() == 0) {
         $this->object->addAnswer("", 0, 0, 0);
     }
     $choices->setValues($this->object->getAnswers());
     $form->addItem($choices);
 }
コード例 #2
0
 /**
  * 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());
     $isSingleline = $this->object->lastChange == 0 && !array_key_exists('types', $_POST) ? $this->object->getMultilineAnswerSetting() ? false : true : $this->object->isSingleline;
     if ($checkonly) {
         $isSingleline = $_POST['types'] == 0 ? true : false;
     }
     if ($isSingleline) {
         $form->setMultipart(TRUE);
     } else {
         $form->setMultipart(FALSE);
     }
     $form->setTableWidth("100%");
     $form->setId("assmultiplechoice");
     // title, author, description, question, working time (assessment mode)
     $this->addBasicQuestionFormProperties($form);
     // shuffle
     $shuffle = new ilCheckboxInputGUI($this->lng->txt("shuffle_answers"), "shuffle");
     $shuffle->setValue(1);
     $shuffle->setChecked($this->object->getShuffle());
     $shuffle->setRequired(FALSE);
     $form->addItem($shuffle);
     if ($this->object->getId()) {
         $hidden = new ilHiddenInputGUI("", "ID");
         $hidden->setValue($this->object->getId());
         $form->addItem($hidden);
     }
     if (!$this->getSelfAssessmentEditingMode()) {
         // Answer types
         $types = new ilSelectInputGUI($this->lng->txt("answer_types"), "types");
         $types->setRequired(false);
         $types->setValue($isSingleline ? 0 : 1);
         $types->setOptions(array(0 => $this->lng->txt('answers_singleline'), 1 => $this->lng->txt('answers_multiline')));
         $form->addItem($types);
     }
     if ($isSingleline) {
         // thumb size
         $thumb_size = new ilNumberInputGUI($this->lng->txt("thumb_size"), "thumb_size");
         $thumb_size->setMinValue(20);
         $thumb_size->setDecimals(0);
         $thumb_size->setSize(6);
         $thumb_size->setInfo($this->lng->txt('thumb_size_info'));
         $thumb_size->setValue($this->object->getThumbSize());
         $thumb_size->setRequired(false);
         $form->addItem($thumb_size);
     }
     // Choices
     include_once "./Modules/TestQuestionPool/classes/class.ilMultipleChoiceWizardInputGUI.php";
     $choices = new ilMultipleChoiceWizardInputGUI($this->lng->txt("answers"), "choice");
     $choices->setRequired(true);
     $choices->setQuestionObject($this->object);
     $choices->setSingleline($isSingleline);
     $choices->setAllowMove(false);
     if ($this->getSelfAssessmentEditingMode()) {
         $choices->setSize(40);
         $choices->setMaxLength(800);
     }
     if ($this->object->getAnswerCount() == 0) {
         $this->object->addAnswer("", 0, 0, 0);
     }
     $choices->setValues($this->object->getAnswers());
     $form->addItem($choices);
     $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;
 }