ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilExSubmissionTeamGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
13{
14 protected $exercise; // [ilObjExercise]
15 protected $assignment; // [ilExAssignment]
16 protected $submission; // [ilExSubmission]
17 protected $team; // [ilExAssignmentTeam]
18
19 public function __construct(ilObjExercise $a_exercise, ilExSubmission $a_submission)
20 {
21 global $ilCtrl, $ilTabs, $lng, $tpl;
22
23 $this->exercise = $a_exercise;
24 $this->submission = $a_submission;
25 $this->assignment = $a_submission->getAssignment();
26
27 // :TODO:
28 $this->ctrl = $ilCtrl;
29 $this->tabs_gui = $ilTabs;
30 $this->lng = $lng;
31 $this->tpl = $tpl;
32 }
33
34 public function executeCommand()
35 {
36 global $ilCtrl;
37
38 $class = $ilCtrl->getNextClass($this);
39 $cmd = $ilCtrl->getCmd("submissionScreenTeam");
40
41 if(!$this->assignment->hasTeam() ||
42 !$this->submission->canView())
43 {
44 return;
45 }
46 $this->team = $this->submission->getTeam();
47
48 if(!$this->submission->isTutor())
49 {
51 $this->tabs_gui->activateTab("team");
52 }
53
54 switch($class)
55 {
56 case 'ilrepositorysearchgui':
57 $this->ctrl->setReturn($this,'submissionScreenTeam');
58 include_once('./Services/Search/classes/class.ilRepositorySearchGUI.php');
59 $rep_search = new ilRepositorySearchGUI();
61 $rep_search->setTitle($this->lng->txt("exc_team_member_add"));
62 $rep_search->setCallback($this,'addTeamMemberActionObject');
63 $this->ctrl->forwardCommand($rep_search);
64 break;
65
66 default:
67 $this->{$cmd."Object"}();
68 break;
69 }
70 }
71
72 public static function getOverviewContent(ilInfoScreenGUI $a_info, ilExSubmission $a_submission)
73 {
74 global $lng, $ilCtrl;
75
76 if(!$a_submission->getAssignment()->hasTeam())
77 {
78 return;
79 }
80
81 $team_members = $a_submission->getTeam()->getMembers();
82 if(sizeof($team_members))
83 {
84 $team = array();
85 foreach($team_members as $member_id)
86 {
87 //$team[] = ilObjUser::_lookupFullname($member_id);
88 include_once("./Services/User/classes/class.ilUserUtil.php");
89 $team[] = ilUserUtil::getNamePresentation($member_id, false, false, "", false);
90 }
91 $team = implode("; ", $team);
92
93 // any team member upload?
94 if(!$a_submission->getLastSubmission())
95 {
96 $button = ilLinkButton::getInstance();
97 $button->setCaption("exc_delete_team");
98 $button->setUrl($ilCtrl->getLinkTargetByClass(array("ilExSubmissionGUI", "ilExSubmissionTeamGUI"), "confirmDeleteTeam"));
99 $team .= " ".$button->render();
100 }
101
102 $button = ilLinkButton::getInstance();
103
104 if(!$a_submission->getAssignment()->getTeamTutor())
105 {
106 $button->setCaption("exc_manage_team");
107 $button->setUrl($ilCtrl->getLinkTargetByClass(array("ilExSubmissionGUI", "ilExSubmissionTeamGUI"), "submissionScreenTeam"));
108 }
109 else
110 {
111 $button->setCaption("exc_team_log");
112 $button->setUrl($ilCtrl->getLinkTargetByClass(array("ilExSubmissionGUI", "ilExSubmissionTeamGUI"), "submissionScreenTeamLog"));
113 }
114 $team .= " ".$button->render();
115
116 $a_info->addProperty($lng->txt("exc_team_members"), $team);
117 }
118 else
119 {
120 if($a_submission->getAssignment()->beforeDeadline())
121 {
122 if(!$a_submission->hasSubmitted())
123 {
124 $team_info = $lng->txt("exc_no_team_yet_notice");
125 }
126 else
127 {
128 $team_info = '<span class="warning">'.$lng->txt("exc_no_team_yet_notice").'</span>';
129 }
130
131 if(!$a_submission->getAssignment()->getTeamTutor())
132 {
133 $button = ilLinkButton::getInstance();
134 $button->setPrimary(true);
135 $button->setCaption("exc_create_team");
136 $button->setUrl($ilCtrl->getLinkTargetByClass(array("ilExSubmissionGUI", "ilExSubmissionTeamGUI"), "createTeam"));
137 $team_info .= " ".$button->render();
138
139 $team_info .= '<div class="ilFormInfo">'.$lng->txt("exc_no_team_yet_info").'</div>';
140 }
141 else
142 {
143 $team_info .= '<div class="ilFormInfo">'.$lng->txt("exc_no_team_yet_info_tutor").'</div>';
144 }
145 }
146 else
147 {
148 $team_info = '<span class="warning">'.$lng->txt("exc_create_team_times_up_warning").'</span>';
149 }
150
151 $a_info->addProperty($lng->txt("exc_team_members"), $team_info);
152 }
153 }
154
156 {
157 $this->ctrl->returnToParent($this);
158 }
159
160 public static function handleTabs()
161 {
162 global $ilTabs, $ilCtrl, $lng;
163
164 $ilTabs->addTab("team", $lng->txt("exc_team"),
165 $ilCtrl->getLinkTargetByClass("ilExSubmissionTeamGUI", "submissionScreenTeam"));
166
167 $ilTabs->addTab("log", $lng->txt("exc_team_log"),
168 $ilCtrl->getLinkTargetByClass("ilExSubmissionTeamGUI", "submissionScreenTeamLog"));
169 }
170
171 protected function canEditTeam()
172 {
173 return (($this->submission->canSubmit() &&
174 !$this->submission->getAssignment()->getTeamTutor()) ||
175 $this->submission->isTutor());
176 }
177
184 {
185 global $ilToolbar;
186
187 // #13414
188 $read_only = !$this->canEditTeam();
189
190 if ($this->submission->getAssignment()->afterDeadlineStrict(false))
191 {
192 ilUtil::sendInfo($this->lng->txt("exercise_time_over"));
193 }
194 else if(!$read_only)
195 {
196 // add member
197 include_once './Services/Search/classes/class.ilRepositorySearchGUI.php';
199 $this,
200 $ilToolbar,
201 array(
202 'auto_complete_name' => $this->lng->txt('user'),
203 'submit_name' => $this->lng->txt('add'),
204 'add_search' => true,
205 'add_from_container' => $this->exercise->getRefId()
206 )
207 );
208 }
209 else if($this->submission->getAssignment()->getTeamTutor())
210 {
211 ilUtil::sendInfo($this->lng->txt("exc_no_team_yet_info_tutor"));
212 }
213
214 include_once "Modules/Exercise/classes/class.ilExAssignmentTeamTableGUI.php";
216 $this,
217 "submissionScreenTeam",
219 $this->exercise->getRefId(),
220 $this->team,
221 $read_only
222 );
223
224 $this->tpl->setContent($tbl->getHTML());
225 }
226
227 public function addTeamMemberActionObject($a_user_ids = array())
228 {
229 if(!$this->canEditTeam())
230 {
231 $this->ctrl->redirect("submissionScreenTeam");
232 }
233
234 if(!count($a_user_ids))
235 {
236 ilUtil::sendFailure($this->lng->txt("no_checkbox"));
237 return false;
238 }
239
240 foreach($a_user_ids as $user_id)
241 {
242 if($this->team->addTeamMember($user_id, $this->exercise->getRefId()))
243 {
244 $new_users[] = $user_id;
245
246 // #14277
247 if (!$this->exercise->members_obj->isAssigned($user_id))
248 {
249 $this->exercise->members_obj->assignMember($user_id);
250 }
251 }
252 else
253 {
254 // #11959
255 ilUtil::sendFailure($this->lng->txt("exc_members_already_assigned_team"), true);
256 }
257 }
258
259 if(sizeof($new_users))
260 {
261 // re-evaluate complete team, as new member could have already submitted
262 $this->exercise->processExerciseStatus(
263 $this->assignment,
264 $this->team->getMembers(),
265 $this->submission->hasSubmitted(),
266 $this->submission->validatePeerReviews()
267 );
268 // :TODO: notification?
269 }
270
271 ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
272 $this->ctrl->redirect($this, "submissionScreenTeam");
273 }
274
275 public function confirmDeleteTeamObject()
276 {
278 }
279
280 public function confirmRemoveTeamMemberObject($a_full_delete = false)
281 {
282 global $ilUser, $tpl;
283
284 if(!$this->submission->isTutor())
285 {
286 $ids = (bool)$a_full_delete
287 ? $this->team->getMembers()
288 : $_POST["id"];
289
290 if(!sizeof($ids) &&
291 !$this->canEditTeam())
292 {
293 ilUtil::sendFailure($this->lng->txt("select_one"), true);
294 $this->ctrl->redirect($this, "submissionScreenTeam");
295 }
296 }
297 else
298 {
299 $ids = array($_GET["id"]);
300 if(!sizeof($ids))
301 {
302 $this->returnToParentObject();
303 }
304 }
305
306 $members = $this->team->getMembers();
307 if(sizeof($members) <= sizeof($ids))
308 {
309 if(sizeof($members) == 1 && $members[0] == $ilUser->getId())
310 {
311 // direct team deletion - no confirmation
312 return $this->removeTeamMemberObject($a_full_delete);
313 }
314 else
315 {
316 ilUtil::sendFailure($this->lng->txt("exc_team_at_least_one"), true);
317 $this->ctrl->redirect($this, "submissionScreenTeam");
318 }
319 }
320
321 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
322 $cgui = new ilConfirmationGUI();
323 $cgui->setFormAction($this->ctrl->getFormAction($this));
324 $cgui->setHeaderText($this->lng->txt("exc_team_member_remove_sure"));
325 $cgui->setConfirm($this->lng->txt("remove"), "removeTeamMember");
326 $cgui->setCancel($this->lng->txt("cancel"), $this->submission->isTutor()
327 ? "returnToParent"
328 : "submissionScreenTeam");
329
330 $files = $this->submission->getFiles();
331
332 include_once "Services/User/classes/class.ilUserUtil.php";
333
334 foreach($ids as $id)
335 {
336 $details = array();
337 foreach ($files as $file)
338 {
339 if($file["owner_id"] == $id)
340 {
341 $details[] = $file["filetitle"];
342 }
343 }
345 if(sizeof($details))
346 {
347 $uname .= ": ".implode(", ", $details);
348 }
349 $cgui->addItem("id[]", $id, $uname);
350 }
351
352 $tpl->setContent($cgui->getHTML());
353 }
354
355 public function removeTeamMemberObject($a_full_delete = false)
356 {
357 global $ilUser;
358
359 $cancel_cmd = $this->submission->isTutor()
360 ? "returnToParent"
361 : "submissionScreenTeam";
362
363 $ids = (bool)$a_full_delete
364 ? $this->team->getMembers()
365 : $_POST["id"];
366
367 if(!sizeof($ids) ||
368 !$this->canEditTeam())
369 {
370 ilUtil::sendFailure($this->lng->txt("select_one"), true);
371 $this->ctrl->redirect($this, $cancel_cmd);
372 }
373
374 $team_deleted = (bool)$a_full_delete;
375 if(!$team_deleted)
376 {
377 $members = $this->team->getMembers();
378 if(sizeof($members) <= sizeof($ids))
379 {
380 if(sizeof($members) == 1 && $members[0] == $ilUser->getId())
381 {
382 $team_deleted = true;
383 }
384 else
385 {
386 ilUtil::sendFailure($this->lng->txt("exc_team_at_least_one"), true);
387 $this->ctrl->redirect($this, $cancel_cmd);
388 }
389 }
390 }
391
392 foreach($ids as $user_id)
393 {
394 $this->team->removeTeamMember($user_id, $this->exercise->getRefId());
395 }
396
397 // reset ex team members, as any submission is not valid without team
398 $this->exercise->processExerciseStatus(
399 $this->assignment,
400 $ids,
401 false
402 );
403
404 if(!$team_deleted)
405 {
406 // re-evaluate complete team, as removed member might have had submitted
407 $this->exercise->processExerciseStatus(
408 $this->assignment,
409 $this->team->getMembers(),
410 $this->submission->hasSubmitted(),
411 $this->submission->validatePeerReviews()
412 );
413 }
414
415 ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
416 if(!$team_deleted)
417 {
418 $this->ctrl->redirect($this, $cancel_cmd);
419 }
420 else
421 {
422 $this->ctrl->redirect($this, "returnToParent");
423 }
424 }
425
427 {
428 $this->tabs_gui->activateTab("log");
429
430 include_once "Modules/Exercise/classes/class.ilExAssignmentTeamLogTableGUI.php";
431 $tbl = new ilExAssignmentTeamLogTableGUI($this, "submissionScreenTeamLog",
432 $this->team);
433
434 $this->tpl->setContent($tbl->getHTML());
435 }
436
438 {
440 $this->assignment->getId(),
441 $this->submission->getUserId(),
442 true
443 );
444 ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
445 $this->returnToParentObject();
446 }
447
449 {
450 include_once "Modules/Exercise/classes/class.ilExAssignmentTeamLogTableGUI.php";
451 $tbl = new ilExAssignmentTeamLogTableGUI($this, "showTeamLog", $this->team);
452 $this->tpl->setContent($tbl->getHTML());
453 }
454
455 public function createTeamObject()
456 {
457 global $ilCtrl, $ilUser, $lng, $tpl;
458
459 if($this->submission->canSubmit())
460 {
461 $options = ilExAssignmentTeam::getAdoptableTeamAssignments($this->assignment->getExerciseId(), $this->assignment->getId(), $ilUser->getId());
462 if(sizeof($options))
463 {
464 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
465 $form = new ilPropertyFormGUI();
466 $form->setTitle($lng->txt("exc_team_assignment_adopt_user"));
467 $form->setFormAction($ilCtrl->getFormAction($this, "createAdoptedTeam"));
468
469 $teams = new ilRadioGroupInputGUI($lng->txt("exc_assignment"), "ass_adpt");
470 $teams->setValue(-1);
471
472 $teams->addOption(new ilRadioOption($lng->txt("exc_team_assignment_adopt_none_user"), -1));
473
474 $current_map = ilExAssignmentTeam::getAssignmentTeamMap($this->assignment->getId());
475
476 include_once "Services/User/classes/class.ilUserUtil.php";
477 foreach($options as $id => $item)
478 {
479 $members = array();
480 $free = false;
481 foreach($item["user_team"] as $user_id)
482 {
483 $members[$user_id] = ilUserUtil::getNamePresentation($user_id);
484
485 if(array_key_exists($user_id, $current_map))
486 {
487 $members[$user_id] .= " (".$lng->txt("exc_team_assignment_adopt_already_assigned").")";
488 }
489 else
490 {
491 $free = true;
492 }
493 }
494 asort($members);
495 $members = implode("<br />", $members);
496 $option = new ilRadioOption($item["title"], $id);
497 $option->setInfo($members);
498 if(!$free)
499 {
500 $option->setDisabled(true);
501 }
502 $teams->addOption($option);
503 }
504
505 $form->addItem($teams);
506
507 $form->addCommandButton("createAdoptedTeam", $lng->txt("save"));
508 $form->addCommandButton("returnToParent", $lng->txt("cancel"));
509
510 $tpl->setContent($form->getHTML());
511 return;
512 }
513
514 ilExAssignmentTeam::getTeamId($this->assignment->getId(), $ilUser->getId(), true);
515
516 // #18046
517 if(!$this->exercise->members_obj->isAssigned($ilUser->getId()))
518 {
519 $this->exercise->members_obj->assignMember($ilUser->getId());
520 }
521
522 ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
523 }
524
525 $ilCtrl->redirect($this, "returnToParent");
526 }
527
528 public function createAdoptedTeamObject()
529 {
530 global $ilCtrl, $ilUser, $lng;
531
532 if($this->submission->canSubmit())
533 {
534 $src_ass_id = (int)$_POST["ass_adpt"];
535 if($src_ass_id > 0)
536 {
537 ilExAssignmentTeam::adoptTeams($src_ass_id, $this->assignment->getId(), $ilUser->getId(), $this->exercise->getRefId());
538 }
539 else
540 {
541 ilExAssignmentTeam::getTeamId($this->assignment->getId(), $ilUser->getId(), true);
542 }
543
544 ilUtil::sendSuccess($lng->txt("settings_saved"), true);
545 }
546
547 $ilCtrl->redirect($this, "returnToParent");
548 }
549
550
555 {
556 if(!strlen(trim($_POST['user_login'])))
557 {
558 ilUtil::sendFailure($this->lng->txt('msg_no_search_string'));
560 return false;
561 }
562
563 $users = explode(',', $_POST['user_login']);
564
565 $user_ids = array();
566 foreach($users as $user)
567 {
568 $user_id = ilObjUser::_lookupId($user);
569
570 if(!$user_id)
571 {
572 ilUtil::sendFailure($this->lng->txt('user_not_known'));
573 return $this->submissionScreenTeamObject();
574 }
575
576 $user_ids[] = $user_id;
577 }
578
579 return $this->addTeamMemberActionObject($user_ids);
580 }
581}
582
global $tpl
Definition: ilias.php:8
$files
Definition: add-vimline.php:18
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
Confirmation screen class.
List all team members of an assignment.
static getAssignmentTeamMap($a_ass_id)
Get team structure for assignment.
static getTeamId($a_assignment_id, $a_user_id, $a_create_on_demand=false)
Get team id for member id.
static getAdoptableTeamAssignments($a_exercise_id, $a_exclude_ass_id=null, $a_user_id=null)
static adoptTeams($a_source_ass_id, $a_target_ass_id, $a_user_id=null, $a_exc_ref_id=null)
addTeamMemberActionObject($a_user_ids=array())
submissionScreenTeamObject()
Displays a form which allows members to manage team uploads.
static getOverviewContent(ilInfoScreenGUI $a_info, ilExSubmission $a_submission)
addUserFromAutoCompleteObject()
Add user as member.
removeTeamMemberObject($a_full_delete=false)
confirmRemoveTeamMemberObject($a_full_delete=false)
__construct(ilObjExercise $a_exercise, ilExSubmission $a_submission)
Exercise submission.
getLastSubmission()
Get the date of the last submission of a user for the assignment.
Class ilInfoScreenGUI.
addProperty($a_name, $a_value, $a_link="")
add a property to current section
static getInstance()
Factory.
Class ilObjExercise.
static _lookupId($a_user_str)
Lookup id by login.
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
static fillAutoCompleteToolbar($parent_object, ilToolbarGUI $toolbar=null, $a_options=array(), $a_sticky=false)
fill toolbar with
static getNamePresentation($a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true, $a_return_data_array=false)
Default behaviour is:
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$tbl
Definition: example_048.php:81
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file
$cmd
Definition: sahs_server.php:35
if(!is_array($argv)) $options
$ilUser
Definition: imgupload.php:18