コード例 #1
0
 /**
  * Update properties
  */
 public function uploadFiles()
 {
     $response = new stdClass();
     $response->error = null;
     $response->debug = null;
     $this->initUploadForm();
     if ($this->form->checkInput()) {
         try {
             $fileresult = $this->handleFileUpload($this->form->getInput("upload_files"));
             if ($fileresult) {
                 $response = (object) array_merge((array) $response, (array) $fileresult);
             }
         } catch (ilException $e) {
             $response->error = $e->getMessage();
         }
     } else {
         $error = new ilCloudException(ilCloudException::UPLOAD_FAILED);
         $response->error = $error->getMessage();
     }
     // send response object (don't use 'application/json' as IE wants to download it!)
     header('Vary: Accept');
     header('Content-type: text/plain');
     echo ilJsonUtil::encode($response);
     exit;
 }
コード例 #2
0
 /**
  *
  */
 protected function saveSettings()
 {
     /**
      * @var $rbacsystem ilRbacSystem
      * @var $ilErr      ilErrorHandling
      */
     global $rbacsystem, $ilErr;
     if (!$rbacsystem->checkAccess('write', $this->object->getRefId())) {
         $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->MESSAGE);
     }
     $provider = $this->factory->getByContext(ilTermsOfServiceTableDataProviderFactory::CONTEXT_AGRREMENT_BY_LANGUAGE);
     $list = $provider->getList(array(), array());
     $has_documents = false;
     foreach ($list['items'] as $item) {
         if ($item['agreement_document']) {
             $has_documents = true;
             break;
         }
     }
     $this->initSettingsForm();
     if ($this->form->checkInput()) {
         if ($has_documents || !(int) $this->form->getInput('tos_status')) {
             $this->object->saveStatus((int) $this->form->getInput('tos_status'));
             ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
         }
     }
     if (!$has_documents && (int) $this->form->getInput('tos_status') && !$this->object->getStatus()) {
         $_POST['tos_status'] = 0;
         ilUtil::sendFailure($this->lng->txt('tos_no_documents_exist_cant_save'));
     }
     $this->settings(false);
 }
コード例 #3
0
 /**
  * Check input of form
  *
  * @param $a_mode 'create' | 'update'
  *
  * @return bool
  */
 protected function checkInput($a_mode)
 {
     global $lng;
     $return = $this->form->checkInput();
     // Additional check for text fields: The length property should be max 200 if the textarea option is not set
     if ($this->form->getInput('datatype') == ilDataCollectionDatatype::INPUTFORMAT_TEXT && (int) $this->form->getInput('prop_' . ilDataCollectionField::PROPERTYID_LENGTH) > 200 && !$this->form->getInput('prop_' . ilDataCollectionField::PROPERTYID_TEXTAREA)) {
         $inputObj = $this->form->getItemByPostVar('prop_' . ilDataCollectionField::PROPERTYID_LENGTH);
         $inputObj->setAlert($lng->txt("form_msg_value_too_high"));
         $return = false;
     }
     // Don't allow multiple fields with the same title in this table
     if ($a_mode == 'create') {
         if ($title = $this->form->getInput('title')) {
             if (ilDataCollectionTable::_hasFieldByTitle($title, $this->table_id)) {
                 $inputObj = $this->form->getItemByPostVar('title');
                 $inputObj->setAlert($lng->txt("dcl_field_title_unique"));
                 $return = false;
             }
         }
     }
     if (!$return) {
         ilUtil::sendFailure($lng->txt("form_input_not_valid"));
     }
     return $return;
 }
コード例 #4
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());
 }
コード例 #5
0
 /**
  *
  */
 protected function saveSettings()
 {
     /**
      * @var $rbacsystem ilRbacSystem
      * @var $ilErr      ilErrorHandling
      */
     global $rbacsystem, $ilErr;
     if (!$rbacsystem->checkAccess('write', $this->object->getRefId())) {
         $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->MESSAGE);
     }
     $this->initSettingsForm();
     if ($this->form->checkInput()) {
         $this->object->saveStatus((int) $this->form->getInput('tos_status'));
         ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
     }
     $this->settings(false);
 }
コード例 #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();
 }
コード例 #7
0
 /**
  *
  */
 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());
     }
 }
