function checkInput() { global $lng; include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php"; if (is_array($_POST[$this->getPostVar()])) { $_POST[$this->getPostVar()] = ilUtil::stripSlashesRecursive($_POST[$this->getPostVar()], false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment")); } $foundvalues = $_POST[$this->getPostVar()]; #vd($foundvalues); if (is_array($foundvalues)) { // check answers if (is_array($foundvalues['answer'])) { foreach ($foundvalues['answer'] as $aidx => $answervalue) { if (strlen($answervalue) == 0 && strlen($foundvalues['imagename'][$aidx]) == 0) { $this->setAlert($lng->txt("msg_input_is_required")); return FALSE; } } } // check correctness if (!isset($foundvalues['correctness']) || count($foundvalues['correctness']) < count($foundvalues['answer'])) { $this->setAlert($lng->txt("msg_input_is_required")); return false; } if (!$this->checkUploads($foundvalues)) { return false; } } else { $this->setAlert($lng->txt("msg_input_is_required")); return FALSE; } return $this->checkSubItemsInput(); }
/** * Check input, strip slashes etc. set alert, if input is not ok. * * @return boolean Input ok, true/false */ function checkInput() { global $lng; include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php"; if (is_array($_POST[$this->getPostVar()])) { $_POST[$this->getPostVar()] = ilUtil::stripSlashesRecursive($_POST[$this->getPostVar()], true, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment")); } $foundvalues = $_POST[$this->getPostVar()]; if (is_array($foundvalues)) { // check answers if (is_array($foundvalues['answer'])) { foreach ($foundvalues['answer'] as $aidx => $answervalue) { if (strlen($answervalue) == 0 && strlen($foundvalues['imagename'][$aidx]) == 0) { $this->setAlert($lng->txt("msg_input_is_required")); return FALSE; } } } if (!$this->hideImages) { if (is_array($_FILES[$this->getPostVar()]['error']['image'])) { foreach ($_FILES[$this->getPostVar()]['error']['image'] as $index => $error) { // error handling if ($error > 0) { switch ($error) { case UPLOAD_ERR_INI_SIZE: $this->setAlert($lng->txt("form_msg_file_size_exceeds")); return false; break; case UPLOAD_ERR_FORM_SIZE: $this->setAlert($lng->txt("form_msg_file_size_exceeds")); return false; break; case UPLOAD_ERR_PARTIAL: $this->setAlert($lng->txt("form_msg_file_partially_uploaded")); return false; break; case UPLOAD_ERR_NO_FILE: if ($this->getRequired()) { if (!strlen($foundvalues['imagename'][$index]) && !strlen($foundvalues['answer'][$index])) { $this->setAlert($lng->txt("form_msg_file_no_upload")); return false; } } break; case UPLOAD_ERR_NO_TMP_DIR: $this->setAlert($lng->txt("form_msg_file_missing_tmp_dir")); return false; break; case UPLOAD_ERR_CANT_WRITE: $this->setAlert($lng->txt("form_msg_file_cannot_write_to_disk")); return false; break; case UPLOAD_ERR_EXTENSION: $this->setAlert($lng->txt("form_msg_file_upload_stopped_ext")); return false; break; } } } } if (is_array($_FILES[$this->getPostVar()]['tmp_name']['image'])) { foreach ($_FILES[$this->getPostVar()]['tmp_name']['image'] as $index => $tmpname) { $filename = $_FILES[$this->getPostVar()]['name']['image'][$index]; $filename_arr = pathinfo($filename); $suffix = $filename_arr["extension"]; // check suffixes if (strlen($tmpname) && is_array($this->getSuffixes())) { $vir = ilUtil::virusHandling($tmpname, $filename); if ($vir[0] == false) { $this->setAlert($lng->txt("form_msg_file_virus_found") . "<br />" . $vir[1]); return false; } if (!in_array(strtolower($suffix), $this->getSuffixes())) { $this->setAlert($lng->txt("form_msg_file_wrong_file_type")); return false; } } } } } } return $this->checkSubItemsInput(); }
/** * FORM HtmlBlock: Get current values for HtmlBlock form. * */ public function getValuesHtmlBlock() { $values = array(); switch ($this->getFormEditMode()) { case IL_FORM_CREATE: $values["Title"] = ""; $values["Content"] = ""; break; case IL_FORM_EDIT: $values["Title"] = $this->html_block->getTitle(); $values["Content"] = $this->html_block->getContent(); break; case IL_FORM_RE_EDIT: case IL_FORM_RE_CREATE: $values["Title"] = ilUtil::stripSlashes($_POST["block_title"]); $values["Content"] = ilUtil::stripSlashes($_POST["block_content"], true, ilObjAdvancedEditing::_getUsedHTMLTagsAsString()); break; } return $values; }
private function performSaveForm(ilPropertyFormGUI $form) { include_once 'Services/MetaData/classes/class.ilMD.php'; $md_obj =& new ilMD($this->testOBJ->getId(), 0, "tst"); $md_section = $md_obj->getGeneral(); // title $md_section->setTitle(ilUtil::stripSlashes($form->getItemByPostVar('title')->getValue())); $md_section->update(); // Description $md_desc_ids = $md_section->getDescriptionIds(); if ($md_desc_ids) { $md_desc = $md_section->getDescription(array_pop($md_desc_ids)); $md_desc->setDescription(ilUtil::stripSlashes($form->getItemByPostVar('description')->getValue())); $md_desc->update(); } else { $md_desc = $md_section->addDescription(); $md_desc->setDescription(ilUtil::stripSlashes($form->getItemByPostVar('description')->getValue())); $md_desc->save(); } $this->testOBJ->setTitle(ilUtil::stripSlashes($form->getItemByPostVar('title')->getValue())); $this->testOBJ->setDescription(ilUtil::stripSlashes($form->getItemByPostVar('description')->getValue())); $this->testOBJ->update(); // pool usage setting if ($form->getItemByPostVar('use_pool') instanceof ilFormPropertyGUI) { $this->testOBJ->setPoolUsage($form->getItemByPostVar('use_pool')->getChecked()); } // Archiving $this->testOBJ->setEnableArchiving($form->getItemByPostVar('enable_archiving')->getChecked()); // Examview $this->testOBJ->setEnableExamview($form->getItemByPostVar('enable_examview')->getChecked()); $this->testOBJ->setShowExamviewHtml($form->getItemByPostVar('show_examview_html')->getChecked()); $this->testOBJ->setShowExamviewPdf($form->getItemByPostVar('show_examview_pdf')->getChecked()); // online status $this->testOBJ->setOnline($form->getItemByPostVar('online')->getChecked()); // activation if ($form->getItemByPostVar('activation_type')->getValue() == ilObjectActivation::TIMINGS_ACTIVATION) { $this->testOBJ->setActivationLimited(true); $this->testOBJ->setActivationVisibility($form->getItemByPostVar('activation_visibility')->getChecked()); $period = $form->getItemByPostVar("access_period"); $this->testOBJ->setActivationStartingTime($period->getStart()->get(IL_CAL_UNIX)); $this->testOBJ->setActivationEndingTime($period->getEnd()->get(IL_CAL_UNIX)); } else { $this->testOBJ->setActivationLimited(false); } include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php"; $this->testOBJ->setIntroduction($form->getItemByPostVar('introduction')->getValue(), false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment")); $this->testOBJ->setShowInfo($form->getItemByPostVar('showinfo')->getChecked()); $this->testOBJ->setFinalStatement($form->getItemByPostVar('finalstatement')->getValue(), false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment")); $this->testOBJ->setShowFinalStatement($form->getItemByPostVar('showfinalstatement')->getChecked()); if ($form->getItemByPostVar('chb_postpone') instanceof ilFormPropertyGUI) { $this->testOBJ->setSequenceSettings($form->getItemByPostVar('chb_postpone')->getChecked()); } $this->testOBJ->setShuffleQuestions($form->getItemByPostVar('chb_shuffle_questions')->getChecked()); $this->testOBJ->setListOfQuestions($form->getItemByPostVar('list_of_questions')->getChecked()); $listOfQuestionsOptions = $form->getItemByPostVar('list_of_questions_options')->getValue(); if (is_array($listOfQuestionsOptions)) { $this->testOBJ->setListOfQuestionsStart(in_array('chb_list_of_questions_start', $listOfQuestionsOptions)); $this->testOBJ->setListOfQuestionsEnd(in_array('chb_list_of_questions_end', $listOfQuestionsOptions)); $this->testOBJ->setListOfQuestionsDescription(in_array('chb_list_of_questions_with_description', $listOfQuestionsOptions)); } else { $this->testOBJ->setListOfQuestionsStart(0); $this->testOBJ->setListOfQuestionsEnd(0); $this->testOBJ->setListOfQuestionsDescription(0); } if ($form->getItemByPostVar('mailnotification') instanceof ilFormPropertyGUI) { $this->testOBJ->setMailNotification($form->getItemByPostVar('mailnotification')->getValue()); } if ($form->getItemByPostVar('mailnottype') instanceof ilFormPropertyGUI) { $this->testOBJ->setMailNotificationType($form->getItemByPostVar('mailnottype')->getChecked()); } if ($form->getItemByPostVar('chb_show_marker') instanceof ilFormPropertyGUI) { $this->testOBJ->setShowMarker($form->getItemByPostVar('chb_show_marker')->getChecked()); } if ($form->getItemByPostVar('chb_show_cancel') instanceof ilFormPropertyGUI) { $this->testOBJ->setShowCancel($form->getItemByPostVar('chb_show_cancel')->getChecked()); } if ($form->getItemByPostVar('kiosk') instanceof ilFormPropertyGUI) { $this->testOBJ->setKioskMode($form->getItemByPostVar('kiosk')->getChecked()); $kioskOptions = $form->getItemByPostVar('kiosk_options')->getValue(); if (is_array($kioskOptions)) { $this->testOBJ->setShowKioskModeTitle(in_array('kiosk_title', $kioskOptions)); $this->testOBJ->setShowKioskModeParticipant(in_array('kiosk_participant', $kioskOptions)); $this->testOBJ->setExamidInKiosk(in_array('examid_in_kiosk', $_POST["kiosk_options"])); } } // redirect after test if ($form->getItemByPostVar('redirection_enabled')->getChecked()) { $this->testOBJ->setRedirectionMode($form->getItemByPostVar('redirection_mode')->getValue()); } else { $this->testOBJ->setRedirectionMode(REDIRECT_NONE); } if (strlen($form->getItemByPostVar('redirection_url')->getValue())) { $this->testOBJ->setRedirectionUrl($form->getItemByPostVar('redirection_url')->getValue()); } else { $this->testOBJ->setRedirectionUrl(null); } if ($form->getItemByPostVar('sign_submission')->getChecked()) { $this->testOBJ->setSignSubmission(true); } else { $this->testOBJ->setSignSubmission(false); } $this->testOBJ->setEnableProcessingTime($form->getItemByPostVar('chb_processing_time')->getChecked()); if ($this->testOBJ->getEnableProcessingTime()) { $processingTime = $form->getItemByPostVar('processing_time'); $this->testOBJ->setProcessingTime(sprintf("%02d:%02d:%02d", $processingTime->getHours(), $processingTime->getMinutes(), $processingTime->getSeconds())); } else { $this->testOBJ->setProcessingTime(''); } $this->testOBJ->setResetProcessingTime($form->getItemByPostVar('chb_reset_processing_time')->getChecked()); if ($form->getItemByPostVar('chb_starting_time')->getChecked()) { $startingTimeSetting = $form->getItemByPostVar('starting_time'); $this->testOBJ->setStartingTime(ilFormat::dateDB2timestamp($startingTimeSetting->getDate()->get(IL_CAL_DATETIME))); } else { $this->testOBJ->setStartingTime(''); } if ($form->getItemByPostVar('chb_ending_time')->getChecked()) { $endingTimeSetting = $form->getItemByPostVar('ending_time'); $this->testOBJ->setEndingTime(ilFormat::dateDB2timestamp($endingTimeSetting->getDate()->get(IL_CAL_DATETIME))); } else { $this->testOBJ->setEndingTime(''); } if ($form->getItemByPostVar('forcejs') instanceof ilFormPropertyGUI) { $this->testOBJ->setForceJS($form->getItemByPostVar('forcejs')->getChecked()); } if ($form->getItemByPostVar('title_output') instanceof ilFormPropertyGUI) { $this->testOBJ->setTitleOutput($form->getItemByPostVar('title_output')->getValue()); } if ($form->getItemByPostVar('password') instanceof ilFormPropertyGUI) { $this->testOBJ->setPassword($form->getItemByPostVar('password')->getValue()); } if ($form->getItemByPostVar('allowedUsers') instanceof ilFormPropertyGUI) { $this->testOBJ->setAllowedUsers($form->getItemByPostVar('allowedUsers')->getValue()); } if ($form->getItemByPostVar('allowedUsersTimeGap') instanceof ilFormPropertyGUI) { $this->testOBJ->setAllowedUsersTimeGap($form->getItemByPostVar('allowedUsersTimeGap')->getValue()); } // Selector for uicode characters global $ilSetting; if ($ilSetting->get('char_selector_availability') > 0) { require_once 'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php'; $char_selector = new ilCharSelectorGUI(ilCharSelectorConfig::CONTEXT_TEST); $char_selector->addFormProperties($form); $char_selector->getFormValues($form); $this->testOBJ->setCharSelectorAvailability($char_selector->getConfig()->getAvailability()); $this->testOBJ->setCharSelectorDefinition($char_selector->getConfig()->getDefinition()); } $this->testOBJ->setAutosave($form->getItemByPostVar('autosave')->getChecked()); $this->testOBJ->setAutosaveIval($form->getItemByPostVar('autosave_ival')->getValue() * 1000); $this->testOBJ->setUsePreviousAnswers($form->getItemByPostVar('chb_use_previous_answers')->getChecked()); // highscore settings $this->testOBJ->setHighscoreEnabled((bool) $form->getItemByPostVar('highscore_enabled')->getChecked()); $this->testOBJ->setHighscoreAnon((bool) $form->getItemByPostVar('highscore_anon')->getChecked()); $this->testOBJ->setHighscoreAchievedTS((bool) $form->getItemByPostVar('highscore_achieved_ts')->getChecked()); $this->testOBJ->setHighscoreScore((bool) $form->getItemByPostVar('highscore_score')->getChecked()); $this->testOBJ->setHighscorePercentage((bool) $form->getItemByPostVar('highscore_percentage')->getChecked()); $this->testOBJ->setHighscoreHints((bool) $form->getItemByPostVar('highscore_hints')->getChecked()); $this->testOBJ->setHighscoreWTime((bool) $form->getItemByPostVar('highscore_wtime')->getChecked()); $this->testOBJ->setHighscoreOwnTable((bool) $form->getItemByPostVar('highscore_own_table')->getChecked()); $this->testOBJ->setHighscoreTopTable((bool) $form->getItemByPostVar('highscore_top_table')->getChecked()); $this->testOBJ->setHighscoreTopNum((int) $form->getItemByPostVar('highscore_top_num')->getValue()); if (!$this->testOBJ->participantDataExist()) { // question set type if ($form->getItemByPostVar('question_set_type') instanceof ilFormPropertyGUI) { $this->testOBJ->setQuestionSetType($form->getItemByPostVar('question_set_type')->getValue()); } // anonymity setting $this->testOBJ->setAnonymity($form->getItemByPostVar('anonymity')->getValue()); // nr of tries (max passes) $this->testOBJ->setNrOfTries($form->getItemByPostVar('nr_of_tries')->getValue()); // fixed participants setting if ($form->getItemByPostVar('fixedparticipants') instanceof ilFormPropertyGUI) { $this->testOBJ->setFixedParticipants($form->getItemByPostVar('fixedparticipants')->getChecked()); } } // store settings to db $this->testOBJ->saveToDb(true); // Update ecs export settings include_once 'Modules/Test/classes/class.ilECSTestSettings.php'; $ecs = new ilECSTestSettings($this->testOBJ); $ecs->handleSettingsUpdate(); }
/** * Clones the textblocks of survey questions * * @access public */ function cloneTextblocks($mapping) { foreach ($mapping as $original_id => $new_id) { $textblock = $this->getTextblock($original_id); include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php"; $this->saveHeading(ilUtil::stripSlashes($textblock, TRUE, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("survey")), $new_id); } }
public function saveHeadingObject() { $form = $this->initHeadingForm((int) $_REQUEST["q_id"]); if ($form->checkInput()) { include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php"; $this->object->saveHeading(ilUtil::stripSlashes($form->getInput("heading"), true, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("survey")), $form->getInput("insertbefore")); $this->ctrl->redirect($this, "questions"); } $form->setValuesByPost(); $this->addHeadingObject($form); }
function savePageContentObject() { include_once "Services/XHTMLPage/classes/class.ilXHTMLPage.php"; include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php"; $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(), "xhtml_page"); /*include_once("./Services/Form/classes/class.ilFormPropertyGUI.php"); include_once("./Services/Form/classes/class.ilTextAreaInputGUI.php"); $ta = new ilTextAreaInputGUI(); $ta->setRteTagSet("extended_table_img"); $tags = $ta->getRteTagString();*/ //$text = ilUtil::stripSlashes($_POST["page_content"], // true, // $tags); $text = ilUtil::stripSlashes($_POST["page_content"], true, ilObjAdvancedEditing::_getUsedHTMLTagsAsString()); if ($xpage_id > 0) { $xpage = new ilXHTMLPage($xpage_id); $xpage->setContent($text); $xpage->save(); } else { $xpage = new ilXHTMLPage(); $xpage->setContent($text); $xpage->save(); ilContainer::_writeContainerSetting($this->object->getId(), "xhtml_page", $xpage->getId()); } include_once "Services/RTE/classes/class.ilRTE.php"; ilRTE::_cleanupMediaObjectUsage($text, $this->object->getType() . ":html", $this->object->getId()); ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true); $this->ctrl->redirect($this, ""); }
private function saveManScoringParticipantScreen($redirect = true) { global $tpl, $ilCtrl, $lng; $activeId = $this->fetchActiveIdParameter(); $pass = $this->fetchPassParameter($activeId); $questionGuiList = $this->service->getManScoringQuestionGuiList($activeId, $pass); $form = $this->buildManScoringParticipantForm($questionGuiList, $activeId, $pass, false); $form->setValuesByPost(); if (!$form->checkInput()) { ilUtil::sendFailure(sprintf($lng->txt('tst_save_manscoring_failed'), $pass + 1)); return $this->showManScoringParticipantScreen($form); } include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; $maxPointsByQuestionId = array(); $maxPointsExceeded = false; foreach ($questionGuiList as $questionId => $questionGui) { $reachedPoints = $form->getItemByPostVar("question__{$questionId}__points")->getValue(); $maxPoints = assQuestion::_getMaximumPoints($questionId); if ($reachedPoints > $maxPoints) { $maxPointsExceeded = true; $form->getItemByPostVar("question__{$questionId}__points")->setAlert(sprintf($lng->txt('tst_manscoring_maxpoints_exceeded_input_alert'), $maxPoints)); } $maxPointsByQuestionId[$questionId] = $maxPoints; } if ($maxPointsExceeded) { ilUtil::sendFailure(sprintf($lng->txt('tst_save_manscoring_failed'), $pass + 1)); return $this->showManScoringParticipantScreen($form); } include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php"; foreach ($questionGuiList as $questionId => $questionGui) { $reachedPoints = $form->getItemByPostVar("question__{$questionId}__points")->getValue(); assQuestion::_setReachedPoints($activeId, $questionId, $reachedPoints, $maxPointsByQuestionId[$questionId], $pass, 1, $this->object->areObligationsEnabled()); $feedback = ilUtil::stripSlashes($form->getItemByPostVar("question__{$questionId}__feedback")->getValue(), false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment")); $this->object->saveManualFeedback($activeId, $questionId, $pass, $feedback); $notificationData[$questionId] = array('points' => $reachedPoints, 'feedback' => $feedback); } include_once "./Modules/Test/classes/class.ilObjTestAccess.php"; include_once "./Services/Tracking/classes/class.ilLPStatusWrapper.php"; ilLPStatusWrapper::_updateStatus($this->object->getId(), ilObjTestAccess::_getParticipantId($activeId)); $manScoringDone = $form->getItemByPostVar("manscoring_done")->getChecked(); ilTestService::setManScoringDone($activeId, $manScoringDone); $manScoringNotify = $form->getItemByPostVar("manscoring_notify")->getChecked(); if ($manScoringNotify) { require_once 'Modules/Test/classes/notifications/class.ilTestManScoringParticipantNotification.php'; $notification = new ilTestManScoringParticipantNotification($this->object->_getUserIdFromActiveId($activeId), $this->object->getRefId()); $notification->setAdditionalInformation(array('test_title' => $this->object->getTitle(), 'test_pass' => $pass + 1, 'questions_gui_list' => $questionGuiList, 'questions_scoring_data' => $notificationData)); $notification->send(); } require_once './Modules/Test/classes/class.ilTestScoring.php'; $scorer = new ilTestScoring($this->object); $scorer->setPreserveManualScores(true); $scorer->recalculateSolutions(); if ($this->object->getAnonymity() == 0) { $user_name = ilObjUser::_lookupName(ilObjTestAccess::_getParticipantId($activeId)); $name_real_or_anon = $user_name['firstname'] . ' ' . $user_name['lastname']; } else { $name_real_or_anon = $lng->txt('anonymous'); } ilUtil::sendSuccess(sprintf($lng->txt('tst_saved_manscoring_successfully'), $pass + 1, $name_real_or_anon), true); if ($redirect == true) { $ilCtrl->redirect($this, 'showManScoringParticipantScreen'); } else { return; } }
/** * Evaluates a posted edit form and writes the form data in the question object * * Evaluates a posted edit form and writes the form data in the question object * * @return integer A positive value, if one of the required fields wasn't set, else 0 * @access private */ function writePostData() { $result = 0; if (!$this->checkInput()) { $result = 1; } if ($result and strcmp($this->ctrl->getCmd(), "add") == 0) { // You cannot add answers before you enter the required data ilUtil::sendInfo($this->lng->txt("fill_out_all_required_fields_add_answer")); } $this->object->setTitle(ilUtil::stripSlashes($_POST["title"])); $this->object->setAuthor(ilUtil::stripSlashes($_POST["author"])); $this->object->setComment(ilUtil::stripSlashes($_POST["comment"])); include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php"; $questiontext = ilUtil::stripSlashes($_POST["question"], false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment")); $this->object->setQuestion($questiontext); $this->object->setCorrectAnswers($_POST["correctanswers"]); $this->object->setTextRating($_POST["text_rating"]); $this->object->setEstimatedWorkingTime($_POST["Estimated"]["h"], $_POST["Estimated"]["m"], $_POST["Estimated"]["s"]); //$saved = $this->writeOtherPostData($result); // Delete all existing answers and create new answers from the form data $this->object->flushAnswers(); // Add all answers from the form into the object foreach ($_POST as $key => $value) { if (preg_match("/answer_(\\d+)/", $key, $matches)) { $this->object->addAnswer(ilUtil::stripSlashes($_POST["{$key}"]), ilUtil::stripSlashes($_POST["points_" . $matches[1]]), ilUtil::stripSlashes($matches[1])); } } // Set the question id from a hidden form parameter if ($_POST["syntaxtree_id"] > 0) { $this->object->setId($_POST["syntaxtree_id"]); } $maximum_points = $this->object->getMaximumPoints(); if ($maximum_points <= 0 && count($this->object->answers) > 0) { $result = 1; $this->setErrorMessage($this->lng->txt("enter_enough_positive_points")); } $this->object->setPoints($maximum_points); if ($saved) { // If the question was saved automatically before an upload, we have to make // sure, that the state after the upload is saved. Otherwise the user could be // irritated, if he presses cancel, because he only has the question state before // the upload process. $this->object->saveToDb(); $this->ctrl->setParameter($this, "q_id", $this->object->getId()); } return $result; }
/** * @param ilPropertyFormGUI $form */ private function saveTestFinishProperties(ilPropertyFormGUI $form) { if ($this->formPropertyExists($form, 'enable_examview')) { $this->testOBJ->setEnableExamview($form->getItemByPostVar('enable_examview')->getChecked()); $this->testOBJ->setShowExamviewHtml($form->getItemByPostVar('show_examview_html')->getChecked()); $this->testOBJ->setShowExamviewPdf($form->getItemByPostVar('show_examview_pdf')->getChecked()); } $this->testOBJ->setShowFinalStatement($form->getItemByPostVar('showfinalstatement')->getChecked()); $this->testOBJ->setFinalStatement($form->getItemByPostVar('finalstatement')->getValue(), false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment")); if ($form->getItemByPostVar('redirection_enabled')->getChecked()) { $this->testOBJ->setRedirectionMode($form->getItemByPostVar('redirection_mode')->getValue()); } else { $this->testOBJ->setRedirectionMode(REDIRECT_NONE); } if (strlen($form->getItemByPostVar('redirection_url')->getValue())) { $this->testOBJ->setRedirectionUrl($form->getItemByPostVar('redirection_url')->getValue()); } else { $this->testOBJ->setRedirectionUrl(null); } if ($this->formPropertyExists($form, 'sign_submission')) { $this->testOBJ->setSignSubmission($form->getItemByPostVar('sign_submission')->getChecked()); } if ($this->formPropertyExists($form, 'mailnotification') && $form->getItemByPostVar('mailnotification')->getChecked()) { $this->testOBJ->setMailNotification($form->getItemByPostVar('mailnotification_content')->getValue()); $this->testOBJ->setMailNotificationType($form->getItemByPostVar('mailnottype')->getChecked()); } else { $this->testOBJ->setMailNotification(0); $this->testOBJ->setMailNotificationType(false); } }
/** * Save the form input of the properties form * * @access public */ function savePropertiesObject() { if (!array_key_exists("tst_properties_confirmation", $_POST)) { $hasErrors = $this->propertiesObject(true); } else { $hasErrors = false; } if (!$hasErrors) { $template_settings = null; $template = $this->object->getTemplate(); if ($template) { include_once "Services/Administration/classes/class.ilSettingsTemplate.php"; $template = new ilSettingsTemplate($template, ilObjAssessmentFolderGUI::getSettingsTemplateConfig()); $template_settings = $template->getSettings(); } include_once 'Services/MetaData/classes/class.ilMD.php'; $md_obj =& new ilMD($this->object->getId(), 0, "tst"); $md_section = $md_obj->getGeneral(); // title $md_section->setTitle(ilUtil::stripSlashes($_POST['title'])); $md_section->update(); // Description $md_desc_ids = $md_section->getDescriptionIds(); if ($md_desc_ids) { $md_desc = $md_section->getDescription(array_pop($md_desc_ids)); $md_desc->setDescription(ilUtil::stripSlashes($_POST['description'])); $md_desc->update(); } else { $md_desc = $md_section->addDescription(); $md_desc->setDescription(ilUtil::stripSlashes($_POST['description'])); $md_desc->save(); } $this->object->setTitle(ilUtil::stripSlashes($_POST['title'])); $this->object->setDescription(ilUtil::stripSlashes($_POST['description'])); $this->object->update(); $total = $this->object->evalTotalPersons(); $randomtest_switch = false; // Check the values the user entered in the form if (!$total) { if (!strlen($_POST["random_test"])) { $random_test = 0; } else { $random_test = $_POST["random_test"]; } if (!array_key_exists("tst_properties_confirmation", $_POST)) { if (!$random_test && $this->object->areRandomTestQuestionpoolsConfigured()) { // user tries to change from a random test with existing random question pools to a non random test $this->confirmChangeProperties(self::SWITCH_RANDOM_TEST_SETTING_TO_DISABLED); return; } elseif ($random_test && $this->object->doesNonRandomTestQuestionsExist()) { // user tries to change from a non random test with existing questions to a random test $this->confirmChangeProperties(self::SWITCH_RANDOM_TEST_SETTING_TO_ENABLED); return; } } } else { $random_test = $this->object->isRandomTest(); } // buffer online status sent by form in local variable and store // it to model after the following if block, because the new status // gets reset when random test setting is switched $online = $_POST["online"]; $randomtest_switch = $this->isRandomTestSettingSwitched($random_test); if (!$total) { if ($randomtest_switch && $this->object->isOnline() && $online) { // reset online status that is stored to model later on // due to fact that the random test setting has been changed $online = false; $info = $this->lng->txt("tst_set_offline_due_to_switched_random_test_setting"); ilUtil::sendInfo($info, true); } $this->object->setAnonymity($_POST["anonymity"]); $this->object->setRandomTest($random_test); $this->object->setNrOfTries($_POST["nr_of_tries"]); } // store effective online status to model $this->object->setOnline($online); // activation if ($_POST["activation_type"] == ilObjectActivation::TIMINGS_ACTIVATION) { $this->object->setActivationLimited(true); $this->object->setActivationVisibility($_POST["activation_visibility"]); $date = new ilDateTime($_POST['act_starting_time']['date'] . ' ' . $_POST['act_starting_time']['time'], IL_CAL_DATETIME); $this->object->setActivationStartingTime($date->get(IL_CAL_UNIX)); $date = new ilDateTime($_POST['act_ending_time']['date'] . ' ' . $_POST['act_ending_time']['time'], IL_CAL_DATETIME); $this->object->setActivationEndingTime($date->get(IL_CAL_UNIX)); } else { $this->object->setActivationLimited(false); } include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php"; $this->object->setIntroduction($_POST["introduction"], false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment")); $this->object->setShowInfo($_POST["showinfo"] ? 1 : 0); $this->object->setFinalStatement($_POST["finalstatement"], false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment")); $this->object->setShowFinalStatement($_POST["showfinalstatement"] ? 1 : 0); $this->object->setSequenceSettings($_POST["chb_postpone"] ? 1 : 0); $this->object->setShuffleQuestions($_POST["chb_shuffle_questions"] ? 1 : 0); $this->object->setListOfQuestions($_POST["list_of_questions"]); if (is_array($_POST["list_of_questions_options"])) { $this->object->setListOfQuestionsStart(in_array('chb_list_of_questions_start', $_POST["list_of_questions_options"]) ? 1 : 0); $this->object->setListOfQuestionsEnd(in_array('chb_list_of_questions_end', $_POST["list_of_questions_options"]) ? 1 : 0); $this->object->setListOfQuestionsDescription(in_array('chb_list_of_questions_with_description', $_POST["list_of_questions_options"]) ? 1 : 0); } else { $this->object->setListOfQuestionsStart(0); $this->object->setListOfQuestionsEnd(0); $this->object->setListOfQuestionsDescription(0); } $this->object->setMailNotification($_POST["mailnotification"]); $this->object->setMailNotificationType($_POST["mailnottype"]); $this->object->setShowMarker($_POST["chb_show_marker"] ? 1 : 0); $this->object->setShowCancel($_POST["chb_show_cancel"] ? 1 : 0); $this->object->setKioskMode($_POST["kiosk"] ? 1 : 0); $this->object->setShowKioskModeTitle(is_array($_POST["kiosk_options"]) && in_array('kiosk_title', $_POST["kiosk_options"]) ? 1 : 0); $this->object->setShowKioskModeParticipant(is_array($_POST["kiosk_options"]) && in_array('kiosk_participant', $_POST["kiosk_options"]) ? 1 : 0); $this->object->setEnableProcessingTime($_POST["chb_processing_time"] ? 1 : 0); if ($this->object->getEnableProcessingTime()) { $this->object->setProcessingTime(sprintf("%02d:%02d:%02d", $_POST["processing_time"]["hh"], $_POST["processing_time"]["mm"], $_POST["processing_time"]["ss"])); } else { $this->object->setProcessingTime(''); } $this->object->setResetProcessingTime($_POST["chb_reset_processing_time"] ? 1 : 0); if ($_POST['chb_starting_time']) { $this->object->setStartingTime(ilFormat::dateDB2timestamp($_POST['starting_time']['date'] . ' ' . $_POST['starting_time']['time'])); } else { $this->object->setStartingTime(''); } if ($_POST['chb_ending_time']) { $this->object->setEndingTime(ilFormat::dateDB2timestamp($_POST['ending_time']['date'] . ' ' . $_POST['ending_time']['time'])); } else { $this->object->setEndingTime(''); } $this->object->setUsePreviousAnswers($_POST["chb_use_previous_answers"] ? 1 : 0); $this->object->setForceJS($_POST["forcejs"] ? 1 : 0); $this->object->setTitleOutput($_POST["title_output"]); $this->object->setPassword($_POST["password"]); $this->object->setAllowedUsers($_POST["allowedUsers"]); $this->object->setAllowedUsersTimeGap($_POST["allowedUsersTimeGap"]); $this->object->setAutosave($_POST['autosave']); $this->object->setAutosaveIval($_POST['autosave_ival']); if ($this->object->isRandomTest()) { $this->object->setUsePreviousAnswers(0); } $invited_users = $this->object->getInvitedUsers(); if (!($total && count($invited_users) == 0)) { $fixed_participants = 0; if (array_key_exists("fixedparticipants", $_POST)) { if ($_POST["fixedparticipants"]) { $fixed_participants = 1; } } $this->object->setFixedParticipants($fixed_participants); if (!$fixed_participants) { $invited_users = $this->object->getInvitedUsers(); foreach ($invited_users as $user_object) { $this->object->disinviteUser($user_object["usr_id"]); } } } $this->object->setHighscoreEnabled((bool) $_POST['highscore_enabled']); $this->object->setHighscoreAnon((bool) $_POST['highscore_anon']); $this->object->setHighscoreAchievedTS((bool) $_POST['highscore_achieved_ts']); $this->object->setHighscoreScore((bool) $_POST['highscore_score']); $this->object->setHighscorePercentage((bool) $_POST['highscore_percentage']); $this->object->setHighscoreHints((bool) $_POST['highscore_hints']); $this->object->setHighscoreWTime((bool) $_POST['highscore_wtime']); $this->object->setHighscoreOwnTable((bool) $_POST['highscore_own_table']); $this->object->setHighscoreTopTable((bool) $_POST['highscore_top_table']); $this->object->setHighscoreTopNum((int) $_POST['highscore_top_num']); //$this->object->setExpressModeQuestionPoolAllowed($_POST['express_allow_question_pool']); $this->object->setEnabledViewMode($_POST['enabled_view_mode']); $this->object->setPoolUsage($_POST['use_pool']); $this->object->saveToDb(true); // Update ecs export settings include_once 'Modules/Test/classes/class.ilECSTestSettings.php'; $ecs = new ilECSTestSettings($this->object); $ecs->handleSettingsUpdate(); ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true); if ($randomtest_switch) { if ($this->object->isRandomTest()) { $this->object->removeNonRandomTestData(); } else { $this->object->removeRandomTestData(); } } $this->ctrl->redirect($this, 'properties'); } }
/** * Saves an edited heading in the survey questions list * * Saves an edited heading in the survey questions list * * @access public */ function saveHeadingObject() { $hasErrors = $this->addHeadingObject(true); if (!$hasErrors) { $insertbefore = $_POST["insertbefore"]; if (!$insertbefore) { $insertbefore = $_POST["insertbefore_original"]; } include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php"; $this->object->saveHeading(ilUtil::stripSlashes($_POST["heading"], TRUE, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("survey")), $insertbefore); $this->ctrl->redirect($this, "questions"); } }