ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilDashboardLearningSequenceGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
23
25{
26 protected function getIcon(string $title): Standard
27 {
28 if (!isset($this->icon) || is_null($this->icon)) {
29 $this->icon = $this->factory->symbol()->icon()->standard(
30 'lso',
31 $title,
32 'medium'
33 );
34 }
35
36 return $this->icon;
37 }
38
39 public function emptyHandling(): string
40 {
41 return '';
42 }
43
44 public function initViewSettings(): void
45 {
46 $this->viewSettings = new ilPDSelectedItemsBlockViewSettings(
47 $this->user,
49 );
50
51 $this->ctrl->setParameter($this, 'view', $this->viewSettings->getCurrentView());
52 }
53
54 public function initData(): void
55 {
56 $data = [];
57 $assignments = ilParticipants::_getMembershipByType($this->user->getId(), ['lso']);
58 foreach ($assignments as $assignment) {
59 $ref_ids = ilObject::_getAllReferences($assignment);
60 $lso_ref_id = array_shift($ref_ids);
61
63 $lso_obj = ilObjLearningSequence::getInstanceByRefId($lso_ref_id);
64
65 if (!$lso_obj) {
66 continue;
67 }
68
69 if (!$this->isRelevantLso($lso_obj)) {
70 continue;
71 }
72
73 if (!$this->access->checkAccess('read', '', $lso_ref_id)) {
74 continue;
75 }
76
77 $data[] = new BlockDTO(
78 'lso',
79 $lso_ref_id,
80 $lso_obj->getId(),
81 $lso_obj->getTitle(),
82 $lso_obj->getDescription(),
83 );
84 }
85
86 $this->setData(['' => $data]);
87 }
88
89 protected function isRelevantLso(ilObjLearningSequence $obj): bool
90 {
91 $ls_lp_items = $obj->getLSLearnerItems($this->user->getId());
92 if ($ls_lp_items === []) {
93 return false;
94 }
95
96 foreach ($ls_lp_items as $item) {
97 if ($item->getLearningProgressStatus() === ilLPStatus::LP_STATUS_IN_PROGRESS_NUM) {
98 return true;
99 }
100 }
101
102 return false;
103 }
104
105 public function getBlockType(): string
106 {
107 return 'pdlern';
108 }
109
110 public function confirmedRemove(array $ids): void
111 {
112 foreach ($ids as $ref_id) {
113 if ($this->access->checkAccess('leave', '', $ref_id)) {
114 if (ilObject::_lookupType($ref_id, true) === 'lso') {
116 if ($lso instanceof ilObjLearningSequence) {
117 $lso->getLSRoles()->leave($this->user->getId());
118 }
119 }
120
121 ilForumNotification::checkForumsExistsDelete($ref_id, $this->user->getId());
122 }
123 }
124
125 $this->main_tpl->setOnScreenMessage('success', $this->lng->txt('mmbr_unsubscribed_from_objs'), true);
126 $this->ctrl->returnToParent($this);
127 }
128
129 public function removeMultipleEnabled(): bool
130 {
131 return true;
132 }
133
134 public function getRemoveMultipleActionText(): string
135 {
136 return $this->lng->txt('pd_unsubscribe_multiple_memberships');
137 }
138}
factory()
static checkForumsExistsDelete(int $ref_id, int $user_id)
const LP_STATUS_IN_PROGRESS_NUM
static getInstanceByRefId(int $ref_id)
static _lookupType(int $id, bool $reference=false)
static _getAllReferences(int $id)
get all reference ids for object ID
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 describes the specific behavior of an ILIAS standard icon.
Definition: Standard.php:27
$ref_id
Definition: ltiauth.php:66