ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilBadgeLearningHistoryProvider.php
Go to the documentation of this file.
1<?php
2
20{
22 private \ILIAS\DI\UIServices $ui;
23
24 public function __construct(
25 int $user_id,
28 ?ilTemplate $template = null,
30 ?\ILIAS\DI\UIServices $ui = null
31 ) {
32 global $DIC;
33
35
36 $this->current_user = $current_user ?? $DIC->user();
37 $this->ui = $ui ?? $DIC->ui();
38 }
39
40 public function isActive(): bool
41 {
43 return true;
44 }
45 return false;
46 }
47
51 public function getEntries(int $ts_start, int $ts_end): array
52 {
53 $lng = $this->getLanguage();
54 $lng->loadLanguageModule('badge');
55 $completions = ilBadgeAssignment::getBadgesForUser($this->getUserId(), $ts_start, $ts_end);
56
57 $entries = [];
58 foreach ($completions as $c) {
59 $title = $this->getEmphasizedTitle($c['title']);
60 if ($this->current_user->getId() === $this->getUserId()) {
61 $title = $this->ui->renderer()->render(
62 $this->ui->factory()->link()->standard(
63 $title,
64 $url = ilLink::_getLink($this->getUserId(), 'usr', [], '_bdg')
65 )
66 );
67 }
68 $text1 = str_replace('$3$', $title, $lng->txt('badge_lhist_badge_completed'));
69 $text2 = str_replace('$3$', $title, $lng->txt('badge_lhist_badge_completed_in'));
70 $entries[] = $this->getFactory()->entry(
71 $text1,
72 $text2,
73 ilUtil::getImagePath('standard/icon_bdga.svg'),
74 $c['tstamp'],
75 $c['parent_id']
76 );
77 }
78
79 return $entries;
80 }
81
82 public function getName(): string
83 {
84 return $this->getLanguage()->txt('obj_bdga');
85 }
86}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getBadgesForUser(int $a_user_id, int $a_ts_from, int $a_ts_to)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(int $user_id, ilLearningHistoryFactory $factory, ilLanguage $lng, ?ilTemplate $template=null, ?ilObjUser $current_user=null, ?\ILIAS\DI\UIServices $ui=null)
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...
User class.
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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class HTTPServicesTest.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
global $DIC
Definition: shib_login.php:26
$url
Definition: shib_logout.php:68