/** * 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()); } }
/** * Clone assignments of exercise * * @param * @return */ function cloneAssignmentsOfExercise($a_old_exc_id, $a_new_exc_id) { $ass_data = ilExAssignment::getAssignmentDataOfExercise($a_old_exc_id); foreach ($ass_data as $d) { // clone assignment $new_ass = new ilExAssignment(); $new_ass->setExerciseId($a_new_exc_id); $new_ass->setTitle($d["title"]); $new_ass->setDeadline($d["deadline"]); $new_ass->setInstruction($d["instruction"]); $new_ass->setMandatory($d["mandatory"]); $new_ass->setOrderNr($d["order_val"]); $new_ass->setStartTime($d["start_time"]); $new_ass->setType($d["type"]); $new_ass->setPeerReview($d["peer"]); $new_ass->setPeerReviewMin($d["peer_min"]); $new_ass->setPeerReviewDeadline($d["peer_dl"]); $new_ass->setFeedbackFile($d["fb_file"]); $new_ass->setFeedbackCron($d["fb_cron"]); $new_ass->save(); // clone assignment files include_once "./Modules/Exercise/classes/class.ilFSStorageExercise.php"; $old_storage = new ilFSStorageExercise($a_old_exc_id, (int) $d["id"]); $new_storage = new ilFSStorageExercise($a_new_exc_id, (int) $new_ass->getId()); $new_storage->create(); if (is_dir($old_storage->getPath())) { ilUtil::rCopy($old_storage->getPath(), $new_storage->getPath()); } } }
/** * Import record * * @param * @return */ function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version) { //echo $a_entity; //var_dump($a_rec); switch ($a_entity) { case "exc": include_once "./Modules/Exercise/classes/class.ilObjExercise.php"; if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_rec['Id'])) { $newObj = ilObjectFactory::getInstanceByObjId($new_id, false); } else { $newObj = new ilObjExercise(); $newObj->setType("exc"); $newObj->create(true); } $newObj->setTitle($a_rec["Title"]); $newObj->setDescription($a_rec["Description"]); $newObj->setPassMode($a_rec["PassMode"]); $newObj->setPassNr($a_rec["PassNr"]); $newObj->setShowSubmissions($a_rec["ShowSubmissions"]); $newObj->update(); $newObj->saveData(); //var_dump($a_rec); $this->current_exc = $newObj; $a_mapping->addMapping("Modules/Exercise", "exc", $a_rec["Id"], $newObj->getId()); //var_dump($a_mapping->mappings["Services/News"]["news_context"]); break; case "exc_assignment": $exc_id = $a_mapping->getMapping("Modules/Exercise", "exc", $a_rec["ExerciseId"]); if ($exc_id > 0) { if (is_object($this->current_exc) && $this->current_exc->getId() == $exc_id) { $exc = $this->current_exc; } else { include_once "./Modules/Exercise/classes/class.ilObjExercise.php"; $exc = new ilObjExercise($exc_id, false); } include_once "./Modules/Exercise/classes/class.ilExAssignment.php"; $ass = new ilExAssignment(); $ass->setExerciseId($exc_id); if ($a_rec["StartTime"] != "") { $start = new ilDateTime($a_rec["StartTime"], IL_CAL_DATETIME, "UTC"); $ass->setStartTime($start->get(IL_CAL_UNIX)); } if ($a_rec["Deadline"] != "") { $deadline = new ilDateTime($a_rec["Deadline"], IL_CAL_DATETIME, "UTC"); $ass->setDeadline($deadline->get(IL_CAL_UNIX)); } //var_dump($a_rec); $ass->setInstruction($a_rec["Instruction"]); $ass->setTitle($a_rec["Title"]); $ass->setMandatory($a_rec["Mandatory"]); $ass->setOrderNr($a_rec["OrderNr"]); // 4.2 $ass->setType($a_rec["Type"]); // 4.4 $ass->setPeerReview($a_rec["Peer"]); $ass->setPeerReviewMin($a_rec["PeerMin"]); $ass->setPeerReviewDeadline($a_rec["PeerDeadline"]); $ass->setFeedbackFile($a_rec["FeedbackFile"]); $ass->setFeedbackCron($a_rec["FeedbackCron"]); $ass->setFeedbackDate($a_rec["FeedbackDate"]); // 5.0 $ass->setPeerReviewFileUpload($a_rec["PeerFile"]); $ass->setPeerReviewPersonalized($a_rec["PeerPersonal"]); $ass->save(); include_once "./Modules/Exercise/classes/class.ilFSStorageExercise.php"; $fstorage = new ilFSStorageExercise($exc_id, $ass->getId()); $fstorage->create(); // assignment files $dir = str_replace("..", "", $a_rec["Dir"]); if ($dir != "" && $this->getImportDirectory() != "") { $source_dir = $this->getImportDirectory() . "/" . $dir; $target_dir = $fstorage->getPath(); ilUtil::rCopy($source_dir, $target_dir); } // (4.4) global feedback file $dir = str_replace("..", "", $a_rec["FeedbackDir"]); if ($dir != "" && $this->getImportDirectory() != "") { $source_dir = $this->getImportDirectory() . "/" . $dir; $target_dir = $fstorage->getGlobalFeedbackPath(); ilUtil::rCopy($source_dir, $target_dir); } $a_mapping->addMapping("Modules/Exercise", "exc_assignment", $a_rec["Id"], $ass->getId()); } break; } }