ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilTestVerificationTableGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
27 {
29 
30  public function __construct(
32  string $parent_cmd,
33  private ilDBInterface $db,
34  private ilObjUser $user,
35  private ilLogger $logger
36  ) {
38  $this->userCertificateRepository = $user_certificate_repository;
39 
40  parent::__construct($parent_obj, $parent_cmd);
41 
42  $this->addColumn($this->lng->txt('title'), 'title');
43  $this->addColumn($this->lng->txt('passed'), 'passed');
44  $this->addColumn($this->lng->txt('action'), '');
45 
46  $this->setTitle($this->lng->txt('tstv_create'));
47  $this->setDescription($this->lng->txt('tstv_create_info'));
48 
49  $this->setRowTemplate('tpl.il_test_verification_row.html', 'Modules/Test');
50  $this->setFormAction($this->ctrl->getFormAction($parent_obj, $parent_cmd));
51 
52  $this->getItems();
53  }
54 
55  protected function getItems(): void
56  {
57  $userId = $this->user->getId();
58 
59  $certificateArray = $this->userCertificateRepository->fetchActiveCertificatesByTypeForPresentation(
60  $userId,
61  'tst'
62  );
63 
64  $data = [];
65  foreach ($certificateArray as $certificate) {
66  $data[] = [
67  'id' => $certificate->getUserCertificate()->getObjId(),
68  'title' => $certificate->getObjectTitle(),
69  'passed' => true
70  ];
71  }
72 
73  $this->setData($data);
74  }
75 
76  protected function fillRow(array $a_set): void
77  {
78  $this->tpl->setVariable('TITLE', $a_set['title']);
79  $this->tpl->setVariable(
80  'PASSED',
81  ($a_set['passed']) ? $this->lng->txt('yes') : $this->lng->txt('no')
82  );
83 
84  if ($a_set['passed']) {
85  $this->ctrl->setParameter($this->parent_obj, 'tst_id', $a_set['id']);
86  $action = $this->ctrl->getLinkTarget($this->parent_obj, 'save');
87  $this->tpl->setVariable('URL_SELECT', $action);
88  $this->tpl->setVariable('TXT_SELECT', $this->lng->txt('select'));
89  }
90  }
91 }
setData(array $a_data)
setFormAction(string $a_form_action, bool $a_multipart=false)
__construct(ilObjTestVerificationGUI $parent_obj, string $parent_cmd, private ilDBInterface $db, private ilObjUser $user, private ilLogger $logger)
setDescription(string $a_val)
ilUserCertificateRepository $userCertificateRepository
__construct(VocabulariesInterface $vocabularies)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
GUI class for test verification.
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)
List all completed tests for current user.
ilUserCertificateRepository $user_certificate_repository