ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
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  $this->exercise->sendFeedbackFileNotification($pcommand["name"],
92  $noti_rec_ids, $this->assignment->getId());
93  }
94  $this->ctrl->forwardCommand($fs_gui);
95  break;
96 
97  case 'ilrepositorysearchgui':
98  include_once('./Services/Search/classes/class.ilRepositorySearchGUI.php');
99  $rep_search = new ilRepositorySearchGUI();
100  $rep_search->setTitle($this->lng->txt("exc_add_participant"));
101  $rep_search->setCallback($this,'addMembersObject');
102 
103  // Set tabs
104  $this->addSubTabs("assignment");
105  $this->ctrl->setReturn($this,'members');
106 
107  $this->ctrl->forwardCommand($rep_search);
108  break;
109 
110  case "ilexsubmissionteamgui":
111  include_once "Modules/Exercise/classes/class.ilExSubmissionTeamGUI.php";
112  $gui = new ilExSubmissionTeamGUI($this->exercise, $this->initSubmission());
113  $ilCtrl->forwardCommand($gui);
114  break;
115 
116  case "ilexsubmissionfilegui":
117  include_once "Modules/Exercise/classes/class.ilExSubmissionFileGUI.php";
118  $gui = new ilExSubmissionFileGUI($this->exercise, $this->initSubmission());
119  $ilCtrl->forwardCommand($gui);
120  break;
121 
122  case "ilexsubmissiontextgui":
123  $ilCtrl->saveParameter($this, array("part_id"));
124  include_once "Modules/Exercise/classes/class.ilExSubmissionTextGUI.php";
125  $gui = new ilExSubmissionTextGUI($this->exercise, $this->initSubmission());
126  $ilCtrl->forwardCommand($gui);
127  break;
128 
129  case "ilexpeerreviewgui":
130  include_once "Modules/Exercise/classes/class.ilExPeerReviewGUI.php";
131  $gui = new ilExPeerReviewGUI($this->assignment, $this->initSubmission());
132  $ilCtrl->forwardCommand($gui);
133  break;
134 
135  default:
136  $this->{$cmd."Object"}();
137  break;
138  }
139  }
140 
141  protected function getViewBack()
142  {
143  switch($_REQUEST["vw"])
144  {
145  case self::VIEW_PARTICIPANT:
146  $back_cmd = "showParticipant";
147  break;
148 
149  case self::VIEW_GRADES:
150  $back_cmd = "showGradesOverview";
151  break;
152 
153  default:
154  // case self::VIEW_ASSIGNMENT:
155  $back_cmd = "members";
156  break;
157  }
158  return $back_cmd;
159  }
160 
161  protected function initSubmission()
162  {
163  $back_cmd = $this->getViewBack();
164  $this->ctrl->setReturn($this, $back_cmd);
165 
166  $this->tabs_gui->clearTargets();
167  $this->tabs_gui->setBackTarget($this->lng->txt("back"),
168  $this->ctrl->getLinkTarget($this, $back_cmd));
169 
170  include_once "Modules/Exercise/classes/class.ilExSubmission.php";
171  return new ilExSubmission($this->assignment, $_REQUEST["member_id"], null, true);
172  }
173 
179  function addSubTabs($a_activate)
180  {
181  global $ilTabs, $lng, $ilCtrl;
182 
183  $ilCtrl->setParameter($this, "vw", "");
184  $ilCtrl->setParameter($this, "member_id", "");
185  $ilTabs->addSubTab("assignment", $lng->txt("exc_assignment_view"),
186  $ilCtrl->getLinkTarget($this, "members"));
187  $ilTabs->addSubTab("participant", $lng->txt("exc_participant_view"),
188  $ilCtrl->getLinkTarget($this, "showParticipant"));
189  $ilTabs->addSubTab("grades", $lng->txt("exc_grades_overview"),
190  $ilCtrl->getLinkTarget($this, "showGradesOverview"));
191  $ilTabs->activateSubTab($a_activate);
192  }
193 
197  function membersObject()
198  {
199  global $tpl, $ilToolbar, $ilCtrl, $lng;
200 
201  include_once 'Services/Tracking/classes/class.ilLPMarks.php';
202 
203  $this->addSubTabs("assignment");
204 
205  // assignment selection
206  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
207  $ass = ilExAssignment::getInstancesByExercise($this->exercise->getId());
208 
209  if (!$this->assignment)
210  {
211  $this->assignment = current($ass);
212  }
213 
214  reset($ass);
215  if (count($ass) > 1)
216  {
217  $options = array();
218  foreach ($ass as $a)
219  {
220  $options[$a->getId()] = $a->getTitle();
221  }
222  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
223  $si = new ilSelectInputGUI($this->lng->txt(""), "ass_id");
224  $si->setOptions($options);
225  $si->setValue($this->assignment->getId());
226  $ilToolbar->addStickyItem($si);
227 
228  include_once("./Services/UIComponent/Button/classes/class.ilSubmitButton.php");
229  $button = ilSubmitButton::getInstance();
230  $button->setCaption("exc_select_ass");
231  $button->setCommand("selectAssignment");
232  $ilToolbar->addStickyItem($button);
233 
234  $ilToolbar->addSeparator();
235  }
236  // #16165 - if only 1 assignment dropdown is not displayed;
237  else if($this->assignment)
238  {
239  $ilCtrl->setParameter($this, "ass_id", $this->assignment->getId());
240  }
241 
242  // add member
243  include_once './Services/Search/classes/class.ilRepositorySearchGUI.php';
245  $this,
246  $ilToolbar,
247  array(
248  'auto_complete_name' => $lng->txt('user'),
249  'submit_name' => $lng->txt('add'),
250  'add_search' => true,
251  'add_from_container' => $this->exercise->getRefId()
252  )
253  );
254 
255  // #16168 - no assignments
256  if (count($ass) > 0)
257  {
258  $ilToolbar->addSeparator();
259 
260  // we do not want the ilRepositorySearchGUI form action
261  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
262 
263  $ilCtrl->setParameter($this, "ass_id", $this->assignment->getId());
264 
265  if($this->assignment->getType() == ilExAssignment::TYPE_UPLOAD_TEAM)
266  {
267  include_once("./Modules/Exercise/classes/class.ilExAssignmentTeam.php");
268  if(ilExAssignmentTeam::getAdoptableGroups($this->exercise->getRefId()))
269  {
270  // multi-feedback
271  $ilToolbar->addButton($this->lng->txt("exc_adopt_group_teams"),
272  $this->ctrl->getLinkTarget($this, "adoptTeamsFromGroup"));
273  }
274  }
275  else
276  {
277  // multi-feedback
278  $ilToolbar->addButton($this->lng->txt("exc_multi_feedback"),
279  $this->ctrl->getLinkTarget($this, "showMultiFeedback"));
280  }
281 
282  if(ilExSubmission::hasAnySubmissions($this->assignment->getId()))
283  {
284  $ilToolbar->addSeparator();
285  if($this->assignment->getType() == ilExAssignment::TYPE_TEXT)
286  {
287  $ilToolbar->addFormButton($lng->txt("exc_list_text_assignment"), "listTextAssignment");
288  }
289  else
290  {
291  $ilToolbar->addFormButton($lng->txt("download_all_returned_files"), "downloadAll");
292  }
293  }
294  $this->ctrl->setParameter($this, "vw", self::VIEW_ASSIGNMENT);
295 
296  include_once("./Modules/Exercise/classes/class.ilExerciseMemberTableGUI.php");
297  $exc_tab = new ilExerciseMemberTableGUI($this, "members", $this->exercise, $this->assignment);
298  $tpl->setContent($exc_tab->getHTML());
299  }
300  else
301  {
302  ilUtil::sendInfo($lng->txt("exc_no_assignments_available"));
303  }
304 
305  $ilCtrl->setParameter($this, "ass_id", "");
306 
307  return;
308  }
309 
310 
311 
312 
316  function saveGradesObject()
317  {
318  global $ilCtrl, $lng;
319 
320  include_once 'Services/Tracking/classes/class.ilLPMarks.php';
321 
322  if (is_array($_POST["lcomment"]))
323  {
324  foreach ($_POST["lcomment"] as $k => $v)
325  {
326  $marks_obj = new ilLPMarks($this->exercise->getId(), (int) $k);
327  $marks_obj->setComment(ilUtil::stripSlashes($v));
328  $marks_obj->setMark(ilUtil::stripSlashes($_POST["mark"][$k]));
329  $marks_obj->update();
330  }
331  }
332  ilUtil::sendSuccess($lng->txt("exc_msg_saved_grades"), true);
333  $ilCtrl->redirect($this, "showGradesOverview");
334  }
335 
336 
337  // TEXT ASSIGNMENT ?!
338 
340  {
341  $this->listTextAssignmentObject(true);
342  }
343 
344  function listTextAssignmentObject($a_show_peer_review = false)
345  {
346  global $tpl, $ilCtrl, $ilTabs, $lng;
347 
348  if(!$this->assignment || $this->assignment->getType() != ilExAssignment::TYPE_TEXT)
349  {
350  $ilCtrl->redirect($this, "members");
351  }
352 
353  $ilTabs->clearTargets();
354  $ilTabs->setBackTarget($lng->txt("back"),
355  $ilCtrl->getLinkTarget($this, "members"));
356 
357  if($a_show_peer_review)
358  {
359  $cmd = "listTextAssignmentWithPeerReview";
360  }
361  else
362  {
363  $cmd = "listTextAssignment";
364  }
365  include_once "Modules/Exercise/classes/class.ilExAssignmentListTextTableGUI.php";
366  $tbl = new ilExAssignmentListTextTableGUI($this, $cmd, $this->assignment, $a_show_peer_review);
367  $tpl->setContent($tbl->getHTML());
368  }
369 
370 
375  {
376  if(!strlen(trim($_POST['user_login'])))
377  {
378  ilUtil::sendFailure($this->lng->txt('msg_no_search_string'));
379  $this->membersObject();
380  return false;
381  }
382  $users = explode(',', $_POST['user_login']);
383 
384  $user_ids = array();
385  foreach($users as $user)
386  {
387  $user_id = ilObjUser::_lookupId($user);
388 
389  if(!$user_id)
390  {
391  ilUtil::sendFailure($this->lng->txt('user_not_known'));
392  return $this->membersObject();
393  }
394 
395  $user_ids[] = $user_id;
396  }
397 
398  if(!$this->addMembersObject($user_ids));
399  {
400  $this->membersObject();
401  return false;
402  }
403  return true;
404  }
405 
409  function addMembersObject($a_user_ids = array())
410  {
411  global $ilAccess,$ilErr;
412 
413  if(!count($a_user_ids))
414  {
415  ilUtil::sendFailure($this->lng->txt("no_checkbox"));
416  return false;
417  }
418 
419  if(!$this->exercise->members_obj->assignMembers($a_user_ids))
420  {
421  ilUtil::sendFailure($this->lng->txt("exc_members_already_assigned"));
422  return false;
423  }
424  else
425  {
426  /* #16921
427  // #9946 - create team for new user(s) for each team upload assignment
428  foreach(ilExAssignment::getInstancesByExercise($this->exercise->getId()) as $ass)
429  {
430  if($ass->hasTeam())
431  {
432  include_once "Modules/Exercise/classes/class.ilExAssignmentTeam.php";
433  foreach($a_user_ids as $user_id)
434  {
435  // #15915
436  ilExAssignmentTeam::getTeamId($ass->getId(), $user_id, true);
437  }
438  }
439  }
440  */
441 
442  ilUtil::sendSuccess($this->lng->txt("exc_members_assigned"),true);
443  }
444 
445  $this->ctrl->redirect($this, "members");
446  return true;
447  }
448 
449 
454  {
455  global $ilTabs;
456 
457  $_GET["ass_id"] = ilUtil::stripSlashes($_POST["ass_id"]);
458  $this->membersObject();
459  }
460 
465  {
466  global $rbacsystem, $tree, $tpl, $ilToolbar, $ilCtrl, $ilTabs, $lng;
467 
468  $this->addSubTabs("participant");
469 
470  // participant selection
471  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
472  $ass = ilExAssignment::getAssignmentDataOfExercise($this->exercise->getId());
473  $members = $this->exercise->members_obj->getMembers();
474 
475  if (count($members) == 0)
476  {
477  ilUtil::sendInfo($lng->txt("exc_no_participants"));
478  return;
479  }
480 
481  $mems = array();
482  foreach ($members as $mem_id)
483  {
484  if (ilObject::_lookupType($mem_id) == "usr")
485  {
486  include_once("./Services/User/classes/class.ilObjUser.php");
487  $name = ilObjUser::_lookupName($mem_id);
488  if (trim($name["login"]) != "") // #20073
489  {
490  $mems[$mem_id] = $name;
491  }
492  }
493  }
494 
495  $mems = ilUtil::sortArray($mems, "lastname", "asc", false, true);
496 
497  if ($_GET["part_id"] == "" && count($mems) > 0)
498  {
499  $_GET["part_id"] = key($mems);
500  }
501 
502  $current_participant = $_GET["part_id"];
503 
504  reset($mems);
505  if (count($mems) > 1)
506  {
507  $options = array();
508  foreach ($mems as $k => $m)
509  {
510  $options[$k] =
511  $m["lastname"].", ".$m["firstname"]." [".$m["login"]."]";
512  }
513  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
514  $si = new ilSelectInputGUI($this->lng->txt(""), "part_id");
515  $si->setOptions($options);
516  $si->setValue($current_participant);
517  $ilToolbar->addStickyItem($si);
518 
519  include_once("./Services/UIComponent/Button/classes/class.ilSubmitButton.php");
520  $button = ilSubmitButton::getInstance();
521  $button->setCaption("exc_select_part");
522  $button->setCommand("selectParticipant");
523  $ilToolbar->addStickyItem($button);
524 
525  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
526  }
527 
528  if (count($mems) > 0)
529  {
530  $this->ctrl->setParameter($this, "vw", self::VIEW_PARTICIPANT);
531  $this->ctrl->setParameter($this, "part_id", $current_participant);
532 
533  include_once("./Modules/Exercise/classes/class.ilExParticipantTableGUI.php");
534  $part_tab = new ilExParticipantTableGUI($this, "showParticipant",
535  $this->exercise, $current_participant);
536  $tpl->setContent($part_tab->getHTML());
537  }
538  else
539  {
540  ilUtil::sendInfo($this->lng->txt("exc_no_assignments_available"));
541  }
542  }
543 
548  {
549  global $ilTabs;
550 
551  $_GET["part_id"] = ilUtil::stripSlashes($_POST["part_id"]);
552  $this->showParticipantObject();
553  }
554 
559  {
560  global $tpl, $ilToolbar, $ilCtrl, $lng;
561 
562  $this->addSubTabs("grades");
563 
564  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
565  $mem_obj = new ilExerciseMembers($this->exercise);
566  $mems = $mem_obj->getMembers();
567 
568  if (count($mems) > 0)
569  {
570  $ilToolbar->addButton($lng->txt("exc_export_excel"),
571  $ilCtrl->getLinkTarget($this, "exportExcel"));
572  }
573 
574  $this->ctrl->setParameter($this, "vw", self::VIEW_GRADES);
575 
576  include_once("./Modules/Exercise/classes/class.ilExGradesTableGUI.php");
577  $grades_tab = new ilExGradesTableGUI($this, "showGradesOverview",
578  $this->exercise, $mem_obj);
579  $tpl->setContent($grades_tab->getHTML());
580  }
581 
586  {
587  $members = array();
588 
589  if ($_GET["member_id"] != "")
590  {
591  $submission = new ilExSubmission($this->assignment, $_GET["member_id"]);
592  $members = $submission->getUserIds();
593  }
594  else if($members = $this->getMultiActionUserIds())
595  {
596  $members = array_keys($members);
597  }
598 
599  if($members)
600  {
601  $logins = array();
602  foreach($members as $user_id)
603  {
604  $member_status = $this->assignment->getMemberStatus($user_id);
605  $member_status->setFeedback(true);
606  $member_status->update();
607 
608  $logins[] = ilObjUser::_lookupLogin($user_id);
609  }
610  $logins = implode($logins, ",");
611 
612  // #16530 - see ilObjCourseGUI::createMailSignature
613  $sig = chr(13).chr(10).chr(13).chr(10);
614  $sig .= $this->lng->txt('exc_mail_permanent_link');
615  $sig .= chr(13).chr(10).chr(13).chr(10);
616  include_once './Services/Link/classes/class.ilLink.php';
617  $sig .= ilLink::_getLink($this->exercise->getRefId());
618  $sig = rawurlencode(base64_encode($sig));
619 
620  require_once 'Services/Mail/classes/class.ilMailFormCall.php';
622  $this,
623  $this->getViewBack(),
624  array(),
625  array(
626  'type' => 'new',
627  'rcp_to' => $logins,
629  )
630  ));
631  }
632 
633  ilUtil::sendFailure($this->lng->txt("no_checkbox"),true);
634  $this->ctrl->redirect($this, "members");
635  }
636 
640  function downloadAllObject()
641  {
642  $members = array();
643 
644  foreach($this->exercise->members_obj->getMembers() as $member_id)
645  {
646  $submission = new ilExSubmission($this->assignment, $member_id);
647  $submission->updateTutorDownloadTime();
648 
649  // get member object (ilObjUser)
650  if (ilObject::_exists($member_id))
651  {
652  // adding file metadata
653  foreach($submission->getFiles() as $file)
654  {
655  $members[$file["user_id"]]["files"][$file["returned_id"]] = $file;
656  }
657 
658  $tmp_obj =& ilObjectFactory::getInstanceByObjId($member_id);
659  $members[$member_id]["name"] = $tmp_obj->getFirstname() . " " . $tmp_obj->getLastname();
660  unset($tmp_obj);
661  }
662  }
663 
664  ilExSubmission::downloadAllAssignmentFiles($this->assignment, $members);
665  }
666 
667  protected function getMultiActionUserIds($a_keep_teams = false)
668  {
669  if (!is_array($_POST["member"]) ||
670  count($_POST["member"]) == 0)
671  {
672  ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
673  }
674  else
675  {
676  $members = array();
677  foreach(array_keys($_POST["member"]) as $user_id)
678  {
679  $submission = new ilExSubmission($this->assignment, $user_id);
680  $tmembers = $submission->getUserIds();
681  if(!(bool)$a_keep_teams)
682  {
683  foreach($tmembers as $tuser_id)
684  {
685  $members[$tuser_id] = 1;
686  }
687  }
688  else
689  {
690  if($tmembers)
691  {
692  $members[] = $tmembers;
693  }
694  else
695  {
696  // no team yet
697  $members[] = $user_id;
698  }
699  }
700  }
701  return $members;
702  }
703  }
704 
708  function sendMembersObject()
709  {
710  global $ilCtrl;
711 
712  $members = $this->getMultiActionUserIds();
713  if(is_array($members))
714  {
715  $this->exercise->sendAssignment($this->assignment, $members);
716  ilUtil::sendSuccess($this->lng->txt("exc_sent"),true);
717  }
718  $ilCtrl->redirect($this, "members");
719  }
720 
725  {
726  global $ilCtrl, $tpl, $lng;
727 
728  $members = $this->getMultiActionUserIds();
729  if(is_array($members))
730  {
731  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
732  $cgui = new ilConfirmationGUI();
733  $cgui->setFormAction($ilCtrl->getFormAction($this));
734  $cgui->setHeaderText($lng->txt("exc_msg_sure_to_deassign_participant"));
735  $cgui->setCancel($lng->txt("cancel"), "members");
736  $cgui->setConfirm($lng->txt("remove"), "deassignMembers");
737 
738  include_once("./Services/User/classes/class.ilUserUtil.php");
739  foreach ($members as $k => $m)
740  {
741  $cgui->addItem("member[$k]", $m,
742  ilUserUtil::getNamePresentation((int) $k, false, false, "", true));
743  }
744 
745  $tpl->setContent($cgui->getHTML());
746  }
747  }
748 
753  {
754  global $ilCtrl, $lng;
755 
756  $members = $this->getMultiActionUserIds();
757  if($members)
758  {
759  foreach(array_keys($members) as $usr_id)
760  {
761  $this->exercise->members_obj->deassignMember((int) $usr_id);
762  }
763  ilUtil::sendSuccess($lng->txt("exc_msg_participants_removed"), true);
764  }
765  $ilCtrl->redirect($this, "members");
766  }
767 
768  function saveCommentsObject()
769  {
770  if(!isset($_POST['comments_value']))
771  {
772  return;
773  }
774 
775  $this->exercise->members_obj->setNoticeForMember($_GET["member_id"],
776  ilUtil::stripSlashes($_POST["comments_value"]));
777  ilUtil::sendSuccess($this->lng->txt("exc_members_comments_saved"));
778  $this->membersObject();
779  }
780 
781 
786  {
787  global $ilCtrl;
788 
789  $member_id = (int)$_GET["member_id"];
790  $data = array();
791  foreach(array_keys($_POST["id"]) as $ass_id)
792  {
793  $data[$ass_id][$member_id] = array(
794  "status" => ilUtil::stripSlashes($_POST["status"][$ass_id])
795  ,"notice" => ilUtil::stripSlashes($_POST["notice"][$ass_id])
796  ,"mark" => ilUtil::stripSlashes($_POST["mark"][$ass_id])
797  );
798  }
799 
800  $ilCtrl->setParameter($this, "part_id", $member_id); // #17629
801  $this->saveStatus($data);
802  }
803 
805  {
806  $data = array();
807  foreach(array_keys($_POST["id"]) as $user_id)
808  {
809  $data[-1][$user_id] = array(
810  "status" => ilUtil::stripSlashes($_POST["status"][$user_id])
811  ,"notice" => ilUtil::stripSlashes($_POST["notice"][$user_id])
812  ,"mark" => ilUtil::stripSlashes($_POST["mark"][$user_id])
813  );
814  }
815  $this->saveStatus($data);
816  }
817 
819  {
820  $members = $this->getMultiActionUserIds();
821  if(!$members)
822  {
823  $this->ctrl->redirect($this, "members");
824  }
825 
826  // #18408 - saveStatus() will rollout teams, we need raw (form) data here
827  $data = array();
828  foreach(array_keys($_POST["member"]) as $user_id)
829  {
830  $data[-1][$user_id] = array(
831  "status" => ilUtil::stripSlashes($_POST["status"][$user_id])
832  ,"notice" => ilUtil::stripSlashes($_POST["notice"][$user_id])
833  ,"mark" => ilUtil::stripSlashes($_POST["mark"][$user_id])
834  );
835  }
836  $this->saveStatus($data);
837  }
838 
842  protected function saveStatus(array $a_data)
843  {
844  global $ilCtrl;
845 
846  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
847 
848  $saved_for = array();
849  foreach($a_data as $ass_id => $users)
850  {
851  $ass = ($ass_id < 0)
852  ? $this->assignment
853  : new ilExAssignment($ass_id);
854 
855  foreach($users as $user_id => $values)
856  {
857  // this will add team members if available
858  $submission = new ilExSubmission($ass, $user_id);
859  foreach($submission->getUserIds() as $sub_user_id)
860  {
861  $uname = ilObjUser::_lookupName($sub_user_id);
862  $saved_for[$sub_user_id] = $uname["lastname"].", ".$uname["firstname"];
863 
864  $member_status = $ass->getMemberStatus($sub_user_id);
865  $member_status->setStatus($values["status"]);
866  $member_status->setNotice($values["notice"]);
867  $member_status->setMark($values["mark"]);
868  $member_status->update();
869  }
870  }
871  }
872 
873  if (count($saved_for) > 0)
874  {
875  $save_for_str = "(".implode($saved_for, " - ").")";
876  }
877 
878  ilUtil::sendSuccess($this->lng->txt("exc_status_saved")." ".$save_for_str, true);
879  $ilCtrl->redirect($this, $this->getViewBack());
880  }
881 
886  {
887  $res = array("result"=>false);
888 
889  if($this->ctrl->isAsynch())
890  {
891  $ass_id = (int)$_POST["ass_id"];
892  $user_id = (int)$_POST["mem_id"];
893  $comment = trim($_POST["comm"]);
894 
895  if($ass_id && $user_id)
896  {
897  $submission = new ilExSubmission($this->assignment, $user_id);
898  $user_ids = $submission->getUserIds();
899 
900  $all_members = new ilExerciseMembers($this->exercise);
901  $all_members = $all_members->getMembers();
902 
903  $reci_ids = array();
904  foreach($user_ids as $user_id)
905  {
906  if(in_array($user_id, $all_members))
907  {
908  $member_status = $this->assignment->getMemberStatus($user_id);
909  $member_status->setComment(ilUtil::stripSlashes($comment));
910  $member_status->setFeedback(true);
911  $member_status->update();
912 
913  if(trim($comment))
914  {
915  $reci_ids[] = $user_id;
916  }
917  }
918  }
919 
920  if(sizeof($reci_ids))
921  {
922  // send notification
923  $this->exercise->sendFeedbackFileNotification(null, $reci_ids,
924  $ass_id, true);
925  }
926 
927  $res = array("result"=>true, "snippet"=>ilUtil::shortenText($comment, 25, true));
928  }
929  }
930 
931  echo(json_encode($res));
932  exit();
933  }
934 
938  function exportExcelObject()
939  {
940  $this->exercise->exportGradesExcel();
941  exit;
942  }
943 
944 
945  //
946  // TEAM
947  //
948 
949  function createTeamsObject()
950  {
951  global $ilCtrl;
952 
953  $members = $this->getMultiActionUserIds(true);
954  if($members)
955  {
956  $new_members = array();
957 
958  include_once "Modules/Exercise/classes/class.ilExAssignmentTeam.php";
959  foreach($members as $group)
960  {
961  if(is_array($group))
962  {
963  $new_members = array_merge($new_members, $group);
964 
965  $first_user = $group;
966  $first_user = array_shift($first_user);
967  $team = ilExAssignmentTeam::getInstanceByUserId($this->assignment->getId(), $first_user);
968  foreach($group as $user_id)
969  {
970  $team->removeTeamMember($user_id);
971  }
972  }
973  else
974  {
975  $new_members[] = $group;
976  }
977  }
978 
979  if(sizeof($new_members))
980  {
981  // see ilExSubmissionTeamGUI::addTeamMemberActionObject()
982 
983  $first_user = array_shift($new_members);
984  $team = ilExAssignmentTeam::getInstanceByUserId($this->assignment->getId(), $first_user, true);
985  if(sizeof($new_members))
986  {
987  foreach($new_members as $user_id)
988  {
989  $team->addTeamMember($user_id);
990  }
991  }
992 
993  // re-evaluate complete team, as some members might have had submitted
994  $submission = new ilExSubmission($this->assignment, $first_user);
995  $this->exercise->processExerciseStatus(
996  $this->assignment,
997  $team->getMembers(),
998  $submission->hasSubmitted(),
999  $submission->validatePeerReviews()
1000  );
1001  }
1002 
1003  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1004  }
1005  $ilCtrl->redirect($this, "members");
1006  }
1007 
1009  {
1010  global $ilCtrl;
1011 
1012  $members = $this->getMultiActionUserIds(true);
1013  if($members)
1014  {
1015  include_once "Modules/Exercise/classes/class.ilExAssignmentTeam.php";
1016  foreach($members as $group)
1017  {
1018  // if single member - nothing to do
1019  if(is_array($group))
1020  {
1021  // see ilExSubmissionTeamGUI::removeTeamMemberObject()
1022 
1023  $first_user = $group;
1024  $first_user = array_shift($first_user);
1025  $team = ilExAssignmentTeam::getInstanceByUserId($this->assignment->getId(), $first_user);
1026  foreach($group as $user_id)
1027  {
1028  $team->removeTeamMember($user_id);
1029  }
1030 
1031  // reset ex team members, as any submission is not valid without team
1032  $this->exercise->processExerciseStatus(
1033  $this->assignment,
1034  $group,
1035  false
1036  );
1037  }
1038  }
1039 
1040  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1041  }
1042  $ilCtrl->redirect($this, "members");
1043  }
1044 
1046  {
1047  global $ilCtrl, $ilTabs, $lng, $tpl;
1048 
1049  $ilTabs->clearTargets();
1050  $ilTabs->setBackTarget($lng->txt("back"),
1051  $ilCtrl->getLinkTarget($this, $this->getViewBack()));
1052 
1053  if(!$a_form)
1054  {
1055  $a_form = $this->initGroupForm();
1056  }
1057  $tpl->setContent($a_form->getHTML());
1058  }
1059 
1060  protected function initGroupForm()
1061  {
1062  global $lng;
1063 
1064  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1065  $form = new ilPropertyFormGUI();
1066  $form->setTitle($lng->txt("exc_adopt_group_teams")." - ".$this->assignment->getTitle());
1067  $form->setFormAction($this->ctrl->getFormAction($this, "createTeamsFromGroups"));
1068 
1069  include_once "Modules/Exercise/classes/class.ilExAssignmentTeam.php";
1070  include_once "Services/User/classes/class.ilUserUtil.php";
1071  $all_members = array();
1072  foreach(ilExAssignmentTeam::getGroupMembersMap($this->exercise->getRefId()) as $grp_id => $group)
1073  {
1074  if(sizeof($group["members"]))
1075  {
1076  $grp_team = new ilCheckboxGroupInputGUI($lng->txt("obj_grp")." \"".$group["title"]."\"", "grpt_".$grp_id);
1077  $grp_value = $options = array();
1078  foreach($group["members"] as $user_id)
1079  {
1080  $user_name = ilUserUtil::getNamePresentation($user_id, false, false, "", true);
1081  $options[$user_id] = $user_name;
1082  if(!in_array($user_id, $all_members))
1083  {
1084  $grp_value[] = $user_id;
1085  $all_members[] = $user_id;
1086  }
1087  }
1088  asort($options);
1089  foreach($options as $user_id => $user_name)
1090  {
1091  $grp_team->addOption(new ilCheckboxOption($user_name, $user_id));
1092  }
1093  $grp_team->setValue($grp_value);
1094  $form->addItem($grp_team);
1095  }
1096  else
1097  {
1098  $grp_team = new ilNonEditableValueGUI($group["title"]);
1099  $grp_team->setValue($lng->txt("exc_adopt_group_teams_no_members"));
1100  $form->addItem($grp_team);
1101  }
1102  }
1103 
1104  if(sizeof($all_members))
1105  {
1106  $form->addCommandButton("createTeamsFromGroups", $lng->txt("save"));
1107  }
1108  $form->addCommandButton("members", $lng->txt("cancel"));
1109 
1110  return $form;
1111  }
1112 
1114  {
1115  global $lng;
1116 
1117  $form = $this->initGroupForm();
1118  if($form->checkInput())
1119  {
1120  include_once "Services/User/classes/class.ilUserUtil.php";
1121  $map = ilExAssignmentTeam::getGroupMembersMap($this->exercise->getRefId());
1122  $all_members = $teams = array();
1123  $valid = true;
1124  foreach(array_keys($map) as $grp_id)
1125  {
1126  $postvar = "grpt_".$grp_id;
1127  $members = $_POST[$postvar];
1128  if(is_array($members))
1129  {
1130  $teams[] = $members;
1131  $invalid_team_members = array();
1132 
1133  foreach($members as $user_id)
1134  {
1135  if(!array_key_exists($user_id, $all_members))
1136  {
1137  $all_members[$user_id] = $grp_id;
1138  }
1139  else
1140  {
1141  // user is selected in multiple groups
1142  $invalid_team_members[] = $user_id;
1143  }
1144  }
1145 
1146  if(sizeof($invalid_team_members))
1147  {
1148  $valid = false;
1149 
1150  $alert = array();
1151  foreach($invalid_team_members as $user_id)
1152  {
1153  $user_name = ilUserUtil::getNamePresentation($user_id, false, false, "", true);
1154  $grp_title = $map[$all_members[$user_id]]["title"];
1155  $alert[] = sprintf($lng->txt("exc_adopt_group_teams_conflict"), $user_name, $grp_title);
1156  }
1157  $input = $form->getItemByPostVar($postvar);
1158  $input->setAlert(implode("<br/>", $alert));
1159  }
1160  }
1161  }
1162  if($valid)
1163  {
1164  if(sizeof($teams))
1165  {
1166  $existing_users = array_keys(ilExAssignmentTeam::getAssignmentTeamMap($this->assignment->getId()));
1167 
1168  // create teams from group selections
1169  $sum = array("added"=>0, "blocked"=>0);
1170  foreach($teams as $members)
1171  {
1172  foreach($members as $user_id)
1173  {
1174  if(!$this->exercise->members_obj->isAssigned($user_id))
1175  {
1176  $this->exercise->members_obj->assignMember($user_id);
1177  }
1178 
1179  if(!in_array($user_id, $existing_users))
1180  {
1181  $sum["added"]++;
1182  }
1183  else
1184  {
1185  $sum["blocked"]++;
1186  }
1187  }
1188 
1189  $first = array_shift($members);
1190  $team = ilExAssignmentTeam::getInstanceByUserId($this->assignment->getId(), $first, true);
1191 
1192  // getTeamId() does NOT send notification
1193  // $team->sendNotification($this->exercise->getRefId(), $first, "add");
1194 
1195  if(sizeof($members))
1196  {
1197  foreach($members as $user_id)
1198  {
1199  $team->addTeamMember($user_id);
1200  }
1201  }
1202  }
1203 
1204  $mess = array();
1205  if($sum["added"])
1206  {
1207  $mess[] = sprintf($lng->txt("exc_adopt_group_teams_added"), $sum["added"]);
1208  }
1209  if($sum["blocked"])
1210  {
1211  $mess[] = sprintf($lng->txt("exc_adopt_group_teams_blocked"), $sum["blocked"]);
1212  }
1213  if($sum["added"])
1214  {
1215  ilUtil::sendSuccess(implode(" ", $mess), true);
1216  }
1217  else
1218  {
1219  ilUtil::sendFailure(implode(" ", $mess), true);
1220  }
1221  }
1222  $this->ctrl->redirect($this, "members");
1223  }
1224  else
1225  {
1226  ilUtil::sendFailure($lng->txt("form_input_not_valid"));
1227  }
1228  }
1229 
1230  $form->setValuesByPost();
1231  $this->adoptTeamsFromGroupObject($form);
1232  }
1233 
1234 
1238 
1239  function initMultiFeedbackForm($a_ass_id)
1240  {
1241  global $lng;
1242 
1243  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1244  $form = new ilPropertyFormGUI();
1245  $form->addCommandButton("uploadMultiFeedback", $lng->txt("upload"));
1246  $form->addCommandButton("members", $lng->txt("cancel"));
1247 
1248  // multi feedback file
1249  $fi = new ilFileInputGUI($lng->txt("exc_multi_feedback_file"), "mfzip");
1250  $fi->setSuffixes(array("zip"));
1251  $fi->setRequired(true);
1252  $form->addItem($fi);
1253 
1254  $form->setTitle(ilExAssignment::lookupTitle($a_ass_id));
1255  $form->setFormAction($this->ctrl->getFormAction($this, "uploadMultiFeedback"));
1256 
1257  return $form;
1258  }
1259 
1267  {
1268  global $ilToolbar, $lng, $tpl;
1269 
1270  ilUtil::sendInfo($lng->txt("exc_multi_feedb_info"));
1271 
1272  $this->addSubTabs("assignment");
1273 
1274  // #13719
1275  include_once("./Services/UIComponent/Button/classes/class.ilLinkButton.php");
1276  $button = ilLinkButton::getInstance();
1277  $button->setCaption("exc_download_zip_structure");
1278  $button->setUrl($this->ctrl->getLinkTarget($this, "downloadMultiFeedbackZip"));
1279  $button->setOmitPreventDoubleSubmission(true);
1280  $ilToolbar->addButtonInstance($button);
1281 
1282  if(!$a_form)
1283  {
1284  $a_form = $this->initMultiFeedbackForm($this->assignment->getId());
1285  }
1286 
1287  $tpl->setContent($a_form->getHTML());
1288  }
1289 
1294  {
1295  $this->assignment->sendMultiFeedbackStructureFile($this->exercise);
1296  }
1297 
1302  {
1303  // #11983
1304  $form = $this->initMultiFeedbackForm($this->assignment->getId());
1305  if($form->checkInput())
1306  {
1307  try
1308  {
1309  $this->assignment->uploadMultiFeedbackFile(ilUtil::stripSlashesArray($_FILES["mfzip"]));
1310  $this->ctrl->redirect($this, "showMultiFeedbackConfirmationTable");
1311  }
1312  catch (ilExerciseException $e)
1313  {
1314  ilUtil::sendFailure($e->getMessage(), true);
1315  $this->ctrl->redirect($this, "showMultiFeedback");
1316  }
1317  }
1318 
1319  $form->setValuesByPost();
1320  $this->showMultiFeedbackObject($form);
1321  }
1322 
1330  {
1331  global $tpl;
1332 
1333  $this->addSubTabs("assignment");
1334 
1335  include_once("./Modules/Exercise/classes/class.ilFeedbackConfirmationTable2GUI.php");
1336  $tab = new ilFeedbackConfirmationTable2GUI($this, "showMultiFeedbackConfirmationTable", $this->assignment);
1337  $tpl->setContent($tab->getHTML());
1338  }
1339 
1344  {
1345  $this->assignment->clearMultiFeedbackDirectory();
1346  $this->ctrl->redirect($this, "members");
1347  }
1348 
1353  {
1354  $this->assignment->saveMultiFeedbackFiles($_POST["file"], $this->exercise);
1355 
1356  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1357  $this->ctrl->redirect($this, "members");
1358  }
1359 }
1360 
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
print $file
deassignMembersObject()
Deassign members from exercise.
exit
Definition: login.php:54
showGradesOverviewObject()
Show grades overview.
static getAssignmentDataOfExercise($a_exc_id)
Get assignments data of an exercise in an array.
Exercise assignment.
$_POST['username']
Definition: cron.php:12
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
This class represents a file property in a property form.
$valid
Exercise participant table.
$cmd
Definition: sahs_server.php:35
static _lookupId($a_user_str)
Lookup id by login.
static shortenText($a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
showMultiFeedbackObject(ilPropertyFormGUI $a_form=null)
Show multi-feedback screen.
addUserFromAutoCompleteObject()
Add user as member.
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)
static hasAnySubmissions($a_ass_id)
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
selectParticipantObject()
Select participant.
saveStatusParticipantObject()
Save assignment status (participant view)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
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.
$data
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)
downloadMultiFeedbackZipObject()
Download multi-feedback structrue file.
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
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
$comment
Definition: buildRTE.php:83
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.
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.
saveStatus(array $a_data)
Save status of selecte members.
static getRedirectTarget($gui, $cmd, array $gui_params=array(), array $mail_params=array(), array $context_params=array())
global $lng
Definition: privfeed.php:40
saveCommentForLearnersObject()
Save comment for learner (asynch)
adoptTeamsFromGroupObject(ilPropertyFormGUI $a_form=null)
showMultiFeedbackConfirmationTableObject()
Show multi feedback confirmation table.
Exercise submission.
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
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.
Object-based submissions (ends up as static file)
static lookupTitle($a_id)
Lookup title.
downloadAllObject()
Download all submitted files (of all members).
Confirmation screen class.
Class to report exception.