コード例 #9
0
 /**
  *	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());
 }
コード例 #10
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("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;
 }
コード例 #11
0
 /**
  * Validate field form
  * 
  * @param ilPropertyFormGUI $form 
  * @param ilUserDefinedFields $user_field_definitions 
  * @param array $access 
  * @param array $a_field_permissions 
  * @return bool
  */
 protected function validateForm($form, $user_field_definitions, array &$access, array $a_field_permissions = null)
 {
     global $lng;
     if ($form->checkInput()) {
         $valid = true;
         $incoming = (array) $form->getInput("access");
         if ($a_field_permissions) {
             $perm_map = self::getAccessPermissions();
         }
         $access = array();
         foreach (array_keys($this->getAccessOptions()) as $id) {
             $access[$id] = in_array($id, $incoming);
             // disabled fields
             if ($a_field_permissions && !$a_field_permissions[ilUDFPermissionHelper::ACTION_FIELD_EDIT_ACCESS][$perm_map[$id]]) {
                 $access[$id] = $this->field_definition[$id];
             }
         }
         if ($access['required'] && !$access['visib_reg']) {
             $this->confirm_change = true;
             $form->getItemByPostVar("access")->setAlert($lng->txt('udf_required_requires_visib_reg'));
             $valid = false;
         }
         if (!$this->field_id && $user_field_definitions->nameExists($form->getInput("name"))) {
             $form->getItemByPostVar("name")->setAlert($lng->txt('udf_name_already_exists'));
             $valid = false;
         }
         if ($form->getInput("field_type") == UDF_TYPE_SELECT && (!$a_field_permissions || $a_field_permissions[ilUDFPermissionHelper::ACTION_FIELD_EDIT_PROPERTY][ilUDFPermissionHelper::SUBACTION_FIELD_PROPERTIES])) {
             $user_field_definitions->setFieldValues($form->getInput("selvalue"));
             if ($error = $user_field_definitions->validateValues()) {
                 switch ($error) {
                     case UDF_DUPLICATE_VALUES:
                         $form->getItemByPostVar("selvalue")->setAlert($lng->txt('udf_duplicate_entries'));
                         $valid = false;
                         break;
                 }
             }
         }
         if (!$valid) {
             ilUtil::sendFailure($lng->txt("form_input_not_valid"));
         }
         return $valid;
     }
     return false;
 }
コード例 #12
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;
 }
コード例 #13
0
 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;
 }
コード例 #14
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;
 }
コード例 #15
0
 /**
  * Questionpool properties
  */
 public function propertiesObject()
 {
     $save = strcmp($this->ctrl->getCmd(), "save") == 0 ? true : false;
     include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
     $form = new ilPropertyFormGUI();
     $form->setFormAction($this->ctrl->getFormAction($this, 'properties'));
     $form->setTitle($this->lng->txt("properties"));
     $form->setMultipart(false);
     $form->setId("properties");
     // online
     $online = new ilCheckboxInputGUI($this->lng->txt("spl_online_property"), "online");
     $online->setInfo($this->lng->txt("spl_online_property_description"));
     $online->setChecked($this->object->getOnline());
     $form->addItem($online);
     $form->addCommandButton("saveProperties", $this->lng->txt("save"));
     if ($save) {
         $form->checkInput();
     }
     $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
 }
コード例 #16
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;
 }
コード例 #17
0
 /**
  * Validate field form
  * 
  * @param ilPropertyFormGUI $form 
  * @param ilUserDefinedFields $user_field_definitions 
  * @param array $access 
  * @return bool
  */
 protected function validateForm($form, $user_field_definitions, array &$access)
 {
     global $lng;
     if ($form->checkInput()) {
         $valid = true;
         $incoming = (array) $form->getInput("access");
         $access = array();
         foreach (array_keys($this->getAccessOptions()) as $id) {
             $access[$id] = in_array($id, $incoming);
         }
         if ($access['required'] && !$access['visib_reg']) {
             $this->confirm_change = true;
             $form->getItemByPostVar("access")->setAlert($lng->txt('udf_required_requires_visib_reg'));
             $valid = false;
         }
         if (!$this->field_id && $user_field_definitions->nameExists($form->getInput("name"))) {
             $form->getItemByPostVar("name")->setAlert($lng->txt('udf_name_already_exists'));
             $valid = false;
         }
         if ($form->getInput("field_type") == UDF_TYPE_SELECT) {
             $user_field_definitions->setFieldValues($form->getInput("selvalue"));
             if ($error = $user_field_definitions->validateValues()) {
                 switch ($error) {
                     case UDF_DUPLICATE_VALUES:
                         $form->getItemByPostVar("selvalue")->setAlert($lng->txt('udf_duplicate_entries'));
                         $valid = false;
                         break;
                 }
             }
         }
         if (!$valid) {
             ilUtil::sendFailure($lng->txt("form_input_not_valid"));
         }
         return $valid;
     }
     return false;
 }
