ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
TestScoringByParticipantTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
32{
33 public const PARENT_DEFAULT_CMD = 'showManScoringParticipantsTable';
34 public const PARENT_APPLY_FILTER_CMD = 'applyManScoringParticipantsFilter';
35 public const PARENT_RESET_FILTER_CMD = 'resetManScoringParticipantsFilter';
36
37 public const PARENT_EDIT_SCORING_CMD = 'showManScoringParticipantScreen';
38
39 protected bool $has_name_columns = false;
40
41 public function __construct(
43 protected array $anon_only_user_ids
44 ) {
45 $this->setPrefix('manScorePartTable');
46 $this->setId('manScorePartTable');
47
48 parent::__construct($parent_obj, self::PARENT_DEFAULT_CMD);
49
50 $this->setFilterCommand(self::PARENT_APPLY_FILTER_CMD);
51 $this->setResetCommand(self::PARENT_RESET_FILTER_CMD);
52
53 $this->setFormName('manScorePartTable');
54 $this->setStyle('table', 'fullwidth');
55
56 $this->enable('header');
57
58 $this->setFormAction($this->ctrl->getFormAction($parent_obj, self::PARENT_DEFAULT_CMD));
59
60 $this->setRowTemplate("tpl.il_as_tst_man_scoring_participant_tblrow.html", "components/ILIAS/Test");
61
62 $this->initColumns();
63 $this->initOrdering();
64
65 $this->initFilter();
66 }
67
68 private function initColumns(): void
69 {
70 $this->addColumn($this->lng->txt("exam_id_label"), 'examid', '');
71
72 if (!$this->parent_obj->getObject()->getAnonymity()
73 && $this->parent_obj->getTestAccess()->checkScoreParticipantsAccess()
74 ) {
75 $this->has_name_columns = true;
76 $this->addColumn($this->lng->txt("lastname"), 'lastname', '');
77 $this->addColumn($this->lng->txt("firstname"), 'firstname', '');
78 $this->addColumn($this->lng->txt("login"), 'login', '');
79 }
80
81 $this->addColumn($this->lng->txt('actions'), '', '1%');
82 }
83
84 private function initOrdering(): void
85 {
86 $this->enable('sort');
87
88 $this->setDefaultOrderField("lastname");
89 $this->setDefaultOrderDirection("asc");
90 }
91
92 public function initFilter(): void
93 {
94 $this->setDisableFilterHiding(true);
95
96 $participantStatus = new \ilSelectInputGUI($this->lng->txt('tst_participant_status'), 'participant_status');
97
98 $statusOptions = [];
99 $statusOptions[TestScoringByParticipantGUI::PART_FILTER_ALL_USERS] = $this->lng->txt("all_users");
100 $statusOptions[TestScoringByParticipantGUI::PART_FILTER_MANSCORING_NONE] = $this->lng->txt("manscoring_none");
101 $statusOptions[TestScoringByParticipantGUI::PART_FILTER_MANSCORING_DONE] = $this->lng->txt("manscoring_done");
102
103 $participantStatus->setOptions($statusOptions);
104
105 $this->addFilterItem($participantStatus);
106
107 $participantStatus->readFromSession();
108
109 if (!$participantStatus->getValue()) {
110 $participantStatus->setValue((string) TestScoringByParticipantGUI::PART_FILTER_MANSCORING_NONE);
111 }
112 }
113
114 public function fillRow(array $a_set): void
115 {
116 $this->ctrl->setParameter($this->parent_obj, 'active_id', $a_set['active_id']);
117
118 $participant_examid = $this->getParentObject()->getUserExamId(
119 $a_set['active_id'],
120 'x'
121 );
122 $this->tpl->setVariable("PARTICIPANT_EXAMID", $participant_examid);
123
124 if (in_array($a_set['usr_id'], $this->anon_only_user_ids)) {
125 $a_set['lastname'] = '';
126 $a_set['firstname'] = '';
127 $a_set['login'] = '';
128 }
129 if ($this->has_name_columns) {
130 $this->tpl->setCurrentBlock('personal');
131 $this->tpl->setVariable("PARTICIPANT_LASTNAME", $a_set['lastname']);
132 $this->tpl->setVariable("PARTICIPANT_FIRSTNAME", $a_set['firstname']);
133 $this->tpl->setVariable("PARTICIPANT_LOGIN", $a_set['login']);
134 $this->tpl->parseCurrentBlock();
135 }
136
137
138 $this->tpl->setVariable("HREF_SCORE_PARTICIPANT", $this->ctrl->getLinkTarget($this->parent_obj, self::PARENT_EDIT_SCORING_CMD));
139 $this->tpl->setVariable("TXT_SCORE_PARTICIPANT", $this->lng->txt('tst_edit_scoring'));
140 }
141
142 public function getInternalyOrderedDataValues(): array
143 {
145
146 return \ilArrayUtil::sortArray(
147 $this->getData(),
148 $this->getOrderField(),
149 $this->getOrderDirection(),
150 $this->numericOrdering($this->getOrderField())
151 );
152 }
153}
__construct(TestScoringByParticipantGUI $parent_obj, protected array $anon_only_user_ids)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setFilterCommand(string $a_val, string $a_caption="")
determineOffsetAndOrder(bool $a_omit_offset=false)
addFilterItem(ilTableFilterItem $a_input_item, bool $a_optional=false)
setFormName(string $a_name="")
setPrefix(string $a_prefix)
set prefix for sort and offset fields (if you have two or more tables on a page that you want to sort...
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)
setDefaultOrderField(string $a_defaultorderfield)
setDisableFilterHiding(bool $a_val=true)
numericOrdering(string $a_field)
Should this field be sorted numeric?
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setDefaultOrderDirection(string $a_defaultorderdirection)
setResetCommand(string $a_val, string $a_caption="")
enable(string $a_module_name)
setStyle(string $a_element, string $a_style)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc