ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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{
17 protected $ctrl;
18
22 protected $tabs_gui;
23
27 protected $lng;
28
32 protected $tpl;
33
37 protected $toolbar;
38
42 protected $user;
43
44 protected $exercise; // [ilObjExercise]
45 protected $assignment; // [ilExAssignment]
46 protected $submission; // [ilExSubmission]
47 protected $team; // [ilExAssignmentTeam]
48
49 public function __construct(ilObjExercise $a_exercise, ilExSubmission $a_submission)
50 {
51 global $DIC;
52
53 $this->toolbar = $DIC->toolbar();
54 $this->user = $DIC->user();
55 $ilCtrl = $DIC->ctrl();
56 $ilTabs = $DIC->tabs();
57 $lng = $DIC->language();
58 $tpl = $DIC["tpl"];
59
60 $this->exercise = $a_exercise;
61 $this->submission = $a_submission;
62 $this->assignment = $a_submission->getAssignment();
63
64 // :TODO:
65 $this->ctrl = $ilCtrl;
66 $this->tabs_gui = $ilTabs;
67 $this->lng = $lng;
68 $this->tpl = $tpl;
69 }
70
71 public function executeCommand()
72 {
74
75 $class = $ilCtrl->getNextClass($this);
76 $cmd = $ilCtrl->getCmd("submissionScreenTeam");
77
78 if (!$this->assignment->hasTeam() ||
79 !$this->submission->canView()) {
80 return;
81 }
82 $this->team = $this->submission->getTeam();
83
84 if (!$this->submission->isTutor()) {
86 $this->tabs_gui->activateTab("team");
87 }
88
89 switch ($class) {
90 case 'ilrepositorysearchgui':
91 $this->ctrl->setReturn($this, 'submissionScreenTeam');
92 include_once('./Services/Search/classes/class.ilRepositorySearchGUI.php');
93 $rep_search = new ilRepositorySearchGUI();
94 if (!$this->submission->isTutor()) {
96 }
97 $rep_search->setTitle($this->lng->txt("exc_team_member_add"));
98 $rep_search->setCallback($this, 'addTeamMemberActionObject');
99 $this->ctrl->forwardCommand($rep_search);
100 break;
101
102 default:
103 $this->{$cmd . "Object"}();
104 break;
105 }
106 }
107
108 public static function getOverviewContent(ilInfoScreenGUI $a_info, ilExSubmission $a_submission)
109 {
110 global $DIC;
111
112 $lng = $DIC->language();
113 $ilCtrl = $DIC->ctrl();
114
115 if (!$a_submission->getAssignment()->hasTeam()) {
116 return;
117 }
118
119 $team_members = $a_submission->getTeam()->getMembers();
120 if (sizeof($team_members)) {
121 $team = array();
122 foreach ($team_members as $member_id) {
123 //$team[] = ilObjUser::_lookupFullname($member_id);
124 include_once("./Services/User/classes/class.ilUserUtil.php");
125 $team[] = ilUserUtil::getNamePresentation($member_id, false, false, "", false);
126 }
127 $team = implode("; ", $team);
128
129 if (!$a_submission->getAssignment()->getTeamTutor()) {
130 #23685
131 // any team member upload?
132 if (!$a_submission->getLastSubmission()) {
133 $button = ilLinkButton::getInstance();
134 $button->setCaption("exc_delete_team");
135 $button->setUrl($ilCtrl->getLinkTargetByClass(array("ilExSubmissionGUI", "ilExSubmissionTeamGUI"), "confirmDeleteTeam"));
136 $team .= " " . $button->render();
137 }
138 $button = ilLinkButton::getInstance();
139 $button->setCaption("exc_manage_team");
140 $button->setUrl($ilCtrl->getLinkTargetByClass(array("ilExSubmissionGUI", "ilExSubmissionTeamGUI"), "submissionScreenTeam"));
141 } else {
142 $button = ilLinkButton::getInstance();
143 $button->setCaption("exc_team_log");
144 $button->setUrl($ilCtrl->getLinkTargetByClass(array("ilExSubmissionGUI", "ilExSubmissionTeamGUI"), "submissionScreenTeamLog"));
145 }
146 $team .= " " . $button->render();
147
148 $a_info->addProperty($lng->txt("exc_team_members"), $team);
149 } else {
150 if ($a_submission->getAssignment()->beforeDeadline()) {
151 if (!$a_submission->hasSubmitted()) {
152 $team_info = $lng->txt("exc_no_team_yet_notice");
153 } else {
154 $team_info = '<span class="warning">' . $lng->txt("exc_no_team_yet_notice") . '</span>';
155 }
156
157 if (!$a_submission->getAssignment()->getTeamTutor()) {
158 $button = ilLinkButton::getInstance();
159 $button->setPrimary(true);
160 $button->setCaption("exc_create_team");
161 $button->setUrl($ilCtrl->getLinkTargetByClass(array("ilExSubmissionGUI", "ilExSubmissionTeamGUI"), "createTeam"));
162 $team_info .= " " . $button->render();
163
164 $team_info .= '<div class="ilFormInfo">' . $lng->txt("exc_no_team_yet_info") . '</div>';
165 } else {
166 $team_info .= '<div class="ilFormInfo">' . $lng->txt("exc_no_team_yet_info_tutor") . '</div>';
167 }
168 } else {
169 $team_info = '<span class="warning">' . $lng->txt("exc_create_team_times_up_warning") . '</span>';
170 }
171
172 $a_info->addProperty($lng->txt("exc_team_members"), $team_info);
173 }
174 }
175
176 public function returnToParentObject()
177 {
178 $this->ctrl->returnToParent($this);
179 }
180
181 public static function handleTabs()
182 {
183 global $DIC;
184
185 $ilTabs = $DIC->tabs();
186 $ilCtrl = $DIC->ctrl();
187 $lng = $DIC->language();
188
189 $ilTabs->addTab(
190 "team",
191 $lng->txt("exc_team"),
192 $ilCtrl->getLinkTargetByClass("ilExSubmissionTeamGUI", "submissionScreenTeam")
193 );
194
195 $ilTabs->addTab(
196 "log",
197 $lng->txt("exc_team_log"),
198 $ilCtrl->getLinkTargetByClass("ilExSubmissionTeamGUI", "submissionScreenTeamLog")
199 );
200 }
201
202 protected function canEditTeam()
203 {
204 return (($this->submission->canSubmit() &&
205 !$this->submission->getAssignment()->getTeamTutor()) ||
206 $this->submission->isTutor());
207 }
208
215 {
216 $ilToolbar = $this->toolbar;
217
218 // #13414
219 $read_only = !$this->canEditTeam();
220
221 if ($this->submission->getAssignment()->afterDeadlineStrict(false)) {
222 ilUtil::sendInfo($this->lng->txt("exercise_time_over"));
223 } elseif (!$read_only) {
224 $add_search = $this->submission->isTutor();
225 // add member
226 include_once './Services/Search/classes/class.ilRepositorySearchGUI.php';
228 $this,
229 $ilToolbar,
230 array(
231 'auto_complete_name' => $this->lng->txt('user'),
232 'submit_name' => $this->lng->txt('add'),
233 'add_search' => $add_search,
234 'add_from_container' => $this->exercise->getRefId()
235 )
236 );
237 } elseif ($this->submission->getAssignment()->getTeamTutor()) {
238 ilUtil::sendInfo($this->lng->txt("exc_no_team_yet_info_tutor"));
239 }
240
241 include_once "Modules/Exercise/classes/class.ilExAssignmentTeamTableGUI.php";
243 $this,
244 "submissionScreenTeam",
246 $this->exercise->getRefId(),
247 $this->team,
248 $read_only
249 );
250
251 $this->tpl->setContent($tbl->getHTML());
252 }
253
254 public function addTeamMemberActionObject($a_user_ids = array())
255 {
256 if (!$this->canEditTeam()) {
257 $this->ctrl->redirect("submissionScreenTeam");
258 }
259
260 if (!count($a_user_ids)) {
261 ilUtil::sendFailure($this->lng->txt("no_checkbox"));
262 return false;
263 }
264
265 $new_users = [];
266
267 foreach ($a_user_ids as $user_id) {
268 if ($this->team->addTeamMember($user_id, $this->exercise->getRefId())) {
269 $new_users[] = $user_id;
270
271 // #14277
272 if (!$this->exercise->members_obj->isAssigned($user_id)) {
273 $this->exercise->members_obj->assignMember($user_id);
274 }
275 } else {
276 // #11959
277 ilUtil::sendFailure($this->lng->txt("exc_members_already_assigned_team"), true);
278 }
279 }
280
281 if (sizeof($new_users)) {
282 // re-evaluate complete team, as new member could have already submitted
283 $this->exercise->processExerciseStatus(
284 $this->assignment,
285 $this->team->getMembers(),
286 $this->submission->hasSubmitted(),
287 $this->submission->validatePeerReviews()
288 );
289 // :TODO: notification?
290 ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
291 }
292
293 $this->ctrl->redirect($this, "submissionScreenTeam");
294 }
295
296 public function confirmDeleteTeamObject()
297 {
299 }
300
301 public function confirmRemoveTeamMemberObject($a_full_delete = false)
302 {
305
306 if (!$this->submission->isTutor()) {
307 $ids = [];
308 if ((bool) $a_full_delete) {
309 $ids = $this->team->getMembers();
310 } elseif (isset($_POST["id"]) && is_array($_POST["id"])) {
311 $ids = $_POST["id"];
312 }
313 $ids = array_filter(array_map('intval', $ids));
314
315 if (0 === count($ids) && !$this->canEditTeam()) {
316 ilUtil::sendFailure($this->lng->txt("select_one"), true);
317 $this->ctrl->redirect($this, "submissionScreenTeam");
318 }
319 } else {
320 $ids = array_filter(array_map('intval', array($_GET["id"])));
321 if (0 === count($ids)) {
322 $this->returnToParentObject();
323 }
324 }
325
326 $members = $this->team->getMembers();
327 if (sizeof($members) <= sizeof($ids)) {
328 if (sizeof($members) == 1 && $members[0] == $ilUser->getId()) {
329 // direct team deletion - no confirmation
330 return $this->removeTeamMemberObject($a_full_delete);
331 } else {
332 ilUtil::sendFailure($this->lng->txt("exc_team_at_least_one"), true);
333 $this->ctrl->redirect($this, "submissionScreenTeam");
334 }
335 }
336
337 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
338 $cgui = new ilConfirmationGUI();
339 $cgui->setFormAction($this->ctrl->getFormAction($this));
340 $cgui->setHeaderText($this->lng->txt("exc_team_member_remove_sure"));
341 $cgui->setConfirm($this->lng->txt("remove"), "removeTeamMember");
342 $cgui->setCancel($this->lng->txt("cancel"), $this->submission->isTutor()
343 ? "returnToParent"
344 : "submissionScreenTeam");
345
346 $files = $this->submission->getFiles();
347
348 include_once "Services/User/classes/class.ilUserUtil.php";
349
350 foreach ($ids as $id) {
351 $details = array();
352 foreach ($files as $file) {
353 if ($file["owner_id"] == $id) {
354 $details[] = $file["filetitle"];
355 }
356 }
358 if (sizeof($details)) {
359 $uname .= ": " . implode(", ", $details);
360 }
361 $cgui->addItem("id[]", $id, $uname);
362 }
363
364 $tpl->setContent($cgui->getHTML());
365 }
366
367 public function removeTeamMemberObject($a_full_delete = false)
368 {
370
371 $cancel_cmd = $this->submission->isTutor()
372 ? "returnToParent"
373 : "submissionScreenTeam";
374
375 $ids = [];
376 if ((bool) $a_full_delete) {
377 $ids = $this->team->getMembers();
378 } elseif (isset($_POST["id"]) && is_array($_POST["id"])) {
379 $ids = $_POST["id"];
380 }
381 $ids = array_filter(array_map('intval', $ids));
382
383 if (0 === count($ids) && !$this->canEditTeam()) {
384 ilUtil::sendFailure($this->lng->txt("select_one"), true);
385 $this->ctrl->redirect($this, $cancel_cmd);
386 }
387
388 $team_deleted = (bool) $a_full_delete;
389 if (!$team_deleted) {
390 $members = $this->team->getMembers();
391 if (sizeof($members) <= sizeof($ids)) {
392 if (sizeof($members) == 1 && $members[0] == $ilUser->getId()) {
393 $team_deleted = true;
394 } else {
395 ilUtil::sendFailure($this->lng->txt("exc_team_at_least_one"), true);
396 $this->ctrl->redirect($this, $cancel_cmd);
397 }
398 }
399 }
400
401 foreach ($ids as $user_id) {
402 $this->team->removeTeamMember($user_id, $this->exercise->getRefId());
403 }
404
405 // reset ex team members, as any submission is not valid without team
406 $this->exercise->processExerciseStatus(
407 $this->assignment,
408 $ids,
409 false
410 );
411
412 if (!$team_deleted) {
413 // re-evaluate complete team, as removed member might have had submitted
414 $this->exercise->processExerciseStatus(
415 $this->assignment,
416 $this->team->getMembers(),
417 $this->submission->hasSubmitted(),
418 $this->submission->validatePeerReviews()
419 );
420 }
421
422 ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
423 if (!$team_deleted) {
424 $this->ctrl->redirect($this, $cancel_cmd);
425 } else {
426 $this->ctrl->redirect($this, "returnToParent");
427 }
428 }
429
431 {
432 $this->tabs_gui->activateTab("log");
433
434 include_once "Modules/Exercise/classes/class.ilExAssignmentTeamLogTableGUI.php";
436 $this,
437 "submissionScreenTeamLog",
438 $this->team
439 );
440
441 $this->tpl->setContent($tbl->getHTML());
442 }
443
445 {
447 $this->assignment->getId(),
448 $this->submission->getUserId(),
449 true
450 );
451 ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
452 $this->returnToParentObject();
453 }
454
455 public function showTeamLogObject()
456 {
457 include_once "Modules/Exercise/classes/class.ilExAssignmentTeamLogTableGUI.php";
458 $tbl = new ilExAssignmentTeamLogTableGUI($this, "showTeamLog", $this->team);
459 $this->tpl->setContent($tbl->getHTML());
460 }
461
462 public function createTeamObject()
463 {
468
469 if ($this->submission->canSubmit()) {
470 $options = ilExAssignmentTeam::getAdoptableTeamAssignments($this->assignment->getExerciseId(), $this->assignment->getId(), $ilUser->getId());
471 if (sizeof($options)) {
472 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
473 $form = new ilPropertyFormGUI();
474 $form->setTitle($lng->txt("exc_team_assignment_adopt_user"));
475 $form->setFormAction($ilCtrl->getFormAction($this, "createAdoptedTeam"));
476
477 $teams = new ilRadioGroupInputGUI($lng->txt("exc_assignment"), "ass_adpt");
478 $teams->setValue(-1);
479
480 $teams->addOption(new ilRadioOption($lng->txt("exc_team_assignment_adopt_none_user"), -1));
481
482 $current_map = ilExAssignmentTeam::getAssignmentTeamMap($this->assignment->getId());
483
484 include_once "Services/User/classes/class.ilUserUtil.php";
485 foreach ($options as $id => $item) {
486 $members = array();
487 $free = false;
488 foreach ($item["user_team"] as $user_id) {
489 $members[$user_id] = ilUserUtil::getNamePresentation($user_id);
490
491 if (array_key_exists($user_id, $current_map)) {
492 $members[$user_id] .= " (" . $lng->txt("exc_team_assignment_adopt_already_assigned") . ")";
493 } else {
494 $free = true;
495 }
496 }
497 asort($members);
498 $members = implode("<br />", $members);
499 $option = new ilRadioOption($item["title"], $id);
500 $option->setInfo($members);
501 if (!$free) {
502 $option->setDisabled(true);
503 }
504 $teams->addOption($option);
505 }
506
507 $form->addItem($teams);
508
509 $form->addCommandButton("createAdoptedTeam", $lng->txt("save"));
510 $form->addCommandButton("returnToParent", $lng->txt("cancel"));
511
512 $tpl->setContent($form->getHTML());
513 return;
514 }
515
516 ilExAssignmentTeam::getTeamId($this->assignment->getId(), $ilUser->getId(), true);
517
518 // #18046
519 if (!$this->exercise->members_obj->isAssigned($ilUser->getId())) {
520 $this->exercise->members_obj->assignMember($ilUser->getId());
521 }
522
523 ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
524 }
525
526 $ilCtrl->redirect($this, "returnToParent");
527 }
528
529 public function createAdoptedTeamObject()
530 {
534
535 if ($this->submission->canSubmit()) {
536 $src_ass_id = (int) $_POST["ass_adpt"];
537 if ($src_ass_id > 0) {
538 ilExAssignmentTeam::adoptTeams($src_ass_id, $this->assignment->getId(), $ilUser->getId(), $this->exercise->getRefId());
539 } else {
540 ilExAssignmentTeam::getTeamId($this->assignment->getId(), $ilUser->getId(), true);
541 }
542
543 ilUtil::sendSuccess($lng->txt("settings_saved"), true);
544 }
545
546 $ilCtrl->redirect($this, "returnToParent");
547 }
548
549
554 {
555 if (!strlen(trim($_POST['user_login']))) {
556 ilUtil::sendFailure($this->lng->txt('msg_no_search_string'));
558 return false;
559 }
560
561 $users = explode(',', $_POST['user_login']);
562
563 $user_ids = array();
564 foreach ($users as $user) {
565 $user_id = ilObjUser::_lookupId($user);
566
567 if (!$user_id) {
568 ilUtil::sendFailure($this->lng->txt('user_not_known'));
569 return $this->submissionScreenTeamObject();
570 }
571
572 $user_ids[] = $user_id;
573 }
574
575 return $this->addTeamMemberActionObject($user_ids);
576 }
577}
user()
Definition: user.php:4
$files
Definition: add-vimline.php:18
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
$users
Definition: authpage.php:44
$_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, $a_ctrl_path="ilpublicuserprofilegui")
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
if(!array_key_exists('StateId', $_REQUEST)) $id
global $ilCtrl
Definition: ilias.php:18
if(isset($_POST['submit'])) $form
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18