ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilExerciseMemberTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
12{
16 protected $ass;
17
18 protected $teams = array();
19
20 public function __construct($a_parent_obj, $a_parent_cmd, ilObjExercise $a_exc, $a_item_id)
21 {
23 global $ilCtrl;
24 //var_dump($ilCtrl->getCmd()); exit;
25 parent::__construct($a_parent_obj, $a_parent_cmd, $a_exc, $a_item_id);
26 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj, "saveStatusAll"));
27 }
28
29 protected function initMode($a_item_id)
30 {
32
33 $this->mode = self::MODE_BY_ASSIGNMENT;
34
35 // global id for all exercises
36 $this->setId("exc_mem");
37
38 $this->ass = new ilExAssignment($a_item_id);
39
40 $this->setTitle($lng->txt("exc_assignment") . ": " . $this->ass->getTitle());
41 $this->setSelectAllCheckbox("member");
42 }
43
44 protected function parseData()
45 {
46 $this->addCommandButton("saveStatusAll", $this->lng->txt("exc_save_all"));
47
48 $tmp_data = $this->ass->getMemberListData();
49
50 // filter user access
51 $usr_ids = array_keys($tmp_data);
52 $filtered_usr_ids = $GLOBALS['DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
53 'edit_submissions_grades',
54 'edit_submissions_grades',
55 $this->exc->getRefId(),
56 $usr_ids
57 );
58 $data = [];
59 foreach ($filtered_usr_ids as $usr_id) {
60 $data[$usr_id] = $tmp_data[$usr_id];
61 }
62
63
64 $idl = $this->ass->getIndividualDeadlines();
65 $calc_deadline = $this->ass->getCalculatedDeadlines();
66
67 // team upload? (1 row == 1 team)
68 if ($this->ass->hasTeam()) {
70 $team_map = ilExAssignmentTeam::getAssignmentTeamMap($this->ass->getId());
71
72 $tmp = array();
73
74 foreach ($data as $item) {
75 // filter
76 if ($this->filter["status"] &&
77 $item["status"] != $this->filter["status"]) {
78 continue;
79 }
80
81 $team_id = $team_map[$item["usr_id"]];
82
83 if (!$team_id) {
84 // #11957
85 $team_id = "nty" . $item["usr_id"];
86 }
87
88 if (!isset($tmp[$team_id])) {
89 $tmp[$team_id] = $item;
90
91 if (is_numeric($team_id)) {
92 $tmp[$team_id]["submission_obj"] = new ilExSubmission($this->ass, $item["usr_id"], $teams[$team_id]);
93 } else {
94 // ilExSubmission should not try to auto-load
95 $tmp[$team_id]["submission_obj"] = new ilExSubmission($this->ass, $item["usr_id"], new ilExAssignmentTeam());
96 }
97 }
98
99 $tmp[$team_id]["team"][$item["usr_id"]] = $item["name"];
100
101 if (is_numeric($team_id)) {
102 $idl_team_id = "t" . $team_id;
103 if (array_key_exists($idl_team_id, $idl)) {
104 $tmp[$team_id]["idl"] = $idl[$idl_team_id];
105 }
106
107 if (isset($calc_deadline["team"][$team_id])) {
108 $tmp[$team_id]["calc_deadline"] = $calc_deadline["team"][$team_id]["calculated_deadline"];
109 }
110 } else {
111 if (isset($calc_deadline["user"][$item["usr_id"]])) {
112 $tmp["nty" . $item["usr_id"]]["calc_deadline"] = $calc_deadline["user"][$item["usr_id"]]["calculated_deadline"];
113 }
114 }
115 }
116
117 // filter (team-wide)
118 if ($this->filter["name"]) {
119 foreach ($tmp as $idx => $item) {
120 if (!stristr(implode("", $item["team"]), $this->filter["name"])) {
121 unset($tmp[$idx]);
122 }
123 }
124 }
125 if ($this->filter["subm"]) {
126 foreach ($tmp as $idx => $item) {
127 $submission = $item["submission_obj"];
128 if ($this->filter["subm"] == "y" &&
129 !$submission->getLastSubmission()) {
130 unset($tmp[$idx]);
131 } elseif ($this->filter["subm"] == "n" &&
132 $submission->getLastSubmission()) {
133 unset($tmp[$idx]);
134 }
135 }
136 }
137
138 $data = $tmp;
139 unset($tmp);
140 } else {
141 foreach ($data as $idx => $item) {
142 // filter
143 if ($this->filter["status"] &&
144 $item["status"] != $this->filter["status"]) {
145 unset($data[$idx]);
146 continue;
147 }
148 if ($this->filter["name"] &&
149 !stristr($item["name"], $this->filter["name"]) &&
150 !stristr($item["login"], $this->filter["name"])) {
151 unset($data[$idx]);
152 continue;
153 }
154
155 $data[$idx]["submission_obj"] = new ilExSubmission($this->ass, $item["usr_id"]);
156
157 // filter
158 if ($this->filter["subm"]) {
159 $submission = $data[$idx]["submission_obj"];
160 if ($this->filter["subm"] == "y" &&
161 !$submission->getLastSubmission()) {
162 unset($data[$idx]);
163 continue;
164 } elseif ($this->filter["subm"] == "n" &&
165 $submission->getLastSubmission()) {
166 unset($data[$idx]);
167 continue;
168 }
169 }
170
171 if (array_key_exists($item["usr_id"], $idl)) {
172 $data[$idx]["idl"] = $idl[$item["usr_id"]];
173 }
174
175 if (isset($calc_deadline["user"][$item["usr_id"]])) {
176 $data[$idx]["calc_deadline"] = $calc_deadline["user"][$item["usr_id"]]["calculated_deadline"];
177 }
178 }
179 }
180
181 return $data;
182 }
183
184 protected function getModeColumns()
185 {
186 $cols = array();
187
188 if (!$this->ass->hasTeam()) {
189 $selected = $this->getSelectedColumns();
190
191 if (in_array("image", $selected)) {
192 $cols["image"] = array($this->lng->txt("image"));
193 }
194
195 $cols["name"] = array($this->lng->txt("name"), "name");
196
197 if (in_array("login", $selected)) {
198 $cols["login"] = array($this->lng->txt("login"), "login");
199 }
200 } else {
201 $cols["name"] = array($this->lng->txt("exc_team"));
202 }
203
204 return $cols;
205 }
206
207 protected function parseModeColumns()
208 {
209 $cols = array();
210
211 if (!$this->ass->hasTeam()) {
212 $cols["image"] = array($this->lng->txt("image"));
213 $cols["name"] = array($this->lng->txt("name"), "name");
214 $cols["login"] = array($this->lng->txt("login"), "login");
215 } else {
216 $cols["name"] = array($this->lng->txt("exc_tbl_team"));
217 }
218
219 if ($this->ass->hasActiveIDl()) {
220 $cols["idl"] = array($this->lng->txt("exc_tbl_individual_deadline"), "idl");
221 }
222
223 if ($this->ass->getDeadlineMode() == ilExAssignment::DEADLINE_RELATIVE && $this->ass->getRelativeDeadline()) {
224 $cols["calc_deadline"] = array($this->lng->txt("exc_tbl_calculated_deadline"), "calc_deadline");
225 }
226
227 return $cols;
228 }
229
230 protected function fillRow($member)
231 {
233
234 $member_id = $member["usr_id"];
235
236 $ilCtrl->setParameter($this->parent_obj, "ass_id", $this->ass->getId());
237 $ilCtrl->setParameter($this->parent_obj, "member_id", $member_id);
238
239 // multi-select id
240 $this->tpl->setVariable("NAME_ID", "member");
241 $this->tpl->setVariable("VAL_ID", $member_id);
242
243 $this->parseRow($member_id, $this->ass, $member);
244
245 $ilCtrl->setParameter($this->parent_obj, "ass_id", $this->ass->getId()); // #17140
246 $ilCtrl->setParameter($this->parent_obj, "member_id", "");
247 }
248}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
An exception for terminatinating execution or to throw for unit testing.
Exercise assignment team.
static getAssignmentTeamMap($a_ass_id)
Get team structure for assignment.
static getInstancesFromMap($a_assignment_id)
Exercise assignment.
Exercise submission //TODO: This class has to much static methods related to delivered "files".
fillRow($member)
Standard Version of Fill Row.
parseRow($a_user_id, ilExAssignment $a_ass, array $a_row)
__construct($a_parent_obj, $a_parent_cmd, ilObjExercise $a_exc, $a_item_id)
Constructor.
Class ilObjExercise.
getSelectedColumns()
Get selected columns.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setSelectAllCheckbox($a_select_all_checkbox, $a_select_all_on_top=false)
Set the name of the checkbox that should be toggled with a select all button.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
global $ilCtrl
Definition: ilias.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$cols
Definition: xhr_table.php:11