ILIAS  release_8 Revision v8.24
class.ilBadgeLearningHistoryProvider.php
Go to the documentation of this file.
1<?php
2
24{
26 protected \ILIAS\DI\UIServices $ui;
27
28 public function __construct(
29 int $user_id,
32 ilTemplate $template = null,
34 \ILIAS\DI\UIServices $ui = null
35 ) {
36 global $DIC;
37
39
40 if (is_null($current_user)) {
41 $current_user = $DIC->user();
42 }
43 $this->current_user = $current_user;
44
45 if (is_null($ui)) {
46 $ui = $DIC->ui();
47 }
48 $this->ui = $ui;
49 }
50
51 public function isActive(): bool
52 {
54 return true;
55 }
56 return false;
57 }
58
59 public function getEntries(int $ts_start, int $ts_end): array
60 {
61 $lng = $this->getLanguage();
62 $lng->loadLanguageModule("badge");
63 $completions = ilBadgeAssignment::getBadgesForUser($this->getUserId(), $ts_start, $ts_end);
64
65 $entries = [];
66 foreach ($completions as $c) {
67 $title = $this->getEmphasizedTitle($c["title"]);
68 if ($this->current_user->getId() === $this->getUserId()) {
69 $title = $this->ui->renderer()->render($this->ui->factory()->link()->standard(
70 $title,
71 $url = ilLink::_getLink($this->getUserId(), "usr", array(), "_bdg")
72 ));
73 }
74 $text1 = str_replace("$3$", $title, $lng->txt("badge_lhist_badge_completed"));
75 $text2 = str_replace("$3$", $title, $lng->txt("badge_lhist_badge_completed_in"));
76 $entries[] = $this->getFactory()->entry(
77 $text1,
78 $text2,
79 ilUtil::getImagePath("icon_bdga.svg"),
80 $c["tstamp"],
81 $c["parent_id"]
82 );
83 }
84 return $entries;
85 }
86
87 public function getName(): string
88 {
89 $lng = $this->getLanguage();
90
91 return $lng->txt("obj_bdga");
92 }
93}
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 $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
$c
Definition: cli.php:38
global $DIC
Definition: feed.php:28
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
Class ChatMainBarProvider \MainMenu\Provider.
$url