コード例 #18
0
 /**
  * Save record
  */
 public function save()
 {
     $this->initForm();
     if ($this->form->checkInput()) {
         $record_obj = ilDataCollectionCache::getRecordCache($this->record_id);
         $date_obj = new ilDateTime(time(), IL_CAL_UNIX);
         $record_obj->setTableId($this->table_id);
         $record_obj->setLastUpdate($date_obj->get(IL_CAL_DATETIME));
         $record_obj->setLastEditBy($this->user->getId());
         $create_mode = false;
         if (ilObjDataCollection::_hasWriteAccess($this->parent_obj->ref_id)) {
             $all_fields = $this->table->getRecordFields();
         } else {
             $all_fields = $this->table->getEditableFields();
         }
         $fail = "";
         //Check if we can create this record.
         foreach ($all_fields as $field) {
             try {
                 $value = $this->form->getInput("field_" . $field->getId());
                 $field->checkValidity($value, $this->record_id);
             } catch (ilDataCollectionInputException $e) {
                 $fail .= $field->getTitle() . ": " . $e . "<br>";
             }
         }
         if ($fail) {
             $this->sendFailure($fail);
             return;
         }
         if (!isset($this->record_id)) {
             if (!$this->table->hasPermissionToAddRecord($this->parent_obj->ref_id)) {
                 $this->accessDenied();
                 return;
             }
             $record_obj->setOwner($this->user->getId());
             $record_obj->setCreateDate($date_obj->get(IL_CAL_DATETIME));
             $record_obj->setTableId($this->table_id);
             $record_obj->doCreate();
             $this->record_id = $record_obj->getId();
             $create_mode = true;
         } else {
             if (!$record_obj->hasPermissionToEdit($this->parent_obj->ref_id)) {
                 $this->accessDenied();
                 return;
             }
         }
         //edit values, they are valid we already checked them above
         foreach ($all_fields as $field) {
             $value = $this->form->getInput("field_" . $field->getId());
             //deletion flag on MOB inputs.
             if ($field->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_MOB && $this->form->getItemByPostVar("field_" . $field->getId())->getDeletionFlag()) {
                 $value = -1;
             }
             $record_obj->setRecordFieldValue($field->getId(), $value);
         }
         // Do we need to set a new owner for this record?
         if (!$create_mode) {
             $owner_id = ilObjUser::_lookupId($_POST['field_owner']);
             if (!$owner_id) {
                 $this->sendFailure($this->lng->txt('user_not_known'));
                 return;
             }
             $record_obj->setOwner($owner_id);
         }
         if ($create_mode) {
             ilObjDataCollection::sendNotification("new_record", $this->table_id, $record_obj->getId());
         }
         $record_obj->doUpdate();
         $this->ctrl->setParameter($this, "table_id", $this->table_id);
         $this->ctrl->setParameter($this, "record_id", $this->record_id);
         if (!$this->ctrl->isAsynch()) {
             ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
         }
         $this->checkAndPerformRedirect();
         if ($this->ctrl->isAsynch()) {
             // If ajax request, return the form in edit mode again
             $this->record_id = $record_obj->getId();
             $this->initForm();
             $this->setFormValues();
             echo $this->tpl->getMessageHTML($this->lng->txt('msg_obj_modified'), 'success') . $this->form->getHTML();
             exit;
         } else {
             $this->ctrl->redirectByClass("ildatacollectionrecordlistgui", "listRecords");
         }
     } else {
         // Form not valid...
         $this->form->setValuesByPost();
         if ($this->ctrl->isAsynch()) {
             echo $this->form->getHTML();
             exit;
         } else {
             $this->tpl->setContent($this->form->getHTML());
         }
     }
 }
コード例 #19
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;
 }
