ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilParticipantsPerAssignmentTableGUI.php
Go to the documentation of this file.
1<?php
2
27{
28 protected array $teams = array();
29
33 public function __construct(
34 object $a_parent_obj,
35 string $a_parent_cmd,
36 ilObjExercise $a_exc,
37 int $a_item_id,
39 ) {
40 parent::__construct($a_parent_obj, $a_parent_cmd, $a_exc, $a_item_id, $feedback_gui);
42
43 $this->ass_types = ilExAssignmentTypes::getInstance();
44 $this->ass_type = $this->ass_types->getById(ilExAssignment::lookupType($a_item_id));
45
46 $this->setFormAction($ctrl->getFormAction($a_parent_obj, "saveStatusAll"));
47
48 $this->addMultiCommand("setPassed", $this->lng->txt("exc_set_passed"));
49 $this->addMultiCommand("setFailed", $this->lng->txt("exc_set_failed"));
50 $this->addMultiCommand("downloadSelected", $this->lng->txt("exc_download_selected"));
51 }
52
53 protected function isForwardingToFormDispatcher(): bool
54 {
55 return true;
56 }
57
61 protected function initMode(int $a_item_id): void
62 {
64
65 $this->mode = self::MODE_BY_ASSIGNMENT;
66
67 // global id for all exercises
68 $this->setId("exc_mem");
69
70 $this->ass = new ilExAssignment($a_item_id);
71
72 $this->setTitle($lng->txt("exc_assignment") . ": " . $this->ass->getTitle());
73 $this->setSelectAllCheckbox("sel_part_ids");
74 }
75
76 protected function parseData(): array
77 {
78 $this->addCommandButton("saveStatusAll", $this->lng->txt("exc_save_all"));
79
80 $tmp_data = $this->ass->getMemberListData();
81
82 // filter user access
83 $usr_ids = array_keys($tmp_data);
84 $filtered_usr_ids = $GLOBALS['DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
85 'edit_submissions_grades',
86 'edit_submissions_grades',
87 $this->exc->getRefId(),
88 $usr_ids
89 );
90 $data = [];
91 foreach ($filtered_usr_ids as $usr_id) {
92 $data[$usr_id] = $tmp_data[$usr_id];
93 }
94
95
96 $idl = $this->ass->getIndividualDeadlines();
97 $rdl = $this->ass->getRequestedDeadlines();
98 $calc_deadline = $this->ass->getCalculatedDeadlines();
99
100 // team upload? (1 row == 1 team)
101 if ($this->ass->hasTeam()) {
102 $teams = ilExAssignmentTeam::getInstancesFromMap($this->ass->getId());
103 $team_map = ilExAssignmentTeam::getAssignmentTeamMap($this->ass->getId());
104
105 $tmp = array();
106
107 foreach ($data as $item) {
108 // filter
109 if ($this->filter["status"] &&
110 $item["status"] != $this->filter["status"]) {
111 continue;
112 }
113
114 $team_id = $team_map[$item["usr_id"]] ?? "";
115
116 if (!$team_id) {
117 // #11957
118 $team_id = "nty" . $item["usr_id"];
119 }
120
121 if (!isset($tmp[$team_id])) {
122 $tmp[$team_id] = $item;
123
124 if (is_numeric($team_id)) {
125 $tmp[$team_id]["submission_obj"] = new ilExSubmission($this->ass, $item["usr_id"], $teams[$team_id]);
126 } else {
127 // ilExSubmission should not try to auto-load
128 $tmp[$team_id]["submission_obj"] = new ilExSubmission($this->ass, $item["usr_id"], new ilExAssignmentTeam());
129 }
130 }
131
132 $tmp[$team_id]["team"][$item["usr_id"]] = $item["name"];
133
134 if (is_numeric($team_id)) {
135 $idl_team_id = "t" . $team_id;
136 if (array_key_exists($idl_team_id, $idl)) {
137 $tmp[$team_id]["idl"] = $idl[$idl_team_id];
138 }
139
140 if (isset($calc_deadline["team"][$team_id])) {
141 $tmp[$team_id]["calc_deadline"] = $calc_deadline["team"][$team_id]["calculated_deadline"];
142 }
143 } elseif (isset($calc_deadline["user"][$item["usr_id"]])) {
144 $tmp["nty" . $item["usr_id"]]["calc_deadline"] = $calc_deadline["user"][$item["usr_id"]]["calculated_deadline"];
145 }
146 }
147
148 // filter (team-wide)
149 if ($this->filter["name"]) {
150 foreach ($tmp as $idx => $item) {
151 if (!stristr(implode("", $item["team"]), $this->filter["name"])) {
152 unset($tmp[$idx]);
153 }
154 }
155 }
156 if ($this->filter["subm"]) {
157 foreach ($tmp as $idx => $item) {
158 $submission = $item["submission_obj"];
159 if ($this->filter["subm"] == "y" &&
160 !$submission->getLastSubmission()) {
161 unset($tmp[$idx]);
162 } elseif ($this->filter["subm"] == "n" &&
163 $submission->getLastSubmission()) {
164 unset($tmp[$idx]);
165 }
166 }
167 }
168 if ($this->filter["subm_after"]) {
169 foreach ($tmp as $idx => $item) {
170 $submission = $item["submission_obj"];
171 if ($this->filter["subm_after"]) {
172 if (is_null($submission->getLastSubmission())) {
173 unset($tmp[$idx]);
174 } else {
175 if ($submission->getLastSubmission() <
176 $this->filter["subm_after"]->get(IL_CAL_DATETIME)) {
177 unset($tmp[$idx]);
178 }
179 }
180 }
181 if ($this->filter["subm_before"]) {
182 if (is_null($submission->getLastSubmission())) {
183 unset($tmp[$idx]);
184 } else {
185 if ($submission->getLastSubmission() >
186 $this->filter["subm_before"]->get(IL_CAL_DATETIME)) {
187 unset($tmp[$idx]);
188 }
189 }
190 }
191 }
192 }
193
194 $data = $tmp;
195 unset($tmp);
196 } else {
197 $member_of_members = null;
198 foreach ($data as $idx => $item) {
199 // filter
200 if ($this->filter["status"] &&
201 $item["status"] != $this->filter["status"]) {
202 unset($data[$idx]);
203 continue;
204 }
205 if ($this->filter["name"] &&
206 !stristr($item["name"], $this->filter["name"]) &&
207 !stristr($item["login"], $this->filter["name"])) {
208 unset($data[$idx]);
209 continue;
210 }
211
212 $data[$idx]["submission_obj"] = new ilExSubmission($this->ass, $item["usr_id"]);
213
214 // filter
215 if ($this->filter["subm"]) {
216 $submission = $data[$idx]["submission_obj"];
217 if ($this->filter["subm"] == "y" &&
218 !$submission->getLastSubmission()) {
219 unset($data[$idx]);
220 continue;
221 } elseif ($this->filter["subm"] == "n" &&
222 $submission->getLastSubmission()) {
223 unset($data[$idx]);
224 continue;
225 }
226 }
227 if ($this->filter["subm_after"]) {
228 if (is_null($data[$idx]["submission_obj"]->getLastSubmission())) {
229 unset($data[$idx]);
230 } else {
231 if ($data[$idx]["submission_obj"]->getLastSubmission() <
232 $this->filter["subm_after"]->get(IL_CAL_DATETIME)) {
233 unset($data[$idx]);
234 }
235 }
236 }
237 if ($this->filter["subm_before"]) {
238 if (is_null($data[$idx]["submission_obj"]->getLastSubmission())) {
239 unset($data[$idx]);
240 } else {
241 if ($data[$idx]["submission_obj"]->getLastSubmission() >
242 $this->filter["subm_before"]->get(IL_CAL_DATETIME)) {
243 unset($data[$idx]);
244 }
245 }
246 }
247 if ($this->filter['member_of']) {
248 if (!ilParticipants::_isParticipant($this->filter['member_of'], $item["usr_id"])) {
249 unset($data[$idx]);
250 }
251 }
252
253 if (array_key_exists($item["usr_id"], $idl)) {
254 $data[$idx]["idl"] = $idl[$item["usr_id"]];
255 }
256
257 if (isset($data[$idx])) {
258 $data[$idx]["requested_idl"] = array_key_exists($item["usr_id"], $rdl);
259 }
260
261 if (isset($calc_deadline["user"][$item["usr_id"]])) {
262 $data[$idx]["calc_deadline"] = $calc_deadline["user"][$item["usr_id"]]["calculated_deadline"];
263 }
264 }
265 }
266 return $data;
267 }
268
269 protected function getModeColumns(): array
270 {
271 $cols = array();
272
273 if (!$this->ass->hasTeam()) {
274 $selected = $this->getSelectedColumns();
275
276 if (in_array("image", $selected)) {
277 $cols["image"] = array($this->lng->txt("image"));
278 }
279
280 $cols["name"] = array($this->lng->txt("name"), "name");
281
282 if (in_array("login", $selected)) {
283 $cols["login"] = array($this->lng->txt("login"), "login");
284 }
285 } else {
286 $cols["name"] = array($this->lng->txt("exc_team"));
287 }
288
289 return $cols;
290 }
291
292 protected function parseModeColumns(): array
293 {
294 $cols = array();
295
296 if (!$this->ass->hasTeam()) {
297 $cols["image"] = array($this->lng->txt("image"));
298 $cols["name"] = array($this->lng->txt("name"), "name");
299 $cols["login"] = array($this->lng->txt("login"), "login");
300 } else {
301 $cols["name"] = array($this->lng->txt("exc_tbl_team"));
302 }
303
304 if ($this->ass->hasActiveIDl()) {
305 $cols["idl"] = array($this->lng->txt("exc_tbl_individual_deadline"), "idl");
306 }
307
308 if ($this->ass->getDeadlineMode() == ilExAssignment::DEADLINE_RELATIVE && $this->ass->getRelativeDeadline()) {
309 $cols["calc_deadline"] = array($this->lng->txt("exc_tbl_calculated_deadline"), "calc_deadline");
310 }
311
312 return $cols;
313 }
314
320 protected function fillRow(array $a_set): void
321 {
322 $ilCtrl = $this->ctrl;
323
324 $member_id = $a_set["usr_id"];
325
326 $ilCtrl->setParameter($this->parent_obj, "ass_id", $this->ass->getId());
327 $ilCtrl->setParameter($this->parent_obj, "member_id", $member_id);
328
329 // multi-select id
330 $this->tpl->setVariable("NAME_ID", "sel_part_ids");
331 $this->tpl->setVariable("LISTED_NAME_ID", "listed_part_ids");
332 $this->tpl->setVariable("VAL_ID", $member_id);
333
334 $this->parseRow($member_id, $this->ass, $a_set);
335
336 $ilCtrl->setParameter($this->parent_obj, "ass_id", $this->ass->getId()); // #17140
337 $ilCtrl->setParameter($this->parent_obj, "member_id", "");
338 }
339}
const IL_CAL_DATETIME
getFormAction(object $a_gui_obj, ?string $a_fallback_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getAssignmentTeamMap(int $a_ass_id)
static getInstancesFromMap(int $a_assignment_id)
Exercise assignment.
static lookupType(int $a_id)
Exercise submission //TODO: This class has many static methods related to delivered "files".
ilExerciseSubmissionFeedbackGUI $feedback_gui
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
Class ilObjExercise.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(object $a_parent_obj, string $a_parent_cmd, ilObjExercise $a_exc, int $a_item_id, ilExerciseSubmissionFeedbackGUI $feedback_gui)
static _isParticipant(int $a_ref_id, int $a_usr_id)
Static function to check if a user is a participant of the container object.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
addMultiCommand(string $a_cmd, string $a_text)
setFormAction(string $a_form_action, bool $a_multipart=false)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
setId(string $a_val)
ilLanguage $lng
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
filter(string $filter_id, $class_path, string $cmd, bool $activated=true, bool $expanded=true)
$GLOBALS["DIC"]
Definition: wac.php:54