Ejemplo n.º 1
0
 /**
  * update marking of member
  *
  * @param int $usr_id
  */
 private function updateMarking($usr_id)
 {
     if (isset($this->mark)) {
         ilExAssignment::updateMarkOfUser($this->assignment->getId(), $usr_id, ilUtil::stripSlashes($this->mark));
     }
     if (isset($this->comment)) {
         ilExAssignment::updateCommentForUser($this->assignment->getId(), $usr_id, ilUtil::stripSlashes($this->comment));
     }
     //$memberObject = $this->exercise->members_obj;
     if (isset($this->status)) {
         ilExAssignment::updateStatusOfUser($this->assignment->getId(), $usr_id, ilUtil::stripSlashes($this->status));
     }
     if (isset($this->notice)) {
         ilExAssignment::updateNoticeForUser($this->assignment->getId(), $usr_id, ilUtil::stripSlashes($this->notice));
     }
     // reset variables
     $this->mark = null;
     $this->status = null;
     $this->notice = null;
     $this->comment = null;
 }
Ejemplo n.º 2
0
 /**
  * Get current values for assignment from 
  *
  */
 public function getAssignmentValues()
 {
     $values = array();
     $ass = new ilExAssignment($_GET["ass_id"]);
     $values["title"] = $ass->getTitle();
     if ($ass->getStartTime() > 0) {
         $values["start_time_cb"] = true;
     }
     $values["mandatory"] = $ass->getMandatory();
     $values["instruction"] = $ass->getInstruction();
     $values["type"] = $ass->getType();
     if ($ass->getDeadline() > 0) {
         $values["deadline_cb"] = true;
     }
     if ($this->ass->getType() == ilExAssignment::TYPE_UPLOAD_TEAM) {
         $this->form->removeItemByPostVar("peer");
         $this->form->removeItemByPostVar("peer_min");
         $this->form->removeItemByPostVar("peer_dl");
     } else {
         $values["peer"] = $ass->getPeerReview();
         $values["peer_min"] = $ass->getPeerReviewMin();
         $values["peer_file"] = $ass->hasPeerReviewFileUpload();
         $values["peer_prsl"] = $ass->hasPeerReviewPersonalized();
         if ($ass->getPeerReviewDeadline() > 0) {
             $values["peer_dl_tgl"] = true;
             $peer_dl_date = new ilDateTime($ass->getPeerReviewDeadline(), IL_CAL_UNIX);
             $peer_dl = $this->form->getItemByPostVar("peer_dl");
             $peer_dl->setDate($peer_dl_date);
         }
         // #14450
         if ($values["peer"] && $ass->hasPeerReviewGroups()) {
             $this->form->getItemByPostVar("deadline_cb")->setDisabled(true);
             $this->form->getItemByPostVar("deadline")->setDisabled(true);
             $this->form->getItemByPostVar("peer")->setDisabled(true);
             $this->form->getItemByPostVar("peer_min")->setDisabled(true);
             $this->form->getItemByPostVar("peer_dl")->setDisabled(true);
             $this->form->getItemByPostVar("peer_file")->setDisabled(true);
             $this->form->getItemByPostVar("peer_prsl")->setDisabled(true);
         }
     }
     $this->form->setValuesByArray($values);
     if ($ass->getDeadline() > 0) {
         $edit_date = new ilDateTime($ass->getDeadline(), IL_CAL_UNIX);
         $ed_item = $this->form->getItemByPostVar("deadline");
         $ed_item->setDate($edit_date);
     }
     if ($ass->getStartTime() > 0) {
         $edit_date = new ilDateTime($ass->getStartTime(), IL_CAL_UNIX);
         $ed_item = $this->form->getItemByPostVar("start_time");
         $ed_item->setDate($edit_date);
     }
     if ($ass->getFeedbackFile()) {
         $this->form->getItemByPostVar("fb")->setChecked(true);
         $this->form->getItemByPostVar("fb_file")->setValue(basename($ass->getFeedbackFilePath()));
     }
     $this->form->getItemByPostVar("fb_cron")->setChecked($ass->hasFeedbackCron());
     $this->form->getItemByPostVar("fb_date")->setValue($ass->getFeedbackDate());
     // if there are any submissions we cannot change type anymore
     if (sizeof(ilExAssignment::getAllDeliveredFiles($this->object->getId(), $ass->getId())) || $this->ass->getType() == ilExAssignment::TYPE_UPLOAD_TEAM) {
         $this->form->getItemByPostVar("type")->setDisabled(true);
     }
 }
