ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules 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  // #18508
2384  if($_POST["fb"] && $_POST["fb_date"] == ilExAssignment::FEEDBACK_DATE_DEADLINE)
2385  {
2386  $this->form->getItemByPostVar("fb")
2387  ->setAlert($lng->txt("exc_needs_deadline"));
2388  $valid = false;
2389  }
2390  }
2391  else
2392  {
2393  if($_POST["type"] != ilExAssignment::TYPE_UPLOAD_TEAM &&
2394  $_POST["peer"] &&
2395  $_POST["peer_dl_tgl"])
2396  {
2397  $peer_dl = $this->form->getItemByPostVar("peer_dl")->getDate();
2398  $peer_dl = $peer_dl->get(IL_CAL_UNIX);
2399  $end_date = $this->form->getItemByPostVar("deadline")->getDate();
2400  $end_date = $end_date->get(IL_CAL_UNIX);
2401 
2402  // #13877
2403  if ($peer_dl < $end_date)
2404  {
2405  $this->form->getItemByPostVar("peer_dl")
2406  ->setAlert($lng->txt("exc_peer_deadline_mismatch"));
2407  $valid = false;
2408  }
2409  }
2410  }
2411 
2412  if(!$valid)
2413  {
2414  ilUtil::sendFailure($lng->txt("form_input_not_valid"));
2415  $this->form->setValuesByPost();
2416  $tpl->setContent($this->form->getHtml());
2417  return;
2418  }
2419 
2420  $ass = new ilExAssignment();
2421  $ass->setTitle($_POST["title"]);
2422  $ass->setInstruction($_POST["instruction"]);
2423  $ass->setExerciseId($this->object->getId());
2424  $ass->setMandatory($_POST["mandatory"]);
2425  $ass->setType($_POST["type"]);
2426 
2427  if ($_POST["start_time_cb"])
2428  {
2429  $date =
2430  $this->form->getItemByPostVar("start_time")->getDate();
2431  $ass->setStartTime($date->get(IL_CAL_UNIX));
2432  }
2433  else
2434  {
2435  $ass->setStartTime(null);
2436  }
2437 
2438  // deadline
2439  if ($_POST["deadline_cb"])
2440  {
2441  $date =
2442  $this->form->getItemByPostVar("deadline")->getDate();
2443  $ass->setDeadline($date->get(IL_CAL_UNIX));
2444  }
2445  else
2446  {
2447  $ass->setDeadline(null);
2448  }
2449 
2451  {
2452  $ass->setPeerReview($_POST["peer"]);
2453  $ass->setPeerReviewMin($_POST["peer_min"]);
2454  $ass->setPeerReviewFileUpload($_POST["peer_file"]);
2455 
2456  if($ass->getDeadline() && $ass->getDeadline() > time())
2457  {
2458  $ass->setPeerReviewPersonalized($_POST["peer_prsl"]);
2459  }
2460 
2461  if($_POST["peer_dl_tgl"])
2462  {
2463  $peer_dl = $this->form->getItemByPostVar("peer_dl")->getDate();
2464  $ass->setPeerReviewDeadline($peer_dl->get(IL_CAL_UNIX));
2465  }
2466  else
2467  {
2468  $ass->setPeerReviewDeadline(null);
2469  }
2470  }
2471 
2472  $ass->setFeedbackCron($_POST["fb_cron"]); // #13380
2473  $ass->setFeedbackDate($_POST["fb_date"]);
2474 
2475  $ass->save();
2476 
2477  // save files
2478  $ass->uploadAssignmentFiles($_FILES["files"]);
2479 
2480  if($_FILES["fb_file"]["tmp_name"])
2481  {
2482  $ass->handleFeedbackFileUpload($_FILES["fb_file"]);
2483  $ass->update();
2484  }
2485 
2486  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
2487 
2488  if($ass->getType() == ilExAssignment::TYPE_UPLOAD_TEAM)
2489  {
2490  if(sizeof(ilExAssignment::getAdoptableTeamAssignments($this->object->getId(), $ass->getId())))
2491  {
2492  $ilCtrl->setParameter($this, "ass_id", $ass->getId());
2493  $ilCtrl->redirect($this, "adoptTeamAssignmentsForm");
2494  }
2495  }
2496 
2497  $ilCtrl->redirect($this, "listAssignments");
2498  }
2499  else
2500  {
2501  $this->form->setValuesByPost();
2502  $tpl->setContent($this->form->getHtml());
2503  }
2504  }
2505 
2510  {
2511  global $tpl, $ilTabs, $tpl;
2512 
2513  $this->checkPermission("write");
2514 
2515  $this->setAssignmentHeader();
2516  $ilTabs->activateTab("ass_settings");
2517 
2518  $this->initAssignmentForm("edit");
2519  $this->getAssignmentValues();
2520  $tpl->setContent($this->form->getHTML());
2521  }
2522 
2527  public function getAssignmentValues()
2528  {
2529  $values = array();
2530 
2531  $ass = new ilExAssignment($_GET["ass_id"]);
2532  $values["title"] = $ass->getTitle();
2533  if ($ass->getStartTime() > 0)
2534  {
2535  $values["start_time_cb"] = true;
2536  }
2537  $values["mandatory"] = $ass->getMandatory();
2538  $values["instruction"] = $ass->getInstruction();
2539  $values["type"] = $ass->getType();
2540  if ($ass->getDeadline() > 0)
2541  {
2542  $values["deadline_cb"] = true;
2543  }
2544  if($this->ass->getType() == ilExAssignment::TYPE_UPLOAD_TEAM)
2545  {
2546  $this->form->removeItemByPostVar("peer");
2547  $this->form->removeItemByPostVar("peer_min");
2548  $this->form->removeItemByPostVar("peer_dl");
2549  }
2550  else
2551  {
2552  if ($ass->getPeerReviewDeadline() > 0)
2553  {
2554  $values["peer_dl_tgl"] = true;
2555  $peer_dl_date = new ilDateTime($ass->getPeerReviewDeadline(), IL_CAL_UNIX);
2556  $peer_dl = $this->form->getItemByPostVar("peer_dl");
2557  $peer_dl->setDate($peer_dl_date);
2558  }
2559  }
2560  $this->form->setValuesByArray($values);
2561 
2562  if ($ass->getStartTime() > 0)
2563  {
2564  $edit_date = new ilDateTime($ass->getStartTime(), IL_CAL_UNIX);
2565  $ed_item = $this->form->getItemByPostVar("start_time");
2566  $ed_item->setDate($edit_date);
2567  }
2568 
2569  if($ass->getFeedbackFile())
2570  {
2571  $this->form->getItemByPostVar("fb")->setChecked(true);
2572  $this->form->getItemByPostVar("fb_file")->setValue(basename($ass->getFeedbackFilePath()));
2573  }
2574  $this->form->getItemByPostVar("fb_cron")->setChecked($ass->hasFeedbackCron());
2575  $this->form->getItemByPostVar("fb_date")->setValue($ass->getFeedbackDate());
2576 
2577  $this->handleDisabledAssignmentFields($ass, $this->form);
2578  }
2579 
2581  {
2582  // potentially disabled elements are initialized here to re-use this
2583  // method after setValuesByPost() - see updateAssignmentObject()
2584 
2585  // if there are any submissions we cannot change type anymore
2586  if(sizeof(ilExAssignment::getAllDeliveredFiles($this->object->getId(), $a_ass->getId())) ||
2588  {
2589  $a_form->getItemByPostVar("type")->setDisabled(true);
2590  }
2591 
2592  if($a_ass->getDeadline() > 0)
2593  {
2594  $a_form->getItemByPostVar("deadline_cb")->setChecked(true);
2595  $edit_date = new ilDateTime($a_ass->getDeadline(), IL_CAL_UNIX);
2596  $ed_item = $a_form->getItemByPostVar("deadline");
2597  $ed_item->setDate($edit_date);
2598  }
2599 
2600  // team assignments do not support peer review
2601  if($a_ass->getType() == ilExAssignment::TYPE_UPLOAD_TEAM)
2602  {
2603  return;
2604  }
2605 
2606  $a_form->getItemByPostVar("peer")->setChecked($a_ass->getPeerReview());
2607  $a_form->getItemByPostVar("peer_min")->setValue($a_ass->getPeerReviewMin());
2608  $a_form->getItemByPostVar("peer_file")->setChecked($a_ass->hasPeerReviewFileUpload());
2609  $a_form->getItemByPostVar("peer_prsl")->setChecked($a_ass->hasPeerReviewPersonalized());
2610 
2611  // with no active peer review there is nothing to protect
2612  if(!$a_ass->getPeerReview())
2613  {
2614  return;
2615  }
2616 
2617  // #14450
2618  if($a_ass->hasPeerReviewGroups())
2619  {
2620  // deadline(s) are past and must not change
2621  $a_form->getItemByPostVar("deadline_cb")->setDisabled(true);
2622  $a_form->getItemByPostVar("deadline")->setDisabled(true);
2623 
2624  // JourFixe, 2015-05-11 - editable again
2625  // $a_form->getItemByPostVar("peer_dl")->setDisabled(true);
2626 
2627  $a_form->getItemByPostVar("peer")->setDisabled(true);
2628  $a_form->getItemByPostVar("peer_min")->setDisabled(true);
2629  $a_form->getItemByPostVar("peer_file")->setDisabled(true);
2630  $a_form->getItemByPostVar("peer_prsl")->setDisabled(true);
2631  }
2632 
2633  }
2634 
2639  public function updateAssignmentObject()
2640  {
2641  global $tpl, $lng, $ilCtrl, $ilTabs;
2642 
2643  $this->checkPermission("write");
2644 
2645  $ilTabs->activateTab("content");
2646  $this->addContentSubTabs("list_assignments");
2647 
2648  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
2649  $ass = new ilExAssignment($_GET["ass_id"]);
2650 
2651  $this->initAssignmentForm("edit");
2652  if ($this->form->checkInput())
2653  {
2654  // #14450
2655  $protected_peer_review_groups = false;
2656  if($ass->getPeerReview() &&
2657  $ass->hasPeerReviewGroups())
2658  {
2659  $protected_peer_review_groups = true;
2660 
2661  // checkInput() will add alert to disabled fields
2662  $this->form->getItemByPostVar("deadline")->setAlert(null);
2663  $this->form->getItemByPostVar("peer_min")->setAlert(null);
2664  }
2665 
2666  // additional checks
2667 
2668  $valid = true;
2669 
2670  if(!$protected_peer_review_groups)
2671  {
2672  $peer = $_POST["peer"];
2673 
2674  if ($_POST["deadline_cb"])
2675  {
2676  $end_date =
2677  $this->form->getItemByPostVar("deadline")->getDate()->get(IL_CAL_UNIX);
2678  }
2679 
2680  if ($_POST["start_time_cb"] && $end_date)
2681  {
2682  // check whether start date is before end date
2683  $start_date =
2684  $this->form->getItemByPostVar("start_time")->getDate()->get(IL_CAL_UNIX);
2685  if ($start_date >= $end_date)
2686  {
2687  $this->form->getItemByPostVar("start_time")
2688  ->setAlert($lng->txt("exc_start_date_should_be_before_end_date"));
2689  $this->form->getItemByPostVar("deadline")
2690  ->setAlert($lng->txt("exc_start_date_should_be_before_end_date"));
2691  $valid = false;
2692  }
2693  }
2694 
2695  if(!$end_date)
2696  {
2697  if($_POST["peer"])
2698  {
2699  $this->form->getItemByPostVar("peer")
2700  ->setAlert($lng->txt("exc_needs_deadline"));
2701  $valid = false;
2702  }
2703  if($_POST["fb"] && $_POST["fb_date"] == ilExAssignment::FEEDBACK_DATE_DEADLINE)
2704  {
2705  $this->form->getItemByPostVar("fb")
2706  ->setAlert($lng->txt("exc_needs_deadline"));
2707  $valid = false;
2708  }
2709  }
2710  }
2711  else
2712  {
2713  $peer = true;
2714  $end_date = $ass->getDeadline();
2715  }
2716 
2717  if($_POST["type"] != ilExAssignment::TYPE_UPLOAD_TEAM &&
2718  $peer &&
2719  $_POST["peer_dl_tgl"])
2720  {
2721  $peer_dl = $this->form->getItemByPostVar("peer_dl")->getDate();
2722  $peer_dl = $peer_dl->get(IL_CAL_UNIX);
2723 
2724  // #13877
2725  if ($peer_dl < $end_date)
2726  {
2727  $this->form->getItemByPostVar("peer_dl")
2728  ->setAlert($lng->txt("exc_peer_deadline_mismatch"));
2729  $valid = false;
2730  }
2731  }
2732 
2733  if(!$valid)
2734  {
2735  ilUtil::sendFailure($lng->txt("form_input_not_valid"));
2736  $this->form->setValuesByPost();
2737  $this->handleDisabledAssignmentFields($ass, $this->form);
2738  $tpl->setContent($this->form->getHtml());
2739  return;
2740  }
2741 
2742  $ass->setTitle($_POST["title"]);
2743  $ass->setInstruction($_POST["instruction"]);
2744  $ass->setExerciseId($this->object->getId());
2745  $ass->setMandatory($_POST["mandatory"]);
2746  $ass->setType($_POST["type"]);
2747 
2748  if ($_POST["start_time_cb"])
2749  {
2750  $date =
2751  $this->form->getItemByPostVar("start_time")->getDate();
2752  $ass->setStartTime($date->get(IL_CAL_UNIX));
2753  }
2754  else
2755  {
2756  $ass->setStartTime(null);
2757  }
2758 
2759  if(!$protected_peer_review_groups)
2760  {
2761  // deadline
2762  if ($_POST["deadline_cb"])
2763  {
2764  $date = $this->form->getItemByPostVar("deadline")->getDate();
2765  $ass->setDeadline($date->get(IL_CAL_UNIX));
2766  }
2767  else
2768  {
2769  $ass->setDeadline(null);
2770  }
2771 
2773  {
2774  $ass->setPeerReview($_POST["peer"]);
2775  $ass->setPeerReviewMin($_POST["peer_min"]);
2776  $ass->setPeerReviewFileUpload($_POST["peer_file"]);
2777 
2778  if($ass->getDeadline() && $ass->getDeadline() > time())
2779  {
2780  $ass->setPeerReviewPersonalized($_POST["peer_prsl"]);
2781  }
2782  }
2783  }
2784 
2785  if($_POST["peer_dl_tgl"])
2786  {
2787  $peer_dl = $this->form->getItemByPostVar("peer_dl")->getDate();
2788  $ass->setPeerReviewDeadline($peer_dl->get(IL_CAL_UNIX));
2789  }
2790  else
2791  {
2792  $ass->setPeerReviewDeadline(null);
2793  }
2794 
2795  if(!$_POST["fb"] ||
2796  $this->form->getItemByPostVar("fb_file")->getDeletionFlag())
2797  {
2798  $ass->deleteFeedbackFile();
2799  $ass->setFeedbackFile(null);
2800  }
2801  else if($_FILES["fb_file"]["tmp_name"]) // #15189
2802  {
2803  $ass->handleFeedbackFileUpload($_FILES["fb_file"]);
2804  }
2805 
2806  $ass->setFeedbackCron($_POST["fb_cron"]); // #13380
2807  $ass->setFeedbackDate($_POST["fb_date"]);
2808 
2809  $ass->update();
2810  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
2811  $ilCtrl->redirect($this, "editAssignment");
2812  }
2813  else
2814  {
2815  $this->form->setValuesByPost();
2816  $this->handleDisabledAssignmentFields($ass, $this->form);
2817  $tpl->setContent($this->form->getHtml());
2818  }
2819  }
2820 
2821 
2826  {
2827  global $ilCtrl, $tpl, $lng, $ilTabs;
2828 
2829  $this->checkPermission("write");
2830 
2831  $ilTabs->activateTab("content");
2832  $this->addContentSubTabs("list_assignments");
2833 
2834  if (!is_array($_POST["id"]) || count($_POST["id"]) == 0)
2835  {
2836  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
2837  $ilCtrl->redirect($this, "listAssignments");
2838  }
2839  else
2840  {
2841  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
2842  $cgui = new ilConfirmationGUI();
2843  $cgui->setFormAction($ilCtrl->getFormAction($this));
2844  $cgui->setHeaderText($lng->txt("exc_conf_del_assignments"));
2845  $cgui->setCancel($lng->txt("cancel"), "listAssignments");
2846  $cgui->setConfirm($lng->txt("delete"), "deleteAssignments");
2847 
2848  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
2849 
2850  foreach ($_POST["id"] as $i)
2851  {
2852  $cgui->addItem("id[]", $i, ilExAssignment::lookupTitle($i));
2853  }
2854 
2855  $tpl->setContent($cgui->getHTML());
2856  }
2857  }
2858 
2863  {
2864  global $ilDB, $ilCtrl, $lng;
2865 
2866  $this->checkPermission("write");
2867 
2868  $delete = false;
2869  if (is_array($_POST["id"]))
2870  {
2871  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
2872  foreach($_POST["id"] as $id)
2873  {
2874  $ass = new ilExAssignment(ilUtil::stripSlashes($id));
2875  $ass->delete();
2876  $delete = true;
2877  }
2878  }
2879 
2880  if ($delete)
2881  {
2882  ilUtil::sendSuccess($lng->txt("exc_assignments_deleted"), true);
2883  }
2884  $ilCtrl->redirect($this, "listAssignments");
2885  }
2886 
2891  {
2892  global $lng, $ilCtrl;
2893 
2894  $this->checkPermission("write");
2895 
2896  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
2897  ilExAssignment::saveAssOrderOfExercise($this->object->getId(), $_POST["order"]);
2898 
2899  ilUtil::sendSuccess($lng->txt("exc_saved_order"), true);
2900  $ilCtrl->redirect($this, "listAssignments");
2901  }
2902 
2907  {
2908  global $lng, $ilCtrl;
2909 
2910  $this->checkPermission("write");
2911 
2912  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
2913  ilExAssignment::orderAssByDeadline($this->object->getId());
2914 
2915  ilUtil::sendSuccess($lng->txt("exc_saved_order"), true);
2916  $ilCtrl->redirect($this, "listAssignments");
2917  }
2918 
2923  {
2924  global $ilTabs, $lng, $ilCtrl, $tpl, $ilHelp;
2925 
2926  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
2927  $tpl->setTitle(ilExAssignment::lookupTitle((int) $_GET["ass_id"]));
2928  $tpl->setDescription("");
2929 
2930  $ilTabs->clearTargets();
2931  $ilHelp->setScreenIdComponent("exc");
2932 
2933  $ilTabs->setBackTarget($lng->txt("back"),
2934  $ilCtrl->getLinkTarget($this, "listAssignments"));
2935 
2936  $ilTabs->addTab("ass_settings",
2937  $lng->txt("settings"),
2938  $ilCtrl->getLinkTarget($this, "editAssignment"));
2939 
2940  $ilTabs->addTab("ass_files",
2941  $lng->txt("exc_instruction_files"),
2942  $ilCtrl->getLinkTargetByClass("ilfilesystemgui", "listFiles"));
2943 
2944  }
2945 
2946 
2950 
2955  {
2956  global $tpl, $ilTabs, $ilUser, $ilToolbar;
2957 
2958  $this->checkPermission("read");
2959 
2960  include_once("./Services/Tracking/classes/class.ilLearningProgress.php");
2961  ilLearningProgress::_tracProgress($ilUser->getId(),$this->object->getId(),
2962  $this->object->getRefId(), 'exc');
2963 
2964  $ilTabs->activateTab("content");
2965  $this->addContentSubTabs("content");
2966 
2967  // show certificate?
2968  if($this->object->hasUserCertificate($ilUser->getId()))
2969  {
2970  include_once "./Modules/Exercise/classes/class.ilExerciseCertificateAdapter.php";
2971  include_once "./Services/Certificate/classes/class.ilCertificate.php";
2972  $adapter = new ilExerciseCertificateAdapter($this->object);
2973  if(ilCertificate::_isComplete($adapter))
2974  {
2975  $ilToolbar->addButton($this->lng->txt("certificate"),
2976  $this->ctrl->getLinkTarget($this, "outCertificate"));
2977  }
2978  }
2979 
2980  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
2981  include_once("./Services/Accordion/classes/class.ilAccordionGUI.php");
2982  $acc = new ilAccordionGUI();
2983  $acc->setId("exc_ow_".$this->object->getId());
2984  $ass_data = ilExAssignment::getAssignmentDataOfExercise($this->object->getId());
2985  include_once("./Modules/Exercise/classes/class.ilExAssignmentGUI.php");
2986  $ass_gui = new ilExAssignmentGUI($this->object);
2987 
2988  foreach ($ass_data as $ass)
2989  {
2990  // incoming assignment deeplink
2991  $force_open = false;
2992  if(isset($_GET["ass_id_goto"]) &&
2993  (int)$_GET["ass_id_goto"] == $ass["id"])
2994  {
2995  $force_open = true;
2996  }
2997 
2998  $acc->addItem($ass_gui->getOverviewHeader($ass),
2999  $ass_gui->getOverviewBody($ass),
3000  $force_open);
3001  }
3002 
3003  if (count($ass_data) < 2)
3004  {
3005  $acc->setBehaviour("FirstOpen");
3006  }
3007  else
3008  {
3009  $acc->setUseSessionStorage(true);
3010  }
3011 
3012  $tpl->setContent($acc->getHTML());
3013  }
3014 
3019  {
3020  global $tpl, $ilTabs;
3021 
3022  $this->checkPermission("read");
3023 
3024  if(!$this->object->getShowSubmissions())
3025  {
3026  $this->ctrl->redirect($this, "view");
3027  }
3028 
3029  $ilTabs->activateTab("content");
3030  $this->addContentSubTabs("content");
3031 
3032  if($this->ass->getType() != ilExAssignment::TYPE_TEXT)
3033  {
3034  include_once("./Modules/Exercise/classes/class.ilPublicSubmissionsTableGUI.php");
3035  $tab = new ilPublicSubmissionsTableGUI($this, "listPublicSubmissions",
3036  $this->object, (int) $_GET["ass_id"]);
3037  $tpl->setContent($tab->getHTML());
3038  }
3039  else
3040  {
3041  // #13271
3042  include_once "Modules/Exercise/classes/class.ilExAssignmentListTextTableGUI.php";
3043  $tbl = new ilExAssignmentListTextTableGUI($this, "listPublicSubmissions", $this->ass, false, true);
3044  $tpl->setContent($tbl->getHTML());
3045  }
3046  }
3047 
3052  {
3053  $this->checkPermission("write");
3054  $this->object->exportGradesExcel();
3055  exit;
3056  }
3057 
3061  function saveGradesObject()
3062  {
3063  global $ilCtrl, $lng;
3064 
3065  $this->checkPermission("write");
3066  include_once 'Services/Tracking/classes/class.ilLPMarks.php';
3067 
3068  if (is_array($_POST["lcomment"]))
3069  {
3070  foreach ($_POST["lcomment"] as $k => $v)
3071  {
3072  $marks_obj = new ilLPMarks($this->object->getId(), (int) $k);
3073  $marks_obj->setComment(ilUtil::stripSlashes($v));
3074  $marks_obj->setMark(ilUtil::stripSlashes($_POST["mark"][$k]));
3075  $marks_obj->update();
3076  }
3077  }
3078  ilUtil::sendSuccess($lng->txt("exc_msg_saved_grades"), true);
3079  $ilCtrl->redirect($this, "showGradesOverview");
3080  }
3081 
3086  protected function sendNotifications($assignment_id)
3087  {
3088  include_once "./Services/Notification/classes/class.ilNotification.php";
3090 
3091  include_once "./Modules/Exercise/classes/class.ilExerciseMailNotification.php";
3092  $not = new ilExerciseMailNotification();
3094  $not->setAssignmentId($assignment_id);
3095  $not->setRefId($this->ref_id);
3096  $not->setRecipients($users);
3097  $not->send();
3098  }
3099 
3100  protected function createBlogObject()
3101  {
3102  global $ilUser;
3103 
3104  $this->checkPermission("read");
3105 
3106  // $this->tabs_gui->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTarget($this, "showOverview"));
3107 
3108  $this->tabs_gui->setTabActive("content");
3109  $this->addContentSubTabs("content");
3110 
3111  if (mktime() > $this->ass->getDeadline() && ($this->ass->getDeadline() != 0))
3112  {
3113  ilUtil::sendInfo($this->lng->txt("exercise_time_over"));
3114  }
3115 
3116  $tpl = new ilTemplate("tpl.exc_select_resource.html", true, true, "Modules/Exercise");
3117  $tpl->setVariable("TXT_TITLE", $this->lng->txt("exc_create_blog").": ".$this->ass->getTitle());
3118  $tpl->setVariable("TREE", $this->renderWorkspaceExplorer("createBlog"));
3119  $tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
3120  $tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
3121  $tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
3122  $tpl->setVariable("CMD_SUBMIT", "saveBlog");
3123  $tpl->setVariable("CMD_CANCEL", "showOverview");
3124 
3125  ilUtil::sendInfo($this->lng->txt("exc_create_blog_select_info"));
3126 
3127  $this->tpl->setContent($tpl->get());
3128  }
3129 
3130  protected function selectBlogObject()
3131  {
3132  global $ilUser;
3133 
3134  $this->checkPermission("read");
3135 
3136  $this->tabs_gui->clearTargets();
3137  $this->tabs_gui->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTarget($this, "showOverview"));
3138 
3139  // $this->tabs_gui->setTabActive("content");
3140  // $this->addContentSubTabs("content");
3141 
3142  if (mktime() > $this->ass->getDeadline() && ($this->ass->getDeadline() != 0))
3143  {
3144  ilUtil::sendInfo($this->lng->txt("exercise_time_over"));
3145  }
3146 
3147  $tpl = new ilTemplate("tpl.exc_select_resource.html", true, true, "Modules/Exercise");
3148  $tpl->setVariable("TXT_TITLE", $this->lng->txt("exc_select_blog").": ".$this->ass->getTitle());
3149  $tpl->setVariable("TREE", $this->renderWorkspaceExplorer("selectBlog"));
3150  $tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
3151  $tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
3152  $tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
3153  $tpl->setVariable("CMD_SUBMIT", "setSelectedBlog");
3154  $tpl->setVariable("CMD_CANCEL", "showOverview");
3155 
3156  ilUtil::sendInfo($this->lng->txt("exc_select_blog_info"));
3157 
3158  $this->tpl->setContent($tpl->get());
3159  }
3160 
3161  protected function saveBlogObject()
3162  {
3163  global $ilUser;
3164 
3165  if(!$_POST["node"])
3166  {
3167  ilUtil::sendFailure($this->lng->txt("select_one"));
3168  return $this->createBlogObject();
3169  }
3170 
3171  $parent_node = $_POST["node"];
3172 
3173  include_once "Modules/Blog/classes/class.ilObjBlog.php";
3174  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
3175  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
3176 
3177  $blog = new ilObjBlog();
3178  $blog->setTitle($this->object->getTitle()." - ".$this->ass->getTitle());
3179  $blog->create();
3180 
3181  $tree = new ilWorkspaceTree($ilUser->getId());
3182 
3183  $node_id = $tree->insertObject($parent_node, $blog->getId());
3184 
3185  $access_handler = new ilWorkspaceAccessHandler($tree);
3186  $access_handler->setPermissions($parent_node, $node_id);
3187 
3188  $this->object->addResourceObject($node_id, $this->ass->getId(), $ilUser->getId());
3189 
3190  ilUtil::sendSuccess($this->lng->txt("exc_blog_created"), true);
3191  $this->ctrl->redirect($this, "showOverview");
3192  }
3193 
3194  protected function setSelectedBlogObject()
3195  {
3196  global $ilUser;
3197 
3198  if($_POST["node"])
3199  {
3200  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
3201  $tree = new ilWorkspaceTree($ilUser->getId());
3202  $node = $tree->getNodeData($_POST["node"]);
3203  if($node && $node["type"] == "blog")
3204  {
3205  $this->removeExistingSubmissions();
3206  $this->object->addResourceObject($node["wsp_id"], $this->ass->getId(), $ilUser->getId());
3207 
3208  ilUtil::sendSuccess($this->lng->txt("exc_blog_selected"), true);
3209  $this->ctrl->setParameter($this, "blog_id", $node["wsp_id"]);
3210  $this->ctrl->redirect($this, "askDirectionSubmission");
3211  }
3212  }
3213 
3214  ilUtil::sendFailure($this->lng->txt("select_one"));
3215  return $this->selectPortfolioObject();
3216  }
3217 
3221  public function removeExistingSubmissions()
3222  {
3223  global $ilUser;
3224 
3225  $submitted = ilExAssignment::getDeliveredFiles($this->ass->getExerciseId(), $this->ass->getId(), $ilUser->getId());
3226  if($submitted)
3227  {
3228  $files = array();
3229  foreach($submitted as $item)
3230  {
3231  $files[] = $item["returned_id"];
3232  }
3233  ilExAssignment::deleteDeliveredFiles($this->ass->getExerciseId(), $this->ass->getId(), $files, $ilUser->getId());
3234  }
3235  }
3236 
3237  protected function askDirectionSubmissionObject()
3238  {
3239  global $tpl;
3240 
3241  $this->tabs_gui->setTabActive("content");
3242  $this->addContentSubTabs("content");
3243 
3244  include_once "Services/Utilities/classes/class.ilConfirmationGUI.php";
3245  $conf = new ilConfirmationGUI();
3246 
3247 
3248  if($_REQUEST["blog_id"])
3249  {
3250  $this->ctrl->setParameter($this, "blog_id", $_REQUEST["blog_id"]);
3251  $txt = $this->lng->txt("exc_direct_submit_blog");
3252  }
3253  else
3254  {
3255  $this->ctrl->setParameter($this, "prtf_id", $_REQUEST["prtf_id"]);
3256  $txt = $this->lng->txt("exc_direct_submit_portfolio");
3257  }
3258  $conf->setFormAction($this->ctrl->getFormAction($this, "directSubmit"));
3259 
3260  $conf->setHeaderText($txt);
3261  $conf->setConfirm($this->lng->txt("exc_direct_submit"), "directSubmit");
3262  $conf->setCancel($this->lng->txt("cancel"), "showOverview");
3263 
3264  $tpl->setContent($conf->getHTML());
3265  }
3266 
3267  protected function directSubmitObject()
3268  {
3269  global $ilUser;
3270 
3271  $success = false;
3272 
3273  // submit current version of blog
3274  if($_REQUEST["blog_id"])
3275  {
3276  $success = $this->submitBlog($_REQUEST["blog_id"]);
3277  $this->ctrl->setParameter($this, "blog_id", "");
3278  }
3279  // submit current version of portfolio
3280  else if($_REQUEST["prtf_id"])
3281  {
3282  $success = $this->submitPortfolio($_REQUEST["prtf_id"]);
3283  $this->ctrl->setParameter($this, "prtf_id", "");
3284  }
3285 
3286  if($success)
3287  {
3288  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
3289  }
3290  else
3291  {
3292  ilUtil::sendFailure($this->lng->txt("msg_failed"), true);
3293  }
3294  $this->ctrl->redirect($this, "showOverview");
3295  }
3296 
3303  function submitBlog($a_blog_id)
3304  {
3305  global $ilUser;
3306 
3307  if($this->object && $this->ass)
3308  {
3309  $blog_id = $a_blog_id;
3310 
3311  include_once "Modules/Blog/classes/class.ilObjBlogGUI.php";
3312  $blog_gui = new ilObjBlogGUI($blog_id, ilObjBlogGUI::WORKSPACE_NODE_ID);
3313  if($blog_gui->object)
3314  {
3315  $file = $blog_gui->buildExportFile();
3316  $size = filesize($file);
3317  if($size)
3318  {
3319  $this->removeExistingSubmissions();
3320 
3321  $meta = array(
3322  "name" => $blog_id,
3323  "tmp_name" => $file,
3324  "size" => $size
3325  );
3326  $this->object->deliverFile($meta, $this->ass->getId(), $ilUser->getId(), true);
3327 
3328  $this->sendNotifications($this->ass->getId());
3329  $this->object->handleSubmission($this->ass->getId());
3330  return true;
3331  }
3332  }
3333  }
3334  return false;
3335  }
3336 
3343  function submitPortfolio($a_portfolio_id)
3344  {
3345  global $ilUser;
3346 
3347  if($this->object && $this->ass)
3348  {
3349  $prtf_id = $a_portfolio_id;
3350 
3351  include_once "Modules/Portfolio/classes/class.ilObjPortfolio.php";
3352  $prtf = new ilObjPortfolio($prtf_id, false);
3353  if($prtf->getTitle())
3354  {
3355  include_once "Modules/Portfolio/classes/class.ilPortfolioHTMLExport.php";
3356  $export = new ilPortfolioHTMLExport(null, $prtf);
3357  $file = $export->buildExportFile();
3358  $size = filesize($file);
3359  if($size)
3360  {
3361  $this->removeExistingSubmissions();
3362 
3363  $meta = array(
3364  "name" => $prtf_id,
3365  "tmp_name" => $file,
3366  "size" => $size
3367  );
3368  $this->object->deliverFile($meta, $this->ass->getId(), $ilUser->getId(), true);
3369 
3370  $this->sendNotifications($this->ass->getId());
3371  $this->object->handleSubmission($this->ass->getId());
3372  return true;
3373  }
3374  }
3375  }
3376  return false;
3377  }
3378 
3379  protected function selectPortfolioObject()
3380  {
3381  global $ilUser;
3382 
3383  $this->checkPermission("read");
3384 
3385  $this->tabs_gui->clearTargets();
3386  $this->tabs_gui->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTarget($this, "showOverview"));
3387 
3388  // $this->tabs_gui->setTabActive("content");
3389  // $this->addContentSubTabs("content");
3390 
3391  if (mktime() > $this->ass->getDeadline() && ($this->ass->getDeadline() != 0))
3392  {
3393  ilUtil::sendInfo($this->lng->txt("exercise_time_over"));
3394  }
3395 
3396  $tpl = new ilTemplate("tpl.exc_select_resource.html", true, true, "Modules/Exercise");
3397 
3398  include_once "Modules/Portfolio/classes/class.ilObjPortfolio.php";
3399  $portfolios = ilObjPortfolio::getPortfoliosOfUser($ilUser->getId());
3400  if($portfolios)
3401  {
3402  $tpl->setCurrentBlock("item");
3403  foreach($portfolios as $portfolio)
3404  {
3405  $tpl->setVariable("ITEM_ID", $portfolio["id"]);
3406  $tpl->setVariable("ITEM_TITLE", $portfolio["title"]);
3407  $tpl->parseCurrentBlock();
3408  }
3409  }
3410 
3411  $tpl->setVariable("TXT_TITLE", $this->lng->txt("exc_select_portfolio").": ".$this->ass->getTitle());
3412  $tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
3413  $tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
3414  $tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
3415  $tpl->setVariable("CMD_SUBMIT", "setSelectedPortfolio");
3416  $tpl->setVariable("CMD_CANCEL", "showOverview");
3417 
3418  ilUtil::sendInfo($this->lng->txt("exc_select_portfolio_info"));
3419 
3420  $this->tpl->setContent($tpl->get());
3421  }
3422 
3423  protected function initPortfolioTemplateForm(array $a_templates)
3424  {
3425  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
3426  $form = new ilPropertyFormGUI();
3427  $form->setTitle($this->lng->txt("exc_create_portfolio").": ".$this->ass->getTitle());
3428  $form->setFormAction($this->ctrl->getFormAction($this, "setSelectedPortfolioTemplate"));
3429 
3430  $prtt = new ilRadioGroupInputGUI($this->lng->txt("obj_prtt"), "prtt");
3431  $prtt->setRequired(true);
3432  $prtt->addOption(new ilRadioOption($this->lng->txt("exc_create_portfolio_no_template"), -1));
3433  foreach($a_templates as $id => $title)
3434  {
3435  $prtt->addOption(new ilRadioOption('"'.$title.'"', $id));
3436  }
3437  $prtt->setValue(-1);
3438  $form->addItem($prtt);
3439 
3440  $form->addCommandButton("setSelectedPortfolioTemplate", $this->lng->txt("save"));
3441  $form->addCommandButton("showOverview", $this->lng->txt("cancel"));
3442 
3443  return $form;
3444  }
3445 
3446  protected function createPortfolioTemplateObject(ilPropertyFormGUI $a_form = null)
3447  {
3448  $this->checkPermission("read");
3449 
3450  include_once "Modules/Portfolio/classes/class.ilObjPortfolioTemplate.php";
3452  if(!sizeof($templates))
3453  {
3454  $this->ctrl->redirect($this, "showOverview");
3455  }
3456 
3457  $this->tabs_gui->clearTargets();
3458  $this->tabs_gui->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTarget($this, "showOverview"));
3459 
3460  if(!$a_form)
3461  {
3462  $a_form = $this->initPortfolioTemplateForm($templates);
3463  }
3464 
3465  $this->tpl->setContent($a_form->getHTML());
3466  }
3467 
3469  {
3470  $this->checkPermission("read");
3471 
3472  include_once "Modules/Portfolio/classes/class.ilObjPortfolioTemplate.php";
3474  if(!sizeof($templates))
3475  {
3476  $this->ctrl->redirect($this, "showOverview");
3477  }
3478 
3479  $form = $this->initPortfolioTemplateForm($templates);
3480  if($form->checkInput())
3481  {
3482  $prtt = $form->getInput("prtt");
3483  if($prtt > 0 && array_key_exists($prtt, $templates))
3484  {
3485  $title = $this->object->getTitle()." - ".$this->ass->getTitle();
3486  $this->ctrl->setParameterByClass("ilObjPortfolioGUI", "exc_id", $this->object->getRefId());
3487  $this->ctrl->setParameterByClass("ilObjPortfolioGUI", "ass_id", $this->ass->getId());
3488  $this->ctrl->setParameterByClass("ilObjPortfolioGUI", "pt", $title);
3489  $this->ctrl->setParameterByClass("ilObjPortfolioGUI", "prtt", $prtt);
3490  $this->ctrl->redirectByClass(array("ilPersonalDesktopGUI", "ilPortfolioRepositoryGUI", "ilObjPortfolioGUI"), "createPortfolioFromTemplate");
3491  }
3492  else
3493  {
3494  // do not use template
3495  return $this->createPortfolioObject();
3496  }
3497  }
3498 
3499  $form->setValuesByPost();
3500  $this->createPortfolioTemplateObject($form);
3501  }
3502 
3503  protected function createPortfolioObject()
3504  {
3505  global $ilUser;
3506 
3507  $this->checkPermission("read");
3508 
3509  include_once "Modules/Portfolio/classes/class.ilObjPortfolio.php";
3510  $portfolio = new ilObjPortfolio();
3511  $portfolio->setTitle($this->object->getTitle()." - ".$this->ass->getTitle());
3512  $portfolio->create();
3513 
3514  $this->object->addResourceObject($portfolio->getId(), $this->ass->getId(), $ilUser->getId());
3515 
3516  ilUtil::sendSuccess($this->lng->txt("exc_portfolio_created"), true);
3517  $this->ctrl->redirect($this, "showOverview");
3518  }
3519 
3520  protected function setSelectedPortfolioObject()
3521  {
3522  global $ilUser;
3523 
3524  if($_POST["item"])
3525  {
3526  $this->removeExistingSubmissions();
3527  $this->object->addResourceObject($_POST["item"], $this->ass->getId(), $ilUser->getId());
3528 
3529  ilUtil::sendSuccess($this->lng->txt("exc_portfolio_selected"), true);
3530  $this->ctrl->setParameter($this, "prtf_id", $_POST["item"]);
3531  $this->ctrl->redirect($this, "askDirectionSubmission");
3532  }
3533 
3534  ilUtil::sendFailure($this->lng->txt("select_one"));
3535  return $this->selectPortfolioObject();
3536  }
3537 
3538  protected function renderWorkspaceExplorer($a_cmd)
3539  {
3540  global $ilUser;
3541 
3542  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
3543  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
3544  require_once 'Services/PersonalWorkspace/classes/class.ilWorkspaceExplorer.php';
3545 
3546  $tree = new ilWorkspaceTree($ilUser->getId());
3547  $access_handler = new ilWorkspaceAccessHandler($tree);
3549  'exc_wspexpand', $tree, $access_handler);
3550  $exp->setTargetGet('wsp_id');
3551 
3552  if($a_cmd == "selectBlog")
3553  {
3554  $exp->removeAllFormItemTypes();
3555  $exp->addFilter('blog');
3556  $exp->addFormItemForType('blog');
3557  }
3558 
3559  if($_GET['exc_wspexpand'] == '')
3560  {
3561  // not really used as session is already set [see above]
3562  $expanded = $tree->readRootId();
3563  }
3564  else
3565  {
3566  $expanded = $_GET['exc_wspexpand'];
3567  }
3568 
3569  $exp->setExpandTarget($this->ctrl->getLinkTarget($this, $a_cmd));
3570  $exp->setPostVar('node');
3571  $exp->setExpand($expanded);
3572  $exp->setOutput(0);
3573 
3574  return $exp->getOutput();
3575  }
3576 
3578  {
3579  $this->setSettingsSubTabs();
3580  $this->tabs_gui->activateTab("settings");
3581  $this->tabs_gui->activateSubTab("certificate");
3582 
3583  include_once "./Services/Certificate/classes/class.ilCertificateGUI.php";
3584  include_once "./Modules/Exercise/classes/class.ilExerciseCertificateAdapter.php";
3585  $output_gui = new ilCertificateGUI(new ilExerciseCertificateAdapter($this->object));
3586  $output_gui->certificateEditor();
3587  }
3588 
3590  {
3591  global $ilUser;
3592 
3593  if($this->object->hasUserCertificate($ilUser->getId()))
3594  {
3595  ilUtil::sendFailure($this->lng->txt("msg_failed"));
3596  $this->showOverviewObject();
3597  }
3598 
3599  include_once "./Services/Certificate/classes/class.ilCertificate.php";
3600  include_once "./Modules/Exercise/classes/class.ilExerciseCertificateAdapter.php";
3601  $certificate = new ilCertificate(new ilExerciseCertificateAdapter($this->object));
3602  $certificate->outCertificate(array("user_id" => $ilUser->getId()));
3603  }
3604 
3605  protected function initTeamSubmission($a_back_cmd, $a_mandatory_team = true)
3606  {
3607  global $ilUser, $ilHelp;
3608 
3609  $this->checkPermission("read");
3610 
3611  if($a_mandatory_team && $this->ass->getType() != ilExAssignment::TYPE_UPLOAD_TEAM)
3612  {
3613  $this->ctrl->redirect($this, "submissionScreen");
3614  }
3615 
3616  $this->tabs_gui->clearTargets();
3617  $ilHelp->setScreenIdComponent("exc");
3618  $this->tabs_gui->setBackTarget($this->lng->txt("back"),
3619  $this->ctrl->getLinkTarget($this, $a_back_cmd));
3620 
3621  if($this->ass->getType() == ilExAssignment::TYPE_UPLOAD_TEAM)
3622  {
3623  $this->tabs_gui->addTab("submissions", $this->lng->txt("files"),
3624  $this->ctrl->getLinkTarget($this, "submissionScreen"));
3625 
3626  $this->tabs_gui->addTab("team", $this->lng->txt("exc_team"),
3627  $this->ctrl->getLinkTarget($this, "submissionScreenTeam"));
3628 
3629  $this->tabs_gui->addTab("log", $this->lng->txt("exc_team_log"),
3630  $this->ctrl->getLinkTarget($this, "submissionScreenTeamLog"));
3631 
3632  $this->tabs_gui->activateTab("team");
3633 
3634  $team_id = $this->ass->getTeamId($ilUser->getId());
3635 
3636  if(!$team_id)
3637  {
3638  $team_id = $this->ass->getTeamId($ilUser->getId(), true);
3639 
3640  // #12337
3641  if (!$this->object->members_obj->isAssigned($ilUser->getId()))
3642  {
3643  $this->object->members_obj->assignMember($ilUser->getId());
3644  }
3645  }
3646 
3647  return $team_id;
3648  }
3649  else
3650  {
3651  $ilHelp->setScreenId("submissions");
3652  }
3653  }
3654 
3661  {
3662  global $ilToolbar;
3663 
3664  $team_id = $this->initTeamSubmission("showOverview");
3665 
3666  // $this->tabs_gui->setTabActive("content");
3667  // $this->addContentSubTabs("content");
3668 
3669  // #13414
3670  $read_only = (mktime() > $this->ass->getDeadline() && ($this->ass->getDeadline() != 0));
3671 
3672  if ($read_only)
3673  {
3674  ilUtil::sendInfo($this->lng->txt("exercise_time_over"));
3675  }
3676  else
3677  {
3678  $this->ctrl->setParameterByClass('ilRepositorySearchGUI', 'ctx', 1);
3679  $this->ctrl->setParameter($this, 'ctx', 1);
3680 
3681  // add member
3682  include_once './Services/Search/classes/class.ilRepositorySearchGUI.php';
3684  $this,
3685  $ilToolbar,
3686  array(
3687  'auto_complete_name' => $this->lng->txt('user'),
3688  'submit_name' => $this->lng->txt('add'),
3689  'add_search' => true,
3690  'add_from_container' => $this->object->getRefId()
3691  )
3692  );
3693  }
3694 
3695  include_once "Modules/Exercise/classes/class.ilExAssignmentTeamTableGUI.php";
3696  $tbl = new ilExAssignmentTeamTableGUI($this, "submissionScreenTeam",
3697  ilExAssignmentTeamTableGUI::MODE_EDIT, $team_id, $this->ass, null, $read_only);
3698 
3699  $this->tpl->setContent($tbl->getHTML());
3700  }
3701 
3702  public function addTeamMemberActionObject($a_user_ids = array())
3703  {
3704  global $ilUser;
3705 
3706  $this->checkPermission("read");
3707 
3708  if(!count($a_user_ids))
3709  {
3710  ilUtil::sendFailure($this->lng->txt("no_checkbox"));
3711  return false;
3712  }
3713 
3714  $team_id = $this->ass->getTeamId($ilUser->getId());
3715  $has_files = $this->ass->getDeliveredFiles($this->object->getId(),
3716  $this->ass->getId(),
3717  $ilUser->getId());
3718  $all_members = $this->ass->getMembersOfAllTeams();
3719  $members = $this->ass->getTeamMembers($team_id);
3720 
3721  foreach($a_user_ids as $user_id)
3722  {
3723  if(!in_array($user_id, $all_members))
3724  {
3725  $this->ass->addTeamMember($team_id, $user_id, $this->ref_id);
3726 
3727  // #14277
3728  if (!$this->object->members_obj->isAssigned($user_id))
3729  {
3730  $this->object->members_obj->assignMember($user_id);
3731  }
3732 
3733  // see ilObjExercise::deliverFile()
3734  if($has_files)
3735  {
3736  ilExAssignment::updateStatusReturnedForUser($this->ass->getId(), $user_id, 1);
3737  ilExerciseMembers::_writeReturned($this->object->getId(), $user_id, 1);
3738  }
3739 
3740  // :TODO: log, notification
3741  }
3742  else if(!in_array($user_id, $members))
3743  {
3744  ilUtil::sendFailure($this->lng->txt("exc_members_already_assigned"), true);
3745  }
3746  }
3747 
3748  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
3749  $this->ctrl->redirect($this, "submissionScreenTeam");
3750  }
3751 
3752  public function confirmDeleteTeamObject()
3753  {
3754  $this->confirmRemoveTeamMemberObject(true);
3755  }
3756 
3757  public function confirmRemoveTeamMemberObject($a_full_delete = false)
3758  {
3759  global $ilUser, $tpl;
3760 
3761  $team_id = $this->ass->getTeamId($ilUser->getId());
3762  $members = $this->ass->getTeamMembers($team_id);
3763 
3764  $ids = (bool)$a_full_delete
3765  ? $members
3766  : $_POST["id"];
3767 
3768  if(!sizeof($ids))
3769  {
3770  ilUtil::sendFailure($this->lng->txt("select_one"), true);
3771  $this->ctrl->redirect($this, "submissionScreenTeam");
3772  }
3773 
3774  $team_deleted = false;
3775  if(sizeof($members) <= sizeof($ids))
3776  {
3777  if(sizeof($members) == 1 && $members[0] == $ilUser->getId())
3778  {
3779  // direct team deletion - no confirmation
3780  return $this->removeTeamMemberObject($a_full_delete);
3781  }
3782  else
3783  {
3784  ilUtil::sendFailure($this->lng->txt("exc_team_at_least_one"), true);
3785  $this->ctrl->redirect($this, "submissionScreenTeam");
3786  }
3787  }
3788 
3789  // #11957
3790  $team_id = $this->initTeamSubmission("showOverview");
3791 
3792  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
3793  $cgui = new ilConfirmationGUI();
3794  $cgui->setFormAction($this->ctrl->getFormAction($this));
3795  $cgui->setHeaderText($this->lng->txt("exc_team_member_remove_sure"));
3796  $cgui->setCancel($this->lng->txt("cancel"), "submissionScreenTeam");
3797  $cgui->setConfirm($this->lng->txt("remove"), "removeTeamMember");
3798 
3799  $files = ilExAssignment::getDeliveredFiles($this->ass->getExerciseId(),
3800  $this->ass->getId(), $ilUser->getId());
3801 
3802  include_once "Services/User/classes/class.ilUserUtil.php";
3803 
3804  foreach($ids as $id)
3805  {
3806  $details = array();
3807  foreach ($files as $file)
3808  {
3809  if($file["owner_id"] == $id)
3810  {
3811  $details[] = $file["filetitle"];
3812  }
3813  }
3814  $uname = ilUserUtil::getNamePresentation($id);
3815  if(sizeof($details))
3816  {
3817  $uname .= ": ".implode(", ", $details);
3818  }
3819  $cgui->addItem("id[]", $id, $uname);
3820  }
3821 
3822  $tpl->setContent($cgui->getHTML());
3823  }
3824  public function removeTeamMemberObject($a_full_delete = false)
3825  {
3826  global $ilUser;
3827 
3828  $team_id = $this->ass->getTeamId($ilUser->getId());
3829  $members = $this->ass->getTeamMembers($team_id);
3830 
3831  $ids = (bool)$a_full_delete
3832  ? $members
3833  : $_POST["id"];
3834 
3835  if(!sizeof($ids))
3836  {
3837  ilUtil::sendFailure($this->lng->txt("select_one"), true);
3838  $this->ctrl->redirect($this, "submissionScreenTeam");
3839  }
3840 
3841  $team_deleted = (bool)$a_full_delete;
3842  if(!$team_deleted)
3843  {
3844  if(sizeof($members) <= sizeof($ids))
3845  {
3846  if(sizeof($members) == 1 && $members[0] == $ilUser->getId())
3847  {
3848  $team_deleted = true;
3849  }
3850  else
3851  {
3852  ilUtil::sendFailure($this->lng->txt("exc_team_at_least_one"), true);
3853  $this->ctrl->redirect($this, "submissionScreenTeam");
3854  }
3855  }
3856  }
3857 
3858  foreach($ids as $user_id)
3859  {
3860  $this->ass->removeTeamMember($team_id, $user_id, $this->ref_id);
3861 
3862  ilExAssignment::updateStatusReturnedForUser($this->ass->getId(), $user_id, 0);
3863  ilExerciseMembers::_writeReturned($this->object->getId(), $user_id, 0);
3864 
3865  // :TODO: log, notification
3866  }
3867 
3868  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
3869 
3870  if(!$team_deleted)
3871  {
3872  $this->ctrl->redirect($this, "submissionScreenTeam");
3873  }
3874  else
3875  {
3876  $this->ctrl->redirect($this, "showOverview");
3877  }
3878  }
3879 
3881  {
3882  $team_id = $this->initTeamSubmission("showOverview");
3883  $this->tabs_gui->activateTab("log");
3884 
3885  include_once "Modules/Exercise/classes/class.ilExAssignmentTeamLogTableGUI.php";
3886  $tbl = new ilExAssignmentTeamLogTableGUI($this, "submissionScreenTeamLog",
3887  $team_id);
3888 
3889  $this->tpl->setContent($tbl->getHTML());
3890  }
3891 
3893  {
3894  if(isset($_GET["lmem"]))
3895  {
3896  $user_id = $_GET["lmem"];
3897  $cmd = "members";
3898  }
3899  else
3900  {
3901  $user_id = $_GET["lpart"];
3902  $cmd = "showParticipant";
3903  }
3904  if($user_id)
3905  {
3906  $this->ass->getTeamId($user_id, true);
3907  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
3908  }
3909  $this->ctrl->redirect($this, $cmd);
3910  }
3911 
3913  {
3914  $this->checkPermission("write");
3915  $this->tabs_gui->activateTab("grades");
3916 
3917  if(isset($_GET["lmem"]))
3918  {
3919  $this->addSubmissionSubTabs("assignment");
3920 
3921  $this->tabs_gui->setBackTarget($this->lng->txt("back"),
3922  $this->ctrl->getLinkTarget($this, "members"));
3923 
3924  $team_id = ilExAssignment::getTeamIdByAssignment($this->ass->getId(), (int)$_GET["lmem"]);
3925 
3926  $this->ctrl->saveParameter($this, "lmem");
3927  }
3928  else
3929  {
3930  $this->addSubmissionSubTabs("participant");
3931 
3932  $this->tabs_gui->setBackTarget($this->lng->txt("back"),
3933  $this->ctrl->getLinkTarget($this, "showParticipant"));
3934 
3935  $team_id = ilExAssignment::getTeamIdByAssignment($this->ass->getId(), (int)$_GET["lpart"]);
3936 
3937  $this->ctrl->saveParameter($this, "lpart");
3938  }
3939 
3940  include_once "Modules/Exercise/classes/class.ilExAssignmentTeamLogTableGUI.php";
3941  $tbl = new ilExAssignmentTeamLogTableGUI($this, "showTeamLog",
3942  $team_id);
3943 
3944  $this->tpl->setContent($tbl->getHTML());
3945  }
3946 
3947  protected function initAssignmentTextForm(ilExAssignment $a_ass, $a_read_only = false, $a_cancel_cmd = "showOverview", $a_peer_review_cmd = null, $a_peer_rating_html = null)
3948  {
3949  global $ilCtrl, $ilUser;
3950 
3951  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
3952  $form = new ilPropertyFormGUI();
3953  $form->setTitle($this->lng->txt("exc_assignment")." \"".$a_ass->getTitle()."\"");
3954 
3955  if(!$a_read_only)
3956  {
3957  $text = new ilTextAreaInputGUI($this->lng->txt("exc_your_text"), "atxt");
3958  $text->setRequired((bool)$a_ass->getMandatory());
3959  $text->setRows(40);
3960  $form->addItem($text);
3961 
3962  // custom rte tags
3963  $text->setUseRte(true);
3964  $text->setRTESupport($ilUser->getId(), "exca~", "exc_ass");
3965 
3966  // see ilObjForumGUI
3967  $text->disableButtons(array(
3968  'charmap',
3969  'undo',
3970  'redo',
3971  'justifyleft',
3972  'justifycenter',
3973  'justifyright',
3974  'justifyfull',
3975  'anchor',
3976  'fullscreen',
3977  'cut',
3978  'copy',
3979  'paste',
3980  'pastetext',
3981  // 'formatselect' #13234
3982  ));
3983 
3984  $form->setFormAction($ilCtrl->getFormAction($this, "updateAssignmentText"));
3985  $form->addCommandButton("updateAssignmentTextAndReturn", $this->lng->txt("save_return"));
3986  $form->addCommandButton("updateAssignmentText", $this->lng->txt("save"));
3987  }
3988  else
3989  {
3990  $text = new ilNonEditableValueGUI($this->lng->txt("exc_files_returned_text"), "atxt", true);
3991  $form->addItem($text);
3992 
3993  if(!$a_peer_review_cmd)
3994  {
3995  $form->setFormAction($ilCtrl->getFormAction($this, "showOverview"));
3996  }
3997  else
3998  {
3999  $rating = new ilCustomInputGUI($this->lng->txt("exc_peer_review_rating"));
4000  $rating->setHtml($a_peer_rating_html);
4001  $form->addItem($rating);
4002 
4003  $comm = new ilTextAreaInputGUI($this->lng->txt("exc_peer_review_comment"), "comm");
4004  $comm->setCols(75);
4005  $comm->setRows(15);
4006  $form->addItem($comm);
4007 
4008  $form->setFormAction($ilCtrl->getFormAction($this, $a_peer_review_cmd));
4009  $form->addCommandButton($a_peer_review_cmd, $this->lng->txt("save"));
4010  }
4011  }
4012  $form->addCommandButton($a_cancel_cmd, $this->lng->txt("cancel"));
4013 
4014  return $form;
4015  }
4016 
4018  {
4019  global $ilTabs, $ilCtrl, $ilUser;
4020 
4021  if(!$this->ass ||
4022  $this->ass->getType() != ilExAssignment::TYPE_TEXT ||
4023  ($this->ass->getDeadline() && $this->ass->getDeadline() - time() < 0))
4024  {
4025  $ilCtrl->redirect($this, "showOverview");
4026  }
4027 
4028  $this->checkPermission("read");
4029 
4030  //$ilTabs->activateTab("content");
4031  //$this->addContentSubTabs("content");
4032 
4033  $this->tabs_gui->clearTargets();
4034  $this->tabs_gui->setBackTarget($this->lng->txt("back"),
4035  $this->ctrl->getLinkTarget($this, "showOverview"));
4036 
4037  global $ilHelp;
4038  $ilHelp->setScreenIdComponent("exc");
4039  $ilHelp->setScreenId("text_submission");
4040 
4041  if($this->ass->getDeadline())
4042  {
4043  ilUtil::sendInfo($this->lng->txt("exc_edit_until").": ".
4044  ilDatePresentation::formatDate(new ilDateTime($this->ass->getDeadline(),IL_CAL_UNIX)));
4045  }
4046 
4047  if(!$a_form)
4048  {
4049  $a_form = $this->initAssignmentTextForm($this->ass);
4050 
4051  $files = ilExAssignment::getDeliveredFiles($this->ass->getExerciseId(), $this->ass->getId(), $ilUser->getId());
4052  if($files)
4053  {
4054  $files = array_shift($files);
4055  if(trim($files["atext"]))
4056  {
4057  $text = $a_form->getItemByPostVar("atxt");
4058  // mob id to mob src
4059  $text->setValue(ilRTE::_replaceMediaObjectImageSrc($files["atext"], 1));
4060  }
4061  }
4062  }
4063 
4064  $this->tpl->setContent($a_form->getHTML());
4065  }
4066 
4068  {
4069  $this->updateAssignmentTextObject(true);
4070  }
4071 
4072  function updateAssignmentTextObject($a_return = false)
4073  {
4074  global $ilCtrl, $ilUser;
4075 
4076  $times_up = ($this->ass->getDeadline() && $this->ass->getDeadline() - time() < 0);
4077 
4078  if(!$this->ass ||
4079  $this->ass->getType() != ilExAssignment::TYPE_TEXT ||
4080  $times_up)
4081  {
4082  if($times_up)
4083  {
4084  ilUtil::sendFailure($this->lng->txt("exercise_time_over"), true);
4085  }
4086  $ilCtrl->redirect($this, "showOverview");
4087  }
4088 
4089  $this->checkPermission("read");
4090 
4091  $form = $this->initAssignmentTextForm($this->ass);
4092 
4093  // we are not using a purifier, so we have to set the valid RTE tags
4094  // :TODO:
4095  include_once("./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php");
4096  $rte = $form->getItemByPostVar("atxt");
4097  $rte->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("exc_ass"));
4098 
4099  if($form->checkInput())
4100  {
4101  $text = trim($form->getInput("atxt"));
4102 
4103  $existing = (bool)ilExAssignment::getDeliveredFiles($this->ass->getExerciseId(),
4104  $this->ass->getId(), $ilUser->getId());
4105 
4106  $returned_id = $this->object->updateTextSubmission(
4107  $this->ass->getExerciseId(),
4108  $this->ass->getId(),
4109  $ilUser->getId(),
4110  // mob src to mob id
4112 
4113  // no empty text
4114  if($returned_id)
4115  {
4116  if(!$existing)
4117  {
4118  // #14332 - new text
4119  $this->sendNotifications($this->ass->getId());
4120  $this->object->handleSubmission($this->ass->getId());
4121  }
4122 
4123  // mob usage
4124  include_once "Services/MediaObjects/classes/class.ilObjMediaObject.php";
4125  $mobs = ilRTE::_getMediaObjects($text, 0);
4126  foreach($mobs as $mob)
4127  {
4128  if(ilObjMediaObject::_exists($mob))
4129  {
4130  ilObjMediaObject::_removeUsage($mob, 'exca~:html', $ilUser->getId());
4131  ilObjMediaObject::_saveUsage($mob, 'exca:html', $returned_id);
4132  }
4133  }
4134  }
4135 
4136  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
4137  if($a_return)
4138  {
4139  $ilCtrl->redirect($this, "showOverview");
4140  }
4141  else
4142  {
4143  $ilCtrl->redirect($this, "editAssignmentText");
4144  }
4145  }
4146 
4147  $form->setValuesByPost();
4148  $this->editAssignmentTextObject($form);
4149  }
4150 
4152  {
4153  global $ilCtrl, $ilUser, $lng, $tpl;
4154 
4155  if(!$this->ass ||
4156  $this->ass->getType() != ilExAssignment::TYPE_TEXT)
4157  {
4158  $ilCtrl->redirect($this, "showOverview");
4159  }
4160 
4161  $add_rating = null;
4162 
4163  // tutor
4164  if((int)$_GET["grd"])
4165  {
4166  $this->checkPermission("write");
4167 
4168  if((int)$_GET["grd"] == 1)
4169  {
4170  $user_id = (int)$_GET["member_id"];
4171  $cancel_cmd = "members";
4172  }
4173  else
4174  {
4175  $user_id = (int)$_GET["part_id"];
4176  $cancel_cmd = "showParticipant";
4177  }
4178  }
4179  // peer review
4180  else if($this->ass->hasPeerReviewAccess((int)$_GET["member_id"]))
4181  {
4182  $this->checkPermission("read");
4183 
4184  $user_id = (int)$_GET["member_id"];
4185  $cancel_cmd = "editPeerReview";
4186 
4187  // rating
4188  $add_rating = "updatePeerReviewText";
4189  $ilCtrl->setParameter($this, "peer_id", $user_id);
4190  include_once './Services/Rating/classes/class.ilRatingGUI.php';
4191  $rating = new ilRatingGUI();
4192  $rating->setObject($this->ass->getId(), "ass", $user_id, "peer");
4193  $rating->setUserId($ilUser->getId());
4194  $rating = '<div id="rtr_widget">'.$rating->getHTML(false, true,
4195  "il.ExcPeerReview.saveSingleRating(".$user_id.", %rating%)").'</div>';
4196 
4197  $ilCtrl->setParameter($this, "ssrtg", 1);
4198  $tpl->addJavaScript("Modules/Exercise/js/ilExcPeerReview.js");
4199  $tpl->addOnLoadCode("il.ExcPeerReview.setAjax('".
4200  $ilCtrl->getLinkTarget($this, "updatePeerReviewComments", "", true, false).
4201  "')");
4202  $ilCtrl->setParameter($this, "ssrtg", "");
4203  }
4204  // personal
4205  else
4206  {
4207  $this->checkPermission("read");
4208 
4209  $user_id = $ilUser->getId();
4210  $cancel_cmd = "showOverview";
4211  }
4212 
4213  $this->tabs_gui->clearTargets();
4214  $this->tabs_gui->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTarget($this, $cancel_cmd));
4215 
4216  $a_form = $this->initAssignmentTextForm($this->ass, true, $cancel_cmd, $add_rating, $rating);
4217 
4218  if(($user_id != $ilUser->getId() || (bool)$_GET["grd"]))
4219  {
4220  if(!stristr($cancel_cmd, "peer"))
4221  {
4222  include_once "Services/User/classes/class.ilUserUtil.php";
4223  $a_form->setDescription(ilUserUtil::getNamePresentation($user_id));
4224  }
4225  else
4226  {
4227  if(!$this->ass->hasPeerReviewPersonalized())
4228  {
4229  $a_form->setDescription($lng->txt("id").": ".(int)$_GET["seq"]);
4230  }
4231  else
4232  {
4233  include_once "Services/User/classes/class.ilUserUtil.php";
4234  $a_form->setDescription(ilUserUtil::getNamePresentation($user_id));
4235  }
4236 
4237  foreach($this->ass->getPeerReviewsByPeerId($user_id) as $item)
4238  {
4239  if($item["giver_id"] == $ilUser->getId())
4240  {
4241  $a_form->getItemByPostVar("comm")->setValue($item["pcomment"]);
4242  break;
4243  }
4244  }
4245  }
4246  }
4247 
4248  $files = ilExAssignment::getDeliveredFiles($this->ass->getExerciseId(), $this->ass->getId(), $user_id);
4249  if($files)
4250  {
4251  $files = array_shift($files);
4252  if(trim($files["atext"]))
4253  {
4254  $text = $a_form->getItemByPostVar("atxt");
4255  // mob id to mob src
4256  $text->setValue(ilRTE::_replaceMediaObjectImageSrc($files["atext"], 1));
4257  }
4258  }
4259 
4260  $this->tpl->setContent($a_form->getHTML());
4261  }
4262 
4264  {
4265  $this->listTextAssignmentObject(true);
4266  }
4267 
4268  function listTextAssignmentObject($a_show_peer_review = false)
4269  {
4270  global $tpl, $ilToolbar, $ilCtrl, $ilTabs, $lng;
4271 
4272  $this->checkPermission("write");
4273 
4274  if(!$this->ass || $this->ass->getType() != ilExAssignment::TYPE_TEXT)
4275  {
4276  $ilCtrl->redirect($this, "member");
4277  }
4278 
4279  $ilTabs->clearTargets();
4280  $ilTabs->setBackTarget($lng->txt("back"),
4281  $ilCtrl->getLinkTarget($this, "members"));
4282 
4283  if($a_show_peer_review)
4284  {
4285  $cmd = "listTextAssignmentWithPeerReview";
4286  }
4287  else
4288  {
4289  $cmd = "listTextAssignment";
4290  }
4291  include_once "Modules/Exercise/classes/class.ilExAssignmentListTextTableGUI.php";
4292  $tbl = new ilExAssignmentListTextTableGUI($this, $cmd, $this->ass, $a_show_peer_review);
4293  $tpl->setContent($tbl->getHTML());
4294  }
4295 
4296  protected function canPeerReviewBeEdited()
4297  {
4298  // #16130
4299  return ($this->ass &&
4300  $this->ass->getPeerReview() &&
4301  $this->ass->getDeadline() &&
4302  $this->ass->getDeadline() < time() &&
4303  (!$this->ass->getPeerReviewDeadline() ||
4304  $this->ass->getPeerReviewDeadline() > time()));
4305  }
4306 
4308  {
4309  global $ilCtrl, $ilUser, $tpl;
4310 
4311  if(!$this->canPeerReviewBeEdited())
4312  {
4313  $ilCtrl->redirect($this, "showOverview");
4314  }
4315 
4316  $this->checkPermission("read");
4317 
4318  $this->tabs_gui->clearTargets();
4319  $this->tabs_gui->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTarget($this, "showOverview"));
4320 
4321  $peer_items = $this->ass->getPeerReviewsByGiver($ilUser->getId());
4322  if(!sizeof($peer_items))
4323  {
4324  ilUtil::sendFailure($this->lng->txt("exc_peer_review_no_peers"), true);
4325  $ilCtrl->redirect($this, "showOverview");
4326  }
4327 
4328  $missing = ilExAssignment::getNumberOfMissingFeedbacks($this->ass->getId(), $this->ass->getPeerReviewMin());
4329  if($missing)
4330  {
4331  $dl = $this->ass->getPeerReviewDeadline();
4332  if(!$dl || $dl < time())
4333  {
4334  ilUtil::sendInfo(sprintf($this->lng->txt("exc_peer_review_missing_info"), $missing));
4335  }
4336  else
4337  {
4338  ilUtil::sendInfo(sprintf($this->lng->txt("exc_peer_review_missing_info_deadline"), $missing,
4340  }
4341  }
4342 
4343  $tpl->addJavaScript("Modules/Exercise/js/ilExcPeerReview.js");
4344  $tpl->addOnLoadCode("il.ExcPeerReview.setAjax('".
4345  $ilCtrl->getLinkTarget($this, "updatePeerReviewComments", "", true, false).
4346  "')");
4347 
4348  include_once "Modules/Exercise/classes/class.ilExAssignmentPeerReviewTableGUI.php";
4349  $tbl = new ilExAssignmentPeerReviewTableGUI($this, "editPeerReview", $this->ass, $ilUser->getId(), $peer_items, "exc_peer_review_give", "showOverview");
4350 
4351  $tpl->setContent($tbl->getHTML());
4352  }
4353 
4355  {
4356  global $ilUser, $ilCtrl;
4357 
4358  if(!$this->canPeerReviewBeEdited() ||
4359  !sizeof($_POST["pc"]))
4360  {
4361  $ilCtrl->redirect($this, "showOverview");
4362  }
4363 
4364  $this->checkPermission("read");
4365 
4366  $peer_items = $this->ass->getPeerReviewsByGiver($ilUser->getId());
4367  if(!sizeof($peer_items))
4368  {
4369  ilUtil::sendFailure($this->lng->txt("exc_peer_review_no_peers"), true);
4370  $ilCtrl->redirect($this, "showOverview");
4371  }
4372 
4373  foreach($_POST["pc"] as $idx => $value)
4374  {
4375  $parts = explode("__", $idx);
4376  if($parts[0] == $ilUser->getId())
4377  {
4378  $this->ass->updatePeerReviewComment($parts[1], ilUtil::stripSlashes($value)); // #16128
4379  }
4380  }
4381 
4382  ilUtil::sendInfo($this->lng->txt("exc_peer_review_updated"), true);
4383  $ilCtrl->redirect($this, "editPeerReview");
4384  }
4385 
4387  {
4388  global $ilCtrl, $ilUser, $tpl;
4389 
4390  if(!$this->canPeerReviewBeEdited() ||
4391  !sizeof($_POST["pc"]) ||
4392  !$ilCtrl->isAsynch())
4393  {
4394  exit();
4395  }
4396 
4397  $rating_peer_id = $_POST["rating_peer_id"];
4398  $giver_id = $ilUser->getId();
4399 
4400  // save rating
4401  include_once './Services/Rating/classes/class.ilRating.php';
4402  ilRating::writeRatingForUserAndObject($this->ass->getId(), "ass",
4403  $rating_peer_id, "peer", $giver_id, $_POST["rating"]);
4404 
4405  // save comments
4406  foreach($_POST["pc"] as $peer_id => $value)
4407  {
4408  if($peer_id)
4409  {
4410  $this->ass->updatePeerReviewComment($peer_id, ilUtil::stripSlashes($value)); // #16128
4411  }
4412  }
4413 
4414 
4415  // render current rating
4416 
4417  $ilCtrl->setParameter($this->parent_obj, "peer_id", $rating_peer_id);
4418 
4419  include_once './Services/Rating/classes/class.ilRatingGUI.php';
4420  $rating = new ilRatingGUI();
4421  $rating->setObject($this->ass->getId(), "ass", $rating_peer_id, "peer");
4422  $rating->setUserId($giver_id);
4423 
4424  if(!$_REQUEST["ssrtg"])
4425  {
4426  echo $rating->getHTML(false, true,
4427  "il.ExcPeerReview.saveComments(".$rating_peer_id.", %rating%)");
4428  }
4429  else
4430  {
4431  echo '<div id="rtr_widget">'.$rating->getHTML(false, true,
4432  "il.ExcPeerReview.saveSingleRating(".$rating_peer_id.", %rating%)").'</div>';
4433  }
4434 
4435  echo $tpl->getOnLoadCodeForAsynch();
4436  exit();
4437  }
4438 
4440  {
4441  global $ilCtrl;
4442 
4443  if(!$this->canPeerReviewBeEdited() ||
4444  !(int)$_REQUEST["peer_id"])
4445  {
4446  $ilCtrl->redirect($this, "editPeerReview");
4447  }
4448 
4449  $this->ass->updatePeerReviewComment((int)$_REQUEST["peer_id"], ilUtil::stripSlashes(trim($_POST["comm"]))); // #16128
4450 
4451  ilUtil::sendInfo($this->lng->txt("exc_peer_review_updated"), true);
4452  $ilCtrl->redirect($this, "editPeerReview");
4453  }
4454 
4456  {
4457  global $ilCtrl, $ilUser;
4458 
4459  if(!$this->ass ||
4460  !$this->ass->getPeerReview() ||
4461  !$this->ass->hasPeerReviewFileUpload() ||
4462  !$_GET["fu"] ||
4463  !$_GET["fuf"])
4464  {
4465  $ilCtrl->redirect($this, "showOverview");
4466  }
4467 
4468  $parts = explode("__", $_GET["fu"]);
4469  $giver_id = $parts[0];
4470  $peer_id = $parts[1];
4471 
4472  if($giver_id == $ilUser->getId() ||
4473  $peer_id == $ilUser->getId())
4474  {
4475  $this->checkPermission("read");
4476  }
4477  else
4478  {
4479  $this->checkPermission("write");
4480  }
4481 
4482  $peer_items = $this->ass->getPeerReviewsByPeerId($peer_id, true);
4483  if(sizeof($peer_items))
4484  {
4485  foreach($peer_items as $item)
4486  {
4487  if($item["giver_id"] == $giver_id)
4488  {
4489  $files = $this->ass->getPeerUploadFiles($peer_id, $giver_id);
4490  foreach($files as $file)
4491  {
4492  if(md5($file) == trim($_GET["fuf"]))
4493  {
4494  ilUtil::deliverFile($file, basename($file));
4495  break(2);
4496  }
4497  }
4498  }
4499  }
4500  }
4501 
4502  $ilCtrl->redirect($this, "showOverview");
4503  }
4504 
4506  {
4507  global $ilCtrl, $ilUser, $tpl;
4508 
4509  if(!$this->ass ||
4510  !$this->ass->getPeerReview() ||
4511  !$this->ass->getDeadline() ||
4512  $this->ass->getDeadline()-time() > 0)
4513  {
4514  $ilCtrl->redirect($this, "showOverview");
4515  }
4516 
4517  // tutor
4518  if((int)$_GET["grd"])
4519  {
4520  $this->checkPermission("write");
4521 
4522  if((int)$_GET["grd"] == 1)
4523  {
4524  $user_id = (int)$_GET["member_id"];
4525  $cancel_cmd = "members";
4526  }
4527  else
4528  {
4529  $user_id = (int)$_GET["part_id"];
4530  $cancel_cmd = "showParticipant";
4531  }
4532  }
4533  // personal
4534  else
4535  {
4536  $this->checkPermission("read");
4537 
4538  $user_id = $ilUser->getId();
4539  $cancel_cmd = "showOverview";
4540  }
4541 
4542  $this->tabs_gui->clearTargets();
4543  $this->tabs_gui->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTarget($this, $cancel_cmd));
4544 
4545  $peer_items = $this->ass->getPeerReviewsByPeerId($user_id, true);
4546  if(!sizeof($peer_items))
4547  {
4548  // #11373
4549  ilUtil::sendFailure($this->lng->txt("exc_peer_review_no_peers_reviewed_yet"), true);
4550  $ilCtrl->redirect($this, "showOverview");
4551  }
4552 
4553  include_once "Modules/Exercise/classes/class.ilExAssignmentPeerReviewTableGUI.php";
4554  $tbl = new ilExAssignmentPeerReviewTableGUI($this, "editPeerReview",
4555  $this->ass, $user_id, $peer_items, "exc_peer_review_show", $cancel_cmd, true);
4556 
4557  $tpl->setContent($tbl->getHTML());
4558  }
4559 
4561  {
4562  global $ilCtrl, $ilTabs, $tpl;
4563 
4564  if(!$this->ass ||
4565  !$this->ass->getPeerReview())
4566  {
4567  $ilCtrl->redirect($this, "showOverview");
4568  }
4569 
4570  $this->checkPermission("write");
4571 
4572  $ilTabs->clearTargets();
4573  $ilTabs->setBackTarget($this->lng->txt("back"),
4574  $ilCtrl->getLinkTarget($this, "listAssignments"));
4575 
4576  include_once "Modules/Exercise/classes/class.ilExAssignmentPeerReviewOverviewTableGUI.php";
4577  $tbl = new ilExAssignmentPeerReviewOverviewTableGUI($this, "showPeerReviewOverview",
4578  $this->ass);
4579 
4580  $panel = "";
4581  $panel_data = $tbl->getPanelInfo();
4582  if(sizeof($panel_data))
4583  {
4584  $ptpl = new ilTemplate("tpl.exc_peer_review_overview_panel.html", true, true, "Modules/Exercise");
4585  foreach($panel_data as $item)
4586  {
4587  $ptpl->setCurrentBlock("user_bl");
4588  foreach($item["value"] as $user)
4589  {
4590  $ptpl->setVariable("USER", $user);
4591  $ptpl->parseCurrentBlock();
4592  }
4593 
4594  $ptpl->setCurrentBlock("item_bl");
4595  $ptpl->setVariable("TITLE", $item["title"]);
4596  $ptpl->parseCurrentBlock();
4597  }
4598 
4599  include_once "Services/UIComponent/Panel/classes/class.ilPanelGUI.php";
4600  $panel = ilPanelGUI::getInstance();
4601  $panel->setHeading($this->lng->txt("exc_peer_review_overview_invalid_users"));
4602  $panel->setBody($ptpl->get());
4603  $panel = $panel->getHTML();
4604  }
4605 
4606  $tpl->setContent($tbl->getHTML().$panel);
4607  }
4608 
4610  {
4611  global $ilCtrl, $tpl, $ilTabs;
4612 
4613  if(!$this->ass ||
4614  !$this->ass->getPeerReview())
4615  {
4616  $ilCtrl->redirect($this, "showOverview");
4617  }
4618 
4619  $this->checkPermission("write");
4620 
4621  $ilTabs->clearTargets();
4622 
4623  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
4624  $cgui = new ilConfirmationGUI();
4625  $cgui->setFormAction($ilCtrl->getFormAction($this));
4626  $cgui->setHeaderText(sprintf($this->lng->txt("exc_peer_review_reset_sure"), $this->ass->getTitle()));
4627  $cgui->setCancel($this->lng->txt("cancel"), "showPeerReviewOverview");
4628  $cgui->setConfirm($this->lng->txt("delete"), "resetPeerReview");
4629 
4630  $tpl->setContent($cgui->getHTML());
4631  }
4632 
4633  public function resetPeerReviewObject()
4634  {
4635  global $ilCtrl;
4636 
4637  if($this->ass &&
4638  $this->ass->getPeerReview())
4639  {
4640  $this->checkPermission("write");
4641  $this->ass->resetPeerReviews();
4642 
4643  ilUtil::sendSuccess($this->lng->txt("exc_peer_review_reset_done"), true);
4644  }
4645 
4646  $ilCtrl->redirect($this, "showPeerReviewOverview");
4647  }
4648 
4650  {
4651  global $ilCtrl, $ilUser;
4652 
4653  $needs_dl = ($this->ass->getFeedbackDate() == ilExAssignment::FEEDBACK_DATE_DEADLINE);
4654 
4655  if(!$this->ass ||
4656  !$this->ass->getFeedbackFile() ||
4657  ($needs_dl && !$this->ass->getDeadline()) ||
4658  ($needs_dl && $this->ass->getDeadline() > time()) ||
4659  (!$needs_dl && !ilExAssignment::getLastSubmission($this->ass->getId(), $ilUser->getId())))
4660  {
4661  $ilCtrl->redirect($this, "showOverview");
4662  }
4663 
4664  ilUtil::deliverFile($this->ass->getFeedbackFilePath(), $this->ass->getFeedbackFile());
4665  }
4666 
4670 
4671  function initMultiFeedbackForm($a_ass_id)
4672  {
4673  global $lng;
4674 
4675  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
4676  $form = new ilPropertyFormGUI();
4677  $form->addCommandButton("uploadMultiFeedback", $lng->txt("upload"));
4678  $form->addCommandButton("members", $lng->txt("cancel"));
4679 
4680  // multi feedback file
4681  $fi = new ilFileInputGUI($lng->txt("exc_multi_feedback_file"), "mfzip");
4682  $fi->setSuffixes(array("zip"));
4683  $fi->setRequired(true);
4684  $form->addItem($fi);
4685 
4686  $form->setTitle(ilExAssignment::lookupTitle($a_ass_id));
4687  $form->setFormAction($this->ctrl->getFormAction($this, "uploadMultiFeedback"));
4688 
4689  return $form;
4690  }
4691 
4699  {
4700  global $ilTabs, $ilToolbar, $lng, $tpl;
4701 
4702  $ass_id = (int)$_GET["ass_id"];
4703 
4704  ilUtil::sendInfo($lng->txt("exc_multi_feedb_info"));
4705 
4706  $ilTabs->activateTab("grades");
4707  $this->checkPermission("write");
4708  $this->addSubmissionSubTabs("assignment");
4709 
4710  // #13719
4711  include_once("./Services/UIComponent/Button/classes/class.ilLinkButton.php");
4712  $button = ilLinkButton::getInstance();
4713  $button->setCaption("exc_download_zip_structure");
4714  $button->setUrl($this->ctrl->getLinkTarget($this, "downloadMultiFeedbackZip"));
4715  $button->setOmitPreventDoubleSubmission(true);
4716  $ilToolbar->addButtonInstance($button);
4717 
4718  if(!$a_form)
4719  {
4720  $a_form = $this->initMultiFeedbackForm($ass_id);
4721  }
4722 
4723  $tpl->setContent($a_form->getHTML());
4724  }
4725 
4730  {
4731  $ass = new ilExAssignment((int) $_GET["ass_id"]);
4732  $ass->sendMultiFeedbackStructureFile($this->object);
4733  }
4734 
4739  {
4740  $ass_id = (int)$_GET["ass_id"];
4741 
4742  // #11983
4743  $form = $this->initMultiFeedbackForm($ass_id);
4744  if($form->checkInput())
4745  {
4746  try
4747  {
4748  $ass = new ilExAssignment($ass_id);
4749  $ass->uploadMultiFeedbackFile(ilUtil::stripSlashesArray($_FILES["mfzip"]));
4750  $this->ctrl->redirect($this, "showMultiFeedbackConfirmationTable");
4751  }
4752  catch (ilExerciseException $e)
4753  {
4754  ilUtil::sendFailure($e->getMessage(), true);
4755  $this->ctrl->redirect($this, "showMultiFeedback");
4756  }
4757  }
4758 
4759  $form->setValuesByPost();
4760  $this->showMultiFeedbackObject($form);
4761  }
4762 
4770  {
4771  global $ilTabs, $tpl;
4772 
4773  $ilTabs->activateTab("grades");
4774  $this->checkPermission("write");
4775  $this->addSubmissionSubTabs("assignment");
4776 
4777  $ass = new ilExAssignment((int) $_GET["ass_id"]);
4778  include_once("./Modules/Exercise/classes/class.ilFeedbackConfirmationTable2GUI.php");
4779  $tab = new ilFeedbackConfirmationTable2GUI($this, "showMultiFeedbackConfirmationTable", $ass);
4780  $tpl->setContent($tab->getHTML());
4781  }
4782 
4787  {
4788  $this->checkPermission("write");
4789  $ass = new ilExAssignment((int) $_GET["ass_id"]);
4790  $ass->clearMultiFeedbackDirectory();
4791 
4792  $this->ctrl->redirect($this, "members");
4793  }
4794 
4799  {
4800  $this->checkPermission("write");
4801  $ass = new ilExAssignment((int) $_GET["ass_id"]);
4802  $ass->saveMultiFeedbackFiles($_POST["file"], $this->object);
4803 
4804  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
4805  $this->ctrl->redirect($this, "members");
4806  }
4807 
4812  {
4813  $this->checkPermission("write");
4814 
4815  $res = array("result"=>false);
4816 
4817  if($this->ctrl->isAsynch())
4818  {
4819  $ass_id = (int)$_POST["ass_id"];
4820  $user_id = (int)$_POST["mem_id"];
4821  $comment = trim($_POST["comm"]);
4822 
4823  if($ass_id && $user_id)
4824  {
4825  include_once "Modules/Exercise/classes/class.ilExAssignment.php";
4826 
4827  // team upload?
4828  if(is_object($this->ass) && $this->ass->getType() == ilExAssignment::TYPE_UPLOAD_TEAM)
4829  {
4830  $team_id = $this->ass->getTeamId($user_id);
4831  $user_ids = $this->ass->getTeamMembers($team_id);
4832  }
4833  else
4834  {
4835  $user_ids = array($user_id);
4836  }
4837 
4838  $all_members = new ilExerciseMembers($this->object);
4839  $all_members = $all_members->getMembers();
4840 
4841  $reci_ids = array();
4842  foreach($user_ids as $user_id)
4843  {
4844  if(in_array($user_id, $all_members))
4845  {
4846  ilExAssignment::updateCommentForUser($ass_id, $user_id,
4848 
4849  if(trim($comment))
4850  {
4851  $reci_ids[] = $user_id;
4852  }
4853  }
4854  }
4855 
4856  if(sizeof($reci_ids))
4857  {
4858  // send notification
4859  $this->object->sendFeedbackFileNotification(null, $reci_ids,
4860  $ass_id, true);
4861  }
4862 
4863  $res = array("result"=>true, "snippet"=>ilUtil::shortenText($comment, 25, true));
4864  }
4865  }
4866 
4867  echo(json_encode($res));
4868  exit();
4869  }
4870 
4871  public function createTeamObject()
4872  {
4873  global $ilCtrl, $ilUser, $ilTabs, $lng, $tpl;
4874 
4875  $this->checkPermission("read");
4876 
4877  if($this->ass->getDeadline() == 0 ||
4878  mktime() < $this->ass->getDeadline())
4879  {
4880  $options = ilExAssignment::getAdoptableTeamAssignments($this->ass->getExerciseId(), $this->ass->getId(), $ilUser->getId());
4881  if(sizeof($options))
4882  {
4883  $ilTabs->activateTab("content");
4884  $this->addContentSubTabs("content");
4885 
4886  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
4887  $form = new ilPropertyFormGUI();
4888  $form->setTitle($lng->txt("exc_team_assignment_adopt_user"));
4889  $form->setFormAction($ilCtrl->getFormAction($this, "createAdoptedTeam"));
4890 
4891 
4892  $teams = new ilRadioGroupInputGUI($lng->txt("exc_assignment"), "ass_adpt");
4893  $teams->setValue(-1);
4894 
4895  $teams->addOption(new ilRadioOption($lng->txt("exc_team_assignment_adopt_none_user"), -1));
4896 
4897  $current_map = ilExAssignment::getAssignmentTeamMap($this->ass->getId());
4898 
4899  include_once "Services/User/classes/class.ilUserUtil.php";
4900  foreach($options as $id => $item)
4901  {
4902  $members = array();
4903  $free = false;
4904  foreach($item["user_team"] as $user_id)
4905  {
4906  $members[$user_id] = ilUserUtil::getNamePresentation($user_id);
4907 
4908  if(array_key_exists($user_id, $current_map))
4909  {
4910  $members[$user_id] .= " (".$lng->txt("exc_team_assignment_adopt_already_assigned").")";
4911  }
4912  else
4913  {
4914  $free = true;
4915  }
4916  }
4917  asort($members);
4918  $members = implode("<br />", $members);
4919  $option = new ilRadioOption($item["title"], $id);
4920  $option->setInfo($members);
4921  if(!$free)
4922  {
4923  $option->setDisabled(true);
4924  }
4925  $teams->addOption($option);
4926  }
4927 
4928  $form->addItem($teams);
4929 
4930  $form->addCommandButton("createAdoptedTeam", $lng->txt("save"));
4931  $form->addCommandButton("showOverview", $lng->txt("cancel"));
4932 
4933  $tpl->setContent($form->getHTML());
4934  return;
4935  }
4936 
4937  $this->ass->getTeamId($ilUser->getId(), true);
4938 
4939  // #18046
4940  if (!$this->object->members_obj->isAssigned($ilUser->getId()))
4941  {
4942  $this->object->members_obj->assignMember($ilUser->getId());
4943  }
4944 
4945  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
4946  }
4947 
4948  $ilCtrl->redirect($this, "showOverview");
4949  }
4950 
4951  public function createAdoptedTeamObject()
4952  {
4953  global $ilCtrl, $ilUser, $lng;
4954 
4955  $this->checkPermission("read");
4956 
4957  if($this->ass->getDeadline() == 0 ||
4958  mktime() < $this->ass->getDeadline())
4959  {
4960  $src_ass_id = (int)$_POST["ass_adpt"];
4961  if($src_ass_id > 0)
4962  {
4963  $this->ass->adoptTeams($src_ass_id, $ilUser->getId(), $this->ref_id);
4964  }
4965  else
4966  {
4967  $this->ass->getTeamId($ilUser->getId(), true);
4968  }
4969 
4970  ilUtil::sendSuccess($lng->txt("settings_saved"), true);
4971  }
4972 
4973  $ilCtrl->redirect($this, "showOverview");
4974  }
4975 
4977  {
4978  global $ilCtrl, $ilTabs, $lng, $tpl;
4979 
4980  $this->checkPermission("write");
4981 
4982  if(!$this->ass)
4983  {
4984  $ilCtrl->redirect($this, "listAssignments");
4985  }
4986 
4987  $ilTabs->activateTab("content");
4988  $this->addContentSubTabs("list_assignments");
4989 
4990  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
4991  $form = new ilPropertyFormGUI();
4992  $form->setTitle($lng->txt("exc_team_assignment_adopt"));
4993  $form->setFormAction($ilCtrl->getFormAction($this, "adoptTeamAssignments"));
4994 
4995  $options = ilExAssignment::getAdoptableTeamAssignments($this->ass->getExerciseId());
4996 
4997  // we must not have existing teams in assignment
4998  if(array_key_exists($this->ass->getId(), $options))
4999  {
5000  $ilCtrl->redirect($this, "listAssignments");
5001  }
5002 
5003  $teams = new ilRadioGroupInputGUI($lng->txt("exc_assignment"), "ass_adpt");
5004  $teams->setValue(-1);
5005 
5006  $teams->addOption(new ilRadioOption($lng->txt("exc_team_assignment_adopt_none"), -1));
5007 
5008  foreach($options as $id => $item)
5009  {
5010  $option = new ilRadioOption($item["title"], $id);
5011  $option->setInfo($lng->txt("exc_team_assignment_adopt_teams").": ".$item["teams"]);
5012  $teams->addOption($option);
5013  }
5014 
5015  $form->addItem($teams);
5016 
5017  $form->addCommandButton("adoptTeamAssignments", $lng->txt("save"));
5018  $form->addCommandButton("listAssignments", $lng->txt("cancel"));
5019 
5020  $tpl->setContent($form->getHTML());
5021  }
5022 
5023  public function adoptTeamAssignmentsObject()
5024  {
5025  global $ilCtrl, $lng;
5026 
5027  $this->checkPermission("write");
5028 
5029  $src_ass_id = (int)$_POST["ass_adpt"];
5030 
5031  if($this->ass && $src_ass_id > 0)
5032  {
5033  // no notifications, assignment is not ready
5034  $this->ass->adoptTeams($src_ass_id);
5035 
5036  ilUtil::sendSuccess($lng->txt("settings_saved"), true);
5037  }
5038 
5039  $ilCtrl->redirect($this, "listAssignments");
5040  }
5041 }
5042 
5043 ?>
static _getMediaObjects($a_text, $a_direction=0)
Returns all media objects found in the passed string.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
getPeerReview()
Get peer review status.
listAssignmentsObject()
List assignments.
static _lookupName($a_user_id)
lookup user name
addAssignmentObject()
Create assignment.
initAssignmentForm($a_mode="create")
Init assignment form.
__getMembersOfObject($a_result, $a_type)
uploadMultiFeedbackObject()
Upload multi feedback file.
This class represents an option in a radio group.
listTextAssignmentObject($a_show_peer_review=false)
print $file
static getRedirectTarget($gui, $cmd, Array $gui_params=array(), Array $mail_params=array())
uploadZipFormObject()
Display form for zip file upload.
removeTeamMemberObject($a_full_delete=false)
static hasNotification($type, $user_id, $id)
Check notification status for object and user.
$size
Definition: RandomTest.php:79
orderAssByDeadline($a_ex_id)
Order assignments by deadline date.
editAssignmentTextObject(ilPropertyFormGUI $a_form=null)
selectAssignmentObject()
Select assignment.
exit
Definition: login.php:54
setTitle($a_val)
Set title.
static getAssignmentDataOfExercise($a_exc_id)
Get assignments data of an exercise in an array.
Class ilInfoScreenGUI.
setHtml($a_html)
Set Html.
static getNumberOfMissingFeedbacks($a_ass_id, $a_min)
Exercise assignment.
$_POST['username']
Definition: cron.php:12
updateCommentForUser($a_ass_id, $a_user_id, $a_value)
Update comment.
getItemByPostVar($a_post_var)
Get Item by POST variable.
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
saveMultiFeedbackObject()
Save multi feedback.
Class ilExerciseMembers.
This class represents a selection list property in a property form.
$result
Portfolio HTML exporter class.
submitBlog($a_blog_id)
Submit blog for assignment.
saveCommentForLearnersObject()
Save comment for learner (asynch)
This class represents a property form user interface.
getAllDeliveredFiles($a_exc_id, $a_ass_id)
was: getAllDeliveredFiles()
GUI class for the workflow of copying objects.
getAssignmentValues()
Get current values for assignment from.
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
$_GET["client_id"]
ilObjExerciseGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output=true)
Constructor public.
countMandatory($a_ex_id)
Order assignments by deadline date.
_lookupMark($a_usr_id, $a_obj_id)
This class represents a section header in a property form.
This class represents a file property in a property form.
membersObject()
All participants and submission of one assignment.
updateStatusTimeOfUser($a_ass_id, $a_user_id)
was: updateStatusTimeForMember($a_user_id)
updateMembersObject()
update data of members table
getId()
Get assignment id.
static getFiles($a_exc_id, $a_ass_id)
Get files.
static getPortfoliosOfUser($a_user_id)
Get views of user.
Class ilObjExerciseGUI.
Class ilObject Basic functions for all objects.
addSubmissionSubTabs($a_activate)
adds tabs to tab gui object
$valid
downloadFeedbackFileObject()
Download feedback file.
showMultiFeedbackConfirmationTableObject()
Show multi feedback confirmation table.
addTeamMemberActionObject($a_user_ids=array())
Class ilShopPurchaseGUI.
This class represents a file wizard property in a property form.
Exercise participant table.
updateCustom(ilPropertyFormGUI $a_form)
$cmd
Definition: sahs_server.php:35
initPortfolioTemplateForm(array $a_templates)
deliverFileObject()
Upload files.
saveAssignmentOrderObject()
Save assignments order.
initUploadForm()
Init upload form form.
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
addUserFromAutoCompleteObject()
Add user as member.
getDeadline()
Get deadline (timestamp)
downloadMultiFeedbackZipObject()
Download multi-feedback structrue file.
downloadAllDeliveredFiles($a_exc_id, $a_ass_id, $members)
Download all submitted files of an assignment (all user)
static _tracProgress($a_user_id, $a_obj_id, $a_ref_id, $a_obj_type='')
_isComplete($adapter)
Checks the status of the certificate.
Access handler for personal workspace.
downloadSelectedFiles($a_exc_id, $a_ass_id, $a_user_id, $array_file_id)
was: downloadSelectedFiles($array_file_id,$a_user_id)?
static _lookupId($a_user_str)
lookup id by login
static shortenText($a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
This class represents a checkbox property in a property form.
ilObjectGUI($a_data, $a_id=0, $a_call_by_reference=true, $a_prepare_output=true)
Constructor public.
static _lookupTitle($a_id)
lookup object title
addItem($a_item)
Add Item (Property, SectionHeader).
static writeRatingForUserAndObject($a_obj_id, $a_obj_type, $a_sub_obj_id, $a_sub_obj_type, $a_user_id, $a_rating, $a_category_id=0)
Write rating for a user and an object.
confirmAssignmentsDeletionObject()
Confirm assignments deletion.
saveAssOrderOfExercise($a_ex_id, $a_order)
Save ordering of all assignments of an exercise.
lookupMarkOfUser($a_ass_id, $a_user_id)
Lookup user mark.
getEditFormCustomValues(array &$a_values)
Get values for properties form.
submissionScreenTeamObject()
Displays a form which allows members to manage team uploads.
downloadNewReturnedObject()
Download newly submitted files of user.
const IL_CAL_UNIX
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
deleteAssignmentsObject()
Delete assignments.
_removeUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
Remove usage of mob in another container.
static getNotificationsForObject($type, $id, $page_id=null, $ignore_threshold=false)
Get all users for given object.
Tree handler for personal workspace.
static _goto($a_target, $a_raw)
redirect script
deliverReturnedFiles($a_exc_id, $a_ass_id, $a_user_id, $a_only_new=false, $a_peer_review_mask_filename=false)
was: deliverReturnedFiles($a_member_id, $a_only_new = false)
static getNamePresentation($a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true)
Default behaviour is:
addContentSubTabs($a_activate)
Add subtabs of content view.
updateAssignmentObject()
Update assignment.
This class represents a date/time property in a property form.
downloadObject()
User downloads (own) submitted files.
global $ilCtrl
Definition: ilias.php:18
selectParticipantObject()
Select participant.
showOverviewObject()
Show overview of assignments.
setInfo($a_info)
Set Information Text.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
GUI clas for exercise assignments.
$section
Definition: Utf8Test.php:84
cancelMultiFeedbackObject()
Cancel Multi Feedback.
setTableId($a_val)
Set table id.
List all peers to be reviewed for user.
setChecked($a_checked)
Set Checked.
static getTeamMembersByAssignmentId($a_ass_id, $a_user_id)
Find team members by assignment and team member.
Export User Interface Class.
static checkAccess($a_ref_id, $a_allow_only_read=true)
check access to learning progress
This class represents a hidden form property in a property form.
updateMarkOfUser($a_ass_id, $a_user_id, $a_value)
Update mark.
_saveUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
Save usage of mob within another container (e.g.
This class represents a property in a property form.
infoScreenObject()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually...
handleDisabledAssignmentFields(ilExAssignment $a_ass, ilPropertyFormGUI $a_form)
Class ilRatingGUI.
setTitle($a_title)
Set Title.
$success
Definition: Utf8Test.php:87
updateStatusFeedbackForUser($a_ass_id, $a_user_id, $a_status)
was: setStatusFeedbackForMember($a_member_id,$a_status)
if(!is_array($argv)) $options
hasPeerReviewPersonalized()
Get peer review personalized status.
$mobs
getDeliveredFiles($a_exc_id, $a_ass_id, $a_user_id, $a_filter_empty_filename=false)
was: getDeliveredFiles($a_member_id)
sendMembersObject()
Send assignment per mail to participants.
Class ilObjBlogGUI.
static _exists($a_id)
checks wether a lm content object with specified id exists or not
This class represents a number property in a property form.
static formSelect($selected, $varname, $options, $multiple=false, $direct_text=false, $size="0", $style_class="", $attribs="", $disabled=false)
Builds a select form field with options and shows the selected option first.
List all team members of an assignment.
redirectFeedbackMailObject()
set feedback status for member and redirect to mail screen
Class ilObjectGUI Basic methods of all Output classes.
static _lookupObjId($a_id)
special template class to simplify handling of ITX/PEAR
Class ilObjBlog.
saveAssignmentObject()
Save assignment.
static setNotification($type, $user_id, $id, $status=true)
Set notification status for object and user.
This class represents a text property in a property form.
static formatDate(ilDateTime $date)
Format a date public.
GUI class to create PDF certificates.
createPortfolioTemplateObject(ilPropertyFormGUI $a_form=null)
Date and time handling
downloadReturnedObject()
Download submitted files of user.
removeExistingSubmissions()
remove existing files/submissions for assignment
_writeReturned($a_obj_id, $a_user_id, $a_status)
Write returned status.
_lookupLogin($a_user_id)
lookup login
static getLastSubmission($a_ass_id, $a_user_id)
Get the date of the last submission of a user for the assignment.
updateTutorDownloadTime($a_exc_id, $a_ass_id, $a_user_id)
was: updateTutorDownloadTime($member_id)
static getAvailablePortfolioTemplates($a_permission="read")
setMaxLength($a_maxlength)
Set Max Length.
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
__getDateSelect($a_type, $a_selected)
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
submissionScreenObject()
Displays a form which allows members to deliver their solutions.
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
setOptions($a_options)
Set Options.
$txt
Definition: error.php:10
initZipUploadForm()
Init upload form form.
showGradesOverviewObject()
Show grades overview.
$comment
Definition: buildRTE.php:83
prepareOutput()
prepare output
static _lookupType($a_id, $a_reference=false)
lookup object type
getMandatory()
Get mandatory.
getPeerReviewMin()
Get peer review minimum.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
updateNoticeForUser($a_ass_id, $a_user_id, $a_notice)
was: setNoticeForMember($a_member_id,$a_notice)
static stripSlashesArray($a_arr, $a_strip_html=true, $a_allow="")
Strip slashes from array.
exportExcelObject()
Export as excel.
setSize($a_size)
Set Size.
afterSave(ilObject $a_new_object)
deleteDeliveredFiles($a_exc_id, $a_ass_id, $file_id_array, $a_user_id)
was: deleteDeliveredFiles($file_id_array, $a_member_id)
downloadFileObject()
Download assignment file.
submitPortfolio($a_portfolio_id)
Submit portfolio for assignment.
This class represents a custom property in a property form.
listPublicSubmissionsObject()
List all submissions.
static getInstance()
Get instance.
_lookupComment($a_usr_id, $a_obj_id)
initAssignmentTextForm(ilExAssignment $a_ass, $a_read_only=false, $a_cancel_cmd="showOverview", $a_peer_review_cmd=null, $a_peer_rating_html=null)
initTeamSubmission($a_back_cmd, $a_mandatory_team=true)
__showObjectSelect($a_result, $a_type)
static fillAutoCompleteToolbar($parent_object, ilToolbarGUI $toolbar=null, $a_options=array())
fill toolbar with
saveStatusObject($a_part_view=false, $a_force_all=false)
Save status of selecte members.
downloadAllObject()
Download all submitted files (of all members).
saveGradesObject()
Save grades.
This class represents a non editable value in a property form.
global $ilUser
Definition: imgupload.php:15
orderAssignmentsByDeadlineObject()
Order by deadline.
global $ilSetting
Definition: privfeed.php:40
& _getUsedHTMLTags($a_module="")
Returns an array of all allowed HTML tags for text editing.
setFilenames($a_filenames)
Set filenames.
setAssignmentHeader()
Set assignment header.
setDate($a_date, $a_format)
set date
This class represents a text area property in a property form.
updateAssignmentTextObject($a_return=false)
global $ilDB
getTabs($tabs_gui)
adds tabs to tab gui object
getRefId()
get reference id public
addMembersObject($a_user_ids=array())
Add new partipant.
editAssignmentObject()
Edit assignment.
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
static getTeamIdByAssignment($a_ass_id, $a_user_id)
Find team by assignment.
deleteDeliveredObject()
Delete file(s) submitted by user.
Create PDF certificates.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
hasPeerReviewFileUpload()
Get peer review file upload status.
confirmRemoveTeamMemberObject($a_full_delete=false)
saveStatusParticipantObject()
Save assignment status (participant view)
deliverUnzipObject()
Upload zip file.
updateStatusOfUser($a_ass_id, $a_user_id, $a_status)
was: setStatusForMember($a_member_id,$a_status)
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
File System Explorer GUI class.
showParticipantObject()
Show Participant.
confirmDeassignMembersObject()
Confirm deassigning members.
static redirect($a_script)
http redirect to other script
deassignMembersObject()
Deassign members from exercise.
initEditCustomForm(ilPropertyFormGUI $a_form)
Init properties form.
Accordion user interface class.
addHeaderAction()
Add header action menu.
infoScreen()
show information screen
Exercise participant table.
showMultiFeedbackObject(ilPropertyFormGUI $a_form=null)
Show multi-feedback screen.
uploadFormObject()
Display form for single file upload.
static getAssignmentTeamMap($a_ass_id)
Get team structure for assignment.
setSuffixes($a_suffixes)
Set Accepted Suffixes.
Class ilObjUserTrackingGUI.
sendNotifications($assignment_id)
Send submission notifications.
static getAdoptableTeamAssignments($a_exercise_id, $a_exclude_ass_id=null, $a_user_id=null)
setRequired($a_required)
Set Required.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
static lookupTitle($a_id)
Lookup title.
setShowTime($a_showtime)
Set Show Time Information.
addLocatorItems()
Add locator item.
confirmDeleteDeliveredObject()
Confirm deletion of delivered files.
Confirmation screen class.
Class to report exception.
updateStatusReturnedForUser($a_ass_id, $a_user_id, $a_status)
was: setStatusReturnedForMember($a_member_id,$a_status)