ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilSkillLearningHistoryProvider.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
12 {
13 
17  public function isActive()
18  {
19  $skmg_set = new ilSetting("skmg");
20  if ($skmg_set->get("enable_skmg")) {
21  return true;
22  }
23  return false;
24  }
25 
29  public function getEntries($ts_start, $ts_end)
30  {
31  $lng = $this->getLanguage();
32  $lng->loadLanguageModule("skll");
33  $from = new ilDateTime($ts_start, IL_CAL_UNIX);
34  $to = new ilDateTime($ts_end, IL_CAL_UNIX);
35 
36  // achievements
38 
39  $entries = [];
40  if (is_array($completions[$this->getUserId()])) {
41  foreach ($completions[$this->getUserId()] as $c) {
42  $ts = new ilDateTime($c["status_date"], IL_CAL_DATETIME);
43  $text = str_replace("$3$", $this->getEmphasizedTitle(ilBasicSkill::_lookupTitle($c["skill_id"], $c["tref_id"])), $lng->txt("skll_lhist_skill_achieved"));
44  $text = str_replace("$4$", $this->getEmphasizedTitle(ilBasicSkill::lookupLevelTitle($c["level_id"])), $text);
45  $entries[] = $this->getFactory()->entry(
46  $text,
47  $text,
48  ilUtil::getImagePath("icon_skmg.svg"),
49  $ts->get(IL_CAL_UNIX),
50  $c["trigger_obj_id"]
51  );
52  }
53  }
54 
55  // self evaluations
56  $completions = ilBasicSkill::getNewAchievementsPerUser($from->get(IL_CAL_DATETIME), $to->get(IL_CAL_DATETIME), $this->getUserId(), 1);
57 
58  if (is_array($completions[$this->getUserId()])) {
59  foreach ($completions[$this->getUserId()] as $c) {
60  $txt = ($c["trigger_obj_id"] > 0)
61  ? $lng->txt("skll_lhist_skill_self_eval_in")
62  : $lng->txt("skll_lhist_skill_self_eval");
63  $ts = new ilDateTime($c["status_date"], IL_CAL_DATETIME);
64  $text1 = str_replace("$3$", $this->getEmphasizedTitle(ilBasicSkill::_lookupTitle($c["skill_id"], $c["tref_id"])), $txt);
65  $text1 = str_replace("$4$", $this->getEmphasizedTitle(ilBasicSkill::lookupLevelTitle($c["level_id"])), $text1);
66  $entries[] = $this->getFactory()->entry(
67  $text1,
68  $text1,
69  ilUtil::getImagePath("icon_skmg.svg"),
70  $ts->get(IL_CAL_UNIX),
71  $c["trigger_obj_id"]
72  );
73  }
74  }
75  return $entries;
76  }
77 
81  public function getName() : string
82  {
83  $lng = $this->getLanguage();
84  $lng->loadLanguageModule("skmg");
85 
86  return $lng->txt("skills");
87  }
88 }
const IL_CAL_DATETIME
static lookupLevelTitle($a_id)
Lookup level title.
static getNewAchievementsPerUser($a_timestamp, $a_timestamp_to=null, $a_user_id=0, $a_self_eval=0)
Get new achievements.
getName()
Get name of provider (in user language)string
$from
const IL_CAL_UNIX
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
$text
Definition: errorreport.php:18
Date and time handling
$txt
Definition: error.php:11
static _lookupTitle($a_obj_id, $a_tref_id=0)
Lookup Title.
getEntries($ts_start, $ts_end)
Get entries.ilLearningHistoryEntry[]