ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilStudyProgrammeDashboardViewGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
24
26{
27 protected ?string $visible_on_pd_mode = null;
28
29 public function initViewSettings(): void
30 {
31 $this->viewSettings = new ilPDSelectedItemsBlockViewSettings(
32 $this->user,
34 );
35
36 $this->ctrl->setParameter($this, 'view', $this->viewSettings->getCurrentView());
37 }
38
39 public function emptyHandling(): string
40 {
41 return '';
42 }
43
44 public function initData(): void
45 {
46 $user_table = ilStudyProgrammeDIC::dic()['ilStudyProgrammeUserTable'];
47 $user_table->disablePermissionCheck(true);
48 $rows = $user_table->fetchSingleUserRootAssignments($this->user->getId());
49
50 $items = [];
51 foreach ($rows as $row) {
52 $prg = ilObjStudyProgramme::getInstanceByObjId($row->getNodeId());
53 if (!$this->isReadable($prg) || !$prg->isActive()) {
54 continue;
55 }
56
57 $properties = [
58 $this->lng->txt('prg_dash_label_minimum') => $row->getPointsRequired(),
59 $this->lng->txt('prg_dash_label_gain') => $row->getPointsCurrent(),
60 $this->lng->txt('prg_dash_label_status') => $row->getStatus(),
61 ];
62
63 if ($row->getStatusRaw() === ilPRGProgress::STATUS_ACCREDITED ||
64 $row->getStatusRaw() === ilPRGProgress::STATUS_COMPLETED
65 ) {
66 $properties[$this->lng->txt('prg_dash_label_valid')] = $row->getExpiryDate() ?: $row->getValidity();
67
68 if ($cert_link = $this->maybeGetCertificateLink($this->user->getId(), $prg->getId(), $prg->getRefId())) {
69 $repo_assignment = ilStudyProgrammeDIC::dic()['repo.assignment'];
70 $longest_lasting = $repo_assignment->getLongestValidAssignment($prg->getId(), $this->user->getId());
71 if ($longest_lasting === null
72 || $row->getAssignmentId() === $longest_lasting->getId()) {
73 $properties[$this->lng->txt('certificate')] = $cert_link;
74 }
75 }
76 } else {
77 $properties[$this->lng->txt('prg_dash_label_finish_until')] = $row->getDeadline();
78 }
79
80 $items[] = new BlockDTO(
81 $prg->getType(),
82 $prg->getRefId(),
83 $prg->getId(),
84 $prg->getTitle(),
85 $prg->getDescription(),
86 null,
87 null,
88 $properties
89 );
90 }
91
92 $this->setData(['' => $items]);
93 }
94
95 protected function isReadable(ilObjStudyProgramme $prg): bool
96 {
98 return true;
99 }
100 return $this->access->checkAccess('read', "", $prg->getRefId(), "prg", $prg->getId());
101 }
102
103 protected function getVisibleOnPDMode(): string
104 {
105 if (is_null($this->visible_on_pd_mode)) {
106 $this->visible_on_pd_mode =
107 $this->settings->get(
110 );
111 }
113 }
114
115 public function getBlockType(): string
116 {
117 return 'pdprg';
118 }
119
120 public function removeMultipleEnabled(): bool
121 {
122 return false;
123 }
124
125 public function getRemoveMultipleActionText(): string
126 {
127 return '';
128 }
129
130 protected function maybeGetCertificateLink(int $usr_id, int $prg_obj_id, int $prg_ref_id): ?string
131 {
132 $cert_validator = new ilCertificateDownloadValidator();
133 if ($cert_validator->isCertificateDownloadable($usr_id, $prg_obj_id)) {
134 $this->ctrl->setParameterByClass('ilObjStudyProgrammeGUI', 'ref_id', $prg_ref_id);
135 $target = $this->ctrl->getLinkTargetByClass("ilObjStudyProgrammeGUI", "deliverCertificate");
136 $this->ctrl->setParameterByClass('ilObjStudyProgrammeGUI', 'ref_id', null);
137 $this->lng->loadLanguageModule('certificate');
138 return $this->renderer->render($this->factory->link()->standard($this->lng->txt('download_certificate'), $target));
139 }
140 return null;
141 }
142}
renderer()
factory()
Validates if an active certificate is stored in the database and can be downloaded by the user.
static getInstanceByObjId(int $obj_id)
maybeGetCertificateLink(int $usr_id, int $prg_obj_id, int $prg_ref_id)
Common interface to all items.
Definition: Item.php:32