ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilDashboardLearningSequenceGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
27 
32 {
33  protected ilLanguage $lng;
34  protected ilObjUser $user;
36  protected Factory $factory;
37  protected Renderer $renderer;
38 
42  protected ?array $assignments = null;
43  protected ?Icon\Icon $icon = null;
44 
45  public function __construct()
46  {
47  global $DIC;
48 
49  $this->lng = $DIC['lng'];
50  $this->user = $DIC['ilUser'];
51  $this->access = $DIC['ilAccess'];
52  $this->factory = $DIC['ui.factory'];
53  $this->renderer = $DIC['ui.renderer'];
54  }
55 
59  protected function getAssignments(): array
60  {
61  if (is_null($this->assignments)) {
62  $this->assignments = ilParticipants::_getMembershipByType($this->user->getId(), ['lso']);
63  }
64 
65  return $this->assignments;
66  }
67 
68  public function getHTML(): string
69  {
70  if (count($this->getAssignments()) == 0) {
71  return '';
72  }
73 
74  $items = array();
75  foreach ($this->getAssignments() as $assignment) {
76  $ref_ids = ilObject::_getAllReferences($assignment);
77  $lso_ref_id = array_shift($ref_ids);
78 
80  $lso_obj = ilObjLearningSequence::getInstanceByRefId($lso_ref_id);
81 
82  if (!$lso_obj) {
83  continue;
84  }
85 
86  if (!$this->access->checkAccess('read', '', $lso_ref_id)) {
87  continue;
88  }
89 
90  if (!$this->isRelevantLso($lso_obj)) {
91  continue;
92  }
93 
94  $items[] = $this->getLsoItem($lso_obj);
95  }
96 
97  if (count($items) == 0) {
98  return '';
99  }
100 
101  $std_list = $this->factory->panel()->listing()->standard($this->lng->txt('dash_learningsequences'), array(
102  $this->factory->item()->group(
103  '',
104  $items
105  )
106  ));
107 
108  return $this->renderer->render($std_list);
109  }
110 
111  protected function getLsoItem(ilObjLearningSequence $lso_obj): Item\Standard
112  {
113  $ref_id = $lso_obj->getRefId();
114  $title = $lso_obj->getTitle();
115 
116  $link = $this->getLinkedTitle($ref_id, $title);
117 
118  return $this->factory->item()->standard($link)
119  ->withProperties(
120  [
121  $this->lng->txt('status') => $this->getOnlineStatus($ref_id)
122  ]
123  )
124  ->withLeadIcon($this->getIcon($title))
125  ;
126  }
127 
128  protected function isRelevantLso(ilObjLearningSequence $obj): bool
129  {
130  $relevant = false;
131 
132  $ls_lp_items = $obj->getLSLearnerItems($this->user->getId());
133  if (count($ls_lp_items) == 0) {
134  return $relevant;
135  }
136 
137  foreach ($ls_lp_items as $item) {
138  if ($item->getLearningProgressStatus() == ilLPStatus::LP_STATUS_IN_PROGRESS_NUM) {
139  $relevant = true;
140  }
141  }
142 
143  return $relevant;
144  }
145 
146  protected function getLinkedTitle(int $ref_id, string $title): Button\Shy
147  {
148  $link = ilLink::_getLink($ref_id, 'lso');
149  return $this->factory->button()->shy($title, $link);
150  }
151 
152  protected function getOnlineStatus(int $ref_id): string
153  {
154  $status = ilObjLearningSequenceAccess::isOffline($ref_id);
155 
156  if ($status) {
157  return 'Offline';
158  }
159 
160  return 'Online';
161  }
162 
163  protected function getIcon(string $title): Icon\Standard
164  {
165  if (is_null($this->icon)) {
166  $this->icon = $this->factory->symbol()->icon()->standard(
167  'lso',
168  $title,
169  'medium'
170  );
171  }
172 
173  return $this->icon;
174  }
175 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This describes how an icon could be modified during construction of UI.
Definition: Icon.php:28
Personal Desktop-Presentation for the LearningSequence.
static _getAllReferences(int $id)
get all reference ids for object ID
const LP_STATUS_IN_PROGRESS_NUM
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Bulky.php:21
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
static getInstanceByRefId(int $ref_id)
Common interface to all items.
Definition: Item.php:31
This describes a standard button.
Definition: Standard.php:26
static _getMembershipByType(int $a_usr_id, array $a_type, bool $a_only_member_role=false)
get membership by type Get course or group membership
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Factory.php:21