ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilBadgeLearningHistoryProvider Class Reference

Learning history provider: Badges. More...

+ Inheritance diagram for ilBadgeLearningHistoryProvider:
+ Collaboration diagram for ilBadgeLearningHistoryProvider:

Public Member Functions

 __construct ( $user_id, ilLearningHistoryFactory $factory, ilLanguage $lng, ilTemplate $template=null, ilObjUser $current_user=null, \ILIAS\DI\UIServices $ui=null)
 Constructor. More...
 
 isActive ()
 Is active?
Returns
bool
More...
 
 getEntries ($ts_start, $ts_end)
 Get entries.
Parameters
int$ts_start
int$ts_end
Returns
ilLearningHistoryEntry[]
More...
 
 getName ()
 Get name of provider (in user language)
Returns
string
More...
 
- Public Member Functions inherited from ilAbstractLearningHistoryProvider
 __construct ( $user_id, ilLearningHistoryFactory $factory, ilLanguage $lng, ilTemplate $template=null)
 Constructor. More...
 

Protected Attributes

 $current_user
 
 $ui
 
- Protected Attributes inherited from ilAbstractLearningHistoryProvider
 $user_id
 
 $factory
 
 $lng
 

Additional Inherited Members

- Protected Member Functions inherited from ilAbstractLearningHistoryProvider
 getUserId ()
 Get user id. More...
 
 getFactory ()
 Get factory. More...
 
 getLanguage ()
 Get language object. More...
 
 getEmphasizedTitle ($title)
 Get emphasized title. More...
 

Detailed Description

Learning history provider: Badges.

Author
killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 11 of file class.ilBadgeLearningHistoryProvider.php.

Constructor & Destructor Documentation

◆ __construct()

ilBadgeLearningHistoryProvider::__construct (   $user_id,
ilLearningHistoryFactory  $factory,
ilLanguage  $lng,
ilTemplate  $template = null,
ilObjUser  $current_user = null,
\ILIAS\DI\UIServices  $ui = null 
)

Constructor.

Parameters
int$user_id
ilLearningHistoryFactory$factory
ilLanguage$lng
ilTemplate | null$template

Definition at line 30 of file class.ilBadgeLearningHistoryProvider.php.

References $current_user, $DIC, ilAbstractLearningHistoryProvider\$template, $ui, and ilAbstractLearningHistoryProvider\$user_id.

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  }
global $DIC
Definition: saml.php:7

Member Function Documentation

◆ getEntries()

ilBadgeLearningHistoryProvider::getEntries (   $ts_start,
  $ts_end 
)

Get entries.

Parameters
int$ts_start
int$ts_end
Returns
ilLearningHistoryEntry[]

Implements ilLearningHistoryProviderInterface.

Definition at line 68 of file class.ilBadgeLearningHistoryProvider.php.

References $c, ilAbstractLearningHistoryProvider\$lng, $title, $url, ilLink\_getLink(), ilBadgeAssignment\getBadgesForUser(), ilAbstractLearningHistoryProvider\getEmphasizedTitle(), ilAbstractLearningHistoryProvider\getFactory(), ilUtil\getImagePath(), ilAbstractLearningHistoryProvider\getLanguage(), and ilAbstractLearningHistoryProvider\getUserId().

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  }
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
$url
static getBadgesForUser($a_user_id, $a_ts_from, $a_ts_to)
Get badges for user.
+ Here is the call graph for this function:

◆ getName()

ilBadgeLearningHistoryProvider::getName ( )

Get name of provider (in user language)

Returns
string

Implements ilLearningHistoryProviderInterface.

Definition at line 99 of file class.ilBadgeLearningHistoryProvider.php.

References ilAbstractLearningHistoryProvider\$lng, and ilAbstractLearningHistoryProvider\getLanguage().

99  : string
100  {
101  $lng = $this->getLanguage();
102 
103  return $lng->txt("obj_bdga");
104  }
+ Here is the call graph for this function:

◆ isActive()

ilBadgeLearningHistoryProvider::isActive ( )

Is active?

Returns
bool

Implements ilLearningHistoryProviderInterface.

Definition at line 56 of file class.ilBadgeLearningHistoryProvider.php.

References ilBadgeHandler\getInstance().

57  {
58  require_once 'Services/Badge/classes/class.ilBadgeHandler.php';
60  return true;
61  }
62  return false;
63  }
static getInstance()
Constructor.
+ Here is the call graph for this function:

Field Documentation

◆ $current_user

ilBadgeLearningHistoryProvider::$current_user
protected

Definition at line 16 of file class.ilBadgeLearningHistoryProvider.php.

Referenced by __construct().

◆ $ui

ilBadgeLearningHistoryProvider::$ui
protected

Definition at line 21 of file class.ilBadgeLearningHistoryProvider.php.

Referenced by __construct().


The documentation for this class was generated from the following file: