ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLOMemberTestResultTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=0);
25{
28
29 private int $current_user = 0;
30
31 public function __construct(object $a_parent_obj_gui, ilObject $a_parent_obj, string $a_parent_cmd)
32 {
33 $this->parent_container = $a_parent_obj;
34 $this->setId('lomemtstres_' . $a_parent_obj->getId());
35 parent::__construct($a_parent_obj_gui, $a_parent_cmd);
36 $this->settings = ilLOSettings::getInstanceByObjId($a_parent_obj->getId());
37 }
38
39 public function getParentContainer(): ilObject
40 {
42 }
43
44 public function getSettings(): ilLOSettings
45 {
46 return $this->settings;
47 }
48
49 public function setUserId(int $a_id): void
50 {
51 $this->current_user = $a_id;
52 }
53
54 public function getUserId(): int
55 {
57 }
58
59 public function init(): void
60 {
61 $name = ilObjUser::_lookupName($this->getUserId());
62
63 if (strlen($name['firstname']) && strlen($name['lastname'])) {
64 $name_string = $name['lastname'] . ', ' . $name['firstname'] . ' [' . $name['login'] . ']';
65 } elseif (strlen($name['lastname']) !== 0) {
66 $name_string = $name['lastname'] . ' [' . $name['login'] . ']';
67 } else {
68 $name_string = $name['login'];
69 }
70 $this->setTitle($this->lng->txt('crs_loc_test_results_of') . ' ' . $name_string);
71 $this->addColumn($this->lng->txt('crs_objectives'), 'title', '50%');
72 if ($this->getSettings()->worksWithInitialTest()) {
73 $this->addColumn($this->lng->txt('crs_loc_itest_info'), 'it', '25%');
74 $this->addColumn($this->lng->txt('crs_loc_qtest_info'), 'qt', '25%');
75 } else {
76 $this->addColumn($this->lng->txt('crs_loc_qtest_info'), 'qt', '25%');
77 }
78 $this->setRowTemplate('tpl.crs_objectives_usr_result_row.html', 'components/ILIAS/Course');
79 $this->disable('sort');
80 $this->disable('num_info');
81 }
82
83 protected function fillRow(array $a_set): void
84 {
85 $this->tpl->setVariable('VAL_TITLE', $a_set['title']);
86 if ($this->getSettings()->worksWithInitialTest()) {
87 if ($a_set['has_result_it']) {
88 $this->tpl->setCurrentBlock('it_has_result');
89 $this->tpl->setVariable('IT_LINK', $a_set['link_it']);
90 $this->tpl->setVariable('IT_VAL', $a_set['res_it'] . '%');
91 $this->tpl->parseCurrentBlock();
92 } else {
93 $this->tpl->setVariable('IT_NO_RES', '-');
94 }
95 }
96
97 if ($a_set['has_result_qt']) {
98 $this->tpl->setCurrentBlock('qt_has_result');
99 $this->tpl->setVariable('QT_LINK', $a_set['link_qt']);
100 $this->tpl->setVariable('QT_VAL', $a_set['res_qt'] . '%');
101 $this->tpl->parseCurrentBlock();
102 } else {
103 $this->tpl->setVariable('QT_NO_RES', '-');
104 }
105 }
106
107 public function parse(): void
108 {
109 $objective_ids = ilCourseObjective::_getObjectiveIds($this->getParentContainer()->getId(), true);
110 $tbl_data = [];
111 foreach ($objective_ids as $objective_id) {
112 $objective = array();
113 $objective['id'] = $objective_id;
114 $objective['title'] = ilCourseObjective::lookupObjectiveTitle($objective_id);
115
116 if ($this->getSettings()->worksWithInitialTest()) {
117 $results_it = ilLOUserResults::lookupResult(
118 $this->getParentContainer()->getId(),
119 $this->getUserId(),
120 $objective_id,
122 );
123 $objective['tries_it'] = $results_it['tries'];
124 $objective['res_it'] = $results_it['result_perc'];
125 $objective['link_it'] = $this->createTestResultLink(ilLOSettings::TYPE_TEST_INITIAL, $objective_id);
126 $objective['has_result_it'] = (bool) $results_it['has_result'];
127 }
128 $results_qt = ilLOUserResults::lookupResult(
129 $this->getParentContainer()->getId(),
130 $this->getUserId(),
131 $objective_id,
133 );
134 $objective['tries_qt'] = $results_qt['tries'];
135 $objective['res_qt'] = $results_qt['result_perc'];
136 $objective['link_qt'] = $this->createTestResultLink(ilLOSettings::TYPE_TEST_QUALIFIED, $objective_id);
137 $objective['has_result_qt'] = (bool) $results_qt['has_result'];
138
139 $tbl_data[] = $objective;
140 }
141 $this->setData($tbl_data);
142 }
143
144 protected function createTestResultLink(int $a_type, int $a_objective_id): string
145 {
147
148 $test_ref_id = $assignments->getTestByObjective($a_objective_id, $a_type);
149 if ($test_ref_id === 0) {
150 return '';
151 }
152 return ilLOUtils::getTestResultLinkForUser($test_ref_id, $this->getUserId());
153 }
154}
static lookupObjectiveTitle(int $a_objective_id, bool $a_add_description=false)
static _getObjectiveIds(int $course_id, bool $a_activated_only=false)
Class ilLOmemberTestResultTableGUI.
fillRow(array $a_set)
Standard Version of Fill Row.
__construct(object $a_parent_obj_gui, ilObject $a_parent_obj, string $a_parent_cmd)
createTestResultLink(int $a_type, int $a_objective_id)
Settings for LO courses.
static getInstanceByObjId(int $a_obj_id)
static getInstance(int $a_container_id)
static lookupResult(int $a_course_obj_id, int $a_user_id, int $a_objective_id, int $a_tst_type)
static getTestResultLinkForUser(int $a_test_ref_id, int $a_user_id)
static _lookupName(int $a_user_id)
Class ilObject Basic functions for all objects.
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="")
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.
setId(string $a_val)
setData(array $a_data)
Set table data.
disable(string $a_module_name)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc