ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilExerciseVerificationTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
29 protected ilObjUser $user;
30
31 public function __construct(
32 ilObjExerciseVerificationGUI $a_parent_obj,
33 string $a_parent_cmd,
35 ) {
36 global $DIC;
37
38 $this->user = $DIC->user();
39 $database = $DIC->database();
40 $logger = $DIC->logger()->root();
41 $ilCtrl = $DIC->ctrl();
42
43 if (null === $userCertificateRepository) {
45 }
46 $this->userCertificateRepository = $userCertificateRepository;
47
48 parent::__construct($a_parent_obj, $a_parent_cmd);
49
50 $this->addColumn($this->lng->txt('title'), 'title');
51 $this->addColumn($this->lng->txt('passed'), 'passed');
52 $this->addColumn($this->lng->txt('action'), '');
53
54 $this->setTitle($this->lng->txt('excv_create'));
55 $this->setDescription($this->lng->txt('excv_create_info'));
56
57 $this->setRowTemplate('tpl.exc_verification_row.html', 'components/ILIAS/Exercise');
58 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj, $a_parent_cmd));
59
60 $this->getItems();
61 }
62
63 // Get all achieved test certificates for the current user
64 protected function getItems(): void
65 {
66 $ilUser = $this->user;
67 $userId = $ilUser->getId();
68
69 $certificateArray = $this->userCertificateRepository
70 ->fetchActiveCertificatesByTypeForPresentation($userId, 'exc');
71
72 $data = [];
73
74 foreach ($certificateArray as $certificate) {
75 $data[] = [
76 'id' => $certificate->getUserCertificate()->getObjId(),
77 'title' => $certificate->getObjectTitle(),
78 'passed' => true
79 ];
80 }
81
82 $this->setData($data);
83 }
84
85 protected function fillRow(array $a_set): void
86 {
87 $ilCtrl = $this->ctrl;
88
89 $this->tpl->setVariable('TITLE', $a_set['title']);
90 $this->tpl->setVariable(
91 'PASSED',
92 ($a_set['passed']) ? $this->lng->txt('yes') : $this->lng->txt('no')
93 );
94
95 if ($a_set['passed']) {
96 $ilCtrl->setParameter($this->parent_obj, 'exc_id', $a_set['id']);
97 $action = $ilCtrl->getLinkTarget($this->parent_obj, 'save');
98 $this->tpl->setVariable('URL_SELECT', $action);
99 $this->tpl->setVariable('TXT_SELECT', $this->lng->txt('select'));
100 }
101 }
102}
return true
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
@inheritDoc
List all completed exercises for current user.
__construct(ilObjExerciseVerificationGUI $a_parent_obj, string $a_parent_cmd, ?ilUserCertificateRepository $userCertificateRepository=null)
fillRow(array $a_set)
Standard Version of Fill Row.
GUI class for exercise verification.
User class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
setDescription(string $a_val)
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setData(array $a_data)
Set table data.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26