Exemplo n.º 1
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;
     }
 }