ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilLearningHistoryEntryCollector Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilLearningHistoryEntryCollector:

Public Member Functions

 __construct (ilLearningHistoryService $service)
 
 getEntries (?int $from=null, ?int $to=null, ?int $user_id=null, ?array $classes=null)
 Get entries. More...
 

Protected Attributes

ilLearningHistoryService $service
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Learning history entry collector

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

Definition at line 23 of file class.ilLearningHistoryEntryCollector.php.

Constructor & Destructor Documentation

◆ __construct()

ilLearningHistoryEntryCollector::__construct ( ilLearningHistoryService  $service)

Definition at line 27 of file class.ilLearningHistoryEntryCollector.php.

References $service.

28  {
29  $this->service = $service;
30  }

Member Function Documentation

◆ getEntries()

ilLearningHistoryEntryCollector::getEntries ( ?int  $from = null,
?int  $to = null,
?int  $user_id = null,
?array  $classes = null 
)

Get entries.

Parameters
?int$from unix timestamp
?int$to unix timestamp
?int$user_id user id
?array$classes
Returns
ilLearningHistoryEntry[]

Definition at line 40 of file class.ilLearningHistoryEntryCollector.php.

References Vendor\Package\$e, $lng, $provider, ilUtil\getImagePath(), and ilArrayUtil\sortArray().

45  : array {
46  $lng = $this->service->language();
47 
48  $to = (is_null($to))
49  ? time()
50  : $to;
51  $from = (is_null($from))
52  ? time() - (365 * 24 * 60 * 60)
53  : $from;
54 
55  $sort_array = [];
56  foreach ($this->service->provider()->getAllProviders(true, $user_id) as $provider) {
57  if (is_array($classes) && !in_array(get_class($provider), $classes, true)) {
58  continue;
59  }
60 
61  foreach ($provider->getEntries($from, $to) as $e) {
62  $sort_array[] = array("entry" => $e,"ts" => $e->getTimestamp());
63  }
64  }
65 
66  $sort_array = ilArrayUtil::sortArray($sort_array, "ts", "desc");
67 
68  // add today entry
69  $entries = [];
70 
71  if (date("Y-m-d", $to) === date("Y-m-d")) {
72  if (count($sort_array) === 0 ||
73  date("Y-m-d", (current($sort_array)["ts"])) !== date("Y-m-d")) {
74  $entries[] = $this->service->factory()->entry(
75  $lng->txt("lhist_no_entries"),
76  $lng->txt("lhist_no_entries"),
77  ilUtil::getImagePath("spacer.png"),
78  time(),
79  0
80  );
81  }
82  }
83 
84 
85  foreach ($sort_array as $s) {
86  $entries[] = $s["entry"];
87  }
88 
89  return $entries;
90  }
$lng
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
$provider
Definition: ltitoken.php:83
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
+ Here is the call graph for this function:

Field Documentation

◆ $service

ilLearningHistoryService ilLearningHistoryEntryCollector::$service
protected

Definition at line 25 of file class.ilLearningHistoryEntryCollector.php.

Referenced by __construct().


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