/**
  * save Field
  *
  * @param string $a_mode values: create | update
  */
 public function save($a_mode = "create")
 {
     global $ilCtrl, $lng, $tpl;
     //check access
     if (!$this->table->hasPermissionToFields($this->parent_obj->ref_id)) {
         $this->accessDenied();
         return;
     }
     $this->initForm($a_mode == "update" ? "edit" : "create");
     if ($this->checkInput($a_mode)) {
         $title = $this->form->getInput("title");
         if ($a_mode != "create" && $title != $this->field_obj->getTitle()) {
             ilUtil::sendInfo($lng->txt("dcl_field_title_change_warning"), true);
         }
         $this->field_obj->setTitle($title);
         $this->field_obj->setDescription($this->form->getInput("description"));
         $this->field_obj->setDatatypeId($this->form->getInput("datatype"));
         $this->field_obj->setRequired($this->form->getInput("required"));
         $this->field_obj->setUnique($this->form->getInput("unique"));
         if ($a_mode == "update") {
             $this->field_obj->doUpdate();
         } else {
             $this->field_obj->setVisible(true);
             $this->field_obj->setOrder($this->table->getNewOrder());
             $this->field_obj->doCreate();
         }
         // Get possible properties and save them
         include_once "./Modules/DataCollection/classes/class.ilDataCollectionFieldProp.php";
         foreach (ilDataCollectionDatatype::getProperties($this->field_obj->getDatatypeId()) as $property) {
             $fieldprop_obj = new ilDataCollectionFieldProp();
             $fieldprop_obj->setDatatypePropertyId($property['id']);
             $fieldprop_obj->setFieldId($this->field_obj->getId());
             $fieldprop_obj->setValue($this->form->getInput("prop_" . $property['id']));
             if ($a_mode == "update") {
                 $fieldprop_obj->doUpdate();
             } else {
                 $fieldprop_obj->doCreate();
             }
         }
         $ilCtrl->setParameter($this, "field_id", $this->field_obj->getId());
         if ($a_mode == "update") {
             ilUtil::sendSuccess($lng->txt("dcl_msg_field_modified"), true);
         } else {
             $this->table->addField($this->field_obj);
             $this->table->buildOrderFields();
             ilUtil::sendSuccess($lng->txt("msg_field_created"), false);
         }
         $ilCtrl->redirectByClass(strtolower("ilDataCollectionFieldListGUI"), "listFields");
     } else {
         $this->form->setValuesByPost();
         $tpl->setContent($this->form->getHTML());
     }
 }
 /**
  * @param $message
  */
 protected function sendFailure($message)
 {
     $keep = $this->ctrl->isAsynch() ? false : true;
     $this->form->setValuesByPost();
     if ($this->ctrl->isAsynch()) {
         echo $this->tpl->getMessageHTML($message, 'failure') . $this->form->getHTML();
         exit;
     } else {
         ilUtil::sendFailure($message, $keep);
         $this->tpl->setContent($this->form->getHTML());
     }
 }
Ejemplo n.º 3
0
 public function updateProperties()
 {
     $this->initPropertiesForm();
     if ($this->form->checkInput()) {
         $this->object->setTitle($this->form->getInput('title'));
         $this->object->setDescription($this->form->getInput('desc'));
         $this->object->update();
         ilUtil::sendSuccess($this->lng->txt('msg_obj_modified'), true);
         $this->ctrl->redirect($this, 'editProperties');
     }
     $this->form->setValuesByPost();
     $this->tpl->setContent($this->form->getHtml());
 }
 /**
  * shows the form for managing a new/existing hint
  * 
  * @access	private
  * @global	ilCtrl		$ilCtrl
  * @global	ilTemplate	$tpl 
  */
 private function showFormCmd(ilPropertyFormGUI $form = null)
 {
     global $ilCtrl, $tpl, $ilToolbar, $lng, $ilCtrl;
     if ($form instanceof ilPropertyFormGUI) {
         $form->setValuesByPost();
     } elseif (isset($_GET['hint_id']) && (int) $_GET['hint_id']) {
         $questionHint = new ilAssQuestionHint();
         if (!$questionHint->load((int) $_GET['hint_id'])) {
             ilUtil::sendFailure('invalid hint id given: ' . (int) $_GET['hint_id'], true);
             $ilCtrl->redirectByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_SHOW_LIST);
         }
         $form = $this->buildForm($questionHint);
     } else {
         $form = $this->buildForm();
     }
     $tpl->setContent($form->getHTML());
 }
 /**
  * @param bool $init_from_database
  */
 protected function settings($init_from_database = true)
 {
     /**
      * @var $rbacsystem  ilRbacSystem
      * @var $ilErr       ilErrorHandling
      * @var $tpl         ilTemplate
      */
     global $rbacsystem, $ilErr, $tpl;
     if (!$rbacsystem->checkAccess('read', $this->object->getRefId())) {
         $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->MESSAGE);
     }
     $this->initSettingsForm();
     if ($init_from_database) {
         $this->form->setValuesByArray(array('tos_status' => $this->object->getStatus()));
     } else {
         $this->form->setValuesByPost();
     }
     $tpl->setContent($this->form->getHtml());
 }
Ejemplo n.º 6
0
 public function updateNotificationSettingsObject()
 {
     /**
      * @var $ilAccess ilAccessHandler
      * @var $ilErr		ilErr
      */
     global $ilAccess, $ilErr;
     if (!$ilAccess->checkAccess('write', '', $this->ref_id)) {
         $ilErr->raiseError($this->lng->txt('msg_no_perm_read'), $ilErr->MESSAGE);
     }
     // instantiate the property form
     $this->initNotificationSettingsForm();
     // check input
     if ($this->notificationSettingsForm->checkInput()) {
         if (isset($_POST['notification_type']) && $_POST['notification_type'] == 'all_users') {
             // set values and call update
             $this->objProperties->setAdminForceNoti(1);
             $this->objProperties->setUserToggleNoti((int) $this->notificationSettingsForm->getInput('usr_toggle'));
             $this->objProperties->setNotificationType('all_users');
             $this->updateUserNotifications(true);
         } else {
             if ($_POST['notification_type'] == 'per_user') {
                 $this->objProperties->setNotificationType('per_user');
                 $this->objProperties->setAdminForceNoti(1);
                 $this->objProperties->setUserToggleNoti(0);
                 $this->updateUserNotifications();
             } else {
                 $this->objProperties->setNotificationType('default');
                 $this->objProperties->setAdminForceNoti(0);
                 $this->objProperties->setUserToggleNoti(0);
                 include_once 'Modules/Forum/classes/class.ilForumNotification.php';
                 $frm_noti = new ilForumNotification($this->object->getRefId());
                 $frm_noti->deleteNotificationAllUsers();
             }
         }
         $this->objProperties->update();
         // print success message
         ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
     }
     $this->notificationSettingsForm->setValuesByPost();
     return $this->showMembersObject();
 }
 /**
  *
  */
 protected function saveCategory()
 {
     if (!$this->isCRUDContext()) {
         $this->{$this->getDefaultCommand()}();
         return;
     }
     $category = $this->getCategoryById((int) $_GET['category_id']);
     $this->initUnitCategoryForm($category);
     if ($this->unit_cat_form->checkInput()) {
         try {
             $category->setCategory($this->unit_cat_form->getInput('category_name'));
             $this->repository->saveCategory($category);
             ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
             $this->{$this->getUnitCategoryOverviewCommand()}();
             return;
         } catch (ilException $e) {
             $this->unit_cat_form->getItemByPostVar('category_name')->setAlert($this->lng->txt($e->getMessage()));
             ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
         }
     }
     $this->unit_cat_form->setValuesByPost();
     $this->tpl->setContent($this->unit_cat_form->getHtml());
 }
 /**
  * Save form input
  */
 public function save()
 {
     /** @var ilCtrl $ilCtrl */
     global $tpl, $ilCtrl;
     $this->initConfigurationForm();
     if ($this->form->checkInput()) {
         // Save Checkbox Values
         foreach ($this->checkboxes as $key => $cb) {
             if (!is_array($cb)) {
                 $this->setValue($cb, $this->form->getInput($cb));
             } else {
                 $this->setValue($key, $this->form->getInput($key));
                 foreach ($cb as $field => $gui) {
                     $this->setValue($key . '_' . $field, $this->form->getInput($key . '_' . $field));
                 }
             }
         }
         $ilCtrl->redirect($this, 'configure');
     } else {
         $this->form->setValuesByPost();
         $tpl->setContent($this->form->getHtml());
     }
 }
 /**
  *	Command for saving the updated Test Overview settings.
  *
  *	This command saves the HTML form input into the Test Overview
  *	currently selected.
  */
 protected function updateSettings()
 {
     /**
      * @var $tpl    ilTemplate
      * @var $lng    ilLanguage
      * @var $ilCtrl ilCtrl
      */
     global $tpl, $lng, $ilCtrl;
     $this->initSettingsForm();
     if ($this->form->checkInput()) {
         /* Form is sent and input validated,
            now save settings. */
         $this->object->setTitle($this->form->getInput('title'));
         $this->object->setDescription($this->form->getInput('desc'));
         $this->object->update();
         ilUtil::sendSuccess($lng->txt('msg_obj_modified'), true);
         /* Back to editSettings */
         $ilCtrl->redirect($this, 'editSettings');
     }
     /* Form is sent but there is an input error.
        Fill back the form and render again. */
     $this->form->setValuesByPost();
     $tpl->setContent($this->renderSettings());
 }
 function importExternalMailRecipientsObject($checkonly = false, $formindex = -1)
 {
     global $ilAccess;
     $this->handleWriteAccess();
     $this->setCodesSubtabs();
     $savefields = strcmp($this->ctrl->getCmd(), "importExternalRecipientsFromFile") == 0 || strcmp($this->ctrl->getCmd(), "importExternalRecipientsFromText") == 0 || strcmp($this->ctrl->getCmd(), "importExternalRecipientsFromDataset") == 0 ? TRUE : FALSE;
     include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
     $form_import_file = new ilPropertyFormGUI();
     $form_import_file->setFormAction($this->ctrl->getFormAction($this));
     $form_import_file->setTableWidth("100%");
     $form_import_file->setId("codes_import_file");
     $headerfile = new ilFormSectionHeaderGUI();
     $headerfile->setTitle($this->lng->txt("import_from_file"));
     $form_import_file->addItem($headerfile);
     $externalmails = new ilFileInputGUI($this->lng->txt("externalmails"), "externalmails");
     $externalmails->setInfo($this->lng->txt('externalmails_info'));
     $externalmails->setRequired(true);
     $form_import_file->addItem($externalmails);
     if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) {
         $form_import_file->addCommandButton("importExternalRecipientsFromFile", $this->lng->txt("import"));
     }
     if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) {
         $form_import_file->addCommandButton("codesMail", $this->lng->txt("cancel"));
     }
     // import text
     $form_import_text = new ilPropertyFormGUI();
     $form_import_text->setFormAction($this->ctrl->getFormAction($this));
     $form_import_text->setTableWidth("100%");
     $form_import_text->setId("codes_import_text");
     $headertext = new ilFormSectionHeaderGUI();
     $headertext->setTitle($this->lng->txt("import_from_text"));
     $form_import_text->addItem($headertext);
     $inp = new ilTextAreaInputGUI($this->lng->txt('externaltext'), 'externaltext');
     if (array_key_exists('externaltext', $_SESSION) && strlen($_SESSION['externaltext'])) {
         $inp->setValue($_SESSION['externaltext']);
     } else {
         $inp->setValue($this->lng->txt('mail_import_example1') . "\n" . $this->lng->txt('mail_import_example2') . "\n" . $this->lng->txt('mail_import_example3') . "\n");
     }
     $inp->setRequired(true);
     $inp->setCols(80);
     $inp->setRows(10);
     $inp->setInfo($this->lng->txt('externaltext_info'));
     $form_import_text->addItem($inp);
     unset($_SESSION['externaltext']);
     if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) {
         $form_import_text->addCommandButton("importExternalRecipientsFromText", $this->lng->txt("import"));
     }
     if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) {
         $form_import_text->addCommandButton("codesMail", $this->lng->txt("cancel"));
     }
     // import dataset
     $form_import_dataset = new ilPropertyFormGUI();
     $form_import_dataset->setFormAction($this->ctrl->getFormAction($this));
     $form_import_dataset->setTableWidth("100%");
     $form_import_dataset->setId("codes_import_dataset");
     $headerfile = new ilFormSectionHeaderGUI();
     $headerfile->setTitle($this->lng->txt("import_from_dataset"));
     $form_import_dataset->addItem($headerfile);
     $existingdata = $this->object->getExternalCodeRecipients();
     $existingcolumns = array('email');
     if (count($existingdata)) {
         $first = array_shift($existingdata);
         foreach ($first as $key => $value) {
             if (strcmp($key, 'email') != 0 && strcmp($key, 'code') != 0 && strcmp($key, 'sent') != 0) {
                 array_push($existingcolumns, $key);
             }
         }
     }
     foreach ($existingcolumns as $column) {
         $inp = new ilTextInputGUI($column, $column);
         $inp->setSize(50);
         if (strcmp($column, 'email') == 0) {
             $inp->setRequired(true);
         } else {
             $inp->setRequired(false);
         }
         $form_import_dataset->addItem($inp);
     }
     if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) {
         $form_import_dataset->addCommandButton("importExternalRecipientsFromDataset", $this->lng->txt("import"));
     }
     if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) {
         $form_import_dataset->addCommandButton("codesMail", $this->lng->txt("cancel"));
     }
     $errors = false;
     if ($savefields) {
         switch ($formindex) {
             case 0:
                 $errors = !$form_import_file->checkInput();
                 $form_import_file->setValuesByPost();
                 if ($errors) {
                     $checkonly = false;
                 }
                 break;
             case 1:
                 $errors = !$form_import_text->checkInput();
                 $form_import_text->setValuesByPost();
                 if ($errors) {
                     $checkonly = false;
                 }
                 break;
             case 2:
                 $errors = !$form_import_dataset->checkInput();
                 $form_import_dataset->setValuesByPost();
                 if ($errors) {
                     $checkonly = false;
                 }
                 break;
         }
     }
     if (!$checkonly) {
         $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_external_mail.html", "Modules/Survey");
         $this->tpl->setVariable("HEADLINE", $this->lng->txt("external_mails_import"));
         $this->tpl->setVariable("FORM1", $form_import_file->getHTML());
         $this->tpl->setVariable("FORM2", $form_import_text->getHTML());
         $this->tpl->setVariable("FORM3", $form_import_dataset->getHTML());
     }
     return $errors;
 }
 /**
  * Creates the output of the feedback page for a single choice question
  *
  * @access public
  */
 function feedback($checkonly = false)
 {
     $save = strcmp($this->ctrl->getCmd(), "saveFeedback") == 0 ? TRUE : FALSE;
     include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
     $form = new ilPropertyFormGUI();
     $form->setFormAction($this->ctrl->getFormAction($this));
     $form->setTitle($this->lng->txt('feedback_answers'));
     $form->setTableWidth("98%");
     $form->setId("feedback");
     $complete = new ilTextAreaInputGUI($this->lng->txt("feedback_complete_solution"), "feedback_complete");
     $complete->setValue($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(1)));
     $complete->setRequired(false);
     $complete->setRows(10);
     $complete->setCols(80);
     if (!$this->getPreventRteUsage()) {
         $complete->setUseRte(true);
     }
     include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
     $complete->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("assessment"));
     $complete->addPlugin("latex");
     $complete->addButton("latex");
     $complete->addButton("pastelatex");
     $complete->setRTESupport($this->object->getId(), "qpl", "assessment", null, false, '3.4.7');
     $form->addItem($complete);
     $incomplete = new ilTextAreaInputGUI($this->lng->txt("feedback_incomplete_solution"), "feedback_incomplete");
     $incomplete->setValue($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(0)));
     $incomplete->setRequired(false);
     $incomplete->setRows(10);
     $incomplete->setCols(80);
     if (!$this->getPreventRteUsage()) {
         $incomplete->setUseRte(true);
     }
     include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
     $incomplete->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("assessment"));
     $incomplete->addPlugin("latex");
     $incomplete->addButton("latex");
     $incomplete->addButton("pastelatex");
     $incomplete->setRTESupport($this->object->getId(), "qpl", "assessment", null, false, '3.4.7');
     $form->addItem($incomplete);
     if (!$this->getSelfAssessmentEditingMode()) {
         foreach ($this->object->getErrorData() as $index => $answer) {
             $caption = $ordinal = $index + 1;
             $caption .= '. <br />"' . $answer->text_wrong . '" =&gt; ';
             $caption .= '"' . $answer->text_correct . '"';
             $caption .= '</i>';
             $answerobj = new ilTextAreaInputGUI($this->object->prepareTextareaOutput($caption, true), "feedback_answer_{$index}");
             $answerobj->setValue($this->object->prepareTextareaOutput($this->object->getFeedbackSingleAnswer($index)));
             $answerobj->setRequired(false);
             $answerobj->setRows(10);
             $answerobj->setCols(80);
             $answerobj->setUseRte(true);
             include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
             $answerobj->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("assessment"));
             $answerobj->addPlugin("latex");
             $answerobj->addButton("latex");
             $answerobj->addButton("pastelatex");
             $answerobj->setRTESupport($this->object->getId(), "qpl", "assessment", null, false, '3.4.7');
             $form->addItem($answerobj);
         }
     }
     global $ilAccess;
     if ($ilAccess->checkAccess("write", "", $_GET['ref_id']) || $this->getSelfAssessmentEditingMode()) {
         $form->addCommandButton("saveFeedback", $this->lng->txt("save"));
     }
     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 (!$checkonly) {
         $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
     }
     return $errors;
 }
