ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilExerciseVerificationTableGUI.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
27 {
29  protected ilObjUser $user;
30 
31  public function __construct(
32  ilObjExerciseVerificationGUI $a_parent_obj,
33  string $a_parent_cmd,
34  ?ilUserCertificateRepository $userCertificateRepository = null
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) {
44  $userCertificateRepository = new ilUserCertificateRepository($database, $logger);
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', 'Modules/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  {
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 }
setData(array $a_data)
setFormAction(string $a_form_action, bool $a_multipart=false)
__construct(ilObjExerciseVerificationGUI $a_parent_obj, string $a_parent_cmd, ?ilUserCertificateRepository $userCertificateRepository=null)
setDescription(string $a_val)
global $DIC
Definition: feed.php:28
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...
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
__construct(Container $dic, ilPlugin $plugin)
$ilUser
Definition: imgupload.php:34
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)
setParameter(object $a_gui_obj, string $a_parameter, $a_value)