ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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  public static $skill_tt_cnt = 1;
23  protected $actual_levels = array();
25  protected $mode = "";
26  protected $history_view = false;
27  protected $intro_text = "";
28  protected $hidden_skills = array();
29 
33  protected $ctrl;
34 
38  protected $lng;
39 
43  protected $help;
44 
48  protected $setting;
49 
53  protected $user;
54 
58  protected $tpl;
59 
63  protected $tabs;
64 
68  protected $toolbar;
69 
73  protected $access;
74 
78  protected $ui_fac;
79 
83  protected $ui_ren;
84  protected $obj_id = 0;
85  protected $obj_skills = array();
86 
92  public function __construct()
93  {
94  global $DIC;
95 
96  $this->ctrl = $DIC->ctrl();
97  $this->lng = $DIC->language();
98  $this->help = $DIC["ilHelp"];
99  $this->setting = $DIC["ilSetting"];
100  $this->user = $DIC->user();
101  $this->tpl = $DIC["tpl"];
102  $this->tabs = $DIC->tabs();
103  $this->toolbar = $DIC->toolbar();
104  $this->access = $DIC->access();
105  $this->ui_fac = $DIC->ui()->factory();
106  $this->ui_ren = $DIC->ui()->renderer();
107 
109  $ilHelp = $this->help;
110  $lng = $this->lng;
112 
113 
114  $lng->loadLanguageModule('skmg');
115  $ilHelp->setScreenIdComponent("skill");
116 
117  $ilCtrl->saveParameter($this, "skill_id");
118  $ilCtrl->saveParameter($this, "tref_id");
119  $ilCtrl->saveParameter($this, "profile_id");
120 
121  $this->user_profiles = ilSkillProfile::getProfilesOfUser($this->user->getId());
122 
123  include_once("./Services/Skill/classes/class.ilSkillTree.php");
124  $this->skill_tree = new ilSkillTree();
125 
126  $this->use_materials = !$ilSetting->get("disable_personal_workspace");
127 
128  include_once("./Services/Skill/classes/class.ilSkillManagementSettings.php");
129  $this->skmg_settings = new ilSkillManagementSettings();
130  }
131 
137  public function setProfileId($a_val)
138  {
139  $this->profile_id = $a_val;
140  }
141 
147  public function getProfileId()
148  {
149  return $this->profile_id;
150  }
151 
157  public function setGapAnalysisSelfEvalLevels(array $a_val)
158  {
159  $this->gap_self_eval_levels = $a_val;
160  }
161 
168  {
170  }
171 
177  public function setHistoryView($a_val)
178  {
179  $this->history_view = $a_val;
180  }
181 
187  public function getHistoryView()
188  {
189  return $this->history_view;
190  }
191 
197  public function setIntroText($a_val)
198  {
199  $this->intro_text = $a_val;
200  }
201 
207  public function getIntroText()
208  {
209  return $this->intro_text;
210  }
211 
218  public function hideSkill($a_skill_id, $a_tref_id = 0)
219  {
220  $this->hidden_skills[] = $a_skill_id . ":" . $a_tref_id;
221  }
222 
229  public function determineCurrentProfile()
230  {
232 
233  if (count($this->user_profiles) == 0) {
234  return;
235  }
236  $current_prof_id = 0;
237  if ((int) $_GET["profile_id"] > 0) {
238  foreach ($this->user_profiles as $p) {
239  if ($p["id"] == (int) $_GET["profile_id"]) {
240  $current_prof_id = (int) $_GET["profile_id"];
241  }
242  }
243  }
244 
245  if ($current_prof_id == 0 && !(is_array($this->obj_skills) && $this->obj_id > 0)) {
246  $current_prof_id = $this->user_profiles[0]["id"];
247  }
248  $ilCtrl->setParameter($this, "profile_id", $current_prof_id);
249  $this->setProfileId($current_prof_id);
250  }
251 
258  public function setObjectSkills($a_obj_id, $a_skills = null)
259  {
260  $this->obj_id = $a_obj_id;
261  $this->obj_skills = $a_skills;
262  }
263 
270  public function executeCommand()
271  {
274  $lng = $this->lng;
275  $tpl = $this->tpl;
276 
277  $next_class = $ilCtrl->getNextClass($this);
278 
279 
280  // determin standard command
281  $std_cmd = "listSkills";
282 
283  $cmd = $ilCtrl->getCmd($std_cmd);
284 
285  $tpl->setTitle($lng->txt("skills"));
286  $tpl->setTitleIcon(ilUtil::getImagePath("icon_skmg.svg"));
287 
288  switch ($next_class) {
289  default:
290  $this->$cmd();
291  break;
292  }
293  return true;
294  }
295 
299  public function setTabs($a_activate)
300  {
302  $lng = $this->lng;
303  $ilTabs = $this->tabs;
304 
305  // list skills
306  $ilTabs->addTab(
307  "list_skills",
308  $lng->txt("skmg_selected_skills"),
309  $ilCtrl->getLinkTarget($this, "listSkills")
310  );
311 
312  if (count($this->user_profiles) > 0) {
313  $ilTabs->addTab(
314  "profile",
315  $lng->txt("skmg_assigned_profiles"),
316  $ilCtrl->getLinkTarget($this, "listAssignedProfile")
317  );
318  }
319 
320  // assign materials
321 
322  $ilTabs->activateTab($a_activate);
323  }
324 
325  public function setOfflineMode($a_file_path)
326  {
327  $this->offline_mode = $a_file_path;
328  }
329 
333  public function listSkills()
334  {
337  $lng = $this->lng;
338  $tpl = $this->tpl;
339  $ilToolbar = $this->toolbar;
340 
341  $this->setTabs("list_skills");
342 
343  include_once("./Services/Skill/classes/class.ilSkillTree.php");
344  $stree = new ilSkillTree();
345 
346  // skill selection / add new personal skill
347  $ilToolbar->addFormButton(
348  $lng->txt("skmg_add_skill"),
349  "listSkillsForAdd"
350  );
351  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
352 
354  $html = "";
355  foreach ($skills as $s) {
356  $path = $stree->getSkillTreePath($s["skill_node_id"]);
357 
358  // check draft
359  foreach ($path as $p) {
360  if ($p["status"] == ilSkillTreeNode::STATUS_DRAFT) {
361  continue(2);
362  }
363  }
364  $html.= $this->getSkillHTML($s["skill_node_id"], 0, true);
365  }
366 
367  // list skills
368  // include_once("./Services/Skill/classes/class.ilPersonalSkillTableGUI.php");
369  // $sktab = new ilPersonalSkillTableGUI($this, "listSkills");
370 
371  $tpl->setContent($html);
372  }
373 
382  public function getSkillHTML($a_top_skill_id, $a_user_id = 0, $a_edit = false, $a_tref_id = 0)
383  {
384  // user interface plugin slot + default rendering
385  include_once("./Services/UIComponent/classes/class.ilUIHookProcessor.php");
386  $uip = new ilUIHookProcessor(
387  "Services/Skill",
388  "personal_skill_html",
389  array("personal_skills_gui" => $this, "top_skill_id" => $a_top_skill_id, "user_id" => $a_user_id,
390  "edit" => $a_edit, "tref_id" => $a_tref_id)
391  );
392  if (!$uip->replaced()) {
393  $skill_html = $this->renderSkillHTML($a_top_skill_id, $a_user_id, $a_edit, $a_tref_id);
394  }
395  $skill_html = $uip->getHTML($skill_html);
396 
397  return $skill_html;
398  }
399 
406  public function renderSkillHTML($a_top_skill_id, $a_user_id = 0, $a_edit = false, $a_tref_id = 0)
407  {
410  $lng = $this->lng;
411 
412  $sub_panels = array();
413 
414  if ($a_user_id == 0) {
415  $user = $ilUser;
416  } else {
417  $user = new ilObjUser($a_user_id);
418  }
419 
420  $tpl = new ilTemplate("tpl.skill_pres.html", true, true, "Services/Skill");
421 
422  include_once("./Services/Skill/classes/class.ilSkillTree.php");
423  $stree = new ilSkillTree();
424 
425  include_once("./Services/Skill/classes/class.ilVirtualSkillTree.php");
426  $vtree = new ilVirtualSkillTree();
427  $tref_id = $a_tref_id;
428  $skill_id = $a_top_skill_id;
429  if (ilSkillTreeNode::_lookupType($a_top_skill_id) == "sktr") {
430  include_once("./Services/Skill/classes/class.ilSkillTemplateReference.php");
431  $tref_id = $a_top_skill_id;
432  $skill_id = ilSkillTemplateReference::_lookupTemplateId($a_top_skill_id);
433  }
434  $b_skills = $vtree->getSubTreeForCSkillId($skill_id . ":" . $tref_id, true);
435 
436  foreach ($b_skills as $bs) {
437  $bs["id"] = $bs["skill_id"];
438  $bs["tref"] = $bs["tref_id"];
439 
440  $path = $stree->getSkillTreePath($bs["id"], $bs["tref"]);
441 
442  $panel_comps = array();
443 
444 
445  // check draft
446  foreach ($path as $p) {
447  if ($p["status"] == ilSkillTreeNode::STATUS_DRAFT) {
448  continue(2);
449  }
450  }
451  reset($path);
452 
453  $skill = ilSkillTreeNodeFactory::getInstance($bs["id"]);
454  $level_data = $skill->getLevelData();
455 
456 
457  // skill description
458  $panel_comps[] = $this->ui_fac->legacy($this->getSkillDescription($skill));
459 
460 
461  if ($this->getProfileId() > 0) {
462  if (!$this->skmg_settings->getHideProfileBeforeSelfEval() ||
463  ilBasicSkill::hasSelfEvaluated($user->getId(), $bs["id"], $bs["tref"])) {
464  $panel_comps[] = $this->ui_fac->legacy($this->getProfileTargetItem($this->getProfileId(), $level_data, $bs["tref"]));
465  }
466  }
467 
468  if ($this->mode == "gap" && !$this->history_view) {
469  $panel_comps[] = $this->ui_fac->legacy($this->getActualGapItem($level_data, $bs["tref"]) . "");
470  $panel_comps[] = $this->ui_fac->legacy($this->getSelfEvalGapItem($level_data, $bs["tref"]) . "");
471  } else {
472  // get date of self evaluation
473  $se_date = ilPersonalSkill::getSelfEvaluationDate($user->getId(), $a_top_skill_id, $bs["tref"], $bs["id"]);
474  $se_rendered = ($se_date == "")
475  ? true
476  : false;
477 
478  // get all object triggered entries and render them
479  foreach ($skill->getAllHistoricLevelEntriesOfUser($bs["tref"], $user->getId(), ilBasicSkill::EVAL_BY_ALL) as $level_entry) {
480  // render the self evaluation at the correct position within the list of object triggered entries
481  if ($se_date > $level_entry["status_date"] && !$se_rendered) {
482  $se_rendered = true;
483  }
484  $panel_comps[] = $this->ui_fac->legacy($this->getEvalItem($level_data, $level_entry));
485  }
486  }
487 
488  // materials (new)
489  if ($this->mode != "gap") {
490  $mat = $this->getMaterials($level_data, $bs["tref"], $user->getId());
491  if ($mat != "") {
492  $panel_comps[] = $this->ui_fac->legacy($mat);
493  }
494  }
495 
496  // suggested resources
497  $sugg = $this->getSuggestedResources($this->getProfileId(), $level_data, $bs["id"], $bs["tref"]);
498  if ($sugg != "") {
499  $panel_comps[] = $this->ui_fac->legacy($sugg);
500  }
501 
502  $title = $sep = "";
503  $found = false;
504  foreach ($path as $p) {
505  if ($found) {
506  $title.= $sep . $p["title"];
507  $sep = " > ";
508  }
509  if ($a_top_skill_id == $p["child"]) {
510  $found = true;
511  }
512  }
513 
514  $sub = $this->ui_fac->panel()->sub((string) $title, $panel_comps);
515  if ($a_edit) {
516  $actions = array();
517  $ilCtrl->setParameterByClass("ilpersonalskillsgui", "skill_id", $a_top_skill_id);
518  $ilCtrl->setParameterByClass("ilpersonalskillsgui", "tref_id", $bs["tref"]);
519  $ilCtrl->setParameterByClass("ilpersonalskillsgui", "basic_skill_id", $bs["id"]);
520  if ($this->use_materials) {
521  $actions[] = $this->ui_fac->button()->shy(
522  $lng->txt('skmg_assign_materials'),
523  $ilCtrl->getLinkTargetByClass("ilpersonalskillsgui", "assignMaterials")
524  );
525  }
526  $actions[] = $this->ui_fac->button()->shy(
527  $lng->txt('skmg_self_evaluation'),
528  $ilCtrl->getLinkTargetByClass("ilpersonalskillsgui", "selfEvaluation")
529  );
530  $sub = $sub->withActions($this->ui_fac->dropdown()->standard($actions)->withLabel($lng->txt("actions")));
531  }
532 
533  $sub_panels[] = $sub;
534 
535  $tpl->parseCurrentBlock();
536  }
537 
538  $panel = $this->ui_fac->panel()->standard(
539  (string) ilSkillTreeNode::_lookupTitle($skill_id, $tref_id),
540  $sub_panels
541  );
542 
543  if ($a_edit && $this->getProfileId() == 0) {
544  $actions = array();
545 
546  $ilCtrl->setParameterByClass("ilpersonalskillsgui", "skill_id", $a_top_skill_id);
547  $actions[] = $this->ui_fac->button()->shy(
548  $lng->txt('skmg_remove_skill'),
549  $ilCtrl->getLinkTargetByClass("ilpersonalskillsgui", "confirmSkillRemove")
550  );
551 
552  $panel = $panel->withActions($this->ui_fac->dropdown()->standard($actions)->withLabel($lng->txt("actions")));
553  }
554 
555  return $this->ui_ren->render($panel);
556  }
557 
558 
565  public function getMaterialInfo($a_wsp_id, $a_user_id)
566  {
567  if (!$this->ws_tree) {
568  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
569  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
570  $this->ws_tree = new ilWorkspaceTree($a_user_id);
571  $this->ws_access = new ilWorkspaceAccessHandler($caption);
572  }
573 
574  $obj_id = $this->ws_tree->lookupObjectId($a_wsp_id);
575  $caption = ilObject::_lookupTitle($obj_id);
576 
577  if (!$this->offline_mode) {
578  $url = $this->ws_access->getGotoLink($a_wsp_id, $obj_id);
579  } else {
580  $url = $this->offline_mode . "file_" . $obj_id . "/";
581 
582  // all possible material types for now
583  switch (ilObject::_lookupType($obj_id)) {
584  case "tstv":
585  include_once "Modules/Test/classes/class.ilObjTestVerification.php";
586  $obj = new ilObjTestVerification($obj_id, false);
587  $url .= $obj->getOfflineFilename();
588  break;
589 
590  case "excv":
591  include_once "Modules/Exercise/classes/class.ilObjExerciseVerification.php";
592  $obj = new ilObjExerciseVerification($obj_id, false);
593  $url .= $obj->getOfflineFilename();
594  break;
595 
596  case "crsv":
597  include_once "Modules/Course/classes/Verification/class.ilObjCourseVerification.php";
598  $obj = new ilObjCourseVerification($obj_id, false);
599  $url .= $obj->getOfflineFilename();
600  break;
601 
602  case "scov":
603  include_once "Modules/ScormAicc/classes/Verification/class.ilObjSCORMVerification.php";
604  $obj = new ilObjSCORMVerification($obj_id, false);
605  $url .= $obj->getOfflineFilename();
606  break;
607 
608  case "file":
609  $file = new ilObjFile($obj_id, false);
610  $url .= $file->getFilename();
611  break;
612  }
613  }
614 
615  return array($caption, $url);
616  }
617 
621  public function addSkill()
622  {
625  $lng = $this->lng;
626 
627  ilPersonalSkill::addPersonalSkill($ilUser->getId(), (int) $_GET["obj_id"]);
628 
629  ilUtil::sendSuccess($lng->txt("msg_object_modified"));
630  $ilCtrl->redirect($this, "listSkills");
631  }
632 
633 
634 
638  public function confirmSkillRemove()
639  {
640  $lng = $this->lng;
641  $tpl = $this->tpl;
643 
644  include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
645  if ($_GET["skill_id"] > 0) {
646  $_POST["id"][] = $_GET["skill_id"];
647  }
648  if (!is_array($_POST["id"]) || count($_POST["id"]) == 0) {
649  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
650  $ilCtrl->redirect($this, "listSkills");
651  } else {
652  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
653  $cgui = new ilConfirmationGUI();
654  $cgui->setFormAction($ilCtrl->getFormAction($this));
655  $cgui->setHeaderText($lng->txt("skmg_really_remove_skills"));
656  $cgui->setCancel($lng->txt("cancel"), "listSkills");
657  $cgui->setConfirm($lng->txt("remove"), "removeSkills");
658 
659  foreach ($_POST["id"] as $i) {
660  $cgui->addItem("id[]", $i, ilSkillTreeNode::_lookupTitle($i));
661  }
662 
663  $tpl->setContent($cgui->getHTML());
664  }
665  }
666 
670  public function removeSkills()
671  {
674  $lng = $this->lng;
675 
676  if (is_array($_POST["id"])) {
677  foreach ($_POST["id"] as $n_id) {
678  ilPersonalSkill::removeSkill($ilUser->getId(), $n_id);
679  }
680  }
681 
682  ilUtil::sendSuccess($lng->txt("msg_object_modified"));
683  $ilCtrl->redirect($this, "listSkills");
684  }
685 
686 
687  //
688  // Materials assignments
689  //
690 
697  public function assignMaterials()
698  {
700  $lng = $this->lng;
701  $tpl = $this->tpl;
702  $ilToolbar = $this->toolbar;
703  $ilTabs = $this->tabs;
704 
705 
706  $ilTabs->setBackTarget(
707  $lng->txt("back"),
708  $ilCtrl->getLinkTarget($this, "listSkills")
709  );
710 
711  $ilCtrl->saveParameter($this, "skill_id");
712  $ilCtrl->saveParameter($this, "basic_skill_id");
713  $ilCtrl->saveParameter($this, "tref_id");
714 
715  include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
716  $tpl->setTitle(ilSkillTreeNode::_lookupTitle((int) $_GET["skill_id"]));
717  $tpl->setTitleIcon(ilUtil::getImagePath("icon_" .
718  ilSkillTreeNode::_lookupType((int) $_GET["skill_id"]) .
719  ".svg"));
720 
721  // basic skill selection
722  include_once("./Services/Skill/classes/class.ilVirtualSkillTree.php");
723  $vtree = new ilVirtualSkillTree();
724  $tref_id = 0;
725  $skill_id = (int) $_GET["skill_id"];
726  if (ilSkillTreeNode::_lookupType((int) $_GET["skill_id"]) == "sktr") {
727  include_once("./Services/Skill/classes/class.ilSkillTemplateReference.php");
728  $tref_id = $_GET["skill_id"];
729  $skill_id = ilSkillTemplateReference::_lookupTemplateId($_GET["skill_id"]);
730  }
731  $bs = $vtree->getSubTreeForCSkillId($skill_id . ":" . $tref_id, true);
732 
733  $options = array();
734  foreach ($bs as $b) {
735  //$options[$b["id"]] = ilSkillTreeNode::_lookupTitle($b["id"]);
736  $options[$b["skill_id"]] = ilSkillTreeNode::_lookupTitle($b["skill_id"]);
737  }
738 
739  $cur_basic_skill_id = ((int) $_POST["basic_skill_id"] > 0)
740  ? (int) $_POST["basic_skill_id"]
741  : (((int) $_GET["basic_skill_id"] > 0)
742  ? (int) $_GET["basic_skill_id"]
743  : key($options));
744 
745  $ilCtrl->setParameter($this, "basic_skill_id", $cur_basic_skill_id);
746 
747  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
748  $si = new ilSelectInputGUI($lng->txt("skmg_skill"), "basic_skill_id");
749  $si->setOptions($options);
750  $si->setValue($cur_basic_skill_id);
751  $ilToolbar->addInputItem($si, true);
752  $ilToolbar->addFormButton(
753  $lng->txt("select"),
754  "assignMaterials"
755  );
756 
757  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
758 
759  // table
760  include_once("./Services/Skill/classes/class.ilSkillAssignMaterialsTableGUI.php");
762  $this,
763  "assignMaterials",
764  (int) $_GET["skill_id"],
765  (int) $_GET["tref_id"],
766  $cur_basic_skill_id
767  );
768 
769  $tpl->setContent($tab->getHTML());
770  }
771 
772 
779  public function assignMaterial()
780  {
783  $lng = $this->lng;
784  $tpl = $this->tpl;
785  $ilTabs = $this->tabs;
787 
788  if (!$ilSetting->get("disable_personal_workspace")) {
789  ilUtil::sendInfo($lng->txt("skmg_ass_materials_from_workspace") . " » <a href='ilias.php?baseClass=ilPersonalDesktopGUI&amp;cmd=jumpToWorkspace'>" . $lng->txt("personal_workspace") . "</a>");
790  }
791 
792  $ilCtrl->saveParameter($this, "skill_id");
793  $ilCtrl->saveParameter($this, "level_id");
794  $ilCtrl->saveParameter($this, "tref_id");
795  $ilCtrl->saveParameter($this, "basic_skill_id");
796 
797  $ilTabs->setBackTarget(
798  $lng->txt("back"),
799  $ilCtrl->getLinkTarget($this, "assignMaterials")
800  );
801 
802 
803  include_once("./Services/PersonalWorkspace/classes/class.ilWorkspaceExplorerGUI.php");
804  $exp = new ilWorkspaceExplorerGUI($ilUser->getId(), $this, "assignMaterial", $this, "selectMaterial");
805  $exp->setTypeWhiteList(array("blog", "wsrt", "wfld", "file", "tstv", "excv"));
806  $exp->setSelectableTypes(array("file", "tstv", "excv"));
807  $exp->setSelectMode("wsp_id", true);
808  if ($exp->handleCommand()) {
809  return;
810  }
811 
812  // fill template
813  $mtpl = new ilTemplate("tpl.materials_selection.html", true, true, "Services/Skill");
814  $mtpl->setVariable("EXP", $exp->getHTML());
815 
816  // toolbars
817  $tb = new ilToolbarGUI();
818  $tb->addFormButton(
819  $lng->txt("select"),
820  "selectMaterial"
821  );
822  $tb->setFormAction($ilCtrl->getFormAction($this));
823  $tb->setOpenFormTag(true);
824  $tb->setCloseFormTag(false);
825  $mtpl->setVariable("TOOLBAR1", $tb->getHTML());
826  $tb->setOpenFormTag(false);
827  $tb->setCloseFormTag(true);
828  $mtpl->setVariable("TOOLBAR2", $tb->getHTML());
829 
830  $tpl->setContent($mtpl->get());
831  }
832 
836  public function selectMaterial()
837  {
840  $lng = $this->lng;
841 
842 
843  include_once("./Services/Skill/classes/class.ilPersonalSkill.php");
844  if (is_array($_POST["wsp_id"])) {
845  foreach ($_POST["wsp_id"] as $w) {
847  $ilUser->getId(),
848  (int) $_GET["skill_id"],
849  (int) $_GET["tref_id"],
850  (int) $_GET["basic_skill_id"],
851  (int) $_GET["level_id"],
852  (int) $w
853  );
854  }
855  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
856  }
857 
858  $ilCtrl->saveParameter($this, "skill_id");
859  $ilCtrl->saveParameter($this, "level_id");
860  $ilCtrl->saveParameter($this, "tref_id");
861  $ilCtrl->saveParameter($this, "basic_skill_id");
862 
863  $ilCtrl->redirect($this, "assignMaterials");
864  }
865 
866 
870  public function removeMaterial()
871  {
874  $lng = $this->lng;
875 
876 
878  $ilUser->getId(),
879  (int) $_GET["tref_id"],
880  (int) $_GET["level_id"],
881  (int) $_GET["wsp_id"]
882  );
883  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
884  $ilCtrl->redirect($this, "assignMaterials");
885  }
886 
887 
888  //
889  // Self evaluation
890  //
891 
898  public function selfEvaluation()
899  {
901  $lng = $this->lng;
902  $tpl = $this->tpl;
903  $ilToolbar = $this->toolbar;
904  $ilTabs = $this->tabs;
905 
906 
907  $ilTabs->setBackTarget(
908  $lng->txt("back"),
909  $ilCtrl->getLinkTarget($this, "listSkills")
910  );
911 
912  $ilCtrl->saveParameter($this, "skill_id");
913  $ilCtrl->saveParameter($this, "basic_skill_id");
914  $ilCtrl->saveParameter($this, "tref_id");
915 
916  include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
917  $tpl->setTitle(ilSkillTreeNode::_lookupTitle((int) $_GET["skill_id"]));
918  $tpl->setTitleIcon(ilUtil::getImagePath("icon_" .
919  ilSkillTreeNode::_lookupType((int) $_GET["skill_id"]) .
920  ".svg"));
921 
922  // basic skill selection
923  include_once("./Services/Skill/classes/class.ilVirtualSkillTree.php");
924  $vtree = new ilVirtualSkillTree();
925  $tref_id = 0;
926  $skill_id = (int) $_GET["skill_id"];
927  if (ilSkillTreeNode::_lookupType((int) $_GET["skill_id"]) == "sktr") {
928  include_once("./Services/Skill/classes/class.ilSkillTemplateReference.php");
929  $tref_id = $_GET["skill_id"];
930  $skill_id = ilSkillTemplateReference::_lookupTemplateId($_GET["skill_id"]);
931  }
932  $bs = $vtree->getSubTreeForCSkillId($skill_id . ":" . $tref_id, true);
933 
934 
935  $options = array();
936  foreach ($bs as $b) {
937  $options[$b["skill_id"]] = ilSkillTreeNode::_lookupTitle($b["skill_id"]);
938  }
939 
940  $cur_basic_skill_id = ((int) $_POST["basic_skill_id"] > 0)
941  ? (int) $_POST["basic_skill_id"]
942  : (((int) $_GET["basic_skill_id"] > 0)
943  ? (int) $_GET["basic_skill_id"]
944  : key($options));
945 
946  $ilCtrl->setParameter($this, "basic_skill_id", $cur_basic_skill_id);
947 
948  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
949  $si = new ilSelectInputGUI($lng->txt("skmg_skill"), "basic_skill_id");
950  $si->setOptions($options);
951  $si->setValue($cur_basic_skill_id);
952  $ilToolbar->addInputItem($si, true);
953  $ilToolbar->addFormButton(
954  $lng->txt("select"),
955  "selfEvaluation"
956  );
957 
958  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
959 
960  // table
961  include_once("./Services/Skill/classes/class.ilSelfEvaluationSimpleTableGUI.php");
963  $this,
964  "selfEvaluation",
965  (int) $_GET["skill_id"],
966  (int) $_GET["tref_id"],
967  $cur_basic_skill_id
968  );
969 
970  $tpl->setContent($tab->getHTML());
971  }
972 
976  public function saveSelfEvaluation()
977  {
980  $lng = $this->lng;
981 
983  $ilUser->getId(),
984  (int) $_GET["skill_id"],
985  (int) $_GET["tref_id"],
986  (int) $_GET["basic_skill_id"],
987  (int) $_POST["se"]
988  );
989  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
990 
991  /* $ilCtrl->saveParameter($this, "skill_id");
992  $ilCtrl->saveParameter($this, "level_id");
993  $ilCtrl->saveParameter($this, "tref_id");
994  $ilCtrl->saveParameter($this, "basic_skill_id");*/
995 
996  $ilCtrl->redirect($this, "listSkills");
997  }
998 
1005  public function listSkillsForAdd()
1006  {
1007  $ilCtrl = $this->ctrl;
1008  $lng = $this->lng;
1009  $tpl = $this->tpl;
1010  $ilTabs = $this->tabs;
1011 
1012 
1013  $ilTabs->setBackTarget(
1014  $lng->txt("back"),
1015  $ilCtrl->getLinkTarget($this, "")
1016  );
1017 
1018  include_once("./Services/Skill/classes/class.ilPersonalSkillExplorerGUI.php");
1019  $exp = new ilPersonalSkillExplorerGUI($this, "listSkillsForAdd", $this, "addSkill");
1020  if ($exp->getHasSelectableNodes()) {
1021  if (!$exp->handleCommand()) {
1022  $tpl->setContent($exp->getHTML());
1023  }
1024  ilUtil::sendInfo($lng->txt("skmg_select_skill"));
1025  } else {
1026  ilUtil::sendInfo($lng->txt("skmg_no_nodes_selectable"));
1027  }
1028  }
1029 
1035  public function listProfilesForGap()
1036  {
1037  $tpl = $this->tpl;
1038 
1039  //$a_user_id = $ilUser->getId();
1040 
1041  //$profiles = ilSkillProfile::getProfilesOfUser($a_user_id);
1042 
1043  if (count($this->user_profiles) == 0 && $this->obj_skills == null) {
1044  return;
1045  }
1046 
1047  $this->determineCurrentProfile();
1048  $this->showProfileSelectorToolbar();
1049 
1050  $tpl->setContent($this->getGapAnalysisHTML());
1051  }
1052 
1053 
1054 
1058  public function showProfileSelectorToolbar()
1059  {
1060  $ilToolbar = $this->toolbar;
1061  $lng = $this->lng;
1062  $ilCtrl = $this->ctrl;
1063 
1064  $options = array();
1065  if (is_array($this->obj_skills) && $this->obj_id > 0) {
1066  $options[0] = $lng->txt("obj_" . ilObject::_lookupType($this->obj_id)) . ": " . ilObject::_lookupTitle($this->obj_id);
1067  }
1068 
1069  foreach ($this->user_profiles as $p) {
1070  $options[$p["id"]] = $lng->txt("skmg_profile") . ": " . $p["title"];
1071  }
1072 
1073  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
1074  $si = new ilSelectInputGUI($lng->txt("skmg_profile"), "profile_id");
1075  $si->setOptions($options);
1076  $si->setValue($this->getProfileId());
1077  $ilToolbar->addInputItem($si, true);
1078  $ilToolbar->addFormButton(
1079  $lng->txt("select"),
1080  "selectProfile"
1081  );
1082  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
1083  }
1084 
1085 
1091  public function setGapAnalysisActualStatusModePerType($a_type, $a_cat_title = "")
1092  {
1093  $this->gap_mode = "max_per_type";
1094  $this->gap_mode_type = $a_type;
1095  $this->gap_cat_title = $a_cat_title;
1096  $this->mode = "gap";
1097  }
1098 
1104  public function setGapAnalysisActualStatusModePerObject($a_obj_id, $a_cat_title = "")
1105  {
1106  $this->gap_mode = "max_per_object";
1107  $this->gap_mode_obj_id = $a_obj_id;
1108  $this->gap_cat_title = $a_cat_title;
1109  $this->mode = "gap";
1110  }
1111 
1118  protected function getActualLevels($skills, $user_id)
1119  {
1120  // get actual levels for gap analysis
1121  $this->actual_levels = array();
1122  include_once("./Services/Skill/classes/class.ilBasicSkill.php");
1123  foreach ($skills as $sk) {
1124  $bs = new ilBasicSkill($sk["base_skill_id"]);
1125  if ($this->gap_mode == "max_per_type") {
1126  $max = $bs->getMaxLevelPerType($sk["tref_id"], $this->gap_mode_type, $user_id);
1127  $this->actual_levels[$sk["base_skill_id"]][$sk["tref_id"]] = $max;
1128  } elseif ($this->gap_mode == "max_per_object") {
1129  $max = $bs->getMaxLevelPerObject($sk["tref_id"], $this->gap_mode_obj_id, $user_id);
1130  $this->actual_levels[$sk["base_skill_id"]][$sk["tref_id"]] = $max;
1131  } else {
1132  $max = $bs->getMaxLevel($sk["tref_id"], $user_id);
1133  $this->actual_levels[$sk["base_skill_id"]][$sk["tref_id"]] = $max;
1134  }
1135  }
1136  }
1137 
1138 
1146  public function getGapAnalysisHTML($a_user_id = 0, $a_skills = null)
1147  {
1148  $ilUser = $this->user;
1149  $lng = $this->lng;
1150 
1151 
1152  if ($a_skills == null) {
1153  $a_skills = $this->obj_skills;
1154  }
1155 
1156  include_once("./Services/UIComponent/Panel/classes/class.ilPanelGUI.php");
1157 
1158  if ($this->getIntroText() != "") {
1159  $pan = ilPanelGUI::getInstance();
1160  $pan->setPanelStyle(ilPanelGUI::PANEL_STYLE_PRIMARY);
1161  $pan->setBody($this->getIntroText());
1162  $intro_html = $pan->getHTML();
1163  }
1164 
1165  // $this->setTabs("list_skills");
1166 
1167  if ($a_user_id == 0) {
1168  $user_id = $ilUser->getId();
1169  } else {
1170  $user_id = $a_user_id;
1171  }
1172 
1173  $skills = array();
1174  if ($this->getProfileId() > 0) {
1175  $profile = new ilSkillProfile($this->getProfileId());
1176  $this->profile_levels = $profile->getSkillLevels();
1177 
1178  foreach ($this->profile_levels as $l) {
1179  $skills[] = array(
1180  "base_skill_id" => $l["base_skill_id"],
1181  "tref_id" => $l["tref_id"],
1182  "level_id" => $l["level_id"]
1183  );
1184  }
1185  } elseif (is_array($a_skills)) {
1186  $skills = $a_skills;
1187  }
1188 
1189  // get actual levels for gap analysis
1190  $this->getActualLevels($skills, $user_id);
1191 
1192  $incl_self_eval = false;
1193  if (count($this->getGapAnalysisSelfEvalLevels()) > 0) {
1194  $incl_self_eval = true;
1195  $self_vals = $this->getGapAnalysisSelfEvalLevels();
1196  }
1197 
1198  // output spider stuff
1199  $all_chart_html = "";
1200 
1201  // determine skills that should be shown in the spider web
1202  $sw_skills = array();
1203  foreach ($skills as $sk) {
1204  if (!in_array($sk["base_skill_id"] . ":" . $sk["tref_id"], $this->hidden_skills)) {
1205  $sw_skills[] = $sk;
1206  }
1207  }
1208 
1209  if (count($sw_skills) >= 3) {
1210  $skill_packages = array();
1211 
1212  if (count($sw_skills) < 8) {
1213  $skill_packages[1] = $sw_skills;
1214  } else {
1215  $mod = count($sw_skills) % 7;
1216  $pkg_num = floor((count($sw_skills) - 1) / 7) + 1;
1217  $cpkg = 1;
1218  foreach ($sw_skills as $k => $s) {
1219  $skill_packages[$cpkg][$k] = $s;
1220  if ($mod < 3 && count($skill_packages) == ($pkg_num - 1) && count($skill_packages[$cpkg]) == 3+$mod) {
1221  $cpkg+=1;
1222  } elseif (count($skill_packages[$cpkg]) == 7) {
1223  $cpkg+=1;
1224  }
1225  }
1226  }
1227 
1228  $pkg_cnt = 0;
1229  foreach ($skill_packages as $pskills) {
1230  $pkg_cnt++;
1231  $max_cnt = 0;
1232  $leg_labels = array();
1233  //var_dump($this->profile_levels);
1234  //foreach ($this->profile_levels as $k => $l)
1235 
1236  // write target, actual and self counter to skill array
1237  foreach ($pskills as $k => $l) {
1238  //$bs = new ilBasicSkill($l["base_skill_id"]);
1239  $bs = new ilBasicSkill($l["base_skill_id"]);
1240  $leg_labels[] = ilBasicSkill::_lookupTitle($l["base_skill_id"], $l["tref_id"]);
1241  $levels = $bs->getLevelData();
1242  $cnt = 0;
1243  foreach ($levels as $lv) {
1244  $cnt++;
1245  if ($l["level_id"] == $lv["id"]) {
1246  $pskills[$k]["target_cnt"] = $cnt;
1247  }
1248  if ($this->actual_levels[$l["base_skill_id"]][$l["tref_id"]] == $lv["id"]) {
1249  $pskills[$k]["actual_cnt"] = $cnt;
1250  }
1251  if ($incl_self_eval) {
1252  if ($self_vals[$l["base_skill_id"]][$l["tref_id"]] == $lv["id"]) {
1253  $pskills[$k]["self_cnt"] = $cnt;
1254  }
1255  }
1256  $max_cnt = max($max_cnt, $cnt);
1257  }
1258  }
1259 
1260  include_once("./Services/Chart/classes/class.ilChart.php");
1261  $chart = ilChart::getInstanceByType(ilChart::TYPE_SPIDER, "gap_chart" . $pkg_cnt);
1262  $chart->setsize(800, 300);
1263  $chart->setYAxisMax($max_cnt);
1264  $chart->setLegLabels($leg_labels);
1265 
1266  // target level
1267  $cd = $chart->getDataInstance();
1268  $cd->setLabel($lng->txt("skmg_target_level"));
1269  $cd->setFill(true, "#A0A0A0");
1270 
1271  // other users
1272  $cd2 = $chart->getDataInstance();
1273  if ($this->gap_cat_title != "") {
1274  $cd2->setLabel($this->gap_cat_title);
1275  } elseif ($this->gap_mode == "max_per_type") {
1276  $cd2->setLabel($lng->txt("objs_" . $this->gap_mode_type));
1277  } elseif ($this->gap_mode == "max_per_object") {
1278  $cd2->setLabel(ilObject::_lookupTitle($this->gap_mode_obj_id));
1279  }
1280  //$cd2->setFill(true, "#dcb496");
1281  $cd2->setFill(true, "#FF8080");
1282  $cd2->setFill(true, "#cc8466");
1283 
1284  // self evaluation
1285  if ($incl_self_eval) {
1286  $cd3 = $chart->getDataInstance();
1287  $cd3->setLabel($lng->txt("skmg_self_evaluation"));
1288  $cd3->setFill(true, "#6ea03c");
1289  }
1290 
1291  // fill in data
1292  $cnt = 0;
1293  foreach ($pskills as $pl) {
1294  $cd->addPoint($cnt, (int) $pl["target_cnt"]);
1295  $cd2->addPoint($cnt, (int) $pl["actual_cnt"]);
1296  if ($incl_self_eval) {
1297  $cd3->addPoint($cnt, (int) $pl["self_cnt"]);
1298  }
1299  $cnt++;
1300  }
1301 
1302  // add data to chart
1303  if ($this->getProfileId() > 0) {
1304  $chart->addData($cd);
1305  }
1306  $chart->addData($cd2);
1307  if ($incl_self_eval && count($this->getGapAnalysisSelfEvalLevels()) > 0) {
1308  $chart->addData($cd3);
1309  }
1310 
1311  if ($pkg_cnt == 1) {
1312  $lg = new ilChartLegend();
1313  $chart->setLegend($lg);
1314  }
1315 
1316  $chart_html = $chart->getHTML();
1317  $all_chart_html.= $chart_html;
1318  }
1319 
1320  $pan = ilPanelGUI::getInstance();
1321  $pan->setPanelStyle(ilPanelGUI::PANEL_STYLE_PRIMARY);
1322  $pan->setBody($all_chart_html);
1323  $all_chart_html = $pan->getHTML();
1324  }
1325 
1326  $stree = new ilSkillTree();
1327  $html = "";
1328 
1329  // order skills per virtual skill tree
1330  include_once("./Services/Skill/classes/class.ilVirtualSkillTree.php");
1331  $vtree = new ilVirtualSkillTree();
1332  $skills = $vtree->getOrderedNodeset($skills, "base_skill_id", "tref_id");
1333  foreach ($skills as $s) {
1334  $path = $stree->getSkillTreePath($s["base_skill_id"]);
1335 
1336  // check draft
1337  foreach ($path as $p) {
1338  if ($p["status"] == ilSkillTreeNode::STATUS_DRAFT) {
1339  continue(2);
1340  }
1341  }
1342  $html.= $this->getSkillHTML($s["base_skill_id"], $user_id, false, $s["tref_id"]);
1343  }
1344 
1345  // list skills
1346  // include_once("./Services/Skill/classes/class.ilPersonalSkillTableGUI.php");
1347  // $sktab = new ilPersonalSkillTableGUI($this, "listSkills");
1348 
1349  return $intro_html . $all_chart_html . $html;
1350  }
1351 
1357  public function selectProfile()
1358  {
1359  $ilCtrl = $this->ctrl;
1360 
1361  $ilCtrl->setParameter($this, "profile_id", $_POST["profile_id"]);
1362  if ($this->mode == "gap") {
1363  $ilCtrl->redirect($this, "listProfilesForGap");
1364  } else {
1365  $ilCtrl->redirect($this, "listAssignedProfile");
1366  }
1367  }
1368 
1375  public function getMaterials($a_levels, $a_tref_id = 0, $a_user_id = 0)
1376  {
1377  $ilUser = $this->user;
1378  $lng = $this->lng;
1379 
1380  if ($a_user_id == 0) {
1381  $a_user_id = $ilUser->getId();
1382  }
1383 
1384  // only render, if materials given
1385  $got_mat = false;
1386  foreach ($a_levels as $v) {
1388  $a_user_id,
1389  $a_tref_id,
1390  $v["id"]
1391  );
1392  if ($mat_cnt > 0) {
1393  $got_mat = true;
1394  }
1395  }
1396  if (!$got_mat) {
1397  return "";
1398  }
1399 
1400  $tpl = new ilTemplate("tpl.skill_materials.html", true, true, "Services/Skill");
1401  foreach ($a_levels as $k => $v) {
1402  $got_mat = false;
1404  $a_user_id,
1405  $a_tref_id,
1406  $v["id"]
1407  ) as $item) {
1408  $tpl->setCurrentBlock("material");
1409  $mat_data = $this->getMaterialInfo($item["wsp_id"], $a_user_id);
1410  $tpl->setVariable("HREF_LINK", $mat_data[1]);
1411  $tpl->setVariable("TXT_LINK", $mat_data[0]);
1412  $tpl->parseCurrentBlock();
1413  $got_mat = true;
1414  }
1415  if ($got_mat) {
1416  $tpl->setCurrentBlock("level");
1417  $tpl->setVariable("LEVEL_VAL", $v["title"]);
1418  $tpl->parseCurrentBlock();
1419  }
1420  }
1421  $tpl->setVariable("TXT_MATERIAL", $lng->txt("skmg_materials"));
1422 
1423  return $tpl->get();
1424  }
1425 
1432  public function getProfileTargetItem($a_profile_id, $a_levels, $a_tref_id = 0)
1433  {
1434  $lng = $this->lng;
1435 
1436  $profile = new ilSkillProfile($a_profile_id);
1437  $profile_levels = $profile->getSkillLevels();
1438 
1439  $a_activated_levels = array();
1440 
1441  foreach ($a_levels as $k => $v) {
1442  foreach ($profile_levels as $pl) {
1443  if ($pl["level_id"] == $v["id"] &&
1444  $pl["base_skill_id"] == $v["skill_id"] &&
1445  $a_tref_id == $pl["tref_id"]) {
1446  $a_activated_levels[] = $pl["level_id"];
1447  }
1448  }
1449  }
1450 
1451  $tpl = new ilTemplate("tpl.skill_eval_item.html", true, true, "Services/Skill");
1452  $tpl->setVariable("SCALE_BAR", $this->getScaleBar($a_levels, $a_activated_levels));
1453 
1454  $tpl->setVariable("TYPE", $lng->txt("skmg_target_level"));
1455  $tpl->setVariable("TITLE", "");
1456 
1457  return $tpl->get();
1458  }
1459 
1466  public function getActualGapItem($a_levels, $a_tref_id = 0)
1467  {
1468  $lng = $this->lng;
1469 
1470  $a_activated_levels = array();
1471  foreach ($a_levels as $k => $v) {
1472  if ($this->actual_levels[$v["skill_id"]][$a_tref_id] == $v["id"]) {
1473  $a_activated_levels[] = $v["id"];
1474  }
1475  }
1476 
1477  if ($this->gap_cat_title != "") {
1478  $title = $this->gap_cat_title;
1479  } elseif ($this->gap_mode == "max_per_type") {
1480  $title = $lng->txt("objs_" . $this->gap_mode_type);
1481  } elseif ($this->gap_mode == "max_per_object") {
1482  $title = ilObject::_lookupTitle($this->gap_mode_obj_id);
1483  }
1484 
1485  $tpl = new ilTemplate("tpl.skill_eval_item.html", true, true, "Services/Skill");
1486  $tpl->setVariable("SCALE_BAR", $this->getScaleBar($a_levels, $a_activated_levels));
1487 
1488  $type = 1;
1489  $tpl->setVariable("TYPE", $lng->txt("skmg_eval_type_" . $type));
1490  if ($type > 0) {
1491  $tpl->touchBlock("st" . $type);
1492  $tpl->touchBlock("stb" . $type);
1493  }
1494 
1495  if ($title != $lng->txt("skmg_eval_type_" . $type)) {
1496  $tpl->setVariable("TITLE", $title);
1497  }
1498 
1499  return $tpl->get();
1500  }
1501 
1508  public function getSelfEvalGapItem($a_levels, $a_tref_id = 0)
1509  {
1510  $lng = $this->lng;
1511 
1512  $self_vals = $this->getGapAnalysisSelfEvalLevels();
1513  if (count($self_vals) == 0) {
1514  return;
1515  }
1516 
1517  $a_activated_levels = array();
1518  foreach ($a_levels as $k => $v) {
1519  if ($self_vals[$v["skill_id"]][$a_tref_id] == $v["id"]) {
1520  $a_activated_levels[] = $v["id"];
1521  }
1522  }
1523 
1524  $tpl = new ilTemplate("tpl.skill_eval_item.html", true, true, "Services/Skill");
1525  $tpl->setVariable("SCALE_BAR", $this->getScaleBar($a_levels, $a_activated_levels));
1526 
1527  $type = 3;
1528  $tpl->setVariable("TYPE", $lng->txt("skmg_eval_type_" . $type));
1529  if ($type > 0) {
1530  $tpl->touchBlock("st" . $type);
1531  $tpl->touchBlock("stb" . $type);
1532  }
1533 
1534  return $tpl->get();
1535  }
1536 
1537 
1544  public function getScaleBar($a_levels, $a_activated_levels)
1545  {
1546  $vals = array();
1547 
1548  if (!is_array($a_activated_levels)) {
1549  $a_activated_levels = array($a_activated_levels);
1550  }
1551 
1552  foreach ($a_levels as $level) {
1553  $vals[$level["title"]] = (in_array($level["id"], $a_activated_levels));
1554  }
1555  $scale_bar = $this->ui_fac->chart()->scaleBar($vals);
1556 
1557  return $this->ui_ren->render($scale_bar);
1558  }
1559 
1566  public function getEvalItem($a_levels, $a_level_entry)
1567  {
1568  $lng = $this->lng;
1569  $ilAccess = $this->access;
1570 
1571  $tpl = new ilTemplate("tpl.skill_eval_item.html", true, true, "Services/Skill");
1572  $tpl->setVariable("SCALE_BAR", $this->getScaleBar($a_levels, $a_level_entry["level_id"]));
1573 
1574  include_once("./Services/Skill/classes/class.ilSkillEval.php");
1576 
1577  if ($a_level_entry["self_eval"] == 1) {
1579  }
1580 
1581  if ($a_level_entry["trigger_obj_type"] == "tst") {
1583  }
1584 
1586  $title = ($a_level_entry["trigger_obj_id"] > 0)
1587  ? $a_level_entry["trigger_title"]
1588  : "";
1589 
1590  if ($a_level_entry["trigger_ref_id"] > 0
1591  && $ilAccess->checkAccess("read", "", $a_level_entry["trigger_ref_id"])) {
1592  include_once("./Services/Link/classes/class.ilLink.php");
1593  $title = "<a href='" . ilLink::_getLink($a_level_entry["trigger_ref_id"]) . "'>" . $title . "</a>";
1594  }
1595 
1596  $tpl->setVariable("TYPE", $lng->txt("skmg_eval_type_" . $type));
1597  if ($type > 0) {
1598  $tpl->touchBlock("st" . $type);
1599  $tpl->touchBlock("stb" . $type);
1600  }
1601  $tpl->setVariable("TITLE", $title);
1602  $tpl->setVariable(
1603  "DATE",
1604  ilDatePresentation::formatDate(new ilDate($a_level_entry["status_date"], IL_CAL_DATETIME))
1605  );
1606 
1608 
1609  return $tpl->get();
1610  }
1611 
1618  public function getSkillDescription($skill)
1619  {
1620  $level_data = $skill->getLevelData();
1621  $tpl = new ilTemplate("tpl.skill_desc.html", true, true, "Services/Skill");
1622 
1623  $desc_exists = false;
1624  foreach ($level_data as $l) {
1625  if ($l["description"] != "") {
1626  $desc_exists = true;
1627  }
1628  }
1629  reset($level_data);
1630  if ($desc_exists) {
1631  foreach ($level_data as $l) {
1632  $tpl->setCurrentBlock("level");
1633  $tpl->setVariable("LEVEL_VAL", $l["title"]);
1634  $tpl->setVariable("LEVEL_DESC", nl2br($l["description"]));
1635  $tpl->parseCurrentBlock();
1636  }
1637  }
1638 
1639  return $tpl->get();
1640  }
1641 
1648  public function getSuggestedResources($a_profile_id, $a_levels, $a_base_skill, $a_tref_id)
1649  {
1650  $lng = $this->lng;
1651 
1652  $tpl = new ilTemplate("tpl.suggested_resources.html", true, true, "Services/Skill");
1653 
1654  // use a profile
1655  if ($a_profile_id > 0) {
1656  $too_low = true;
1657  $current_target_level = 0;
1658 
1659  foreach ($a_levels as $k => $v) {
1660  foreach ($this->profile_levels as $pl) {
1661  if ($pl["level_id"] == $v["id"] &&
1662  $pl["base_skill_id"] == $v["skill_id"]) {
1663  $too_low = true;
1664  $current_target_level = $v["id"];
1665  }
1666  }
1667 
1668  if ($this->actual_levels[$v["skill_id"]][$a_tref_id] == $v["id"]) {
1669  $too_low = false;
1670  }
1671  }
1672 
1673  // suggested resources
1674  if ($too_low) {
1675  include_once("./Services/Skill/classes/class.ilSkillResources.php");
1676  $skill_res = new ilSkillResources($a_base_skill, $a_tref_id);
1677  $res = $skill_res->getResources();
1678  $imp_resources = array();
1679  foreach ($res as $level) {
1680  foreach ($level as $r) {
1681  if ($r["imparting"] == true &&
1682  $current_target_level == $r["level_id"]) {
1683  $imp_resources[] = $r;
1684  }
1685  }
1686  }
1687  foreach ($imp_resources as $r) {
1688  $ref_id = $r["rep_ref_id"];
1689  $obj_id = ilObject::_lookupObjId($ref_id);
1691  include_once("./Services/Link/classes/class.ilLink.php");
1692  $tpl->setCurrentBlock("resource_item");
1693  $tpl->setVariable("TXT_RES", $title);
1694  $tpl->setVariable("HREF_RES", ilLink::_getLink($ref_id));
1695  $tpl->parseCurrentBlock();
1696  }
1697  if (count($imp_resources) > 0) {
1698  $tpl->touchBlock("resources_list");
1699  $tpl->setVariable("SUGGESTED_MAT_MESS", $lng->txt("skmg_skill_needs_impr_res"));
1700  return $tpl->get();
1701  } else {
1702  $tpl->setVariable("SUGGESTED_MAT_MESS", $lng->txt("skmg_skill_needs_impr_no_res"));
1703  return $tpl->get();
1704  }
1705  } else {
1706  $tpl->setVariable("SUGGESTED_MAT_MESS", $lng->txt("skmg_skill_no_needs_impr"));
1707  return $tpl->get();
1708  }
1709  } else {
1710  // no profile, just list all resources
1711  include_once("./Services/Skill/classes/class.ilSkillResources.php");
1712  $skill_res = new ilSkillResources($a_base_skill, $a_tref_id);
1713  $res = $skill_res->getResources();
1714  // add $r["level_id"] info
1715  $any = false;
1716  foreach ($res as $level) {
1717  $available = false;
1718  $cl = 0;
1719  foreach ($level as $r) {
1720  if ($r["imparting"]) {
1721  $ref_id = $r["rep_ref_id"];
1722  $obj_id = ilObject::_lookupObjId($ref_id);
1724  include_once("./Services/Link/classes/class.ilLink.php");
1725  $tpl->setCurrentBlock("resource_item");
1726  $tpl->setVariable("TXT_RES", $title);
1727  $tpl->setVariable("HREF_RES", ilLink::_getLink($ref_id));
1728  $tpl->parseCurrentBlock();
1729  $available = true;
1730  $any = true;
1731  $cl = $r["level_id"];
1732  }
1733  }
1734  if ($available) {
1735  $tpl->setCurrentBlock("resources_list_level");
1736  $tpl->setVariable("TXT_LEVEL", $lng->txt("skmg_level"));
1737  $tpl->setVariable("LEVEL_NAME", ilBasicSkill::lookupLevelTitle($cl));
1738  $tpl->parseCurrentBlock();
1739  $tpl->touchBlock("resources_list");
1740  }
1741  }
1742  if ($any) {
1743  $tpl->setVariable("SUGGESTED_MAT_MESS", $lng->txt("skmg_suggested_resources"));
1744  return $tpl->get();
1745  }
1746  }
1747  return "";
1748  }
1749 
1756  public function listAssignedProfile()
1757  {
1758  $tpl = $this->tpl;
1759 
1760  $this->setTabs("profile");
1761 
1762  $this->determineCurrentProfile();
1763  $this->showProfileSelectorToolbar();
1764 
1765  $skills = array();
1766  if ($this->getProfileId() > 0) {
1767  $profile = new ilSkillProfile($this->getProfileId());
1768  $this->profile_levels = $profile->getSkillLevels();
1769 
1770  foreach ($this->profile_levels as $l) {
1771  $skills[] = array(
1772  "base_skill_id" => $l["base_skill_id"],
1773  "tref_id" => $l["tref_id"],
1774  "level_id" => $l["level_id"]
1775  );
1776  }
1777  }
1778 
1779  $this->getActualLevels($skills, $this->user->getId());
1780 
1781  // render
1782  $html = "";
1783  foreach ($skills as $s) {
1784  // todo draft check
1785  $html.= $this->getSkillHTML($s["base_skill_id"], 0, true, $s["tref_id"]);
1786  }
1787 
1788  $tpl->setContent($html);
1789  }
1790 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
saveSelfEvaluation()
Save self evaluation.
$lg
Definition: example_018.php:62
hideSkill($a_skill_id, $a_tref_id=0)
Hide skill.
setGapAnalysisSelfEvalLevels(array $a_val)
Set self evaluation levels for gap analysis.
const TYPE_SPIDER
setProfileId($a_val)
Set profile id.
const IL_CAL_DATETIME
This class represents a selection list property in a property form.
$type
global $DIC
Definition: saml.php:7
static lookupLevelTitle($a_id)
Lookup level title.
Chart legend.
Skill tree.
$_GET["client_id"]
getMaterialInfo($a_wsp_id, $a_user_id)
Get material file name and goto url.
const PANEL_STYLE_PRIMARY
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date public.
getMaterials($a_levels, $a_tref_id=0, $a_user_id=0)
Get materials.
getHistoryView()
Get history view.
Explorer for selecting a personal skill.
Access handler for personal workspace.
static setUseRelativeDates($a_status)
set use relative dates
static _lookupTitle($a_id)
lookup object title
$s
Definition: pwgen.php:45
addSkill()
Add personal skill.
getSkillHTML($a_top_skill_id, $a_user_id=0, $a_edit=false, $a_tref_id=0)
Get skill presentation HTML.
setTabs($a_activate)
Set tabs.
static getSelectedUserSkills($a_user_id)
Get personal selected user skills.
getEvalItem($a_levels, $a_level_entry)
Get eval item.
static saveSelfEvaluation($a_user_id, $a_top_skill, $a_tref_id, $a_basic_skill, $a_level)
Save self evaluation.
renderSkillHTML($a_top_skill_id, $a_user_id=0, $a_edit=false, $a_tref_id=0)
Render skill html.
getGapAnalysisHTML($a_user_id=0, $a_skills=null)
Get gap analysis html.
$w
Assign materials to skill levels table.
user()
Definition: user.php:4
removeMaterial()
Remove material.
Tree handler for personal workspace.
setTypeWhiteList($a_val)
Set type white list.
static _lookupType($a_obj_id)
Lookup Type.
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
assignMaterial()
Assign materials to skill level.
$a_type
Definition: workflow.php:92
Personal skills GUI class.
getScaleBar($a_levels, $a_activated_levels)
Get scale bar.
static getProfilesOfUser($a_user_id)
Get profiles of a user.
$r
Definition: example_031.php:79
getActualGapItem($a_levels, $a_tref_id=0)
selfEvaluation()
Assign materials to skill levels.
getGapAnalysisSelfEvalLevels()
Get self evaluation levels for gap analysis.
Class for single dates.
foreach($_POST as $key=> $value) $res
selectMaterial()
Select material.
static removeSkill($a_user_id, $a_skill_node_id)
Remove personal skill.
setIntroText($a_val)
Set intro text.
Self evaluation, second simplier implementation.
getActualLevels($skills, $user_id)
Get actual levels.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
getSuggestedResources($a_profile_id, $a_levels, $a_base_skill, $a_tref_id)
Render suggested resources.
static _lookupObjId($a_id)
special template class to simplify handling of ITX/PEAR
Manages resources for skills.
determineCurrentProfile()
Determine current profile id.
Explorer for selecting a personal workspace item.
getSelfEvalGapItem($a_levels, $a_tref_id=0)
static addPersonalSkill($a_user_id, $a_skill_node_id)
Add personal skill.
$ilUser
Definition: imgupload.php:18
static _lookupTemplateId($a_obj_id)
Lookup template ID.
setHistoryView($a_val)
Set history view.
listSkillsForAdd()
LIst skills for adding.
showProfileSelectorToolbar()
Show profile selector toolbar.
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
static _lookupTitle($a_obj_id, $a_tref_id=0)
Lookup Title.
static getAssignedMaterial($a_user_id, $a_tref_id, $a_level)
Get assigned material (for a skill level and user)
static getInstance()
Get instance.
global $l
Definition: afr.php:30
assignMaterials()
Assign materials to skill levels.
global $ilSetting
Definition: privfeed.php:17
static countAssignedMaterial($a_user_id, $a_tref_id, $a_level)
Get assigned material (for a skill level and user)
getProfileTargetItem($a_profile_id, $a_levels, $a_tref_id=0)
Get profile target item.
setGapAnalysisActualStatusModePerType($a_type, $a_cat_title="")
Set gap analysis actual status mode "per type".
executeCommand()
Execute command.
setObjectSkills($a_obj_id, $a_skills=null)
Set object skills.
getSkillDescription($skill)
Get level description.
$i
Definition: disco.tpl.php:19
$url
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
Basic Skill.
static hasSelfEvaluated($a_user_id, $a_skill_id, $a_tref_id)
Has use self evaluated a skill?
confirmSkillRemove()
Confirm skill remove.
$_POST["username"]
$html
Definition: example_001.php:87
static getSelfEvaluationDate($a_user_id, $a_top_skill, $a_tref_id, $a_basic_skill)
Get self evaluation.
static getInstanceByType($a_type, $a_id)
Get type instance.
static removeMaterial($a_user_id, $a_tref_id, $a_level_id, $a_wsp_id)
Remove material.
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
Confirmation screen class.
static assignMaterial($a_user_id, $a_top_skill, $a_tref_id, $a_basic_skill, $a_level, $a_wsp_id)
Assign material to skill level.
setGapAnalysisActualStatusModePerObject($a_obj_id, $a_cat_title="")
Set gap analysis actual status mode "per object".