ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilDashboardLearningSequenceGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2015 Daniel Weise <daniel.weise@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
9{
13 protected $lng;
14
18 protected $user;
19
23 protected $access;
24
28 protected $factory;
29
33 protected $renderer;
34
38 protected $assignments;
39
43 protected $icon;
44
45 public function __construct()
46 {
47 global $DIC;
48
49 $this->lng = $DIC['lng'];
50 ;
51 $this->user = $DIC['ilUser'];
52 $this->access = $DIC['ilAccess'];
53 $this->factory = $DIC['ui.factory'];
54 $this->renderer = $DIC['ui.renderer'];
55 }
56
60 protected function getAssignments() : array
61 {
62 if (is_null($this->assignments)) {
63 $this->assignments = ilParticipants::_getMembershipByType($this->user->getId(), 'lso');
64 }
65
66 return $this->assignments;
67 }
68
69 public function getHTML() : string
70 {
71 if (count($this->getAssignments()) == 0) {
72 return '';
73 }
74
75 $items = array();
76 foreach ($this->getAssignments() as $assignment) {
77 $lso_ref_id = array_shift(ilObject::_getAllReferences($assignment));
78 $lso_obj = ilObjLearningSequence::getInstanceByRefId($lso_ref_id);
79
80 if (!$lso_obj) {
81 continue;
82 }
83
84 if (!$this->access->checkAccess('read', '', $lso_ref_id)) {
85 continue;
86 }
87
88 if (!$this->isRelevantLso($lso_obj)) {
89 continue;
90 }
91
92 $items[] = $this->getLsoItem($lso_obj);
93 }
94
95 if (count($items) == 0) {
96 return '';
97 }
98
99 $std_list = $this->factory->panel()->listing()->standard($this->lng->txt('dash_learningsequences'), array(
100 $this->factory->item()->group(
101 '',
102 $items
103 )
104 ));
105
106 return $this->renderer->render($std_list);
107 }
108
109 protected function getLsoItem(ilObjLearningSequence $lso_obj) : ILIAS\UI\Implementation\Component\Item\Standard
110 {
111 $ref_id = (int) $lso_obj->getRefId();
112 $title = $lso_obj->getTitle();
113
114 $link = $this->getLinkedTitle($ref_id, $title);
115
116 return $this->factory->item()->standard($link)
117 ->withProperties(
118 [
119 $this->lng->txt('status') => $this->getOnlineStatus($ref_id)
120 ]
121 )
122 ->withLeadIcon($this->getIcon($title))
123 ;
124 }
125
126 protected function isRelevantLso(ilObjLearningSequence $obj) : bool
127 {
128 $relevant = false;
129
130 $ls_lp_items = $obj->getLSLearnerItems($this->user->getId());
131 if (count($ls_lp_items) == 0) {
132 return $relevant;
133 }
134
135 foreach ($ls_lp_items as $item) {
136 if ($item->getLearningProgressStatus() == ilLPStatus::LP_STATUS_IN_PROGRESS_NUM) {
137 $relevant = true;
138 }
139 }
140
141 return $relevant;
142 }
143
144 protected function getLinkedTitle(int $ref_id, string $title) : ILIAS\UI\Component\Button\Shy
145 {
146 $link = ilLink::_getLink($ref_id, 'lso');
147 return $this->factory->button()->shy($title, $link);
148 }
149
150 protected function getOnlineStatus(int $ref_id) : string
151 {
153
154 if ($status) {
155 return 'Offline';
156 }
157
158 return 'Online';
159 }
160
161 protected function getIcon(string $title) : ILIAS\UI\Component\Symbol\Icon\Icon
162 {
163 if (is_null($this->icon)) {
164 $this->icon = $this->factory->symbol()->icon()->standard(
165 'lso',
166 $title,
167 'medium'
168 );
169 }
170
171 return $this->icon;
172 }
173}
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
Personal Desktop-Presentation for the Learningsequence.
const LP_STATUS_IN_PROGRESS_NUM
Class ilObjLearningSequence.
getLSLearnerItems(int $usr_id)
Get a list of LSLearnerItems.
static getInstanceByRefId(int $ref_id)
getRefId()
get reference id @access public
static _getAllReferences($a_id)
get all reference ids of object
getTitle()
get object title @access public
static _getMembershipByType($a_usr_id, $a_type, $a_only_member_role=false)
get membership by type Get course or group membership
global $DIC
Definition: goto.php:24
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.