ILIAS  release_7 Revision v7.30-3-g800a261c036
ilLearningHistoryEntryCollector Class Reference

Learning history entry collector. More...

+ Collaboration diagram for ilLearningHistoryEntryCollector:

Public Member Functions

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

Protected Attributes

 $service
 

Detailed Description

Learning history entry collector.

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

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

Constructor & Destructor Documentation

◆ __construct()

ilLearningHistoryEntryCollector::__construct ( ilLearningHistoryService  $service)

Constructor.

Parameters
ilLearningHistoryService$service

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

References $service.

Member Function Documentation

◆ getEntries()

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

Get entries.

Parameters
int$fromunix timestamp
int$tounix timestamp
int$user_iduser id
array$classes
Returns
ilLearningHistoryEntry[]

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

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

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

+ Here is the call graph for this function:

Field Documentation

◆ $service

ilLearningHistoryEntryCollector::$service
protected

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

Referenced by __construct().


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