ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilSkillLearningHistoryProvider.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
26 
34 {
35  protected ilCtrl $ctrl;
36  protected Factory $ui_fac;
37  protected Renderer $ui_ren;
40 
41  public function __construct(
42  int $user_id,
45  ?ilTemplate $template = null
46  ) {
47  global $DIC;
48 
49  parent::__construct($user_id, $factory, $lng, $template);
50  $this->ctrl = $DIC->ctrl();
51  $this->ui_fac = $DIC->ui()->factory();
52  $this->ui_ren = $DIC->ui()->renderer();
53  $this->profile_manager = $DIC->skills()->internal()->manager()->getProfileManager();
54  $this->profile_completion_manager = $DIC->skills()->internal()->manager()->getProfileCompletionManager();
55  }
56 
60  public function isActive(): bool
61  {
62  $skmg_set = new ilSetting("skmg");
63  if ($skmg_set->get("enable_skmg")) {
64  return true;
65  }
66  return false;
67  }
68 
72  public function getEntries(int $ts_start, int $ts_end): array
73  {
74  $lng = $this->getLanguage();
75  $lng->loadLanguageModule("skll");
76  $from = new ilDateTime($ts_start, IL_CAL_UNIX);
77  $to = new ilDateTime($ts_end, IL_CAL_UNIX);
78 
79  // achievements
80  $completions = ilBasicSkill::getNewAchievementsPerUser($from->get(IL_CAL_DATETIME), $to->get(IL_CAL_DATETIME), $this->getUserId());
81 
82  $entries = [];
83  if (isset($completions[$this->getUserId()])) {
84  foreach ($completions[$this->getUserId()] as $c) {
85  $ts = new ilDateTime($c["status_date"], IL_CAL_DATETIME);
86  $text = str_replace("$3$", $this->getEmphasizedTitle(ilBasicSkill::_lookupTitle($c["skill_id"], $c["tref_id"])), $lng->txt("skll_lhist_skill_achieved"));
87  $text = str_replace("$4$", $this->getEmphasizedTitle(ilBasicSkill::lookupLevelTitle($c["level_id"])), $text);
88  $entries[] = $this->getFactory()->entry(
89  $text,
90  $text,
91  ilUtil::getImagePath("standard/icon_skmg.svg"),
92  $ts->get(IL_CAL_UNIX),
93  $c["trigger_obj_id"]
94  );
95  }
96  }
97 
98  // self evaluations
99  $completions = ilBasicSkill::getNewAchievementsPerUser($from->get(IL_CAL_DATETIME), $to->get(IL_CAL_DATETIME), $this->getUserId(), 1);
100 
101  if (isset($completions[$this->getUserId()])) {
102  foreach ($completions[$this->getUserId()] as $c) {
103  $txt = ($c["trigger_obj_id"] > 0)
104  ? $lng->txt("skll_lhist_skill_self_eval_in")
105  : $lng->txt("skll_lhist_skill_self_eval");
106  $ts = new ilDateTime($c["status_date"], IL_CAL_DATETIME);
107  $text1 = str_replace("$3$", $this->getEmphasizedTitle(ilBasicSkill::_lookupTitle($c["skill_id"], $c["tref_id"])), $txt);
108  $text1 = str_replace("$4$", $this->getEmphasizedTitle(ilBasicSkill::lookupLevelTitle($c["level_id"])), $text1);
109  $entries[] = $this->getFactory()->entry(
110  $text1,
111  $text1,
112  ilUtil::getImagePath("standard/icon_skmg.svg"),
113  $ts->get(IL_CAL_UNIX),
114  $c["trigger_obj_id"]
115  );
116  }
117  }
118 
119  // profiles
120  $completions = $this->profile_completion_manager->getFulfilledEntriesForUser($this->getUserId());
121 
122  foreach ($completions as $c) {
123  $this->ctrl->setParameterByClass("ilpersonalskillsgui", "profile_id", $c->getProfileId());
124  $p_link = $this->ui_fac->link()->standard(
125  $this->profile_manager->lookupTitle($c->getProfileId()),
126  $this->ctrl->getLinkTargetByClass("ilpersonalskillsgui", "listassignedprofile")
127  );
128  $ts = new ilDateTime($c->getDate(), IL_CAL_DATETIME);
129  $text = str_replace(
130  "$3$",
131  $this->getEmphasizedTitle($this->ui_ren->render($p_link)),
132  $lng->txt("skll_lhist_skill_profile_fulfilled")
133  );
134  }
135 
136  return $entries;
137  }
138 
142  public function getName(): string
143  {
144  $lng = $this->getLanguage();
145  $lng->loadLanguageModule("skmg");
146 
147  return $lng->txt("skills");
148  }
149 }
An entity that renders components to a string output.
Definition: Renderer.php:30
const IL_CAL_DATETIME
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...
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static _lookupTitle(int $a_obj_id, int $a_tref_id=0)
__construct(int $user_id, ilLearningHistoryFactory $factory, ilLanguage $lng, ?ilTemplate $template=null)
SkillProfileCompletionManager $profile_completion_manager
loadLanguageModule(string $a_module)
Load language module.
static lookupLevelTitle(int $a_id)
const IL_CAL_UNIX
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(VocabulariesInterface $vocabularies)
static getNewAchievementsPerUser(string $a_timestamp, string $a_timestamp_to=null, int $a_user_id=0, int $a_self_eval=0)
$txt
Definition: error.php:14
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...