/** * Update assignment * */ public function updateAssignmentObject() { global $tpl, $lng, $ilCtrl, $ilTabs; $this->checkPermission("write"); $ilTabs->activateTab("content"); $this->addContentSubTabs("list_assignments"); $this->initAssignmentForm("edit"); if ($this->form->checkInput()) { include_once "./Modules/Exercise/classes/class.ilExAssignment.php"; $ass = new ilExAssignment($_GET["ass_id"]); // #14450 $protected_peer_review_groups = false; if ($ass->getPeerReview() && $ass->hasPeerReviewGroups()) { $protected_peer_review_groups = true; } // additional checks $valid = true; if (!$protected_peer_review_groups) { if ($_POST["start_time_cb"] && $_POST["deadline_cb"]) { // check whether start date is before end date $start_date = $this->form->getItemByPostVar("start_time")->getDate(); $end_date = $this->form->getItemByPostVar("deadline")->getDate(); if ($start_date->get(IL_CAL_UNIX) >= $end_date->get(IL_CAL_UNIX)) { $this->form->getItemByPostVar("start_time")->setAlert($lng->txt("exc_start_date_should_be_before_end_date")); $this->form->getItemByPostVar("deadline")->setAlert($lng->txt("exc_start_date_should_be_before_end_date")); $valid = false; } } if (!$_POST["deadline_cb"]) { if ($_POST["peer"]) { $this->form->getItemByPostVar("peer")->setAlert($lng->txt("exc_needs_deadline")); $valid = false; } if ($_POST["fb"] && $_POST["fb_date"] == ilExAssignment::FEEDBACK_DATE_DEADLINE) { $this->form->getItemByPostVar("fb")->setAlert($lng->txt("exc_needs_deadline")); $valid = false; } } else { if ($_POST["type"] != ilExAssignment::TYPE_UPLOAD_TEAM && $_POST["peer"] && $_POST["peer_dl_tgl"]) { $peer_dl = $this->form->getItemByPostVar("peer_dl")->getDate(); $peer_dl = $peer_dl->get(IL_CAL_UNIX); $end_date = $this->form->getItemByPostVar("deadline")->getDate(); $end_date = $end_date->get(IL_CAL_UNIX); // #13877 if ($peer_dl < $end_date) { $this->form->getItemByPostVar("peer_dl")->setAlert($lng->txt("exc_peer_deadline_mismatch")); $valid = false; } } } } if (!$valid) { ilUtil::sendFailure($lng->txt("form_input_not_valid")); $this->form->setValuesByPost(); $tpl->setContent($this->form->getHtml()); return; } $ass->setTitle($_POST["title"]); $ass->setInstruction($_POST["instruction"]); $ass->setExerciseId($this->object->getId()); $ass->setMandatory($_POST["mandatory"]); $ass->setType($_POST["type"]); if ($_POST["start_time_cb"]) { $date = $this->form->getItemByPostVar("start_time")->getDate(); $ass->setStartTime($date->get(IL_CAL_UNIX)); } else { $ass->setStartTime(null); } if (!$protected_peer_review_groups) { // deadline if ($_POST["deadline_cb"]) { $date = $this->form->getItemByPostVar("deadline")->getDate(); $ass->setDeadline($date->get(IL_CAL_UNIX)); } else { $ass->setDeadline(null); } if ($_POST["type"] != ilExAssignment::TYPE_UPLOAD_TEAM) { $ass->setPeerReview($_POST["peer"]); $ass->setPeerReviewMin($_POST["peer_min"]); $ass->setPeerReviewFileUpload($_POST["peer_file"]); if ($ass->getDeadline() && $ass->getDeadline() > time()) { $ass->setPeerReviewPersonalized($_POST["peer_prsl"]); } if ($_POST["peer_dl_tgl"]) { $peer_dl = $this->form->getItemByPostVar("peer_dl")->getDate(); $ass->setPeerReviewDeadline($peer_dl->get(IL_CAL_UNIX)); } else { $ass->setPeerReviewDeadline(null); } } } if (!$_POST["fb"] || $this->form->getItemByPostVar("fb_file")->getDeletionFlag()) { $ass->deleteFeedbackFile(); $ass->setFeedbackFile(null); } else { if ($_FILES["fb_file"]["tmp_name"]) { $ass->handleFeedbackFileUpload($_FILES["fb_file"]); } } $ass->setFeedbackCron($_POST["fb"]); // #13380 $ass->setFeedbackDate($_POST["fb_date"]); $ass->update(); ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true); $ilCtrl->redirect($this, "editAssignment"); } else { $this->form->setValuesByPost(); $tpl->setContent($this->form->getHtml()); } }
/** * Update assignment * */ public function updateAssignmentObject() { global $tpl, $lng, $ilCtrl, $ilTabs; $this->checkPermission("write"); $ilTabs->activateTab("content"); $this->addContentSubTabs("list_assignments"); $this->initAssignmentForm("edit"); if ($this->form->checkInput()) { include_once "./Modules/Exercise/classes/class.ilExAssignment.php"; // additional checks if ($_POST["start_time_cb"] && $_POST["deadline_cb"]) { // check whether start date is before end date $start_date = $this->form->getItemByPostVar("start_time")->getDate(); $end_date = $this->form->getItemByPostVar("deadline")->getDate(); if ($start_date->get(IL_CAL_UNIX) >= $end_date->get(IL_CAL_UNIX)) { ilUtil::sendFailure($lng->txt("form_input_not_valid"), true); $this->form->getItemByPostVar("start_time")->setAlert($lng->txt("exc_start_date_should_be_before_end_date")); $this->form->getItemByPostVar("deadline")->setAlert($lng->txt("exc_start_date_should_be_before_end_date")); $this->form->setValuesByPost(); $tpl->setContent($this->form->getHtml()); return; } } $ass = new ilExAssignment($_GET["ass_id"]); $ass->setTitle($_POST["title"]); $ass->setInstruction($_POST["instruction"]); $ass->setExerciseId($this->object->getId()); $ass->setMandatory($_POST["mandatory"]); $ass->setType($_POST["type"]); if ($_POST["start_time_cb"]) { $date = $this->form->getItemByPostVar("start_time")->getDate(); $ass->setStartTime($date->get(IL_CAL_UNIX)); } else { $ass->setStartTime(null); } // deadline if ($_POST["deadline_cb"]) { $date = $this->form->getItemByPostVar("deadline")->getDate(); $ass->setDeadline($date->get(IL_CAL_UNIX)); } else { $ass->setDeadline(null); } $ass->update(); ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true); $ilCtrl->redirect($this, "listAssignments"); } else { $this->form->setValuesByPost(); $tpl->setContent($this->form->getHtml()); } }