Ejemplo n.º 12
0
 /**
  * Display and fill the scoring settings form of the test
  *
  * @access	public
  */
 function scoringObject($checkonly = FALSE)
 {
     global $ilAccess;
     if (!$ilAccess->checkAccess("write", "", $this->ref_id)) {
         // allow only write access
         ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
         $this->ctrl->redirect($this, "infoScreen");
     }
     // using template?
     $template_settings = null;
     $template = $this->object->getTemplate();
     if ($template) {
         include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
         include_once "Modules/Test/classes/class.ilObjAssessmentFolderGUI.php";
         $template = new ilSettingsTemplate($template, ilObjAssessmentFolderGUI::getSettingsTemplateConfig());
         $template_settings = $template->getSettings();
     }
     $save = strcmp($this->ctrl->getCmd(), "saveScoring") == 0 ? TRUE : FALSE;
     $total = $this->object->evalTotalPersons();
     $this->tpl->addJavascript("./Services/JavaScript/js/Basic.js");
     // Determine settings availability
     $setting_available = true;
     // In general, the scoring settings are available.
     if ($total != 0) {
         $setting_available = false;
         // Unless there are results from users.
     }
     if ($this->object->getScoreReporting() == 4) {
         $setting_available = true;
         // But if the results are not public since they will never be
     }
     if ($this->object->getScoreReporting() == 3 && $this->object->getReportingDate() > time()) {
         $setting_available = true;
         // or the presentation date is not reached, then we can still edit them.
     }
     include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
     $form = new ilPropertyFormGUI();
     $form->setFormAction($this->ctrl->getFormAction($this));
     $form->setTableWidth("100%");
     $form->setId("test_properties_scoring");
     // scoring properties
     $header = new ilFormSectionHeaderGUI();
     $header->setTitle($this->lng->txt("test_scoring"));
     $form->addItem($header);
     // scoring system
     $count_system = new ilRadioGroupInputGUI($this->lng->txt("tst_text_count_system"), "count_system");
     $count_system->addOption(new ilRadioOption($this->lng->txt("tst_count_partial_solutions"), 0, ''));
     $count_system->addOption(new ilRadioOption($this->lng->txt("tst_count_correct_solutions"), 1, ''));
     $count_system->setValue($this->object->getCountSystem());
     $count_system->setInfo($this->lng->txt("tst_count_system_description"));
     $count_system->setDisabled(!$setting_available);
     $form->addItem($count_system);
     // mc questions
     $mc_scoring = new ilRadioGroupInputGUI($this->lng->txt("tst_score_mcmr_questions"), "mc_scoring");
     $mc_scoring->addOption(new ilRadioOption($this->lng->txt("tst_score_mcmr_zero_points_when_unanswered"), 0, ''));
     $mc_scoring->addOption(new ilRadioOption($this->lng->txt("tst_score_mcmr_use_scoring_system"), 1, ''));
     $mc_scoring->setValue($this->object->getMCScoring());
     $mc_scoring->setInfo($this->lng->txt("tst_score_mcmr_questions_description"));
     $mc_scoring->setDisabled(!$setting_available);
     $form->addItem($mc_scoring);
     // score cutting
     $score_cutting = new ilRadioGroupInputGUI($this->lng->txt("tst_score_cutting"), "score_cutting");
     $score_cutting->addOption(new ilRadioOption($this->lng->txt("tst_score_cut_question"), 0, ''));
     $score_cutting->addOption(new ilRadioOption($this->lng->txt("tst_score_cut_test"), 1, ''));
     $score_cutting->setValue($this->object->getScoreCutting());
     $score_cutting->setInfo($this->lng->txt("tst_score_cutting_description"));
     $score_cutting->setDisabled(!$setting_available);
     $form->addItem($score_cutting);
     // pass scoring
     $pass_scoring = new ilRadioGroupInputGUI($this->lng->txt("tst_pass_scoring"), "pass_scoring");
     $pass_scoring->addOption(new ilRadioOption($this->lng->txt("tst_pass_last_pass"), 0, ''));
     $pass_scoring->addOption(new ilRadioOption($this->lng->txt("tst_pass_best_pass"), 1, ''));
     $pass_scoring->setValue($this->object->getPassScoring());
     $pass_scoring->setInfo($this->lng->txt("tst_pass_scoring_description"));
     $pass_scoring->setDisabled(!$setting_available);
     $form->addItem($pass_scoring);
     // test presentation
     $header_tp = new ilFormSectionHeaderGUI();
     $header_tp->setTitle($this->lng->txt("test_presentation"));
     $form->addItem($header_tp);
     // enable obligations
     $checkBoxEnableObligations = new ilCheckboxInputGUI($this->lng->txt("tst_setting_enable_obligations_label"), "obligations_enabled");
     $checkBoxEnableObligations->setChecked($this->object->areObligationsEnabled());
     $checkBoxEnableObligations->setInfo($this->lng->txt("tst_setting_enable_obligations_info"));
     if ($total) {
         $checkBoxEnableObligations->setDisabled(true);
     }
     $form->addItem($checkBoxEnableObligations);
     // offer hints
     $checkBoxOfferHints = new ilCheckboxInputGUI($this->lng->txt("tst_setting_offer_hints_label"), "offer_hints");
     $checkBoxOfferHints->setChecked($this->object->isOfferingQuestionHintsEnabled());
     $checkBoxOfferHints->setInfo($this->lng->txt("tst_setting_offer_hints_info"));
     if ($total) {
         $checkBoxOfferHints->setDisabled(true);
     }
     $form->addItem($checkBoxOfferHints);
     // instant feedback
     $instant_feedback = new ilCheckboxGroupInputGUI($this->lng->txt("tst_instant_feedback"), "instant_feedback");
     $instant_feedback->addOption(new ilCheckboxOption($this->lng->txt("tst_instant_feedback_answer_specific"), 'instant_feedback_specific', ''));
     $instant_feedback->addOption(new ilCheckboxOption($this->lng->txt("tst_instant_feedback_answer_generic"), 'instant_feedback_generic', ''));
     $instant_feedback->addOption(new ilCheckboxOption($this->lng->txt("tst_instant_feedback_results"), 'instant_feedback_points', ''));
     $instant_feedback->addOption(new ilCheckboxOption($this->lng->txt("tst_instant_feedback_solution"), 'instant_feedback_solution', ''));
     $values = array();
     if ($this->object->getSpecificAnswerFeedback()) {
         array_push($values, 'instant_feedback_specific');
     }
     if ($this->object->getGenericAnswerFeedback()) {
         array_push($values, 'instant_feedback_generic');
     }
     if ($this->object->getAnswerFeedbackPoints()) {
         array_push($values, 'instant_feedback_points');
     }
     if ($this->object->getInstantFeedbackSolution()) {
         array_push($values, 'instant_feedback_solution');
     }
     $instant_feedback->setValue($values);
     $instant_feedback->setInfo($this->lng->txt("tst_instant_feedback_description"));
     $form->addItem($instant_feedback);
     // scoring properties
     $header_tr = new ilFormSectionHeaderGUI();
     $header_tr->setTitle($this->lng->txt("test_results"));
     $form->addItem($header_tr);
     // access to test results
     $results_access = new ilRadioGroupInputGUI($this->lng->txt("tst_results_access"), "results_access");
     $results_access->addOption(new ilRadioOption($this->lng->txt("tst_results_access_always"), 2, ''));
     $results_access->addOption(new ilRadioOption($this->lng->txt("tst_results_access_finished"), 1, ''));
     $results_access_date_limitation = new ilRadioOption($this->lng->txt("tst_results_access_date"), 3, '');
     $results_access->addOption($results_access_date_limitation);
     $results_access->addOption(new ilRadioOption($this->lng->txt("tst_results_access_never"), 4, ''));
     $results_access->setValue($this->object->getScoreReporting());
     $results_access->setInfo($this->lng->txt("tst_results_access_description"));
     // access date
     $reporting_date = new ilDateTimeInputGUI('', 'reporting_date');
     $reporting_date->setShowDate(true);
     $reporting_date->setShowTime(true);
     if (strlen($this->object->getReportingDate())) {
         $reporting_date->setDate(new ilDateTime($this->object->getReportingDate(), IL_CAL_TIMESTAMP));
     } else {
         $reporting_date->setDate(new ilDateTime(time(), IL_CAL_UNIX));
     }
     $results_access_date_limitation->addSubItem($reporting_date);
     $form->addItem($results_access);
     $results_print_best_solution = new ilCheckboxInputGUI($this->lng->txt("tst_results_print_best_solution"), "print_bs_with_res");
     $results_print_best_solution->setInfo($this->lng->txt('tst_results_print_best_solution_info'));
     $results_print_best_solution->setValue(1);
     $results_print_best_solution->setChecked((bool) $this->object->isBestSolutionPrintedWithResult());
     $form->addItem($results_print_best_solution);
     // results presentation
     $results_presentation = new ilCheckboxGroupInputGUI($this->lng->txt("tst_results_presentation"), "results_presentation");
     $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_pass_details"), 'pass_details', ''));
     $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_solution_details"), 'solution_details', ''));
     $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_solution_printview"), 'solution_printview', ''));
     $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_solution_compare"), 'solution_compare', ''));
     $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_solution_feedback"), 'solution_feedback', ''));
     $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_solution_answers_only"), 'solution_answers_only', ''));
     $signatureOption = new ilCheckboxOption($this->lng->txt("tst_show_solution_signature"), 'solution_signature', '');
     $results_presentation->addOption($signatureOption);
     $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_solution_suggested"), 'solution_suggested', ''));
     $values = array();
     if ($this->object->getShowPassDetails()) {
         array_push($values, 'pass_details');
     }
     if ($this->object->getShowSolutionDetails()) {
         array_push($values, 'solution_details');
     }
     if ($this->object->getShowSolutionPrintview()) {
         array_push($values, 'solution_printview');
     }
     if ($this->object->getShowSolutionFeedback()) {
         array_push($values, 'solution_feedback');
     }
     if ($this->object->getShowSolutionAnswersOnly()) {
         array_push($values, 'solution_answers_only');
     }
     if ($this->object->getShowSolutionSignature()) {
         array_push($values, 'solution_signature');
     }
     if ($this->object->getShowSolutionSuggested()) {
         array_push($values, 'solution_suggested');
     }
     if ($this->object->getShowSolutionListComparison()) {
         array_push($values, 'solution_compare');
     }
     $results_presentation->setValue($values);
     $results_presentation->setInfo($this->lng->txt("tst_results_presentation_description"));
     if ($this->object->getAnonymity()) {
         $signatureOption->setDisabled(true);
     }
     $form->addItem($results_presentation);
     // misc properties
     $header_misc = new ilFormSectionHeaderGUI();
     $header_misc->setTitle($this->lng->txt("misc"));
     $form->addItem($header_misc);
     // deletion of test results
     $passDeletion = new ilRadioGroupInputGUI($this->lng->txt("tst_pass_deletion"), "pass_deletion_allowed");
     $passDeletion->addOption(new ilRadioOption($this->lng->txt("tst_pass_deletion_not_allowed"), 0, ''));
     $passDeletion->addOption(new ilRadioOption($this->lng->txt("tst_pass_deletion_allowed"), 1, ''));
     $passDeletion->setValue($this->object->isPassDeletionAllowed());
     $form->addItem($passDeletion);
     // export settings
     $export_settings = new ilCheckboxGroupInputGUI($this->lng->txt("tst_export_settings"), "export_settings");
     $export_settings->addOption(new ilCheckboxOption($this->lng->txt("tst_exp_sc_short"), 'exp_sc_short', ''));
     $values = array();
     if ($this->object->getExportSettingsSingleChoiceShort()) {
         array_push($values, 'exp_sc_short');
     }
     $export_settings->setValue($values);
     $form->addItem($export_settings);
     if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]) && $total == 0) {
         $form->addCommandButton("saveScoring", $this->lng->txt("save"));
     }
     if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]) && $total != 0) {
         $form->addCommandButton("confirmScoring", $this->lng->txt("save"));
     }
     // remove items when using template
     if ($template_settings) {
         foreach ($template_settings as $id => $item) {
             if ($item["hide"]) {
                 $form->removeItemByPostVar($id);
             }
         }
     }
     $errors = false;
     if ($save) {
         $errors = !$form->checkInput();
         $form->setValuesByPost();
         if ($errors) {
             $checkonly = false;
         }
     }
     if (!$checkonly) {
         $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
     }
     return $errors;
 }
 /**
  * In case the form input for the name of the class was empty an error message and the class
  * form with its non erroneous entries will be displayed.
  *
  * @param ilPropertyFormGUI $a_class_form the class for which the invalid input should be handled
  */
 private function handleInvalidAddClassForm($a_class_form)
 {
     $this->tabs->clearTargets();
     $a_class_form->setValuesByPost();
     $this->tpl->setContent($a_class_form->getHTML());
 }
 function randomQuestionsObject()
 {
     global $ilUser;
     $total = $this->object->evalTotalPersons();
     $save = strcmp($this->ctrl->getCmd(), "saveRandomQuestions") == 0 ? TRUE : FALSE;
     include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
     $form = new ilPropertyFormGUI();
     $form->setFormAction($this->ctrl->getFormAction($this, 'randomQuestions'));
     $form->setTitle($this->lng->txt('random_selection'));
     $form->setDescription($this->lng->txt('tst_select_random_questions'));
     $form->setMultipart(FALSE);
     $form->setTableWidth("100%");
     $form->setId("randomSelectionForm");
     // question selection
     $selection_mode = $save ? $_POST['chbQuestionSelectionMode'] : $ilUser->getPref("tst_question_selection_mode_equal");
     $question_selection = new ilCheckboxInputGUI($this->lng->txt("tst_question_selection"), "chbQuestionSelectionMode");
     $question_selection->setValue(1);
     $question_selection->setChecked($selection_mode);
     $question_selection->setOptionTitle($this->lng->txt('tst_question_selection_equal'));
     $question_selection->setInfo($this->lng->txt('tst_question_selection_description'));
     $question_selection->setRequired(false);
     $form->addItem($question_selection);
     // total amount of questions
     $total_questions = new ilNumberInputGUI($this->lng->txt('tst_total_questions'), 'total_questions');
     $total_questions->setValue($this->object->getRandomQuestionCount());
     $total_questions->setSize(3);
     $total_questions->setInfo($this->lng->txt('tst_total_questions_description'));
     $total_questions->setRequired(false);
     $form->addItem($total_questions);
     if ($total == 0) {
         $found_qpls = $this->object->getRandomQuestionpoolData();
         include_once "./Modules/Test/classes/class.ilRandomTestData.php";
         if (count($found_qpls) == 0) {
             array_push($found_qpls, new ilRandomTestData());
         }
         $available_qpl =& $this->object->getAvailableQuestionpools(TRUE, $selection_mode, FALSE, TRUE, TRUE);
         include_once './Modules/Test/classes/class.ilRandomTestInputGUI.php';
         $source = new ilRandomTestInputGUI($this->lng->txt('tst_random_questionpools'), 'source');
         $source->setUseEqualPointsOnly($selection_mode);
         $source->setRandomQuestionPools($available_qpl);
         $source->setUseQuestionCount(array_key_exists('total_questions', $_POST) ? $_POST['total_questions'] < 1 : $this->object->getRandomQuestionCount() < 1);
         $source->setValues($found_qpls);
         $form->addItem($source);
     } else {
         $qpls = $this->object->getUsedRandomQuestionpools();
         include_once './Modules/Test/classes/class.ilRandomTestROInputGUI.php';
         $source = new ilRandomTestROInputGUI($this->lng->txt('tst_random_questionpools'), 'source');
         $source->setValues($qpls);
         $form->addItem($source);
     }
     if ($total == 0) {
         $form->addCommandButton("saveRandomQuestions", $this->lng->txt("save"));
     }
     $errors = false;
     if ($save) {
         $form->setValuesByPost();
         $errors = !$form->checkInput();
         if (!$errors) {
             // check total amount of questions
             if ($_POST['total_questions'] > 0) {
                 $totalcount = 0;
                 foreach ($_POST['source']['qpl'] as $idx => $qpl) {
                     $totalcount += $available_qpl[$qpl]['count'];
                 }
                 if ($_POST['total_questions'] > $totalcount) {
                     $total_questions->setAlert($this->lng->txt('msg_total_questions_too_high'));
                     $errors = true;
                 }
             }
         }
         if ($errors) {
             $checkonly = false;
         }
     }
     if (!$checkonly) {
         $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
     }
     return $errors;
 }
