ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilBadgeLearningHistoryProvider.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{
16 protected $current_user;
17
21 protected $ui;
22
30 public function __construct(
34 ilTemplate $template = null,
36 \ILIAS\DI\UIServices $ui = null
37 ) {
38 global $DIC;
39
40 parent::__construct($user_id, $factory, $lng, $template);
41
42 if (is_null($current_user)) {
43 $current_user = $DIC->user();
44 }
45 $this->current_user = $current_user;
46
47 if (is_null($ui)) {
48 $ui = $DIC->ui();
49 }
50 $this->ui = $ui;
51 }
52
56 public function isActive()
57 {
58 require_once 'Services/Badge/classes/class.ilBadgeHandler.php';
60 return true;
61 }
62 return false;
63 }
64
68 public function getEntries($ts_start, $ts_end)
69 {
70 $lng = $this->getLanguage();
71 $lng->loadLanguageModule("badge");
72 $completions = ilBadgeAssignment::getBadgesForUser($this->getUserId(), $ts_start, $ts_end);
73
74 $entries = [];
75 foreach ($completions as $c) {
76 $title = $this->getEmphasizedTitle($c["title"]);
77 if ($this->current_user->getId() == $this->getUserId()) {
78 $title = $this->ui->renderer()->render($this->ui->factory()->link()->standard(
79 $title,
80 $url = ilLink::_getLink($this->getUserId(), "usr", array(), "_bdg")
81 ));
82 }
83 $text1 = str_replace("$3$", $title, $lng->txt("badge_lhist_badge_completed"));
84 $text2 = str_replace("$3$", $title, $lng->txt("badge_lhist_badge_completed_in"));
85 $entries[] = $this->getFactory()->entry(
86 $text1,
87 $text2,
88 ilUtil::getImagePath("icon_bdga.svg"),
89 $c["tstamp"],
90 $c["parent_id"]
91 );
92 }
93 return $entries;
94 }
95
99 public function getName() : string
100 {
101 $lng = $this->getLanguage();
102
103 return $lng->txt("obj_bdga");
104 }
105}
An exception for terminatinating execution or to throw for unit testing.
static getBadgesForUser($a_user_id, $a_ts_from, $a_ts_to)
Get badges for user.
static getInstance()
Constructor.
getEntries($ts_start, $ts_end)
Get entries.ilLearningHistoryEntry[]
__construct( $user_id, ilLearningHistoryFactory $factory, ilLanguage $lng, ilTemplate $template=null, ilObjUser $current_user=null, \ILIAS\DI\UIServices $ui=null)
Constructor.
getName()
Get name of provider (in user language)string
language handling
special template class to simplify handling of ITX/PEAR
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
Class HTTPServicesTest.
Class BaseForm.
$url
global $DIC
Definition: saml.php:7