示例#1
0
 /**
  * Import record
  *
  * @param
  * @return
  */
 function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
 {
     switch ($a_entity) {
         case "poll":
             include_once "./Modules/Poll/classes/class.ilObjPoll.php";
             // container copy
             if ($new_id = $a_mapping->getMapping("Services/Container", "objs", $a_rec["Id"])) {
                 $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
             } else {
                 $newObj = new ilObjPoll();
                 $newObj->create();
             }
             $newObj->setTitle($a_rec["Title"]);
             $newObj->setDescription($a_rec["Description"]);
             if ((int) $a_rec["MaxAnswers"]) {
                 $newObj->setMaxNumberOfAnswers($a_rec["MaxAnswers"]);
             }
             $newObj->setSortResultByVotes((bool) $a_rec["ResultSort"]);
             $newObj->setNonAnonymous((bool) $a_rec["NonAnon"]);
             if ((int) $a_rec["ShowResultsAs"]) {
                 $newObj->setShowResultsAs($a_rec["ShowResultsAs"]);
             }
             $newObj->setShowComments($a_rec["ShowComments"]);
             $newObj->setQuestion($a_rec["Question"]);
             $newObj->setImage($a_rec["Image"]);
             $newObj->setViewResults($a_rec["ViewResults"]);
             $newObj->update();
             // handle image(s)
             if ($a_rec["Image"]) {
                 $dir = str_replace("..", "", $a_rec["Dir"]);
                 if ($dir != "" && $this->getImportDirectory() != "") {
                     $source_dir = $this->getImportDirectory() . "/" . $dir;
                     $target_dir = ilObjPoll::initStorage($newObj->getId());
                     ilUtil::rCopy($source_dir, $target_dir);
                 }
             }
             $a_mapping->addMapping("Modules/Poll", "poll", $a_rec["Id"], $newObj->getId());
             break;
         case "poll_answer":
             $poll_id = (int) $a_mapping->getMapping("Modules/Poll", "poll", $a_rec["PollId"]);
             if ($poll_id) {
                 $poll = new ilObjPoll($poll_id, false);
                 $poll->saveAnswer($a_rec["Answer"], $a_rec["pos"]);
             }
             break;
     }
 }
 /**
  * Import record
  *
  * @param
  * @return
  */
 function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
 {
     switch ($a_entity) {
         case "poll":
             include_once "./Modules/Poll/classes/class.ilObjPoll.php";
             $newObj = new ilObjPoll();
             $newObj->setTitle($a_rec["Title"]);
             $newObj->setDescription($a_rec["Description"]);
             $newObj->create();
             $newObj->setQuestion($a_rec["Question"]);
             $newObj->setImage($a_rec["Image"]);
             $newObj->setViewResults($a_rec["ViewResults"]);
             $newObj->update();
             // handle image(s)
             if ($a_rec["Image"]) {
                 $dir = str_replace("..", "", $a_rec["Dir"]);
                 if ($dir != "" && $this->getImportDirectory() != "") {
                     $source_dir = $this->getImportDirectory() . "/" . $dir;
                     $target_dir = ilObjPoll::initStorage($newObj->getId());
                     ilUtil::rCopy($source_dir, $target_dir);
                 }
             }
             $a_mapping->addMapping("Modules/Poll", "poll", $a_rec["Id"], $newObj->getId());
             break;
         case "poll_answer":
             $poll_id = (int) $a_mapping->getMapping("Modules/Poll", "poll", $a_rec["PollId"]);
             if ($poll_id) {
                 $poll = new ilObjPoll($poll_id, false);
                 $poll->saveAnswer($a_rec["Answer"], $a_rec["pos"]);
             }
             break;
     }
 }