ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 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 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 $tmp_data = $this->ass->getMemberListData();
50
51 // filter user access
52 $usr_ids = array_keys($tmp_data);
53 $filtered_usr_ids = $GLOBALS['DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
54 'etit_submissions_grades',
55 'edit_submissions_grades',
56 $this->exc->getRefId(),
57 $usr_ids
58 );
59 $data = [];
60 foreach ($filtered_usr_ids as $usr_id) {
61 $data[$usr_id] = $tmp_data[$usr_id];
62 }
63
64
65 $idl = $this->ass->getIndividualDeadlines();
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 }
108
109 // filter (team-wide)
110 if ($this->filter["name"]) {
111 foreach ($tmp as $idx => $item) {
112 if (!stristr(implode("", $item["team"]), $this->filter["name"])) {
113 unset($tmp[$idx]);
114 }
115 }
116 }
117 if ($this->filter["subm"]) {
118 foreach ($tmp as $idx => $item) {
119 $submission = $item["submission_obj"];
120 if ($this->filter["subm"] == "y" &&
121 !$submission->getLastSubmission()) {
122 unset($tmp[$idx]);
123 } elseif ($this->filter["subm"] == "n" &&
124 $submission->getLastSubmission()) {
125 unset($tmp[$idx]);
126 }
127 }
128 }
129
130 $data = $tmp;
131 unset($tmp);
132 } else {
133 foreach ($data as $idx => $item) {
134 // filter
135 if ($this->filter["status"] &&
136 $item["status"] != $this->filter["status"]) {
137 unset($data[$idx]);
138 continue;
139 }
140 if ($this->filter["name"] &&
141 !stristr($item["name"], $this->filter["name"]) &&
142 !stristr($item["login"], $this->filter["name"])) {
143 unset($data[$idx]);
144 continue;
145 }
146
147 $data[$idx]["submission_obj"] = new ilExSubmission($this->ass, $item["usr_id"]);
148
149 // filter
150 if ($this->filter["subm"]) {
151 $submission = $data[$idx]["submission_obj"];
152 if ($this->filter["subm"] == "y" &&
153 !$submission->getLastSubmission()) {
154 unset($data[$idx]);
155 continue;
156 } elseif ($this->filter["subm"] == "n" &&
157 $submission->getLastSubmission()) {
158 unset($data[$idx]);
159 continue;
160 }
161 }
162
163 if (array_key_exists($item["usr_id"], $idl)) {
164 $data[$idx]["idl"] = $idl[$item["usr_id"]];
165 }
166 }
167 }
168
169 return $data;
170 }
171
172 protected function getModeColumns()
173 {
174 $cols = array();
175
176 if (!$this->ass->hasTeam()) {
177 $selected = $this->getSelectedColumns();
178
179 if (in_array("image", $selected)) {
180 $cols["image"] = array($this->lng->txt("image"));
181 }
182
183 $cols["name"] = array($this->lng->txt("name"), "name");
184
185 if (in_array("login", $selected)) {
186 $cols["login"] = array($this->lng->txt("login"), "login");
187 }
188 } else {
189 $cols["name"] = array($this->lng->txt("exc_team"));
190 }
191
192 return $cols;
193 }
194
195 protected function parseModeColumns()
196 {
197 $cols = array();
198
199 if (!$this->ass->hasTeam()) {
200 $cols["image"] = array($this->lng->txt("image"));
201 $cols["name"] = array($this->lng->txt("name"), "name");
202 $cols["login"] = array($this->lng->txt("login"), "login");
203 } else {
204 $cols["name"] = array($this->lng->txt("exc_tbl_team"));
205 }
206
207 if ($this->ass->hasActiveIDl()) {
208 $cols["idl"] = array($this->lng->txt("exc_tbl_individual_deadline"), "idl");
209 }
210
211 return $cols;
212 }
213
214 protected function fillRow($member)
215 {
217
218 $member_id = $member["usr_id"];
219
220 $ilCtrl->setParameter($this->parent_obj, "ass_id", $this->ass->getId());
221 $ilCtrl->setParameter($this->parent_obj, "member_id", $member_id);
222
223 // multi-select id
224 $this->tpl->setVariable("NAME_ID", "member");
225 $this->tpl->setVariable("VAL_ID", $member_id);
226
227 $this->parseRow($member_id, $this->ass, $member);
228
229 $ilCtrl->setParameter($this->parent_obj, "ass_id", $this->ass->getId()); // #17140
230 $ilCtrl->setParameter($this->parent_obj, "member_id", "");
231 }
232}
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.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
global $ilCtrl
Definition: ilias.php:18
$cols
Definition: xhr_table.php:11