ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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,
29  ?ilObjUser $current_user = null,
30  ?\ILIAS\DI\UIServices $ui = null
31  ) {
32  global $DIC;
33 
34  parent::__construct($user_id, $factory, $lng, $template);
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...
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...
Interface Observer Contains several chained tasks and infos about them.
loadLanguageModule(string $a_module)
Load language module.
$url
Definition: shib_logout.php:66
$c
Definition: deliver.php:25
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class HTTPServicesTest.
global $DIC
Definition: shib_login.php:22
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
static getBadgesForUser(int $a_user_id, int $a_ts_from, int $a_ts_to)
__construct(int $user_id, ilLearningHistoryFactory $factory, ilLanguage $lng, ?ilTemplate $template=null, ?ilObjUser $current_user=null, ?\ILIAS\DI\UIServices $ui=null)