Ejemplo n.º 15
0
 /**
  * Material tab of the survey questions
  */
 public function material($checkonly = FALSE)
 {
     global $rbacsystem, $ilTabs;
     $ilTabs->activateTab("material");
     $add_html = '';
     if ($rbacsystem->checkAccess('write', $_GET['ref_id'])) {
         include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
         $form = new ilPropertyFormGUI();
         $form->setFormAction($this->ctrl->getFormAction($this));
         $form->setTitle($this->lng->txt('add_material'));
         $form->setMultipart(FALSE);
         $form->setTableWidth("100%");
         $form->setId("material");
         // material
         $material = new ilRadioGroupInputGUI($this->lng->txt("material"), "internalLinkType");
         $material->setRequired(true);
         $material->addOption(new ilRadioOption($this->lng->txt('obj_lm'), "lm"));
         $material->addOption(new ilRadioOption($this->lng->txt('obj_st'), "st"));
         $material->addOption(new ilRadioOption($this->lng->txt('obj_pg'), "pg"));
         $material->addOption(new ilRadioOption($this->lng->txt('glossary_term'), "glo"));
         $form->addItem($material);
         $form->addCommandButton("addMaterial", $this->lng->txt("add"));
         $errors = false;
         if ($checkonly) {
             $form->setValuesByPost();
             $errors = !$form->checkInput();
             if ($errors) {
                 $checkonly = false;
             }
         }
         $add_html = $form->getHTML();
     }
     $mat_html = "";
     if (count($this->object->getMaterial())) {
         include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyMaterialsTableGUI.php";
         $table_gui = new ilSurveyMaterialsTableGUI($this, 'material', $rbacsystem->checkAccess('write', $_GET['ref_id']) ? true : false);
         $data = array();
         foreach ($this->object->getMaterial() as $material) {
             switch ($material->type) {
                 case 0:
                     $href = SurveyQuestion::_getInternalLinkHref($material->internal_link, $_GET['ref_id']);
                     $type = $this->lng->txt('internal_link');
                     break;
             }
             $title = strlen($material->title) ? ilUtil::prepareFormOutput($material->title) : $this->lng->txt('material');
             array_push($data, array('href' => $href, 'title' => $title, 'type' => $type));
         }
         $table_gui->setData($data);
         $mat_html = $table_gui->getHTML();
     }
     if (!$checkonly) {
         $this->tpl->setVariable("ADM_CONTENT", $add_html . $mat_html);
     }
     return $errors;
 }
 /**
  * @param ilPropertyFormGUI $form
  */
 public function showChatOptions(ilPropertyFormGUI $form = null)
 {
     /**
      * @var $ilUser ilObjUser
      * @var $ilCtrl ilCtrl
      */
     global $ilUser, $ilCtrl;
     $chatSettings = new ilSetting('chatroom');
     $notificationSettings = new ilSetting('notifications');
     if (!($chatSettings->get('chat_enabled', false) && $notificationSettings->get('enable_osd', false) && $chatSettings->get('play_invitation_sound', false))) {
         $ilCtrl->redirect($this);
     }
     $this->__initSubTabs('showChatOptions');
     $this->setHeader();
     if ($form) {
         $form->setValuesByPost();
     } else {
         $form = $this->getChatSettingsForm();
         $form->setValuesByArray(array('play_invitation_sound' => $ilUser->getPref('chat_play_invitation_sound')));
     }
     $this->tpl->setContent($form->getHTML());
     $this->tpl->show();
 }
