ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSkillLearningHistoryProvider.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25
33{
34 protected ilCtrl $ctrl;
35 protected Factory $ui_fac;
36 protected Renderer $ui_ren;
39
40 public function __construct(
41 int $user_id,
44 ?ilTemplate $template = null
45 ) {
46 global $DIC;
47
49 $this->ctrl = $DIC->ctrl();
50 $this->ui_fac = $DIC->ui()->factory();
51 $this->ui_ren = $DIC->ui()->renderer();
52 $this->profile_manager = $DIC->skills()->internal()->manager()->getProfileManager();
53 $this->profile_completion_manager = $DIC->skills()->internal()->manager()->getProfileCompletionManager();
54 }
55
59 public function isActive(): bool
60 {
61 $skmg_set = new ilSetting("skmg");
62 if ($skmg_set->get("enable_skmg")) {
63 return true;
64 }
65 return false;
66 }
67
71 public function getEntries(int $ts_start, int $ts_end): array
72 {
73 $lng = $this->getLanguage();
74 $lng->loadLanguageModule("skll");
75 $from = new ilDateTime($ts_start, IL_CAL_UNIX);
76 $to = new ilDateTime($ts_end, IL_CAL_UNIX);
77
78 // achievements
79 $completions = ilBasicSkill::getNewAchievementsPerUser($from->get(IL_CAL_DATETIME), $to->get(IL_CAL_DATETIME), $this->getUserId());
80
81 $entries = [];
82 if (isset($completions[$this->getUserId()])) {
83 foreach ($completions[$this->getUserId()] as $c) {
84 $ts = new ilDateTime($c["status_date"], IL_CAL_DATETIME);
85 $text = str_replace("$3$", $this->getEmphasizedTitle(ilBasicSkill::_lookupTitle($c["skill_id"], $c["tref_id"])), $lng->txt("skll_lhist_skill_achieved"));
86 $text = str_replace("$4$", $this->getEmphasizedTitle(ilBasicSkill::lookupLevelTitle($c["level_id"])), $text);
87 $entries[] = $this->getFactory()->entry(
88 $text,
89 $text,
90 ilUtil::getImagePath("standard/icon_skmg.svg"),
91 $ts->get(IL_CAL_UNIX),
92 $c["trigger_obj_id"]
93 );
94 }
95 }
96
97 // self evaluations
98 $completions = ilBasicSkill::getNewAchievementsPerUser($from->get(IL_CAL_DATETIME), $to->get(IL_CAL_DATETIME), $this->getUserId(), 1);
99
100 if (isset($completions[$this->getUserId()])) {
101 foreach ($completions[$this->getUserId()] as $c) {
102 $txt = ($c["trigger_obj_id"] > 0)
103 ? $lng->txt("skll_lhist_skill_self_eval_in")
104 : $lng->txt("skll_lhist_skill_self_eval");
105 $ts = new ilDateTime($c["status_date"], IL_CAL_DATETIME);
106 $text1 = str_replace("$3$", $this->getEmphasizedTitle(ilBasicSkill::_lookupTitle($c["skill_id"], $c["tref_id"])), $txt);
107 $text1 = str_replace("$4$", $this->getEmphasizedTitle(ilBasicSkill::lookupLevelTitle($c["level_id"])), $text1);
108 $entries[] = $this->getFactory()->entry(
109 $text1,
110 $text1,
111 ilUtil::getImagePath("standard/icon_skmg.svg"),
112 $ts->get(IL_CAL_UNIX),
113 $c["trigger_obj_id"]
114 );
115 }
116 }
117
118 // profiles
119 $completions = $this->profile_completion_manager->getFulfilledEntriesForUser($this->getUserId());
120
121 foreach ($completions as $c) {
122 $this->ctrl->setParameterByClass("ilpersonalskillsgui", "profile_id", $c->getProfileId());
123 $p_link = $this->ui_fac->link()->standard(
124 $this->profile_manager->lookupTitle($c->getProfileId()),
125 $this->ctrl->getLinkTargetByClass("ilpersonalskillsgui", "listassignedprofile")
126 );
127 $ts = new ilDateTime($c->getDate(), IL_CAL_DATETIME);
128 $text = str_replace(
129 "$3$",
130 $this->getEmphasizedTitle($this->ui_ren->render($p_link)),
131 $lng->txt("skll_lhist_skill_profile_fulfilled")
132 );
133 }
134
135 return $entries;
136 }
137
141 public function getName(): string
142 {
143 $lng = $this->getLanguage();
144 $lng->loadLanguageModule("skmg");
145
146 return $lng->txt("skills");
147 }
148}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
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 lookupLevelTitle(int $a_id)
static getNewAchievementsPerUser(string $a_timestamp, ?string $a_timestamp_to=null, int $a_user_id=0, int $a_self_eval=0)
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...
ILIAS Setting Class.
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 $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
$c
Definition: deliver.php:25
$txt
Definition: error.php:31
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
global $DIC
Definition: shib_login.php:26