ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilExerciseManagementGUI.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.ilExSubmission.php";
5include_once "Modules/Exercise/classes/class.ilExSubmissionBaseGUI.php";
6
19{
23 protected $ctrl;
24
28 protected $tabs_gui;
29
33 protected $lng;
34
38 protected $tpl;
39
43 protected $toolbar;
44
45 protected $exercise; // [ilObjExercise]
46 protected $assignment; // [ilExAssignment]
47
48 const VIEW_ASSIGNMENT = 1;
50 const VIEW_GRADES = 3;
51
58 public function __construct(ilObjExercise $a_exercise, ilExAssignment $a_ass = null)
59 {
60 global $DIC;
61
62 $this->toolbar = $DIC->toolbar();
63 $ilCtrl = $DIC->ctrl();
64 $ilTabs = $DIC->tabs();
65 $lng = $DIC->language();
66 $tpl = $DIC["tpl"];
67
68 $this->exercise = $a_exercise;
69 $this->assignment = $a_ass;
70
71 $ilCtrl->saveParameter($this, array("vw", "member_id"));
72
73 // :TODO:
74 $this->ctrl = $ilCtrl;
75 $this->tabs_gui = $ilTabs;
76 $this->lng = $lng;
77 $this->tpl = $tpl;
78 }
79
80 public function executeCommand()
81 {
84 $ilTabs = $this->tabs_gui;
85
86 $class = $ilCtrl->getNextClass($this);
87 $cmd = $ilCtrl->getCmd("listPublicSubmissions");
88
89 switch ($class) {
90 case "ilfilesystemgui":
91 $ilTabs->clearTargets();
92 $ilTabs->setBackTarget(
93 $lng->txt("back"),
94 $ilCtrl->getLinkTarget($this, $this->getViewBack())
95 );
96
97 ilUtil::sendInfo($lng->txt("exc_fb_tutor_info"));
98
99 include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
100 $fstorage = new ilFSStorageExercise($this->exercise->getId(), $this->assignment->getId());
101 $fstorage->create();
102
103 $submission = new ilExSubmission($this->assignment, (int) $_GET["member_id"]);
104 $feedback_id = $submission->getFeedbackId();
105 $noti_rec_ids = $submission->getUserIds();
106
107 include_once("./Services/User/classes/class.ilUserUtil.php");
108 $fs_title = array();
109 foreach ($noti_rec_ids as $rec_id) {
110 $fs_title[] = ilUserUtil::getNamePresentation($rec_id, false, false, "", true);
111 }
112 $fs_title = implode(" / ", $fs_title);
113
114 include_once("./Services/FileSystem/classes/class.ilFileSystemGUI.php");
115 $fs_gui = new ilFileSystemGUI($fstorage->getFeedbackPath($feedback_id));
116 $fs_gui->setTableId("excfbfil" . $this->assignment->getId() . "_" . $feedback_id);
117 $fs_gui->setAllowDirectories(false);
118 $fs_gui->setTitle($lng->txt("exc_fb_files") . " - " .
119 $this->assignment->getTitle() . " - " .
120 $fs_title);
121 $pcommand = $fs_gui->getLastPerformedCommand();
122 if (is_array($pcommand) && $pcommand["cmd"] == "create_file") {
123 foreach ($noti_rec_ids as $user_id) {
124 $member_status = $this->assignment->getMemberStatus($user_id);
125 $member_status->setFeedback(true);
126 $member_status->update();
127 }
128
129 $this->exercise->sendFeedbackFileNotification(
130 $pcommand["name"],
131 $noti_rec_ids,
132 $this->assignment->getId()
133 );
134 }
135 $this->ctrl->forwardCommand($fs_gui);
136 break;
137
138 case 'ilrepositorysearchgui':
139 include_once('./Services/Search/classes/class.ilRepositorySearchGUI.php');
140 $rep_search = new ilRepositorySearchGUI();
141 $ref_id = $this->exercise->getRefId();
142 $rep_search->addUserAccessFilterCallable(function ($a_user_ids) use ($ref_id) {
143 return $GLOBALS['DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
144 'edit_submissions_grades',
145 'edit_submissions_grades',
146 $ref_id,
147 $a_user_ids
148 );
149 });
150 $rep_search->setTitle($this->lng->txt("exc_add_participant"));
151 $rep_search->setCallback($this, 'addMembersObject');
152
153 // Set tabs
154 $this->addSubTabs("assignment");
155 $this->ctrl->setReturn($this, 'members');
156
157 $this->ctrl->forwardCommand($rep_search);
158 break;
159
160 case "ilexsubmissionteamgui":
161 include_once "Modules/Exercise/classes/class.ilExSubmissionTeamGUI.php";
162 $gui = new ilExSubmissionTeamGUI($this->exercise, $this->initSubmission());
163 $ilCtrl->forwardCommand($gui);
164 break;
165
166 case "ilexsubmissionfilegui":
167 include_once "Modules/Exercise/classes/class.ilExSubmissionFileGUI.php";
168 $gui = new ilExSubmissionFileGUI($this->exercise, $this->initSubmission());
169 $ilCtrl->forwardCommand($gui);
170 break;
171
172 case "ilexsubmissiontextgui":
173 $ilCtrl->saveParameter($this, array("part_id"));
174 include_once "Modules/Exercise/classes/class.ilExSubmissionTextGUI.php";
175 $gui = new ilExSubmissionTextGUI($this->exercise, $this->initSubmission());
176 $ilCtrl->forwardCommand($gui);
177 break;
178
179 case "ilexpeerreviewgui":
180 include_once "Modules/Exercise/classes/class.ilExPeerReviewGUI.php";
181 $gui = new ilExPeerReviewGUI($this->assignment, $this->initSubmission());
182 $ilCtrl->forwardCommand($gui);
183 break;
184
185 default:
186 $this->{$cmd . "Object"}();
187 break;
188 }
189 }
190
191 protected function getViewBack()
192 {
193 switch ($_REQUEST["vw"]) {
195 $back_cmd = "showParticipant";
196 break;
197
199 $back_cmd = "showGradesOverview";
200 break;
201
202 default:
203 // case self::VIEW_ASSIGNMENT:
204 $back_cmd = "members";
205 break;
206 }
207 return $back_cmd;
208 }
209
210 protected function initSubmission()
211 {
212 $back_cmd = $this->getViewBack();
213 $this->ctrl->setReturn($this, $back_cmd);
214
215 $this->tabs_gui->clearTargets();
216 $this->tabs_gui->setBackTarget(
217 $this->lng->txt("back"),
218 $this->ctrl->getLinkTarget($this, $back_cmd)
219 );
220
221 include_once "Modules/Exercise/classes/class.ilExSubmission.php";
222 return new ilExSubmission($this->assignment, $_REQUEST["member_id"], null, true);
223 }
224
230 public function addSubTabs($a_activate)
231 {
232 $ilTabs = $this->tabs_gui;
235
236 $ass_id = $_GET["ass_id"];
237 $part_id = $_GET["part_id"];
238
239 $ilCtrl->setParameter($this, "vw", "");
240 $ilCtrl->setParameter($this, "member_id", "");
241 $ilCtrl->setParameter($this, "ass_id", "");
242 $ilCtrl->setParameter($this, "part_id", "");
243
244 $ilTabs->addSubTab(
245 "assignment",
246 $lng->txt("exc_assignment_view"),
247 $ilCtrl->getLinkTarget($this, "members")
248 );
249 $ilTabs->addSubTab(
250 "participant",
251 $lng->txt("exc_participant_view"),
252 $ilCtrl->getLinkTarget($this, "showParticipant")
253 );
254 $ilTabs->addSubTab(
255 "grades",
256 $lng->txt("exc_grades_overview"),
257 $ilCtrl->getLinkTarget($this, "showGradesOverview")
258 );
259 $ilTabs->activateSubTab($a_activate);
260
261 $ilCtrl->setParameter($this, "ass_id", $ass_id);
262 $ilCtrl->setParameter($this, "part_id", $part_id);
263 }
264
265 public function waitingDownloadObject()
266 {
269
270 $ilCtrl->setParameterByClass("ilExSubmissionFileGUI", "member_id", (int) $_GET["member_id"]);
271 $url = $ilCtrl->getLinkTargetByClass(array("ilRepositoryGUI", "ilExerciseHandlerGUI", "ilObjExerciseGUI", "ilExerciseManagementGUI", "ilExSubmissionFileGUI"), "downloadNewReturned");
272 $js_url = $ilCtrl->getLinkTargetByClass(array("ilRepositoryGUI", "ilExerciseHandlerGUI", "ilObjExerciseGUI", "ilExerciseManagementGUI", "ilExSubmissionFileGUI"), "downloadNewReturned", "", "", false);
273 ilUtil::sendInfo($lng->txt("exc_wait_for_files") . "<a href='$url'> " . $lng->txt('exc_download_files') . "</a><script>window.location.href ='" . $js_url . "';</script>");
274 $this->membersObject();
275 }
276
280 public function membersObject()
281 {
283 $ilToolbar = $this->toolbar;
286
287 include_once 'Services/Tracking/classes/class.ilLPMarks.php';
288
289 $this->addSubTabs("assignment");
290
291 // assignment selection
292 include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
293 $ass = ilExAssignment::getInstancesByExercise($this->exercise->getId());
294
295 if (!$this->assignment) {
296 $this->assignment = current($ass);
297 }
298
299 reset($ass);
300 if (count($ass) > 1) {
301 $options = array();
302 foreach ($ass as $a) {
303 $options[$a->getId()] = $a->getTitle();
304 }
305 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
306 $si = new ilSelectInputGUI($this->lng->txt(""), "ass_id");
307 $si->setOptions($options);
308 $si->setValue($this->assignment->getId());
309 $ilToolbar->addStickyItem($si);
310
311 include_once("./Services/UIComponent/Button/classes/class.ilSubmitButton.php");
312 $button = ilSubmitButton::getInstance();
313 $button->setCaption("exc_select_ass");
314 $button->setCommand("selectAssignment");
315 $ilToolbar->addStickyItem($button);
316
317 $ilToolbar->addSeparator();
318 }
319 // #16165 - if only 1 assignment dropdown is not displayed;
320 elseif ($this->assignment) {
321 $ilCtrl->setParameter($this, "ass_id", $this->assignment->getId());
322 }
323
324 // add member
325 // is only shown if 'edit_submissions_grades' is granted by rbac. positions
326 // access is not sufficient.
327 $has_rbac_access = $GLOBALS['DIC']->access()->checkAccess(
328 'edit_submissions_grades',
329 '',
330 $this->exercise->getRefId()
331 );
332 if ($has_rbac_access) {
333 include_once './Services/Search/classes/class.ilRepositorySearchGUI.php';
335 $this,
336 $ilToolbar,
337 array(
338 'auto_complete_name' => $lng->txt('user'),
339 'submit_name' => $lng->txt('add'),
340 'add_search' => true,
341 'add_from_container' => $this->exercise->getRefId()
342 )
343 );
344 }
345
346 // #16168 - no assignments
347 if (count($ass) > 0) {
348 if ($has_rbac_access) {
349 $ilToolbar->addSeparator();
350 }
351
352 // we do not want the ilRepositorySearchGUI form action
353 $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
354
355 $ilCtrl->setParameter($this, "ass_id", $this->assignment->getId());
356
357 if ($this->assignment->getType() == ilExAssignment::TYPE_UPLOAD_TEAM) {
358 include_once("./Modules/Exercise/classes/class.ilExAssignmentTeam.php");
359 if (ilExAssignmentTeam::getAdoptableGroups($this->exercise->getRefId())) {
360 $ilToolbar->addButton(
361 $this->lng->txt("exc_adopt_group_teams"),
362 $this->ctrl->getLinkTarget($this, "adoptTeamsFromGroup")
363 );
364
365 $ilToolbar->addSeparator();
366 }
367 } elseif ($this->exercise->hasTutorFeedbackFile()) {
368 // multi-feedback
369 $ilToolbar->addButton(
370 $this->lng->txt("exc_multi_feedback"),
371 $this->ctrl->getLinkTarget($this, "showMultiFeedback")
372 );
373
374 $ilToolbar->addSeparator();
375 }
376
377 if (ilExSubmission::hasAnySubmissions($this->assignment->getId())) {
378 if ($this->assignment->getType() == ilExAssignment::TYPE_TEXT) {
379 $ilToolbar->addFormButton($lng->txt("exc_list_text_assignment"), "listTextAssignment");
380 } else {
381 $ilToolbar->addFormButton($lng->txt("download_all_returned_files"), "downloadAll");
382 }
383 }
384 $this->ctrl->setParameter($this, "vw", self::VIEW_ASSIGNMENT);
385
386 include_once("./Modules/Exercise/classes/class.ilExerciseMemberTableGUI.php");
387 $exc_tab = new ilExerciseMemberTableGUI($this, "members", $this->exercise, $this->assignment->getId());
388 $tpl->setContent(
389 $exc_tab->getHTML() .
390 $this->initIndividualDeadlineModal()
391 );
392 } else {
393 ilUtil::sendInfo($lng->txt("exc_no_assignments_available"));
394 }
395
396 $ilCtrl->setParameter($this, "ass_id", "");
397
398 return;
399 }
400
401 public function membersApplyObject()
402 {
403 $this->saveStatusAllObject(null, false);
404 include_once("./Modules/Exercise/classes/class.ilExerciseMemberTableGUI.php");
405 $exc_tab = new ilExerciseMemberTableGUI($this, "members", $this->exercise, $this->assignment->getId());
406 $exc_tab->resetOffset();
407 $exc_tab->writeFilterToSession();
408
409 $this->membersObject();
410 }
411
412 public function membersResetObject()
413 {
414 include_once("./Modules/Exercise/classes/class.ilExerciseMemberTableGUI.php");
415 $exc_tab = new ilExerciseMemberTableGUI($this, "members", $this->exercise, $this->assignment->getId());
416 $exc_tab->resetOffset();
417 $exc_tab->resetFilter();
418
419 $this->membersObject();
420 }
421
425 public function saveGradesObject()
426 {
429
430 include_once 'Services/Tracking/classes/class.ilLPMarks.php';
431
432 if (is_array($_POST["lcomment"])) {
433 foreach ($_POST["lcomment"] as $k => $v) {
434 $marks_obj = new ilLPMarks($this->exercise->getId(), (int) $k);
435 $marks_obj->setComment(ilUtil::stripSlashes($v));
436 $marks_obj->setMark(ilUtil::stripSlashes($_POST["mark"][$k]));
437 $marks_obj->update();
438 }
439 }
440 ilUtil::sendSuccess($lng->txt("exc_msg_saved_grades"), true);
441 $ilCtrl->redirect($this, "showGradesOverview");
442 }
443
444
445 // TEXT ASSIGNMENT ?!
446
448 {
449 $this->listTextAssignmentObject(true);
450 }
451
452 public function listTextAssignmentObject($a_show_peer_review = false)
453 {
456 $ilTabs = $this->tabs_gui;
458
459 if (!$this->assignment || $this->assignment->getType() != ilExAssignment::TYPE_TEXT) {
460 $ilCtrl->redirect($this, "members");
461 }
462
463 $ilTabs->clearTargets();
464 $ilTabs->setBackTarget(
465 $lng->txt("back"),
466 $ilCtrl->getLinkTarget($this, "members")
467 );
468
469 if ($a_show_peer_review) {
470 $cmd = "listTextAssignmentWithPeerReview";
471 } else {
472 $cmd = "listTextAssignment";
473 }
474 include_once "Modules/Exercise/classes/class.ilExAssignmentListTextTableGUI.php";
475 $tbl = new ilExAssignmentListTextTableGUI($this, $cmd, $this->assignment, $a_show_peer_review);
476 $tpl->setContent($tbl->getHTML());
477 }
478
479
484 {
485 if (!strlen(trim($_POST['user_login']))) {
486 ilUtil::sendFailure($this->lng->txt('msg_no_search_string'));
487 $this->membersObject();
488 return false;
489 }
490 $users = explode(',', $_POST['user_login']);
491
492 $user_ids = array();
493 foreach ($users as $user) {
494 $user_id = ilObjUser::_lookupId($user);
495
496 if (!$user_id) {
497 ilUtil::sendFailure($this->lng->txt('user_not_known'));
498 return $this->membersObject();
499 }
500
501 $user_ids[] = $user_id;
502 }
503
504 if (!$this->addMembersObject($user_ids)) {
505 $this->membersObject();
506 return false;
507 }
508 return true;
509 }
510
514 public function addMembersObject($a_user_ids = array())
515 {
516 if (!count($a_user_ids)) {
517 ilUtil::sendFailure($this->lng->txt("no_checkbox"));
518 return false;
519 }
520
521 if (!$this->exercise->members_obj->assignMembers($a_user_ids)) {
522 ilUtil::sendFailure($this->lng->txt("exc_members_already_assigned"));
523 return false;
524 } else {
525 /* #16921
526 // #9946 - create team for new user(s) for each team upload assignment
527 foreach(ilExAssignment::getInstancesByExercise($this->exercise->getId()) as $ass)
528 {
529 if($ass->hasTeam())
530 {
531 include_once "Modules/Exercise/classes/class.ilExAssignmentTeam.php";
532 foreach($a_user_ids as $user_id)
533 {
534 // #15915
535 ilExAssignmentTeam::getTeamId($ass->getId(), $user_id, true);
536 }
537 }
538 }
539 */
540
541 ilUtil::sendSuccess($this->lng->txt("exc_members_assigned"), true);
542 }
543
544 $this->ctrl->redirect($this, "members");
545 return true;
546 }
547
548
552 public function selectAssignmentObject()
553 {
554 $_GET["ass_id"] = ilUtil::stripSlashes($_POST["ass_id"]);
555 $this->membersObject();
556 }
557
561 public function showParticipantObject()
562 {
564 $ilToolbar = $this->toolbar;
567
568 $this->addSubTabs("participant");
569 $this->ctrl->setParameter($this, "ass_id", "");
570
571 // participant selection
572 include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
573 $ass = ilExAssignment::getAssignmentDataOfExercise($this->exercise->getId());
574 $members = $this->exercise->members_obj->getMembers();
575
576 $members = $GLOBALS['DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
577 'edit_submissions_grades',
578 'edit_submissions_grades',
579 $this->exercise->getRefId(),
580 $members
581 );
582
583
584 if (count($members) == 0) {
585 ilUtil::sendInfo($lng->txt("exc_no_participants"));
586 return;
587 }
588
589 $mems = array();
590 foreach ($members as $mem_id) {
591 if (ilObject::_lookupType($mem_id) == "usr") {
592 include_once("./Services/User/classes/class.ilObjUser.php");
593 $name = ilObjUser::_lookupName($mem_id);
594 if (trim($name["login"]) != "") { // #20073
595 $mems[$mem_id] = $name;
596 }
597 }
598 }
599
600 $mems = ilUtil::sortArray($mems, "lastname", "asc", false, true);
601
602 if ($_GET["part_id"] == "" && count($mems) > 0) {
603 $_GET["part_id"] = key($mems);
604 }
605
606 $current_participant = $_GET["part_id"];
607
608 reset($mems);
609 if (count($mems) > 1) {
610 $options = array();
611 foreach ($mems as $k => $m) {
612 $options[$k] =
613 $m["lastname"] . ", " . $m["firstname"] . " [" . $m["login"] . "]";
614 }
615 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
616 $si = new ilSelectInputGUI($this->lng->txt(""), "part_id");
617 $si->setOptions($options);
618 $si->setValue($current_participant);
619 $ilToolbar->addStickyItem($si);
620
621 include_once("./Services/UIComponent/Button/classes/class.ilSubmitButton.php");
622 $button = ilSubmitButton::getInstance();
623 $button->setCaption("exc_select_part");
624 $button->setCommand("selectParticipant");
625 $ilToolbar->addStickyItem($button);
626
627 $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
628 }
629
630 if (count($mems) > 0) {
631 $this->ctrl->setParameter($this, "vw", self::VIEW_PARTICIPANT);
632 $this->ctrl->setParameter($this, "part_id", $current_participant);
633
634 include_once("./Modules/Exercise/classes/class.ilExParticipantTableGUI.php");
635 $part_tab = new ilExParticipantTableGUI(
636 $this,
637 "showParticipant",
638 $this->exercise,
639 $current_participant
640 );
641 $tpl->setContent($part_tab->getHTML() .
642 $this->initIndividualDeadlineModal());
643 } else {
644 ilUtil::sendInfo($this->lng->txt("exc_no_assignments_available"));
645 }
646 }
647
649 {
650 include_once("./Modules/Exercise/classes/class.ilExParticipantTableGUI.php");
651 $exc_tab = new ilExParticipantTableGUI($this, "showParticipant", $this->exercise, $_GET["part_id"]);
652 $exc_tab->resetOffset();
653 $exc_tab->writeFilterToSession();
654
655 $this->showParticipantObject();
656 }
657
659 {
660 include_once("./Modules/Exercise/classes/class.ilExParticipantTableGUI.php");
661 $exc_tab = new ilExParticipantTableGUI($this, "showParticipant", $this->exercise, $_GET["part_id"]);
662 $exc_tab->resetOffset();
663 $exc_tab->resetFilter();
664
665 $this->showParticipantObject();
666 }
667
671 public function selectParticipantObject()
672 {
673 $_GET["part_id"] = ilUtil::stripSlashes($_POST["part_id"]);
674 $this->showParticipantObject();
675 }
676
680 public function showGradesOverviewObject()
681 {
683 $ilToolbar = $this->toolbar;
686
687 $this->addSubTabs("grades");
688
689 include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
690 $mem_obj = new ilExerciseMembers($this->exercise);
691 $mems = $mem_obj->getMembers();
692
693 $mems = $GLOBALS['DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
694 'edit_submissions_grades',
695 'edit_submissions_grades',
696 $this->exercise->getRefId(),
697 $mems
698 );
699 if (count($mems) > 0) {
700 $ilToolbar->addButton(
701 $lng->txt("exc_export_excel"),
702 $ilCtrl->getLinkTarget($this, "exportExcel")
703 );
704 }
705
706 $this->ctrl->setParameter($this, "vw", self::VIEW_GRADES);
707
708 include_once("./Modules/Exercise/classes/class.ilExGradesTableGUI.php");
709 $grades_tab = new ilExGradesTableGUI(
710 $this,
711 "showGradesOverview",
712 $this->exercise,
713 $mem_obj
714 );
715 $tpl->setContent($grades_tab->getHTML());
716 }
717
722 {
723 $members = array();
724
725 if ($_GET["member_id"] != "") {
726 $submission = new ilExSubmission($this->assignment, $_GET["member_id"]);
727 $members = $submission->getUserIds();
728 } elseif ($members = $this->getMultiActionUserIds()) {
729 $members = array_keys($members);
730 }
731
732 if ($members) {
733 $logins = array();
734 foreach ($members as $user_id) {
735 $member_status = $this->assignment->getMemberStatus($user_id);
736 $member_status->setFeedback(true);
737 $member_status->update();
738
739 $logins[] = ilObjUser::_lookupLogin($user_id);
740 }
741 $logins = implode($logins, ",");
742
743 // #16530 - see ilObjCourseGUI::createMailSignature
744 $sig = chr(13) . chr(10) . chr(13) . chr(10);
745 $sig .= $this->lng->txt('exc_mail_permanent_link');
746 $sig .= chr(13) . chr(10) . chr(13) . chr(10);
747 include_once './Services/Link/classes/class.ilLink.php';
748 $sig .= ilLink::_getLink($this->exercise->getRefId());
749 $sig = rawurlencode(base64_encode($sig));
750
751 require_once 'Services/Mail/classes/class.ilMailFormCall.php';
753 $this,
754 $this->getViewBack(),
755 array(),
756 array(
757 'type' => 'new',
758 'rcp_to' => $logins,
760 )
761 ));
762 }
763 }
764
768 public function downloadAllObject()
769 {
770 $members = array();
771
772 foreach ($this->exercise->members_obj->getMembers() as $member_id) {
773 $submission = new ilExSubmission($this->assignment, $member_id);
774 $submission->updateTutorDownloadTime();
775
776 // get member object (ilObjUser)
777 if (ilObject::_exists($member_id)) {
778 // adding file metadata
779 foreach ($submission->getFiles() as $file) {
780 $members[$file["user_id"]]["files"][$file["returned_id"]] = $file;
781 }
782
783 $tmp_obj =&ilObjectFactory::getInstanceByObjId($member_id);
784 $members[$member_id]["name"] = $tmp_obj->getFirstname() . " " . $tmp_obj->getLastname();
785 unset($tmp_obj);
786 }
787 }
788
789 ilExSubmission::downloadAllAssignmentFiles($this->assignment, $members);
790 }
791
792 protected function getMultiActionUserIds($a_keep_teams = false)
793 {
794 // multi-user
795 if ($this->assignment) {
796 if (!$_POST["member"]) {
797 ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
798 $this->ctrl->redirect($this, "members");
799 }
800
801 foreach (array_keys($_POST["member"]) as $user_id) {
802 $submission = new ilExSubmission($this->assignment, $user_id);
803 $tmembers = $submission->getUserIds();
804 if (!(bool) $a_keep_teams) {
805 foreach ($tmembers as $tuser_id) {
806 $members[$tuser_id] = 1;
807 }
808 } else {
809 if ($tmembers) {
810 $members[] = $tmembers;
811 } else {
812 // no team yet
813 $members[] = $user_id;
814 }
815 }
816 }
817 }
818 // multi-ass
819 else {
820 if (!$_POST["ass"]) {
821 ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
822 $this->ctrl->redirect($this, "showParticipant");
823 }
824
825 $user_id = $_GET["part_id"];
826
827 include_once "Modules/Exercise/classes/class.ilExAssignment.php";
828 foreach (array_keys($_POST["ass"]) as $ass_id) {
829 $submission = new ilExSubmission(new ilExAssignment($ass_id), $user_id);
830 $tmembers = $submission->getUserIds();
831 if (!(bool) $a_keep_teams) {
832 foreach ($tmembers as $tuser_id) {
833 $members[$ass_id][] = $tuser_id;
834 }
835 } else {
836 if ($tmembers) {
837 $members[$ass_id][] = $tmembers;
838 } else {
839 // no team yet
840 $members[$ass_id][] = $user_id;
841 }
842 }
843 }
844 }
845
846 return $members;
847 }
848
852 public function sendMembersObject()
853 {
854 $members = $this->getMultiActionUserIds();
855
856 ilUtil::sendSuccess($this->lng->txt("exc_sent"), true);
857 if ($this->assignment) {
858 $this->exercise->sendAssignment($this->assignment, array_keys($members));
859 $this->ctrl->redirect($this, "members");
860 } else {
861 foreach ($members as $ass_id => $users) {
862 $this->exercise->sendAssignment(new ilExAssignment($ass_id), $users);
863 }
864 $this->ctrl->setParameter($this, "part_id", $_GET["part_id"]); // #17629
865 $this->ctrl->redirect($this, "showParticipant");
866 }
867 }
868
873 {
877
878 $members = $this->getMultiActionUserIds();
879
880 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
881 $cgui = new ilConfirmationGUI();
882 $cgui->setFormAction($ilCtrl->getFormAction($this));
883 $cgui->setHeaderText($lng->txt("exc_msg_sure_to_deassign_participant"));
884 $cgui->setCancel($lng->txt("cancel"), "members");
885 $cgui->setConfirm($lng->txt("remove"), "deassignMembers");
886
887 include_once("./Services/User/classes/class.ilUserUtil.php");
888 foreach ($members as $k => $m) {
889 $cgui->addItem(
890 "member[$k]",
891 $m,
892 ilUserUtil::getNamePresentation((int) $k, false, false, "", true)
893 );
894 }
895
896 $tpl->setContent($cgui->getHTML());
897 }
898
902 public function deassignMembersObject()
903 {
906
907 $members = $this->getMultiActionUserIds();
908
909 foreach (array_keys($members) as $usr_id) {
910 $this->exercise->members_obj->deassignMember((int) $usr_id);
911 }
912 ilUtil::sendSuccess($lng->txt("exc_msg_participants_removed"), true);
913 $ilCtrl->redirect($this, "members");
914 }
915
916 public function saveCommentsObject()
917 {
918 if (!isset($_POST['comments_value'])) {
919 return;
920 }
921
922 $this->exercise->members_obj->setNoticeForMember(
923 $_GET["member_id"],
924 ilUtil::stripSlashes($_POST["comments_value"])
925 );
926 ilUtil::sendSuccess($this->lng->txt("exc_members_comments_saved"));
927 $this->membersObject();
928 }
929
933 public function saveStatusParticipantObject(array $a_selected = null)
934 {
936
937 $member_id = (int) $_GET["part_id"];
938 $data = array();
939 foreach (array_keys($_POST["id"]) as $ass_id) {
940 if (is_array($a_selected) &&
941 !in_array($ass_id, $a_selected)) {
942 continue;
943 }
944
945 $data[$ass_id][$member_id] = array(
946 "status" => ilUtil::stripSlashes($_POST["status"][$ass_id])
947 );
948
949 if (array_key_exists("mark", $_POST)) {
950 $data[$ass_id][$member_id]["mark"] = ilUtil::stripSlashes($_POST["mark"][$ass_id]);
951 }
952 if (array_key_exists("notice", $_POST)) {
953 $data[$ass_id][$member_id]["notice"] = ilUtil::stripSlashes($_POST["notice"][$ass_id]);
954 }
955 }
956
957 $ilCtrl->setParameter($this, "part_id", $member_id); // #17629
958 $this->saveStatus($data);
959 }
960
961
962 public function saveStatusAllObject(array $a_selected = null, $a_redirect = true)
963 {
964 $user_ids = (array) array_keys((array) $_POST['id']);
965 $filtered_user_ids = $GLOBALS['DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
966 'edit_submissions_grades',
967 'edit_submissions_grades',
968 $this->exercise->getRefId(),
969 $user_ids
970 );
971
972 $data = array();
973 foreach ($filtered_user_ids as $user_id) {
974 if (is_array($a_selected) &&
975 !in_array($user_id, $a_selected)) {
976 continue;
977 }
978
979 $data[-1][$user_id] = array(
980 "status" => ilUtil::stripSlashes($_POST["status"][$user_id])
981 );
982
983 if (array_key_exists("mark", $_POST)) {
984 $data[-1][$user_id]["mark"] = ilUtil::stripSlashes($_POST["mark"][$user_id]);
985 }
986 if (array_key_exists("notice", $_POST)) {
987 $data[-1][$user_id]["notice"] = ilUtil::stripSlashes($_POST["notice"][$user_id]);
988 }
989 }
990 $this->saveStatus($data, $a_redirect);
991 }
992
993 public function saveStatusSelectedObject()
994 {
995 $members = $this->getMultiActionUserIds();
996
997 if ($this->assignment) {
998 $this->saveStatusAllObject(array_keys($members));
999 } else {
1000 $this->saveStatusParticipantObject(array_keys($members));
1001 }
1002 }
1003
1007 protected function saveStatus(array $a_data, $a_redirect = true)
1008 {
1010
1011 include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
1012
1013 $saved_for = array();
1014 foreach ($a_data as $ass_id => $users) {
1015 $ass = ($ass_id < 0)
1016 ? $this->assignment
1017 : new ilExAssignment($ass_id);
1018 foreach ($users as $user_id => $values) {
1019 // this will add team members if available
1020 $submission = new ilExSubmission($ass, $user_id);
1021 foreach ($submission->getUserIds() as $sub_user_id) {
1022 $uname = ilObjUser::_lookupName($sub_user_id);
1023 $saved_for[$sub_user_id] = $uname["lastname"] . ", " . $uname["firstname"];
1024
1025 $member_status = $ass->getMemberStatus($sub_user_id);
1026
1027 // see bug #22566
1028 $status = $values["status"];
1029 if ($status == "") {
1030 $status = "notgraded";
1031 }
1032 $member_status->setStatus($status);
1033 if (array_key_exists("mark", $values)) {
1034 $member_status->setMark($values["mark"]);
1035 }
1036 if (array_key_exists("notice", $values)) {
1037 $member_status->setNotice($values["notice"]);
1038 }
1039 $member_status->update();
1040 }
1041 }
1042 }
1043
1044 if (count($saved_for) > 0) {
1045 $save_for_str = "(" . implode($saved_for, " - ") . ")";
1046 }
1047
1048 if ($a_redirect) {
1049 ilUtil::sendSuccess($this->lng->txt("exc_status_saved") . " " . $save_for_str, true);
1050 $ilCtrl->redirect($this, $this->getViewBack());
1051 }
1052 }
1053
1058 {
1059 $res = array("result"=>false);
1060
1061 if ($this->ctrl->isAsynch()) {
1062 $ass_id = (int) $_POST["ass_id"];
1063 $user_id = (int) $_POST["mem_id"];
1064 $comment = trim($_POST["comm"]);
1065
1066 if ($ass_id && $user_id) {
1067 $submission = new ilExSubmission($this->assignment, $user_id);
1068 $user_ids = $submission->getUserIds();
1069
1070 $all_members = new ilExerciseMembers($this->exercise);
1071 $all_members = $all_members->getMembers();
1072
1073 $reci_ids = array();
1074 foreach ($user_ids as $user_id) {
1075 if (in_array($user_id, $all_members)) {
1076 $member_status = $this->assignment->getMemberStatus($user_id);
1077 $member_status->setComment(ilUtil::stripSlashes($comment));
1078 $member_status->setFeedback(true);
1079 $member_status->update();
1080
1081 if (trim($comment)) {
1082 $reci_ids[] = $user_id;
1083 }
1084 }
1085 }
1086
1087 if (sizeof($reci_ids)) {
1088 // send notification
1089 $this->exercise->sendFeedbackFileNotification(
1090 null,
1091 $reci_ids,
1092 $ass_id,
1093 true
1094 );
1095 }
1096
1097 $res = array("result"=>true, "snippet"=>nl2br($comment));
1098 }
1099 }
1100
1101 echo(json_encode($res));
1102 exit();
1103 }
1104
1108 public function exportExcelObject()
1109 {
1110 $this->exercise->exportGradesExcel();
1111 exit;
1112 }
1113
1114
1115 //
1116 // TEAM
1117 //
1118
1119 public function createTeamsObject()
1120 {
1122
1123 $members = $this->getMultiActionUserIds(true);
1124
1125 $new_members = array();
1126
1127 include_once "Modules/Exercise/classes/class.ilExAssignmentTeam.php";
1128 foreach ($members as $group) {
1129 if (is_array($group)) {
1130 $new_members = array_merge($new_members, $group);
1131
1132 $first_user = $group;
1133 $first_user = array_shift($first_user);
1134 $team = ilExAssignmentTeam::getInstanceByUserId($this->assignment->getId(), $first_user);
1135 foreach ($group as $user_id) {
1136 $team->removeTeamMember($user_id);
1137 }
1138 } else {
1139 $new_members[] = $group;
1140 }
1141 }
1142
1143 if (sizeof($new_members)) {
1144 // see ilExSubmissionTeamGUI::addTeamMemberActionObject()
1145
1146 $first_user = array_shift($new_members);
1147 $team = ilExAssignmentTeam::getInstanceByUserId($this->assignment->getId(), $first_user, true);
1148 if (sizeof($new_members)) {
1149 foreach ($new_members as $user_id) {
1150 $team->addTeamMember($user_id);
1151 }
1152 }
1153
1154 // re-evaluate complete team, as some members might have had submitted
1155 $submission = new ilExSubmission($this->assignment, $first_user);
1156 $this->exercise->processExerciseStatus(
1157 $this->assignment,
1158 $team->getMembers(),
1159 $submission->hasSubmitted(),
1160 $submission->validatePeerReviews()
1161 );
1162 }
1163
1164 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1165 $ilCtrl->redirect($this, "members");
1166 }
1167
1168 public function dissolveTeamsObject()
1169 {
1171
1172 $members = $this->getMultiActionUserIds(true);
1173
1174 include_once "Modules/Exercise/classes/class.ilExAssignmentTeam.php";
1175 foreach ($members as $group) {
1176 // if single member - nothing to do
1177 if (is_array($group)) {
1178 // see ilExSubmissionTeamGUI::removeTeamMemberObject()
1179
1180 $first_user = $group;
1181 $first_user = array_shift($first_user);
1182 $team = ilExAssignmentTeam::getInstanceByUserId($this->assignment->getId(), $first_user);
1183 foreach ($group as $user_id) {
1184 $team->removeTeamMember($user_id);
1185 }
1186
1187 // reset ex team members, as any submission is not valid without team
1188 $this->exercise->processExerciseStatus(
1189 $this->assignment,
1190 $group,
1191 false
1192 );
1193 }
1194 }
1195
1196 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1197 $ilCtrl->redirect($this, "members");
1198 }
1199
1200 public function adoptTeamsFromGroupObject(ilPropertyFormGUI $a_form = null)
1201 {
1203 $ilTabs = $this->tabs_gui;
1204 $lng = $this->lng;
1205 $tpl = $this->tpl;
1206
1207 $ilTabs->clearTargets();
1208 $ilTabs->setBackTarget(
1209 $lng->txt("back"),
1210 $ilCtrl->getLinkTarget($this, $this->getViewBack())
1211 );
1212
1213 if (!$a_form) {
1214 $a_form = $this->initGroupForm();
1215 }
1216 $tpl->setContent($a_form->getHTML());
1217 }
1218
1219 protected function initGroupForm()
1220 {
1221 $lng = $this->lng;
1222
1223 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1224 $form = new ilPropertyFormGUI();
1225 $form->setTitle($lng->txt("exc_adopt_group_teams") . " - " . $this->assignment->getTitle());
1226 $form->setFormAction($this->ctrl->getFormAction($this, "createTeamsFromGroups"));
1227
1228 include_once "Modules/Exercise/classes/class.ilExAssignmentTeam.php";
1229 include_once "Services/User/classes/class.ilUserUtil.php";
1230 $all_members = array();
1231 foreach (ilExAssignmentTeam::getGroupMembersMap($this->exercise->getRefId()) as $grp_id => $group) {
1232 if (sizeof($group["members"])) {
1233 $grp_team = new ilCheckboxGroupInputGUI($lng->txt("obj_grp") . " \"" . $group["title"] . "\"", "grpt_" . $grp_id);
1234 $grp_value = $options = array();
1235 foreach ($group["members"] as $user_id) {
1236 $user_name = ilUserUtil::getNamePresentation($user_id, false, false, "", true);
1237 $options[$user_id] = $user_name;
1238 if (!in_array($user_id, $all_members)) {
1239 $grp_value[] = $user_id;
1240 $all_members[] = $user_id;
1241 }
1242 }
1243 asort($options);
1244 foreach ($options as $user_id => $user_name) {
1245 $grp_team->addOption(new ilCheckboxOption($user_name, $user_id));
1246 }
1247 $grp_team->setValue($grp_value);
1248 $form->addItem($grp_team);
1249 } else {
1250 $grp_team = new ilNonEditableValueGUI($group["title"]);
1251 $grp_team->setValue($lng->txt("exc_adopt_group_teams_no_members"));
1252 $form->addItem($grp_team);
1253 }
1254 }
1255
1256 if (sizeof($all_members)) {
1257 $form->addCommandButton("createTeamsFromGroups", $lng->txt("save"));
1258 }
1259 $form->addCommandButton("members", $lng->txt("cancel"));
1260
1261 return $form;
1262 }
1263
1265 {
1266 $lng = $this->lng;
1267
1268 $form = $this->initGroupForm();
1269 if ($form->checkInput()) {
1270 include_once "Services/User/classes/class.ilUserUtil.php";
1271 $map = ilExAssignmentTeam::getGroupMembersMap($this->exercise->getRefId());
1272 $all_members = $teams = array();
1273 $valid = true;
1274 foreach (array_keys($map) as $grp_id) {
1275 $postvar = "grpt_" . $grp_id;
1276 $members = $_POST[$postvar];
1277 if (is_array($members)) {
1278 $teams[] = $members;
1279 $invalid_team_members = array();
1280
1281 foreach ($members as $user_id) {
1282 if (!array_key_exists($user_id, $all_members)) {
1283 $all_members[$user_id] = $grp_id;
1284 } else {
1285 // user is selected in multiple groups
1286 $invalid_team_members[] = $user_id;
1287 }
1288 }
1289
1290 if (sizeof($invalid_team_members)) {
1291 $valid = false;
1292
1293 $alert = array();
1294 foreach ($invalid_team_members as $user_id) {
1295 $user_name = ilUserUtil::getNamePresentation($user_id, false, false, "", true);
1296 $grp_title = $map[$all_members[$user_id]]["title"];
1297 $alert[] = sprintf($lng->txt("exc_adopt_group_teams_conflict"), $user_name, $grp_title);
1298 }
1299 $input = $form->getItemByPostVar($postvar);
1300 $input->setAlert(implode("<br/>", $alert));
1301 }
1302 }
1303 }
1304 if ($valid) {
1305 if (sizeof($teams)) {
1306 $existing_users = array_keys(ilExAssignmentTeam::getAssignmentTeamMap($this->assignment->getId()));
1307
1308 // create teams from group selections
1309 $sum = array("added"=>0, "blocked"=>0);
1310 foreach ($teams as $members) {
1311 foreach ($members as $user_id) {
1312 if (!$this->exercise->members_obj->isAssigned($user_id)) {
1313 $this->exercise->members_obj->assignMember($user_id);
1314 }
1315
1316 if (!in_array($user_id, $existing_users)) {
1317 $sum["added"]++;
1318 } else {
1319 $sum["blocked"]++;
1320 }
1321 }
1322
1323 $first = array_shift($members);
1324 $team = ilExAssignmentTeam::getInstanceByUserId($this->assignment->getId(), $first, true);
1325
1326 // getTeamId() does NOT send notification
1327 // $team->sendNotification($this->exercise->getRefId(), $first, "add");
1328
1329 if (sizeof($members)) {
1330 foreach ($members as $user_id) {
1331 $team->addTeamMember($user_id);
1332 }
1333 }
1334 }
1335
1336 $mess = array();
1337 if ($sum["added"]) {
1338 $mess[] = sprintf($lng->txt("exc_adopt_group_teams_added"), $sum["added"]);
1339 }
1340 if ($sum["blocked"]) {
1341 $mess[] = sprintf($lng->txt("exc_adopt_group_teams_blocked"), $sum["blocked"]);
1342 }
1343 if ($sum["added"]) {
1344 ilUtil::sendSuccess(implode(" ", $mess), true);
1345 } else {
1346 ilUtil::sendFailure(implode(" ", $mess), true);
1347 }
1348 }
1349 $this->ctrl->redirect($this, "members");
1350 } else {
1351 ilUtil::sendFailure($lng->txt("form_input_not_valid"));
1352 }
1353 }
1354
1355 $form->setValuesByPost();
1357 }
1358
1359
1363
1364 public function initMultiFeedbackForm($a_ass_id)
1365 {
1366 $lng = $this->lng;
1367
1368 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1369 $form = new ilPropertyFormGUI();
1370 $form->addCommandButton("uploadMultiFeedback", $lng->txt("upload"));
1371 $form->addCommandButton("members", $lng->txt("cancel"));
1372
1373 // multi feedback file
1374 $fi = new ilFileInputGUI($lng->txt("exc_multi_feedback_file"), "mfzip");
1375 $fi->setSuffixes(array("zip"));
1376 $fi->setRequired(true);
1377 $form->addItem($fi);
1378
1379 $form->setTitle(ilExAssignment::lookupTitle($a_ass_id));
1380 $form->setFormAction($this->ctrl->getFormAction($this, "uploadMultiFeedback"));
1381
1382 return $form;
1383 }
1384
1391 public function showMultiFeedbackObject(ilPropertyFormGUI $a_form = null)
1392 {
1393 $ilToolbar = $this->toolbar;
1394 $lng = $this->lng;
1395 $tpl = $this->tpl;
1396
1397 ilUtil::sendInfo($lng->txt("exc_multi_feedb_info"));
1398
1399 $this->addSubTabs("assignment");
1400
1401 // #13719
1402 include_once("./Services/UIComponent/Button/classes/class.ilLinkButton.php");
1403 $button = ilLinkButton::getInstance();
1404 $button->setCaption("exc_download_zip_structure");
1405 $button->setUrl($this->ctrl->getLinkTarget($this, "downloadMultiFeedbackZip"));
1406 $button->setOmitPreventDoubleSubmission(true);
1407 $ilToolbar->addButtonInstance($button);
1408
1409 if (!$a_form) {
1410 $a_form = $this->initMultiFeedbackForm($this->assignment->getId());
1411 }
1412
1413 $tpl->setContent($a_form->getHTML());
1414 }
1415
1420 {
1421 $this->assignment->sendMultiFeedbackStructureFile($this->exercise);
1422 }
1423
1428 {
1429 // #11983
1430 $form = $this->initMultiFeedbackForm($this->assignment->getId());
1431 if ($form->checkInput()) {
1432 try {
1433 $this->assignment->uploadMultiFeedbackFile(ilUtil::stripSlashesArray($_FILES["mfzip"]));
1434 $this->ctrl->redirect($this, "showMultiFeedbackConfirmationTable");
1435 } catch (ilExerciseException $e) {
1436 ilUtil::sendFailure($e->getMessage(), true);
1437 $this->ctrl->redirect($this, "showMultiFeedback");
1438 }
1439 }
1440
1441 $form->setValuesByPost();
1443 }
1444
1452 {
1453 $tpl = $this->tpl;
1454
1455 $this->addSubTabs("assignment");
1456
1457 include_once("./Modules/Exercise/classes/class.ilFeedbackConfirmationTable2GUI.php");
1458 $tab = new ilFeedbackConfirmationTable2GUI($this, "showMultiFeedbackConfirmationTable", $this->assignment);
1459 $tpl->setContent($tab->getHTML());
1460 }
1461
1466 {
1467 $this->assignment->clearMultiFeedbackDirectory();
1468 $this->ctrl->redirect($this, "members");
1469 }
1470
1474 public function saveMultiFeedbackObject()
1475 {
1476 $this->assignment->saveMultiFeedbackFiles($_POST["file"], $this->exercise);
1477
1478 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1479 $this->ctrl->redirect($this, "members");
1480 }
1481
1482
1483 //
1484 // individual deadlines
1485 //
1486
1487 protected function initIndividualDeadlineModal()
1488 {
1489 $lng = $this->lng;
1490 $tpl = $this->tpl;
1491
1492 // prepare modal+
1493 include_once "./Services/UIComponent/Modal/classes/class.ilModalGUI.php";
1494 $modal = ilModalGUI::getInstance();
1495 $modal->setHeading($lng->txt("exc_individual_deadline"));
1496 $modal->setId("ilExcIDl");
1497 $modal->setBody('<div id="ilExcIDlBody"></div>');
1498 $modal = $modal->getHTML();
1499
1500 $ajax_url = $this->ctrl->getLinkTarget($this, "handleIndividualDeadlineCalls", "", true, false);
1501
1502 $tpl->addJavaScript("./Modules/Exercise/js/ilExcIDl.js", true, 3);
1503 $tpl->addOnloadCode('il.ExcIDl.init("' . $ajax_url . '");');
1504
1505 include_once "Services/Calendar/classes/class.ilCalendarUtil.php";
1507
1508 return $modal;
1509 }
1510
1511 protected function parseIndividualDeadlineData(array $a_data)
1512 {
1513 if ($a_data) {
1514 $map = array();
1515 $ass_tmp = array();
1516 foreach ($a_data as $item) {
1517 $item = explode("_", $item);
1518 $ass_id = $item[0];
1519 $user_id = $item[1];
1520
1521 if (!array_key_exists($ass_id, $ass_tmp)) {
1522 if ($this->assignment &&
1523 $ass_id == $this->assignment->getId()) {
1524 $ass_tmp[$ass_id] = $this->assignment;
1525 } else {
1526 $ass_tmp[$ass_id] = new ilExAssignment($ass_id);
1527 }
1528 }
1529
1530 $map[$ass_id][] = $user_id;
1531 }
1532
1533 return array($map, $ass_tmp);
1534 }
1535 }
1536
1538 {
1539 $tpl = $this->tpl;
1540
1541 $this->ctrl->saveParameter($this, "part_id");
1542
1543 // we are done
1544 if ((bool) $_GET["dn"]) {
1545 ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
1546 $this->ctrl->redirect($this, $this->assignment
1547 ? "members"
1548 : "showParticipant");
1549 }
1550
1551 include_once "Modules/Exercise/classes/class.ilExAssignment.php";
1552
1553 // initial form call
1554 if ($_GET["idlid"]) {
1555 $tmp = $this->parseIndividualDeadlineData(explode(",", $_GET["idlid"]));
1556 if (is_array($tmp)) {
1557 $form = $this->initIndividualDeadlineForm($tmp[1], $tmp[0]);
1558 echo $form->getHTML() .
1559 $tpl->getOnLoadCodeForAsynch();
1560 }
1561 }
1562 // form "submit"
1563 else {
1564 $tmp = array();
1565 foreach (array_keys($_POST) as $id) {
1566 if (substr($id, 0, 3) == "dl_") {
1567 $tmp[] = substr($id, 3);
1568 }
1569 }
1570 $tmp = $this->parseIndividualDeadlineData($tmp);
1571 $ass_map = $tmp[1];
1572 $users = $tmp[0];
1573 unset($tmp);
1574
1575 $form = $this->initIndividualDeadlineForm($ass_map, $users);
1576 $res = array();
1577 if ($valid = $form->checkInput()) {
1578 foreach ($users as $ass_id => $users) {
1579 $ass = $ass_map[$ass_id];
1580
1581 // :TODO: should individual deadlines BEFORE extended be possible?
1582 $dl = new ilDateTime($ass->getDeadline(), IL_CAL_UNIX);
1583
1584 foreach ($users as $user_id) {
1585 $date_field = $form->getItemByPostVar("dl_" . $ass_id . "_" . $user_id);
1586 if (ilDate::_before($date_field->getDate(), $dl)) {
1587 $date_field->setAlert(sprintf($this->lng->txt("exc_individual_deadline_before_global"), ilDatePresentation::formatDate($dl)));
1588 $valid = false;
1589 } else {
1590 $res[$ass_id][$user_id] = $date_field->getDate();
1591 }
1592 }
1593 }
1594 }
1595
1596 if (!$valid) {
1597 $form->setValuesByPost();
1598 echo $form->getHTML() .
1599 $tpl->getOnLoadCodeForAsynch();
1600 } else {
1601 foreach ($res as $ass_id => $users) {
1602 $ass = $ass_map[$ass_id];
1603
1604 foreach ($users as $id => $date) {
1605 $ass->setIndividualDeadline($id, $date);
1606 }
1607
1608 $ass->recalculateLateSubmissions();
1609 }
1610
1611 echo "ok";
1612 }
1613 }
1614
1615 exit();
1616 }
1617
1618 protected function initIndividualDeadlineForm(array $a_ass_map, array $ids)
1619 {
1620 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
1621 $form = new ilPropertyFormGUI();
1622 $form->setFormAction($this->ctrl->getFormAction($this));
1623 $form->setName("ilExcIDlForm");
1624
1625 include_once "Services/User/classes/class.ilUserUtil.php";
1626 foreach ($ids as $ass_id => $users) {
1627 $ass = $a_ass_map[$ass_id];
1628
1630 $section->setTitle($ass->getTitle());
1631 $form->addItem($section);
1632
1633 include_once("./Modules/Exercise/classes/class.ilExAssignmentTeam.php");
1634 $teams = ilExAssignmentTeam::getInstancesFromMap($ass->getId());
1635
1636 $values = $ass->getIndividualDeadlines();
1637
1638 foreach ($users as $id) {
1639 // single user
1640 if (is_numeric($id)) {
1642 $name = $name["lastname"] . ", " . $name["firstname"];
1643 }
1644 // team
1645 else {
1646 $name = "";
1647 $team_id = (int) substr($id, 1);
1648 if (array_key_exists($team_id, $teams)) {
1649 $name = array();
1650 foreach ($teams[$team_id]->getMembers() as $member_id) {
1651 $uname = ilObjUser::_lookupName($member_id);
1652 $name[] = $uname["lastname"] . ", " . $uname["firstname"];
1653 }
1654 asort($name);
1655 $name = implode("<br />", $name);
1656 }
1657 }
1658
1659 $dl = new ilDateTimeInputGUI($name, "dl_" . $ass_id . "_" . $id);
1660 $dl->setShowTime(true);
1661 $dl->setRequired(true);
1662 $form->addItem($dl);
1663
1664 if (array_key_exists($id, $values)) {
1665 $dl->setDate(new ilDateTime($values[$id], IL_CAL_UNIX));
1666 }
1667 }
1668 }
1669
1670 $form->addCommandButton("", $this->lng->txt("save"));
1671
1672 return $form;
1673 }
1674
1675 protected function setIndividualDeadlineObject()
1676 {
1677 // this will only get called if no selection
1678 ilUtil::sendFailure($this->lng->txt("select_one"));
1679
1680 if ($this->assignment) {
1681 $this->membersObject();
1682 } else {
1683 $this->showParticipantObject();
1684 }
1685 }
1686}
sprintf('%.4f', $callTime)
$section
Definition: Utf8Test.php:83
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
$users
Definition: authpage.php:44
$comment
Definition: buildRTE.php:83
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
This class represents a property in a property form.
This class represents an option in a checkbox group.
Confirmation screen class.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date @access public.
This class represents a date/time property in a property form.
@classDescription Date and time handling
static _before(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
compare two dates and check start is before end This method does not consider tz offsets.
static getAdoptableGroups($a_exc_ref_id)
static getGroupMembersMap($a_exc_ref_id)
static getAssignmentTeamMap($a_ass_id)
Get team structure for assignment.
static getInstanceByUserId($a_assignment_id, $a_user_id, $a_create_on_demand=false)
static getInstancesFromMap($a_assignment_id)
Exercise assignment.
static getInstancesByExercise($a_exc_id)
static getAssignmentDataOfExercise($a_exc_id)
Get assignments data of an exercise in an array.
static lookupTitle($a_id)
Lookup title.
Exercise participant table.
Class ilExPeerReviewGUI.
Object-based submissions (ends up as static file)
Exercise submission.
static hasAnySubmissions($a_ass_id)
static downloadAllAssignmentFiles(ilExAssignment $a_ass, array $members)
Download all submitted files of an assignment (all user)
Exercise exceptions class.
Class ilExerciseManagementGUI.
initIndividualDeadlineForm(array $a_ass_map, array $ids)
listTextAssignmentObject($a_show_peer_review=false)
redirectFeedbackMailObject()
set feedback status for member and redirect to mail screen
confirmDeassignMembersObject()
Confirm deassigning members.
addSubTabs($a_activate)
adds tabs to tab gui object
uploadMultiFeedbackObject()
Upload multi feedback file.
sendMembersObject()
Send assignment per mail to participants.
saveStatusAllObject(array $a_selected=null, $a_redirect=true)
showMultiFeedbackObject(ilPropertyFormGUI $a_form=null)
Show multi-feedback screen.
saveStatusParticipantObject(array $a_selected=null)
Save assignment status (participant view)
adoptTeamsFromGroupObject(ilPropertyFormGUI $a_form=null)
deassignMembersObject()
Deassign members from exercise.
showMultiFeedbackConfirmationTableObject()
Show multi feedback confirmation table.
saveMultiFeedbackObject()
Save multi feedback.
cancelMultiFeedbackObject()
Cancel Multi Feedback.
membersObject()
All participants and submission of one assignment.
showGradesOverviewObject()
Show grades overview.
addUserFromAutoCompleteObject()
Add user as member.
selectParticipantObject()
Select participant.
downloadAllObject()
Download all submitted files (of all members).
downloadMultiFeedbackZipObject()
Download multi-feedback structrue file.
addMembersObject($a_user_ids=array())
Add new partipant.
saveStatus(array $a_data, $a_redirect=true)
Save status of selecte members.
__construct(ilObjExercise $a_exercise, ilExAssignment $a_ass=null)
Constructor.
saveCommentForLearnersObject()
Save comment for learner (asynch)
Class ilExerciseMembers.
This class represents a file property in a property form.
File System Explorer GUI class.
This class represents a section header in a property form.
static getInstance()
Factory.
static getRedirectTarget($gui, $cmd, array $gui_params=array(), array $mail_params=array(), array $context_params=array())
const SIGNATURE_KEY
Session parameter for the hash.
static getInstance()
Get instance.
This class represents a non editable value in a property form.
Class ilObjExercise.
static _lookupLogin($a_user_id)
lookup login
static _lookupId($a_user_str)
Lookup id by login.
static _lookupName($a_user_id)
lookup user name
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data@access public
static _lookupType($a_id, $a_reference=false)
lookup object type
This class represents a property form user interface.
static fillAutoCompleteToolbar($parent_object, ilToolbarGUI $toolbar=null, $a_options=array(), $a_sticky=false)
fill toolbar with
This class represents a selection list property in a property form.
static getInstance()
Factory.
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 sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static redirect($a_script)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static stripSlashesArray($a_arr, $a_strip_html=true, $a_allow="")
Strip slashes from array.
$valid
$tbl
Definition: example_048.php:81
if(!array_key_exists('StateId', $_REQUEST)) $id
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
global $ilCtrl
Definition: ilias.php:18
if($format !==null) $name
Definition: metadata.php:146
$url
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
foreach($_POST as $key=> $value) $res