Ejemplo n.º 17
0
 /**
  * Creates the output of the feedback page for a single choice question
  *
  * @access public
  */
 function feedback($checkonly = false)
 {
     $save = strcmp($this->ctrl->getCmd(), "saveFeedback") == 0 ? TRUE : FALSE;
     include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
     $form = new ilPropertyFormGUI();
     $form->setFormAction($this->ctrl->getFormAction($this));
     $form->setTitle($this->lng->txt('feedback_answers'));
     $form->setTableWidth("100%");
     $form->setId("feedback");
     $complete = new ilTextAreaInputGUI($this->lng->txt("feedback_complete_solution"), "feedback_complete");
     $complete->setValue($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(1)));
     $complete->setRequired(falsse);
     $complete->setRows(10);
     $complete->setCols(80);
     $complete->setUseRte(true);
     include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
     $complete->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("assessment"));
     $complete->addPlugin("latex");
     $complete->addButton("latex");
     $complete->addButton("pastelatex");
     $complete->setRTESupport($this->object->getId(), "qpl", "assessment");
     $form->addItem($complete);
     $incomplete = new ilTextAreaInputGUI($this->lng->txt("feedback_incomplete_solution"), "feedback_incomplete");
     $incomplete->setValue($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(0)));
     $incomplete->setRequired(false);
     $incomplete->setRows(10);
     $incomplete->setCols(80);
     $incomplete->setUseRte(true);
     include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
     $incomplete->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("assessment"));
     $incomplete->addPlugin("latex");
     $incomplete->addButton("latex");
     $incomplete->addButton("pastelatex");
     $incomplete->setRTESupport($this->object->getId(), "qpl", "assessment");
     $form->addItem($incomplete);
     if (!$this->getSelfAssessmentEditingMode()) {
         foreach ($this->object->answers as $index => $answer) {
             $answerobj = new ilTextAreaInputGUI($this->object->prepareTextareaOutput($answer->getAnswertext(), true), "feedback_answer_{$index}");
             $answerobj->setValue($this->object->prepareTextareaOutput($this->object->getFeedbackSyntaxTree($index)));
             $answerobj->setRequired(false);
             $answerobj->setRows(10);
             $answerobj->setCols(80);
             $answerobj->setUseRte(true);
             include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
             $answerobj->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("assessment"));
             $answerobj->addPlugin("latex");
             $answerobj->addButton("latex");
             $answerobj->addButton("pastelatex");
             $answerobj->setRTESupport($this->object->getId(), "qpl", "assessment");
             $form->addItem($answerobj);
         }
     }
     $form->addCommandButton("saveFeedback", $this->lng->txt("save"));
     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 (!$checkonly) {
         $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
     }
     return $errors;
 }
