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