ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPersonalSkillsGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once("./Services/Skill/classes/class.ilPersonalSkill.php");
6 include_once("./Services/Skill/classes/class.ilSkillProfile.php");
7 
19 {
20  protected $offline_mode;
21  protected $skill_tree;
22  static $skill_tt_cnt = 1;
23  protected $actual_levels = array();
24  protected $gap_self_eval_levels = array();
25  protected $mode = "";
26 
32  public function __construct()
33  {
34  global $ilCtrl, $lng, $ilHelp, $ilSetting;
35 
36  $lng->loadLanguageModule('skmg');
37 
38  $ilHelp->setScreenIdComponent("skill");
39 
40  $ilCtrl->saveParameter($this, "skill_id");
41  $ilCtrl->saveParameter($this, "tref_id");
42  $ilCtrl->saveParameter($this, "profile_id");
43 
44  include_once("./Services/Skill/classes/class.ilSkillTree.php");
45  $this->skill_tree = new ilSkillTree();
46 
47  $this->use_materials = !$ilSetting->get("disable_personal_workspace");
48  }
49 
55  function setProfileId($a_val)
56  {
57  $this->profile_id = $a_val;
58  }
59 
65  function getProfileId()
66  {
67  return $this->profile_id;
68  }
69 
76  {
77  $this->gap_self_eval_levels = $a_val;
78  }
79 
86  {
88  }
89 
96  public function executeCommand()
97  {
98  global $ilCtrl, $tpl, $lng, $ilUser;
99 
100  $next_class = $ilCtrl->getNextClass($this);
101 
102  $profiles = ilSkillProfile::getProfilesOfUser($ilUser->getId());
103 
104  // determin standard command
105  $std_cmd = "listSkills";
106  if (count($profiles) > 0)
107  {
108 // $std_cmd = "listProfiles";
109  }
110 
111  $cmd = $ilCtrl->getCmd($std_cmd);
112 
113  $tpl->setTitle($lng->txt("skills"));
114  $tpl->setTitleIcon(ilUtil::getImagePath("icon_skmg_b.png"));
115 
116  switch($next_class)
117  {
118  default:
119  $this->$cmd();
120  break;
121  }
122  return true;
123  }
124 
128  function setTabs($a_activate)
129  {
130  global $ilTabs, $lng, $ilCtrl;
131 
132  // list skills
133  $ilTabs->addTab("list_skills",
134  $lng->txt("skmg_list_skills"),
135  $ilCtrl->getLinkTarget($this, "listSkills"));
136 
137  // assign materials
138 /* $ilTabs->addTab("assign_materials",
139  $lng->txt("skmg_assign_materials"),
140  $ilCtrl->getLinkTarget($this, "assignMaterials"));*/
141 
142  $ilTabs->activateTab($a_activate);
143  }
144 
145  function setOfflineMode($a_file_path)
146  {
147  $this->offline_mode = $a_file_path;
148  }
149 
153  function listSkills()
154  {
155  global $tpl, $ilTabs, $lng, $ilCtrl, $ilToolbar, $ilUser;
156 
157  $this->setTabs("list_skills");
158 
159  include_once("./Services/Skill/classes/class.ilSkillTree.php");
160  $stree = new ilSkillTree();
161 
162  // skill selection / add new personal skill
163  $ilToolbar->addFormButton($lng->txt("skmg_add_skill"),
164  "listSkillsForAdd");
165  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
166 
167  $skills = ilPersonalSkill::getSelectedUserSkills($ilUser->getId());
168  $html = "";
169  foreach ($skills as $s)
170  {
171  $path = $stree->getSkillTreePath($s["skill_node_id"]);
172 
173  // check draft
174  foreach ($path as $p)
175  {
176  if ($p["status"] == ilSkillTreeNode::STATUS_DRAFT)
177  {
178  continue(2);
179  }
180  }
181  $html.= $this->getSkillHTML($s["skill_node_id"], 0, true);
182  }
183 
184  // list skills
185 // include_once("./Services/Skill/classes/class.ilPersonalSkillTableGUI.php");
186 // $sktab = new ilPersonalSkillTableGUI($this, "listSkills");
187 
188  $tpl->setContent($html);
189 
190  }
191 
200  function getSkillHTML($a_top_skill_id, $a_user_id = 0, $a_edit = false, $a_tref_id = 0)
201  {
202  global $ilUser, $lng, $ilCtrl, $ilSetting;
203 
204 //echo "<br>".$a_top_skill_id.":".$a_tref_id;
205  $this->tooltips = array();
206 
207  if ($a_user_id == 0)
208  {
209  $user = $ilUser;
210  }
211  else
212  {
213  $user = new ilObjUser($a_user_id);
214  }
215 
216  $tpl = new ilTemplate("tpl.skill_pres.html", true, true, "Services/Skill");
217 
218  include_once("./Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php");
219 
220  include_once("./Services/Skill/classes/class.ilSkillTree.php");
221  $stree = new ilSkillTree();
222 
223  include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
224  include_once("./Services/Skill/classes/class.ilSkillTreeNodeFactory.php");
225 
226  // general settings for the action drop down
227  include_once("Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
228  $act_list = new ilAdvancedSelectionListGUI();
229  $act_list->setListTitle($lng->txt("actions"));
230  $act_list->setSelectionHeaderClass("small");
231 // $act_list->setLinksMode("il_ContainerItemCommand2");
232  $act_list->setHeaderIcon(ilAdvancedSelectionListGUI::DOWN_ARROW_DARK);
233  $act_list->setUseImages(false);
234 
235  include_once("./Services/Skill/classes/class.ilVirtualSkillTree.php");
236  $vtree = new ilVirtualSkillTree();
237  $tref_id = $a_tref_id;
238  $skill_id = $a_top_skill_id;
239  if (ilSkillTreeNode::_lookupType($a_top_skill_id) == "sktr")
240  {
241  include_once("./Services/Skill/classes/class.ilSkillTemplateReference.php");
242  $tref_id = $a_top_skill_id;
243  $skill_id = ilSkillTemplateReference::_lookupTemplateId($a_top_skill_id);
244  }
245  $b_skills = $vtree->getSubTreeForCSkillId($skill_id.":".$tref_id, true);
246 //if ($a_tref_id > 0) $a_top_skill_id = $a_tref_id;
247  foreach ($b_skills as $bs)
248  {
249 $bs["id"] = $bs["skill_id"];
250 $bs["tref"] = $bs["tref_id"];
251 //var_dump($bs); exit;
252  $path = $stree->getSkillTreePath($bs["id"], $bs["tref"]);
253 
254  // check draft
255  foreach ($path as $p)
256  {
257  if ($p["status"] == ilSkillTreeNode::STATUS_DRAFT)
258  {
259  continue(2);
260  }
261  }
262  reset($path);
263 
264  $skill = ilSkillTreeNodeFactory::getInstance($bs["id"]);
265  $level_data = $skill->getLevelData();
266 
267  if ($this->mode == "gap")
268  {
269  if ($this->getProfileId() > 0)
270  {
271  $this->renderProfileTargetRow($tpl, $level_data, $a_top_skill_id, $bs["id"], $bs["tref"], $user->getId());
272  }
273  $this->renderActualLevelsRow($tpl, $level_data, $a_top_skill_id, $bs["id"], $bs["tref"], $user->getId());
274  $this->renderGapSelfEvalRow($tpl, $level_data, $a_top_skill_id, $bs["id"], $bs["tref"], $user->getId());
275  $this->renderSuggestedResources($tpl, $level_data, $bs["id"], $bs["tref"]);
276  }
277  else
278  {
279  if ($this->getProfileId() > 0)
280  {
281  $this->renderProfileTargetRow($tpl, $level_data, $a_top_skill_id, $bs["id"], $bs["tref"], $user->getId());
282  }
283  $this->renderMaterialsRow($tpl, $level_data, $a_top_skill_id, $bs["id"], $bs["tref"], $user->getId());
284 
285  // get date of self evaluation
286  $se_date = ilPersonalSkill::getSelfEvaluationDate($user->getId(), $a_top_skill_id, $bs["tref"], $bs["id"]);
287  $se_rendered = ($se_date == "")
288  ? true
289  : false;
290 
291  // get all object triggered entries and render them
292  foreach ($skill->getAllLevelEntriesOfUser($bs["tref"] , $user->getId()) as $level_entry)
293  {
294  // render the self evaluation at the correct position within the list of object triggered entries
295  if ($se_date > $level_entry["status_date"] && !$se_rendered)
296  {
297  $this->renderSelfEvaluationRow($tpl, $level_data, $a_top_skill_id, $bs["id"], $bs["tref"], $user->getId());
298  $se_rendered = true;
299  }
300  $this->renderObjectEvalRow($tpl, $level_data, $level_entry);
301  }
302 
303  // if not rendered yet, render self evaluation now
304  if (!$se_rendered)
305  {
306  $this->renderSelfEvaluationRow($tpl, $level_data, $a_top_skill_id, $bs["id"], $bs["tref"], $user->getId());
307  }
308  $this->renderSuggestedResources($tpl, $level_data, $bs["id"], $bs["tref"]);
309  }
310 
311  $too_low = true;
312  $current_target_level = 0;
313 
314  foreach ($level_data as $k => $v)
315  {
316  // level
317  $tpl->setCurrentBlock("level_td");
318  $tpl->setVariable("VAL_LEVEL", $v["title"]);
319  $tt_id = "skmg_skl_tt_".self::$skill_tt_cnt;
320  self::$skill_tt_cnt++;
321  $tpl->setVariable("TT_ID", $tt_id);
322  if ($v["description"] != "")
323  {
324  ilTooltipGUI::addTooltip($tt_id, $v["description"]);
325  }
326  $tpl->parseCurrentBlock();
327  }
328 
329 
330  $title = $sep = "";
331  $found = false;
332  foreach ($path as $p)
333  {
334  if ($found)
335  {
336  $title.= $sep.$p["title"];
337  $sep = " > ";
338  }
339  if ($a_top_skill_id == $p["child"])
340  {
341  $found = true;
342  }
343  }
344 
345  $tpl->setCurrentBlock("skill");
346  $tpl->setVariable("BSKILL_TITLE", $title);
347 /* $tpl->setVariable("TXT_LEVEL", $lng->txt("skmg_level"));
348  $tpl->setVariable("TXT_SELF_EVAL", $lng->txt("skmg_self_evaluation"));
349  if ($this->use_materials)
350  {
351  $tpl->setVariable("TXT_MATERIAL", $lng->txt("skmg_material"));
352  }*/
353  $tpl->setVariable("TXT_TARGET", $lng->txt("skmg_target_level"));
354  $tpl->setVariable("TXT_360_SURVEY", $lng->txt("skmg_360_survey"));
355 
356  if ($a_edit)
357  {
358  $act_list->flush();
359  $act_list->setId("act_".$a_top_skill_id."_".$bs["id"]."_".$bs["tref"]);
360  $ilCtrl->setParameterByClass("ilpersonalskillsgui", "skill_id", $a_top_skill_id);
361  $ilCtrl->setParameterByClass("ilpersonalskillsgui", "tref_id", $bs["tref"]);
362  $ilCtrl->setParameterByClass("ilpersonalskillsgui", "basic_skill_id", $bs["id"]);
363  if ($this->use_materials)
364  {
365  $act_list->addItem($lng->txt('skmg_assign_materials'), "",
366  $ilCtrl->getLinkTargetByClass("ilpersonalskillsgui", "assignMaterials"));
367  }
368  $act_list->addItem($lng->txt('skmg_self_evaluation'), "",
369  $ilCtrl->getLinkTargetByClass("ilpersonalskillsgui", "selfEvaluation"));
370  $tpl->setVariable("ACTIONS2", $act_list->getHTML());
371  }
372 
373  $tpl->parseCurrentBlock();
374 
375  }
376 
377  $tpl->setVariable("SKILL_TITLE", ilSkillTreeNode::_lookupTitle($skill_id, $tref_id));
378 
379  if ($a_edit)
380  {
381  $act_list->flush();
382  $act_list->setId("act_".$a_top_skill_id);
383  $ilCtrl->setParameterByClass("ilpersonalskillsgui", "skill_id", $a_top_skill_id);
384 // $act_list->addItem($lng->txt('skmg_assign_materials'), "",
385 // $ilCtrl->getLinkTargetByClass("ilpersonalskillsgui", "assignMaterials"));
386  $act_list->addItem($lng->txt('skmg_remove_skill'), "",
387  $ilCtrl->getLinkTargetByClass("ilpersonalskillsgui", "confirmSkillRemove"));
388  $tpl->setVariable("ACTIONS1", $act_list->getHTML());
389  }
390 
391 
392 
393  return $tpl->get();
394  }
395 
396  function getTooltipsJs()
397  {
398  return $this->tooltips;
399  }
400 
407  function getMaterialInfo($a_wsp_id, $a_user_id)
408  {
409  if(!$this->ws_tree)
410  {
411  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
412  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
413  $this->ws_tree = new ilWorkspaceTree($a_user_id);
414  $this->ws_access = new ilWorkspaceAccessHandler($caption);
415  }
416 
417  $obj_id = $this->ws_tree->lookupObjectId($a_wsp_id);
418  $caption = ilObject::_lookupTitle($obj_id);
419 
420  if(!$this->offline_mode)
421  {
422  $url = $this->ws_access->getGotoLink($a_wsp_id, $obj_id);
423  }
424  else
425  {
426  $url = $this->offline_mode."file_".$obj_id."/";
427 
428  // all possible material types for now
429  switch(ilObject::_lookupType($obj_id))
430  {
431  case "tstv":
432  include_once "Modules/Test/classes/class.ilObjTestVerification.php";
433  $obj = new ilObjTestVerification($obj_id, false);
434  $url .= $obj->getOfflineFilename();
435  break;
436 
437  case "excv":
438  include_once "Modules/Exercise/classes/class.ilObjExerciseVerification.php";
439  $obj = new ilObjExerciseVerification($obj_id, false);
440  $url .= $obj->getOfflineFilename();
441  break;
442 
443  case "crsv":
444  include_once "Modules/Course/classes/Verification/class.ilObjCourseVerification.php";
445  $obj = new ilObjCourseVerification($obj_id, false);
446  $url .= $obj->getOfflineFilename();
447  break;
448 
449  case "scov":
450  include_once "Modules/ScormAicc/classes/Verification/class.ilObjSCORMVerification.php";
451  $obj = new ilObjSCORMVerification($obj_id, false);
452  $url .= $obj->getOfflineFilename();
453  break;
454 
455  case "file":
456  $file = new ilObjFile($obj_id, false);
457  $url .= $file->getFilename();
458  break;
459  }
460  }
461 
462  return array($caption, $url);
463  }
464 
468  function addSkill()
469  {
470  global $ilUser, $ilCtrl, $lng;
471 
472  ilPersonalSkill::addPersonalSkill($ilUser->getId(), (int) $_GET["obj_id"]);
473 
474  ilUtil::sendSuccess($lng->txt("msg_object_modified"));
475  $ilCtrl->redirect($this, "listSkills");
476  }
477 
478 
479 
484  {
485  global $ilCtrl, $tpl, $lng;
486 
487  include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
488  if ($_GET["skill_id"] > 0)
489  {
490  $_POST["id"][] = $_GET["skill_id"];
491  }
492  if (!is_array($_POST["id"]) || count($_POST["id"]) == 0)
493  {
494  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
495  $ilCtrl->redirect($this, "listSkills");
496  }
497  else
498  {
499  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
500  $cgui = new ilConfirmationGUI();
501  $cgui->setFormAction($ilCtrl->getFormAction($this));
502  $cgui->setHeaderText($lng->txt("skmg_really_remove_skills"));
503  $cgui->setCancel($lng->txt("cancel"), "listSkills");
504  $cgui->setConfirm($lng->txt("delete"), "removeSkills");
505 
506  foreach ($_POST["id"] as $i)
507  {
508  $cgui->addItem("id[]", $i, ilSkillTreeNode::_lookupTitle($i));
509  }
510 
511  $tpl->setContent($cgui->getHTML());
512  }
513  }
514 
518  function removeSkills()
519  {
520  global $ilUser, $lng, $ilCtrl;
521 
522  if (is_array($_POST["id"]))
523  {
524  foreach ($_POST["id"] as $n_id)
525  {
526  ilPersonalSkill::removeSkill($ilUser->getId(), $n_id);
527  }
528  }
529 
530  ilUtil::sendSuccess($lng->txt("msg_object_modified"));
531  $ilCtrl->redirect($this, "listSkills");
532  }
533 
534 
535  //
536  // Materials assignments
537  //
538 
546  {
547  global $ilCtrl;
548 
549  $cskill = explode(":", $_POST["cskill_id"]);
550  $ilCtrl->setParameter($this, "skill_id", $_GET["skill_id"]);
551  $ilCtrl->setParameter($this, "basic_skill_id", (int) $cskill[0]);
552  $ilCtrl->setParameter($this, "tref_id", (int) $cskill[1]);
553  $ilCtrl->redirect($this, "assignMaterials");
554  }
555 
562  function assignMaterials()
563  {
564  global $ilTabs, $lng, $ilCtrl, $tpl, $ilToolbar;
565 
566  $ilTabs->setBackTarget($lng->txt("back"),
567  $ilCtrl->getLinkTarget($this, "listSkills"));
568 
569  $ilCtrl->saveParameter($this, "skill_id");
570  $ilCtrl->saveParameter($this, "basic_skill_id");
571  $ilCtrl->saveParameter($this, "tref_id");
572 
573  include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
574  $tpl->setTitle(ilSkillTreeNode::_lookupTitle((int) $_GET["skill_id"]));
575  $tpl->setTitleIcon(ilUtil::getImagePath("icon_".
576  ilSkillTreeNode::_lookupType((int) $_GET["skill_id"]).
577  "_b.png"));
578 
579  // basic skill selection
580  include_once("./Services/Skill/classes/class.ilVirtualSkillTree.php");
581  $vtree = new ilVirtualSkillTree();
582  $tref_id = 0;
583  $skill_id = (int) $_GET["skill_id"];
584  if (ilSkillTreeNode::_lookupType((int) $_GET["skill_id"]) == "sktr")
585  {
586  include_once("./Services/Skill/classes/class.ilSkillTemplateReference.php");
587  $tref_id = $_GET["skill_id"];
588  $skill_id = ilSkillTemplateReference::_lookupTemplateId($_GET["skill_id"]);
589  }
590  $bs = $vtree->getSubTreeForCSkillId($skill_id.":".$tref_id, true);
591 
592  $options = array();
593  include_once("./Services/Skill/classes/class.ilBasicSkill.php");
594  foreach ($bs as $b)
595  {
596  $options[$b["skill_id"].":".$b["tref_id"]] = ilBasicSkill::_lookupTitle($b["skill_id"], $b["tref_id"]);
597  }
598 
599 /* $cur_basic_skill_id = ((int) $_POST["basic_skill_id"] > 0)
600  ? (int) $_POST["basic_skill_id"]
601  : (((int) $_GET["basic_skill_id"] > 0)
602  ? (int) $_GET["basic_skill_id"]
603  : key($options));*/
604 
605 // $ilCtrl->setParameter($this, "basic_skill_id", $cur_basic_skill_id);
606 
607  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
608  $si = new ilSelectInputGUI($lng->txt("skmg_skill"), "cskill_id");
609  $si->setOptions($options);
610  $si->setValue($_GET["basic_skill_id"].":".((int) $_GET["tref_id"]));
611  $ilToolbar->addInputItem($si, true);
612  $ilToolbar->addFormButton($lng->txt("select"),
613  "switchAssignMaterials");
614 
615  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
616 
617  // table
618  include_once("./Services/Skill/classes/class.ilSkillAssignMaterialsTableGUI.php");
619  $tab = new ilSkillAssignMaterialsTableGUI($this, "assignMaterials",
620  (int) $_GET["skill_id"], (int) $_GET["tref_id"], (int) $_GET["basic_skill_id"]);
621 
622  $tpl->setContent($tab->getHTML());
623 
624  }
625 
626 
633  function assignMaterial()
634  {
635  global $tpl, $ilUser, $ilCtrl, $ilTabs, $lng, $ilSetting;
636 
637  if(!$ilSetting->get("disable_personal_workspace"))
638  {
639  ilUtil::sendInfo($lng->txt("skmg_ass_materials_from_workspace")." » <a href='ilias.php?baseClass=ilPersonalDesktopGUI&amp;cmd=jumpToWorkspace'>".$lng->txt("personal_workspace")."</a>");
640  }
641 
642  $ilCtrl->saveParameter($this, "skill_id");
643  $ilCtrl->saveParameter($this, "level_id");
644  $ilCtrl->saveParameter($this, "tref_id");
645  $ilCtrl->saveParameter($this, "basic_skill_id");
646 
647  $ilTabs->setBackTarget($lng->txt("back"),
648  $ilCtrl->getLinkTarget($this, "assignMaterials"));
649 
650  // get ws tree
651  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
652  $tree = new ilWorkspaceTree($ilUser->getId());
653 
654  // get access handler
655  include_once("./Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php");
656  $acc_handler = new ilWorkspaceAccessHandler($tree);
657 
658  // get es explorer
659  include_once("./Services/PersonalWorkspace/classes/class.ilWorkspaceExplorer.php");
661  'skill_wspexpand', $tree, $acc_handler);
662  $exp->setTargetGet('wsp_id');
663  $exp->setFiltered(false);
664  $exp->removeAllFormItemTypes();
665  $exp->addFormItemForType("file");
666  $exp->addFormItemForType("tstv");
667  $exp->addFormItemForType("excv");
668 
669  if($_GET['skill_wspexpand'] == '')
670  {
671  // not really used as session is already set [see above]
672  $expanded = $tree->readRootId();
673  }
674  else
675  {
676  $expanded = $_GET['skill_wspexpand'];
677  }
678  $exp->setCheckedItems(array((int)$_POST['wsp_id']));
679  $exp->setExpandTarget($ilCtrl->getLinkTarget($this, 'assignMaterial'));
680  $exp->setPostVar('wsp_id[]');
681  $exp->setExpand($expanded);
682  $exp->setOutput(0);
683 
684  // fill template
685  $mtpl = new ilTemplate("tpl.materials_selection.html", true, true, "Services/Skill");
686  $mtpl->setVariable("EXP", $exp->getOutput());
687 
688  // toolbars
689  $tb = new ilToolbarGUI();
690  $tb->addFormButton($lng->txt("select"),
691  "selectMaterial");
692  $tb->setFormAction($ilCtrl->getFormAction($this));
693  $tb->setOpenFormTag(true);
694  $tb->setCloseFormTag(false);
695  $mtpl->setVariable("TOOLBAR1", $tb->getHTML());
696  $tb->setOpenFormTag(false);
697  $tb->setCloseFormTag(true);
698  $mtpl->setVariable("TOOLBAR2", $tb->getHTML());
699 
700  $tpl->setContent($mtpl->get());
701  }
702 
706  function selectMaterial()
707  {
708  global $ilUser, $ilCtrl, $lng;
709 
710  include_once("./Services/Skill/classes/class.ilPersonalSkill.php");
711  if (is_array($_POST["wsp_id"]))
712  {
713  foreach ($_POST["wsp_id"] as $w)
714  {
715  ilPersonalSkill::assignMaterial($ilUser->getId(), (int) $_GET["skill_id"],
716  (int) $_GET["tref_id"],
717  (int) $_GET["basic_skill_id"], (int) $_GET["level_id"], (int) $w);
718  }
719  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
720  }
721 
722  $ilCtrl->saveParameter($this, "skill_id");
723  $ilCtrl->saveParameter($this, "level_id");
724  $ilCtrl->saveParameter($this, "tref_id");
725  $ilCtrl->saveParameter($this, "basic_skill_id");
726 
727  $ilCtrl->redirect($this, "assignMaterials");
728  }
729 
730 
734  function removeMaterial()
735  {
736  global $ilUser, $lng, $ilCtrl;
737 
738  ilPersonalSkill::removeMaterial($ilUser->getId(), (int) $_GET["tref_id"],
739  (int) $_GET["level_id"],
740  (int) $_GET["wsp_id"]);
741  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
742  $ilCtrl->saveParameter($this, array("skill_id", "basic_skill_id", "tref_id"));
743  $ilCtrl->redirect($this, "assignMaterials");
744  }
745 
746 
747  //
748  // Self evaluation
749  //
750 
758  {
759  global $ilCtrl;
760 
761  $cskill = explode(":", $_POST["cskill_id"]);
762  $ilCtrl->setParameter($this, "skill_id", $_GET["skill_id"]);
763  $ilCtrl->setParameter($this, "basic_skill_id", (int) $cskill[0]);
764  $ilCtrl->setParameter($this, "tref_id", (int) $cskill[1]);
765  $ilCtrl->redirect($this, "selfEvaluation");
766  }
767 
768 
775  function selfEvaluation()
776  {
777  global $ilTabs, $lng, $ilCtrl, $tpl, $ilToolbar;
778 
779  $ilTabs->setBackTarget($lng->txt("back"),
780  $ilCtrl->getLinkTarget($this, "listSkills"));
781 
782  $ilCtrl->saveParameter($this, "skill_id");
783  $ilCtrl->saveParameter($this, "basic_skill_id");
784  $ilCtrl->saveParameter($this, "tref_id");
785 
786  include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
787  $tpl->setTitle(ilSkillTreeNode::_lookupTitle((int) $_GET["skill_id"]));
788  $tpl->setTitleIcon(ilUtil::getImagePath("icon_".
789  ilSkillTreeNode::_lookupType((int) $_GET["skill_id"]).
790  "_b.png"));
791 
792  // basic skill selection
793  include_once("./Services/Skill/classes/class.ilVirtualSkillTree.php");
794  $vtree = new ilVirtualSkillTree();
795  $tref_id = 0;
796  $skill_id = (int) $_GET["skill_id"];
797  if (ilSkillTreeNode::_lookupType((int) $_GET["skill_id"]) == "sktr")
798  {
799  include_once("./Services/Skill/classes/class.ilSkillTemplateReference.php");
800  $tref_id = $_GET["skill_id"];
801  $skill_id = ilSkillTemplateReference::_lookupTemplateId($_GET["skill_id"]);
802  }
803  $bs = $vtree->getSubTreeForCSkillId($skill_id.":".$tref_id, true);
804 
805 
806  $options = array();
807  include_once("./Services/Skill/classes/class.ilBasicSkill.php");
808 
809  foreach ($bs as $b)
810  {
811  $options[$b["skill_id"].":".$b["tref_id"]] = ilBasicSkill::_lookupTitle($b["skill_id"], $b["tref_id"]);
812  }
813 
814 /* $cur_basic_skill_id = ((int) $_POST["basic_skill_id"] > 0)
815  ? (int) $_POST["basic_skill_id"]
816  : (((int) $_GET["basic_skill_id"] > 0)
817  ? (int) $_GET["basic_skill_id"]
818  : key($options));
819 
820  $ilCtrl->setParameter($this, "basic_skill_id", $cur_basic_skill_id);*/
821 
822  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
823  $si = new ilSelectInputGUI($lng->txt("skmg_skill"), "cskill_id");
824  $si->setOptions($options);
825  $si->setValue(((int) $_GET["basic_skill_id"]).":".((int) $_GET["tref_id"]));
826  $ilToolbar->addInputItem($si, true);
827  $ilToolbar->addFormButton($lng->txt("select"),
828  "switchSelfEvaluation");
829 
830  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
831 
832  // table
833  include_once("./Services/Skill/classes/class.ilSelfEvaluationSimpleTableGUI.php");
834  $tab = new ilSelfEvaluationSimpleTableGUI($this, "selfEvaluation",
835  (int) $_GET["skill_id"], (int) $_GET["tref_id"], (int) $_GET["basic_skill_id"]);
836 
837  $tpl->setContent($tab->getHTML());
838 
839  }
840 
845  {
846  global $ilUser, $lng, $ilCtrl;
847 
848  ilPersonalSkill::saveSelfEvaluation($ilUser->getId(), (int) $_GET["skill_id"],
849  (int) $_GET["tref_id"], (int) $_GET["basic_skill_id"], (int) $_POST["se"]);
850  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
851 
852 /* $ilCtrl->saveParameter($this, "skill_id");
853  $ilCtrl->saveParameter($this, "level_id");
854  $ilCtrl->saveParameter($this, "tref_id");
855  $ilCtrl->saveParameter($this, "basic_skill_id");*/
856 
857  $ilCtrl->redirect($this, "listSkills");
858 
859  }
860 
867  function listSkillsForAdd()
868  {
869  global $ilUser, $tpl, $ilCtrl, $lng, $ilTabs;
870 
871  $ilTabs->setBackTarget($lng->txt("back"),
872  $ilCtrl->getLinkTarget($this, ""));
873 
874  include_once("./Services/Skill/classes/class.ilPersonalSkillExplorerGUI.php");
875  $exp = new ilPersonalSkillExplorerGUI($this, "listSkillsForAdd", $this, "addSkill");
876  if ($exp->getHasSelectableNodes())
877  {
878  if (!$exp->handleCommand())
879  {
880  $tpl->setContent($exp->getHTML());
881  }
882  ilUtil::sendInfo($lng->txt("skmg_select_skill"));
883  }
884  else
885  {
886  ilUtil::sendInfo($lng->txt("skmg_no_nodes_selectable"));
887  }
888  }
889 
896  function listProfiles()
897  {
898  global $ilCtrl, $ilToolbar, $ilUser, $lng, $tpl;
899 
900  $profiles = ilSkillProfile::getProfilesOfUser($ilUser->getId());
901 
902  if (count($profiles) == 0)
903  {
904  return;
905  }
906 
907  // select profiles
908  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
909  $options = array();
910  foreach ($profiles as $p)
911  {
912  $options[$p["id"]] = $p["title"];
913  }
914 
915  if (!isset($options[$_GET["profile_id"]]))
916  {
917  $_GET["profile_id"] = (int) key($options);
918  $ilCtrl->setParameter($this, "profile_id", $_GET["profile_id"]);
919  }
920  $current_profile_id = $_GET["profile_id"];
921 
922  $si = new ilSelectInputGUI($lng->txt("skmg_profile"), "");
923  $si->setOptions($options);
924  $si->setValue($current_profile_id);
925  $ilToolbar->addInputItem($si, true);
926  $ilToolbar->addFormButton($lng->txt("select"),
927  "selectProfile");
928  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
929 
930  $this->setProfileId($current_profile_id);
931 
932  $tpl->setContent($this->getGapAnalysisHTML());
933  }
934 
940  function setGapAnalysisActualStatusModePerType($a_type, $a_cat_title = "")
941  {
942  $this->gap_mode = "max_per_type";
943  $this->gap_mode_type = $a_type;
944  $this->gap_cat_title = $a_cat_title;
945  $this->mode = "gap";
946  }
947 
953  function setGapAnalysisActualStatusModePerObject($a_obj_id, $a_cat_title = "")
954  {
955  $this->gap_mode = "max_per_object";
956  $this->gap_mode_obj_id = $a_obj_id;
957  $this->gap_cat_title = $a_cat_title;
958  $this->mode = "gap";
959  }
960 
967  function getGapAnalysisHTML($a_user_id = 0, $a_skills = null)
968  {
969  global $ilUser, $lng;
970 
971 // $this->setTabs("list_skills");
972 
973  if ($a_user_id == 0)
974  {
975  $user_id = $ilUser->getId();
976  }
977  else
978  {
979  $user_id = $a_user_id;
980  }
981 
982  $skills = array();
983  if ($this->getProfileId() > 0)
984  {
985  $profile = new ilSkillProfile($this->getProfileId());
986  $this->profile_levels = $profile->getSkillLevels();
987 
988  foreach ($this->profile_levels as $l)
989  {
990  $skills[] = array(
991  "base_skill_id" => $l["base_skill_id"],
992  "tref_id" => $l["tref_id"],
993  "level_id" => $l["level_id"]
994  );
995  }
996  }
997  else if (is_array($a_skills))
998  {
999  $skills = $a_skills;
1000  }
1001 
1002  // get actual levels for gap analysis
1003  $this->actual_levels = array();
1004  include_once("./Services/Skill/classes/class.ilBasicSkill.php");
1005  foreach ($skills as $sk)
1006  {
1007  $bs = new ilBasicSkill($sk["base_skill_id"]);
1008  if ($this->gap_mode == "max_per_type")
1009  {
1010  $max = $bs->getMaxLevelPerType($sk["tref_id"], $this->gap_mode_type, $user_id);
1011  $this->actual_levels[$sk["base_skill_id"]][$sk["tref_id"]] = $max;
1012  }
1013  else if ($this->gap_mode == "max_per_object")
1014  {
1015  $max = $bs->getMaxLevelPerObject($sk["tref_id"], $this->gap_mode_obj_id, $user_id);
1016  $this->actual_levels[$sk["base_skill_id"]][$sk["tref_id"]] = $max;
1017  }
1018  }
1019 
1020  $incl_self_eval = false;
1021  if (count($this->getGapAnalysisSelfEvalLevels() > 0))
1022  {
1023  $incl_self_eval = true;
1024  $self_vals = $this->getGapAnalysisSelfEvalLevels();
1025  }
1026 
1027  // output spider stuff
1028  if (count($skills) >= 3)
1029  {
1030  $max_cnt = 0;
1031  $leg_labels = array();
1032 //var_dump($this->profile_levels);
1033  //foreach ($this->profile_levels as $k => $l)
1034 
1035  // write target, actual and self counter to skill array
1036  foreach ($skills as $k => $l)
1037  {
1038  //$bs = new ilBasicSkill($l["base_skill_id"]);
1039  $bs = new ilBasicSkill($l["base_skill_id"]);
1040  $leg_labels[] = ilBasicSkill::_lookupTitle($l["base_skill_id"] , $l["tref_id"]);
1041  $levels = $bs->getLevelData();
1042  $cnt = 0;
1043  foreach ($levels as $lv)
1044  {
1045  $cnt++;
1046  if ($l["level_id"] == $lv["id"])
1047  {
1048  $skills[$k]["target_cnt"] = $cnt;
1049  }
1050  if ($this->actual_levels[$l["base_skill_id"]][$l["tref_id"]] == $lv["id"])
1051  {
1052  $skills[$k]["actual_cnt"] = $cnt;
1053  }
1054  if ($incl_self_eval)
1055  {
1056  if ($self_vals[$l["base_skill_id"]][$l["tref_id"]] == $lv["id"])
1057  {
1058  $skills[$k]["self_cnt"] = $cnt;
1059  }
1060  }
1061  $max_cnt = max($max_cnt, $cnt);
1062  }
1063  }
1064 
1065 // $leg_labels = array("AAAAA", "BBBBB", "CCCCC");
1066 
1067 //var_dump($this->profile_levels);
1068 //var_dump($this->actual_levels);
1069 
1070  include_once("./Services/Chart/classes/class.ilChart.php");
1071  $chart = new ilChart("gap_chart", 800, 300);
1072  $chart->setYAxisMax($max_cnt);
1073  $chart->setLegLabels($leg_labels);
1074 
1075  // target level
1076  $cd = new ilChartData("spider");
1077  $cd->setLabel($lng->txt("skmg_target_level"));
1078  $cd->setFill("true", "#A0A0A0");
1079 
1080  // other users
1081  $cd2 = new ilChartData("spider");
1082  if ($this->gap_cat_title != "")
1083  {
1084  $cd2->setLabel($this->gap_cat_title);
1085  }
1086  else if ($this->gap_mode == "max_per_type")
1087  {
1088  $cd2->setLabel($lng->txt("objs_".$this->gap_mode_type));
1089  }
1090  else if ($this->gap_mode == "max_per_object")
1091  {
1092  $cd2->setLabel(ilObject::_lookupTitle($this->gap_mode_obj_id));
1093  }
1094  $cd2->setFill("true", "#8080FF");
1095 
1096  // self evaluation
1097  if ($incl_self_eval)
1098  {
1099  $cd3 = new ilChartData("spider");
1100  $cd3->setLabel($lng->txt("skmg_self_evaluation"));
1101  $cd3->setFill("true", "#FF8080");
1102  }
1103 
1104  // fill in data
1105  $cnt = 0;
1106  foreach ($skills as $pl)
1107  {
1108  $cd->addPoint($cnt, (int) $pl["target_cnt"]);
1109  $cd2->addPoint($cnt, (int) $pl["actual_cnt"]);
1110  if ($incl_self_eval)
1111  {
1112  $cd3->addPoint($cnt, (int) $pl["self_cnt"]);
1113  }
1114  $cnt++;
1115  }
1116 
1117  // add data to chart
1118  if ($this->getProfileId() > 0)
1119  {
1120  $chart->addData($cd);
1121  }
1122  $chart->addData($cd2);
1123  if ($incl_self_eval && count($this->getGapAnalysisSelfEvalLevels()) > 0)
1124  {
1125  $chart->addData($cd3);
1126  }
1127 
1128  $lg = new ilChartLegend();
1129  $chart->setLegend($lg);
1130 
1131  $chart_html = $chart->getHTML();
1132  }
1133 
1134  $stree = new ilSkillTree();
1135  $html = "";
1136  foreach ($skills as $s)
1137  {
1138  $path = $stree->getSkillTreePath($s["base_skill_id"]);
1139 
1140  // check draft
1141  foreach ($path as $p)
1142  {
1143  if ($p["status"] == ilSkillTreeNode::STATUS_DRAFT)
1144  {
1145  continue(2);
1146  }
1147  }
1148  $html.= $this->getSkillHTML($s["base_skill_id"], $user_id, false, $s["tref_id"]);
1149  }
1150 
1151  // list skills
1152 // include_once("./Services/Skill/classes/class.ilPersonalSkillTableGUI.php");
1153 // $sktab = new ilPersonalSkillTableGUI($this, "listSkills");
1154 
1155  return $chart_html.$html;
1156  }
1157 
1164  function selectProfile()
1165  {
1166  global $ilCtrl;
1167 
1168  $ilCtrl->setParameter($this, "profile_id", $_GET["profile_id"]);
1169  $ilCtrl->redirect($this, "listProfiles");
1170  }
1171 
1178  function renderSelfEvaluationRow($a_tpl, $a_levels, $a_top_skill_id, $a_base_skill, $a_tref_id = 0, $a_user_id = 0)
1179  {
1180  global $ilUser, $lng;
1181 
1182  if ($a_user_id == 0)
1183  {
1184  $a_user_id = $ilUser->getId();
1185  }
1186 
1187  $se_date = ilPersonalSkill::getSelfEvaluationDate($a_user_id, $a_top_skill_id, $a_tref_id, $a_base_skill);
1188 
1189  $se_level = ilPersonalSkill::getSelfEvaluation($a_user_id,
1190  $a_top_skill_id, $a_tref_id, $a_base_skill);
1191  // check, if current self eval level is in current level data
1192  $valid_sel_level = false;
1193  if ($se_level > 0)
1194  {
1195  foreach ($a_levels as $k => $v)
1196  {
1197  if ($v["id"] == $se_level)
1198  {
1199  $valid_sel_level = true;
1200  }
1201  }
1202  }
1203  reset($a_levels);
1204  $found = false;
1205  foreach ($a_levels as $k => $v)
1206  {
1207  $a_tpl->setCurrentBlock("val_level_td");
1208  if ($valid_sel_level && $v["id"] == $se_level)
1209  {
1210  $a_tpl->setVariable("VAL_LEVEL", "x");
1211  $a_tpl->setVariable("TD_CLASS", "ilSkillSelf");
1212  }
1213  else
1214  {
1215  $a_tpl->setVariable("VAL_LEVEL", " ");
1216  }
1217  $a_tpl->parseCurrentBlock();
1218  /*if ($v["id"] == $se_level)
1219  {
1220  $found = true;
1221  }*/
1222  }
1223 
1224  $a_tpl->setCurrentBlock("value_row");
1226  $a_tpl->setVariable("TXT_VAL_TITLE", $lng->txt("skmg_self_evaluation").
1227  ", ".ilDatePresentation::formatDate(new ilDateTime($se_date, IL_CAL_DATETIME)));
1229  $a_tpl->parseCurrentBlock();
1230  }
1231 
1238  function renderMaterialsRow($a_tpl, $a_levels, $a_top_skill_id, $a_base_skill, $a_tref_id = 0, $a_user_id = 0)
1239  {
1240  global $ilUser, $lng;
1241 
1242  if ($a_user_id == 0)
1243  {
1244  $a_user_id = $ilUser->getId();
1245  }
1246 
1247  $got_mat = false;
1248  foreach ($a_levels as $v)
1249  {
1250  $mat_cnt = ilPersonalSkill::countAssignedMaterial($a_user_id,
1251  $a_tref_id, $v["id"]);
1252  if ($mat_cnt > 0)
1253  {
1254  $got_mat = true;
1255  }
1256  }
1257  if (!$got_mat)
1258  {
1259  return;
1260  }
1261 
1262  foreach ($a_levels as $k => $v)
1263  {
1264  $mat_cnt = ilPersonalSkill::countAssignedMaterial($a_user_id,
1265  $a_tref_id, $v["id"]);
1266  if ($mat_cnt == 0)
1267  {
1268  $a_tpl->setCurrentBlock("val_level_td");
1269  $a_tpl->setVariable("VAL_LEVEL", " ");
1270  $a_tpl->parseCurrentBlock();
1271  }
1272  else
1273  {
1274  // links to material files
1275  $a_tpl->setCurrentBlock("level_link");
1276 
1277  $mat_tt = array();
1278  $cnt = 1;
1279  foreach(ilPersonalSkill::getAssignedMaterial($a_user_id,
1280  $a_tref_id, $v["id"]) as $item)
1281  {
1282  $mat_data = $this->getMaterialInfo($item["wsp_id"], $a_user_id);
1283  $a_tpl->setVariable("HREF_LINK", $mat_data[1]);
1284  $a_tpl->setVariable("TXT_LINK", $cnt);
1285 
1286  // tooltip
1287  $mat_tt_id = "skmg_skl_tt_mat_".self::$skill_tt_cnt;
1288  self::$skill_tt_cnt++;
1289  $a_tpl->setVariable("LEVEL_LINK_ID", $mat_tt_id);
1290 
1291  if(!$this->offline_mode)
1292  {
1293  ilTooltipGUI::addTooltip($mat_tt_id, $mat_data[0]);
1294  }
1295  else
1296  {
1297  $this->tooltips[] = ilTooltipGUI::getTooltip($mat_tt_id, $mat_data[0]);
1298  }
1299 
1300  $a_tpl->parseCurrentBlock();
1301  $cnt++;
1302  }
1303 
1304  $a_tpl->setCurrentBlock("val_level_td");
1305  $a_tpl->setVariable("TD_CLASS", "ilSkillMat");
1306  $a_tpl->parseCurrentBlock();
1307  }
1308  }
1309 
1310  $a_tpl->setCurrentBlock("value_row");
1311  $a_tpl->setVariable("TXT_VAL_TITLE", $lng->txt("skmg_material"));
1312  $a_tpl->parseCurrentBlock();
1313  }
1314 
1321  function renderProfileTargetRow($a_tpl, $a_levels, $a_top_skill_id, $a_base_skill, $a_tref_id = 0, $a_user_id = 0)
1322  {
1323  global $ilUser, $lng;
1324 
1325  if ($a_user_id == 0)
1326  {
1327  $a_user_id = $ilUser->getId();
1328  }
1329 
1330  $profile = new ilSkillProfile($this->getProfileId());
1331  $profile_levels = $profile->getSkillLevels();
1332 
1333  foreach ($a_levels as $k => $v)
1334  {
1335  $a_tpl->setCurrentBlock("val_level_td");
1336  $target_level = false;
1337  foreach ($profile_levels as $pl)
1338  {
1339  if ($pl["level_id"] == $v["id"] &&
1340  $pl["base_skill_id"] == $v["skill_id"])
1341  {
1342  $target_level = true;
1343  $current_target_level = $v["id"];
1344  }
1345  }
1346  if ($target_level)
1347  {
1348  $too_low = true;
1349  $a_tpl->setVariable("VAL_LEVEL", "x");
1350  $a_tpl->setVariable("TD_CLASS", "ilSkillSelf");
1351  }
1352  else
1353  {
1354  $a_tpl->setVariable("VAL_LEVEL", " ");
1355  }
1356  $a_tpl->parseCurrentBlock();
1357  }
1358 
1359  $a_tpl->setCurrentBlock("value_row");
1360  $a_tpl->setVariable("TXT_VAL_TITLE", $lng->txt("skmg_target_level"));
1361  $a_tpl->parseCurrentBlock();
1362  }
1363 
1370  function renderActualLevelsRow($a_tpl, $a_levels, $a_top_skill_id, $a_base_skill, $a_tref_id = 0, $a_user_id = 0)
1371  {
1372  global $ilUser, $lng;
1373 
1374  if ($a_user_id == 0)
1375  {
1376  $a_user_id = $ilUser->getId();
1377  }
1378 
1379  $profile = new ilSkillProfile($this->getProfileId());
1380  $profile_levels = $profile->getSkillLevels();
1381 
1382  foreach ($a_levels as $k => $v)
1383  {
1384  $a_tpl->setCurrentBlock("val_level_td");
1385  $survey_level = false;
1386  if ($this->actual_levels[$v["skill_id"]][$a_tref_id] == $v["id"])
1387  {
1388  $survey_level = true;
1389  $too_low = false;
1390  }
1391  if ($survey_level)
1392  {
1393  $a_tpl->setVariable("VAL_LEVEL", "x");
1394  $a_tpl->setVariable("TD_CLASS", "ilSkillSelf");
1395  }
1396  else
1397  {
1398  $a_tpl->setVariable("VAL_LEVEL", " ");
1399  }
1400  $a_tpl->parseCurrentBlock();
1401  }
1402 
1403  $a_tpl->setCurrentBlock("value_row");
1404  if ($this->gap_cat_title != "")
1405  {
1406  $a_tpl->setVariable("TXT_VAL_TITLE", $this->gap_cat_title);
1407  }
1408  else if ($this->gap_mode == "max_per_type")
1409  {
1410  $a_tpl->setVariable("TXT_VAL_TITLE", $lng->txt("objs_".$this->gap_mode_type));
1411  }
1412  else if ($this->gap_mode == "max_per_object")
1413  {
1414  $a_tpl->setVariable("TXT_VAL_TITLE", ilObject::_lookupTitle($this->gap_mode_obj_id));
1415  }
1416 
1417  $a_tpl->parseCurrentBlock();
1418  }
1419 
1426  function renderGapSelfEvalRow($a_tpl, $a_levels, $a_top_skill_id, $a_base_skill, $a_tref_id = 0, $a_user_id = 0)
1427  {
1428  global $ilUser, $lng;
1429 
1430  if ($a_user_id == 0)
1431  {
1432  $a_user_id = $ilUser->getId();
1433  }
1434 
1435  $self_vals = $this->getGapAnalysisSelfEvalLevels();
1436  if (count($self_vals) == 0)
1437  {
1438  return;
1439  }
1440 
1441  foreach ($a_levels as $k => $v)
1442  {
1443  $a_tpl->setCurrentBlock("val_level_td");
1444  $survey_level = false;
1445  if ($self_vals[$v["skill_id"]][$a_tref_id] == $v["id"])
1446  {
1447  $survey_level = true;
1448  }
1449  if ($survey_level)
1450  {
1451  $a_tpl->setVariable("VAL_LEVEL", "x");
1452  $a_tpl->setVariable("TD_CLASS", "ilSkillSelf");
1453  }
1454  else
1455  {
1456  $a_tpl->setVariable("VAL_LEVEL", " ");
1457  }
1458  $a_tpl->parseCurrentBlock();
1459  }
1460 
1461  $a_tpl->setCurrentBlock("value_row");
1462  $a_tpl->setVariable("TXT_VAL_TITLE", $lng->txt("skmg_self_evaluation"));
1463 
1464  $a_tpl->parseCurrentBlock();
1465  }
1466 
1473  function renderObjectEvalRow($a_tpl, $a_levels, $a_level_entry)
1474  {
1475  $se_level = $a_level_entry["level_id"];
1476 
1477  // check, if current self eval level is in current level data
1478  $valid_sel_level = false;
1479  if ($se_level > 0)
1480  {
1481  foreach ($a_levels as $k => $v)
1482  {
1483  if ($v["id"] == $se_level)
1484  {
1485  $valid_sel_level = true;
1486  }
1487  }
1488  }
1489  reset($a_levels);
1490  $found = false;
1491  foreach ($a_levels as $k => $v)
1492  {
1493  $a_tpl->setCurrentBlock("val_level_td");
1494  if ($valid_sel_level && $v["id"] == $se_level)
1495  {
1496  $a_tpl->setVariable("VAL_LEVEL", "x");
1497  $a_tpl->setVariable("TD_CLASS", "ilSkillSelf");
1498  }
1499  else
1500  {
1501  $a_tpl->setVariable("VAL_LEVEL", " ");
1502  }
1503  $a_tpl->parseCurrentBlock();
1504  /*if ($v["id"] == $se_level)
1505  {
1506  $found = true;
1507  }*/
1508  }
1509 
1510  $a_tpl->setCurrentBlock("value_row");
1512  $a_tpl->setVariable("TXT_VAL_TITLE", $a_level_entry["trigger_title"].
1513  ", ".ilDatePresentation::formatDate(new ilDateTime($a_level_entry["status_date"], IL_CAL_DATETIME)));
1515  $a_tpl->parseCurrentBlock();
1516  }
1517 
1524  function renderSuggestedResources($a_tpl, $a_levels, $a_base_skill, $a_tref_id)
1525  {
1526  global $lng;
1527 
1528  // use a profile
1529  if ($this->getProfileId() > 0)
1530  {
1531  $profile = new ilSkillProfile($this->getProfileId());
1532  $profile_levels = $profile->getSkillLevels();
1533 
1534  $too_low = true;
1535  $current_target_level = 0;
1536 
1537 
1538  foreach ($a_levels as $k => $v)
1539  {
1540  foreach ($this->profile_levels as $pl)
1541  {
1542  if ($pl["level_id"] == $v["id"] &&
1543  $pl["base_skill_id"] == $v["skill_id"])
1544  {
1545  $too_low = true;
1546  $current_target_level = $v["id"];
1547  }
1548  }
1549 
1550  if ($this->actual_levels[$v["skill_id"]][0] == $v["id"])
1551  {
1552  $too_low = false;
1553  }
1554  }
1555 
1556  // suggested resources
1557  if ($too_low)
1558  {
1559  include_once("./Services/Skill/classes/class.ilSkillResources.php");
1560  $skill_res = new ilSkillResources($a_base_skill, $a_tref_id);
1561  $res = $skill_res->getResources();
1562  $imp_resources = array();
1563  foreach ($res as $level)
1564  {
1565  foreach($level as $r)
1566  {
1567  if ($r["imparting"] == true &&
1568  $current_target_level == $r["level_id"])
1569  {
1570  $imp_resources[] = $r;
1571  }
1572  }
1573  }
1574  foreach($imp_resources as $r)
1575  {
1576  $ref_id = $r["rep_ref_id"];
1577  $obj_id = ilObject::_lookupObjId($ref_id);
1578  $title = ilObject::_lookupTitle($obj_id);
1579  include_once("./Services/Link/classes/class.ilLink.php");
1580  $a_tpl->setCurrentBlock("resource_item");
1581  $a_tpl->setVariable("TXT_RES", $title);
1582  $a_tpl->setVariable("HREF_RES", ilLink::_getLink($ref_id));
1583  $a_tpl->parseCurrentBlock();
1584  }
1585  if (count($imp_resources) > 0)
1586  {
1587  $a_tpl->touchBlock("resources_list");
1588  $a_tpl->setCurrentBlock("resources");
1589  $a_tpl->setVariable("SUGGESTED_MAT_MESS", $lng->txt("skmg_skill_needs_impr_res"));
1590  $a_tpl->parseCurrentBlock();
1591  }
1592  else
1593  {
1594  $a_tpl->setCurrentBlock("resources");
1595  $a_tpl->setVariable("SUGGESTED_MAT_MESS", $lng->txt("skmg_skill_needs_impr_no_res"));
1596  $a_tpl->parseCurrentBlock();
1597  }
1598  }
1599  else
1600  {
1601  $a_tpl->setCurrentBlock("resources");
1602  $a_tpl->setVariable("SUGGESTED_MAT_MESS", $lng->txt("skmg_skill_no_needs_impr"));
1603  $a_tpl->parseCurrentBlock();
1604  }
1605  }
1606  else
1607  {
1608  // no profile, just list all resources
1609  include_once("./Services/Skill/classes/class.ilSkillResources.php");
1610  $skill_res = new ilSkillResources($a_base_skill, $a_tref_id);
1611  $res = $skill_res->getResources();
1612  // add $r["level_id"] info
1613  $any = false;
1614  foreach ($res as $level)
1615  {
1616  $available = false;
1617  $cl = 0;
1618  foreach($level as $r)
1619  {
1620  if ($r["imparting"])
1621  {
1622  $ref_id = $r["rep_ref_id"];
1623  $obj_id = ilObject::_lookupObjId($ref_id);
1624  $title = ilObject::_lookupTitle($obj_id);
1625  include_once("./Services/Link/classes/class.ilLink.php");
1626  $a_tpl->setCurrentBlock("resource_item");
1627  $a_tpl->setVariable("TXT_RES", $title);
1628  $a_tpl->setVariable("HREF_RES", ilLink::_getLink($ref_id));
1629  $a_tpl->parseCurrentBlock();
1630  $available = true;
1631  $any = true;
1632  $cl = $r["level_id"];
1633  }
1634  }
1635  if ($available)
1636  {
1637  $a_tpl->setCurrentBlock("resources_list_level");
1638  $a_tpl->setVariable("TXT_LEVEL", $lng->txt("skmg_level"));
1639  $a_tpl->setVariable("LEVEL_NAME", ilBasicSkill::lookupLevelTitle($cl));
1640  $a_tpl->parseCurrentBlock();
1641  $a_tpl->touchBlock("resources_list");
1642  }
1643  }
1644  if ($any)
1645  {
1646  $a_tpl->setCurrentBlock("resources");
1647  $a_tpl->setVariable("SUGGESTED_MAT_MESS", $lng->txt("skmg_suggested_resources"));
1648  $a_tpl->parseCurrentBlock();
1649  }
1650  }
1651  }
1652 
1653 }
1654 ?>