/**
  * Import relevant properties from given exercise
  *
  * @param ilObjExercise $a_test
  * @return object
  */
 public static function createFromExercise(ilObjExercise $a_exercise, $a_user_id)
 {
     global $lng;
     $lng->loadLanguageModule("exercise");
     $newObj = new self();
     $newObj->setTitle($a_exercise->getTitle());
     $newObj->setDescription($a_exercise->getDescription());
     include_once "Services/Tracking/classes/class.ilLPMarks.php";
     $lp_marks = new ilLPMarks($a_exercise->getId(), $a_user_id);
     $newObj->setProperty("issued_on", new ilDate($lp_marks->getStatusChanged(), IL_CAL_DATETIME));
     // create certificate
     include_once "Services/Certificate/classes/class.ilCertificate.php";
     include_once "Modules/Exercise/classes/class.ilExerciseCertificateAdapter.php";
     $certificate = new ilCertificate(new ilExerciseCertificateAdapter($a_exercise));
     $certificate = $certificate->outCertificate(array("user_id" => $a_user_id), false);
     // save pdf file
     if ($certificate) {
         // we need the object id for storing the certificate file
         $newObj->create();
         $path = self::initStorage($newObj->getId(), "certificate");
         $file_name = "exc_" . $a_exercise->getId() . "_" . $a_user_id . ".pdf";
         if (file_put_contents($path . $file_name, $certificate)) {
             $newObj->setProperty("file", $file_name);
             $newObj->update();
             return $newObj;
         }
         // file creation failed, so remove to object, too
         $newObj->delete();
     }
     // remove if certificate works
     $newObj->create();
     return $newObj;
 }
 function start()
 {
     $this->__buildHeader();
     $attribs = array("obj_id" => "il_" . IL_INST_ID . "_exc_" . $this->exercise->getId());
     if ($this->exercise->getOwner()) {
         $attribs["owner"] = "il_" . IL_INST_ID . "_usr_" . $this->exercise->getOwner();
     }
     $this->xmlStartTag("Exercise", $attribs);
     //todo: create new dtd for new assignment structure
     $this->xmlElement("Title", null, $this->exercise->getTitle());
     $this->xmlElement("Description", null, $this->exercise->getDescription());
     //$this->xmlElement("Instruction",  null,$this->exercise->getInstruction());
     //$this->xmlElement("DueDate",  null,$this->exercise->getTimestamp());
     //todo: as a workaround use first assignment for compatibility with old exercise dtd
     $assignments = ilExAssignment::getAssignmentDataOfExercise($this->exercise->getId());
     if (count($assignments) > 0) {
         foreach ($assignments as $assignment) {
             $this->xmlStartTag("Assignment");
             $this->xmlElement("Instruction", null, $assignment["instruction"]);
             $this->xmlElement("DueDate", null, $assignment["deadline"]);
             $this->handleAssignmentFiles($this->exercise->getId(), $assignment["id"]);
             if ($this->attachMembers) {
                 $this->handleAssignmentMembers($this->exercise->getId(), $assignment["id"]);
             }
             $this->xmlEndTag("Assignment");
         }
     }
     $this->xmlEndTag("Exercise");
     $this->__buildFooter();
     return true;
 }
 /**
  * Get all completed tests
  */
 protected function getItems()
 {
     global $ilUser;
     include_once "Modules/Exercise/classes/class.ilObjExercise.php";
     $data = array();
     foreach (ilObjExercise::_lookupFinishedUserExercises($ilUser->getId()) as $exercise_id => $passed) {
         // #11210 - only available certificates!
         $exc = new ilObjExercise($exercise_id, false);
         if ($exc->hasUserCertificate($ilUser->getId())) {
             $adapter = new ilExerciseCertificateAdapter($exc);
             if (ilCertificate::_isComplete($adapter)) {
                 $data[] = array("id" => $exercise_id, "title" => ilObject::_lookupTitle($exercise_id), "passed" => $passed);
             }
         }
     }
     $this->setData($data);
 }
 /**
  * add an exercise with id.
  *
  * @param string $session_id    current session
  * @param int $target_id refid of parent in repository
  * @param string $exercise_xml   qti xml description of test
  *
  * @return int reference id in the tree, 0 if not successful
  */
 function addExercise($sid, $target_id, $exercise_xml)
 {
     $this->initAuth($sid);
     $this->initIlias();
     if (!$this->__checkSession($sid)) {
         return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
     }
     global $rbacsystem, $tree, $ilLog;
     if (!($target_obj =& ilObjectFactory::getInstanceByRefId($target_id, false))) {
         return $this->__raiseError('No valid target given.', 'Client');
     }
     if (ilObject::_isInTrash($target_id)) {
         return $this->__raiseError("Parent with ID {$target_id} has been deleted.", 'CLIENT_OBJECT_DELETED');
     }
     // Check access
     $allowed_types = array('cat', 'grp', 'crs', 'fold', 'root');
     if (!in_array($target_obj->getType(), $allowed_types)) {
         return $this->__raiseError('No valid target type. Target must be reference id of "course, group, category or folder"', 'Client');
     }
     if (!$rbacsystem->checkAccess('create', $target_id, "exc")) {
         return $this->__raiseError('No permission to create exercises in target  ' . $target_id . '!', 'Client');
     }
     // create object, put it into the tree and use the parser to update the settings
     include_once './Modules/Exercise/classes/class.ilObjExercise.php';
     include_once './Modules/Exercise/classes/class.ilExerciseXMLParser.php';
     include_once './Modules/Exercise/classes/class.ilExerciseException.php';
     $exercise = new ilObjExercise();
     $exercise->create();
     $exercise->createReference();
     $exercise->putInTree($target_id);
     $exercise->setPermissions($target_id);
     $exercise->saveData();
     // we need this as workaround because file and member objects need to be initialised
     $exercise->read();
     $exerciseXMLParser = new ilExerciseXMLParser($exercise, $exercise_xml);
     try {
         if ($exerciseXMLParser->start()) {
             $exerciseXMLParser->getAssignment()->update();
             return $exercise->update() ? $exercise->getRefId() : -1;
         }
         throw new ilExerciseException("Could not parse XML");
     } catch (ilExerciseException $exception) {
         return $this->__raiseError($exception->getMessage(), $exception->getCode() == ilExerciseException::$ID_MISMATCH ? "Client" : "Server");
     }
 }
 /**
  * handler for end of element
  *
  * @param	resource	$a_xml_parser		xml parser
  * @param	string		$a_name				element name
  */
 function handlerEndTag($a_xml_parser, $a_name)
 {
     switch ($a_name) {
         case 'Exercise':
             $this->result = true;
             break;
         case 'Title':
             $this->exercise->setTitle(trim($this->cdata));
             $this->assignment->setTitle(trim($this->cdata));
             break;
         case 'Description':
             $this->exercise->setDescription(trim($this->cdata));
             break;
         case 'Instruction':
             $this->assignment->setInstruction(trim($this->cdata));
             break;
         case 'DueDate':
             $this->assignment->setDeadLine(trim($this->cdata));
             break;
         case 'Member':
             $this->updateMember($this->usr_id, $this->usr_action);
             // update marking after update member.
             $this->updateMarking($this->usr_id);
             break;
         case 'Filename':
             $this->file_name = trim($this->cdata);
             break;
         case 'Content':
             $this->file_content = trim($this->cdata);
             break;
         case 'File':
             $this->updateFile($this->file_name, $this->file_content, $this->file_action);
             break;
         case 'Comment':
             $this->comment = trim($this->cdata);
             break;
         case 'Notice':
             $this->notice = trim($this->cdata);
             break;
         case 'Mark':
             $this->mark = trim($this->cdata);
             break;
         case 'Marking':
             // see Member end tag
             break;
     }
     $this->cdata = '';
     return;
 }
 /**
  * Render object context
  */
 function render()
 {
     global $tpl, $ilTabs, $ilCtrl, $lng, $ilToolbar, $ilUser, $tree;
     if (!$this->checkPermissionBool("read")) {
         ilUtil::sendInfo($lng->txt("no_permission"));
         return;
     }
     $ilTabs->activateTab("content");
     // toolbar
     if ($this->mayContribute()) {
         $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "createPosting"));
         include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
         $title = new ilTextInputGUI($lng->txt("title"), "title");
         $ilToolbar->addInputItem($title, $lng->txt("title"));
         $ilToolbar->addFormButton($lng->txt("blog_add_posting"), "createPosting");
         // exercise blog?
         include_once "Modules/Exercise/classes/class.ilObjExercise.php";
         $exercises = ilObjExercise::findUserFiles($ilUser->getId(), $this->node_id);
         if ($exercises) {
             $info = array();
             foreach ($exercises as $exercise) {
                 // #9988
                 $active_ref = false;
                 foreach (ilObject::_getAllReferences($exercise["obj_id"]) as $ref_id) {
                     if (!$tree->isSaved($ref_id)) {
                         $active_ref = true;
                         break;
                     }
                 }
                 if ($active_ref) {
                     $part = $this->getExerciseInfo($exercise["ass_id"]);
                     if ($part) {
                         $info[] = $part;
                     }
                 }
             }
             if (sizeof($info)) {
                 ilUtil::sendInfo(implode("<br />", $info));
             }
         }
     }
     $list_items = $this->getListItems();
     $list = $nav = "";
     if ($list_items) {
         // $is_owner = ($this->object->getOwner() == $ilUser->getId());
         $is_owner = $this->mayContribute();
         $list = $this->renderList($list_items, $this->month, "preview", null, $is_owner);
         $nav = $this->renderNavigation($this->items, "render", "preview", null, $is_owner);
     }
     $this->setContentStyleSheet();
     $tpl->setContent($list);
     $tpl->setRightContent($nav);
 }
 /**
  * Get's the repository object ID of a parent object, if possible
  * 
  * see ilWebAccessChecker 
  */
 function getParentObjectIdForUsage($a_usage, $a_include_all_access_obj_ids = false)
 {
     if (is_int(strpos($a_usage["type"], ":"))) {
         $us_arr = explode(":", $a_usage["type"]);
         $type = $us_arr[1];
         $cont_type = $us_arr[0];
     } else {
         $type = $a_usage["type"];
     }
     $id = $a_usage["id"];
     $obj_id = false;
     switch ($type) {
         // RTE / tiny mce
         case "html":
             switch ($cont_type) {
                 case "qpl":
                     // Question Pool *Question* Text (Test)
                     include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
                     $qinfo = assQuestion::_getQuestionInfo($id);
                     if ($qinfo["original_id"] > 0) {
                         include_once "./Modules/Test/classes/class.ilObjTest.php";
                         $obj_id = ilObjTest::_lookupTestObjIdForQuestionId($id);
                         // usage in test
                     } else {
                         $obj_id = $qinfo["obj_fi"];
                         // usage in pool
                     }
                     break;
                 case "spl":
                     // Question Pool *Question* Text (Survey)
                     include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
                     $quest = SurveyQuestion::_instanciateQuestion($id);
                     if ($quest) {
                         if ($quest->getOriginalId() > 0) {
                             $obj_id = $quest->getSurveyId();
                         } else {
                             $obj_id = $quest->getObjId();
                             // usage in pool
                         }
                         unset($quest);
                     }
                     break;
                 case "exca":
                     // Exercise assignment
                     $returned_pk = $a_usage['id'];
                     // we are just checking against exercise object
                     include_once 'Modules/Exercise/classes/class.ilObjExercise.php';
                     $obj_id = ilObjExercise::lookupExerciseIdForReturnedId($returned_pk);
                     break;
                 case "frm":
                     // Forum
                     $post_pk = $a_usage['id'];
                     include_once 'Modules/Forum/classes/class.ilForumPost.php';
                     include_once 'Modules/Forum/classes/class.ilForum.php';
                     $oPost = new ilForumPost($post_pk);
                     $frm_pk = $oPost->getForumId();
                     $obj_id = ilForum::_lookupObjIdForForumId($frm_pk);
                     break;
                     // temporary items (per user)
                 // temporary items (per user)
                 case "frm~":
                 case "exca~":
                     $obj_id = $a_usage['id'];
                     break;
                     // "old" category pages
                 // "old" category pages
                 case "cat":
                     // InfoScreen Text
                 // InfoScreen Text
                 case "tst":
                 case "svy":
                     // data collection
                 // data collection
                 case "dcl":
                     $obj_id = $id;
                     break;
             }
             break;
             // page editor
         // page editor
         case "pg":
             switch ($cont_type) {
                 case "qpl":
                     // Question Pool Question Pages
                     include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
                     $qinfo = assQuestion::_getQuestionInfo($id);
                     if ($qinfo["original_id"] > 0) {
                         include_once "./Modules/Test/classes/class.ilObjTest.php";
                         $obj_id = ilObjTest::_lookupTestObjIdForQuestionId($id);
                         // usage in test
                     } else {
                         $obj_id = $qinfo["obj_fi"];
                         // usage in pool
                     }
                     break;
                 case "lm":
                 case "dbk":
                     // learning modules
                     include_once "./Modules/LearningModule/classes/class.ilLMObject.php";
                     $obj_id = ilLMObject::_lookupContObjID($id);
                     break;
                 case "gdf":
                     // glossary definition
                     include_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php";
                     include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php";
                     $term_id = ilGlossaryDefinition::_lookupTermId($id);
                     $obj_id = ilGlossaryTerm::_lookGlossaryID($term_id);
                     break;
                 case "wpg":
                     // wiki page
                     include_once 'Modules/Wiki/classes/class.ilWikiPage.php';
                     $obj_id = ilWikiPage::lookupObjIdByPage($id);
                     break;
                 case "sahs":
                     // sahs page
                     // can this implementation be used for other content types, too?
                     include_once './Services/COPage/classes/class.ilPageObject.php';
                     $obj_id = ilPageObject::lookupParentId($id, 'sahs');
                     break;
                 case "prtf":
                     // portfolio
                     include_once "Modules/Portfolio/classes/class.ilPortfolioPage.php";
                     $obj_id = ilPortfolioPage::findPortfolioForPage($id);
                     break;
                 case "prtt":
                     // portfolio template
                     include_once "Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php";
                     $obj_id = ilPortfolioTemplatePage::findPortfolioForPage($id);
                     break;
                 case "blp":
                     // blog
                     include_once './Services/COPage/classes/class.ilPageObject.php';
                     $obj_id = ilPageObject::lookupParentId($id, 'blp');
                     break;
                 case "crs":
                 case "grp":
                 case "cat":
                 case "fold":
                 case "root":
                     // repository pages
                     $obj_id = $id;
                     break;
             }
             break;
             // Media Pool
         // Media Pool
         case "mep":
             $obj_id = $id;
             break;
             // News Context Object (e.g. MediaCast)
         // News Context Object (e.g. MediaCast)
         case "news":
             include_once "./Services/News/classes/class.ilNewsItem.php";
             $obj_id = ilNewsItem::_lookupContextObjId($id);
             break;
     }
     return $obj_id;
 }
 /**
  * Save multi feedback files
  *
  * @param
  * @return
  */
 function saveMultiFeedbackFiles($a_files, $a_user_id = 0)
 {
     global $ilUser;
     $exc = new ilObjExercise($this->getExerciseId(), false);
     include_once "./Modules/Exercise/classes/class.ilFSStorageExercise.php";
     $fstorage = new ilFSStorageExercise($this->getExerciseId(), $this->getId());
     $fstorage->create();
     $mfu = $fstorage->getMultiFeedbackUploadPath($ilUser->getId());
     if ($a_user_id == 0) {
         $a_user_id = $ilUser->getId();
     }
     $mf_files = $this->getMultiFeedbackFiles();
     foreach ($mf_files as $f) {
         if ($a_files[$f["user_id"]][$f["file"]] != "") {
             $fb_path = $fstorage->getFeedbackPath((int) $f["user_id"]);
             $target = $fb_path . "/" . $f["file"];
             if (is_file($target)) {
                 unlink($target);
             }
             // rename file
             rename($f["full_path"], $target);
             $exc->sendFeedbackFileNotification($f["file"], (int) $f["user_id"], (int) $this->getId());
         }
     }
     $this->clearMultiFeedbackDirectory();
 }
 /**
  * was: setStatusForMember($a_member_id,$a_status)
  */
 function updateStatusOfUser($a_ass_id, $a_user_id, $a_status)
 {
     global $ilDB;
     $ilDB->manipulateF("UPDATE exc_mem_ass_status " . "SET status = %s, status_time= %s " . " WHERE ass_id = %s AND usr_id = %s AND status <> %s ", array("text", "timestamp", "integer", "integer", "text"), array($a_status, ilUtil::now(), $a_ass_id, $a_user_id, $a_status));
     $ass = new ilExAssignment($a_ass_id);
     $exc = new ilObjExercise($ass->getExerciseId(), false);
     $exc->updateUserStatus($a_user_id);
 }
 /**
  * Iterates an associative array and fixes all fields with the key "filename"
  * using the _fixFilename() method
  */
 static function _fixFilenameArray($a_array)
 {
     if (is_array($a_array)) {
         foreach ($a_array as $k => $v) {
             if ($v["filename"] != "") {
                 $a_array[$k]["filename"] = ilObjExercise::_fixFilename($a_array[$k]["filename"]);
             }
         }
     }
     return $a_array;
 }
 /**
  * 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;
     }
 }
Example #12
0
 /**
  * Handle calendar entries for deadline(s)
  * 
  * @param string $a_event
  */
 protected function handleCalendarEntries($a_event)
 {
     global $ilAppEventHandler;
     $dl_id = $this->getId() . "0";
     $fbdl_id = $this->getId() . "1";
     $context_ids = array($dl_id, $fbdl_id);
     $apps = array();
     if ($a_event != "delete") {
         include_once "Services/Calendar/classes/class.ilCalendarAppointmentTemplate.php";
         if ($this->getDeadline()) {
             $app = new ilCalendarAppointmentTemplate($dl_id);
             $app->setTranslationType(IL_CAL_TRANSLATION_SYSTEM);
             $app->setSubtitle("cal_exc_deadline");
             $app->setTitle($this->getTitle());
             $app->setFullday(false);
             $app->setStart(new ilDateTime($this->getDeadline(), IL_CAL_UNIX));
             $apps[] = $app;
         }
         if ($this->getPeerReview() && $this->getPeerReviewDeadline()) {
             $app = new ilCalendarAppointmentTemplate($fbdl_id);
             $app->setTranslationType(IL_CAL_TRANSLATION_SYSTEM);
             $app->setSubtitle("cal_exc_peer_review_deadline");
             $app->setTitle($this->getTitle());
             $app->setFullday(false);
             $app->setStart(new ilDateTime($this->getPeerReviewDeadline(), IL_CAL_UNIX));
             $apps[] = $app;
         }
     }
     include_once "Modules/Exercise/classes/class.ilObjExercise.php";
     $exc = new ilObjExercise($this->getExerciseId(), false);
     $ilAppEventHandler->raise('Modules/Exercise', $a_event . 'Assignment', array('object' => $exc, 'obj_id' => $exc->getId(), 'context_ids' => $context_ids, 'appointments' => $apps));
 }
 protected function createPortfolioFromTemplateProcess($a_process_form = true)
 {
     global $ilSetting, $ilUser, $ilAccess;
     $title = trim($_REQUEST["pt"]);
     $prtt_id = (int) $_REQUEST["prtt"];
     // valid template?
     include_once "Modules/Portfolio/classes/class.ilObjPortfolioTemplate.php";
     $templates = array_keys(ilObjPortfolioTemplate::getAvailablePortfolioTemplates());
     if (!sizeof($templates) || !in_array($prtt_id, $templates)) {
         $this->toRepository();
     }
     unset($templates);
     // build page recipe (aka import form values)
     $recipe = null;
     if ($a_process_form) {
         $this->ctrl->setParameter($this, "prtt", $prtt_id);
         $form = $this->initCreatePortfolioFromTemplateForm($prtt_id, $title);
         if ($form->checkInput()) {
             include_once "Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php";
             foreach (ilPortfolioTemplatePage::getAllPages($prtt_id) as $page) {
                 switch ($page["type"]) {
                     case ilPortfolioTemplatePage::TYPE_BLOG_TEMPLATE:
                         if (!$ilSetting->get('disable_wsp_blogs')) {
                             $field_id = "blog_" . $page["id"];
                             switch ($form->getInput($field_id)) {
                                 case "blog_create":
                                     $recipe[$page["id"]] = array("blog", "create", trim($form->getInput($field_id . "_create_title")));
                                     break;
                                 case "blog_resuse":
                                     $recipe[$page["id"]] = array("blog", "reuse", (int) $form->getInput($field_id . "_reuse_blog"));
                                     break;
                                 case "blog_ignore":
                                     $recipe[$page["id"]] = array("blog", "ignore");
                                     break;
                             }
                         }
                         break;
                 }
             }
             $recipe["skills"] = (array) $form->getInput("skill_ids");
         } else {
             $form->setValuesByPost();
             return $this->createPortfolioFromTemplate($form);
         }
     }
     $source = new ilObjPortfolioTemplate($prtt_id, false);
     // create portfolio
     include_once "Modules/Portfolio/classes/class.ilObjPortfolio.php";
     $target = new ilObjPortfolio();
     $target->setTitle($title);
     $target->create();
     $target_id = $target->getId();
     $source->clonePagesAndSettings($source, $target, $recipe);
     // link portfolio to exercise assignment
     $exc_ref_id = (int) $_REQUEST["exc_id"];
     $ass_id = (int) $_REQUEST["ass_id"];
     if ($exc_ref_id && $ass_id && $ilAccess->checkAccess("read", "", $exc_ref_id)) {
         include_once "Modules/Exercise/classes/class.ilObjExercise.php";
         include_once "Modules/Exercise/classes/class.ilExAssignment.php";
         $exc = new ilObjExercise($exc_ref_id);
         $ass = new ilExAssignment($ass_id);
         if ($ass->getExerciseId() == $exc->getId() && $ass->getType() == ilExAssignment::TYPE_PORTFOLIO) {
             $exc->addResourceObject($target_id, $ass_id, $ilUser->getId());
         }
     }
     ilUtil::sendSuccess($this->lng->txt("prtf_portfolio_created"), true);
     $this->ctrl->setParameter($this, "prt_id", $target_id);
     $this->ctrl->redirect($this, "view");
 }
 /**
  * Show list of portfolio pages
  */
 public function view()
 {
     global $ilToolbar, $ilSetting, $tree;
     if (!$this->checkPermissionBool("write")) {
         $this->ctrl->redirect($this, "infoScreen");
     }
     $this->tabs_gui->activateTab("pages");
     include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
     $button = ilLinkButton::getInstance();
     $button->setCaption("prtf_add_page");
     $button->setUrl($this->ctrl->getLinkTarget($this, "addPage"));
     $ilToolbar->addButtonInstance($button);
     if (!$ilSetting->get('disable_wsp_blogs')) {
         $button = ilLinkButton::getInstance();
         $button->setCaption("prtf_add_blog");
         $button->setUrl($this->ctrl->getLinkTarget($this, "addBlog"));
         $ilToolbar->addButtonInstance($button);
     }
     $ilToolbar->addSeparator();
     $button = ilLinkButton::getInstance();
     $button->setCaption("export_html");
     $button->setUrl($this->ctrl->getLinkTarget($this, "export"));
     $ilToolbar->addButtonInstance($button);
     include_once "Modules/Portfolio/classes/class.ilPortfolioPageTableGUI.php";
     $table = new ilPortfolioPageTableGUI($this, "view");
     // exercise portfolio?
     include_once "Modules/Exercise/classes/class.ilObjExercise.php";
     $exercises = ilObjExercise::findUserFiles($this->user_id, $this->object->getId());
     if ($exercises) {
         $info = array();
         foreach ($exercises as $exercise) {
             // #9988
             $active_ref = false;
             foreach (ilObject::_getAllReferences($exercise["obj_id"]) as $ref_id) {
                 if (!$tree->isSaved($ref_id)) {
                     $active_ref = true;
                     break;
                 }
             }
             if ($active_ref) {
                 $part = $this->getExerciseInfo($exercise["ass_id"], $table->dataExists());
                 if ($part) {
                     $info[] = $part;
                 }
             }
         }
         if (sizeof($info)) {
             ilUtil::sendInfo(implode("<br />", $info));
         }
     }
     $this->tpl->setContent($table->getHTML());
 }
 /**
  * checks wether a single condition is fulfilled
  * every trigger object type must implement a static method
  * _checkCondition($a_operator, $a_value)
  */
 function _checkCondition($a_id, $a_usr_id = 0)
 {
     global $ilUser;
     $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
     $condition = ilConditionHandler::_getCondition($a_id);
     switch ($condition['trigger_type']) {
         case "tst":
             include_once './Modules/Test/classes/class.ilObjTestAccess.php';
             return ilObjTestAccess::_checkCondition($condition['trigger_obj_id'], $condition['operator'], $condition['value'], $a_usr_id);
         case "crs":
             include_once './Modules/Course/classes/class.ilObjCourse.php';
             return ilObjCourse::_checkCondition($condition['trigger_obj_id'], $condition['operator'], $condition['value'], $a_usr_id);
         case 'exc':
             include_once './Modules/Exercise/classes/class.ilObjExercise.php';
             return ilObjExercise::_checkCondition($condition['trigger_obj_id'], $condition['operator'], $condition['value'], $a_usr_id);
         case 'crsg':
             include_once './Modules/Course/classes/class.ilObjCourseGrouping.php';
             return ilObjCourseGrouping::_checkCondition($condition['trigger_obj_id'], $condition['operator'], $condition['value'], $a_usr_id);
         case 'sahs':
             include_once './Services/Tracking/classes/class.ilLPStatus.php';
             return ilLPStatus::_lookupStatus($condition['trigger_obj_id'], $a_usr_id) == LP_STATUS_COMPLETED_NUM;
         case 'svy':
             include_once './Modules/Survey/classes/class.ilObjSurvey.php';
             return ilObjSurvey::_checkCondition($condition['trigger_obj_id'], $condition['operator'], $condition['value'], $a_usr_id);
         default:
             return false;
     }
 }
 /**
  * Show list of portfolio pages
  */
 protected function pages()
 {
     global $tpl, $lng, $ilToolbar, $ilCtrl, $ilTabs, $ilUser, $ilSetting, $tree;
     if (!$this->checkAccess("write")) {
         return;
     }
     $ilTabs->clearTargets();
     $ilCtrl->setParameter($this, "prt_id", "");
     $ilTabs->setBackTarget($lng->txt("back"), $ilCtrl->getLinkTarget($this, "show"));
     $ilCtrl->setParameter($this, "prt_id", $this->portfolio->getId());
     $this->setPagesTabs();
     $ilTabs->activateTab("pages");
     $ilToolbar->addButton($lng->txt("prtf_add_page"), $ilCtrl->getLinkTarget($this, "addPage"));
     if (!$ilSetting->get('disable_wsp_blogs')) {
         $ilToolbar->addButton($lng->txt("prtf_add_blog"), $ilCtrl->getLinkTarget($this, "addBlog"));
     }
     $ilToolbar->addSeparator();
     $ilToolbar->addButton($lng->txt("export"), $ilCtrl->getLinkTarget($this, "export"));
     include_once "Services/Portfolio/classes/class.ilPortfolioPageTableGUI.php";
     $table = new ilPortfolioPageTableGUI($this, "pages", $this->portfolio);
     // exercise portfolio?
     include_once "Modules/Exercise/classes/class.ilObjExercise.php";
     $exercises = ilObjExercise::findUserFiles($ilUser->getId(), $this->portfolio->getId());
     if ($exercises) {
         $info = array();
         foreach ($exercises as $exercise) {
             // #9988
             $active_ref = false;
             foreach (ilObject::_getAllReferences($exercise["obj_id"]) as $ref_id) {
                 if (!$tree->isSaved($ref_id)) {
                     $active_ref = true;
                     break;
                 }
             }
             if ($active_ref) {
                 $part = $this->getExerciseInfo($exercise["ass_id"], $table->dataExists());
                 if ($part) {
                     $info[] = $part;
                 }
             }
         }
         if (sizeof($info)) {
             ilUtil::sendInfo(implode("<br />", $info));
         }
     }
     $tpl->setContent($table->getHTML());
 }