ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilPersonalSkillsGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2020 ILIAS open source, Extended GPL, see docs/LICENSE */
4
12{
13 const LIST_SELECTED = "";
14 const LIST_PROFILES = "profiles";
15
16 protected $offline_mode;
17 protected $skill_tree;
18 public static $skill_tt_cnt = 1;
19 protected $actual_levels = array();
20 protected $gap_self_eval_levels = array();
21 protected $mode = "";
22 protected $history_view = false;
23 protected $trigger_objects_filter = array();
24 protected $intro_text = "";
25 protected $hidden_skills = array();
26
30 protected $ui;
31
35 protected $ctrl;
36
40 protected $lng;
41
45 protected $help;
46
50 protected $setting;
51
55 protected $user;
56
60 protected $tpl;
61
65 protected $tabs;
66
70 protected $toolbar;
71
75 protected $access;
76
80 protected $ui_fac;
81
85 protected $ui_ren;
86
90 protected $tree_service;
91
95 protected $obj_definition;
96
97 protected $obj_id = 0;
98 protected $obj_skills = array();
99
103 protected $filter;
104
109
115 public function __construct()
116 {
117 global $DIC;
118
119 $this->ctrl = $DIC->ctrl();
120 $this->lng = $DIC->language();
121 $this->help = $DIC["ilHelp"];
122 $this->setting = $DIC["ilSetting"];
123 $this->user = $DIC->user();
124 $this->tpl = $DIC["tpl"];
125 $this->tabs = $DIC->tabs();
126 $this->toolbar = $DIC->toolbar();
127 $this->access = $DIC->access();
128 $this->ui_fac = $DIC->ui()->factory();
129 $this->ui_ren = $DIC->ui()->renderer();
130 $this->ui = $DIC->ui();
131 $this->tree_service = $DIC->repositoryTree();
132 $this->obj_definition = $DIC["objDefinition"];
133
134 $ilCtrl = $this->ctrl;
135 $ilHelp = $this->help;
138
139
140 $lng->loadLanguageModule('skmg');
141 $ilHelp->setScreenIdComponent("skill");
142
143 $ilCtrl->saveParameter($this, "skill_id");
144 $ilCtrl->saveParameter($this, "tref_id");
145 $ilCtrl->saveParameter($this, "profile_id");
146 $ilCtrl->saveParameter($this, "list_mode");
147
148 $this->list_mode = $_GET["list_mode"];
149
150 $this->user_profiles = ilSkillProfile::getProfilesOfUser($this->user->getId());
151 $this->cont_profiles = array();
152
153 $this->skill_tree = new ilSkillTree();
154
155 $this->use_materials = !$ilSetting->get("disable_personal_workspace");
156
157 $this->skmg_settings = new ilSkillManagementSettings();
158
159 $this->filter = new ilPersonalSkillsFilterGUI();
160 }
161
167 public function getFilter()
168 {
169 return $this->filter;
170 }
171
172
178 public function setProfileId($a_val)
179 {
180 $this->profile_id = $a_val;
181 }
182
188 public function getProfileId()
189 {
190 return $this->profile_id;
191 }
192
198 public function setGapAnalysisSelfEvalLevels(array $a_val)
199 {
200 $this->gap_self_eval_levels = $a_val;
201 }
202
209 {
211 }
212
218 public function setHistoryView($a_val)
219 {
220 $this->history_view = $a_val;
221 }
222
228 public function getHistoryView()
229 {
230 return $this->history_view;
231 }
232
236 public function getTriggerObjectsFilter()
237 {
239 }
240
245 {
246 $this->trigger_objects_filter = $trigger_objects_filter;
247 }
248
254 public function setIntroText($a_val)
255 {
256 $this->intro_text = $a_val;
257 }
258
264 public function getIntroText()
265 {
266 return $this->intro_text;
267 }
268
275 public function hideSkill($a_skill_id, $a_tref_id = 0)
276 {
277 $this->hidden_skills[] = $a_skill_id . ":" . $a_tref_id;
278 }
279
286 public function determineCurrentProfile()
287 {
288 $ilCtrl = $this->ctrl;
289
290 if (count($this->user_profiles) == 0 && count($this->cont_profiles) == 0) {
291 return;
292 }
293 $current_prof_id = 0;
294 if ((int) $_GET["profile_id"] > 0) {
295 foreach ($this->user_profiles as $p) {
296 if ($p["id"] == (int) $_GET["profile_id"]) {
297 $current_prof_id = (int) $_GET["profile_id"];
298 }
299 }
300 }
301
302 if ((int) $_GET["profile_id"] > 0 && $current_prof_id == 0) {
303 foreach ($this->cont_profiles as $p) {
304 if ($p["profile_id"] == (int) $_GET["profile_id"]) {
305 $current_prof_id = (int) $_GET["profile_id"];
306 }
307 }
308 }
309
310 if ($current_prof_id == 0 && !(is_array($this->obj_skills) && $this->obj_id > 0)) {
311 $current_prof_id = $this->user_profiles[0]["id"];
312 }
313 $ilCtrl->setParameter($this, "profile_id", $current_prof_id);
314 $this->setProfileId($current_prof_id);
315 }
316
320 public function getObjectId() : int
321 {
322 return $this->obj_id;
323 }
324
328 public function getObjectSkills() : array
329 {
330 return $this->obj_skills;
331 }
332
339 public function setObjectSkills($a_obj_id, $a_skills = null)
340 {
341 $this->obj_id = $a_obj_id;
342 $this->obj_skills = $a_skills;
343 }
344
351 public function setObjectSkillProfiles(
352 ilContainerGlobalProfiles $a_g_profiles,
353 ilContainerLocalProfiles $a_l_profils
354 ) {
355 $this->cont_profiles = array_merge($a_g_profiles->getProfiles(), $a_l_profils->getProfiles());
356 }
357
364 public function executeCommand()
365 {
366 $ilCtrl = $this->ctrl;
370
371 $next_class = $ilCtrl->getNextClass($this);
372
373
374 // determin standard command
375 $std_cmd = "listSkills";
376
377 $cmd = $ilCtrl->getCmd($std_cmd);
378
379 //$tpl->setTitle($lng->txt("skills"));
380 //$tpl->setTitleIcon(ilUtil::getImagePath("icon_skmg.svg"));
381
382 switch ($next_class) {
383 default:
384 $this->$cmd();
385 break;
386 }
387 return true;
388 }
389
393 public function setTabs($a_activate)
394 {
395 $ilCtrl = $this->ctrl;
397 $ilTabs = $this->tabs;
398
399 // list skills
400 $ilCtrl->setParameter($this, "list_mode", self::LIST_SELECTED);
401 $ilTabs->addTab(
402 "list_skills",
403 $lng->txt("skmg_selected_skills"),
404 $ilCtrl->getLinkTarget($this, "render")
405 );
406
407 if (count($this->user_profiles) > 0) {
408 $ilCtrl->setParameter($this, "list_mode", self::LIST_PROFILES);
409 $ilTabs->addTab(
410 "profile",
411 $lng->txt("skmg_assigned_profiles"),
412 $ilCtrl->getLinkTarget($this, "render")
413 );
414 }
415
416 $ilCtrl->clearParameterByClass(get_class($this), "list_mode");
417
418 // assign materials
419
420 $ilTabs->activateTab($a_activate);
421 }
422
423 public function setOfflineMode($a_file_path)
424 {
425 $this->offline_mode = $a_file_path;
426 }
427
431 protected function render()
432 {
433 switch ($this->list_mode) {
435 $this->listAssignedProfile();
436 break;
437
438 default:
439 $this->listSkills();
440 break;
441 }
442 }
443
444
448 public function listSkills()
449 {
450 $ilCtrl = $this->ctrl;
453 $main_tpl = $this->tpl;
454 $ilToolbar = $this->toolbar;
455
456 $tpl = new ilTemplate("tpl.skill_filter.html", true, true, "Services/Skill");
457
458 $this->setTabs("list_skills");
459
460 $stree = new ilSkillTree();
461
462 // skill selection / add new personal skill
463 $ilToolbar->addFormButton(
464 $lng->txt("skmg_add_skill"),
465 "listSkillsForAdd"
466 );
467 $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
468
469 $filter_toolbar = new ilToolbarGUI();
470 $filter_toolbar->setFormAction($ilCtrl->getFormAction($this));
471 $this->getFilter()->addToToolbar($filter_toolbar, false);
472
474 $html = "";
475 foreach ($skills as $s) {
476 $path = $stree->getSkillTreePath($s["skill_node_id"]);
477
478 // check draft
479 foreach ($path as $p) {
480 if ($p["status"] == ilSkillTreeNode::STATUS_DRAFT) {
481 continue(2);
482 }
483 }
484 $html .= $this->getSkillHTML($s["skill_node_id"], 0, true);
485 }
486
487 // list skills
488
489 if ($html != "") {
490 $filter_toolbar->addFormButton($this->lng->txt("skmg_refresh_view"), "applyFilter");
491 $tpl->setVariable("FILTER", $filter_toolbar->getHTML());
492 $html = $tpl->get() . $html;
493 } else {
494 $box = $this->ui_fac->messageBox()->info($lng->txt("skmg_no_skills_selected_info"));
495 $html = $this->ui_ren->render($box);
496 }
497
498 $main_tpl->setContent($html);
499 }
500
504 protected function applyFilter()
505 {
506 $this->getFilter()->save();
507 $this->ctrl->redirect($this, "listSkills");
508 }
509
513 protected function applyFilterAssignedProfiles()
514 {
515 $this->getFilter()->save();
516 $this->ctrl->redirect($this, "listAssignedProfile");
517 }
518
519
528 public function getSkillHTML($a_top_skill_id, $a_user_id = 0, $a_edit = false, $a_tref_id = 0)
529 {
530 // user interface plugin slot + default rendering
531 $uip = new ilUIHookProcessor(
532 "Services/Skill",
533 "personal_skill_html",
534 array("personal_skills_gui" => $this, "top_skill_id" => $a_top_skill_id, "user_id" => $a_user_id,
535 "edit" => $a_edit, "tref_id" => $a_tref_id)
536 );
537 if (!$uip->replaced()) {
538 $skill_html = $this->renderSkillHTML($a_top_skill_id, $a_user_id, $a_edit, $a_tref_id);
539 }
540 $skill_html = $uip->getHTML($skill_html);
541
542 return $skill_html;
543 }
544
551 public function renderSkillHTML($a_top_skill_id, $a_user_id = 0, $a_edit = false, $a_tref_id = 0)
552 {
553 $ilCtrl = $this->ctrl;
556
557 $sub_panels = array();
558
559 if ($a_user_id == 0) {
560 $user = $ilUser;
561 } else {
562 $user = new ilObjUser($a_user_id);
563 }
564
565 $tpl = new ilTemplate("tpl.skill_pres.html", true, true, "Services/Skill");
566
567 $stree = new ilSkillTree();
568
569 $vtree = new ilVirtualSkillTree();
570 $tref_id = $a_tref_id;
571 $skill_id = $a_top_skill_id;
572 if (ilSkillTreeNode::_lookupType($a_top_skill_id) == "sktr") {
573 $tref_id = $a_top_skill_id;
574 $skill_id = ilSkillTemplateReference::_lookupTemplateId($a_top_skill_id);
575 }
576 $b_skills = $vtree->getSubTreeForCSkillId($skill_id . ":" . $tref_id, true);
577
578 foreach ($b_skills as $bs) {
579 $bs["id"] = $bs["skill_id"];
580 $bs["tref"] = $bs["tref_id"];
581
582 $path = $stree->getSkillTreePath($bs["id"], $bs["tref"]);
583
584 $panel_comps = array();
585
586
587 // check draft
588 foreach ($path as $p) {
589 if ($p["status"] == ilSkillTreeNode::STATUS_DRAFT) {
590 continue(2);
591 }
592 }
593 reset($path);
594
595 $skill = ilSkillTreeNodeFactory::getInstance($bs["id"]);
596 $level_data = $skill->getLevelData();
597
598
599 $title = $sep = "";
600 $description = "";
601 $found = false;
602 foreach ($path as $p) {
603 if ($found) {
604 $title .= $sep . $p["title"];
605 $sep = " > ";
606 $description = $p["description"];
607 }
608 if ($a_top_skill_id == $p["child"]) {
609 $found = true;
610 }
611 }
612
613 // skill description
614 $panel_comps[] = $this->ui_fac->legacy($this->getBasicSkillDescription((string) $description));
615
616
617 // skill level description
618 $panel_comps[] = $this->ui_fac->legacy($this->getSkillLevelDescription($skill));
619
620
621 if ($this->getProfileId() > 0) {
622 if (!$this->skmg_settings->getHideProfileBeforeSelfEval() ||
623 ilBasicSkill::hasSelfEvaluated($user->getId(), $bs["id"], $bs["tref"])) {
624 if ($this->getFilter()->showTargetLevel()) {
625 $panel_comps[] = $this->ui_fac->legacy($this->getProfileTargetItem($this->getProfileId(), $level_data, $bs["tref"]));
626 }
627 }
628 }
629
630 if ($this->mode == "gap" && !$this->history_view) {
631 $panel_comps[] = $this->ui_fac->legacy($this->getActualGapItem($level_data, $bs["tref"]) . "");
632 $panel_comps[] = $this->ui_fac->legacy($this->getSelfEvalGapItem($level_data, $bs["tref"]) . "");
633 } else {
634 // get date of self evaluation
635 $se_date = ilPersonalSkill::getSelfEvaluationDate($user->getId(), $a_top_skill_id, $bs["tref"], $bs["id"]);
636 $se_rendered = ($se_date == "")
637 ? true
638 : false;
639
640 // get all object triggered entries and render them
641 foreach ($skill->getAllHistoricLevelEntriesOfUser($bs["tref"], $user->getId(), ilBasicSkill::EVAL_BY_ALL) as $level_entry) {
642 if (count($this->getTriggerObjectsFilter()) && !in_array($level_entry['trigger_obj_id'], $this->getTriggerObjectsFilter())) {
643 continue;
644 }
645
646 // render the self evaluation at the correct position within the list of object triggered entries
647 if ($se_date > $level_entry["status_date"] && !$se_rendered) {
648 $se_rendered = true;
649 }
650 if ($this->getFilter()->isInRange($level_data, $level_entry)) {
651 $panel_comps[] = $this->ui_fac->legacy($this->getEvalItem($level_data, $level_entry));
652 }
653 }
654 }
655
656 // materials (new)
657 if ($this->mode != "gap") {
658 if ($this->getFilter()->showMaterialsRessources() && $this->use_materials) {
659 $mat = $this->getMaterials($level_data, $bs["tref"], $user->getId());
660 }
661 if ($mat != "") {
662 $panel_comps[] = $this->ui_fac->legacy($mat);
663 }
664 }
665
666 // suggested resources
667 if ($this->getFilter()->showMaterialsRessources()) {
668 $sugg = $this->getSuggestedResources($this->getProfileId(), $level_data, $bs["id"], $bs["tref"]);
669 }
670 if ($sugg != "") {
671 $panel_comps[] = $this->ui_fac->legacy($sugg);
672 }
673
674 $sub = $this->ui_fac->panel()->sub((string) $title, $panel_comps);
675 if ($a_edit) {
676 $actions = array();
677 $ilCtrl->setParameterByClass("ilpersonalskillsgui", "skill_id", $a_top_skill_id);
678 $ilCtrl->setParameterByClass("ilpersonalskillsgui", "tref_id", $bs["tref"]);
679 $ilCtrl->setParameterByClass("ilpersonalskillsgui", "basic_skill_id", $bs["id"]);
680 if ($this->use_materials) {
681 $actions[] = $this->ui_fac->button()->shy(
682 $lng->txt('skmg_assign_materials'),
683 $ilCtrl->getLinkTargetByClass("ilpersonalskillsgui", "assignMaterials")
684 );
685 }
686 $actions[] = $this->ui_fac->button()->shy(
687 $lng->txt('skmg_self_evaluation'),
688 $ilCtrl->getLinkTargetByClass("ilpersonalskillsgui", "selfEvaluation")
689 );
690 $sub = $sub->withActions($this->ui_fac->dropdown()->standard($actions)->withLabel($lng->txt("actions")));
691 }
692
693 $sub_panels[] = $sub;
694
695 $tpl->parseCurrentBlock();
696 }
697
698 $des = $this->getSkillCategoryDescription($skill_id, $tref_id);
699
700 //put the description of the skill category to the very top of the sub panels
701 $sub_panels = $this->ui_fac->legacy($des . $this->ui_ren->render($sub_panels));
702
703 $panel = $this->ui_fac->panel()->standard(
704 (string) ilSkillTreeNode::_lookupTitle($skill_id, $tref_id),
705 $sub_panels
706 );
707
708 if ($a_edit && $this->getProfileId() == 0) {
709 $actions = array();
710
711 $ilCtrl->setParameterByClass("ilpersonalskillsgui", "skill_id", $a_top_skill_id);
712 $actions[] = $this->ui_fac->button()->shy(
713 $lng->txt('skmg_remove_skill'),
714 $ilCtrl->getLinkTargetByClass("ilpersonalskillsgui", "confirmSkillRemove")
715 );
716
717 $panel = $panel->withActions($this->ui_fac->dropdown()->standard($actions)->withLabel($lng->txt("actions")));
718 }
719
720 return $this->ui_ren->render($panel);
721 }
722
723
730 public function getMaterialInfo($a_wsp_id, $a_user_id)
731 {
732 if (!$this->ws_tree) {
733 $this->ws_tree = new ilWorkspaceTree($a_user_id);
734 $this->ws_access = new ilWorkspaceAccessHandler($caption);
735 }
736
737 $obj_id = $this->ws_tree->lookupObjectId($a_wsp_id);
739
740 if (!$this->offline_mode) {
741 $url = $this->ws_access->getGotoLink($a_wsp_id, $obj_id);
742 } else {
743 $url = $this->offline_mode . "file_" . $obj_id . "/";
744
745 // all possible material types for now
747 case "tstv":
748 $obj = new ilObjTestVerification($obj_id, false);
749 $url .= $obj->getOfflineFilename();
750 break;
751
752 case "excv":
753 $obj = new ilObjExerciseVerification($obj_id, false);
754 $url .= $obj->getOfflineFilename();
755 break;
756
757 case "crsv":
758 $obj = new ilObjCourseVerification($obj_id, false);
759 $url .= $obj->getOfflineFilename();
760 break;
761
762 case "cmxv":
763 $obj = new ilObjCmiXapiVerification($obj_id, false);
764 $url .= $obj->getOfflineFilename();
765 break;
766
767 case "ltiv":
768 $obj = new ilObjLTIConsumerVerification($obj_id, false);
769 $url .= $obj->getOfflineFilename();
770 break;
771
772 case "scov":
773 $obj = new ilObjSCORMVerification($obj_id, false);
774 $url .= $obj->getOfflineFilename();
775 break;
776
777 case "file":
778 $file = new ilObjFile($obj_id, false);
779 $url .= $file->getFilename();
780 break;
781 }
782 }
783
784 return array($caption, $url);
785 }
786
790 public function addSkill()
791 {
792 $ilCtrl = $this->ctrl;
795
796 ilPersonalSkill::addPersonalSkill($ilUser->getId(), (int) $_GET["obj_id"]);
797
798 ilUtil::sendSuccess($lng->txt("msg_object_modified"));
799 $ilCtrl->redirect($this, "listSkills");
800 }
801
802
803
807 public function confirmSkillRemove()
808 {
811 $ilCtrl = $this->ctrl;
812
813 if ($_GET["skill_id"] > 0) {
814 $_POST["id"][] = $_GET["skill_id"];
815 }
816 if (!is_array($_POST["id"]) || count($_POST["id"]) == 0) {
817 ilUtil::sendInfo($lng->txt("no_checkbox"), true);
818 $ilCtrl->redirect($this, "listSkills");
819 } else {
820 $cgui = new ilConfirmationGUI();
821 $cgui->setFormAction($ilCtrl->getFormAction($this));
822 $cgui->setHeaderText($lng->txt("skmg_really_remove_skills"));
823 $cgui->setCancel($lng->txt("cancel"), "listSkills");
824 $cgui->setConfirm($lng->txt("remove"), "removeSkills");
825
826 foreach ($_POST["id"] as $i) {
827 $cgui->addItem("id[]", $i, ilSkillTreeNode::_lookupTitle($i));
828 }
829
830 $tpl->setContent($cgui->getHTML());
831 }
832 }
833
837 public function removeSkills()
838 {
839 $ilCtrl = $this->ctrl;
842
843 if (is_array($_POST["id"])) {
844 foreach ($_POST["id"] as $n_id) {
845 ilPersonalSkill::removeSkill($ilUser->getId(), $n_id);
846 }
847 }
848
849 ilUtil::sendSuccess($lng->txt("msg_object_modified"));
850 $ilCtrl->redirect($this, "listSkills");
851 }
852
853
854 //
855 // Materials assignments
856 //
857
864 public function assignMaterials()
865 {
866 $ilCtrl = $this->ctrl;
869 $ilToolbar = $this->toolbar;
870 $ilTabs = $this->tabs;
871
872
873 $ilTabs->setBackTarget(
874 $lng->txt("back"),
875 $ilCtrl->getLinkTarget($this, "render")
876 );
877
878 $ilCtrl->saveParameter($this, "skill_id");
879 $ilCtrl->saveParameter($this, "basic_skill_id");
880 $ilCtrl->saveParameter($this, "tref_id");
881
882 $tpl->setTitle(ilSkillTreeNode::_lookupTitle((int) $_GET["skill_id"]));
883 $tpl->setTitleIcon(ilUtil::getImagePath("icon_" .
884 ilSkillTreeNode::_lookupType((int) $_GET["skill_id"]) .
885 ".svg"));
886
887 // basic skill selection
888 $vtree = new ilVirtualSkillTree();
889 $tref_id = 0;
890 $skill_id = (int) $_GET["skill_id"];
891 if (ilSkillTreeNode::_lookupType((int) $_GET["skill_id"]) == "sktr") {
892 $tref_id = $_GET["skill_id"];
893 $skill_id = ilSkillTemplateReference::_lookupTemplateId($_GET["skill_id"]);
894 }
895 $bs = $vtree->getSubTreeForCSkillId($skill_id . ":" . $tref_id, true);
896
897 $options = array();
898 foreach ($bs as $b) {
899 //$options[$b["id"]] = ilSkillTreeNode::_lookupTitle($b["id"]);
900 $options[$b["skill_id"]] = ilSkillTreeNode::_lookupTitle($b["skill_id"]);
901 }
902
903 $cur_basic_skill_id = ((int) $_POST["basic_skill_id"] > 0)
904 ? (int) $_POST["basic_skill_id"]
905 : (((int) $_GET["basic_skill_id"] > 0)
906 ? (int) $_GET["basic_skill_id"]
907 : key($options));
908
909 $ilCtrl->setParameter($this, "basic_skill_id", $cur_basic_skill_id);
910
911 if (count($options) > 1) {
912 $si = new ilSelectInputGUI($lng->txt("skmg_skill"), "basic_skill_id");
913 $si->setOptions($options);
914 $si->setValue($cur_basic_skill_id);
915 $ilToolbar->addInputItem($si, true);
916 $ilToolbar->addFormButton(
917 $lng->txt("select"),
918 "assignMaterials"
919 );
920
921 $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
922 }
923
924 // table
926 $this,
927 "assignMaterials",
928 (int) $_GET["skill_id"],
929 (int) $_GET["tref_id"],
930 $cur_basic_skill_id
931 );
932
933 $tpl->setContent($tab->getHTML());
934 }
935
936
943 public function assignMaterial()
944 {
945 $ilCtrl = $this->ctrl;
949 $ilTabs = $this->tabs;
951 $ui = $this->ui;
952
953 if (!$ilSetting->get("disable_personal_workspace")) {
954 $url = 'ilias.php?baseClass=ilDashboardGUI&amp;cmd=jumpToWorkspace';
955 $mbox = $ui->factory()->messageBox()->info($lng->txt("skmg_ass_materials_from_workspace"))
956 ->withLinks([$ui->factory()->link()->standard(
957 $lng->txt("personal_resources"),
958 $url
959 )]);
960 $message = $ui->renderer()->render($mbox);
961 }
962
963 $ilCtrl->saveParameter($this, "skill_id");
964 $ilCtrl->saveParameter($this, "level_id");
965 $ilCtrl->saveParameter($this, "tref_id");
966 $ilCtrl->saveParameter($this, "basic_skill_id");
967
968 $ilTabs->setBackTarget(
969 $lng->txt("back"),
970 $ilCtrl->getLinkTarget($this, "assignMaterials")
971 );
972
973
974 $exp = new ilWorkspaceExplorerGUI($ilUser->getId(), $this, "assignMaterial", $this, "");
975 $exp->setTypeWhiteList(array("blog", "wsrt", "wfld", "file", "tstv", "excv"));
976 $exp->setSelectableTypes(array("file", "tstv", "excv"));
977 $exp->setSelectMode("wsp_id", true);
978 if ($exp->handleCommand()) {
979 return;
980 }
981
982 // fill template
983 $mtpl = new ilTemplate("tpl.materials_selection.html", true, true, "Services/Skill");
984 $mtpl->setVariable("EXP", $exp->getHTML());
985
986 // toolbars
987 $tb = new ilToolbarGUI();
988 $tb->addFormButton(
989 $lng->txt("select"),
990 "selectMaterial"
991 );
992 $tb->setFormAction($ilCtrl->getFormAction($this));
993 $tb->setOpenFormTag(true);
994 $tb->setCloseFormTag(false);
995 $mtpl->setVariable("TOOLBAR1", $tb->getHTML());
996 $tb->setOpenFormTag(false);
997 $tb->setCloseFormTag(true);
998 $mtpl->setVariable("TOOLBAR2", $tb->getHTML());
999
1000 $tpl->setContent($message . $mtpl->get());
1001 }
1002
1006 public function selectMaterial()
1007 {
1008 $ilCtrl = $this->ctrl;
1010 $lng = $this->lng;
1011
1012
1013 if (is_array($_POST["wsp_id"])) {
1014 foreach ($_POST["wsp_id"] as $w) {
1016 $ilUser->getId(),
1017 (int) $_GET["skill_id"],
1018 (int) $_GET["tref_id"],
1019 (int) $_GET["basic_skill_id"],
1020 (int) $_GET["level_id"],
1021 (int) $w
1022 );
1023 }
1024 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
1025 }
1026
1027 $ilCtrl->saveParameter($this, "skill_id");
1028 $ilCtrl->saveParameter($this, "level_id");
1029 $ilCtrl->saveParameter($this, "tref_id");
1030 $ilCtrl->saveParameter($this, "basic_skill_id");
1031
1032 $ilCtrl->redirect($this, "assignMaterials");
1033 }
1034
1035
1039 public function removeMaterial()
1040 {
1041 $ilCtrl = $this->ctrl;
1043 $lng = $this->lng;
1044
1045
1047 $ilUser->getId(),
1048 (int) $_GET["tref_id"],
1049 (int) $_GET["level_id"],
1050 (int) $_GET["wsp_id"]
1051 );
1052 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
1053 $ilCtrl->redirect($this, "assignMaterials");
1054 }
1055
1056
1057 //
1058 // Self evaluation
1059 //
1060
1067 public function selfEvaluation()
1068 {
1069 $ilCtrl = $this->ctrl;
1070 $lng = $this->lng;
1071 $tpl = $this->tpl;
1072 $ilToolbar = $this->toolbar;
1073 $ilTabs = $this->tabs;
1074
1075
1076 $ilTabs->setBackTarget(
1077 $lng->txt("back"),
1078 $ilCtrl->getLinkTarget($this, "render")
1079 );
1080
1081 $ilCtrl->saveParameter($this, "skill_id");
1082 $ilCtrl->saveParameter($this, "basic_skill_id");
1083 $ilCtrl->saveParameter($this, "tref_id");
1084
1085 $tpl->setTitle(ilSkillTreeNode::_lookupTitle((int) $_GET["skill_id"]));
1086 $tpl->setTitleIcon(ilUtil::getImagePath("icon_" .
1087 ilSkillTreeNode::_lookupType((int) $_GET["skill_id"]) .
1088 ".svg"));
1089
1090 // basic skill selection
1091 $vtree = new ilVirtualSkillTree();
1092 $tref_id = 0;
1093 $skill_id = (int) $_GET["skill_id"];
1094 if (ilSkillTreeNode::_lookupType((int) $_GET["skill_id"]) == "sktr") {
1095 $tref_id = $_GET["skill_id"];
1096 $skill_id = ilSkillTemplateReference::_lookupTemplateId($_GET["skill_id"]);
1097 }
1098 $bs = $vtree->getSubTreeForCSkillId($skill_id . ":" . $tref_id, true);
1099
1100
1101 $options = array();
1102 foreach ($bs as $b) {
1103 $options[$b["skill_id"]] = ilSkillTreeNode::_lookupTitle($b["skill_id"]);
1104 }
1105
1106 $cur_basic_skill_id = ((int) $_POST["basic_skill_id"] > 0)
1107 ? (int) $_POST["basic_skill_id"]
1108 : (((int) $_GET["basic_skill_id"] > 0)
1109 ? (int) $_GET["basic_skill_id"]
1110 : key($options));
1111
1112 $ilCtrl->setParameter($this, "basic_skill_id", $cur_basic_skill_id);
1113
1114 if (count($options) > 1) {
1115 $si = new ilSelectInputGUI($lng->txt("skmg_skill"), "basic_skill_id");
1116 $si->setOptions($options);
1117 $si->setValue($cur_basic_skill_id);
1118 $ilToolbar->addInputItem($si, true);
1119 $ilToolbar->addFormButton(
1120 $lng->txt("select"),
1121 "selfEvaluation"
1122 );
1123
1124 $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
1125 }
1126
1127 // table
1129 $this,
1130 "selfEvaluation",
1131 (int) $_GET["skill_id"],
1132 (int) $_GET["tref_id"],
1133 $cur_basic_skill_id
1134 );
1135
1136 $tpl->setContent($tab->getHTML());
1137 }
1138
1142 public function saveSelfEvaluation()
1143 {
1144 $ilCtrl = $this->ctrl;
1146 $lng = $this->lng;
1147
1149 $ilUser->getId(),
1150 (int) $_GET["skill_id"],
1151 (int) $_GET["tref_id"],
1152 (int) $_GET["basic_skill_id"],
1153 (int) $_POST["se"]
1154 );
1155 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
1156
1157 /* $ilCtrl->saveParameter($this, "skill_id");
1158 $ilCtrl->saveParameter($this, "level_id");
1159 $ilCtrl->saveParameter($this, "tref_id");
1160 $ilCtrl->saveParameter($this, "basic_skill_id");*/
1161
1162 $ilCtrl->redirect($this, "render");
1163 }
1164
1171 public function listSkillsForAdd()
1172 {
1173 $ilCtrl = $this->ctrl;
1174 $lng = $this->lng;
1175 $tpl = $this->tpl;
1176 $ilTabs = $this->tabs;
1177
1178
1179 $ilTabs->setBackTarget(
1180 $lng->txt("back"),
1181 $ilCtrl->getLinkTarget($this, "")
1182 );
1183
1184 $exp = new ilPersonalSkillExplorerGUI($this, "listSkillsForAdd", $this, "addSkill");
1185 if ($exp->getHasSelectableNodes()) {
1186 if (!$exp->handleCommand()) {
1187 $tpl->setContent($exp->getHTML());
1188 }
1189 ilUtil::sendInfo($lng->txt("skmg_select_skill"));
1190 } else {
1191 ilUtil::sendInfo($lng->txt("skmg_no_nodes_selectable"));
1192 }
1193 }
1194
1200 public function listProfilesForGap()
1201 {
1202 $tpl = $this->tpl;
1203
1204 //$a_user_id = $ilUser->getId();
1205
1206 //$profiles = ilSkillProfile::getProfilesOfUser($a_user_id);
1207
1208 if (count($this->cont_profiles) == 0 && $this->obj_skills == null) {
1209 return;
1210 }
1211
1212 $this->determineCurrentProfile();
1214
1215 $html = $this->showInfoBox() . $this->getGapAnalysisHTML();
1216 $tpl->setContent($html);
1217 }
1218
1219 public function showInfoBox() : string
1220 {
1221 $link = $this->ui_fac->link()->standard(
1222 $this->lng->txt("skmg_open_all_assigned_profiles"),
1223 $this->ctrl->getLinkTargetByClass(["ilDashboardGUI", "ilAchievementsGUI", "ilPersonalSkillsGUI"])
1224 );
1225 $box = $this->ui_fac->messageBox()->info($this->lng->txt("skmg_cont_profiles_info"))->withLinks([$link]);
1226
1227 return $this->ui_ren->render($box);
1228 }
1229
1230
1231
1236 {
1237 $ilToolbar = $this->toolbar;
1238 $lng = $this->lng;
1239 $ilCtrl = $this->ctrl;
1240
1241 $options = array();
1242 $cont_options = array();
1243 if (is_array($this->obj_skills) && $this->obj_id > 0) {
1244 $options[0] = $lng->txt("obj_" . ilObject::_lookupType($this->obj_id)) . ": " . ilObject::_lookupTitle($this->obj_id);
1245 foreach ($this->cont_profiles as $p) {
1246 $cont_options[$p["profile_id"]] = $p["title"];
1247 }
1248 asort($cont_options);
1249 $options = $options + $cont_options;
1250 }
1251 else {
1252 foreach ($this->user_profiles as $p) {
1253 $options[$p["id"]] = $p["title"];
1254 }
1255 }
1256
1257 $si = new ilSelectInputGUI($lng->txt("skmg_profile"), "profile_id");
1258 $si->setOptions($options);
1259 $si->setValue($this->getProfileId());
1260 $ilToolbar->addInputItem($si, true);
1261 $ilToolbar->addFormButton(
1262 $lng->txt("select"),
1263 "selectProfile"
1264 );
1265 $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
1266 }
1267
1268
1274 public function setGapAnalysisActualStatusModePerType($a_type, $a_cat_title = "")
1275 {
1276 $this->gap_mode = "max_per_type";
1277 $this->gap_mode_type = $a_type;
1278 $this->gap_cat_title = $a_cat_title;
1279 $this->mode = "gap";
1280 }
1281
1287 public function setGapAnalysisActualStatusModePerObject($a_obj_id, $a_cat_title = "")
1288 {
1289 $this->gap_mode = "max_per_object";
1290 $this->gap_mode_obj_id = $a_obj_id;
1291 $this->gap_cat_title = $a_cat_title;
1292 $this->mode = "gap";
1293 }
1294
1301 protected function getActualLevels($skills, $user_id)
1302 {
1303 // get actual levels for gap analysis
1304 $this->actual_levels = array();
1305 foreach ($skills as $sk) {
1306 $bs = new ilBasicSkill($sk["base_skill_id"]);
1307 if ($this->gap_mode == "max_per_type") {
1308 $max = $bs->getMaxLevelPerType($sk["tref_id"], $this->gap_mode_type, $user_id);
1309 $this->actual_levels[$sk["base_skill_id"]][$sk["tref_id"]] = $max;
1310 } elseif ($this->gap_mode == "max_per_object") {
1311 if ($this->obj_definition->isContainer(\ilObject::_lookupType($this->gap_mode_obj_id))) {
1312 $sub_objects = $this->tree_service->getSubTree(
1313 $this->tree_service->getNodeData((int) current(\ilObject::_getAllReferences($this->gap_mode_obj_id))),
1314 false,
1316 );
1317 $max = 0;
1318 foreach ($sub_objects as $ref_id) {
1320 $max_tmp = $bs->getMaxLevelPerObject($sk["tref_id"], $obj_id, $user_id);
1321 if ($max_tmp > $max) {
1322 $max = $max_tmp;
1323 }
1324 }
1325 } else {
1326 $max = $bs->getMaxLevelPerObject($sk["tref_id"], $this->gap_mode_obj_id, $user_id);
1327 }
1328 $this->actual_levels[$sk["base_skill_id"]][$sk["tref_id"]] = $max;
1329 } else {
1330 $max = $bs->getMaxLevel($sk["tref_id"], $user_id);
1331 $this->actual_levels[$sk["base_skill_id"]][$sk["tref_id"]] = $max;
1332 }
1333 }
1334 }
1335
1336
1344 public function getGapAnalysisHTML($a_user_id = 0, $a_skills = null)
1345 {
1347 $lng = $this->lng;
1348
1349 // needed fix for profiles in gap view, because there is no filter shown (yet)
1350 $this->getFilter()->clear();
1351
1352 if ($a_skills == null) {
1353 $a_skills = $this->obj_skills;
1354 }
1355
1356
1357 if ($this->getIntroText() != "") {
1358 $pan = ilPanelGUI::getInstance();
1359 $pan->setPanelStyle(ilPanelGUI::PANEL_STYLE_PRIMARY);
1360 $pan->setBody($this->getIntroText());
1361 $intro_html = $pan->getHTML();
1362 }
1363
1364 // $this->setTabs("list_skills");
1365
1366 if ($a_user_id == 0) {
1367 $user_id = $ilUser->getId();
1368 } else {
1369 $user_id = $a_user_id;
1370 }
1371
1372 $skills = array();
1373 if ($this->getProfileId() > 0) {
1374 $profile = new ilSkillProfile($this->getProfileId());
1375 $this->profile_levels = $profile->getSkillLevels();
1376
1377 foreach ($this->profile_levels as $l) {
1378 $skills[] = array(
1379 "base_skill_id" => $l["base_skill_id"],
1380 "tref_id" => $l["tref_id"],
1381 "level_id" => $l["level_id"]
1382 );
1383 }
1384 } elseif (is_array($a_skills)) {
1385 $skills = $a_skills;
1386 }
1387
1388 // get actual levels for gap analysis
1389 $this->getActualLevels($skills, $user_id);
1390
1391 $incl_self_eval = false;
1392 if (count($this->getGapAnalysisSelfEvalLevels()) > 0) {
1393 $incl_self_eval = true;
1394 $self_vals = $this->getGapAnalysisSelfEvalLevels();
1395 }
1396
1397 // output spider stuff
1398 $all_chart_html = "";
1399
1400 // determine skills that should be shown in the spider web
1401 $sw_skills = array();
1402 foreach ($skills as $sk) {
1403 if (!in_array($sk["base_skill_id"] . ":" . $sk["tref_id"], $this->hidden_skills)) {
1404 $sw_skills[] = $sk;
1405 }
1406 }
1407
1408 if (count($sw_skills) >= 3) {
1409 $skill_packages = array();
1410
1411 if (count($sw_skills) < 8) {
1412 $skill_packages[1] = $sw_skills;
1413 } else {
1414 $mod = count($sw_skills) % 7;
1415 $pkg_num = floor((count($sw_skills) - 1) / 7) + 1;
1416 $cpkg = 1;
1417 foreach ($sw_skills as $k => $s) {
1418 $skill_packages[$cpkg][$k] = $s;
1419 if ($mod < 3 && count($skill_packages) == ($pkg_num - 1) && count($skill_packages[$cpkg]) == 3 + $mod) {
1420 $cpkg += 1;
1421 } elseif (count($skill_packages[$cpkg]) == 7) {
1422 $cpkg += 1;
1423 }
1424 }
1425 }
1426
1427 $pkg_cnt = 0;
1428 foreach ($skill_packages as $pskills) {
1429 $pkg_cnt++;
1430 $max_cnt = 0;
1431 $leg_labels = array();
1432 //var_dump($this->profile_levels);
1433 //foreach ($this->profile_levels as $k => $l)
1434
1435 // write target, actual and self counter to skill array
1436 foreach ($pskills as $k => $l) {
1437 //$bs = new ilBasicSkill($l["base_skill_id"]);
1438 $bs = new ilBasicSkill($l["base_skill_id"]);
1439 $leg_labels[] = ilBasicSkill::_lookupTitle($l["base_skill_id"], $l["tref_id"]);
1440 $levels = $bs->getLevelData();
1441 $cnt = 0;
1442 foreach ($levels as $lv) {
1443 $cnt++;
1444 if ($l["level_id"] == $lv["id"]) {
1445 $pskills[$k]["target_cnt"] = $cnt;
1446 }
1447 if ($this->actual_levels[$l["base_skill_id"]][$l["tref_id"]] == $lv["id"]) {
1448 $pskills[$k]["actual_cnt"] = $cnt;
1449 }
1450 if ($incl_self_eval) {
1451 if ($self_vals[$l["base_skill_id"]][$l["tref_id"]] == $lv["id"]) {
1452 $pskills[$k]["self_cnt"] = $cnt;
1453 }
1454 }
1455 $max_cnt = max($max_cnt, $cnt);
1456 }
1457 }
1458
1459 $chart = ilChart::getInstanceByType(ilChart::TYPE_SPIDER, "gap_chart" . $pkg_cnt);
1460 $chart->setsize(800, 300);
1461 $chart->setYAxisMax($max_cnt);
1462 $chart->setLegLabels($leg_labels);
1463
1464 // target level
1465 $cd = $chart->getDataInstance();
1466 $cd->setLabel($lng->txt("skmg_target_level"));
1467 $cd->setFill(true, "#A0A0A0");
1468
1469 // other users
1470 $cd2 = $chart->getDataInstance();
1471 if ($this->gap_cat_title != "") {
1472 $cd2->setLabel($this->gap_cat_title);
1473 } elseif ($this->gap_mode == "max_per_type") {
1474 $cd2->setLabel($lng->txt("objs_" . $this->gap_mode_type));
1475 } elseif ($this->gap_mode == "max_per_object") {
1476 $cd2->setLabel(ilObject::_lookupTitle($this->gap_mode_obj_id));
1477 }
1478 //$cd2->setFill(true, "#dcb496");
1479 $cd2->setFill(true, "#FF8080");
1480 $cd2->setFill(true, "#cc8466");
1481
1482 // self evaluation
1483 if ($incl_self_eval) {
1484 $cd3 = $chart->getDataInstance();
1485 $cd3->setLabel($lng->txt("skmg_self_evaluation"));
1486 $cd3->setFill(true, "#6ea03c");
1487 }
1488
1489 // fill in data
1490 $cnt = 0;
1491 foreach ($pskills as $pl) {
1492 $cd->addPoint($cnt, (int) $pl["target_cnt"]);
1493 $cd2->addPoint($cnt, (int) $pl["actual_cnt"]);
1494 if ($incl_self_eval) {
1495 $cd3->addPoint($cnt, (int) $pl["self_cnt"]);
1496 }
1497 $cnt++;
1498 }
1499
1500 // add data to chart
1501 if ($this->getProfileId() > 0) {
1502 $chart->addData($cd);
1503 }
1504 $chart->addData($cd2);
1505 if ($incl_self_eval && count($this->getGapAnalysisSelfEvalLevels()) > 0) {
1506 $chart->addData($cd3);
1507 }
1508
1509 if ($pkg_cnt == 1) {
1510 $lg = new ilChartLegend();
1511 $chart->setLegend($lg);
1512 }
1513
1514 $chart_html = $chart->getHTML();
1515 $all_chart_html .= $chart_html;
1516 }
1517
1518 $pan = ilPanelGUI::getInstance();
1519 $pan->setPanelStyle(ilPanelGUI::PANEL_STYLE_PRIMARY);
1520 $pan->setBody($all_chart_html);
1521 $all_chart_html = $pan->getHTML();
1522 }
1523
1524 $stree = new ilSkillTree();
1525 $html = "";
1526
1527 if (!$this->getProfileId() > 0) {
1528 // order skills per virtual skill tree
1529 $vtree = new ilVirtualSkillTree();
1530 $skills = $vtree->getOrderedNodeset($skills, "base_skill_id", "tref_id");
1531 }
1532 foreach ($skills as $s) {
1533 $path = $stree->getSkillTreePath($s["base_skill_id"]);
1534
1535 // check draft
1536 foreach ($path as $p) {
1537 if ($p["status"] == ilSkillTreeNode::STATUS_DRAFT) {
1538 continue(2);
1539 }
1540 }
1541 $html .= $this->getSkillHTML($s["base_skill_id"], $user_id, false, $s["tref_id"]);
1542 }
1543
1544 // list skills
1545
1546 return $intro_html . $all_chart_html . $html;
1547 }
1548
1554 public function selectProfile()
1555 {
1556 $ilCtrl = $this->ctrl;
1557
1558 $ilCtrl->setParameter($this, "profile_id", $_POST["profile_id"]);
1559 if ($this->mode == "gap") {
1560 $ilCtrl->redirect($this, "listProfilesForGap");
1561 } else {
1562 $ilCtrl->redirect($this, "listAssignedProfile");
1563 }
1564 }
1565
1572 public function getMaterials($a_levels, $a_tref_id = 0, $a_user_id = 0)
1573 {
1575 $lng = $this->lng;
1576
1577 if ($a_user_id == 0) {
1578 $a_user_id = $ilUser->getId();
1579 }
1580
1581 // only render, if materials given
1582 $got_mat = false;
1583 foreach ($a_levels as $v) {
1585 $a_user_id,
1586 $a_tref_id,
1587 $v["id"]
1588 );
1589 if ($mat_cnt > 0) {
1590 $got_mat = true;
1591 }
1592 }
1593 if (!$got_mat) {
1594 return "";
1595 }
1596
1597 $tpl = new ilTemplate("tpl.skill_materials.html", true, true, "Services/Skill");
1598 foreach ($a_levels as $k => $v) {
1599 $got_mat = false;
1601 $a_user_id,
1602 $a_tref_id,
1603 $v["id"]
1604 ) as $item) {
1605 $tpl->setCurrentBlock("material");
1606 $mat_data = $this->getMaterialInfo($item["wsp_id"], $a_user_id);
1607 $tpl->setVariable("HREF_LINK", $mat_data[1]);
1608 $tpl->setVariable("TXT_LINK", $mat_data[0]);
1609 $tpl->parseCurrentBlock();
1610 $got_mat = true;
1611 }
1612 if ($got_mat) {
1613 $tpl->setCurrentBlock("level");
1614 $tpl->setVariable("LEVEL_VAL", $v["title"]);
1615 $tpl->parseCurrentBlock();
1616 }
1617 }
1618 $tpl->setVariable("TXT_MATERIAL", $lng->txt("skmg_materials"));
1619
1620 return $tpl->get();
1621 }
1622
1629 public function getProfileTargetItem($a_profile_id, $a_levels, $a_tref_id = 0)
1630 {
1631 $lng = $this->lng;
1632
1633 $profile = new ilSkillProfile($a_profile_id);
1634 $profile_levels = $profile->getSkillLevels();
1635
1636 $a_activated_levels = array();
1637
1638 foreach ($a_levels as $k => $v) {
1639 foreach ($profile_levels as $pl) {
1640 if ($pl["level_id"] == $v["id"] &&
1641 $pl["base_skill_id"] == $v["skill_id"] &&
1642 $a_tref_id == $pl["tref_id"]) {
1643 $a_activated_levels[] = $pl["level_id"];
1644 }
1645 }
1646 }
1647
1648 $tpl = new ilTemplate("tpl.skill_eval_item.html", true, true, "Services/Skill");
1649 $tpl->setVariable("SCALE_BAR", $this->getScaleBar($a_levels, $a_activated_levels));
1650
1651 $tpl->setVariable("TYPE", $lng->txt("skmg_target_level"));
1652 $tpl->setVariable("TITLE", "");
1653
1654 return $tpl->get();
1655 }
1656
1663 public function getActualGapItem($a_levels, $a_tref_id = 0)
1664 {
1665 $lng = $this->lng;
1666
1667 $a_activated_levels = array();
1668 foreach ($a_levels as $k => $v) {
1669 if ($this->actual_levels[$v["skill_id"]][$a_tref_id] == $v["id"]) {
1670 $a_activated_levels[] = $v["id"];
1671 }
1672 }
1673
1674 if ($this->gap_cat_title != "") {
1675 $title = $this->gap_cat_title;
1676 } elseif ($this->gap_mode == "max_per_type") {
1677 $title = $lng->txt("objs_" . $this->gap_mode_type);
1678 } elseif ($this->gap_mode == "max_per_object") {
1679 $title = ilObject::_lookupTitle($this->gap_mode_obj_id);
1680 }
1681
1682 $tpl = new ilTemplate("tpl.skill_eval_item.html", true, true, "Services/Skill");
1683 $tpl->setVariable("SCALE_BAR", $this->getScaleBar($a_levels, $a_activated_levels));
1684
1685 $type = 1;
1686 $tpl->setVariable("TYPE", $lng->txt("skmg_eval_type_" . $type));
1687 if ($type > 0) {
1688 $tpl->touchBlock("st" . $type);
1689 $tpl->touchBlock("stb" . $type);
1690 }
1691
1692 if ($title != $lng->txt("skmg_eval_type_" . $type)) {
1693 $tpl->setVariable("TITLE", $title);
1694 }
1695
1696 return $tpl->get();
1697 }
1698
1705 public function getSelfEvalGapItem($a_levels, $a_tref_id = 0)
1706 {
1707 $lng = $this->lng;
1708
1709 $self_vals = $this->getGapAnalysisSelfEvalLevels();
1710 if (count($self_vals) == 0) {
1711 return;
1712 }
1713
1714 $a_activated_levels = array();
1715 foreach ($a_levels as $k => $v) {
1716 if ($self_vals[$v["skill_id"]][$a_tref_id] == $v["id"]) {
1717 $a_activated_levels[] = $v["id"];
1718 }
1719 }
1720
1721 $tpl = new ilTemplate("tpl.skill_eval_item.html", true, true, "Services/Skill");
1722 $tpl->setVariable("SCALE_BAR", $this->getScaleBar($a_levels, $a_activated_levels));
1723
1724 $type = 3;
1725 $tpl->setVariable("TYPE", $lng->txt("skmg_eval_type_" . $type));
1726 if ($type > 0) {
1727 $tpl->touchBlock("st" . $type);
1728 $tpl->touchBlock("stb" . $type);
1729 }
1730
1731 return $tpl->get();
1732 }
1733
1734
1741 public function getScaleBar($a_levels, $a_activated_levels)
1742 {
1743 $vals = array();
1744
1745 if (!is_array($a_activated_levels)) {
1746 $a_activated_levels = array($a_activated_levels);
1747 }
1748
1749 foreach ($a_levels as $level) {
1750 $vals[$level["title"]] = (in_array($level["id"], $a_activated_levels));
1751 }
1752 $scale_bar = $this->ui_fac->chart()->scaleBar($vals);
1753
1754 return $this->ui_ren->render($scale_bar);
1755 }
1756
1763 public function getEvalItem($a_levels, $a_level_entry)
1764 {
1765 $lng = $this->lng;
1766 $ilAccess = $this->access;
1767
1768 $tpl = new ilTemplate("tpl.skill_eval_item.html", true, true, "Services/Skill");
1769 $tpl->setVariable("SCALE_BAR", $this->getScaleBar($a_levels, $a_level_entry["level_id"]));
1770
1772
1773 if ($a_level_entry["self_eval"] == 1) {
1775 }
1776
1777 if ($a_level_entry["trigger_obj_type"] == "tst") {
1779 }
1780
1782 $title = "";
1783 if ($a_level_entry["trigger_obj_id"] > 0) {
1784 if (ilObject::_exists($a_level_entry["trigger_ref_id"], true)) {
1785 $title = ilObject::_lookupTitle($a_level_entry["trigger_obj_id"]);
1786 } elseif (!empty($del_data = ilObjectDataDeletionLog::get($a_level_entry["trigger_obj_id"]))) {
1787 $title = $del_data["title"];
1788 } else {
1789 $title = ($a_level_entry["trigger_title"]) ?? "";
1790 }
1791 }
1792
1793 if ($a_level_entry["trigger_ref_id"] > 0
1794 && $ilAccess->checkAccess("read", "", $a_level_entry["trigger_ref_id"])) {
1795 $title = "<a href='" . ilLink::_getLink($a_level_entry["trigger_ref_id"]) . "'>" . $title . "</a>";
1796 }
1797
1798 $tpl->setVariable("TYPE", $lng->txt("skmg_eval_type_" . $type));
1799 if ($type > 0) {
1800 $tpl->touchBlock("st" . $type);
1801 $tpl->touchBlock("stb" . $type);
1802 }
1803 $tpl->setVariable("TITLE", $title);
1804 $tpl->setVariable(
1805 "DATE",
1806 ilDatePresentation::formatDate(new ilDate($a_level_entry["status_date"], IL_CAL_DATETIME))
1807 );
1808
1810
1811 return $tpl->get();
1812 }
1813
1822 protected function getSkillCategoryDescription(int $skill_id, int $tref_id) : string
1823 {
1824 $tpl = new ilTemplate("tpl.skill_description_category.html", true, true, "Services/Skill");
1825
1826 //if (ilSkillTreeNode::_lookupType($skill_id) == "scat") {
1827 $des = ilSkillTreeNode::_lookupDescription($skill_id);
1828 if (!is_null($des) && !empty($des)) {
1829 $tpl->setCurrentBlock("description_category");
1830 $tpl->setVariable("DESCRIPTION_CATEGORY", $des);
1831 $tpl->parseCurrentBlock();
1832 }
1833 //}
1834
1835 return $tpl->get();
1836 }
1837
1845 protected function getBasicSkillDescription(string $description) : string
1846 {
1847 $tpl = new ilTemplate("tpl.skill_description_basic.html", true, true, "Services/Skill");
1848
1849 if (!is_null($description) && !empty($description)) {
1850 $tpl->setCurrentBlock("description_basic");
1851 $tpl->setVariable("DESCRIPTION_BASIC", $description);
1852 $tpl->parseCurrentBlock();
1853 }
1854
1855 return $tpl->get();
1856 }
1857
1864 public function getSkillLevelDescription($skill)
1865 {
1866 $level_data = $skill->getLevelData();
1867 $tpl = new ilTemplate("tpl.skill_desc.html", true, true, "Services/Skill");
1868
1869 $desc_exists = false;
1870 foreach ($level_data as $l) {
1871 if ($l["description"] != "") {
1872 $desc_exists = true;
1873 }
1874 }
1875 reset($level_data);
1876 if ($desc_exists) {
1877 foreach ($level_data as $l) {
1878 $tpl->setCurrentBlock("level");
1879 $tpl->setVariable("LEVEL_VAL", $l["title"]);
1880 $tpl->setVariable("LEVEL_DESC", nl2br($l["description"]));
1881 $tpl->parseCurrentBlock();
1882 }
1883 }
1884
1885 return $tpl->get();
1886 }
1887
1894 public function getSuggestedResources($a_profile_id, $a_levels, $a_base_skill, $a_tref_id)
1895 {
1896 $lng = $this->lng;
1897
1898 $tpl = new ilTemplate("tpl.suggested_resources.html", true, true, "Services/Skill");
1899
1900 // use a profile
1901 if ($a_profile_id > 0) {
1902 $too_low = true;
1903 $current_target_level = 0;
1904
1905 foreach ($a_levels as $k => $v) {
1906 foreach ($this->profile_levels as $pl) {
1907 if ($pl["level_id"] == $v["id"] &&
1908 $pl["base_skill_id"] == $v["skill_id"]) {
1909 $too_low = true;
1910 $current_target_level = $v["id"];
1911 }
1912 }
1913
1914 if ($this->actual_levels[$v["skill_id"]][$a_tref_id] == $v["id"]) {
1915 $too_low = false;
1916 }
1917 }
1918
1919 // note for self-evaluation
1920 if ($this->skmg_settings->getHideProfileBeforeSelfEval() &&
1921 !ilBasicSkill::hasSelfEvaluated($this->user->getId(), $a_base_skill, $a_tref_id)) {
1922 $tpl->setVariable("SUGGESTED_MAT_MESS", $lng->txt("skmg_skill_needs_self_eval"));
1923 return $tpl->get();
1924 }
1925
1926 // suggested resources
1927 if ($too_low) {
1928 $skill_res = new ilSkillResources($a_base_skill, $a_tref_id);
1929 $res = $skill_res->getResources();
1930 $imp_resources = array();
1931 foreach ($res as $level) {
1932 foreach ($level as $r) {
1933 if ($r["imparting"] == true &&
1934 $current_target_level == $r["level_id"]) {
1935 $imp_resources[] = $r;
1936 }
1937 }
1938 }
1939 foreach ($imp_resources as $r) {
1940 $ref_id = $r["rep_ref_id"];
1943 $tpl->setCurrentBlock("resource_item");
1944 $tpl->setVariable("TXT_RES", $title);
1945 $tpl->setVariable("HREF_RES", ilLink::_getLink($ref_id));
1946 $tpl->parseCurrentBlock();
1947 }
1948 if (count($imp_resources) > 0) {
1949 $tpl->touchBlock("resources_list");
1950 $tpl->setVariable("SUGGESTED_MAT_MESS", $lng->txt("skmg_skill_needs_impr_res"));
1951 return $tpl->get();
1952 } else {
1953 $tpl->setVariable("SUGGESTED_MAT_MESS", $lng->txt("skmg_skill_needs_impr_no_res"));
1954 return $tpl->get();
1955 }
1956 } else {
1957 $tpl->setVariable("SUGGESTED_MAT_MESS", $lng->txt("skmg_skill_no_needs_impr"));
1958 return $tpl->get();
1959 }
1960 } else {
1961 // no profile, just list all resources
1962 $skill_res = new ilSkillResources($a_base_skill, $a_tref_id);
1963 $res = $skill_res->getResources();
1964 // add $r["level_id"] info
1965 $any = false;
1966 foreach ($res as $level) {
1967 $available = false;
1968 $cl = 0;
1969 foreach ($level as $r) {
1970 if ($r["imparting"]) {
1971 $ref_id = $r["rep_ref_id"];
1974 $tpl->setCurrentBlock("resource_item");
1975 $tpl->setVariable("TXT_RES", $title);
1976 $tpl->setVariable("HREF_RES", ilLink::_getLink($ref_id));
1977 $tpl->parseCurrentBlock();
1978 $available = true;
1979 $any = true;
1980 $cl = $r["level_id"];
1981 }
1982 }
1983 if ($available) {
1984 $tpl->setCurrentBlock("resources_list_level");
1985 $tpl->setVariable("TXT_LEVEL", $lng->txt("skmg_level"));
1986 $tpl->setVariable("LEVEL_NAME", ilBasicSkill::lookupLevelTitle($cl));
1987 $tpl->parseCurrentBlock();
1988 $tpl->touchBlock("resources_list");
1989 }
1990 }
1991 if ($any) {
1992 $tpl->setVariable("SUGGESTED_MAT_MESS", $lng->txt("skmg_suggested_resources"));
1993 return $tpl->get();
1994 }
1995 }
1996 return "";
1997 }
1998
2005 public function listAssignedProfile()
2006 {
2007 $ilCtrl = $this->ctrl;
2008 $lng = $this->lng;
2009
2010 $main_tpl = $this->tpl;
2011
2012 $tpl = new ilTemplate("tpl.skill_filter.html", true, true, "Services/Skill");
2013
2014 $this->setTabs("profile");
2015
2016 $this->determineCurrentProfile();
2018
2019 $filter_toolbar = new ilToolbarGUI();
2020 $filter_toolbar->setFormAction($ilCtrl->getFormAction($this));
2021 $this->getFilter()->addToToolbar($filter_toolbar, true);
2022
2023 $skills = array();
2024 if ($this->getProfileId() > 0) {
2025 $profile = new ilSkillProfile($this->getProfileId());
2026 $this->profile_levels = $profile->getSkillLevels();
2027
2028 foreach ($this->profile_levels as $l) {
2029 $skills[] = array(
2030 "base_skill_id" => $l["base_skill_id"],
2031 "tref_id" => $l["tref_id"],
2032 "level_id" => $l["level_id"]
2033 );
2034 }
2035 }
2036
2037 $this->getActualLevels($skills, $this->user->getId());
2038
2039 // render
2040 $html = "";
2041 $not_all_self_evaluated = false;
2042 foreach ($skills as $s) {
2043 if ($this->skmg_settings->getHideProfileBeforeSelfEval() &&
2044 !ilBasicSkill::hasSelfEvaluated($this->user->getId(), $s["base_skill_id"], $s["tref_id"])) {
2045 $not_all_self_evaluated = true;
2046 }
2047
2048 // todo draft check
2049 $html .= $this->getSkillHTML($s["base_skill_id"], 0, true, $s["tref_id"]);
2050 }
2051
2052 if ($html != "") {
2053 $filter_toolbar->addFormButton($this->lng->txt("skmg_refresh_view"), "applyFilterAssignedProfiles");
2054
2055 $tpl->setVariable("FILTER", $filter_toolbar->getHTML());
2056
2057 $html = $tpl->get() . $html;
2058 }
2059
2060 if ($not_all_self_evaluated) {
2061 $box = $this->ui_fac->messageBox()->info($lng->txt("skmg_skill_needs_self_eval_box"));
2062 $html = $this->ui_ren->render($box) . $html;
2063 }
2064
2065 $main_tpl->setContent($html);
2066 }
2067}
user()
Definition: user.php:4
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATETIME
static lookupLevelTitle(int $a_id)
static hasSelfEvaluated(int $a_user_id, int $a_skill_id, int $a_tref_id)
const TYPE_SPIDER
static getInstanceByType($a_type, $a_id)
Get type instance.
Confirmation screen class.
Global competence profiles of a container.
Local competence profiles of a container.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
static setUseRelativeDates($a_status)
set use relative dates
Class for single dates.
Class ilObjFile.
static getSupportedObjectTypes()
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
static _lookupObjectId($a_ref_id)
lookup object id
static _getAllReferences($a_id)
get all reference ids of object
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data@access public
static _lookupType($a_id, $a_reference=false)
lookup object type
static getInstance()
Get instance.
const PANEL_STYLE_PRIMARY
Explorer for selecting a personal skill.
static getAssignedMaterial($a_user_id, $a_tref_id, $a_level)
Get assigned material (for a skill level and user)
static removeMaterial($a_user_id, $a_tref_id, $a_level_id, $a_wsp_id)
Remove material.
static getSelectedUserSkills($a_user_id)
Get personal selected user skills.
static getSelfEvaluationDate($a_user_id, $a_top_skill, $a_tref_id, $a_basic_skill)
Get self evaluation.
static addPersonalSkill($a_user_id, $a_skill_node_id)
Add personal skill.
static assignMaterial($a_user_id, $a_top_skill, $a_tref_id, $a_basic_skill, $a_level, $a_wsp_id)
Assign material to skill level.
static removeSkill($a_user_id, $a_skill_node_id)
Remove personal skill.
static countAssignedMaterial($a_user_id, $a_tref_id, $a_level)
Get assigned material (for a skill level and user)
static saveSelfEvaluation($a_user_id, $a_top_skill, $a_tref_id, $a_basic_skill, $a_level)
Save self evaluation.
Personal skills GUI class.
assignMaterials()
Assign materials to skill levels.
setTriggerObjectsFilter($trigger_objects_filter)
getScaleBar($a_levels, $a_activated_levels)
Get scale bar.
setHistoryView($a_val)
Set history view.
hideSkill($a_skill_id, $a_tref_id=0)
Hide skill.
getBasicSkillDescription(string $description)
Get description for basic skill.
selfEvaluation()
Assign materials to skill levels.
setObjectSkills($a_obj_id, $a_skills=null)
Set object skills.
setIntroText($a_val)
Set intro text.
getSkillCategoryDescription(int $skill_id, int $tref_id)
Get description for skill category.
confirmSkillRemove()
Confirm skill remove.
getMaterialInfo($a_wsp_id, $a_user_id)
Get material file name and goto url.
getActualLevels($skills, $user_id)
Get actual levels.
getGapAnalysisSelfEvalLevels()
Get self evaluation levels for gap analysis.
applyFilterAssignedProfiles()
Apply filter for profiles view.
getActualGapItem($a_levels, $a_tref_id=0)
assignMaterial()
Assign materials to skill level.
renderSkillHTML($a_top_skill_id, $a_user_id=0, $a_edit=false, $a_tref_id=0)
Render skill html.
setGapAnalysisSelfEvalLevels(array $a_val)
Set self evaluation levels for gap analysis.
getSkillLevelDescription($skill)
Get level description.
setTabs($a_activate)
Set tabs.
getProfileTargetItem($a_profile_id, $a_levels, $a_tref_id=0)
Get profile target item.
showProfileSelectorToolbar()
Show profile selector toolbar.
getSelfEvalGapItem($a_levels, $a_tref_id=0)
getSkillHTML($a_top_skill_id, $a_user_id=0, $a_edit=false, $a_tref_id=0)
Get skill presentation HTML.
addSkill()
Add personal skill.
setObjectSkillProfiles(ilContainerGlobalProfiles $a_g_profiles, ilContainerLocalProfiles $a_l_profils)
Set object skill profiles.
determineCurrentProfile()
Determine current profile id.
getGapAnalysisHTML($a_user_id=0, $a_skills=null)
Get gap analysis html.
getSuggestedResources($a_profile_id, $a_levels, $a_base_skill, $a_tref_id)
Render suggested resources.
setGapAnalysisActualStatusModePerObject($a_obj_id, $a_cat_title="")
Set gap analysis actual status mode "per object".
saveSelfEvaluation()
Save self evaluation.
getMaterials($a_levels, $a_tref_id=0, $a_user_id=0)
Get materials.
setGapAnalysisActualStatusModePerType($a_type, $a_cat_title="")
Set gap analysis actual status mode "per type".
getHistoryView()
Get history view.
listSkillsForAdd()
LIst skills for adding.
setProfileId($a_val)
Set profile id.
getEvalItem($a_levels, $a_level_entry)
Get eval item.
This class represents a selection list property in a property form.
Self evaluation, second simplier implementation.
Assign materials to skill levels table.
static getProfilesOfUser($a_user_id)
Get profiles of a user.
Manages resources for skills.
static _lookupTemplateId($a_obj_id)
Lookup template ID.
static _lookupTitle($a_obj_id, $a_tref_id=0)
Lookup Title.
static _lookupDescription($a_obj_id)
Lookup Description.
static _lookupType($a_obj_id)
Lookup Type.
special template class to simplify handling of ITX/PEAR
Class ilUIHookProcessor.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
Access handler for personal workspace.
Explorer for selecting a personal workspace item.
Tree handler for personal workspace.
filter()
Definition: filter.php:2
global $DIC
Definition: goto.php:24
help()
Definition: help.php:2
if(isset($_FILES['img_file']) &&is_array($_FILES['img_file'])) $panel
Definition: imgupload.php:138
$ilUser
Definition: imgupload.php:18
$i
Definition: metadata.php:24
global $ilSetting
Definition: privfeed.php:17
$type
$url
foreach($_POST as $key=> $value) $res
ui()
Definition: ui.php:5
$message
Definition: xapiexit.php:14