ILIAS  release_8 Revision v8.24
class.ilSkillLearningHistoryProvider.php
Go to the documentation of this file.
1<?php
2
24
32{
33 protected ilCtrl $ctrl;
34 protected Factory $ui_fac;
35 protected Renderer $ui_ren;
38
39 public function __construct(
40 int $user_id,
43 ?ilTemplate $template = null
44 ) {
45 global $DIC;
46
48 $this->ctrl = $DIC->ctrl();
49 $this->ui_fac = $DIC->ui()->factory();
50 $this->ui_ren = $DIC->ui()->renderer();
51 $this->profile_manager = $DIC->skills()->internal()->manager()->getProfileManager();
52 $this->profile_completion_manager = $DIC->skills()->internal()->manager()->getProfileCompletionManager();
53 }
54
58 public function isActive(): bool
59 {
60 $skmg_set = new ilSetting("skmg");
61 if ($skmg_set->get("enable_skmg")) {
62 return true;
63 }
64 return false;
65 }
66
70 public function getEntries(int $ts_start, int $ts_end): array
71 {
72 $lng = $this->getLanguage();
73 $lng->loadLanguageModule("skll");
74 $from = new ilDateTime($ts_start, IL_CAL_UNIX);
75 $to = new ilDateTime($ts_end, IL_CAL_UNIX);
76
77 // achievements
78 $completions = ilBasicSkill::getNewAchievementsPerUser($from->get(IL_CAL_DATETIME), $to->get(IL_CAL_DATETIME), $this->getUserId());
79
80 $entries = [];
81 if (isset($completions[$this->getUserId()])) {
82 foreach ($completions[$this->getUserId()] as $c) {
83 $ts = new ilDateTime($c["status_date"], IL_CAL_DATETIME);
84 $text = str_replace("$3$", $this->getEmphasizedTitle(ilBasicSkill::_lookupTitle($c["skill_id"], $c["tref_id"])), $lng->txt("skll_lhist_skill_achieved"));
85 $text = str_replace("$4$", $this->getEmphasizedTitle(ilBasicSkill::lookupLevelTitle($c["level_id"])), $text);
86 $entries[] = $this->getFactory()->entry(
87 $text,
88 $text,
89 ilUtil::getImagePath("icon_skmg.svg"),
90 $ts->get(IL_CAL_UNIX),
91 $c["trigger_obj_id"]
92 );
93 }
94 }
95
96 // self evaluations
97 $completions = ilBasicSkill::getNewAchievementsPerUser($from->get(IL_CAL_DATETIME), $to->get(IL_CAL_DATETIME), $this->getUserId(), 1);
98
99 if (isset($completions[$this->getUserId()])) {
100 foreach ($completions[$this->getUserId()] as $c) {
101 $txt = ($c["trigger_obj_id"] > 0)
102 ? $lng->txt("skll_lhist_skill_self_eval_in")
103 : $lng->txt("skll_lhist_skill_self_eval");
104 $ts = new ilDateTime($c["status_date"], IL_CAL_DATETIME);
105 $text1 = str_replace("$3$", $this->getEmphasizedTitle(ilBasicSkill::_lookupTitle($c["skill_id"], $c["tref_id"])), $txt);
106 $text1 = str_replace("$4$", $this->getEmphasizedTitle(ilBasicSkill::lookupLevelTitle($c["level_id"])), $text1);
107 $entries[] = $this->getFactory()->entry(
108 $text1,
109 $text1,
110 ilUtil::getImagePath("icon_skmg.svg"),
111 $ts->get(IL_CAL_UNIX),
112 $c["trigger_obj_id"]
113 );
114 }
115 }
116
117 // profiles
118 $completions = $this->profile_completion_manager->getFulfilledEntriesForUser($this->getUserId());
119
120 foreach ($completions as $c) {
121 $this->ctrl->setParameterByClass("ilpersonalskillsgui", "profile_id", $c["profile_id"]);
122 $p_link = $this->ui_fac->link()->standard(
123 $this->profile_manager->lookupTitle($c["profile_id"]),
124 $this->ctrl->getLinkTargetByClass("ilpersonalskillsgui", "listassignedprofile")
125 );
126 $ts = new ilDateTime($c["date"], IL_CAL_DATETIME);
127 $text = str_replace(
128 "$3$",
129 $this->getEmphasizedTitle($this->ui_ren->render($p_link)),
130 $lng->txt("skll_lhist_skill_profile_fulfilled")
131 );
132 }
133
134 return $entries;
135 }
136
140 public function getName(): string
141 {
142 $lng = $this->getLanguage();
143 $lng->loadLanguageModule("skmg");
144
145 return $lng->txt("skills");
146 }
147}
const IL_CAL_UNIX
const IL_CAL_DATETIME
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getNewAchievementsPerUser(string $a_timestamp, string $a_timestamp_to=null, int $a_user_id=0, int $a_self_eval=0)
static lookupLevelTitle(int $a_id)
Class ilCtrl provides processing control methods.
@classDescription Date and time handling
language handling
loadLanguageModule(string $a_module)
Load language module.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
SkillProfileCompletionManager $profile_completion_manager
__construct(int $user_id, ilLearningHistoryFactory $factory, ilLanguage $lng, ?ilTemplate $template=null)
static _lookupTitle(int $a_obj_id, int $a_tref_id=0)
special template class to simplify handling of ITX/PEAR
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
$c
Definition: cli.php:38
$txt
Definition: error.php:13
global $DIC
Definition: feed.php:28
This is how the factory for UI elements looks.
Definition: Factory.php:38
An entity that renders components to a string output.
Definition: Renderer.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc