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