ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjExerciseGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 require_once "./Services/Object/classes/class.ilObjectGUI.php";
6 
23 {
28  function ilObjExerciseGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output = true)
29  {
30  global $lng;
31 
32  $this->type = "exc";
33  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,false);
34 
35  $lng->loadLanguageModule("exercise");
36  $lng->loadLanguageModule("exc");
37  $this->ctrl->saveParameter($this,
38  array("ass_id", "part_id", "fsmode"));
39 
40  if ($_GET["ass_id"] > 0)
41  {
42  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
43  $this->ass = new ilExAssignment((int) $_GET["ass_id"]);
44  }
45  }
46 
47  function getFiles()
48  {
49  return $this->files ? $this->files : array();
50  }
51 
52  function setFiles($a_files)
53  {
54  $this->files = $a_files;
55  }
56 
57  function executeCommand()
58  {
59  global $ilUser,$ilCtrl, $ilTabs, $lng;
60 
61  $next_class = $this->ctrl->getNextClass($this);
62  $cmd = $this->ctrl->getCmd();
63  $this->prepareOutput();
64 
65 //echo "-".$next_class."-".$cmd."-"; exit;
66  switch($next_class)
67  {
68  case "ilfilesystemgui":
69  if($_GET["fsmode"] == "peer")
70  {
71  $ilCtrl->saveParameter($this, array("fu"));
72 
73  // see self::downloadPeerReview()
74  $parts = explode("__", $_GET["fu"]);
75  $giver_id = $parts[0];
76  $peer_id = $parts[1];
77 
78  if($giver_id == $ilUser->getId() ||
79  $peer_id == $ilUser->getId())
80  {
81  $this->checkPermission("read");
82  }
83  else
84  {
85  $this->checkPermission("write");
86  }
87 
88  /* could be 1st review and not saved yet
89  $valid = false;
90  $peer_items = $this->ass->getPeerReviewsByPeerId($peer_id, true);
91  if(sizeof($peer_items))
92  {
93  foreach($peer_items as $item)
94  {
95  if($item["giver_id"] == $giver_id)
96  {
97  $valid = true;
98  }
99  }
100  }
101  if(!$valid)
102  {
103  $ilCtrl->redirect($this, "editPeerReview");
104  }
105  */
106 
107  $ilTabs->clearTargets();
108  $ilTabs->setBackTarget($lng->txt("back"),
109  $ilCtrl->getLinkTarget($this, "editPeerReview"));
110 
111  include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
112  $fstorage = new ilFSStorageExercise($this->object->getId(), $this->ass->getId());
113  $fstorage->create();
114 
115  include_once("./Services/FileSystem/classes/class.ilFileSystemGUI.php");
116  $fs_gui = new ilFileSystemGUI($fstorage->getPeerReviewUploadPath($peer_id, $giver_id));
117  $fs_gui->setTableId("excfbpeer");
118  $fs_gui->setAllowDirectories(false);
119  $fs_gui->setTitle($this->ass->getTitle().": ".
120  $lng->txt("exc_peer_review")." - ".
121  $lng->txt("exc_peer_review_give"));
122  $ret = $this->ctrl->forwardCommand($fs_gui);
123  }
124  else if ($_GET["fsmode"] == "feedback" ||
125  $_GET["fsmode"] == "feedbackpart") // feedback files
126  {
127  $this->checkPermission("write");
128  $ilCtrl->saveParameter($this, array("member_id"));
129  //$this->setAssignmentHeader();
130  //$ilTabs->activateTab("ass_files");
131  $ilTabs->clearTargets();
132 
133  if ($_GET["fsmode"] != "feedbackpart")
134  {
135  $ilTabs->setBackTarget($lng->txt("back"),
136  $ilCtrl->getLinkTarget($this, "members"));
137  }
138  else
139  {
140  $ilTabs->setBackTarget($lng->txt("back"),
141  $ilCtrl->getLinkTarget($this, "showParticipant"));
142  }
143 
144  ilUtil::sendInfo($lng->txt("exc_fb_tutor_info"));
145 
146  include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
147  $fstorage = new ilFSStorageExercise($this->object->getId(), (int) $_GET["ass_id"]);
148  $fstorage->create();
149 
150  include_once("./Services/User/classes/class.ilUserUtil.php");
151  $noti_rec_ids = array();
152  if($this->ass->getType() == ilExAssignment::TYPE_UPLOAD_TEAM)
153  {
154  $team_id = $this->ass->getTeamId((int) $_GET["member_id"]);
155  $feedback_id = "t".$team_id;
156  $fs_title = array();
157  foreach($this->ass->getTeamMembers($team_id) as $team_user_id)
158  {
159  $fs_title[] = ilUserUtil::getNamePresentation($team_user_id, false, false, "", true);
160  $noti_rec_ids[] = $team_user_id;
161  }
162  $fs_title = implode(" / ", $fs_title);
163  }
164  else
165  {
166  $feedback_id = $noti_rec_ids = (int) $_GET["member_id"];
167  $fs_title = ilUserUtil::getNamePresentation((int) $_GET["member_id"], false, false, "", true);
168  }
169 
170  include_once("./Services/FileSystem/classes/class.ilFileSystemGUI.php");
171  $fs_gui = new ilFileSystemGUI($fstorage->getFeedbackPath($feedback_id));
172  $fs_gui->setTableId("excfbfil".(int)$_GET["ass_id"]."_".$feedback_id);
173  $fs_gui->setAllowDirectories(false);
174  $fs_gui->setTitle($lng->txt("exc_fb_files")." - ".
175  ilExAssignment::lookupTitle((int) $_GET["ass_id"])." - ".
176  $fs_title);
177  $pcommand = $fs_gui->getLastPerformedCommand();
178  if (is_array($pcommand) && $pcommand["cmd"] == "create_file")
179  {
180  $this->object->sendFeedbackFileNotification($pcommand["name"],
181  $noti_rec_ids, (int) $_GET["ass_id"]);
182  }
183  $ret = $this->ctrl->forwardCommand($fs_gui);
184  }
185  else // assignment files
186  {
187  $this->setAssignmentHeader();
188  $ilTabs->activateTab("ass_files");
189  include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
190  $fstorage = new ilFSStorageExercise($this->object->getId(), (int) $_GET["ass_id"]);
191  $fstorage->create();
192  include_once("./Services/FileSystem/classes/class.ilFileSystemGUI.php");
193  $fs_gui = new ilFileSystemGUI($fstorage->getPath());
194  $fs_gui->setTitle($lng->txt("exc_instruction_files"));
195  $fs_gui->setTableId("excassfil".$_GET["ass_id"]);
196  $fs_gui->setAllowDirectories(false);
197  $ret = $this->ctrl->forwardCommand($fs_gui);
198  }
199  break;
200 
201  case "ilinfoscreengui":
202  $ilTabs->activateTab("info");
203  $this->infoScreen(); // forwards command
204  break;
205 
206  case 'ilpermissiongui':
207  $ilTabs->activateTab("permissions");
208  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
209  $perm_gui =& new ilPermissionGUI($this);
210  $ret =& $this->ctrl->forwardCommand($perm_gui);
211  break;
212 
213  case "illearningprogressgui":
214  $ilTabs->activateTab("learning_progress");
215  include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
216 
218  $this->object->getRefId(),
219  $_GET['user_id'] ? $_GET['user_id'] : $ilUser->getId());
220  $this->ctrl->forwardCommand($new_gui);
221  $this->tabs_gui->setTabActive('learning_progress');
222  break;
223 
224  case 'ilrepositorysearchgui':
225  $ilTabs->activateTab("grades");
226  include_once('./Services/Search/classes/class.ilRepositorySearchGUI.php');
227  $rep_search = new ilRepositorySearchGUI();
228  if(!$_REQUEST["ctx"])
229  {
230  $rep_search->setTitle($this->lng->txt("exc_add_participant"));
231  $rep_search->setCallback($this,'addMembersObject');
232 
233  // Set tabs
234  $this->tabs_gui->setTabActive('members');
235  $this->ctrl->setReturn($this,'members');
236 
237  #$this->__setSubTabs('members');
238  #$this->tabs_gui->setSubTabActive('members');
239  }
240  else
241  {
242  $this->ctrl->saveParameterByClass('ilRepositorySearchGUI', 'ctx', 1);
243 
244  $rep_search->setTitle($this->lng->txt("exc_team_member_add"));
245  $rep_search->setCallback($this,'addTeamMemberActionObject');
246 
247  // Set tabs
248  $this->initTeamSubmission("submissionScreenTeam");
249  $this->ctrl->setReturn($this,'submissionScreenTeam');
250  }
251  $ret =& $this->ctrl->forwardCommand($rep_search);
252  break;
253 
254  case 'ilobjectcopygui':
255  $ilCtrl->saveParameter($this, 'new_type');
256  $ilCtrl->setReturnByClass(get_class($this),'create');
257 
258  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
259  $cp = new ilObjectCopyGUI($this);
260  $cp->setType('exc');
261  $this->ctrl->forwardCommand($cp);
262  break;
263 
264  case "ilexportgui":
265  $ilTabs->activateTab("export");
266  include_once("./Services/Export/classes/class.ilExportGUI.php");
267  $exp_gui = new ilExportGUI($this);
268  $exp_gui->addFormat("xml");
269  $ret = $this->ctrl->forwardCommand($exp_gui);
270 // $this->tpl->show();
271  break;
272  case 'ilshoppurchasegui':
273  include_once './Services/Payment/classes/class.ilShopPurchaseGUI.php';
274  $sp = new ilShopPurchaseGUI($_GET['ref_id']);
275 
276  $this->ctrl->forwardCommand($sp);
277  break;
278 
279  case "ilcommonactiondispatchergui":
280  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
282  $this->ctrl->forwardCommand($gui);
283  break;
284 
285  case "ilcertificategui":
286  $this->setSettingsSubTabs();
287  $this->tabs_gui->activateTab("settings");
288  $this->tabs_gui->activateSubTab("certificate");
289  include_once "./Services/Certificate/classes/class.ilCertificateGUI.php";
290  include_once "./Modules/Exercise/classes/class.ilExerciseCertificateAdapter.php";
291  $output_gui = new ilCertificateGUI(new ilExerciseCertificateAdapter($this->object));
292  $this->ctrl->forwardCommand($output_gui);
293  break;
294 
295  case "ilratinggui":
296  $this->ass->updatePeerReviewTimestamp((int)$_REQUEST["peer_id"]);
297 
298  include_once("./Services/Rating/classes/class.ilRatingGUI.php");
299  $rating_gui = new ilRatingGUI();
300  $rating_gui->setObject($this->ass->getId(), "ass",
301  (int)$_REQUEST["peer_id"], "peer");
302  $this->ctrl->forwardCommand($rating_gui);
303  $ilCtrl->redirect($this, "editPeerReview");
304  break;
305 
306  default:
307  $this->ctrl->setParameter($this, "fsmode", ""); // #15115
308 
309  if(!$cmd)
310  {
311  $cmd = "infoScreen";
312  }
313 
314  $cmd .= "Object";
315 
316  $this->$cmd();
317 
318  break;
319  }
320 
321  $this->addHeaderAction();
322 
323  return true;
324  }
325 
326  function viewObject()
327  {
328  $this->infoScreenObject();
329  }
330 
337  function downloadObject()
338  {
339  global $ilUser, $ilCtrl;
340 
341  $this->checkPermission("read");
342  if (count($_REQUEST["delivered"]))
343  {
344  if(!is_array($_REQUEST["delivered"]))
345  {
346  $_REQUEST["delivered"] = array($_REQUEST["delivered"]);
347  }
348  ilExAssignment::downloadSelectedFiles($this->object->getId(), (int) $_GET["ass_id"],
349  $ilUser->getId(), $_REQUEST["delivered"]);
350  exit;
351  }
352  else
353  {
354  ilUtil::sendFailure($this->lng->txt("please_select_a_delivered_file_to_download"), true);
355  $ilCtrl->redirect($this, "submissionScreen");
356  }
357  }
358 
363  {
364  global $ilCtrl, $tpl, $lng, $ilUser;
365 
366  $this->checkPermission("read");
367 
368  $this->tabs_gui->clearTargets();
369  $this->tabs_gui->setBackTarget($this->lng->txt("back"),
370  $this->ctrl->getLinkTarget($this, "submissionScreen"));
371 
372  // $this->tabs_gui->setTabActive("content");
373  // $this->addContentSubTabs("content");
374 
375  if (mktime() > $this->ass->getDeadline() && ($this->ass->getDeadline() != 0))
376  {
377  ilUtil::sendFailure($this->lng->txt("exercise_time_over"), true);
378  $ilCtrl->redirect($this, "submissionScreen");
379  }
380 
381  if (!is_array($_POST["delivered"]) || count($_POST["delivered"]) == 0)
382  {
383  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
384  $ilCtrl->redirect($this, "submissionScreen");
385  }
386  else
387  {
388  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
389  $cgui = new ilConfirmationGUI();
390  $cgui->setFormAction($ilCtrl->getFormAction($this));
391  $cgui->setHeaderText($lng->txt("info_delete_sure"));
392  $cgui->setCancel($lng->txt("cancel"), "submissionScreen");
393  $cgui->setConfirm($lng->txt("delete"), "deleteDelivered");
394 
395  $files = ilExAssignment::getDeliveredFiles($this->object->getId(), (int) $_GET["ass_id"],
396  $ilUser->getId());
397 //var_dump($files);
398  foreach ($_POST["delivered"] as $i)
399  {
400  reset ($files);
401  $title = "";
402  foreach ($files as $f)
403  {
404  if ($f["returned_id"] == $i)
405  {
406  $title = $f["filetitle"];
407  }
408  }
409  $cgui->addItem("delivered[]", $i, $title);
410  }
411 
412  $tpl->setContent($cgui->getHTML());
413  }
414  }
415 
423  {
424  global $ilUser, $ilCtrl;
425 
426  $this->checkPermission("read");
427 
428  if (mktime() > $this->ass->getDeadline() && ($this->ass->getDeadline() != 0))
429  {
430  ilUtil::sendFailure($this->lng->txt("exercise_time_over"), true);
431  $ilCtrl->redirect($this, "submissionScreen");
432  }
433 
434  if (count($_POST["delivered"]) && (mktime() < $this->ass->getDeadline() ||
435  $this->ass->getDeadline() == 0))
436  {
437  $this->object->deleteDeliveredFiles($this->object->getId(), (int) $_GET["ass_id"],
438  $_POST["delivered"], $ilUser->id);
439 
440  $this->object->handleSubmission((int)$_GET['ass_id']);
441 
442  ilUtil::sendSuccess($this->lng->txt("exc_submitted_files_deleted"), true);
443  }
444  else
445  {
446  ilUtil::sendFailure($this->lng->txt("please_select_a_delivered_file_to_delete"), true);
447  }
448  $ilCtrl->redirect($this, "submissionScreen");
449  }
450 
457  {
458  global $ilToolbar;
459 
460  $this->initTeamSubmission("showOverview", false);
461  $this->tabs_gui->activateTab("submissions");
462 
463  // $this->tabs_gui->setTabActive("content");
464  // $this->addContentSubTabs("content");
465 
466  if (mktime() > $this->ass->getDeadline() && ($this->ass->getDeadline() != 0))
467  {
468  ilUtil::sendInfo($this->lng->txt("exercise_time_over"));
469  }
470  else
471  {
472  $ilToolbar->addButton($this->lng->txt("file_add"),
473  $this->ctrl->getLinkTarget($this, "uploadForm"));
474 
475  $ilToolbar->addButton($this->lng->txt("header_zip"),
476  $this->ctrl->getLinkTarget($this, "uploadZipForm"));
477  }
478 
479  include_once("./Modules/Exercise/classes/class.ilExcDeliveredFilesTableGUI.php");
480  $tab = new ilExcDeliveredFilesTableGUI($this, "submissionScreen", $this->object, $_GET["ass_id"]);
481  $this->tpl->setContent($tab->getHTML());
482  }
483 
487  public function uploadFormObject()
488  {
489  if (mktime() < $this->ass->getDeadline() || ($this->ass->getDeadline() == 0))
490  {
491  $this->tabs_gui->clearTargets();
492  $this->tabs_gui->setBackTarget($this->lng->txt("back"),
493  $this->ctrl->getLinkTarget($this, "submissionScreen"));
494 
495  global $ilHelp;
496  $ilHelp->setScreenIdComponent("exc");
497  $ilHelp->setScreenId("upload_submission");
498 
499  $this->initUploadForm();
500  $this->tpl->setContent($this->form->getHTML());
501  }
502  else
503  {
504  $this->ctrl->redirect($this, "submissionScreen");
505  }
506  }
507 
511  public function uploadZipFormObject()
512  {
513  if (mktime() < $this->ass->getDeadline() || ($this->ass->getDeadline() == 0))
514  {
515  $this->tabs_gui->clearTargets();
516  $this->tabs_gui->setBackTarget($this->lng->txt("back"),
517  $this->ctrl->getLinkTarget($this, "submissionScreen"));
518 
519  $this->initZipUploadForm();
520  $this->tpl->setContent($this->form->getHTML());
521  }
522  else
523  {
524  $this->ctrl->redirect($this, "submissionScreen");
525  }
526  }
527 
531  public function initUploadForm()
532  {
533  global $lng, $ilCtrl;
534 
535  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
536  $this->form = new ilPropertyFormGUI();
537 
538  // file input
539  include_once("./Services/Form/classes/class.ilFileWizardInputGUI.php");
540  $fi = new ilFileWizardInputGUI($lng->txt("file"), "deliver");
541  $fi->setFilenames(array(0 => ''));
542  //$fi->setInfo($lng->txt(""));
543  $this->form->addItem($fi);
544 
545  $this->form->addCommandButton("deliverFile", $lng->txt("upload"));
546  $this->form->addCommandButton("submissionScreen", $lng->txt("cancel"));
547 
548  $this->form->setTitle($lng->txt("file_add"));
549  $this->form->setFormAction($ilCtrl->getFormAction($this));
550  }
551 
555  public function initZipUploadForm()
556  {
557  global $lng, $ilCtrl;
558 
559  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
560  $this->form = new ilPropertyFormGUI();
561 
562  // desc
563  include_once("./Services/Form/classes/class.ilFileInputGUI.php");
564  $fi = new ilFileInputGUI($lng->txt("file"), "deliver");
565  $fi->setSuffixes(array("zip"));
566  $this->form->addItem($fi);
567 
568  $this->form->addCommandButton("deliverUnzip", $lng->txt("upload"));
569  $this->form->addCommandButton("submissionScreen", $lng->txt("cancel"));
570 
571  $this->form->setTitle($lng->txt("header_zip"));
572  $this->form->setFormAction($ilCtrl->getFormAction($this));
573  }
574 
578  function deliverFileObject()
579  {
580  global $ilUser, $lng, $ilCtrl;
581 
582  $this->checkPermission("read");
583 
584  // #15322
585  if (mktime() > $this->ass->getDeadline() && ($this->ass->getDeadline() != 0))
586  {
587  ilUtil::sendInfo($this->lng->txt("exercise_time_over"));
588  return;
589  }
590 
591  $success = false;
592  foreach ($_FILES["deliver"]["name"] as $k => $v)
593  {
594  $file = array(
595  "name" => $_FILES["deliver"]["name"][$k],
596  "type" => $_FILES["deliver"]["type"][$k],
597  "tmp_name" => $_FILES["deliver"]["tmp_name"][$k],
598  "error" => $_FILES["deliver"]["error"][$k],
599  "size" => $_FILES["deliver"]["size"][$k],
600  );
601  if(!$this->object->deliverFile($file, (int) $_GET["ass_id"], $ilUser->id))
602  {
603  ilUtil::sendFailure($this->lng->txt("exc_upload_error"), true);
604  }
605  else
606  {
607  $success = true;
608  }
609  }
610 
611  if($success)
612  {
613  ilUtil::sendSuccess($this->lng->txt("file_added"), true);
614 
615  $this->sendNotifications((int)$_GET["ass_id"]);
616  $this->object->handleSubmission((int)$_GET['ass_id']);
617  }
618  $ilCtrl->redirect($this, "submissionScreen");
619  }
620 
625  {
626  global $ilCtrl;
627 
628  $this->checkPermission("read");
629 
630  // #15322
631  if (mktime() > $this->ass->getDeadline() && ($this->ass->getDeadline() != 0))
632  {
633  ilUtil::sendInfo($this->lng->txt("exercise_time_over"));
634  return;
635  }
636 
637  if (preg_match("/zip/",$_FILES["deliver"]["type"]) == 1)
638  {
639  if($this->object->processUploadedFile($_FILES["deliver"]["tmp_name"], "deliverFile", false,
640  (int) $_GET["ass_id"]))
641  {
642  $this->sendNotifications((int)$_GET["ass_id"]);
643  $this->object->handleSubmission((int)$_GET['ass_id']);
644  }
645  }
646 
647  $ilCtrl->redirect($this, "submissionScreen");
648  }
649 
654  {
655  global $rbacsystem, $ilUser;
656 
657  $file = $_REQUEST["file"];
658 
659  // check read permission
660  $this->checkPermission("read");
661 
662  if (!isset($file))
663  {
664  ilUtil::sendFailure($this->lng->txt("exc_select_one_file"),true);
665  $this->ctrl->redirect($this, "view");
666  }
667 
668  $ass = new ilExAssignment((int) $_GET["ass_id"]);
669 
670  if($ass->getType() == ilExAssignment::TYPE_UPLOAD_TEAM)
671  {
672  $feedback_id = "t".$ass->getTeamId($ilUser->getId());
673  }
674  else
675  {
676  $feedback_id = $ilUser->getId();
677  }
678 
679  // check, whether file belongs to assignment
680  include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
681  $storage = new ilFSStorageExercise($this->object->getId(), (int) $_GET["ass_id"]);
682  $files = $storage->getFeedbackFiles($feedback_id);
683  $file_exist = false;
684  foreach($files as $fb_file)
685  {
686  if($fb_file == $file)
687  {
688  $file_exist = true;
689  break;
690  }
691  }
692  if(!$file_exist)
693  {
694  echo "FILE DOES NOT EXIST";
695  exit;
696  }
697 
698  // check whether assignment as already started
699  $not_started_yet = false;
700  if ($ass->getStartTime() > 0 && time() - $ass->getStartTime() <= 0)
701  {
702  $not_started_yet = true;
703  }
704 
705  // deliver file
706  if (!$not_started_yet)
707  {
708  $p = $storage->getFeedbackFilePath($feedback_id, $file);
710  }
711 
712  return true;
713  }
714 
719  {
720  global $rbacsystem;
721 
722  $file = $_REQUEST["file"];
723 
724  // check read permission
725  $this->checkPermission("read");
726 
727  if (!isset($file))
728  {
729  ilUtil::sendFailure($this->lng->txt("exc_select_one_file"),true);
730  $this->ctrl->redirect($this, "view");
731  }
732 
733  // check, whether file belongs to assignment
734  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
735  $files = ilExAssignment::getFiles($this->object->getId(), (int) $_GET["ass_id"]);
736  $file_exist = false;
737  foreach($files as $lfile)
738  {
739  if($lfile["name"] == $file)
740  {
741  $file_exist = true;
742  break;
743  }
744  }
745  if(!$file_exist)
746  {
747  echo "FILE DOES NOT EXIST";
748  exit;
749  }
750 
751  // check whether assignment as already started
752  $ass = new ilExAssignment((int) $_GET["ass_id"]);
753  $not_started_yet = false;
754  if ($ass->getStartTime() > 0 && time() - $ass->getStartTime() <= 0)
755  {
756  $not_started_yet = true;
757  }
758 
759  // deliver file
760  if (!$not_started_yet)
761  {
762  include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
763  $storage = new ilFSStorageExercise($this->object->getId(), (int) $_GET["ass_id"]);
764  $p = $storage->getAssignmentFilePath($file);
766  }
767 
768  return true;
769  }
770 
771  protected function afterSave(ilObject $a_new_object)
772  {
773  $a_new_object->saveData();
774 
775  ilUtil::sendSuccess($this->lng->txt("exc_added"), true);
776  ilUtil::redirect("ilias.php?baseClass=ilExerciseHandlerGUI&ref_id=".$a_new_object->getRefId()."&cmd=addAssignment");
777  }
778 
782  protected function initEditCustomForm(ilPropertyFormGUI $a_form)
783  {
784  $a_form->setTitle($this->lng->txt("exc_edit_exercise"));
785 
787  $section->setTitle($this->lng->txt('exc_passing_exc'));
788  $a_form->addItem($section);
789 
790  // pass mode
791  $radg = new ilRadioGroupInputGUI($this->lng->txt("exc_pass_mode"), "pass_mode");
792 
793  $op1 = new ilRadioOption($this->lng->txt("exc_pass_all"), "all",
794  $this->lng->txt("exc_pass_all_info"));
795  $radg->addOption($op1);
796  $op2 = new ilRadioOption($this->lng->txt("exc_pass_minimum_nr"), "nr",
797  $this->lng->txt("exc_pass_minimum_nr_info"));
798  $radg->addOption($op2);
799 
800  // minimum number of assignments to pass
801  $ni = new ilNumberInputGUI($this->lng->txt("exc_min_nr"), "pass_nr");
802  $ni->setSize(4);
803  $ni->setMaxLength(4);
804  $ni->setRequired(true);
805  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
806  $mand = ilExAssignment::countMandatory($this->object->getId());
807  $min = max($mand, 1);
808  $ni->setMinValue($min, true);
809  $ni->setInfo($this->lng->txt("exc_min_nr_info"));
810  $op2->addSubItem($ni);
811 
812  $a_form->addItem($radg);
813 
814  // completion by submission
815  $subcompl = new ilRadioGroupInputGUI($this->lng->txt("exc_passed_status_determination"), "completion_by_submission");
816  $op1 = new ilRadioOption($this->lng->txt("exc_completion_by_tutor"), 0, "");
817  $subcompl->addOption($op1);
818  $op2 = new ilRadioOption($this->lng->txt("exc_completion_by_submission"), 1,$this->lng->txt("exc_completion_by_submission_info"));
819  $subcompl->addOption($op2);
820  $a_form->addItem($subcompl);
821 
822  /*$subcompl = new ilCheckboxInputGUI($this->lng->txt('exc_completion_by_submission'), 'completion_by_submission');
823  $subcompl->setInfo($this->lng->txt('exc_completion_by_submission_info'));
824  $subcompl->setValue(1);
825  $a_form->addItem($subcompl);*/
826 
828  $section->setTitle($this->lng->txt('exc_publishing'));
829  $a_form->addItem($section);
830 
831  // show submissions
832  $cb = new ilCheckboxInputGUI($this->lng->txt("exc_show_submissions"), "show_submissions");
833  $cb->setInfo($this->lng->txt("exc_show_submissions_info"));
834  $a_form->addItem($cb);
835 
837  $section->setTitle($this->lng->txt('exc_notification'));
838  $a_form->addItem($section);
839 
840  // submission notifications
841  $cbox = new ilCheckboxInputGUI($this->lng->txt("exc_submission_notification"), "notification");
842  $cbox->setInfo($this->lng->txt("exc_submission_notification_info"));
843  $a_form->addItem($cbox);
844  }
845 
849  protected function getEditFormCustomValues(array &$a_values)
850  {
851  global $ilUser;
852 
853  $a_values["desc"] = $this->object->getLongDescription();
854  $a_values["show_submissions"] = $this->object->getShowSubmissions();
855  $a_values["pass_mode"] = $this->object->getPassMode();
856  if ($a_values["pass_mode"] == "nr")
857  {
858  $a_values["pass_nr"] = $this->object->getPassNr();
859  }
860 
861  include_once "./Services/Notification/classes/class.ilNotification.php";
862  $a_values["notification"] = ilNotification::hasNotification(
864  $this->object->getId());
865 
866  $a_values['completion_by_submission'] = (int) $this->object->isCompletionBySubmissionEnabled();
867  }
868 
869  protected function updateCustom(ilPropertyFormGUI $a_form)
870  {
871  global $ilUser;
872  $this->object->setShowSubmissions($a_form->getInput("show_submissions"));
873  $this->object->setPassMode($a_form->getInput("pass_mode"));
874  if ($this->object->getPassMode() == "nr")
875  {
876  $this->object->setPassNr($a_form->getInput("pass_nr"));
877  }
878 
879  $this->object->setCompletionBySubmission($a_form->getInput('completion_by_submission') == 1 ? true : false);
880 
881  include_once "./Services/Notification/classes/class.ilNotification.php";
883  $ilUser->getId(), $this->object->getId(),
884  (bool)$a_form->getInput("notification"));
885  }
886 
887  function cancelEditObject()
888  {
889  $this->ctrl->redirect($this, "view");
890  }
891 
892  function uploadZipObject()
893  {
894  global $rbacsystem;
895 
896  $this->checkPermission("write");
897 
898  if(!$this->object->addUploadedFile($_FILES["zipfile"], true))
899  {
900  ilUtil::sendFailure($this->lng->txt("exc_upload_error"),true);
901  }
902  $this->ctrl->redirect($this, "edit");
903 
904  }
905 
906  function uploadFileObject()
907  {
908  global $rbacsystem;
909 
910  $this->checkPermission("write");
911 
912  if(!$this->object->addUploadedFile($_FILES["file"]))
913  {
914  ilUtil::sendFailure($this->lng->txt("exc_upload_error"),true);
915  }
916  $this->ctrl->redirect($this, "edit");
917  }
918 
919 
924  {
925  global $rbacsystem;
926 
927  $this->checkPermission("write");
928 
929  if ($_POST["downloadReturned"])
930  {
931  $this->object->members_obj->deliverReturnedFiles(key($_POST["downloadReturned"]));
932  exit;
933  }
934  else
935  {
936  switch($_POST["action"])
937  {
938  case "save_status":
939  $this->saveStatusObject();
940  break;
941 
942  case "send_member":
943  $this->sendMembersObject();
944  break;
945 
946  case "redirectFeedbackMail":
948  break;
949 
950  case "delete_member":
951  $this->deassignMembersObject();
952  break;
953  }
954  }
955  }
956 
961  {
962  global $ilAccess;
963 
964  $peer_review_mask_filename = false;
965 
966  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
967  {
968  if ($ilAccess->checkAccess("read", "", $this->object->getRefId()) &&
969  $this->object->getShowSubmissions() &&
970  $this->object->getTimestamp() - time() <= 0)
971  {
972  // ok: read access + public submissions
973  }
974  else
975  {
976  // ok: read access + peer review
977  $ass = new ilExAssignment((int) $_GET["ass_id"]);
978  if(!($ilAccess->checkAccess("read", "", $this->object->getRefId()) &&
979  $ass->hasPeerReviewAccess((int) $_GET["member_id"])))
980  {
981  $this->checkPermission("write");
982  }
983  else
984  {
985  $peer_review_mask_filename = true;
986  }
987  }
988  }
989 
991  $this->object->getId(), (int) $_GET["ass_id"], (int) $_GET["member_id"],
992  false, $peer_review_mask_filename))
993  {
994  $this->ctrl->redirect($this, "members");
995  }
996  exit;
997  }
998 
1003  {
1004  global $ilAccess;
1005 
1006  $peer_review_mask_filename = false;
1007 
1008  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
1009  {
1010  // ok: read access + peer review
1011  $ass = new ilExAssignment((int) $_GET["ass_id"]);
1012  if(!($ilAccess->checkAccess("read", "", $this->object->getRefId()) &&
1013  $ass->hasPeerReviewAccess((int) $_GET["member_id"])))
1014  {
1015  $this->checkPermission("write");
1016  }
1017  else
1018  {
1019  $peer_review_mask_filename = true;
1020  }
1021  }
1022 
1024  $this->object->getId(), (int) $_GET["ass_id"], (int) $_GET["member_id"],
1025  true, $peer_review_mask_filename))
1026  {
1027  $this->ctrl->redirect($this, "members");
1028  }
1029  exit;
1030  }
1031 
1036  {
1037  if(!strlen(trim($_POST['user_login'])))
1038  {
1039  ilUtil::sendFailure($this->lng->txt('msg_no_search_string'));
1040  $this->membersObject();
1041  return false;
1042  }
1043  $users = explode(',', $_POST['user_login']);
1044 
1045  $user_ids = array();
1046  foreach($users as $user)
1047  {
1048  $user_id = ilObjUser::_lookupId($user);
1049 
1050  if(!$user_id)
1051  {
1052  ilUtil::sendFailure($this->lng->txt('user_not_known'));
1053 
1054  // add team member
1055  if($_REQUEST['ctx'])
1056  {
1057  return $this->submissionScreenTeamObject();
1058  }
1059  else
1060  {
1061  return $this->membersObject();
1062  }
1063  }
1064 
1065  $user_ids[] = $user_id;
1066  }
1067 
1068  if($_REQUEST['ctx'])
1069  {
1070  return $this->addTeamMemberActionObject($user_ids);
1071  }
1072 
1073  if(!$this->addMembersObject($user_ids));
1074  {
1075  $this->membersObject();
1076  return false;
1077  }
1078  return true;
1079  }
1080 
1084  function addMembersObject($a_user_ids = array())
1085  {
1086  global $ilAccess,$ilErr;
1087 
1088  $this->checkPermission("write");
1089  if(!count($a_user_ids))
1090  {
1091  ilUtil::sendFailure($this->lng->txt("no_checkbox"));
1092  return false;
1093  }
1094 
1095  if(!$this->object->members_obj->assignMembers($a_user_ids))
1096  {
1097  ilUtil::sendFailure($this->lng->txt("exc_members_already_assigned"));
1098  return false;
1099  }
1100  else
1101  {
1102  /* #16921
1103  // #9946 - create team for new user(s) for each team upload assignment
1104  foreach(ilExAssignment::getAssignmentDataOfExercise($this->object->getId()) as $ass)
1105  {
1106  if($ass["type"] == ilExAssignment::TYPE_UPLOAD_TEAM)
1107  {
1108  $ass_obj = new ilExAssignment($ass["id"]);
1109  foreach($a_user_ids as $user_id)
1110  {
1111  $ass_obj->getTeamId($user_id, true);
1112  }
1113  }
1114  }
1115  */
1116 
1117  ilUtil::sendSuccess($this->lng->txt("exc_members_assigned"),true);
1118  }
1119 
1120  $this->ctrl->redirect($this, "members");
1121  return true;
1122  }
1123 
1124 
1128  function membersObject()
1129  {
1130  global $rbacsystem, $tree, $tpl, $ilToolbar, $ilCtrl, $ilTabs, $lng;
1131 
1132  $ilTabs->activateTab("grades");
1133 
1134  include_once 'Services/Tracking/classes/class.ilLPMarks.php';
1135 
1136  $this->checkPermission("write");
1137  $this->addSubmissionSubTabs("assignment");
1138 
1139  // assignment selection
1140  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
1141  $ass = ilExAssignment::getAssignmentDataOfExercise($this->object->getId());
1142 
1143  if ($_GET["ass_id"] == "")
1144  {
1145  $a = current($ass);
1146  $_GET["ass_id"] = $a["id"];
1147  }
1148 
1149  reset($ass);
1150  if (count($ass) > 1)
1151  {
1152  $options = array();
1153  foreach ($ass as $a)
1154  {
1155  $options[$a["id"]] = $a["title"];
1156  }
1157  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
1158  $si = new ilSelectInputGUI($this->lng->txt(""), "ass_id");
1159  $si->setOptions($options);
1160  $si->setValue($_GET["ass_id"]);
1161  $ilToolbar->addInputItem($si);
1162 
1163  $ilToolbar->addFormButton($this->lng->txt("exc_select_ass"),
1164  "selectAssignment");
1165  $ilToolbar->addSeparator();
1166  }
1167 
1168  // add member
1169  include_once './Services/Search/classes/class.ilRepositorySearchGUI.php';
1171  $this,
1172  $ilToolbar,
1173  array(
1174  'auto_complete_name' => $lng->txt('user'),
1175  'submit_name' => $lng->txt('add'),
1176  'add_search' => true,
1177  'add_from_container' => $_GET["ref_id"]
1178  )
1179  );
1180 
1181  // we do not want the ilRepositorySearchGUI form action
1182  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
1183 
1184  $ilToolbar->addSeparator();
1185 
1186  // multi-feebdack
1187  $ilToolbar->addButton($this->lng->txt("exc_multi_feedback"),
1188  $this->ctrl->getLinkTarget($this, "showMultiFeedback"));
1189 
1190  if (count($ass) > 0)
1191  {
1192  $ctype = null;
1193  foreach($ass as $item)
1194  {
1195  if($item["id"] == $_GET["ass_id"])
1196  {
1197  $ctype = $item["type"];
1198  }
1199  }
1200  if($ctype == ilExAssignment::TYPE_TEXT)
1201  {
1202  $ilToolbar->addSeparator();
1203  $ilToolbar->addFormButton($lng->txt("exc_list_text_assignment"), "listTextAssignment");
1204  }
1205  else if(count(ilExAssignment::getAllDeliveredFiles($this->object->getId(), $_GET["ass_id"])))
1206  {
1207  $ilToolbar->addSeparator();
1208  $ilToolbar->addFormButton($lng->txt("download_all_returned_files"), "downloadAll");
1209  }
1210 
1211  include_once("./Modules/Exercise/classes/class.ilExerciseMemberTableGUI.php");
1212  $exc_tab = new ilExerciseMemberTableGUI($this, "members", $this->object, $_GET["ass_id"]);
1213  $tpl->setContent($exc_tab->getHTML());
1214  }
1215  else
1216  {
1217  ilUtil::sendInfo($lng->txt("exc_no_assignments_available"));
1218  }
1219  return;
1220  }
1221 
1226  {
1227  global $ilTabs;
1228 
1229  $ilTabs->activateTab("grades");
1230 
1231  $_GET["ass_id"] = ilUtil::stripSlashes($_POST["ass_id"]);
1232  $this->membersObject();
1233  }
1234 
1239  {
1240  global $rbacsystem, $tree, $tpl, $ilToolbar, $ilCtrl, $ilTabs, $lng;
1241 
1242  $this->checkPermission("write");
1243 
1244  $ilTabs->activateTab("grades");
1245  $this->addSubmissionSubTabs("participant");
1246 
1247  // participant selection
1248  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
1249  $ass = ilExAssignment::getAssignmentDataOfExercise($this->object->getId());
1250  $members = $this->object->members_obj->getMembers();
1251 
1252  if (count($members) == 0)
1253  {
1254  ilUtil::sendInfo($lng->txt("exc_no_participants"));
1255  return;
1256  }
1257 
1258  $mems = array();
1259  foreach ($members as $mem_id)
1260  {
1261  if (ilObject::_lookupType($mem_id) == "usr")
1262  {
1263  include_once("./Services/User/classes/class.ilObjUser.php");
1264  $name = ilObjUser::_lookupName($mem_id);
1265  $mems[$mem_id] = $name;
1266  }
1267  }
1268 
1269  $mems = ilUtil::sortArray($mems, "lastname", "asc", false, true);
1270 
1271  if ($_GET["part_id"] == "" && count($mems) > 0)
1272  {
1273  $_GET["part_id"] = key($mems);
1274  }
1275 
1276  reset($mems);
1277  if (count($mems) > 1)
1278  {
1279  $options = array();
1280  foreach ($mems as $k => $m)
1281  {
1282  $options[$k] =
1283  $m["lastname"].", ".$m["firstname"]." [".$m["login"]."]";
1284  }
1285  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
1286  $si = new ilSelectInputGUI($this->lng->txt(""), "part_id");
1287  $si->setOptions($options);
1288  $si->setValue($_GET["part_id"]);
1289  $ilToolbar->addInputItem($si);
1290 
1291  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
1292  $ilToolbar->addFormButton($this->lng->txt("exc_select_part"),
1293  "selectParticipant");
1294  }
1295 
1296  if (count($mems) > 0)
1297  {
1298  include_once("./Modules/Exercise/classes/class.ilExParticipantTableGUI.php");
1299  $part_tab = new ilExParticipantTableGUI($this, "showParticipant",
1300  $this->object, $_GET["part_id"]);
1301  $tpl->setContent($part_tab->getHTML());
1302  }
1303  else
1304  {
1305  ilUtil::sendInfo($this->lng->txt("exc_no_assignments_available"));
1306  }
1307  }
1308 
1313  {
1314  global $ilTabs;
1315 
1316  $ilTabs->activateTab("grades");
1317 
1318  $_GET["part_id"] = ilUtil::stripSlashes($_POST["part_id"]);
1319  $this->showParticipantObject();
1320  }
1321 
1326  {
1327  global $rbacsystem, $tree, $tpl, $ilToolbar, $ilCtrl, $ilTabs, $lng;
1328 
1329  $this->checkPermission("write");
1330 
1331  $ilTabs->activateTab("grades");
1332  $this->addSubmissionSubTabs("grades");
1333 
1334  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
1335  $mem_obj = new ilExerciseMembers($this->object);
1336  $mems = $mem_obj->getMembers();
1337 
1338  if (count($mems) > 0)
1339  {
1340  $ilToolbar->addButton($lng->txt("exc_export_excel"),
1341  $ilCtrl->getLinkTarget($this, "exportExcel"));
1342  }
1343 
1344  include_once("./Modules/Exercise/classes/class.ilExGradesTableGUI.php");
1345  $grades_tab = new ilExGradesTableGUI($this, "showGradesOverview",
1346  $this->object, $mem_obj);
1347  $tpl->setContent($grades_tab->getHTML());
1348  }
1349 
1354  {
1355  $this->checkPermission("write");
1356 
1357  $members = array();
1358 
1359  if ($_GET["member_id"] != "")
1360  {
1361  if($this->ass->getType() == ilExAssignment::TYPE_UPLOAD_TEAM)
1362  {
1363  $members = ilExAssignment::getTeamMembersByAssignmentId($this->ass->getId(), $_GET["member_id"]);
1364  }
1365  else
1366  {
1367  $members = array($_GET["member_id"]);
1368  }
1369  }
1370  else if(count($_POST["member"]) > 0)
1371  {
1372  if($this->ass->getType() == ilExAssignment::TYPE_UPLOAD_TEAM)
1373  {
1374  foreach(array_keys($_POST["member"]) as $user_id)
1375  {
1376  $members = array_merge($members, ilExAssignment::getTeamMembersByAssignmentId($this->ass->getId(), $user_id));
1377  }
1378  $members = array_unique($members);
1379  }
1380  else
1381  {
1382  $members = array_keys($_POST["member"]);
1383  }
1384  }
1385 
1386  if($members)
1387  {
1388  $logins = array();
1389  foreach($members as $user_id)
1390  {
1391  ilExAssignment::updateStatusFeedbackForUser($this->ass->getId(), $user_id, 1);
1392  $logins[] = ilObjUser::_lookupLogin($user_id);
1393  }
1394  $logins = implode($logins, ",");
1395 
1396  require_once 'Services/Mail/classes/class.ilMailFormCall.php';
1397  ilUtil::redirect(ilMailFormCall::getRedirectTarget($this, 'members', array(), array('type' => 'new', 'rcp_to' => $logins)));
1398  }
1399 
1400  ilUtil::sendFailure($this->lng->txt("no_checkbox"),true);
1401  $this->ctrl->redirect($this, "members");
1402  }
1403 
1408  {
1409  $this->checkPermission("write");
1410 
1411  $members = array();
1412 
1413  foreach($this->object->members_obj->getMembers() as $member_id)
1414  {
1415  // update download time
1416  ilExAssignment::updateTutorDownloadTime($this->object->getId(),
1417  (int) $_GET["ass_id"], $member_id);
1418 
1419  // get member object (ilObjUser)
1420  if (ilObject::_exists($member_id))
1421  {
1422  $tmp_obj =& ilObjectFactory::getInstanceByObjId($member_id);
1423  $members[$member_id] = $tmp_obj->getFirstname() . " " . $tmp_obj->getLastname();
1424  unset($tmp_obj);
1425  }
1426  }
1427 
1428  ilExAssignment::downloadAllDeliveredFiles($this->object->getId(),
1429  (int) $_GET["ass_id"], $members);
1430  exit;
1431  }
1432 
1433 
1434  function __getMembersOfObject($a_result,$a_type)
1435  {
1436 
1437  switch($a_type)
1438  {
1439  case "usr":
1440  return $a_result;
1441  case "grp":
1442  include_once "./Modules/Group/classes/class.ilObjGroup.php";
1443 
1444  $all_members = array();
1445  foreach($a_result as $group)
1446  {
1447  $tmp_grp_obj = ilObjectFactory::getInstanceByRefId($group["id"]);
1448 
1449  $members = $tmp_grp_obj->getGroupMemberIds();
1450  $all_members = array_merge($all_members,$members);
1451  }
1452  // FORMAT ARRAY
1453  $all_members = array_unique($all_members);
1454  foreach($all_members as $member)
1455  {
1456  $result[] = array("id" => $member);
1457  }
1458  return $result;
1459  }
1460  return true;
1461  }
1462 
1463  function __showObjectSelect($a_result,$a_type)
1464  {
1465  include_once "./Services/Object/classes/class.ilObjectFactory.php";
1466 
1467  foreach($a_result as $obj)
1468  {
1469  $tmp_obj =& ilObjectFactory::getInstanceByRefId($obj["id"]);
1470  $this->tpl->setCurrentBlock("OBJ_SELECT_ROW");
1471  $this->tpl->setVariable("OBJ_ROW_TITLE",$tmp_obj->getTitle());
1472  $this->tpl->setVariable("OBJ_ROW_ID",$tmp_obj->getRefId());
1473  $this->tpl->setVariable("OBJ_ROW_DESCRIPTION",$tmp_obj->getDescription());
1474  $this->tpl->parseCurrentBlock();
1475 
1476  unset($tmp_obj);
1477  }
1478  $this->tpl->setCurrentBlock("OBJ_SELECT");
1479  $this->tpl->setVariable("OBJ_SELECT_TITLE",$this->lng->txt("title"));
1480  $this->tpl->setVariable("OBJ_SELECT_DESCRIPTION",$this->lng->txt("description"));
1481 
1482  $this->tpl->setVariable("OBJ_BTN1_VALUE",$this->lng->txt("select"));
1483  $this->tpl->setVariable("OBJ_BTN2_VALUE",$this->lng->txt("cancel"));
1484  $this->tpl->parseCurrentBlock();
1485  }
1486 
1491  {
1492  global $ilCtrl;
1493 
1494  $this->checkPermission("write");
1495 
1496  if(!count($_POST["member"]))
1497  {
1498  ilUtil::sendFailure($this->lng->txt("no_checkbox"),true);
1499  }
1500  else
1501  {
1502  // team upload?
1503  if($this->ass->getType() == ilExAssignment::TYPE_UPLOAD_TEAM)
1504  {
1505  $members = array();
1506  foreach(array_keys($_POST["member"]) as $user_id)
1507  {
1508  $tmembers = ilExAssignment::getTeamMembersByAssignmentId($this->ass->getId(), $user_id);
1509  foreach($tmembers as $tuser_id)
1510  {
1511  $members[$tuser_id] = 1;
1512  }
1513  }
1514  }
1515  else
1516  {
1517  $members = $_POST["member"];
1518  }
1519 
1520  $this->object->sendAssignment($this->object->getId(),
1521  (int) $_GET["ass_id"], $members);
1522 
1523  ilUtil::sendSuccess($this->lng->txt("exc_sent"),true);
1524  }
1525  $ilCtrl->redirect($this, "members");
1526  }
1527 
1532  {
1533  global $ilCtrl, $tpl, $lng, $ilTabs;
1534 
1535  $this->checkPermission("write");
1536  $ilTabs->activateTab("grades");
1537 
1538  if (!is_array($_POST["member"]) || count($_POST["member"]) == 0)
1539  {
1540  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
1541  $ilCtrl->redirect($this, "members");
1542  }
1543  else
1544  {
1545  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1546  $cgui = new ilConfirmationGUI();
1547  $cgui->setFormAction($ilCtrl->getFormAction($this));
1548  $cgui->setHeaderText($lng->txt("exc_msg_sure_to_deassign_participant"));
1549  $cgui->setCancel($lng->txt("cancel"), "members");
1550  $cgui->setConfirm($lng->txt("remove"), "deassignMembers");
1551 
1552  // team upload?
1553  if($this->ass->getType() == ilExAssignment::TYPE_UPLOAD_TEAM)
1554  {
1555  $members = array();
1556  foreach(array_keys($_POST["member"]) as $user_id)
1557  {
1558  $tmembers = ilExAssignment::getTeamMembersByAssignmentId($this->ass->getId(), $user_id);
1559  foreach($tmembers as $tuser_id)
1560  {
1561  $members[$tuser_id] = 1;
1562  }
1563  }
1564  }
1565  else
1566  {
1567  $members = $_POST["member"];
1568  }
1569 
1570  include_once("./Services/User/classes/class.ilUserUtil.php");
1571  foreach ($members as $k => $m)
1572  {
1573  $cgui->addItem("member[$k]", $m,
1574  ilUserUtil::getNamePresentation((int) $k, false, false, "", true));
1575  }
1576 
1577  $tpl->setContent($cgui->getHTML());
1578  }
1579  }
1580 
1585  {
1586  global $ilCtrl, $lng;
1587 
1588  $this->checkPermission("write");
1589 
1590  if(is_array($_POST["member"]))
1591  {
1592  foreach(array_keys($_POST["member"]) as $usr_id)
1593  {
1594  $this->object->members_obj->deassignMember((int) $usr_id);
1595  }
1596  ilUtil::sendSuccess($lng->txt("exc_msg_participants_removed"), true);
1597  $ilCtrl->redirect($this, "members");
1598  }
1599  else
1600  {
1601  ilUtil::sendFailure($this->lng->txt("no_checkbox"),true);
1602  $ilCtrl->redirect($this, "members");
1603  }
1604  }
1605 
1607  {
1608  $this->checkPermission("write");
1609 
1610  if(!isset($_POST['comments_value']))
1611  {
1612  return;
1613  }
1614 
1615  $this->object->members_obj->setNoticeForMember($_GET["member_id"],
1616  ilUtil::stripSlashes($_POST["comments_value"]));
1617  ilUtil::sendSuccess($this->lng->txt("exc_members_comments_saved"));
1618  $this->membersObject();
1619  }
1620 
1621 
1626  {
1627  $this->saveStatusObject(true);
1628  }
1629 
1631  {
1632  $this->saveStatusObject(false, true);
1633  }
1634 
1638  function saveStatusObject($a_part_view = false, $a_force_all = false)
1639  {
1640  global $ilCtrl;
1641 
1642  $this->checkPermission("write");
1643 
1644  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
1645 
1646 // include_once 'Services/Tracking/classes/class.ilLPMarks.php';
1647 
1648  $saved_for = array();
1649 
1650  foreach($_POST["id"] as $key => $value)
1651  {
1652  if (!$a_part_view)
1653  {
1654  if (!$a_force_all && $_POST["member"][$key] != "1")
1655  {
1656  continue;
1657  }
1658  else
1659  {
1660  $uname = ilObjUser::_lookupName($key);
1661  $saved_for[] = $uname["lastname"].", ".$uname["firstname"];
1662  }
1663  }
1664  if (!$a_part_view)
1665  {
1666  $ass_id = (int) $_GET["ass_id"];
1667  $user_id = (int) $key;
1668  }
1669  else
1670  {
1671  $ass_id = (int) $key;
1672  $user_id = (int) $_GET["part_id"];
1673  }
1674 
1675  // team upload?
1676  if(is_object($this->ass) and $this->ass->getType() == ilExAssignment::TYPE_UPLOAD_TEAM)
1677  {
1678  $team_id = $this->ass->getTeamId($user_id);
1679  $user_ids = $this->ass->getTeamMembers($team_id);
1680 
1681  if (count($_POST["member"]) > 0)
1682  {
1683  foreach($user_ids as $user_id)
1684  {
1685  if($user_id != $key)
1686  {
1687  $uname = ilObjUser::_lookupName($user_id);
1688  $saved_for[] = $uname["lastname"].", ".$uname["firstname"];
1689  }
1690  }
1691  }
1692  }
1693  else
1694  {
1695  $user_ids = array($user_id);
1696  }
1697 
1698  foreach($user_ids as $user_id)
1699  {
1700  ilExAssignment::updateStatusOfUser($ass_id, $user_id,
1701  ilUtil::stripSlashes($_POST["status"][$key]));
1702  ilExAssignment::updateNoticeForUser($ass_id, $user_id,
1703  ilUtil::stripSlashes($_POST["notice"][$key]));
1704 
1705  if (ilUtil::stripSlashes($_POST['mark'][$key]) !=
1706  ilExAssignment::lookupMarkOfUser($ass_id, $user_id))
1707  {
1708  ilExAssignment::updateStatusTimeOfUser($ass_id, $user_id);
1709  }
1710 
1711  ilExAssignment::updateMarkOfUser($ass_id, $user_id,
1712  ilUtil::stripSlashes($_POST['mark'][$key]));
1713 
1714  /*
1715  ilExAssignment::updateCommentForUser($ass_id, $user_id,
1716  ilUtil::stripSlashes($_POST['lcomment'][$key]));
1717  */
1718  }
1719  }
1720 
1721  if (count($saved_for) > 0)
1722  {
1723  $save_for_str = "(".implode($saved_for, " - ").")";
1724  }
1725  if($save_for_str || $a_part_view)
1726  {
1727  ilUtil::sendSuccess($this->lng->txt("exc_status_saved")." ".$save_for_str,true);
1728  }
1729  if (!$a_part_view)
1730  {
1731  $ilCtrl->redirect($this, "members");
1732  }
1733  else
1734  {
1735  $ilCtrl->redirect($this, "showParticipant");
1736  }
1737  }
1738 
1739  function __getDateSelect($a_type,$a_selected)
1740  {
1741  switch($a_type)
1742  {
1743  case "hour":
1744  for($i=0; $i<24; $i++)
1745  {
1746  $hours[$i] = $i < 10 ? "0".$i : $i;
1747  }
1748  return ilUtil::formSelect($a_selected,"d_hour",$hours,false,true);
1749 
1750  case "minutes":
1751  for($i=0;$i<60;$i++)
1752  {
1753  $minutes[$i] = $i < 10 ? "0".$i : $i;
1754  }
1755  return ilUtil::formSelect($a_selected,"d_minutes",$minutes,false,true);
1756 
1757  case "day":
1758  for($i=1; $i<32; $i++)
1759  {
1760  $days[$i] = $i < 10 ? "0".$i : $i;
1761  }
1762  return ilUtil::formSelect($a_selected,"d_day",$days,false,true);
1763 
1764  case "month":
1765  for($i=1; $i<13; $i++)
1766  {
1767  $month[$i] = $i < 10 ? "0".$i : $i;
1768  }
1769  return ilUtil::formSelect($a_selected,"d_month",$month,false,true);
1770 
1771  case "year":
1772  for($i = date("Y",time());$i < date("Y",time()) + 3;++$i)
1773  {
1774  $year[$i] = $i;
1775  }
1776  return ilUtil::formSelect($a_selected,"d_year",$year,false,true);
1777  }
1778  }
1779 
1780  function __filterAssignedUsers($a_result)
1781  {
1782  foreach($a_result as $user)
1783  {
1784  if(!$this->object->members_obj->isAssigned($user["id"]))
1785  {
1786  $filtered[] = $user;
1787  }
1788  }
1789 
1790  return $filtered ? $filtered : array();
1791  }
1792 
1798  function addSubmissionSubTabs($a_activate)
1799  {
1800  global $ilTabs, $lng, $ilCtrl;
1801 
1802  $ilTabs->addSubTab("assignment", $lng->txt("exc_assignment_view"),
1803  $ilCtrl->getLinkTarget($this, "members"));
1804  $ilTabs->addSubTab("participant", $lng->txt("exc_participant_view"),
1805  $ilCtrl->getLinkTarget($this, "showParticipant"));
1806  $ilTabs->addSubTab("grades", $lng->txt("exc_grades_overview"),
1807  $ilCtrl->getLinkTarget($this, "showGradesOverview"));
1808  $ilTabs->activateSubTab($a_activate);
1809  }
1810 
1816  function addContentSubTabs($a_activate)
1817  {
1818  global $ilTabs, $lng, $ilCtrl, $ilAccess;
1819 
1820  $ilTabs->addSubTab("content", $lng->txt("view"),
1821  $ilCtrl->getLinkTarget($this, "showOverview"));
1822  if ($ilAccess->checkAccess("write", "", $this->ref_id))
1823  {
1824  $ilTabs->addSubTab("list_assignments", $lng->txt("edit"),
1825  $ilCtrl->getLinkTarget($this, "listAssignments"));
1826  }
1827  $ilTabs->activateSubTab($a_activate);
1828  }
1829 
1830 
1836  function getTabs($tabs_gui)
1837  {
1838  global $ilAccess, $ilUser, $lng, $ilHelp;
1839 
1840  $ilHelp->setScreenIdComponent("exc");
1841 
1842  if ($ilAccess->checkAccess("read", "", $this->object->getRefId()))
1843  {
1844  $tabs_gui->addTab("content",
1845  $lng->txt("exc_assignments"),
1846  $this->ctrl->getLinkTarget($this, "showOverview"));
1847  }
1848 
1849  $next_class = strtolower($this->ctrl->getNextClass());
1850  if ($ilAccess->checkAccess("visible", "", $this->object->getRefId()))
1851  {
1852  $tabs_gui->addTab("info",
1853  $lng->txt("info_short"),
1854  $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary"));
1855  }
1856 
1857  // edit properties
1858  if ($ilAccess->checkAccess("write", "", $this->ref_id))
1859  {
1860  /*$tabs_gui->addTab("assignments",
1861  $lng->txt("exc_edit_assignments"),
1862  $this->ctrl->getLinkTarget($this, 'listAssignments'));*/
1863 
1864  $tabs_gui->addTab("settings",
1865  $lng->txt("settings"),
1866  $this->ctrl->getLinkTarget($this, 'edit'));
1867 
1868  $tabs_gui->addTab("grades",
1869  $lng->txt("exc_submissions_and_grades"),
1870  $this->ctrl->getLinkTarget($this, 'members'));
1871  }
1872 
1873  // learning progress
1874  $save_sort_order = $_GET["sort_order"]; // hack, because exercise sort parameters
1875  $save_sort_by = $_GET["sort_by"]; // must not be forwarded to learning progress
1876  $save_offset = $_GET["offset"];
1877  $_GET["offset"] = $_GET["sort_by"] = $_GET["sort_order"] = "";
1878 
1879  include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
1880  if(ilLearningProgressAccess::checkAccess($this->object->getRefId()))
1881  {
1882  $tabs_gui->addTab('learning_progress',
1883  $lng->txt('learning_progress'),
1884  $this->ctrl->getLinkTargetByClass(array('ilobjexercisegui','illearningprogressgui'),''));
1885  }
1886 
1887  $_GET["sort_order"] = $save_sort_order; // hack, part ii
1888  $_GET["sort_by"] = $save_sort_by;
1889  $_GET["offset"] = $save_offset;
1890 
1891  // export
1892  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
1893  {
1894  $tabs_gui->addTab("export",
1895  $lng->txt("export"),
1896  $this->ctrl->getLinkTargetByClass("ilexportgui", ""));
1897  }
1898 
1899 
1900  // permissions
1901  if ($ilAccess->checkAccess("edit_permission", "", $this->ref_id))
1902  {
1903  $tabs_gui->addTab('permissions',
1904  $lng->txt("perm_settings"),
1905  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"));
1906  }
1907  }
1908 
1914  function infoScreenObject()
1915  {
1916  $this->ctrl->setCmd("showSummary");
1917  $this->ctrl->setCmdClass("ilinfoscreengui");
1918  $this->infoScreen();
1919  }
1920 
1924  function infoScreen()
1925  {
1926  global $ilAccess, $ilUser, $ilTabs, $lng;
1927 
1928  $ilTabs->activateTab("info");
1929 
1930  $this->checkPermission("visible");
1931 
1932  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
1933  $info = new ilInfoScreenGUI($this);
1934 
1935  $info->enablePrivateNotes();
1936 
1937  $info->enableNews();
1938  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
1939  {
1940  $info->enableNewsEditing();
1941  $info->setBlockProperty("news", "settings", true);
1942  }
1943 
1944  // standard meta data
1945  //$info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
1946 
1947  // instructions
1948  $info->addSection($this->lng->txt("exc_overview"));
1949  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
1950  $ass = ilExAssignment::getAssignmentDataOfExercise($this->object->getId());
1951  $cnt = 0;
1952  $mcnt = 0;
1953  foreach ($ass as $a)
1954  {
1955  $cnt++;
1956  if ($a["mandatory"])
1957  {
1958  $mcnt++;
1959  }
1960  }
1961  $info->addProperty($lng->txt("exc_assignments"), $cnt);
1962  $info->addProperty($lng->txt("exc_mandatory"), $mcnt);
1963  if ($this->object->getPassMode() != "nr")
1964  {
1965  $info->addProperty($lng->txt("exc_pass_mode"),
1966  $lng->txt("exc_msg_all_mandatory_ass"));
1967  }
1968  else
1969  {
1970  $info->addProperty($lng->txt("exc_pass_mode"),
1971  sprintf($lng->txt("exc_msg_min_number_ass"), $this->object->getPassNr()));
1972  }
1973 
1974  // feedback from tutor
1975  include_once("Services/Tracking/classes/class.ilLPMarks.php");
1976  if ($ilAccess->checkAccess("read", "", $this->ref_id))
1977  {
1978  $lpcomment = ilLPMarks::_lookupComment($ilUser->getId(), $this->object->getId());
1979  $mark = ilLPMarks::_lookupMark($ilUser->getId(), $this->object->getId());
1980  //$status = ilExerciseMembers::_lookupStatus($this->object->getId(), $ilUser->getId());
1981  $st = $this->object->determinStatusOfUser($ilUser->getId());
1982  $status = $st["overall_status"];
1983  if ($lpcomment != "" || $mark != "" || $status != "notgraded")
1984  {
1985  $info->addSection($this->lng->txt("exc_feedback_from_tutor"));
1986  if ($lpcomment != "")
1987  {
1988  $info->addProperty($this->lng->txt("exc_comment"),
1989  $lpcomment);
1990  }
1991  if ($mark != "")
1992  {
1993  $info->addProperty($this->lng->txt("exc_mark"),
1994  $mark);
1995  }
1996 
1997  //if ($status == "")
1998  //{
1999  // $info->addProperty($this->lng->txt("status"),
2000  // $this->lng->txt("message_no_delivered_files"));
2001  //}
2002  //else
2003  if ($status != "notgraded")
2004  {
2005  $img = '<img src="'.ilUtil::getImagePath("scorm/".$status.".svg").'" '.
2006  ' alt="'.$lng->txt("exc_".$status).'" title="'.$lng->txt("exc_".$status).
2007  '" />';
2008 
2009  $add = "";
2010  if ($st["failed_a_mandatory"])
2011  {
2012  $add = " (".$lng->txt("exc_msg_failed_mandatory").")";
2013  }
2014  else if ($status == "failed")
2015  {
2016  $add = " (".$lng->txt("exc_msg_missed_minimum_number").")";
2017  }
2018  $info->addProperty($this->lng->txt("status"),
2019  $img." ".$this->lng->txt("exc_".$status).$add);
2020  }
2021  }
2022  }
2023 
2024  // forward the command
2025  $this->ctrl->forwardCommand($info);
2026  }
2027 
2028  function editObject()
2029  {
2030  $this->setSettingsSubTabs();
2031  $this->tabs_gui->activateSubTab("edit");
2032  return parent::editObject();
2033  }
2034 
2035  protected function setSettingsSubTabs()
2036  {
2037  $this->tabs_gui->addSubTab("edit",
2038  $this->lng->txt("general_settings"),
2039  $this->ctrl->getLinkTarget($this, "edit"));
2040 
2041  include_once "Services/Certificate/classes/class.ilCertificate.php";
2043  {
2044  $this->tabs_gui->addSubTab("certificate",
2045  $this->lng->txt("certificate"),
2046  $this->ctrl->getLinkTarget($this, "certificate"));
2047  }
2048  }
2049 
2055  public static function _goto($a_target, $a_raw)
2056  {
2057  global $ilErr, $lng, $ilAccess;
2058 
2059  $ass_id = null;
2060  $parts = explode("_", $a_raw);
2061  if(sizeof($parts) == 2)
2062  {
2063  $ass_id = (int)$parts[1];
2064  }
2065 
2066  if ($ilAccess->checkAccess("read", "", $a_target))
2067  {
2068  if($ass_id)
2069  {
2070  $_GET["ass_id_goto"] = $ass_id;
2071  }
2072  $_GET["ref_id"] = $a_target;
2073  $_GET["cmd"] = "showOverview";
2074  $_GET["baseClass"] = "ilExerciseHandlerGUI";
2075  include("ilias.php");
2076  exit;
2077  }
2078  else if ($ilAccess->checkAccess("visible", "", $a_target))
2079  {
2080  $_GET["ref_id"] = $a_target;
2081  $_GET["cmd"] = "infoScreen";
2082  $_GET["baseClass"] = "ilExerciseHandlerGUI";
2083  include("ilias.php");
2084  exit;
2085  }
2086  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
2087  {
2088  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
2089  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
2091  }
2092 
2093  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
2094  }
2095 
2099  function addLocatorItems()
2100  {
2101  global $ilLocator;
2102 
2103  if (is_object($this->object))
2104  {
2105  // #17955
2106  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "showOverview"), "", $_GET["ref_id"]);
2107  }
2108  }
2109 
2113 
2118  {
2119  global $tpl, $ilTabs, $ilToolbar, $lng, $ilCtrl;
2120 
2121  $this->checkPermission("write");
2122 
2123  $ilTabs->activateTab("content");
2124  $this->addContentSubTabs("list_assignments");
2125 
2126  $ilToolbar->addButton($lng->txt("exc_add_assignment"),
2127  $ilCtrl->getLinkTarget($this, "addAssignment"));
2128 
2129  include_once("./Modules/Exercise/classes/class.ilAssignmentsTableGUI.php");
2130  $t = new ilAssignmentsTableGUI($this, "listAssignments", $this->object);
2131  $tpl->setContent($t->getHTML());
2132  }
2133 
2138  {
2139  global $tpl, $ilTabs;
2140 
2141  $this->checkPermission("write");
2142 
2143  $ilTabs->activateTab("content");
2144  $this->addContentSubTabs("list_assignments");
2145 
2146  $this->initAssignmentForm("create");
2147  $tpl->setContent($this->form->getHTML());
2148  }
2149 
2155  public function initAssignmentForm($a_mode = "create")
2156  {
2157  global $lng, $ilCtrl, $ilSetting;
2158 
2159  // init form
2160  $lng->loadLanguageModule("form");
2161  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
2162  $this->form = new ilPropertyFormGUI();
2163  $this->form->setTableWidth("600px");
2164  if ($a_mode == "edit")
2165  {
2166  $this->form->setTitle($lng->txt("exc_edit_assignment"));
2167  }
2168  else
2169  {
2170  $this->form->setTitle($lng->txt("exc_new_assignment"));
2171  }
2172  $this->form->setFormAction($ilCtrl->getFormAction($this));
2173 
2174  // type
2175  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
2176  $types = array(ilExAssignment::TYPE_UPLOAD => $this->lng->txt("exc_type_upload"),
2177  ilExAssignment::TYPE_UPLOAD_TEAM => $this->lng->txt("exc_type_upload_team"),
2178  ilExAssignment::TYPE_TEXT => $this->lng->txt("exc_type_text"));
2179  if(!$ilSetting->get('disable_wsp_blogs'))
2180  {
2181  $types[ilExAssignment::TYPE_BLOG] = $this->lng->txt("exc_type_blog");
2182  }
2183  if($ilSetting->get('user_portfolios'))
2184  {
2185  $types[ilExAssignment::TYPE_PORTFOLIO] = $this->lng->txt("exc_type_portfolio");
2186  }
2187  if(sizeof($types) > 1)
2188  {
2189  $ty = new ilSelectInputGUI($this->lng->txt("exc_assignment_type"), "type");
2190  $ty->setOptions($types);
2191  $ty->setRequired(true);
2192  }
2193  else
2194  {
2195  $ty = new ilHiddenInputGUI("type");
2196  $ty->setValue(ilExAssignment::TYPE_UPLOAD);
2197  }
2198  $this->form->addItem($ty);
2199 
2200  // title
2201  $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
2202  $ti->setMaxLength(200);
2203  $ti->setRequired(true);
2204  $this->form->addItem($ti);
2205 
2206  // start time y/n
2207  $cb = new ilCheckboxInputGUI($this->lng->txt("exc_start_time"), "start_time_cb");
2208  $this->form->addItem($cb);
2209 
2210  // start time
2211  $edit_date = new ilDateTimeInputGUI("", "start_time");
2212  $edit_date->setShowTime(true);
2213  $cb->addSubItem($edit_date);
2214 
2215 
2216  // deadline y/n
2217  $dcb = new ilCheckboxInputGUI($this->lng->txt("exc_deadline"), "deadline_cb");
2218  $dcb->setChecked(true);
2219  $this->form->addItem($dcb);
2220 
2221  // Deadline
2222  $edit_date = new ilDateTimeInputGUI($lng->txt(""), "deadline");
2223  $edit_date->setShowTime(true);
2224  $dcb->addSubItem($edit_date);
2225 
2226  // mandatory
2227  $cb = new ilCheckboxInputGUI($this->lng->txt("exc_mandatory"), "mandatory");
2228  $cb->setInfo($this->lng->txt("exc_mandatory_info"));
2229  $cb->setChecked(true);
2230  $this->form->addItem($cb);
2231 
2232  // Work Instructions
2233  $desc_input = new ilTextAreaInputGUI($lng->txt("exc_instruction"), "instruction");
2234  $desc_input->setRows(20);
2235  $desc_input->setUseRte(true);
2236  $desc_input->setRteTagSet("mini");
2237  $this->form->addItem($desc_input);
2238 
2239  // files
2240  if ($a_mode == "create")
2241  {
2242  $files = new ilFileWizardInputGUI($this->lng->txt('objs_file'),'files');
2243  $files->setFilenames(array(0 => ''));
2244  $this->form->addItem($files);
2245  }
2246 
2247  // peer review
2248  $peer = new ilCheckboxInputGUI($lng->txt("exc_peer_review"), "peer");
2249  $peer->setInfo($this->lng->txt("exc_peer_review_ass_setting_info"));
2250  $this->form->addItem($peer);
2251 
2252  if ($a_mode == "create")
2253  {
2254  $peer->setInfo($lng->txt("exc_peer_review_info"));
2255  }
2256 
2257  $peer_min = new ilNumberInputGUI($lng->txt("exc_peer_review_min_number"), "peer_min");
2258  $peer_min->setInfo($lng->txt("exc_peer_review_min_number_info"));
2259  $peer_min->setRequired(true);
2260  $peer_min->setValue(5);
2261  $peer_min->setSize(3);
2262  $peer_min->setValue(2);
2263  $peer->addSubItem($peer_min);
2264 
2265  $peer_dl = new ilDateTimeInputGUI($lng->txt("exc_peer_review_deadline"), "peer_dl");
2266  $peer_dl->setInfo($lng->txt("exc_peer_review_deadline_info"));
2267  $peer_dl->enableDateActivation("", "peer_dl_tgl");
2268  $peer_dl->setShowTime(true);
2269  $peer->addSubItem($peer_dl);
2270 
2271  $peer_file = new ilCheckboxInputGUI($lng->txt("exc_peer_review_file"), "peer_file");
2272  $peer_file->setInfo($lng->txt("exc_peer_review_file_info"));
2273  $peer->addSubItem($peer_file);
2274 
2275  $peer_prsl = new ilCheckboxInputGUI($lng->txt("exc_peer_review_personal"), "peer_prsl");
2276  $peer_prsl->setInfo($lng->txt("exc_peer_review_personal_info"));
2277  $peer->addSubItem($peer_prsl);
2278 
2279  if($a_mode != "create" && // #13745
2280  $this->ass &&
2281  $this->ass->getDeadline() && $this->ass->getDeadline() < time())
2282  {
2283  $peer_prsl->setDisabled(true);
2284  }
2285 
2286 
2287  // global feedback
2288 
2289  $fb = new ilCheckboxInputGUI($lng->txt("exc_global_feedback_file"), "fb");
2290  $this->form->addItem($fb);
2291 
2292  $fb_file = new ilFileInputGUI($lng->txt("file"), "fb_file");
2293  $fb_file->setRequired(true); // will be disabled on update if file exists (see below)
2294  // $fb_file->setAllowDeletion(true); makes no sense if required (overwrite or keep)
2295  $fb->addSubItem($fb_file);
2296 
2297  // #15467
2298  if($a_mode != "create" &&
2299  $this->ass &&
2300  $this->ass->getFeedbackFile())
2301  {
2302  $fb_file->setRequired(false);
2303  }
2304 
2305  $fb_date = new ilRadioGroupInputGUI($lng->txt("exc_global_feedback_file_date"), "fb_date");
2306  $fb_date->setRequired(true);
2307  $fb_date->addOption(new ilRadioOption($lng->txt("exc_global_feedback_file_date_deadline"), ilExAssignment::FEEDBACK_DATE_DEADLINE));
2308  $fb_date->addOption(new ilRadioOption($lng->txt("exc_global_feedback_file_date_upload"), ilExAssignment::FEEDBACK_DATE_SUBMISSION));
2309  $fb->addSubItem($fb_date);
2310 
2311  $fb_cron = new ilCheckboxInputGUI($lng->txt("exc_global_feedback_file_cron"), "fb_cron");
2312  $fb_cron->setInfo($lng->txt("exc_global_feedback_file_cron_info"));
2313  $fb->addSubItem($fb_cron);
2314 
2315  // save and cancel commands
2316  if ($a_mode == "create")
2317  {
2318  $this->form->addCommandButton("saveAssignment", $lng->txt("save"));
2319  $this->form->addCommandButton("listAssignments", $lng->txt("cancel"));
2320  }
2321  else
2322  {
2323  $this->form->addCommandButton("updateAssignment", $lng->txt("save"));
2324  $this->form->addCommandButton("listAssignments", $lng->txt("cancel"));
2325  }
2326  }
2327 
2332  public function saveAssignmentObject()
2333  {
2334  global $tpl, $lng, $ilCtrl, $ilTabs;
2335 
2336  $this->checkPermission("write");
2337 
2338  $ilTabs->activateTab("content");
2339  $this->addContentSubTabs("list_assignments");
2340 
2341  $this->initAssignmentForm("create");
2342  if ($this->form->checkInput())
2343  {
2344  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
2345 
2346  // additional checks
2347 
2348  $valid = true;
2349 
2350  if ($_POST["start_time_cb"] && $_POST["deadline_cb"])
2351  {
2352  // check whether start date is before end date
2353  $start_date =
2354  $this->form->getItemByPostVar("start_time")->getDate();
2355  $end_date =
2356  $this->form->getItemByPostVar("deadline")->getDate();
2357  if ($start_date->get(IL_CAL_UNIX) >=
2358  $end_date->get(IL_CAL_UNIX))
2359  {
2360  $this->form->getItemByPostVar("start_time")
2361  ->setAlert($lng->txt("exc_start_date_should_be_before_end_date"));
2362  $this->form->getItemByPostVar("deadline")
2363  ->setAlert($lng->txt("exc_start_date_should_be_before_end_date"));
2364  $valid = false;
2365  }
2366  }
2367 
2368  if($_POST["type"] == ilExAssignment::TYPE_UPLOAD_TEAM && $_POST["peer"])
2369  {
2370  $this->form->getItemByPostVar("peer")
2371  ->setAlert($lng->txt("exc_team_upload_not_supported"));
2372  $valid = false;
2373  }
2374 
2375  if(!$_POST["deadline_cb"])
2376  {
2377  if($_POST["peer"])
2378  {
2379  $this->form->getItemByPostVar("peer")
2380  ->setAlert($lng->txt("exc_needs_deadline"));
2381  $valid = false;
2382  }
2383  if($_POST["fb"])
2384  {
2385  $this->form->getItemByPostVar("fb")
2386  ->setAlert($lng->txt("exc_needs_deadline"));
2387  $valid = false;
2388  }
2389  }
2390  else
2391  {
2392  if($_POST["type"] != ilExAssignment::TYPE_UPLOAD_TEAM &&
2393  $_POST["peer"] &&
2394  $_POST["peer_dl_tgl"])
2395  {
2396  $peer_dl = $this->form->getItemByPostVar("peer_dl")->getDate();
2397  $peer_dl = $peer_dl->get(IL_CAL_UNIX);
2398  $end_date = $this->form->getItemByPostVar("deadline")->getDate();
2399  $end_date = $end_date->get(IL_CAL_UNIX);
2400 
2401  // #13877
2402  if ($peer_dl < $end_date)
2403  {
2404  $this->form->getItemByPostVar("peer_dl")
2405  ->setAlert($lng->txt("exc_peer_deadline_mismatch"));
2406  $valid = false;
2407  }
2408  }
2409  }
2410 
2411  if(!$valid)
2412  {
2413  ilUtil::sendFailure($lng->txt("form_input_not_valid"));
2414  $this->form->setValuesByPost();
2415  $tpl->setContent($this->form->getHtml());
2416  return;
2417  }
2418 
2419  $ass = new ilExAssignment();
2420  $ass->setTitle($_POST["title"]);
2421  $ass->setInstruction($_POST["instruction"]);
2422  $ass->setExerciseId($this->object->getId());
2423  $ass->setMandatory($_POST["mandatory"]);
2424  $ass->setType($_POST["type"]);
2425 
2426  if ($_POST["start_time_cb"])
2427  {
2428  $date =
2429  $this->form->getItemByPostVar("start_time")->getDate();
2430  $ass->setStartTime($date->get(IL_CAL_UNIX));
2431  }
2432  else
2433  {
2434  $ass->setStartTime(null);
2435  }
2436 
2437  // deadline
2438  if ($_POST["deadline_cb"])
2439  {
2440  $date =
2441  $this->form->getItemByPostVar("deadline")->getDate();
2442  $ass->setDeadline($date->get(IL_CAL_UNIX));
2443  }
2444  else
2445  {
2446  $ass->setDeadline(null);
2447  }
2448 
2450  {
2451  $ass->setPeerReview($_POST["peer"]);
2452  $ass->setPeerReviewMin($_POST["peer_min"]);
2453  $ass->setPeerReviewFileUpload($_POST["peer_file"]);
2454 
2455  if($ass->getDeadline() && $ass->getDeadline() > time())
2456  {
2457  $ass->setPeerReviewPersonalized($_POST["peer_prsl"]);
2458  }
2459 
2460  if($_POST["peer_dl_tgl"])
2461  {
2462  $peer_dl = $this->form->getItemByPostVar("peer_dl")->getDate();
2463  $ass->setPeerReviewDeadline($peer_dl->get(IL_CAL_UNIX));
2464  }
2465  else
2466  {
2467  $ass->setPeerReviewDeadline(null);
2468  }
2469  }
2470 
2471  $ass->setFeedbackCron($_POST["fb_cron"]); // #13380
2472  $ass->setFeedbackDate($_POST["fb_date"]);
2473 
2474  $ass->save();
2475 
2476  // save files
2477  $ass->uploadAssignmentFiles($_FILES["files"]);
2478 
2479  if($_FILES["fb_file"]["tmp_name"])
2480  {
2481  $ass->handleFeedbackFileUpload($_FILES["fb_file"]);
2482  $ass->update();
2483  }
2484 
2485  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
2486 
2487  if($ass->getType() == ilExAssignment::TYPE_UPLOAD_TEAM)
2488  {
2489  if(sizeof(ilExAssignment::getAdoptableTeamAssignments($this->object->getId(), $ass->getId())))
2490  {
2491  $ilCtrl->setParameter($this, "ass_id", $ass->getId());
2492  $ilCtrl->redirect($this, "adoptTeamAssignmentsForm");
2493  }
2494  }
2495 
2496  $ilCtrl->redirect($this, "listAssignments");
2497  }
2498  else
2499  {
2500  $this->form->setValuesByPost();
2501  $tpl->setContent($this->form->getHtml());
2502  }
2503  }
2504 
2509  {
2510  global $tpl, $ilTabs, $tpl;
2511 
2512  $this->checkPermission("write");
2513 
2514  $this->setAssignmentHeader();
2515  $ilTabs->activateTab("ass_settings");
2516 
2517  $this->initAssignmentForm("edit");
2518  $this->getAssignmentValues();
2519  $tpl->setContent($this->form->getHTML());
2520  }
2521 
2526  public function getAssignmentValues()
2527  {
2528  $values = array();
2529 
2530  $ass = new ilExAssignment($_GET["ass_id"]);
2531  $values["title"] = $ass->getTitle();
2532  if ($ass->getStartTime() > 0)
2533  {
2534  $values["start_time_cb"] = true;
2535  }
2536  $values["mandatory"] = $ass->getMandatory();
2537  $values["instruction"] = $ass->getInstruction();
2538  $values["type"] = $ass->getType();
2539  if ($ass->getDeadline() > 0)
2540  {
2541  $values["deadline_cb"] = true;
2542  }
2543  if($this->ass->getType() == ilExAssignment::TYPE_UPLOAD_TEAM)
2544  {
2545  $this->form->removeItemByPostVar("peer");
2546  $this->form->removeItemByPostVar("peer_min");
2547  $this->form->removeItemByPostVar("peer_dl");
2548  }
2549  else
2550  {
2551  if ($ass->getPeerReviewDeadline() > 0)
2552  {
2553  $values["peer_dl_tgl"] = true;
2554  $peer_dl_date = new ilDateTime($ass->getPeerReviewDeadline(), IL_CAL_UNIX);
2555  $peer_dl = $this->form->getItemByPostVar("peer_dl");
2556  $peer_dl->setDate($peer_dl_date);
2557  }
2558  }
2559  $this->form->setValuesByArray($values);
2560 
2561  if ($ass->getStartTime() > 0)
2562  {
2563  $edit_date = new ilDateTime($ass->getStartTime(), IL_CAL_UNIX);
2564  $ed_item = $this->form->getItemByPostVar("start_time");
2565  $ed_item->setDate($edit_date);
2566  }
2567 
2568  if($ass->getFeedbackFile())
2569  {
2570  $this->form->getItemByPostVar("fb")->setChecked(true);
2571  $this->form->getItemByPostVar("fb_file")->setValue(basename($ass->getFeedbackFilePath()));
2572  }
2573  $this->form->getItemByPostVar("fb_cron")->setChecked($ass->hasFeedbackCron());
2574  $this->form->getItemByPostVar("fb_date")->setValue($ass->getFeedbackDate());
2575 
2576  $this->handleDisabledAssignmentFields($ass, $this->form);
2577  }
2578 
2580  {
2581  // potentially disabled elements are initialized here to re-use this
2582  // method after setValuesByPost() - see updateAssignmentObject()
2583 
2584  // if there are any submissions we cannot change type anymore
2585  if(sizeof(ilExAssignment::getAllDeliveredFiles($this->object->getId(), $a_ass->getId())) ||
2587  {
2588  $a_form->getItemByPostVar("type")->setDisabled(true);
2589  }
2590 
2591  if($a_ass->getDeadline() > 0)
2592  {
2593  $a_form->getItemByPostVar("deadline_cb")->setChecked(true);
2594  $edit_date = new ilDateTime($a_ass->getDeadline(), IL_CAL_UNIX);
2595  $ed_item = $a_form->getItemByPostVar("deadline");
2596  $ed_item->setDate($edit_date);
2597  }
2598 
2599  // team assignments do not support peer review
2600  if($a_ass->getType() == ilExAssignment::TYPE_UPLOAD_TEAM)
2601  {
2602  return;
2603  }
2604 
2605  $a_form->getItemByPostVar("peer")->setChecked($a_ass->getPeerReview());
2606  $a_form->getItemByPostVar("peer_min")->setValue($a_ass->getPeerReviewMin());
2607  $a_form->getItemByPostVar("peer_file")->setChecked($a_ass->hasPeerReviewFileUpload());
2608  $a_form->getItemByPostVar("peer_prsl")->setChecked($a_ass->hasPeerReviewPersonalized());
2609 
2610  // with no active peer review there is nothing to protect
2611  if(!$a_ass->getPeerReview())
2612  {
2613  return;
2614  }
2615 
2616  // #14450
2617  if($a_ass->hasPeerReviewGroups())
2618  {
2619  // deadline(s) are past and must not change
2620  $a_form->getItemByPostVar("deadline_cb")->setDisabled(true);
2621  $a_form->getItemByPostVar("deadline")->setDisabled(true);
2622 
2623  // JourFixe, 2015-05-11 - editable again
2624  // $a_form->getItemByPostVar("peer_dl")->setDisabled(true);
2625 
2626  $a_form->getItemByPostVar("peer")->setDisabled(true);
2627  $a_form->getItemByPostVar("peer_min")->setDisabled(true);
2628  $a_form->getItemByPostVar("peer_file")->setDisabled(true);
2629  $a_form->getItemByPostVar("peer_prsl")->setDisabled(true);
2630  }
2631 
2632  }
2633 
2638  public function updateAssignmentObject()
2639  {
2640  global $tpl, $lng, $ilCtrl, $ilTabs;
2641 
2642  $this->checkPermission("write");
2643 
2644  $ilTabs->activateTab("content");
2645  $this->addContentSubTabs("list_assignments");
2646 
2647  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
2648  $ass = new ilExAssignment($_GET["ass_id"]);
2649 
2650  $this->initAssignmentForm("edit");
2651  if ($this->form->checkInput())
2652  {
2653  // #14450
2654  $protected_peer_review_groups = false;
2655  if($ass->getPeerReview() &&
2656  $ass->hasPeerReviewGroups())
2657  {
2658  $protected_peer_review_groups = true;
2659 
2660  // checkInput() will add alert to disabled fields
2661  $this->form->getItemByPostVar("deadline")->setAlert(null);
2662  $this->form->getItemByPostVar("peer_min")->setAlert(null);
2663  }
2664 
2665  // additional checks
2666 
2667  $valid = true;
2668 
2669  if(!$protected_peer_review_groups)
2670  {
2671  $peer = $_POST["peer"];
2672 
2673  if ($_POST["deadline_cb"])
2674  {
2675  $end_date =
2676  $this->form->getItemByPostVar("deadline")->getDate()->get(IL_CAL_UNIX);
2677  }
2678 
2679  if ($_POST["start_time_cb"] && $end_date)
2680  {
2681  // check whether start date is before end date
2682  $start_date =
2683  $this->form->getItemByPostVar("start_time")->getDate()->get(IL_CAL_UNIX);
2684  if ($start_date >= $end_date)
2685  {
2686  $this->form->getItemByPostVar("start_time")
2687  ->setAlert($lng->txt("exc_start_date_should_be_before_end_date"));
2688  $this->form->getItemByPostVar("deadline")
2689  ->setAlert($lng->txt("exc_start_date_should_be_before_end_date"));
2690  $valid = false;
2691  }
2692  }
2693 
2694  if(!$end_date)
2695  {
2696  if($_POST["peer"])
2697  {
2698  $this->form->getItemByPostVar("peer")
2699  ->setAlert($lng->txt("exc_needs_deadline"));
2700  $valid = false;
2701  }
2702  if($_POST["fb"] && $_POST["fb_date"] == ilExAssignment::FEEDBACK_DATE_DEADLINE)
2703  {
2704  $this->form->getItemByPostVar("fb")
2705  ->setAlert($lng->txt("exc_needs_deadline"));
2706  $valid = false;
2707  }
2708  }
2709  }
2710  else
2711  {
2712  $peer = true;
2713  $end_date = $ass->getDeadline();
2714  }
2715 
2716  if($_POST["type"] != ilExAssignment::TYPE_UPLOAD_TEAM &&
2717  $peer &&
2718  $_POST["peer_dl_tgl"])
2719  {
2720  $peer_dl = $this->form->getItemByPostVar("peer_dl")->getDate();
2721  $peer_dl = $peer_dl->get(IL_CAL_UNIX);
2722 
2723  // #13877
2724  if ($peer_dl < $end_date)
2725  {
2726  $this->form->getItemByPostVar("peer_dl")
2727  ->setAlert($lng->txt("exc_peer_deadline_mismatch"));
2728  $valid = false;
2729  }
2730  }
2731 
2732  if(!$valid)
2733  {
2734  ilUtil::sendFailure($lng->txt("form_input_not_valid"));
2735  $this->form->setValuesByPost();
2736  $this->handleDisabledAssignmentFields($ass, $this->form);
2737  $tpl->setContent($this->form->getHtml());
2738  return;
2739  }
2740 
2741  $ass->setTitle($_POST["title"]);
2742  $ass->setInstruction($_POST["instruction"]);
2743  $ass->setExerciseId($this->object->getId());
2744  $ass->setMandatory($_POST["mandatory"]);
2745  $ass->setType($_POST["type"]);
2746 
2747  if ($_POST["start_time_cb"])
2748  {
2749  $date =
2750  $this->form->getItemByPostVar("start_time")->getDate();
2751  $ass->setStartTime($date->get(IL_CAL_UNIX));
2752  }
2753  else
2754  {
2755  $ass->setStartTime(null);
2756  }
2757 
2758  if(!$protected_peer_review_groups)
2759  {
2760  // deadline
2761  if ($_POST["deadline_cb"])
2762  {
2763  $date = $this->form->getItemByPostVar("deadline")->getDate();
2764  $ass->setDeadline($date->get(IL_CAL_UNIX));
2765  }
2766  else
2767  {
2768  $ass->setDeadline(null);
2769  }
2770 
2772  {
2773  $ass->setPeerReview($_POST["peer"]);
2774  $ass->setPeerReviewMin($_POST["peer_min"]);
2775  $ass->setPeerReviewFileUpload($_POST["peer_file"]);
2776 
2777  if($ass->getDeadline() && $ass->getDeadline() > time())
2778  {
2779  $ass->setPeerReviewPersonalized($_POST["peer_prsl"]);
2780  }
2781  }
2782  }
2783 
2784  if($_POST["peer_dl_tgl"])
2785  {
2786  $peer_dl = $this->form->getItemByPostVar("peer_dl")->getDate();
2787  $ass->setPeerReviewDeadline($peer_dl->get(IL_CAL_UNIX));
2788  }
2789  else
2790  {
2791  $ass->setPeerReviewDeadline(null);
2792  }
2793 
2794  if(!$_POST["fb"] ||
2795  $this->form->getItemByPostVar("fb_file")->getDeletionFlag())
2796  {
2797  $ass->deleteFeedbackFile();
2798  $ass->setFeedbackFile(null);
2799  }
2800  else if($_FILES["fb_file"]["tmp_name"]) // #15189
2801  {
2802  $ass->handleFeedbackFileUpload($_FILES["fb_file"]);
2803  }
2804 
2805  $ass->setFeedbackCron($_POST["fb_cron"]); // #13380
2806  $ass->setFeedbackDate($_POST["fb_date"]);
2807 
2808  $ass->update();
2809  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
2810  $ilCtrl->redirect($this, "editAssignment");
2811  }
2812  else
2813  {
2814  $this->form->setValuesByPost();
2815  $this->handleDisabledAssignmentFields($ass, $this->form);
2816  $tpl->setContent($this->form->getHtml());
2817  }
2818  }
2819 
2820 
2825  {
2826  global $ilCtrl, $tpl, $lng, $ilTabs;
2827 
2828  $this->checkPermission("write");
2829 
2830  $ilTabs->activateTab("content");
2831  $this->addContentSubTabs("list_assignments");
2832 
2833  if (!is_array($_POST["id"]) || count($_POST["id"]) == 0)
2834  {
2835  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
2836  $ilCtrl->redirect($this, "listAssignments");
2837  }
2838  else
2839  {
2840  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
2841  $cgui = new ilConfirmationGUI();
2842  $cgui->setFormAction($ilCtrl->getFormAction($this));
2843  $cgui->setHeaderText($lng->txt("exc_conf_del_assignments"));
2844  $cgui->setCancel($lng->txt("cancel"), "listAssignments");
2845  $cgui->setConfirm($lng->txt("delete"), "deleteAssignments");
2846 
2847  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
2848 
2849  foreach ($_POST["id"] as $i)
2850  {
2851  $cgui->addItem("id[]", $i, ilExAssignment::lookupTitle($i));
2852  }
2853 
2854  $tpl->setContent($cgui->getHTML());
2855  }
2856  }
2857 
2862  {
2863  global $ilDB, $ilCtrl, $lng;
2864 
2865  $this->checkPermission("write");
2866 
2867  $delete = false;
2868  if (is_array($_POST["id"]))
2869  {
2870  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
2871  foreach($_POST["id"] as $id)
2872  {
2873  $ass = new ilExAssignment(ilUtil::stripSlashes($id));
2874  $ass->delete();
2875  $delete = true;
2876  }
2877  }
2878 
2879  if ($delete)
2880  {
2881  ilUtil::sendSuccess($lng->txt("exc_assignments_deleted"), true);
2882  }
2883  $ilCtrl->redirect($this, "listAssignments");
2884  }
2885 
2890  {
2891  global $lng, $ilCtrl;
2892 
2893  $this->checkPermission("write");
2894 
2895  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
2896  ilExAssignment::saveAssOrderOfExercise($this->object->getId(), $_POST["order"]);
2897 
2898  ilUtil::sendSuccess($lng->txt("exc_saved_order"), true);
2899  $ilCtrl->redirect($this, "listAssignments");
2900  }
2901 
2906  {
2907  global $lng, $ilCtrl;
2908 
2909  $this->checkPermission("write");
2910 
2911  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
2912  ilExAssignment::orderAssByDeadline($this->object->getId());
2913 
2914  ilUtil::sendSuccess($lng->txt("exc_saved_order"), true);
2915  $ilCtrl->redirect($this, "listAssignments");
2916  }
2917 
2922  {
2923  global $ilTabs, $lng, $ilCtrl, $tpl, $ilHelp;
2924 
2925  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
2926  $tpl->setTitle(ilExAssignment::lookupTitle((int) $_GET["ass_id"]));
2927  $tpl->setDescription("");
2928 
2929  $ilTabs->clearTargets();
2930  $ilHelp->setScreenIdComponent("exc");
2931 
2932  $ilTabs->setBackTarget($lng->txt("back"),
2933  $ilCtrl->getLinkTarget($this, "listAssignments"));
2934 
2935  $ilTabs->addTab("ass_settings",
2936  $lng->txt("settings"),
2937  $ilCtrl->getLinkTarget($this, "editAssignment"));
2938 
2939  $ilTabs->addTab("ass_files",
2940  $lng->txt("exc_instruction_files"),
2941  $ilCtrl->getLinkTargetByClass("ilfilesystemgui", "listFiles"));
2942 
2943  }
2944 
2945 
2949 
2954  {
2955  global $tpl, $ilTabs, $ilUser, $ilToolbar;
2956 
2957  $this->checkPermission("read");
2958 
2959  include_once("./Services/Tracking/classes/class.ilLearningProgress.php");
2960  ilLearningProgress::_tracProgress($ilUser->getId(),$this->object->getId(),
2961  $this->object->getRefId(), 'exc');
2962 
2963  $ilTabs->activateTab("content");
2964  $this->addContentSubTabs("content");
2965 
2966  // show certificate?
2967  if($this->object->hasUserCertificate($ilUser->getId()))
2968  {
2969  include_once "./Modules/Exercise/classes/class.ilExerciseCertificateAdapter.php";
2970  include_once "./Services/Certificate/classes/class.ilCertificate.php";
2971  $adapter = new ilExerciseCertificateAdapter($this->object);
2972  if(ilCertificate::_isComplete($adapter))
2973  {
2974  $ilToolbar->addButton($this->lng->txt("certificate"),
2975  $this->ctrl->getLinkTarget($this, "outCertificate"));
2976  }
2977  }
2978 
2979  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
2980  include_once("./Services/Accordion/classes/class.ilAccordionGUI.php");
2981  $acc = new ilAccordionGUI();
2982  $acc->setId("exc_ow_".$this->object->getId());
2983  $ass_data = ilExAssignment::getAssignmentDataOfExercise($this->object->getId());
2984  include_once("./Modules/Exercise/classes/class.ilExAssignmentGUI.php");
2985  $ass_gui = new ilExAssignmentGUI($this->object);
2986 
2987  foreach ($ass_data as $ass)
2988  {
2989  // incoming assignment deeplink
2990  $force_open = false;
2991  if(isset($_GET["ass_id_goto"]) &&
2992  (int)$_GET["ass_id_goto"] == $ass["id"])
2993  {
2994  $force_open = true;
2995  }
2996 
2997  $acc->addItem($ass_gui->getOverviewHeader($ass),
2998  $ass_gui->getOverviewBody($ass),
2999  $force_open);
3000  }
3001 
3002  if (count($ass_data) < 2)
3003  {
3004  $acc->setBehaviour("FirstOpen");
3005  }
3006  else
3007  {
3008  $acc->setUseSessionStorage(true);
3009  }
3010 
3011  $tpl->setContent($acc->getHTML());
3012  }
3013 
3018  {
3019  global $tpl, $ilTabs;
3020 
3021  $this->checkPermission("read");
3022 
3023  if(!$this->object->getShowSubmissions())
3024  {
3025  $this->ctrl->redirect($this, "view");
3026  }
3027 
3028  $ilTabs->activateTab("content");
3029  $this->addContentSubTabs("content");
3030 
3031  if($this->ass->getType() != ilExAssignment::TYPE_TEXT)
3032  {
3033  include_once("./Modules/Exercise/classes/class.ilPublicSubmissionsTableGUI.php");
3034  $tab = new ilPublicSubmissionsTableGUI($this, "listPublicSubmissions",
3035  $this->object, (int) $_GET["ass_id"]);
3036  $tpl->setContent($tab->getHTML());
3037  }
3038  else
3039  {
3040  // #13271
3041  include_once "Modules/Exercise/classes/class.ilExAssignmentListTextTableGUI.php";
3042  $tbl = new ilExAssignmentListTextTableGUI($this, "listPublicSubmissions", $this->ass, false, true);
3043  $tpl->setContent($tbl->getHTML());
3044  }
3045  }
3046 
3051  {
3052  $this->checkPermission("write");
3053  $this->object->exportGradesExcel();
3054  exit;
3055  }
3056 
3060  function saveGradesObject()
3061  {
3062  global $ilCtrl, $lng;
3063 
3064  $this->checkPermission("write");
3065  include_once 'Services/Tracking/classes/class.ilLPMarks.php';
3066 
3067  if (is_array($_POST["lcomment"]))
3068  {
3069  foreach ($_POST["lcomment"] as $k => $v)
3070  {
3071  $marks_obj = new ilLPMarks($this->object->getId(), (int) $k);
3072  $marks_obj->setComment(ilUtil::stripSlashes($v));
3073  $marks_obj->setMark(ilUtil::stripSlashes($_POST["mark"][$k]));
3074  $marks_obj->update();
3075  }
3076  }
3077  ilUtil::sendSuccess($lng->txt("exc_msg_saved_grades"), true);
3078  $ilCtrl->redirect($this, "showGradesOverview");
3079  }
3080 
3085  protected function sendNotifications($assignment_id)
3086  {
3087  include_once "./Services/Notification/classes/class.ilNotification.php";
3089 
3090  include_once "./Modules/Exercise/classes/class.ilExerciseMailNotification.php";
3091  $not = new ilExerciseMailNotification();
3093  $not->setAssignmentId($assignment_id);
3094  $not->setRefId($this->ref_id);
3095  $not->setRecipients($users);
3096  $not->send();
3097  }
3098 
3099  protected function createBlogObject()
3100  {
3101  global $ilUser;
3102 
3103  $this->checkPermission("read");
3104 
3105  // $this->tabs_gui->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTarget($this, "showOverview"));
3106 
3107  $this->tabs_gui->setTabActive("content");
3108  $this->addContentSubTabs("content");
3109 
3110  if (mktime() > $this->ass->getDeadline() && ($this->ass->getDeadline() != 0))
3111  {
3112  ilUtil::sendInfo($this->lng->txt("exercise_time_over"));
3113  }
3114 
3115  $tpl = new ilTemplate("tpl.exc_select_resource.html", true, true, "Modules/Exercise");
3116  $tpl->setVariable("TXT_TITLE", $this->lng->txt("exc_create_blog").": ".$this->ass->getTitle());
3117  $tpl->setVariable("TREE", $this->renderWorkspaceExplorer("createBlog"));
3118  $tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
3119  $tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
3120  $tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
3121  $tpl->setVariable("CMD_SUBMIT", "saveBlog");
3122  $tpl->setVariable("CMD_CANCEL", "showOverview");
3123 
3124  ilUtil::sendInfo($this->lng->txt("exc_create_blog_select_info"));
3125 
3126  $this->tpl->setContent($tpl->get());
3127  }
3128 
3129  protected function selectBlogObject()
3130  {
3131  global $ilUser;
3132 
3133  $this->checkPermission("read");
3134 
3135  $this->tabs_gui->clearTargets();
3136  $this->tabs_gui->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTarget($this, "showOverview"));
3137 
3138  // $this->tabs_gui->setTabActive("content");
3139  // $this->addContentSubTabs("content");
3140 
3141  if (mktime() > $this->ass->getDeadline() && ($this->ass->getDeadline() != 0))
3142  {
3143  ilUtil::sendInfo($this->lng->txt("exercise_time_over"));
3144  }
3145 
3146  $tpl = new ilTemplate("tpl.exc_select_resource.html", true, true, "Modules/Exercise");
3147  $tpl->setVariable("TXT_TITLE", $this->lng->txt("exc_select_blog").": ".$this->ass->getTitle());
3148  $tpl->setVariable("TREE", $this->renderWorkspaceExplorer("selectBlog"));
3149  $tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
3150  $tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
3151  $tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
3152  $tpl->setVariable("CMD_SUBMIT", "setSelectedBlog");
3153  $tpl->setVariable("CMD_CANCEL", "showOverview");
3154 
3155  ilUtil::sendInfo($this->lng->txt("exc_select_blog_info"));
3156 
3157  $this->tpl->setContent($tpl->get());
3158  }
3159 
3160  protected function saveBlogObject()
3161  {
3162  global $ilUser;
3163 
3164  if(!$_POST["node"])
3165  {
3166  ilUtil::sendFailure($this->lng->txt("select_one"));
3167  return $this->createBlogObject();
3168  }
3169 
3170  $parent_node = $_POST["node"];
3171 
3172  include_once "Modules/Blog/classes/class.ilObjBlog.php";
3173  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
3174  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
3175 
3176  $blog = new ilObjBlog();
3177  $blog->setTitle($this->object->getTitle()." - ".$this->ass->getTitle());
3178  $blog->create();
3179 
3180  $tree = new ilWorkspaceTree($ilUser->getId());
3181 
3182  $node_id = $tree->insertObject($parent_node, $blog->getId());
3183 
3184  $access_handler = new ilWorkspaceAccessHandler($tree);
3185  $access_handler->setPermissions($parent_node, $node_id);
3186 
3187  $this->object->addResourceObject($node_id, $this->ass->getId(), $ilUser->getId());
3188 
3189  ilUtil::sendSuccess($this->lng->txt("exc_blog_created"), true);
3190  $this->ctrl->redirect($this, "showOverview");
3191  }
3192 
3193  protected function setSelectedBlogObject()
3194  {
3195  global $ilUser;
3196 
3197  if($_POST["node"])
3198  {
3199  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
3200  $tree = new ilWorkspaceTree($ilUser->getId());
3201  $node = $tree->getNodeData($_POST["node"]);
3202  if($node && $node["type"] == "blog")
3203  {
3204  $this->removeExistingSubmissions();
3205  $this->object->addResourceObject($node["wsp_id"], $this->ass->getId(), $ilUser->getId());
3206 
3207  ilUtil::sendSuccess($this->lng->txt("exc_blog_selected"), true);
3208  $this->ctrl->setParameter($this, "blog_id", $node["wsp_id"]);
3209  $this->ctrl->redirect($this, "askDirectionSubmission");
3210  }
3211  }
3212 
3213  ilUtil::sendFailure($this->lng->txt("select_one"));
3214  return $this->selectPortfolioObject();
3215  }
3216 
3220  public function removeExistingSubmissions()
3221  {
3222  global $ilUser;
3223 
3224  $submitted = ilExAssignment::getDeliveredFiles($this->ass->getExerciseId(), $this->ass->getId(), $ilUser->getId());
3225  if($submitted)
3226  {
3227  $files = array();
3228  foreach($submitted as $item)
3229  {
3230  $files[] = $item["returned_id"];
3231  }
3232  ilExAssignment::deleteDeliveredFiles($this->ass->getExerciseId(), $this->ass->getId(), $files, $ilUser->getId());
3233  }
3234  }
3235 
3236  protected function askDirectionSubmissionObject()
3237  {
3238  global $tpl;
3239 
3240  $this->tabs_gui->setTabActive("content");
3241  $this->addContentSubTabs("content");
3242 
3243  include_once "Services/Utilities/classes/class.ilConfirmationGUI.php";
3244  $conf = new ilConfirmationGUI();
3245 
3246 
3247  if($_REQUEST["blog_id"])
3248  {
3249  $this->ctrl->setParameter($this, "blog_id", $_REQUEST["blog_id"]);
3250  $txt = $this->lng->txt("exc_direct_submit_blog");
3251  }
3252  else
3253  {
3254  $this->ctrl->setParameter($this, "prtf_id", $_REQUEST["prtf_id"]);
3255  $txt = $this->lng->txt("exc_direct_submit_portfolio");
3256  }
3257  $conf->setFormAction($this->ctrl->getFormAction($this, "directSubmit"));
3258 
3259  $conf->setHeaderText($txt);
3260  $conf->setConfirm($this->lng->txt("exc_direct_submit"), "directSubmit");
3261  $conf->setCancel($this->lng->txt("cancel"), "showOverview");
3262 
3263  $tpl->setContent($conf->getHTML());
3264  }
3265 
3266  protected function directSubmitObject()
3267  {
3268  global $ilUser;
3269 
3270  $success = false;
3271 
3272  // submit current version of blog
3273  if($_REQUEST["blog_id"])
3274  {
3275  $success = $this->submitBlog($_REQUEST["blog_id"]);
3276  $this->ctrl->setParameter($this, "blog_id", "");
3277  }
3278  // submit current version of portfolio
3279  else if($_REQUEST["prtf_id"])
3280  {
3281  $success = $this->submitPortfolio($_REQUEST["prtf_id"]);
3282  $this->ctrl->setParameter($this, "prtf_id", "");
3283  }
3284 
3285  if($success)
3286  {
3287  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
3288  }
3289  else
3290  {
3291  ilUtil::sendFailure($this->lng->txt("msg_failed"), true);
3292  }
3293  $this->ctrl->redirect($this, "showOverview");
3294  }
3295 
3302  function submitBlog($a_blog_id)
3303  {
3304  global $ilUser;
3305 
3306  if($this->object && $this->ass)
3307  {
3308  $blog_id = $a_blog_id;
3309 
3310  include_once "Modules/Blog/classes/class.ilObjBlogGUI.php";
3311  $blog_gui = new ilObjBlogGUI($blog_id, ilObjBlogGUI::WORKSPACE_NODE_ID);
3312  if($blog_gui->object)
3313  {
3314  $file = $blog_gui->buildExportFile();
3315  $size = filesize($file);
3316  if($size)
3317  {
3318  $this->removeExistingSubmissions();
3319 
3320  $meta = array(
3321  "name" => $blog_id,
3322  "tmp_name" => $file,
3323  "size" => $size
3324  );
3325  $this->object->deliverFile($meta, $this->ass->getId(), $ilUser->getId(), true);
3326 
3327  $this->sendNotifications($this->ass->getId());
3328  $this->object->handleSubmission($this->ass->getId());
3329  return true;
3330  }
3331  }
3332  }
3333  return false;
3334  }
3335 
3342  function submitPortfolio($a_portfolio_id)
3343  {
3344  global $ilUser;
3345 
3346  if($this->object && $this->ass)
3347  {
3348  $prtf_id = $a_portfolio_id;
3349 
3350  include_once "Modules/Portfolio/classes/class.ilObjPortfolio.php";
3351  $prtf = new ilObjPortfolio($prtf_id, false);
3352  if($prtf->getTitle())
3353  {
3354  include_once "Modules/Portfolio/classes/class.ilPortfolioHTMLExport.php";
3355  $export = new ilPortfolioHTMLExport(null, $prtf);
3356  $file = $export->buildExportFile();
3357  $size = filesize($file);
3358  if($size)
3359  {
3360  $this->removeExistingSubmissions();
3361 
3362  $meta = array(
3363  "name" => $prtf_id,
3364  "tmp_name" => $file,
3365  "size" => $size
3366  );
3367  $this->object->deliverFile($meta, $this->ass->getId(), $ilUser->getId(), true);
3368 
3369  $this->sendNotifications($this->ass->getId());
3370  $this->object->handleSubmission($this->ass->getId());
3371  return true;
3372  }
3373  }
3374  }
3375  return false;
3376  }
3377 
3378  protected function selectPortfolioObject()
3379  {
3380  global $ilUser;
3381 
3382  $this->checkPermission("read");
3383 
3384  $this->tabs_gui->clearTargets();
3385  $this->tabs_gui->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTarget($this, "showOverview"));
3386 
3387  // $this->tabs_gui->setTabActive("content");
3388  // $this->addContentSubTabs("content");
3389 
3390  if (mktime() > $this->ass->getDeadline() && ($this->ass->getDeadline() != 0))
3391  {
3392  ilUtil::sendInfo($this->lng->txt("exercise_time_over"));
3393  }
3394 
3395  $tpl = new ilTemplate("tpl.exc_select_resource.html", true, true, "Modules/Exercise");
3396 
3397  include_once "Modules/Portfolio/classes/class.ilObjPortfolio.php";
3398  $portfolios = ilObjPortfolio::getPortfoliosOfUser($ilUser->getId());
3399  if($portfolios)
3400  {
3401  $tpl->setCurrentBlock("item");
3402  foreach($portfolios as $portfolio)
3403  {
3404  $tpl->setVariable("ITEM_ID", $portfolio["id"]);
3405  $tpl->setVariable("ITEM_TITLE", $portfolio["title"]);
3406  $tpl->parseCurrentBlock();
3407  }
3408  }
3409 
3410  $tpl->setVariable("TXT_TITLE", $this->lng->txt("exc_select_portfolio").": ".$this->ass->getTitle());
3411  $tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
3412  $tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
3413  $tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
3414  $tpl->setVariable("CMD_SUBMIT", "setSelectedPortfolio");
3415  $tpl->setVariable("CMD_CANCEL", "showOverview");
3416 
3417  ilUtil::sendInfo($this->lng->txt("exc_select_portfolio_info"));
3418 
3419  $this->tpl->setContent($tpl->get());
3420  }
3421 
3422  protected function initPortfolioTemplateForm(array $a_templates)
3423  {
3424  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
3425  $form = new ilPropertyFormGUI();
3426  $form->setTitle($this->lng->txt("exc_create_portfolio").": ".$this->ass->getTitle());
3427  $form->setFormAction($this->ctrl->getFormAction($this, "setSelectedPortfolioTemplate"));
3428 
3429  $prtt = new ilRadioGroupInputGUI($this->lng->txt("obj_prtt"), "prtt");
3430  $prtt->setRequired(true);
3431  $prtt->addOption(new ilRadioOption($this->lng->txt("exc_create_portfolio_no_template"), -1));
3432  foreach($a_templates as $id => $title)
3433  {
3434  $prtt->addOption(new ilRadioOption('"'.$title.'"', $id));
3435  }
3436  $prtt->setValue(-1);
3437  $form->addItem($prtt);
3438 
3439  $form->addCommandButton("setSelectedPortfolioTemplate", $this->lng->txt("save"));
3440  $form->addCommandButton("showOverview", $this->lng->txt("cancel"));
3441 
3442  return $form;
3443  }
3444 
3445  protected function createPortfolioTemplateObject(ilPropertyFormGUI $a_form = null)
3446  {
3447  $this->checkPermission("read");
3448 
3449  include_once "Modules/Portfolio/classes/class.ilObjPortfolioTemplate.php";
3451  if(!sizeof($templates))
3452  {
3453  $this->ctrl->redirect($this, "showOverview");
3454  }
3455 
3456  $this->tabs_gui->clearTargets();
3457  $this->tabs_gui->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTarget($this, "showOverview"));
3458 
3459  if(!$a_form)
3460  {
3461  $a_form = $this->initPortfolioTemplateForm($templates);
3462  }
3463 
3464  $this->tpl->setContent($a_form->getHTML());
3465  }
3466 
3468  {
3469  $this->checkPermission("read");
3470 
3471  include_once "Modules/Portfolio/classes/class.ilObjPortfolioTemplate.php";
3473  if(!sizeof($templates))
3474  {
3475  $this->ctrl->redirect($this, "showOverview");
3476  }
3477 
3478  $form = $this->initPortfolioTemplateForm($templates);
3479  if($form->checkInput())
3480  {
3481  $prtt = $form->getInput("prtt");
3482  if($prtt > 0 && array_key_exists($prtt, $templates))
3483  {
3484  $title = $this->object->getTitle()." - ".$this->ass->getTitle();
3485  $this->ctrl->setParameterByClass("ilObjPortfolioGUI", "exc_id", $this->object->getRefId());
3486  $this->ctrl->setParameterByClass("ilObjPortfolioGUI", "ass_id", $this->ass->getId());
3487  $this->ctrl->setParameterByClass("ilObjPortfolioGUI", "pt", $title);
3488  $this->ctrl->setParameterByClass("ilObjPortfolioGUI", "prtt", $prtt);
3489  $this->ctrl->redirectByClass(array("ilPersonalDesktopGUI", "ilPortfolioRepositoryGUI", "ilObjPortfolioGUI"), "createPortfolioFromTemplate");
3490  }
3491  else
3492  {
3493  // do not use template
3494  return $this->createPortfolioObject();
3495  }
3496  }
3497 
3498  $form->setValuesByPost();
3499  $this->createPortfolioTemplateObject($form);
3500  }
3501 
3502  protected function createPortfolioObject()
3503  {
3504  global $ilUser;
3505 
3506  $this->checkPermission("read");
3507 
3508  include_once "Modules/Portfolio/classes/class.ilObjPortfolio.php";
3509  $portfolio = new ilObjPortfolio();
3510  $portfolio->setTitle($this->object->getTitle()." - ".$this->ass->getTitle());
3511  $portfolio->create();
3512 
3513  $this->object->addResourceObject($portfolio->getId(), $this->ass->getId(), $ilUser->getId());
3514 
3515  ilUtil::sendSuccess($this->lng->txt("exc_portfolio_created"), true);
3516  $this->ctrl->redirect($this, "showOverview");
3517  }
3518 
3519  protected function setSelectedPortfolioObject()
3520  {
3521  global $ilUser;
3522 
3523  if($_POST["item"])
3524  {
3525  $this->removeExistingSubmissions();
3526  $this->object->addResourceObject($_POST["item"], $this->ass->getId(), $ilUser->getId());
3527 
3528  ilUtil::sendSuccess($this->lng->txt("exc_portfolio_selected"), true);
3529  $this->ctrl->setParameter($this, "prtf_id", $_POST["item"]);
3530  $this->ctrl->redirect($this, "askDirectionSubmission");
3531  }
3532 
3533  ilUtil::sendFailure($this->lng->txt("select_one"));
3534  return $this->selectPortfolioObject();
3535  }
3536 
3537  protected function renderWorkspaceExplorer($a_cmd)
3538  {
3539  global $ilUser;
3540 
3541  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
3542  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
3543  require_once 'Services/PersonalWorkspace/classes/class.ilWorkspaceExplorer.php';
3544 
3545  $tree = new ilWorkspaceTree($ilUser->getId());
3546  $access_handler = new ilWorkspaceAccessHandler($tree);
3548  'exc_wspexpand', $tree, $access_handler);
3549  $exp->setTargetGet('wsp_id');
3550 
3551  if($a_cmd == "selectBlog")
3552  {
3553  $exp->removeAllFormItemTypes();
3554  $exp->addFilter('blog');
3555  $exp->addFormItemForType('blog');
3556  }
3557 
3558  if($_GET['exc_wspexpand'] == '')
3559  {
3560  // not really used as session is already set [see above]
3561  $expanded = $tree->readRootId();
3562  }
3563  else
3564  {
3565  $expanded = $_GET['exc_wspexpand'];
3566  }
3567 
3568  $exp->setExpandTarget($this->ctrl->getLinkTarget($this, $a_cmd));
3569  $exp->setPostVar('node');
3570  $exp->setExpand($expanded);
3571  $exp->setOutput(0);
3572 
3573  return $exp->getOutput();
3574  }
3575 
3577  {
3578  $this->setSettingsSubTabs();
3579  $this->tabs_gui->activateTab("settings");
3580  $this->tabs_gui->activateSubTab("certificate");
3581 
3582  include_once "./Services/Certificate/classes/class.ilCertificateGUI.php";
3583  include_once "./Modules/Exercise/classes/class.ilExerciseCertificateAdapter.php";
3584  $output_gui = new ilCertificateGUI(new ilExerciseCertificateAdapter($this->object));
3585  $output_gui->certificateEditor();
3586  }
3587 
3589  {
3590  global $ilUser;
3591 
3592  if($this->object->hasUserCertificate($ilUser->getId()))
3593  {
3594  ilUtil::sendFailure($this->lng->txt("msg_failed"));
3595  $this->showOverviewObject();
3596  }
3597 
3598  include_once "./Services/Certificate/classes/class.ilCertificate.php";
3599  include_once "./Modules/Exercise/classes/class.ilExerciseCertificateAdapter.php";
3600  $certificate = new ilCertificate(new ilExerciseCertificateAdapter($this->object));
3601  $certificate->outCertificate(array("user_id" => $ilUser->getId()));
3602  }
3603 
3604  protected function initTeamSubmission($a_back_cmd, $a_mandatory_team = true)
3605  {
3606  global $ilUser, $ilHelp;
3607 
3608  $this->checkPermission("read");
3609 
3610  if($a_mandatory_team && $this->ass->getType() != ilExAssignment::TYPE_UPLOAD_TEAM)
3611  {
3612  $this->ctrl->redirect($this, "submissionScreen");
3613  }
3614 
3615  $this->tabs_gui->clearTargets();
3616  $ilHelp->setScreenIdComponent("exc");
3617  $this->tabs_gui->setBackTarget($this->lng->txt("back"),
3618  $this->ctrl->getLinkTarget($this, $a_back_cmd));
3619 
3620  if($this->ass->getType() == ilExAssignment::TYPE_UPLOAD_TEAM)
3621  {
3622  $this->tabs_gui->addTab("submissions", $this->lng->txt("files"),
3623  $this->ctrl->getLinkTarget($this, "submissionScreen"));
3624 
3625  $this->tabs_gui->addTab("team", $this->lng->txt("exc_team"),
3626  $this->ctrl->getLinkTarget($this, "submissionScreenTeam"));
3627 
3628  $this->tabs_gui->addTab("log", $this->lng->txt("exc_team_log"),
3629  $this->ctrl->getLinkTarget($this, "submissionScreenTeamLog"));
3630 
3631  $this->tabs_gui->activateTab("team");
3632 
3633  $team_id = $this->ass->getTeamId($ilUser->getId());
3634 
3635  if(!$team_id)
3636  {
3637  $team_id = $this->ass->getTeamId($ilUser->getId(), true);
3638 
3639  // #12337
3640  if (!$this->object->members_obj->isAssigned($ilUser->getId()))
3641  {
3642  $this->object->members_obj->assignMember($ilUser->getId());
3643  }
3644  }
3645 
3646  return $team_id;
3647  }
3648  else
3649  {
3650  $ilHelp->setScreenId("submissions");
3651  }
3652  }
3653 
3660  {
3661  global $ilToolbar;
3662 
3663  $team_id = $this->initTeamSubmission("showOverview");
3664 
3665  // $this->tabs_gui->setTabActive("content");
3666  // $this->addContentSubTabs("content");
3667 
3668  // #13414
3669  $read_only = (mktime() > $this->ass->getDeadline() && ($this->ass->getDeadline() != 0));
3670 
3671  if ($read_only)
3672  {
3673  ilUtil::sendInfo($this->lng->txt("exercise_time_over"));
3674  }
3675  else
3676  {
3677  $this->ctrl->setParameterByClass('ilRepositorySearchGUI', 'ctx', 1);
3678  $this->ctrl->setParameter($this, 'ctx', 1);
3679 
3680  // add member
3681  include_once './Services/Search/classes/class.ilRepositorySearchGUI.php';
3683  $this,
3684  $ilToolbar,
3685  array(
3686  'auto_complete_name' => $this->lng->txt('user'),
3687  'submit_name' => $this->lng->txt('add'),
3688  'add_search' => true,
3689  'add_from_container' => $this->object->getRefId()
3690  )
3691  );
3692  }
3693 
3694  include_once "Modules/Exercise/classes/class.ilExAssignmentTeamTableGUI.php";
3695  $tbl = new ilExAssignmentTeamTableGUI($this, "submissionScreenTeam",
3696  ilExAssignmentTeamTableGUI::MODE_EDIT, $team_id, $this->ass, null, $read_only);
3697 
3698  $this->tpl->setContent($tbl->getHTML());
3699  }
3700 
3701  public function addTeamMemberActionObject($a_user_ids = array())
3702  {
3703  global $ilUser;
3704 
3705  $this->checkPermission("read");
3706 
3707  if(!count($a_user_ids))
3708  {
3709  ilUtil::sendFailure($this->lng->txt("no_checkbox"));
3710  return false;
3711  }
3712 
3713  $team_id = $this->ass->getTeamId($ilUser->getId());
3714  $has_files = $this->ass->getDeliveredFiles($this->object->getId(),
3715  $this->ass->getId(),
3716  $ilUser->getId());
3717  $all_members = $this->ass->getMembersOfAllTeams();
3718  $members = $this->ass->getTeamMembers($team_id);
3719 
3720  foreach($a_user_ids as $user_id)
3721  {
3722  if(!in_array($user_id, $all_members))
3723  {
3724  $this->ass->addTeamMember($team_id, $user_id, $this->ref_id);
3725 
3726  // #14277
3727  if (!$this->object->members_obj->isAssigned($user_id))
3728  {
3729  $this->object->members_obj->assignMember($user_id);
3730  }
3731 
3732  // see ilObjExercise::deliverFile()
3733  if($has_files)
3734  {
3735  ilExAssignment::updateStatusReturnedForUser($this->ass->getId(), $user_id, 1);
3736  ilExerciseMembers::_writeReturned($this->object->getId(), $user_id, 1);
3737  }
3738 
3739  // :TODO: log, notification
3740  }
3741  else if(!in_array($user_id, $members))
3742  {
3743  ilUtil::sendFailure($this->lng->txt("exc_members_already_assigned"), true);
3744  }
3745  }
3746 
3747  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
3748  $this->ctrl->redirect($this, "submissionScreenTeam");
3749  }
3750 
3751  public function confirmDeleteTeamObject()
3752  {
3753  $this->confirmRemoveTeamMemberObject(true);
3754  }
3755 
3756  public function confirmRemoveTeamMemberObject($a_full_delete = false)
3757  {
3758  global $ilUser, $tpl;
3759 
3760  $team_id = $this->ass->getTeamId($ilUser->getId());
3761  $members = $this->ass->getTeamMembers($team_id);
3762 
3763  $ids = (bool)$a_full_delete
3764  ? $members
3765  : $_POST["id"];
3766 
3767  if(!sizeof($ids))
3768  {
3769  ilUtil::sendFailure($this->lng->txt("select_one"), true);
3770  $this->ctrl->redirect($this, "submissionScreenTeam");
3771  }
3772 
3773  $team_deleted = false;
3774  if(sizeof($members) <= sizeof($ids))
3775  {
3776  if(sizeof($members) == 1 && $members[0] == $ilUser->getId())
3777  {
3778  // direct team deletion - no confirmation
3779  return $this->removeTeamMemberObject($a_full_delete);
3780  }
3781  else
3782  {
3783  ilUtil::sendFailure($this->lng->txt("exc_team_at_least_one"), true);
3784  $this->ctrl->redirect($this, "submissionScreenTeam");
3785  }
3786  }
3787 
3788  // #11957
3789  $team_id = $this->initTeamSubmission("showOverview");
3790 
3791  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
3792  $cgui = new ilConfirmationGUI();
3793  $cgui->setFormAction($this->ctrl->getFormAction($this));
3794  $cgui->setHeaderText($this->lng->txt("exc_team_member_remove_sure"));
3795  $cgui->setCancel($this->lng->txt("cancel"), "submissionScreenTeam");
3796  $cgui->setConfirm($this->lng->txt("remove"), "removeTeamMember");
3797 
3798  $files = ilExAssignment::getDeliveredFiles($this->ass->getExerciseId(),
3799  $this->ass->getId(), $ilUser->getId());
3800 
3801  include_once "Services/User/classes/class.ilUserUtil.php";
3802 
3803  foreach($ids as $id)
3804  {
3805  $details = array();
3806  foreach ($files as $file)
3807  {
3808  if($file["owner_id"] == $id)
3809  {
3810  $details[] = $file["filetitle"];
3811  }
3812  }
3813  $uname = ilUserUtil::getNamePresentation($id);
3814  if(sizeof($details))
3815  {
3816  $uname .= ": ".implode(", ", $details);
3817  }
3818  $cgui->addItem("id[]", $id, $uname);
3819  }
3820 
3821  $tpl->setContent($cgui->getHTML());
3822  }
3823  public function removeTeamMemberObject($a_full_delete = false)
3824  {
3825  global $ilUser;
3826 
3827  $team_id = $this->ass->getTeamId($ilUser->getId());
3828  $members = $this->ass->getTeamMembers($team_id);
3829 
3830  $ids = (bool)$a_full_delete
3831  ? $members
3832  : $_POST["id"];
3833 
3834  if(!sizeof($ids))
3835  {
3836  ilUtil::sendFailure($this->lng->txt("select_one"), true);
3837  $this->ctrl->redirect($this, "submissionScreenTeam");
3838  }
3839 
3840  $team_deleted = (bool)$a_full_delete;
3841  if(!$team_deleted)
3842  {
3843  if(sizeof($members) <= sizeof($ids))
3844  {
3845  if(sizeof($members) == 1 && $members[0] == $ilUser->getId())
3846  {
3847  $team_deleted = true;
3848  }
3849  else
3850  {
3851  ilUtil::sendFailure($this->lng->txt("exc_team_at_least_one"), true);
3852  $this->ctrl->redirect($this, "submissionScreenTeam");
3853  }
3854  }
3855  }
3856 
3857  foreach($ids as $user_id)
3858  {
3859  $this->ass->removeTeamMember($team_id, $user_id, $this->ref_id);
3860 
3861  ilExAssignment::updateStatusReturnedForUser($this->ass->getId(), $user_id, 0);
3862  ilExerciseMembers::_writeReturned($this->object->getId(), $user_id, 0);
3863 
3864  // :TODO: log, notification
3865  }
3866 
3867  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
3868 
3869  if(!$team_deleted)
3870  {
3871  $this->ctrl->redirect($this, "submissionScreenTeam");
3872  }
3873  else
3874  {
3875  $this->ctrl->redirect($this, "showOverview");
3876  }
3877  }
3878 
3880  {
3881  $team_id = $this->initTeamSubmission("showOverview");
3882  $this->tabs_gui->activateTab("log");
3883 
3884  include_once "Modules/Exercise/classes/class.ilExAssignmentTeamLogTableGUI.php";
3885  $tbl = new ilExAssignmentTeamLogTableGUI($this, "submissionScreenTeamLog",
3886  $team_id);
3887 
3888  $this->tpl->setContent($tbl->getHTML());
3889  }
3890 
3892  {
3893  if(isset($_GET["lmem"]))
3894  {
3895  $user_id = $_GET["lmem"];
3896  $cmd = "members";
3897  }
3898  else
3899  {
3900  $user_id = $_GET["lpart"];
3901  $cmd = "showParticipant";
3902  }
3903  if($user_id)
3904  {
3905  $this->ass->getTeamId($user_id, true);
3906  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
3907  }
3908  $this->ctrl->redirect($this, $cmd);
3909  }
3910 
3912  {
3913  $this->checkPermission("write");
3914  $this->tabs_gui->activateTab("grades");
3915 
3916  if(isset($_GET["lmem"]))
3917  {
3918  $this->addSubmissionSubTabs("assignment");
3919 
3920  $this->tabs_gui->setBackTarget($this->lng->txt("back"),
3921  $this->ctrl->getLinkTarget($this, "members"));
3922 
3923  $team_id = ilExAssignment::getTeamIdByAssignment($this->ass->getId(), (int)$_GET["lmem"]);
3924 
3925  $this->ctrl->saveParameter($this, "lmem");
3926  }
3927  else
3928  {
3929  $this->addSubmissionSubTabs("participant");
3930 
3931  $this->tabs_gui->setBackTarget($this->lng->txt("back"),
3932  $this->ctrl->getLinkTarget($this, "showParticipant"));
3933 
3934  $team_id = ilExAssignment::getTeamIdByAssignment($this->ass->getId(), (int)$_GET["lpart"]);
3935 
3936  $this->ctrl->saveParameter($this, "lpart");
3937  }
3938 
3939  include_once "Modules/Exercise/classes/class.ilExAssignmentTeamLogTableGUI.php";
3940  $tbl = new ilExAssignmentTeamLogTableGUI($this, "showTeamLog",
3941  $team_id);
3942 
3943  $this->tpl->setContent($tbl->getHTML());
3944  }
3945 
3946  protected function initAssignmentTextForm(ilExAssignment $a_ass, $a_read_only = false, $a_cancel_cmd = "showOverview", $a_peer_review_cmd = null, $a_peer_rating_html = null)
3947  {
3948  global $ilCtrl, $ilUser;
3949 
3950  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
3951  $form = new ilPropertyFormGUI();
3952  $form->setTitle($this->lng->txt("exc_assignment")." \"".$a_ass->getTitle()."\"");
3953 
3954  if(!$a_read_only)
3955  {
3956  $text = new ilTextAreaInputGUI($this->lng->txt("exc_your_text"), "atxt");
3957  $text->setRequired((bool)$a_ass->getMandatory());
3958  $text->setRows(40);
3959  $form->addItem($text);
3960 
3961  // custom rte tags
3962  $text->setUseRte(true);
3963  $text->setRTESupport($ilUser->getId(), "exca~", "exc_ass");
3964 
3965  // see ilObjForumGUI
3966  $text->disableButtons(array(
3967  'charmap',
3968  'undo',
3969  'redo',
3970  'justifyleft',
3971  'justifycenter',
3972  'justifyright',
3973  'justifyfull',
3974  'anchor',
3975  'fullscreen',
3976  'cut',
3977  'copy',
3978  'paste',
3979  'pastetext',
3980  // 'formatselect' #13234
3981  ));
3982 
3983  $form->setFormAction($ilCtrl->getFormAction($this, "updateAssignmentText"));
3984  $form->addCommandButton("updateAssignmentTextAndReturn", $this->lng->txt("save_return"));
3985  $form->addCommandButton("updateAssignmentText", $this->lng->txt("save"));
3986  }
3987  else
3988  {
3989  $text = new ilNonEditableValueGUI($this->lng->txt("exc_files_returned_text"), "atxt", true);
3990  $form->addItem($text);
3991 
3992  if(!$a_peer_review_cmd)
3993  {
3994  $form->setFormAction($ilCtrl->getFormAction($this, "showOverview"));
3995  }
3996  else
3997  {
3998  $rating = new ilCustomInputGUI($this->lng->txt("exc_peer_review_rating"));
3999  $rating->setHtml($a_peer_rating_html);
4000  $form->addItem($rating);
4001 
4002  $comm = new ilTextAreaInputGUI($this->lng->txt("exc_peer_review_comment"), "comm");
4003  $comm->setCols(75);
4004  $comm->setRows(15);
4005  $form->addItem($comm);
4006 
4007  $form->setFormAction($ilCtrl->getFormAction($this, $a_peer_review_cmd));
4008  $form->addCommandButton($a_peer_review_cmd, $this->lng->txt("save"));
4009  }
4010  }
4011  $form->addCommandButton($a_cancel_cmd, $this->lng->txt("cancel"));
4012 
4013  return $form;
4014  }
4015 
4017  {
4018  global $ilTabs, $ilCtrl, $ilUser;
4019 
4020  if(!$this->ass ||
4021  $this->ass->getType() != ilExAssignment::TYPE_TEXT ||
4022  ($this->ass->getDeadline() && $this->ass->getDeadline() - time() < 0))
4023  {
4024  $ilCtrl->redirect($this, "showOverview");
4025  }
4026 
4027  $this->checkPermission("read");
4028 
4029  //$ilTabs->activateTab("content");
4030  //$this->addContentSubTabs("content");
4031 
4032  $this->tabs_gui->clearTargets();
4033  $this->tabs_gui->setBackTarget($this->lng->txt("back"),
4034  $this->ctrl->getLinkTarget($this, "showOverview"));
4035 
4036  global $ilHelp;
4037  $ilHelp->setScreenIdComponent("exc");
4038  $ilHelp->setScreenId("text_submission");
4039 
4040  if($this->ass->getDeadline())
4041  {
4042  ilUtil::sendInfo($this->lng->txt("exc_edit_until").": ".
4043  ilDatePresentation::formatDate(new ilDateTime($this->ass->getDeadline(),IL_CAL_UNIX)));
4044  }
4045 
4046  if(!$a_form)
4047  {
4048  $a_form = $this->initAssignmentTextForm($this->ass);
4049 
4050  $files = ilExAssignment::getDeliveredFiles($this->ass->getExerciseId(), $this->ass->getId(), $ilUser->getId());
4051  if($files)
4052  {
4053  $files = array_shift($files);
4054  if(trim($files["atext"]))
4055  {
4056  $text = $a_form->getItemByPostVar("atxt");
4057  // mob id to mob src
4058  $text->setValue(ilRTE::_replaceMediaObjectImageSrc($files["atext"], 1));
4059  }
4060  }
4061  }
4062 
4063  $this->tpl->setContent($a_form->getHTML());
4064  }
4065 
4067  {
4068  $this->updateAssignmentTextObject(true);
4069  }
4070 
4071  function updateAssignmentTextObject($a_return = false)
4072  {
4073  global $ilCtrl, $ilUser;
4074 
4075  $times_up = ($this->ass->getDeadline() && $this->ass->getDeadline() - time() < 0);
4076 
4077  if(!$this->ass ||
4078  $this->ass->getType() != ilExAssignment::TYPE_TEXT ||
4079  $times_up)
4080  {
4081  if($times_up)
4082  {
4083  ilUtil::sendFailure($this->lng->txt("exercise_time_over"), true);
4084  }
4085  $ilCtrl->redirect($this, "showOverview");
4086  }
4087 
4088  $this->checkPermission("read");
4089 
4090  $form = $this->initAssignmentTextForm($this->ass);
4091 
4092  // we are not using a purifier, so we have to set the valid RTE tags
4093  // :TODO:
4094  include_once("./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php");
4095  $rte = $form->getItemByPostVar("atxt");
4096  $rte->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("exc_ass"));
4097 
4098  if($form->checkInput())
4099  {
4100  $text = trim($form->getInput("atxt"));
4101 
4102  $existing = (bool)ilExAssignment::getDeliveredFiles($this->ass->getExerciseId(),
4103  $this->ass->getId(), $ilUser->getId());
4104 
4105  $returned_id = $this->object->updateTextSubmission(
4106  $this->ass->getExerciseId(),
4107  $this->ass->getId(),
4108  $ilUser->getId(),
4109  // mob src to mob id
4111 
4112  // no empty text
4113  if($returned_id)
4114  {
4115  if(!$existing)
4116  {
4117  // #14332 - new text
4118  $this->sendNotifications($this->ass->getId());
4119  $this->object->handleSubmission($this->ass->getId());
4120  }
4121 
4122  // mob usage
4123  include_once "Services/MediaObjects/classes/class.ilObjMediaObject.php";
4124  $mobs = ilRTE::_getMediaObjects($text, 0);
4125  foreach($mobs as $mob)
4126  {
4127  if(ilObjMediaObject::_exists($mob))
4128  {
4129  ilObjMediaObject::_removeUsage($mob, 'exca~:html', $ilUser->getId());
4130  ilObjMediaObject::_saveUsage($mob, 'exca:html', $returned_id);
4131  }
4132  }
4133  }
4134 
4135  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
4136  if($a_return)
4137  {
4138  $ilCtrl->redirect($this, "showOverview");
4139  }
4140  else
4141  {
4142  $ilCtrl->redirect($this, "editAssignmentText");
4143  }
4144  }
4145 
4146  $form->setValuesByPost();
4147  $this->editAssignmentTextObject($form);
4148  }
4149 
4151  {
4152  global $ilCtrl, $ilUser, $lng, $tpl;
4153 
4154  if(!$this->ass ||
4155  $this->ass->getType() != ilExAssignment::TYPE_TEXT)
4156  {
4157  $ilCtrl->redirect($this, "showOverview");
4158  }
4159 
4160  $add_rating = null;
4161 
4162  // tutor
4163  if((int)$_GET["grd"])
4164  {
4165  $this->checkPermission("write");
4166 
4167  if((int)$_GET["grd"] == 1)
4168  {
4169  $user_id = (int)$_GET["member_id"];
4170  $cancel_cmd = "members";
4171  }
4172  else
4173  {
4174  $user_id = (int)$_GET["part_id"];
4175  $cancel_cmd = "showParticipant";
4176  }
4177  }
4178  // peer review
4179  else if($this->ass->hasPeerReviewAccess((int)$_GET["member_id"]))
4180  {
4181  $this->checkPermission("read");
4182 
4183  $user_id = (int)$_GET["member_id"];
4184  $cancel_cmd = "editPeerReview";
4185 
4186  // rating
4187  $add_rating = "updatePeerReviewText";
4188  $ilCtrl->setParameter($this, "peer_id", $user_id);
4189  include_once './Services/Rating/classes/class.ilRatingGUI.php';
4190  $rating = new ilRatingGUI();
4191  $rating->setObject($this->ass->getId(), "ass", $user_id, "peer");
4192  $rating->setUserId($ilUser->getId());
4193  $rating = '<div id="rtr_widget">'.$rating->getHTML(false, true,
4194  "il.ExcPeerReview.saveSingleRating(".$user_id.", %rating%)").'</div>';
4195 
4196  $ilCtrl->setParameter($this, "ssrtg", 1);
4197  $tpl->addJavaScript("Modules/Exercise/js/ilExcPeerReview.js");
4198  $tpl->addOnLoadCode("il.ExcPeerReview.setAjax('".
4199  $ilCtrl->getLinkTarget($this, "updatePeerReviewComments", "", true, false).
4200  "')");
4201  $ilCtrl->setParameter($this, "ssrtg", "");
4202  }
4203  // personal
4204  else
4205  {
4206  $this->checkPermission("read");
4207 
4208  $user_id = $ilUser->getId();
4209  $cancel_cmd = "showOverview";
4210  }
4211 
4212  $this->tabs_gui->clearTargets();
4213  $this->tabs_gui->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTarget($this, $cancel_cmd));
4214 
4215  $a_form = $this->initAssignmentTextForm($this->ass, true, $cancel_cmd, $add_rating, $rating);
4216 
4217  if(($user_id != $ilUser->getId() || (bool)$_GET["grd"]))
4218  {
4219  if(!stristr($cancel_cmd, "peer"))
4220  {
4221  include_once "Services/User/classes/class.ilUserUtil.php";
4222  $a_form->setDescription(ilUserUtil::getNamePresentation($user_id));
4223  }
4224  else
4225  {
4226  if(!$this->ass->hasPeerReviewPersonalized())
4227  {
4228  $a_form->setDescription($lng->txt("id").": ".(int)$_GET["seq"]);
4229  }
4230  else
4231  {
4232  include_once "Services/User/classes/class.ilUserUtil.php";
4233  $a_form->setDescription(ilUserUtil::getNamePresentation($user_id));
4234  }
4235 
4236  foreach($this->ass->getPeerReviewsByPeerId($user_id) as $item)
4237  {
4238  if($item["giver_id"] == $ilUser->getId())
4239  {
4240  $a_form->getItemByPostVar("comm")->setValue($item["pcomment"]);
4241  break;
4242  }
4243  }
4244  }
4245  }
4246 
4247  $files = ilExAssignment::getDeliveredFiles($this->ass->getExerciseId(), $this->ass->getId(), $user_id);
4248  if($files)
4249  {
4250  $files = array_shift($files);
4251  if(trim($files["atext"]))
4252  {
4253  $text = $a_form->getItemByPostVar("atxt");
4254  // mob id to mob src
4255  $text->setValue(ilRTE::_replaceMediaObjectImageSrc($files["atext"], 1));
4256  }
4257  }
4258 
4259  $this->tpl->setContent($a_form->getHTML());
4260  }
4261 
4263  {
4264  $this->listTextAssignmentObject(true);
4265  }
4266 
4267  function listTextAssignmentObject($a_show_peer_review = false)
4268  {
4269  global $tpl, $ilToolbar, $ilCtrl, $ilTabs, $lng;
4270 
4271  $this->checkPermission("write");
4272 
4273  if(!$this->ass || $this->ass->getType() != ilExAssignment::TYPE_TEXT)
4274  {
4275  $ilCtrl->redirect($this, "member");
4276  }
4277 
4278  $ilTabs->clearTargets();
4279  $ilTabs->setBackTarget($lng->txt("back"),
4280  $ilCtrl->getLinkTarget($this, "members"));
4281 
4282  if($a_show_peer_review)
4283  {
4284  $cmd = "listTextAssignmentWithPeerReview";
4285  }
4286  else
4287  {
4288  $cmd = "listTextAssignment";
4289  }
4290  include_once "Modules/Exercise/classes/class.ilExAssignmentListTextTableGUI.php";
4291  $tbl = new ilExAssignmentListTextTableGUI($this, $cmd, $this->ass, $a_show_peer_review);
4292  $tpl->setContent($tbl->getHTML());
4293  }
4294 
4295  protected function canPeerReviewBeEdited()
4296  {
4297  // #16130
4298  return ($this->ass &&
4299  $this->ass->getPeerReview() &&
4300  $this->ass->getDeadline() &&
4301  $this->ass->getDeadline() < time() &&
4302  (!$this->ass->getPeerReviewDeadline() ||
4303  $this->ass->getPeerReviewDeadline() > time()));
4304  }
4305 
4307  {
4308  global $ilCtrl, $ilUser, $tpl;
4309 
4310  if(!$this->canPeerReviewBeEdited())
4311  {
4312  $ilCtrl->redirect($this, "showOverview");
4313  }
4314 
4315  $this->checkPermission("read");
4316 
4317  $this->tabs_gui->clearTargets();
4318  $this->tabs_gui->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTarget($this, "showOverview"));
4319 
4320  $peer_items = $this->ass->getPeerReviewsByGiver($ilUser->getId());
4321  if(!sizeof($peer_items))
4322  {
4323  ilUtil::sendFailure($this->lng->txt("exc_peer_review_no_peers"), true);
4324  $ilCtrl->redirect($this, "showOverview");
4325  }
4326 
4327  $missing = ilExAssignment::getNumberOfMissingFeedbacks($this->ass->getId(), $this->ass->getPeerReviewMin());
4328  if($missing)
4329  {
4330  $dl = $this->ass->getPeerReviewDeadline();
4331  if(!$dl || $dl < time())
4332  {
4333  ilUtil::sendInfo(sprintf($this->lng->txt("exc_peer_review_missing_info"), $missing));
4334  }
4335  else
4336  {
4337  ilUtil::sendInfo(sprintf($this->lng->txt("exc_peer_review_missing_info_deadline"), $missing,
4339  }
4340  }
4341 
4342  $tpl->addJavaScript("Modules/Exercise/js/ilExcPeerReview.js");
4343  $tpl->addOnLoadCode("il.ExcPeerReview.setAjax('".
4344  $ilCtrl->getLinkTarget($this, "updatePeerReviewComments", "", true, false).
4345  "')");
4346 
4347  include_once "Modules/Exercise/classes/class.ilExAssignmentPeerReviewTableGUI.php";
4348  $tbl = new ilExAssignmentPeerReviewTableGUI($this, "editPeerReview", $this->ass, $ilUser->getId(), $peer_items, "exc_peer_review_give", "showOverview");
4349 
4350  $tpl->setContent($tbl->getHTML());
4351  }
4352 
4354  {
4355  global $ilUser, $ilCtrl;
4356 
4357  if(!$this->canPeerReviewBeEdited() ||
4358  !sizeof($_POST["pc"]))
4359  {
4360  $ilCtrl->redirect($this, "showOverview");
4361  }
4362 
4363  $this->checkPermission("read");
4364 
4365  $peer_items = $this->ass->getPeerReviewsByGiver($ilUser->getId());
4366  if(!sizeof($peer_items))
4367  {
4368  ilUtil::sendFailure($this->lng->txt("exc_peer_review_no_peers"), true);
4369  $ilCtrl->redirect($this, "showOverview");
4370  }
4371 
4372  foreach($_POST["pc"] as $idx => $value)
4373  {
4374  $parts = explode("__", $idx);
4375  if($parts[0] == $ilUser->getId())
4376  {
4377  $this->ass->updatePeerReviewComment($parts[1], ilUtil::stripSlashes($value)); // #16128
4378  }
4379  }
4380 
4381  ilUtil::sendInfo($this->lng->txt("exc_peer_review_updated"), true);
4382  $ilCtrl->redirect($this, "editPeerReview");
4383  }
4384 
4386  {
4387  global $ilCtrl, $ilUser, $tpl;
4388 
4389  if(!$this->canPeerReviewBeEdited() ||
4390  !sizeof($_POST["pc"]) ||
4391  !$ilCtrl->isAsynch())
4392  {
4393  exit();
4394  }
4395 
4396  $rating_peer_id = $_POST["rating_peer_id"];
4397  $giver_id = $ilUser->getId();
4398 
4399  // save rating
4400  include_once './Services/Rating/classes/class.ilRating.php';
4401  ilRating::writeRatingForUserAndObject($this->ass->getId(), "ass",
4402  $rating_peer_id, "peer", $giver_id, $_POST["rating"]);
4403 
4404  // save comments
4405  foreach($_POST["pc"] as $peer_id => $value)
4406  {
4407  if($peer_id)
4408  {
4409  $this->ass->updatePeerReviewComment($peer_id, ilUtil::stripSlashes($value)); // #16128
4410  }
4411  }
4412 
4413 
4414  // render current rating
4415 
4416  $ilCtrl->setParameter($this->parent_obj, "peer_id", $rating_peer_id);
4417 
4418  include_once './Services/Rating/classes/class.ilRatingGUI.php';
4419  $rating = new ilRatingGUI();
4420  $rating->setObject($this->ass->getId(), "ass", $rating_peer_id, "peer");
4421  $rating->setUserId($giver_id);
4422 
4423  if(!$_REQUEST["ssrtg"])
4424  {
4425  echo $rating->getHTML(false, true,
4426  "il.ExcPeerReview.saveComments(".$rating_peer_id.", %rating%)");
4427  }
4428  else
4429  {
4430  echo '<div id="rtr_widget">'.$rating->getHTML(false, true,
4431  "il.ExcPeerReview.saveSingleRating(".$rating_peer_id.", %rating%)").'</div>';
4432  }
4433 
4434  echo $tpl->getOnLoadCodeForAsynch();
4435  exit();
4436  }
4437 
4439  {
4440  global $ilCtrl;
4441 
4442  if(!$this->canPeerReviewBeEdited() ||
4443  !(int)$_REQUEST["peer_id"])
4444  {
4445  $ilCtrl->redirect($this, "editPeerReview");
4446  }
4447 
4448  $this->ass->updatePeerReviewComment((int)$_REQUEST["peer_id"], ilUtil::stripSlashes(trim($_POST["comm"]))); // #16128
4449 
4450  ilUtil::sendInfo($this->lng->txt("exc_peer_review_updated"), true);
4451  $ilCtrl->redirect($this, "editPeerReview");
4452  }
4453 
4455  {
4456  global $ilCtrl, $ilUser;
4457 
4458  if(!$this->ass ||
4459  !$this->ass->getPeerReview() ||
4460  !$this->ass->hasPeerReviewFileUpload() ||
4461  !$_GET["fu"] ||
4462  !$_GET["fuf"])
4463  {
4464  $ilCtrl->redirect($this, "showOverview");
4465  }
4466 
4467  $parts = explode("__", $_GET["fu"]);
4468  $giver_id = $parts[0];
4469  $peer_id = $parts[1];
4470 
4471  if($giver_id == $ilUser->getId() ||
4472  $peer_id == $ilUser->getId())
4473  {
4474  $this->checkPermission("read");
4475  }
4476  else
4477  {
4478  $this->checkPermission("write");
4479  }
4480 
4481  $peer_items = $this->ass->getPeerReviewsByPeerId($peer_id, true);
4482  if(sizeof($peer_items))
4483  {
4484  foreach($peer_items as $item)
4485  {
4486  if($item["giver_id"] == $giver_id)
4487  {
4488  $files = $this->ass->getPeerUploadFiles($peer_id, $giver_id);
4489  foreach($files as $file)
4490  {
4491  if(md5($file) == trim($_GET["fuf"]))
4492  {
4493  ilUtil::deliverFile($file, basename($file));
4494  break(2);
4495  }
4496  }
4497  }
4498  }
4499  }
4500 
4501  $ilCtrl->redirect($this, "showOverview");
4502  }
4503 
4505  {
4506  global $ilCtrl, $ilUser, $tpl;
4507 
4508  if(!$this->ass ||
4509  !$this->ass->getPeerReview() ||
4510  !$this->ass->getDeadline() ||
4511  $this->ass->getDeadline()-time() > 0)
4512  {
4513  $ilCtrl->redirect($this, "showOverview");
4514  }
4515 
4516  // tutor
4517  if((int)$_GET["grd"])
4518  {
4519  $this->checkPermission("write");
4520 
4521  if((int)$_GET["grd"] == 1)
4522  {
4523  $user_id = (int)$_GET["member_id"];
4524  $cancel_cmd = "members";
4525  }
4526  else
4527  {
4528  $user_id = (int)$_GET["part_id"];
4529  $cancel_cmd = "showParticipant";
4530  }
4531  }
4532  // personal
4533  else
4534  {
4535  $this->checkPermission("read");
4536 
4537  $user_id = $ilUser->getId();
4538  $cancel_cmd = "showOverview";
4539  }
4540 
4541  $this->tabs_gui->clearTargets();
4542  $this->tabs_gui->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTarget($this, $cancel_cmd));
4543 
4544  $peer_items = $this->ass->getPeerReviewsByPeerId($user_id, true);
4545  if(!sizeof($peer_items))
4546  {
4547  // #11373
4548  ilUtil::sendFailure($this->lng->txt("exc_peer_review_no_peers_reviewed_yet"), true);
4549  $ilCtrl->redirect($this, "showOverview");
4550  }
4551 
4552  include_once "Modules/Exercise/classes/class.ilExAssignmentPeerReviewTableGUI.php";
4553  $tbl = new ilExAssignmentPeerReviewTableGUI($this, "editPeerReview",
4554  $this->ass, $user_id, $peer_items, "exc_peer_review_show", $cancel_cmd, true);
4555 
4556  $tpl->setContent($tbl->getHTML());
4557  }
4558 
4560  {
4561  global $ilCtrl, $ilTabs, $tpl;
4562 
4563  if(!$this->ass ||
4564  !$this->ass->getPeerReview())
4565  {
4566  $ilCtrl->redirect($this, "showOverview");
4567  }
4568 
4569  $this->checkPermission("write");
4570 
4571  $ilTabs->clearTargets();
4572  $ilTabs->setBackTarget($this->lng->txt("back"),
4573  $ilCtrl->getLinkTarget($this, "listAssignments"));
4574 
4575  include_once "Modules/Exercise/classes/class.ilExAssignmentPeerReviewOverviewTableGUI.php";
4576  $tbl = new ilExAssignmentPeerReviewOverviewTableGUI($this, "showPeerReviewOverview",
4577  $this->ass);
4578 
4579  $panel = "";
4580  $panel_data = $tbl->getPanelInfo();
4581  if(sizeof($panel_data))
4582  {
4583  $ptpl = new ilTemplate("tpl.exc_peer_review_overview_panel.html", true, true, "Modules/Exercise");
4584  foreach($panel_data as $item)
4585  {
4586  $ptpl->setCurrentBlock("user_bl");
4587  foreach($item["value"] as $user)
4588  {
4589  $ptpl->setVariable("USER", $user);
4590  $ptpl->parseCurrentBlock();
4591  }
4592 
4593  $ptpl->setCurrentBlock("item_bl");
4594  $ptpl->setVariable("TITLE", $item["title"]);
4595  $ptpl->parseCurrentBlock();
4596  }
4597 
4598  include_once "Services/UIComponent/Panel/classes/class.ilPanelGUI.php";
4599  $panel = ilPanelGUI::getInstance();
4600  $panel->setHeading($this->lng->txt("exc_peer_review_overview_invalid_users"));
4601  $panel->setBody($ptpl->get());
4602  $panel = $panel->getHTML();
4603  }
4604 
4605  $tpl->setContent($tbl->getHTML().$panel);
4606  }
4607 
4609  {
4610  global $ilCtrl, $tpl, $ilTabs;
4611 
4612  if(!$this->ass ||
4613  !$this->ass->getPeerReview())
4614  {
4615  $ilCtrl->redirect($this, "showOverview");
4616  }
4617 
4618  $this->checkPermission("write");
4619 
4620  $ilTabs->clearTargets();
4621 
4622  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
4623  $cgui = new ilConfirmationGUI();
4624  $cgui->setFormAction($ilCtrl->getFormAction($this));
4625  $cgui->setHeaderText(sprintf($this->lng->txt("exc_peer_review_reset_sure"), $this->ass->getTitle()));
4626  $cgui->setCancel($this->lng->txt("cancel"), "showPeerReviewOverview");
4627  $cgui->setConfirm($this->lng->txt("delete"), "resetPeerReview");
4628 
4629  $tpl->setContent($cgui->getHTML());
4630  }
4631 
4632  public function resetPeerReviewObject()
4633  {
4634  global $ilCtrl;
4635 
4636  if($this->ass &&
4637  $this->ass->getPeerReview())
4638  {
4639  $this->checkPermission("write");
4640  $this->ass->resetPeerReviews();
4641 
4642  ilUtil::sendSuccess($this->lng->txt("exc_peer_review_reset_done"), true);
4643  }
4644 
4645  $ilCtrl->redirect($this, "showPeerReviewOverview");
4646  }
4647 
4649  {
4650  global $ilCtrl, $ilUser;
4651 
4652  $needs_dl = ($this->ass->getFeedbackDate() == ilExAssignment::FEEDBACK_DATE_DEADLINE);
4653 
4654  if(!$this->ass ||
4655  !$this->ass->getFeedbackFile() ||
4656  ($needs_dl && !$this->ass->getDeadline()) ||
4657  ($needs_dl && $this->ass->getDeadline() > time()) ||
4658  (!$needs_dl && !ilExAssignment::getLastSubmission($this->ass->getId(), $ilUser->getId())))
4659  {
4660  $ilCtrl->redirect($this, "showOverview");
4661  }
4662 
4663  ilUtil::deliverFile($this->ass->getFeedbackFilePath(), $this->ass->getFeedbackFile());
4664  }
4665 
4669 
4670  function initMultiFeedbackForm($a_ass_id)
4671  {
4672  global $lng;
4673 
4674  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
4675  $form = new ilPropertyFormGUI();
4676  $form->addCommandButton("uploadMultiFeedback", $lng->txt("upload"));
4677  $form->addCommandButton("members", $lng->txt("cancel"));
4678 
4679  // multi feedback file
4680  $fi = new ilFileInputGUI($lng->txt("exc_multi_feedback_file"), "mfzip");
4681  $fi->setSuffixes(array("zip"));
4682  $fi->setRequired(true);
4683  $form->addItem($fi);
4684 
4685  $form->setTitle(ilExAssignment::lookupTitle($a_ass_id));
4686  $form->setFormAction($this->ctrl->getFormAction($this, "uploadMultiFeedback"));
4687 
4688  return $form;
4689  }
4690 
4698  {
4699  global $ilTabs, $ilToolbar, $lng, $tpl;
4700 
4701  $ass_id = (int)$_GET["ass_id"];
4702 
4703  ilUtil::sendInfo($lng->txt("exc_multi_feedb_info"));
4704 
4705  $ilTabs->activateTab("grades");
4706  $this->checkPermission("write");
4707  $this->addSubmissionSubTabs("assignment");
4708 
4709  // #13719
4710  include_once("./Services/UIComponent/Button/classes/class.ilLinkButton.php");
4711  $button = ilLinkButton::getInstance();
4712  $button->setCaption("exc_download_zip_structure");
4713  $button->setUrl($this->ctrl->getLinkTarget($this, "downloadMultiFeedbackZip"));
4714  $button->setOmitPreventDoubleSubmission(true);
4715  $ilToolbar->addButtonInstance($button);
4716 
4717  if(!$a_form)
4718  {
4719  $a_form = $this->initMultiFeedbackForm($ass_id);
4720  }
4721 
4722  $tpl->setContent($a_form->getHTML());
4723  }
4724 
4729  {
4730  $ass = new ilExAssignment((int) $_GET["ass_id"]);
4731  $ass->sendMultiFeedbackStructureFile($this->object);
4732  }
4733 
4738  {
4739  $ass_id = (int)$_GET["ass_id"];
4740 
4741  // #11983
4742  $form = $this->initMultiFeedbackForm($ass_id);
4743  if($form->checkInput())
4744  {
4745  try
4746  {
4747  $ass = new ilExAssignment($ass_id);
4748  $ass->uploadMultiFeedbackFile(ilUtil::stripSlashesArray($_FILES["mfzip"]));
4749  $this->ctrl->redirect($this, "showMultiFeedbackConfirmationTable");
4750  }
4751  catch (ilExerciseException $e)
4752  {
4753  ilUtil::sendFailure($e->getMessage(), true);
4754  $this->ctrl->redirect($this, "showMultiFeedback");
4755  }
4756  }
4757 
4758  $form->setValuesByPost();
4759  $this->showMultiFeedbackObject($form);
4760  }
4761 
4769  {
4770  global $ilTabs, $tpl;
4771 
4772  $ilTabs->activateTab("grades");
4773  $this->checkPermission("write");
4774  $this->addSubmissionSubTabs("assignment");
4775 
4776  $ass = new ilExAssignment((int) $_GET["ass_id"]);
4777  include_once("./Modules/Exercise/classes/class.ilFeedbackConfirmationTable2GUI.php");
4778  $tab = new ilFeedbackConfirmationTable2GUI($this, "showMultiFeedbackConfirmationTable", $ass);
4779  $tpl->setContent($tab->getHTML());
4780  }
4781 
4786  {
4787  $this->checkPermission("write");
4788  $ass = new ilExAssignment((int) $_GET["ass_id"]);
4789  $ass->clearMultiFeedbackDirectory();
4790 
4791  $this->ctrl->redirect($this, "members");
4792  }
4793 
4798  {
4799  $this->checkPermission("write");
4800  $ass = new ilExAssignment((int) $_GET["ass_id"]);
4801  $ass->saveMultiFeedbackFiles($_POST["file"]);
4802 
4803  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
4804  $this->ctrl->redirect($this, "members");
4805  }
4806 
4811  {
4812  $this->checkPermission("write");
4813 
4814  $res = array("result"=>false);
4815 
4816  if($this->ctrl->isAsynch())
4817  {
4818  $ass_id = (int)$_POST["ass_id"];
4819  $user_id = (int)$_POST["mem_id"];
4820  $comment = trim($_POST["comm"]);
4821 
4822  if($ass_id && $user_id)
4823  {
4824  include_once "Modules/Exercise/classes/class.ilExAssignment.php";
4825 
4826  // team upload?
4827  if(is_object($this->ass) && $this->ass->getType() == ilExAssignment::TYPE_UPLOAD_TEAM)
4828  {
4829  $team_id = $this->ass->getTeamId($user_id);
4830  $user_ids = $this->ass->getTeamMembers($team_id);
4831  }
4832  else
4833  {
4834  $user_ids = array($user_id);
4835  }
4836 
4837  $all_members = new ilExerciseMembers($this->object);
4838  $all_members = $all_members->getMembers();
4839 
4840  $reci_ids = array();
4841  foreach($user_ids as $user_id)
4842  {
4843  if(in_array($user_id, $all_members))
4844  {
4845  ilExAssignment::updateCommentForUser($ass_id, $user_id,
4847 
4848  if(trim($comment))
4849  {
4850  $reci_ids[] = $user_id;
4851  }
4852  }
4853  }
4854 
4855  if(sizeof($reci_ids))
4856  {
4857  // send notification
4858  $this->object->sendFeedbackFileNotification(null, $reci_ids,
4859  $ass_id, true);
4860  }
4861 
4862  $res = array("result"=>true, "snippet"=>ilUtil::shortenText($comment, 25, true));
4863  }
4864  }
4865 
4866  echo(json_encode($res));
4867  exit();
4868  }
4869 
4870  public function createTeamObject()
4871  {
4872  global $ilCtrl, $ilUser, $ilTabs, $lng, $tpl;
4873 
4874  $this->checkPermission("read");
4875 
4876  if($this->ass->getDeadline() == 0 ||
4877  mktime() < $this->ass->getDeadline())
4878  {
4879  $options = ilExAssignment::getAdoptableTeamAssignments($this->ass->getExerciseId(), $this->ass->getId(), $ilUser->getId());
4880  if(sizeof($options))
4881  {
4882  $ilTabs->activateTab("content");
4883  $this->addContentSubTabs("content");
4884 
4885  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
4886  $form = new ilPropertyFormGUI();
4887  $form->setTitle($lng->txt("exc_team_assignment_adopt_user"));
4888  $form->setFormAction($ilCtrl->getFormAction($this, "createAdoptedTeam"));
4889 
4890 
4891  $teams = new ilRadioGroupInputGUI($lng->txt("exc_assignment"), "ass_adpt");
4892  $teams->setValue(-1);
4893 
4894  $teams->addOption(new ilRadioOption($lng->txt("exc_team_assignment_adopt_none_user"), -1));
4895 
4896  $current_map = ilExAssignment::getAssignmentTeamMap($this->ass->getId());
4897 
4898  include_once "Services/User/classes/class.ilUserUtil.php";
4899  foreach($options as $id => $item)
4900  {
4901  $members = array();
4902  $free = false;
4903  foreach($item["user_team"] as $user_id)
4904  {
4905  $members[$user_id] = ilUserUtil::getNamePresentation($user_id);
4906 
4907  if(array_key_exists($user_id, $current_map))
4908  {
4909  $members[$user_id] .= " (".$lng->txt("exc_team_assignment_adopt_already_assigned").")";
4910  }
4911  else
4912  {
4913  $free = true;
4914  }
4915  }
4916  asort($members);
4917  $members = implode("<br />", $members);
4918  $option = new ilRadioOption($item["title"], $id);
4919  $option->setInfo($members);
4920  if(!$free)
4921  {
4922  $option->setDisabled(true);
4923  }
4924  $teams->addOption($option);
4925  }
4926 
4927  $form->addItem($teams);
4928 
4929  $form->addCommandButton("createAdoptedTeam", $lng->txt("save"));
4930  $form->addCommandButton("showOverview", $lng->txt("cancel"));
4931 
4932  $tpl->setContent($form->getHTML());
4933  return;
4934  }
4935 
4936  $this->ass->getTeamId($ilUser->getId(), true);
4937 
4938  // #18046
4939  if (!$this->object->members_obj->isAssigned($ilUser->getId()))
4940  {
4941  $this->object->members_obj->assignMember($ilUser->getId());
4942  }
4943 
4944  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
4945  }
4946 
4947  $ilCtrl->redirect($this, "showOverview");
4948  }
4949 
4950  public function createAdoptedTeamObject()
4951  {
4952  global $ilCtrl, $ilUser, $lng;
4953 
4954  $this->checkPermission("read");
4955 
4956  if($this->ass->getDeadline() == 0 ||
4957  mktime() < $this->ass->getDeadline())
4958  {
4959  $src_ass_id = (int)$_POST["ass_adpt"];
4960  if($src_ass_id > 0)
4961  {
4962  $this->ass->adoptTeams($src_ass_id, $ilUser->getId(), $this->ref_id);
4963  }
4964  else
4965  {
4966  $this->ass->getTeamId($ilUser->getId(), true);
4967  }
4968 
4969  ilUtil::sendSuccess($lng->txt("settings_saved"), true);
4970  }
4971 
4972  $ilCtrl->redirect($this, "showOverview");
4973  }
4974 
4976  {
4977  global $ilCtrl, $ilTabs, $lng, $tpl;
4978 
4979  $this->checkPermission("write");
4980 
4981  if(!$this->ass)
4982  {
4983  $ilCtrl->redirect($this, "listAssignments");
4984  }
4985 
4986  $ilTabs->activateTab("content");
4987  $this->addContentSubTabs("list_assignments");
4988 
4989  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
4990  $form = new ilPropertyFormGUI();
4991  $form->setTitle($lng->txt("exc_team_assignment_adopt"));
4992  $form->setFormAction($ilCtrl->getFormAction($this, "adoptTeamAssignments"));
4993 
4994  $options = ilExAssignment::getAdoptableTeamAssignments($this->ass->getExerciseId());
4995 
4996  // we must not have existing teams in assignment
4997  if(array_key_exists($this->ass->getId(), $options))
4998  {
4999  $ilCtrl->redirect($this, "listAssignments");
5000  }
5001 
5002  $teams = new ilRadioGroupInputGUI($lng->txt("exc_assignment"), "ass_adpt");
5003  $teams->setValue(-1);
5004 
5005  $teams->addOption(new ilRadioOption($lng->txt("exc_team_assignment_adopt_none"), -1));
5006 
5007  foreach($options as $id => $item)
5008  {
5009  $option = new ilRadioOption($item["title"], $id);
5010  $option->setInfo($lng->txt("exc_team_assignment_adopt_teams").": ".$item["teams"]);
5011  $teams->addOption($option);
5012  }
5013 
5014  $form->addItem($teams);
5015 
5016  $form->addCommandButton("adoptTeamAssignments", $lng->txt("save"));
5017  $form->addCommandButton("listAssignments", $lng->txt("cancel"));
5018 
5019  $tpl->setContent($form->getHTML());
5020  }
5021 
5022  public function adoptTeamAssignmentsObject()
5023  {
5024  global $ilCtrl, $lng;
5025 
5026  $this->checkPermission("write");
5027 
5028  $src_ass_id = (int)$_POST["ass_adpt"];
5029 
5030  if($this->ass && $src_ass_id > 0)
5031  {
5032  // no notifications, assignment is not ready
5033  $this->ass->adoptTeams($src_ass_id);
5034 
5035  ilUtil::sendSuccess($lng->txt("settings_saved"), true);
5036  }
5037 
5038  $ilCtrl->redirect($this, "listAssignments");
5039  }
5040 }
5041 
5042 ?>