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