コード例 #20
0
 /**
  * Allows to add suggested solutions for questions
  *
  * @access public
  */
 public function suggestedsolution()
 {
     global $ilUser;
     global $ilAccess;
     if ($_POST["deleteSuggestedSolution"] == 1) {
         $this->object->deleteSuggestedSolutions();
         ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
         $this->ctrl->redirect($this, "suggestedsolution");
     }
     $save = is_array($_POST["cmd"]) && array_key_exists("suggestedsolution", $_POST["cmd"]) ? TRUE : FALSE;
     $output = "";
     $solution_array = $this->object->getSuggestedSolution(0);
     $options = array("lm" => $this->lng->txt("obj_lm"), "st" => $this->lng->txt("obj_st"), "pg" => $this->lng->txt("obj_pg"), "git" => $this->lng->txt("glossary_term"), "file" => $this->lng->txt("fileDownload"), "text" => $this->lng->txt("solutionText"));
     if (strcmp($_POST["solutiontype"], "file") == 0 && strcmp($solution_array["type"], "file") != 0) {
         $solution_array = array("type" => "file");
     } elseif (strcmp($_POST["solutiontype"], "text") == 0 && strcmp($solution_array["type"], "text") != 0) {
         $solution_array = array("type" => "text", "value" => $this->getSolutionOutput(0, NULL, FALSE, FALSE, TRUE, FALSE, TRUE));
     }
     if ($save && strlen($_POST["filename"])) {
         $solution_array["value"]["filename"] = $_POST["filename"];
     }
     if ($save && strlen($_POST["solutiontext"])) {
         $solution_array["value"] = $_POST["solutiontext"];
     }
     include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
     if (count($solution_array)) {
         $form = new ilPropertyFormGUI();
         $form->setFormAction($this->ctrl->getFormAction($this));
         $form->setTitle($this->lng->txt("solution_hint"));
         $form->setMultipart(TRUE);
         $form->setTableWidth("100%");
         $form->setId("suggestedsolutiondisplay");
         // suggested solution output
         include_once "./Modules/TestQuestionPool/classes/class.ilSolutionTitleInputGUI.php";
         $title = new ilSolutionTitleInputGUI($this->lng->txt("showSuggestedSolution"), "solutiontype");
         $template = new ilTemplate("tpl.il_as_qpl_suggested_solution_input_presentation.html", TRUE, TRUE, "Modules/TestQuestionPool");
         if (strlen($solution_array["internal_link"])) {
             $href = assQuestion::_getInternalLinkHref($solution_array["internal_link"]);
             $template->setCurrentBlock("preview");
             $template->setVariable("TEXT_SOLUTION", $this->lng->txt("suggested_solution"));
             $template->setVariable("VALUE_SOLUTION", " <a href=\"{$href}\" target=\"content\">" . $this->lng->txt("view") . "</a> ");
             $template->parseCurrentBlock();
         } elseif (strcmp($solution_array["type"], "file") == 0 && is_array($solution_array["value"])) {
             $href = $this->object->getSuggestedSolutionPathWeb() . $solution_array["value"]["name"];
             $template->setCurrentBlock("preview");
             $template->setVariable("TEXT_SOLUTION", $this->lng->txt("suggested_solution"));
             $template->setVariable("VALUE_SOLUTION", " <a href=\"{$href}\" target=\"content\">" . ilUtil::prepareFormOutput(strlen($solution_array["value"]["filename"]) ? $solution_array["value"]["filename"] : $solution_array["value"]["name"]) . "</a> ");
             $template->parseCurrentBlock();
         }
         $template->setVariable("TEXT_TYPE", $this->lng->txt("type"));
         $template->setVariable("VALUE_TYPE", $options[$solution_array["type"]]);
         $title->setHtml($template->get());
         $deletesolution = new ilCheckboxInputGUI("", "deleteSuggestedSolution");
         $deletesolution->setOptionTitle($this->lng->txt("deleteSuggestedSolution"));
         $title->addSubItem($deletesolution);
         $form->addItem($title);
         if (strcmp($solution_array["type"], "file") == 0) {
             // file
             $file = new ilFileInputGUI($this->lng->txt("fileDownload"), "file");
             $file->setRequired(TRUE);
             $file->enableFileNameSelection("filename");
             //$file->setSuffixes(array("doc","xls","png","jpg","gif","pdf"));
             if ($_FILES["file"]["tmp_name"] && $file->checkInput()) {
                 if (!file_exists($this->object->getSuggestedSolutionPath())) {
                     ilUtil::makeDirParents($this->object->getSuggestedSolutionPath());
                 }
                 $res = ilUtil::moveUploadedFile($_FILES["file"]["tmp_name"], $_FILES["file"]["name"], $this->object->getSuggestedSolutionPath() . $_FILES["file"]["name"]);
                 if ($res) {
                     ilUtil::renameExecutables($this->object->getSuggestedSolutionPath());
                     // remove an old file download
                     if (is_array($solution_array["value"])) {
                         @unlink($this->object->getSuggestedSolutionPath() . $solution_array["value"]["name"]);
                     }
                     $file->setValue($_FILES["file"]["name"]);
                     $this->object->saveSuggestedSolution("file", "", 0, array("name" => $_FILES["file"]["name"], "type" => $_FILES["file"]["type"], "size" => $_FILES["file"]["size"], "filename" => $_POST["filename"]));
                     $originalexists = $this->object->_questionExistsInPool($this->object->original_id);
                     if (($_GET["calling_test"] || isset($_GET['calling_consumer']) && (int) $_GET['calling_consumer']) && $originalexists && assQuestion::_isWriteable($this->object->original_id, $ilUser->getId())) {
                         return $this->originalSyncForm("suggestedsolution");
                     } else {
                         ilUtil::sendSuccess($this->lng->txt("suggested_solution_added_successfully"), TRUE);
                         $this->ctrl->redirect($this, "suggestedsolution");
                     }
                 } else {
                     // BH: $res as info string? wtf? it holds a bool or something else!!?
                     ilUtil::sendInfo($res);
                 }
             } else {
                 if (is_array($solution_array["value"])) {
                     $file->setValue($solution_array["value"]["name"]);
                     $file->setFilename(strlen($solution_array["value"]["filename"]) ? $solution_array["value"]["filename"] : $solution_array["value"]["name"]);
                 }
             }
             $form->addItem($file);
             $hidden = new ilHiddenInputGUI("solutiontype");
             $hidden->setValue("file");
             $form->addItem($hidden);
         } else {
             if (strcmp($solution_array["type"], "text") == 0) {
                 $question = new ilTextAreaInputGUI($this->lng->txt("solutionText"), "solutiontext");
                 $question->setValue($this->object->prepareTextareaOutput($solution_array["value"]));
                 $question->setRequired(TRUE);
                 $question->setRows(10);
                 $question->setCols(80);
                 $question->setUseRte(TRUE);
                 $question->addPlugin("latex");
                 $question->addButton("latex");
                 $question->setRTESupport($this->object->getId(), "qpl", "assessment");
                 $hidden = new ilHiddenInputGUI("solutiontype");
                 $hidden->setValue("text");
                 $form->addItem($hidden);
                 $form->addItem($question);
             }
         }
         if ($ilAccess->checkAccess("write", "", $_GET['ref_id'])) {
             $form->addCommandButton("suggestedsolution", $this->lng->txt("save"));
         }
         if ($save) {
             if ($form->checkInput()) {
                 switch ($solution_array["type"]) {
                     case "file":
                         $this->object->saveSuggestedSolution("file", "", 0, array("name" => $solution_array["value"]["name"], "type" => $solution_array["value"]["type"], "size" => $solution_array["value"]["size"], "filename" => $_POST["filename"]));
                         break;
                     case "text":
                         $this->object->saveSuggestedSolution("text", "", 0, $solution_array["value"]);
                         break;
                 }
                 $originalexists = $this->object->_questionExistsInPool($this->object->original_id);
                 if (($_GET["calling_test"] || isset($_GET['calling_consumer']) && (int) $_GET['calling_consumer']) && $originalexists && assQuestion::_isWriteable($this->object->original_id, $ilUser->getId())) {
                     return $this->originalSyncForm("suggestedsolution");
                 } else {
                     ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
                     $this->ctrl->redirect($this, "suggestedsolution");
                 }
             }
         }
         $output = $form->getHTML();
     }
     $savechange = strcmp($this->ctrl->getCmd(), "saveSuggestedSolution") == 0 ? TRUE : FALSE;
     $changeoutput = "";
     if ($ilAccess->checkAccess("write", "", $_GET['ref_id'])) {
         $formchange = new ilPropertyFormGUI();
         $formchange->setFormAction($this->ctrl->getFormAction($this));
         $formchange->setTitle(count($solution_array) ? $this->lng->txt("changeSuggestedSolution") : $this->lng->txt("addSuggestedSolution"));
         $formchange->setMultipart(FALSE);
         $formchange->setTableWidth("100%");
         $formchange->setId("suggestedsolution");
         $solutiontype = new ilRadioGroupInputGUI($this->lng->txt("suggestedSolutionType"), "solutiontype");
         foreach ($options as $opt_value => $opt_caption) {
             $solutiontype->addOption(new ilRadioOption($opt_caption, $opt_value));
         }
         if (count($solution_array)) {
             $solutiontype->setValue($solution_array["type"]);
         }
         $solutiontype->setRequired(TRUE);
         $formchange->addItem($solutiontype);
         $formchange->addCommandButton("saveSuggestedSolution", $this->lng->txt("select"));
         if ($savechange) {
             $formchange->checkInput();
         }
         $changeoutput = $formchange->getHTML();
     }
     $this->tpl->setVariable("ADM_CONTENT", $changeoutput . $output);
 }
コード例 #21
0
 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;
 }