ILIAS  release_8 Revision v8.24
class.ilStudyProgrammeDashboardViewGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
22{
23 protected ilLanguage $lng;
28 protected ilCtrl $ctrl;
30 protected int $usr_id;
31 protected ?string $visible_on_pd_mode = null;
32 public function __construct(
36 ILIAS\UI\Factory $factory,
37 ILIAS\UI\Renderer $renderer,
40 int $usr_id
41 ) {
42 $this->lng = $lng;
43 $this->lng->loadLanguageModule('prg');
44 $this->lng->loadLanguageModule('certificate');
45 $this->access = $access;
46 $this->setting = $setting;
47 $this->factory = $factory;
48 $this->renderer = $renderer;
49 $this->ctrl = $ctrl;
50 $this->user_table = $user_table;
51 $this->usr_id = $usr_id;
52 }
53
54 public function getHTML(): string
55 {
56 //array ilStudyProgrammeUserTableRow[]
57 $this->user_table->disablePermissionCheck(true);
58 $rows = $this->user_table->fetchSingleUserRootAssignments($this->usr_id);
59 $items = [];
60 foreach ($rows as $row) {
61 $prg = ilObjStudyProgramme::getInstanceByObjId($row->getNodeId());
62 if (! $this->isReadable($prg)) {
63 continue;
64 }
65
66 $min = $row->getPointsRequired();
67 $max = $row->getPointsReachable();
68 $cur = $row->getPointsCurrent();
69 $required_string = $min;
70 if ((float)$max < (float)$min) {
71 $required_string .= ' ' . $this->txt('prg_dash_label_unreachable') . ' (' . $max . ')';
72 }
73
74 $properties = [
75 [$this->txt('prg_dash_label_minimum') => $required_string],
76 [$this->txt('prg_dash_label_gain') => $cur],
77 [$this->txt('prg_dash_label_status') => $row->getStatus()],
78 ];
79
80 if (in_array($row->getStatusRaw(), [ilPRGProgress::STATUS_COMPLETED, ilPRGProgress::STATUS_ACCREDITED])) {
81 $validity = $row->getExpiryDate() ? $row->getExpiryDate() : $row->getValidity();
82 $properties[] = [$this->txt('prg_dash_label_valid') => $validity];
83 } else {
84 $properties[] = [$this->txt('prg_dash_label_finish_until') =>$row->getDeadline()];
85 }
86
87 $validator = new ilCertificateDownloadValidator();
88 if ($validator->isCertificateDownloadable($row->getUsrId(), $row->getNodeId())) {
89 $cert_url = "ilias.php?baseClass=ilRepositoryGUI&ref_id=" . $prg->getRefId() . "&cmd=deliverCertificate";
90 $cert_link = $this->factory->link()->standard($this->txt('download_certificate'), $cert_url);
91 $properties[] = [$this->txt('certificate') => $this->renderer->render($cert_link)];
92 }
93
94 $items[] = $this->buildItem($prg, $properties);
95 }
96
97 if (count($items) === 0) {
98 return '';
99 }
100 $group[] = $this->factory->item()->group("", $items);
101 $panel = $this->factory->panel()->listing()->standard($this->lng->txt("dash_studyprogramme"), $group);
102
103 return $this->renderer->render($panel);
104 }
105
106 protected function getVisibleOnPDMode(): string
107 {
108 if (is_null($this->visible_on_pd_mode)) {
109 $this->visible_on_pd_mode =
110 $this->setting->get(
113 );
114 }
116 }
117
118 protected function isReadable(ilObjStudyProgramme $prg): bool
119 {
121 return true;
122 }
123 return $this->access->checkAccess('read', "", $prg->getRefId(), "prg", $prg->getId());
124 }
125
126 protected function txt(string $code): string
127 {
128 return $this->lng->txt($code);
129 }
130
131 protected function buildItem(
133 array $properties
134 ): ILIAS\UI\Component\Item\Item {
135 $title = $prg->getTitle();
136 $link = $this->getDefaultTargetUrl($prg->getRefId());
137 $title_btn = $this->factory->button()->shy($title, $link);
138 $description = $prg->getLongDescription() ?? "";
139 $max = (int) $this->setting->get("rep_shorten_description_length");
140 if ($this->setting->get("rep_shorten_description") && $max !== 0) {
141 $description = ilStr::shortenTextExtended($description, $max, true);
142 }
143
144 $icon = $this->factory->symbol()->icon()->standard('prg', $title, 'medium');
145 return $this->factory->item()->standard($title_btn)
146 ->withProperties(array_merge(...$properties))
147 ->withDescription($description)
148 ->withLeadIcon($icon)
149 ;
150 }
151
152 protected function getDefaultTargetUrl(int $prg_ref_id): string
153 {
154 $this->ctrl->setParameterByClass(
155 ilObjStudyProgrammeGUI::class,
156 'ref_id',
157 $prg_ref_id
158 );
159 $link = $this->ctrl->getLinkTargetByClass(
160 [
161 ilRepositoryGUI::class,
162 ilObjStudyProgrammeGUI::class,
163 ]
164 );
165 $this->ctrl->setParameterByClass(
166 ilObjStudyProgrammeGUI::class,
167 'ref_id',
168 null
169 );
170 return $link;
171 }
172}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Validates if an active certificate is stored in the database and can be downloaded by the user.
Class ilCtrl provides processing control methods.
language handling
static getInstanceByObjId(int $obj_id)
getLongDescription()
get object long description (stored in object_description)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static shortenTextExtended(string $a_str, int $a_len, bool $a_dots=false, bool $a_next_blank=false, bool $a_keep_extension=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
buildItem(ilObjStudyProgramme $prg, array $properties)
__construct(ilLanguage $lng, ilAccess $access, ilSetting $setting, ILIAS\UI\Factory $factory, ILIAS\UI\Renderer $renderer, ilCtrl $ctrl, ilStudyProgrammeUserTable $user_table, int $usr_id)
ilStudyProgrammeUserTable provides a flattened list of progresses at a programme-node.
if(isset($_FILES['img_file']) &&is_array($_FILES['img_file'])) $panel
Definition: imgupload.php:198
This is how the factory for UI elements looks.
Definition: Factory.php:38
An entity that renders components to a string output.
Definition: Renderer.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.
$rows
Definition: xhr_table.php:10