ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilStudyProgrammeDashboardViewGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(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  $properties[$this->lng->txt('certificate')] = $cert_link;
70  }
71  } else {
72  $properties[$this->lng->txt('prg_dash_label_finish_until')] = $row->getDeadline();
73  }
74 
75  $items[] = new BlockDTO(
76  $prg->getType(),
77  $prg->getRefId(),
78  $prg->getId(),
79  $prg->getTitle(),
80  $prg->getDescription(),
81  null,
82  null,
83  $properties
84  );
85  }
86 
87  $this->setData(['' => $items]);
88  }
89 
90  protected function isReadable(ilObjStudyProgramme $prg): bool
91  {
93  return true;
94  }
95  return $this->access->checkAccess('read', "", $prg->getRefId(), "prg", $prg->getId());
96  }
97 
98  protected function getVisibleOnPDMode(): string
99  {
100  if (is_null($this->visible_on_pd_mode)) {
101  $this->visible_on_pd_mode =
102  $this->settings->get(
105  );
106  }
108  }
109 
110  public function getBlockType(): string
111  {
112  return 'pdprg';
113  }
114 
115  public function removeMultipleEnabled(): bool
116  {
117  return false;
118  }
119 
120  public function getRemoveMultipleActionText(): string
121  {
122  return '';
123  }
124 
125  protected function maybeGetCertificateLink(int $usr_id, int $prg_obj_id, int $prg_ref_id): ?string
126  {
127  $cert_validator = new ilCertificateDownloadValidator();
128  if ($cert_validator->isCertificateDownloadable($usr_id, $prg_obj_id)) {
129  $this->ctrl->setParameterByClass('ilObjStudyProgrammeGUI', 'ref_id', $prg_ref_id);
130  $target = $this->ctrl->getLinkTargetByClass("ilObjStudyProgrammeGUI", "deliverCertificate");
131  $this->ctrl->setParameterByClass('ilObjStudyProgrammeGUI', 'ref_id', null);
132  $this->lng->loadLanguageModule('certificate');
133  return $this->renderer->render($this->factory->link()->standard($this->lng->txt('download_certificate'), $target));
134  }
135  return null;
136  }
137 }
factory()
renderer()
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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)