Ejemplo n.º 18
0
 public function phraseEditor($checkonly = FALSE)
 {
     $save = strcmp($this->ctrl->getCmd(), "saveEditPhrase") == 0 ? TRUE : FALSE;
     include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
     $form = new ilPropertyFormGUI();
     $form->setFormAction($this->ctrl->getFormAction($this, 'phraseEditor'));
     $form->setTitle($this->lng->txt('edit_phrase'));
     $form->setMultipart(FALSE);
     $form->setTableWidth("100%");
     $form->setId("phraseeditor");
     $phrase_id = $_GET['p_id'];
     // title
     $title = new ilTextInputGUI($this->lng->txt("title"), "title");
     $title->setValue($this->getPhraseTitle($phrase_id));
     $title->setRequired(TRUE);
     $form->addItem($title);
     // Answers
     include_once "./Modules/SurveyQuestionPool/classes/class.ilCategoryWizardInputGUI.php";
     $answers = new ilCategoryWizardInputGUI($this->lng->txt("answers"), "answers");
     $answers->setRequired(true);
     $answers->setAllowMove(true);
     $answers->setShowWizard(false);
     $answers->setShowSavePhrase(false);
     $answers->setUseOtherAnswer(false);
     $answers->setShowNeutralCategory(true);
     $answers->setNeutralCategoryTitle($this->lng->txt('matrix_neutral_answer'));
     include_once "./Modules/SurveyQuestionPool/classes/class.SurveyCategories.php";
     $categories =& $this->getCategoriesForPhrase($phrase_id);
     if (!$categories->getCategoryCount()) {
         $categories->addCategory("");
     }
     $answers->setValues($categories);
     $answers->setDisabledScale(true);
     $form->addItem($answers);
     $form->addCommandButton("saveEditPhrase", $this->lng->txt("save"));
     $form->addCommandButton("cancelEditPhrase", $this->lng->txt("cancel"));
     $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("ADM_CONTENT", $form->getHTML());
     }
     return $errors;
 }
 /**
  * Resets the current view, by reloading the template with a given form and setting special back target.
  *
  * @param ilPropertyFormGUI $a_form
  */
 private function resetView(ilPropertyFormGUI $a_form)
 {
     $this->tabs->clearTargets();
     $this->tabs->setBackTarget($this->lng->txt('rep_robj_xrs_back_to_floor_plans'), $this->ctrl->getLinkTarget($this, 'render'));
     $a_form->setValuesByPost();
     $this->tpl->setContent($a_form->getHTML());
 }
 /**
  * In case the form was empty an error message and the class form with its non erroneous
  * entries will be displayed.
  *
  * @param ilPropertyFormGUI $a_class_form the class for which the invalid input should be handled
  */
 private function handleInvalidEditClassForm($a_class_form)
 {
     $a_class_form->setValuesByPost();
     $toolbar = $this->createEditClassFormToolbar();
     $this->tpl->setContent($toolbar->getHTML() . $a_class_form->getHTML());
     $this->tabs->setTabActive("edit_properties");
     ilUtil::sendFailure($this->lng->txt("err_check_input"));
 }