Ejemplo n.º 3
0
 function downloadExcSubFile()
 {
     global $ilUser;
     if ($_GET["ass"]) {
         include_once "Modules/Exercise/classes/class.ilExAssignment.php";
         $ass = new ilExAssignment((int) $_GET["ass"]);
         $submitted = ilExAssignment::getDeliveredFiles($ass->getExerciseId(), $ass->getId(), $ilUser->getId());
         if (count($submitted) > 0) {
             $submitted = array_pop($submitted);
             $user_data = ilObjUser::_lookupName($submitted["user_id"]);
             $title = ilObject::_lookupTitle($submitted["obj_id"]) . " - " . $ass->getTitle() . " - " . $user_data["firstname"] . " " . $user_data["lastname"] . " (" . $user_data["login"] . ").zip";
             ilUtil::deliverFile($submitted["filename"], $title);
         }
     }
 }
 protected function handleDisabledAssignmentFields(ilExAssignment $a_ass, ilPropertyFormGUI $a_form)
 {
     // potentially disabled elements are initialized here to re-use this
     // method after setValuesByPost() - see updateAssignmentObject()
     // if there are any submissions we cannot change type anymore
     if (sizeof(ilExAssignment::getAllDeliveredFiles($this->object->getId(), $a_ass->getId())) || $a_ass->getType() == ilExAssignment::TYPE_UPLOAD_TEAM) {
         $a_form->getItemByPostVar("type")->setDisabled(true);
     }
     if ($a_ass->getDeadline() > 0) {
         $a_form->getItemByPostVar("deadline_cb")->setChecked(true);
         $edit_date = new ilDateTime($a_ass->getDeadline(), IL_CAL_UNIX);
         $ed_item = $a_form->getItemByPostVar("deadline");
         $ed_item->setDate($edit_date);
     }
     // team assignments do not support peer review
     if ($a_ass->getType() == ilExAssignment::TYPE_UPLOAD_TEAM) {
         return;
     }
     $a_form->getItemByPostVar("peer")->setChecked($a_ass->getPeerReview());
     $a_form->getItemByPostVar("peer_min")->setValue($a_ass->getPeerReviewMin());
     $a_form->getItemByPostVar("peer_file")->setChecked($a_ass->hasPeerReviewFileUpload());
     $a_form->getItemByPostVar("peer_prsl")->setChecked($a_ass->hasPeerReviewPersonalized());
     // with no active peer review there is nothing to protect
     if (!$a_ass->getPeerReview()) {
         return;
     }
     // #14450
     if ($a_ass->hasPeerReviewGroups()) {
         // deadline(s) are past and must not change
         $a_form->getItemByPostVar("deadline_cb")->setDisabled(true);
         $a_form->getItemByPostVar("deadline")->setDisabled(true);
         // JourFixe, 2015-05-11 - editable again
         // $a_form->getItemByPostVar("peer_dl")->setDisabled(true);
         $a_form->getItemByPostVar("peer")->setDisabled(true);
         $a_form->getItemByPostVar("peer_min")->setDisabled(true);
         $a_form->getItemByPostVar("peer_file")->setDisabled(true);
         $a_form->getItemByPostVar("peer_prsl")->setDisabled(true);
     }
 }
Ejemplo n.º 5
0
 /**
  * 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());
         }
     }
 }
 /**
  * Get current values for assignment from 
  *
  */
 public function getAssignmentValues()
 {
     $values = array();
     $ass = new ilExAssignment($_GET["ass_id"]);
     $values["title"] = $ass->getTitle();
     if ($ass->getStartTime() > 0) {
         $values["start_time_cb"] = true;
     }
     $values["mandatory"] = $ass->getMandatory();
     $values["instruction"] = $ass->getInstruction();
     $values["type"] = $ass->getType();
     if ($ass->getDeadline() > 0) {
         $values["deadline_cb"] = true;
     }
     $this->form->setValuesByArray($values);
     if ($ass->getDeadline() > 0) {
         $edit_date = new ilDateTime($ass->getDeadline(), IL_CAL_UNIX);
         $ed_item = $this->form->getItemByPostVar("deadline");
         $ed_item->setDate($edit_date);
     }
     if ($ass->getStartTime() > 0) {
         $edit_date = new ilDateTime($ass->getStartTime(), IL_CAL_UNIX);
         $ed_item = $this->form->getItemByPostVar("start_time");
         $ed_item->setDate($edit_date);
     }
     // if there are any submissions we cannot change type anymore
     if (sizeof(ilExAssignment::getAllDeliveredFiles($this->object->getId(), $ass->getId()))) {
         $this->form->getItemByPostVar("type")->setDisabled(true);
     }
 }
Ejemplo n.º 7
0
 /**
  * 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;
     }
 }