ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilTestVerificationTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
29{
31
32 public function __construct(
34 string $parent_cmd,
35 private ilDBInterface $db,
36 private ilObjUser $user,
37 private TestLogger $logger
38 ) {
39 $user_certificate_repository = new ilUserCertificateRepository($this->db, $this->logger->getComponentLogger());
40 $this->userCertificateRepository = $user_certificate_repository;
41
43
44 $this->addColumn($this->lng->txt('title'), 'title');
45 $this->addColumn($this->lng->txt('passed'), 'passed');
46 $this->addColumn($this->lng->txt('action'), '');
47
48 $this->setTitle($this->lng->txt('tstv_create'));
49 $this->setDescription($this->lng->txt('tstv_create_info'));
50
51 $this->setRowTemplate('tpl.il_test_verification_row.html', 'components/ILIAS/Test');
52 $this->setFormAction($this->ctrl->getFormAction($parent_obj, $parent_cmd));
53
54 $this->getItems();
55 }
56
57 protected function getItems(): void
58 {
59 $userId = $this->user->getId();
60
61 $certificateArray = $this->userCertificateRepository->fetchActiveCertificatesByTypeForPresentation(
62 $userId,
63 'tst'
64 );
65
66 $data = [];
67 foreach ($certificateArray as $certificate) {
68 $data[] = [
69 'id' => $certificate->getUserCertificate()->getObjId(),
70 'title' => $certificate->getObjectTitle(),
71 'passed' => true
72 ];
73 }
74
75 $this->setData($data);
76 }
77
78 protected function fillRow(array $a_set): void
79 {
80 $this->tpl->setVariable('TITLE', $a_set['title']);
81 $this->tpl->setVariable(
82 'PASSED',
83 ($a_set['passed']) ? $this->lng->txt('yes') : $this->lng->txt('no')
84 );
85
86 if ($a_set['passed']) {
87 $this->ctrl->setParameter($this->parent_obj, 'tst_id', $a_set['id']);
88 $action = $this->ctrl->getLinkTarget($this->parent_obj, 'save');
89 $this->tpl->setVariable('URL_SELECT', $action);
90 $this->tpl->setVariable('TXT_SELECT', $this->lng->txt('select'));
91 }
92 }
93}
return true
GUI class for test 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.
List all completed tests for current user.
fillRow(array $a_set)
Standard Version of Fill Row.
ilUserCertificateRepository $userCertificateRepository
__construct(ilObjTestVerificationGUI $parent_obj, string $parent_cmd, private ilDBInterface $db, private ilObjUser $user, private TestLogger $logger)
ilUserCertificateRepository $user_certificate_repository
Interface ilDBInterface.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc