1<?php 2 3/* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */ 4 5/** 6 * Learning history provider: Skills 7 * 8 * @author killing@leifos.de 9 * @ingroup ServicesSkill 10 */ 11class ilSkillLearningHistoryProvider extends ilAbstractLearningHistoryProvider implements ilLearningHistoryProviderInterface 12{ 13 14 /** 15 * @inheritdoc 16 */ 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 26 /** 27 * @inheritdoc 28 */ 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 37 $completions = ilBasicSkill::getNewAchievementsPerUser($from->get(IL_CAL_DATETIME), $to->get(IL_CAL_DATETIME), $this->getUserId()); 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 78 /** 79 * @inheritdoc 80 */ 81 public function getName() : string 82 { 83 $lng = $this->getLanguage(); 84 $lng->loadLanguageModule("skmg"); 85 86 return $lng->txt("skills"); 87 } 88} 89