/** * Fill table row */ protected function fillRow($a_set) { global $lng, $ilCtrl, $ilUser; include_once "./Services/Skill/classes/class.ilPersonalSkill.php"; $mat = ilPersonalSkill::getAssignedMaterial($ilUser->getId(), $this->tref_id, $a_set["id"]); $ilCtrl->setParameter($this->parent_obj, "level_id", $a_set["id"]); foreach ($mat as $m) { $this->tpl->setCurrentBlock("mat"); $obj_id = $this->ws_tree->lookupObjectId($m["wsp_id"]); $this->tpl->setVariable("MAT_TITLE", ilObject::_lookupTitle($obj_id)); $this->tpl->setVariable("MAT_IMG", ilUtil::img(ilUtil::getImagePath("icon_" . ilObject::_lookupType($obj_id) . ".svg"))); $this->tpl->setVariable("TXT_REMOVE", $lng->txt("remove")); $ilCtrl->setParameter($this->parent_obj, "wsp_id", $m["wsp_id"]); $this->tpl->setVariable("HREF_REMOVE", $ilCtrl->getLinkTarget($this->parent_obj, "removeMaterial")); $obj_id = $this->ws_tree->lookupObjectId($m["wsp_id"]); $url = $this->ws_access->getGotoLink($m["wsp_id"], $obj_id); $this->tpl->setVariable("HREF_MAT", $url); $this->tpl->parseCurrentBlock(); } $this->tpl->setCurrentBlock("cmd"); $this->tpl->setVariable("HREF_CMD", $ilCtrl->getLinkTarget($this->parent_obj, "assignMaterial")); $this->tpl->setVariable("TXT_CMD", $lng->txt("skmg_assign_materials")); $this->tpl->parseCurrentBlock(); $ilCtrl->setParameter($this->parent_obj, "level_id", ""); $this->tpl->setVariable("LEVEL_ID", $a_set["id"]); $this->tpl->setVariable("SKILL_ID", $this->basic_skill_id); $this->tpl->setVariable("TXT_SKILL", $a_set["title"]); $this->tpl->setVariable("TXT_SKILL_DESC", $a_set["description"]); }
/** * Constructor */ function __construct($a_parent_obj, $a_parent_cmd, $a_top_skill_id, $a_tref_id, $a_basic_skill_id) { global $ilCtrl, $lng, $ilAccess, $lng, $ilUser; $this->top_skill_id = $a_top_skill_id; $this->tref_id = (int) $a_tref_id; $this->basic_skill_id = $a_basic_skill_id; $this->cur_level_id = ilPersonalSkill::getSelfEvaluation($ilUser->getId(), $this->top_skill_id, $this->tref_id, $this->basic_skill_id); // build title include_once "./Services/Skill/classes/class.ilSkillTree.php"; $stree = new ilSkillTree(); $path = $stree->getPathFull($this->basic_skill_id); $title = $sep = ""; foreach ($path as $p) { if ($p["type"] != "skrt") { $title .= $sep . $p["title"]; $sep = " > "; } } parent::__construct($a_parent_obj, $a_parent_cmd); $this->setData($this->getLevels()); $this->setTitle($title); $this->setLimit(9999); $this->addColumn("", "", "", true); $this->addColumn($this->lng->txt("skmg_skill_level")); $this->addColumn($this->lng->txt("description")); $this->setEnableHeader(true); $this->setRowTemplate("tpl.simple_self_eval.html", "Services/Skill"); $this->disable("footer"); $this->setEnableTitle(true); $this->addCommandButton("saveSelfEvaluation", $lng->txt("save")); $this->setFormAction($ilCtrl->getFormAction($a_parent_obj)); }
/** * Constructor */ function __construct($a_parent_obj, $a_parent_cmd) { global $ilCtrl, $lng, $ilAccess, $lng, $ilUser; parent::__construct($a_parent_obj, $a_parent_cmd); include_once "./Services/Skill/classes/class.ilPersonalSkill.php"; $this->setData(ilPersonalSkill::getSelectedUserSkills($ilUser->getId())); $this->setTitle($lng->txt("skills")); $this->addColumn("", "", "1", true); $this->addColumn($this->lng->txt("title"), "title"); $this->addColumn($this->lng->txt("skmg_materials")); $this->addColumn($this->lng->txt("actions")); $this->setFormAction($ilCtrl->getFormAction($a_parent_obj)); $this->setRowTemplate("tpl.personal_skill_row.html", "Services/Skill"); $this->addMultiCommand("confirmSkillRemove", $lng->txt("skmg_remove_skills")); }
/** * 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"]; // get user id from portfolio page include_once "Services/Portfolio/classes/class.ilPortfolioPage.php"; $page = new ilPortfolioPage(0, $a_id); $user_id = $page->create_user; // 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 $b_skills = ilSkillTreeNode::getSkillTreeNodes($skill_id, true); foreach ($b_skills as $bs) { $skill = ilSkillTreeNodeFactory::getInstance($bs["id"]); $level_data = $skill->getLevelData(); foreach ($level_data as $k => $v) { // get assigned materials from personal skill $mat = ilPersonalSkill::getAssignedMaterial($user_id, $bs["tref"], $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; } } } } } } } }
/** * Render materials row * * @param * @return */ function renderMaterialsRow($a_tpl, $a_levels, $a_top_skill_id, $a_base_skill, $a_tref_id = 0, $a_user_id = 0) { global $ilUser, $lng; if ($a_user_id == 0) { $a_user_id = $ilUser->getId(); } foreach ($a_levels as $k => $v) { $mat_cnt = ilPersonalSkill::countAssignedMaterial($a_user_id, $a_tref_id, $v["id"]); if ($mat_cnt == 0) { $a_tpl->setCurrentBlock("val_level_td"); $a_tpl->setVariable("VAL_LEVEL", " "); $a_tpl->parseCurrentBlock(); } else { // links to material files $a_tpl->setCurrentBlock("level_link"); $mat_tt = array(); $cnt = 1; foreach (ilPersonalSkill::getAssignedMaterial($a_user_id, $a_tref_id, $v["id"]) as $item) { $mat_data = $this->getMaterialInfo($item["wsp_id"]); $a_tpl->setVariable("HREF_LINK", $mat_data[1]); $a_tpl->setVariable("TXT_LINK", $cnt); // tooltip $mat_tt_id = "skmg_skl_tt_mat_" . self::$skill_tt_cnt; self::$skill_tt_cnt++; $a_tpl->setVariable("LEVEL_LINK_ID", $mat_tt_id); if (!$this->offline_mode) { ilTooltipGUI::addTooltip($mat_tt_id, $mat_data[0]); } else { $this->tooltips[] = ilTooltipGUI::getTooltip($mat_tt_id, $mat_data[0]); } $a_tpl->parseCurrentBlock(); $cnt++; } $a_tpl->setCurrentBlock("val_level_td"); $a_tpl->setVariable("TD_CLASS", "ilSkillMat"); $a_tpl->parseCurrentBlock(); } } $a_tpl->setCurrentBlock("value_row"); $a_tpl->setVariable("TXT_VAL_TITLE", $lng->txt("skmg_material")); $a_tpl->parseCurrentBlock(); }
/** * Save self evaluation */ function saveSelfEvaluation() { global $ilUser, $lng, $ilCtrl; ilPersonalSkill::saveSelfEvaluation($ilUser->getId(), (int) $_GET["skill_id"], (int) $_GET["tref_id"], (int) $_GET["basic_skill_id"], (int) $_POST["se"]); ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true); /* $ilCtrl->saveParameter($this, "skill_id"); $ilCtrl->saveParameter($this, "level_id"); $ilCtrl->saveParameter($this, "tref_id"); $ilCtrl->saveParameter($this, "basic_skill_id");*/ $ilCtrl->redirect($this, "listSkills"); }
/** * @return array */ protected function addSkills() { $user = $this->getUsrObject(); $pskills = array_keys(ilPersonalSkill::getSelectedUserSkills($user->getId())); $skill_ids = array(); $recipe = array(); foreach (ilPortfolioTemplatePage::getAllPages($this->getPortfolioTemplateId()) as $page) { switch ($page['type']) { case ilPortfolioTemplatePage::TYPE_PAGE: $source_page = new ilPortfolioTemplatePage($page['id']); $source_page->buildDom(true); $dom = $source_page->getDom(); if ($dom instanceof php4DOMDocument) { $dom = $dom->myDOMDocument; } $xpath = new DOMXPath($dom); $nodes = $xpath->query('//PageContent/Skills'); foreach ($nodes as $node) { $skill_id = $node->getAttribute('Id'); if (!in_array($skill_id, $pskills)) { $skill_ids[] = $skill_id; } } unset($nodes); unset($xpath); unset($dom); break; } } foreach ($skill_ids as $skill_id) { ilPersonalSkill::addPersonalSkill($user->getId(), $skill_id); } }
/** * Init skills form * * @param bool $a_insert * @return ilPropertyFormGUI */ protected function initForm($a_insert = false) { global $ilCtrl, $ilUser, $lng; include_once "./Services/Form/classes/class.ilPropertyFormGUI.php"; $form = new ilPropertyFormGUI(); $form->setFormAction($ilCtrl->getFormAction($this)); if ($a_insert) { $form->setTitle($this->lng->txt("cont_insert_skills")); } else { $form->setTitle($this->lng->txt("cont_update_skills")); } $options = array(); include_once "Services/Skill/classes/class.ilPersonalSkill.php"; $skills = ilPersonalSkill::getSelectedUserSkills($ilUser->getId()); if ($skills) { foreach ($skills as $skill) { $options[$skill["skill_node_id"]] = $skill["title"]; } asort($options); } else { ilUtil::sendFailure("cont_no_skills"); } $obj = new ilSelectInputGUI($this->lng->txt("cont_pc_skills"), "skill_id"); $obj->setRequired(true); $obj->setOptions($options); $form->addItem($obj); if ($a_insert) { $form->addCommandButton("create_skill", $this->lng->txt("select")); $form->addCommandButton("cancelCreate", $this->lng->txt("cancel")); } else { $obj->setValue($this->content_obj->getSkillId()); $form->addCommandButton("update", $this->lng->txt("select")); $form->addCommandButton("cancelUpdate", $this->lng->txt("cancel")); } return $form; }
protected function initCreatePortfolioFromTemplateForm($a_prtt_id, $a_title) { global $ilSetting, $ilUser; if ((int) $_REQUEST["exc_id"]) { $this->ctrl->setParameter($this, "exc_id", (int) $_REQUEST["exc_id"]); $this->ctrl->setParameter($this, "ass_id", (int) $_REQUEST["ass_id"]); } include_once "Services/Form/classes/class.ilPropertyFormGUI.php"; $form = new ilPropertyFormGUI(); $form->setFormAction($this->ctrl->getFormAction($this)); $tmpl = new ilNonEditableValueGUI($this->lng->txt("obj_prtt")); $tmpl->setValue(ilObject::_lookupTitle($a_prtt_id)); $form->addItem($tmpl); $title = new ilNonEditableValueGUI($this->lng->txt("title"), "pt"); $title->setValue($a_title); $form->addItem($title); // gather user blogs if (!$ilSetting->get('disable_wsp_blogs')) { $blog_options = array(); include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php"; $tree = new ilWorkspaceTree($this->user_id); $root = $tree->readRootId(); if ($root) { $root = $tree->getNodeData($root); foreach ($tree->getSubTree($root, true, "blog") as $node) { $blog_options[$node["obj_id"]] = $node["title"]; } asort($blog_options); } } $has_form_content = false; include_once "Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php"; $check_quota = ilDiskQuotaActivationChecker::_isPersonalWorkspaceActive(); $quota_sum = 0; include_once "Services/Skill/classes/class.ilPersonalSkill.php"; $pskills = array_keys(ilPersonalSkill::getSelectedUserSkills($ilUser->getId())); $skill_ids = array(); include_once "Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php"; foreach (ilPortfolioTemplatePage::getAllPages($a_prtt_id) as $page) { switch ($page["type"]) { case ilPortfolioTemplatePage::TYPE_PAGE: // skills $source_page = new ilPortfolioTemplatePage($page["id"]); $source_page->buildDom(true); $dom = $source_page->getDom(); if ($dom instanceof php4DOMDocument) { $dom = $dom->myDOMDocument; } $xpath = new DOMXPath($dom); $nodes = $xpath->query("//PageContent/Skills"); foreach ($nodes as $node) { $skill_id = $node->getAttribute("Id"); if (!in_array($skill_id, $pskills)) { $skill_ids[] = $skill_id; } } unset($nodes); unset($xpath); unset($dom); if ($check_quota) { $quota_sum += $source_page->getPageDiskSize(); } if (sizeof($skill_ids)) { $has_form_content = true; } break; case ilPortfolioTemplatePage::TYPE_BLOG_TEMPLATE: if (!$ilSetting->get('disable_wsp_blogs')) { $has_form_content = true; $field_id = "blog_" . $page["id"]; $blog = new ilRadioGroupInputGUI($this->lng->txt("obj_blog") . ": " . $page["title"], $field_id); $blog->setRequired(true); $blog->setValue("blog_create"); $form->addItem($blog); $new_blog = new ilRadioOption($this->lng->txt("prtf_template_import_blog_create"), "blog_create"); $blog->addOption($new_blog); $title = new ilTextInputGUI($this->lng->txt("title"), $field_id . "_create_title"); $title->setRequired(true); $new_blog->addSubItem($title); if (sizeof($blog_options)) { $reuse_blog = new ilRadioOption($this->lng->txt("prtf_template_import_blog_reuse"), "blog_resuse"); $blog->addOption($reuse_blog); $obj = new ilSelectInputGUI($this->lng->txt("obj_blog"), $field_id . "_reuse_blog"); $obj->setRequired(true); $obj->setOptions(array("" => $this->lng->txt("please_select")) + $blog_options); $reuse_blog->addSubItem($obj); } $blog->addOption(new ilRadioOption($this->lng->txt("prtf_template_import_blog_ignore"), "blog_ignore")); } break; } } if ($skill_ids) { include_once "Services/Skill/classes/class.ilSkillTreeNode.php"; $skills = new ilCheckboxGroupInputGUI($this->lng->txt("skills"), "skill_ids"); $skills->setInfo($this->lng->txt("prtf_template_import_new_skills")); $skills->setValue($skill_ids); foreach ($skill_ids as $skill_id) { $skills->addOption(new ilCheckboxOption(ilSkillTreeNode::_lookupTitle($skill_id), $skill_id)); } $form->addItem($skills); } if ($quota_sum) { include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php"; if (!ilDiskQuotaHandler::isUploadPossible($quota_sum)) { ilUtil::sendFailure($this->lng->txt("prtf_template_import_quota_failure"), true); $this->ctrl->redirect($this, "create"); } } // no dialog needed, go ahead if (!$has_form_content) { return; } $form->setTitle($this->lng->txt("prtf_creation_mode") . ": " . $this->lng->txt("prtf_creation_mode_template")); $form->addCommandButton("createPortfolioFromTemplateProcess", $this->lng->txt("continue")); $form->addCommandButton("toRepository", $this->lng->txt("cancel")); return $form; }
/** * Init skills form * * @param bool $a_insert * @return ilPropertyFormGUI */ protected function initForm($a_insert = false) { global $ilCtrl, $ilUser, $lng; include_once "./Services/Form/classes/class.ilPropertyFormGUI.php"; $form = new ilPropertyFormGUI(); $form->setFormAction($ilCtrl->getFormAction($this)); if ($a_insert) { $form->setTitle($this->lng->txt("cont_insert_skills")); } else { $form->setTitle($this->lng->txt("cont_update_skills")); } $options = array(); include_once "Services/Skill/classes/class.ilPersonalSkill.php"; // template mode: get skills from global skill tree if ($this->getPageConfig()->getEnablePCType("PlaceHolder") && false) { // :TODO: use custom input gui here => skill explorer? // needed for portfolio template } else { $skills = ilPersonalSkill::getSelectedUserSkills($ilUser->getId()); } if ($skills) { foreach ($skills as $skill) { $options[$skill["skill_node_id"]] = $skill["title"]; } asort($options); } else { ilUtil::sendFailure("cont_no_skills"); } $obj = new ilSelectInputGUI($this->lng->txt("cont_pc_skills"), "skill_id"); $obj->setRequired(true); $obj->setOptions($options); $form->addItem($obj); if ($a_insert) { $form->addCommandButton("create_skill", $this->lng->txt("select")); $form->addCommandButton("cancelCreate", $this->lng->txt("cancel")); } else { $obj->setValue($this->content_obj->getSkillId()); $form->addCommandButton("update", $this->lng->txt("select")); $form->addCommandButton("cancelUpdate", $this->lng->txt("cancel")); } return $form; }
/** * Build template from portfolio and vice versa * * @param ilObjPortfolioBase $a_source * @param ilObjPortfolioBase $a_target * @param array $a_recipe */ public static function clonePagesAndSettings(ilObjPortfolioBase $a_source, ilObjPortfolioBase $a_target, array $a_recipe = null) { global $lng, $ilUser; $source_id = $a_source->getId(); $target_id = $a_target->getId(); if ($a_source instanceof ilObjPortfolioTemplate && $a_target instanceof ilObjPortfolio) { $direction = "t2p"; } else { if ($a_source instanceof ilObjPortfolio && $a_target instanceof ilObjPortfolioTemplate) { $direction = "p2t"; } else { return; } } self::cloneBasics($a_source, $a_target); // personal skills include_once "Services/Skill/classes/class.ilPersonalSkill.php"; $pskills = array_keys(ilPersonalSkill::getSelectedUserSkills($ilUser->getId())); // copy pages $blog_count = 0; include_once "Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php"; foreach (ilPortfolioPage::getAllPages($source_id) as $page) { $page_id = $page["id"]; if ($direction == "t2p") { $source_page = new ilPortfolioTemplatePage($page_id); $target_page = new ilPortfolioPage(); } else { $source_page = new ilPortfolioPage($page_id); $target_page = new ilPortfolioTemplatePage(); } $source_page->setPortfolioId($source_id); $target_page->setPortfolioId($target_id); $page_type = $source_page->getType(); $page_title = $source_page->getTitle(); $page_recipe = null; if (is_array($a_recipe)) { $page_recipe = $a_recipe[$page_id]; } $valid = false; switch ($page_type) { // blog => blog template case ilPortfolioTemplatePage::TYPE_BLOG: if ($direction == "p2t") { $page_type = ilPortfolioTemplatePage::TYPE_BLOG_TEMPLATE; $page_title = $lng->txt("obj_blog") . " " . ++$blog_count; $valid = true; } break; // blog template => blog (needs recipe) // blog template => blog (needs recipe) case ilPortfolioTemplatePage::TYPE_BLOG_TEMPLATE: if ($direction == "t2p" && is_array($page_recipe)) { $page_type = ilPortfolioPage::TYPE_BLOG; if ($page_recipe[0] == "blog") { switch ($page_recipe[1]) { case "create": $page_title = self::createBlogInPersonalWorkspace($page_recipe[2]); $valid = true; break; case "reuse": $page_title = $page_recipe[2]; $valid = true; break; case "ignore": // do nothing break; } } } break; // page editor // page editor default: $target_page->setXMLContent($source_page->copyXmlContent(true)); // copy mobs $target_page->buildDom(true); // parse content / blocks if ($direction == "t2p") { $dom = $target_page->getDom(); if ($dom instanceof php4DOMDocument) { $dom = $dom->myDOMDocument; } // update profile/consultation hours user id self::updateDomNodes($dom, "//PageContent/Profile", "User", $ilUser->getId()); self::updateDomNodes($dom, "//PageContent/ConsultationHours", "User", $ilUser->getId()); self::updateDomNodes($dom, "//PageContent/MyCourses", "User", $ilUser->getId()); // skills $xpath = new DOMXPath($dom); $nodes = $xpath->query("//PageContent/Skills"); foreach ($nodes as $node) { $skill_id = $node->getAttribute("Id"); // existing personal skills if (in_array($skill_id, $pskills)) { $node->setAttribute("User", $ilUser->getId()); } else { if (in_array($skill_id, $a_recipe["skills"])) { include_once "Services/Skill/classes/class.ilPersonalSkill.php"; ilPersonalSkill::addPersonalSkill($ilUser->getId(), $skill_id); $node->setAttribute("User", $ilUser->getId()); } else { $page_element = $node->parentNode; $page_element->parentNode->removeChild($page_element); } } } } $valid = true; break; } if ($valid) { // #12038 - update xml from dom $target_page->setXMLContent($target_page->getXMLFromDom()); $target_page->setType($page_type); $target_page->setTitle($page_title); $target_page->create(); if ($page_type == ilPortfolioPage::TYPE_PAGE) { $target_page->update(); // handle mob usages! } } } }