ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
4include_once("./Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php");
5
6
16{
17 protected $ass; // [ilExAssignment]
18 protected $teams = array();
19
20 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 {
31 global $lng;
32
33 $this->mode = self::MODE_BY_ASSIGNMENT;
34
35 // global id for all exercises
36 $this->setId("exc_mem");
37
38 include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
39 $this->ass = new ilExAssignment($a_item_id);
40
41 $this->setTitle($lng->txt("exc_assignment").": ".$this->ass->getTitle());
42 $this->setSelectAllCheckbox("member");
43 }
44
45 protected function parseData()
46 {
47 $this->addCommandButton("saveStatusAll", $this->lng->txt("exc_save_all"));
48
49 $data = $this->ass->getMemberListData();
50
51 $idl = $this->ass->getIndividualDeadlines();
52
53 // team upload? (1 row == 1 team)
54 if($this->ass->hasTeam())
55 {
56 $teams = ilExAssignmentTeam::getInstancesFromMap($this->ass->getId());
57 $team_map = ilExAssignmentTeam::getAssignmentTeamMap($this->ass->getId());
58
59 $tmp = array();
60
61 foreach($data as $item)
62 {
63 // filter
64 if($this->filter["status"] &&
65 $item["status"] != $this->filter["status"])
66 {
67 continue;
68 }
69
70 $team_id = $team_map[$item["usr_id"]];
71
72 if(!$team_id)
73 {
74 // #11957
75 $team_id = "nty".$item["usr_id"];
76 }
77
78 if(!isset($tmp[$team_id]))
79 {
80 $tmp[$team_id] = $item;
81
82 if(is_numeric($team_id))
83 {
84 $tmp[$team_id]["submission_obj"] = new ilExSubmission($this->ass, $item["usr_id"], $teams[$team_id]);
85 }
86 else
87 {
88 // ilExSubmission should not try to auto-load
89 $tmp[$team_id]["submission_obj"] = new ilExSubmission($this->ass, $item["usr_id"], new ilExAssignmentTeam());
90 }
91 }
92
93 $tmp[$team_id]["team"][$item["usr_id"]] = $item["name"];
94
95 if(is_numeric($team_id))
96 {
97 $idl_team_id = "t".$team_id;
98 if(array_key_exists($idl_team_id, $idl))
99 {
100 $tmp[$team_id]["idl"] = $idl[$idl_team_id];
101 }
102 }
103 }
104
105 // filter (team-wide)
106 if($this->filter["name"])
107 {
108 foreach($tmp as $idx => $item)
109 {
110 if(!stristr(implode("", $item["team"]), $this->filter["name"]))
111 {
112 unset($tmp[$idx]);
113 }
114 }
115 }
116 if($this->filter["subm"])
117 {
118 foreach($tmp as $idx => $item)
119 {
120 $submission = $item["submission_obj"];
121 if($this->filter["subm"] == "y" &&
122 !$submission->getLastSubmission())
123 {
124 unset($tmp[$idx]);
125 }
126 else if($this->filter["subm"] == "n" &&
127 $submission->getLastSubmission())
128 {
129 unset($tmp[$idx]);
130 }
131 }
132
133
134 }
135
136 $data = $tmp;
137 unset($tmp);
138 }
139 else
140 {
141 foreach($data as $idx => $item)
142 {
143 // filter
144 if($this->filter["status"] &&
145 $item["status"] != $this->filter["status"])
146 {
147 unset($data[$idx]);
148 continue;
149 }
150 if($this->filter["name"] &&
151 !stristr($item["name"], $this->filter["name"]) &&
152 !stristr($item["login"], $this->filter["name"]))
153 {
154 unset($data[$idx]);
155 continue;
156 }
157
158 $data[$idx]["submission_obj"] = new ilExSubmission($this->ass, $item["usr_id"]);
159
160 // filter
161 if($this->filter["subm"])
162 {
163 $submission = $data[$idx]["submission_obj"];
164 if($this->filter["subm"] == "y" &&
165 !$submission->getLastSubmission())
166 {
167 unset($data[$idx]);
168 continue;
169 }
170 else if($this->filter["subm"] == "n" &&
171 $submission->getLastSubmission())
172 {
173 unset($data[$idx]);
174 continue;
175 }
176 }
177
178 if(array_key_exists($item["usr_id"], $idl))
179 {
180 $data[$idx]["idl"] = $idl[$item["usr_id"]];
181 }
182 }
183 }
184
185 return $data;
186 }
187
188 protected function getModeColumns()
189 {
190 $cols = array();
191
192 if(!$this->ass->hasTeam())
193 {
194 $selected = $this->getSelectedColumns();
195
196 if(in_array("image", $selected))
197 {
198 $cols["image"] = array($this->lng->txt("image"));
199 }
200
201 $cols["name"] = array($this->lng->txt("name"), "name");
202
203 if(in_array("login", $selected))
204 {
205 $cols["login"] = array($this->lng->txt("login"), "login");
206 }
207 }
208 else
209 {
210 $cols["name"] = array($this->lng->txt("exc_team"));
211 }
212
213 return $cols;
214 }
215
216 protected function parseModeColumns()
217 {
218 $cols = array();
219
220 if(!$this->ass->hasTeam())
221 {
222 $cols["image"] = array($this->lng->txt("image"));
223 $cols["name"] = array($this->lng->txt("name"), "name");
224 $cols["login"] = array($this->lng->txt("login"), "login");
225 }
226 else
227 {
228 $cols["name"] = array($this->lng->txt("exc_tbl_team"));
229 }
230
231 if($this->ass->hasActiveIDl())
232 {
233 $cols["idl"] = array($this->lng->txt("exc_tbl_individual_deadline"), "idl");
234 }
235
236 return $cols;
237 }
238
239 protected function fillRow($member)
240 {
241 global $ilCtrl;
242
243 $member_id = $member["usr_id"];
244
245 $ilCtrl->setParameter($this->parent_obj, "ass_id", $this->ass->getId());
246 $ilCtrl->setParameter($this->parent_obj, "member_id", $member_id);
247
248 // multi-select id
249 $this->tpl->setVariable("NAME_ID", "member");
250 $this->tpl->setVariable("VAL_ID", $member_id);
251
252 $this->parseRow($member_id, $this->ass, $member);
253
254 $ilCtrl->setParameter($this->parent_obj, "ass_id", $this->ass->getId()); // #17140
255 $ilCtrl->setParameter($this->parent_obj, "member_id", "");
256 }
257}
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.
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)
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
global $lng
Definition: privfeed.php:17