/**
  * create new instance and save it
  */
 public function save()
 {
     global $ilUser;
     $course_id = $_REQUEST["crs_id"];
     if ($course_id) {
         include_once "Modules/Course/classes/class.ilObjCourse.php";
         $course = new ilObjCourse($course_id, false);
         include_once "Modules/Course/classes/Verification/class.ilObjCourseVerification.php";
         $newObj = ilObjCourseVerification::createFromCourse($course, $ilUser->getId());
         if ($newObj) {
             $parent_id = $this->node_id;
             $this->node_id = null;
             $this->putObjectInTree($newObj, $parent_id);
             $this->afterSave($newObj);
         } else {
             ilUtil::sendFailure($this->lng->txt("msg_failed"));
         }
     } else {
         ilUtil::sendFailure($this->lng->txt("select_one"));
     }
     $this->create();
 }
 /**
  * Get material file name and goto url
  * 
  * @param int $a_wsp_id
  * @return array caption, url 
  */
 function getMaterialInfo($a_wsp_id, $a_user_id)
 {
     if (!$this->ws_tree) {
         include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
         include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
         $this->ws_tree = new ilWorkspaceTree($a_user_id);
         $this->ws_access = new ilWorkspaceAccessHandler($caption);
     }
     $obj_id = $this->ws_tree->lookupObjectId($a_wsp_id);
     $caption = ilObject::_lookupTitle($obj_id);
     if (!$this->offline_mode) {
         $url = $this->ws_access->getGotoLink($a_wsp_id, $obj_id);
     } else {
         $url = $this->offline_mode . "file_" . $obj_id . "/";
         // all possible material types for now
         switch (ilObject::_lookupType($obj_id)) {
             case "tstv":
                 include_once "Modules/Test/classes/class.ilObjTestVerification.php";
                 $obj = new ilObjTestVerification($obj_id, false);
                 $url .= $obj->getOfflineFilename();
                 break;
             case "excv":
                 include_once "Modules/Exercise/classes/class.ilObjExerciseVerification.php";
                 $obj = new ilObjExerciseVerification($obj_id, false);
                 $url .= $obj->getOfflineFilename();
                 break;
             case "crsv":
                 include_once "Modules/Course/classes/Verification/class.ilObjCourseVerification.php";
                 $obj = new ilObjCourseVerification($obj_id, false);
                 $url .= $obj->getOfflineFilename();
                 break;
             case "scov":
                 include_once "Modules/ScormAicc/classes/Verification/class.ilObjSCORMVerification.php";
                 $obj = new ilObjSCORMVerification($obj_id, false);
                 $url .= $obj->getOfflineFilename();
                 break;
             case "file":
                 $file = new ilObjFile($obj_id, false);
                 $url .= $file->getFilename();
                 break;
         }
     }
     return array($caption, $url);
 }
 /**
  * Collect page elements (that need to be exported separately)
  *
  * @param string $a_pg_type page type
  * @param int $a_pg_id page id
  */
 function collectPageElements($a_type, $a_id)
 {
     // collect media objects
     $pg_mobs = ilObjMediaObject::_getMobsOfObject($a_type, $a_id);
     foreach ($pg_mobs as $pg_mob) {
         $this->mobs[$pg_mob] = $pg_mob;
     }
     // collect all files
     include_once "./Modules/File/classes/class.ilObjFile.php";
     $files = ilObjFile::_getFilesOfObject($a_type, $a_id);
     foreach ($files as $f) {
         $this->files[$f] = $f;
     }
     $skill_tree = $ws_tree = null;
     $pcs = ilPageContentUsage::getUsagesOfPage($a_id, $a_type);
     foreach ($pcs as $pc) {
         // skils
         if ($pc["type"] == "skmg") {
             $skill_id = $pc["id"];
             // trying to find user id
             $user_id = null;
             switch ($a_type) {
                 case "prtf:pg":
                     include_once "Modules/Portfolio/classes/class.ilPortfolioPage.php";
                     $page = new ilPortfolioPage($a_id);
                     $user_id = $page->create_user;
                     break;
                 default:
                     // :TODO:
                     break;
             }
             if ($user_id) {
                 // we only need 1 instance each
                 if (!$skill_tree) {
                     include_once "Services/Skill/classes/class.ilSkillTree.php";
                     $skill_tree = new ilSkillTree();
                     include_once "Services/Skill/classes/class.ilPersonalSkill.php";
                     include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
                     $ws_tree = new ilWorkspaceTree($user_id);
                 }
                 // walk skill tree
                 include_once "./Services/Skill/classes/class.ilVirtualSkillTree.php";
                 $vtree = new ilVirtualSkillTree();
                 $tref_id = 0;
                 $skill_id = (int) $skill_id;
                 include_once "./Services/Skill/classes/class.ilSkillTreeNode.php";
                 if (ilSkillTreeNode::_lookupType($skill_id) == "sktr") {
                     include_once "./Services/Skill/classes/class.ilSkillTemplateReference.php";
                     $tref_id = $skill_id;
                     $skill_id = ilSkillTemplateReference::_lookupTemplateId($skill_id);
                 }
                 $b_skills = $vtree->getSubTreeForCSkillId($skill_id . ":" . $tref_id, true);
                 foreach ($b_skills as $bs) {
                     $skill = ilSkillTreeNodeFactory::getInstance($bs["skill_id"]);
                     $level_data = $skill->getLevelData();
                     foreach ($level_data as $k => $v) {
                         // get assigned materials from personal skill
                         $mat = ilPersonalSkill::getAssignedMaterial($user_id, $bs["tref_id"], $v["id"]);
                         if (sizeof($mat)) {
                             foreach ($mat as $item) {
                                 $wsp_id = $item["wsp_id"];
                                 $obj_id = $ws_tree->lookupObjectId($wsp_id);
                                 // all possible material types for now
                                 switch (ilObject::_lookupType($obj_id)) {
                                     case "file":
                                         $this->files[$obj_id] = $obj_id;
                                         break;
                                     case "tstv":
                                         include_once "Modules/Test/classes/class.ilObjTestVerification.php";
                                         $obj = new ilObjTestVerification($obj_id, false);
                                         $this->files_direct[$obj_id] = array($obj->getFilePath(), $obj->getOfflineFilename());
                                         break;
                                     case "excv":
                                         include_once "Modules/Exercise/classes/class.ilObjExerciseVerification.php";
                                         $obj = new ilObjExerciseVerification($obj_id, false);
                                         $this->files_direct[$obj_id] = array($obj->getFilePath(), $obj->getOfflineFilename());
                                         break;
                                     case "crsv":
                                         include_once "Modules/Course/classes/Verification/class.ilObjCourseVerification.php";
                                         $obj = new ilObjCourseVerification($obj_id, false);
                                         $this->files_direct[$obj_id] = array($obj->getFilePath(), $obj->getOfflineFilename());
                                         break;
                                     case "scov":
                                         include_once "Modules/ScormAicc/classes/Verification/class.ilObjSCORMVerification.php";
                                         $obj = new ilObjSCORMVerification($obj_id, false);
                                         $this->files_direct[$obj_id] = array($obj->getFilePath(), $obj->getOfflineFilename());
                                         break;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }