ILIAS  Release_4_1_x_branch Revision 61804
 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 "classes/class.ilObjectGUI.php";
6 
20 {
25  function ilObjExerciseGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output = true)
26  {
27  global $lng;
28 
29  $this->type = "exc";
30  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,false);
31 
32  $lng->loadLanguageModule("exercise");
33  $lng->loadLanguageModule("exc");
34  $this->ctrl->saveParameter($this,
35  array("ass_id", "part_id", "fsmode"));
36 
37  if ($_GET["ass_id"] > 0)
38  {
39  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
40  $this->ass = new ilExAssignment((int) $_GET["ass_id"]);
41  }
42  }
43 
44  function getFiles()
45  {
46  return $this->files ? $this->files : array();
47  }
48 
49  function setFiles($a_files)
50  {
51  $this->files = $a_files;
52  }
53 
54  function &executeCommand()
55  {
56  global $ilUser,$ilCtrl, $ilTabs, $lng;
57 
58  $next_class = $this->ctrl->getNextClass($this);
59  $cmd = $this->ctrl->getCmd();
60  $this->prepareOutput();
61 
62 //echo "-".$next_class."-".$cmd."-"; exit;
63  switch($next_class)
64  {
65  case "ilfilesystemgui":
66  $this->checkPermission("write");
67 
68  if ($_GET["fsmode"] == "feedback" ||
69  $_GET["fsmode"] == "feedbackpart") // feedback files
70  {
71  $ilCtrl->saveParameter($this, array("member_id"));
72  //$this->setAssignmentHeader();
73  //$ilTabs->activateTab("ass_files");
74  $ilTabs->clearTargets();
75 
76  if ($_GET["fsmode"] != "feedbackpart")
77  {
78  $ilTabs->setBackTarget($lng->txt("back"),
79  $ilCtrl->getLinkTarget($this, "members"));
80  }
81  else
82  {
83  $ilTabs->setBackTarget($lng->txt("back"),
84  $ilCtrl->getLinkTarget($this, "showParticipant"));
85  }
86  include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
87  $fstorage = new ilFSStorageExercise($this->object->getId(), (int) $_GET["ass_id"]);
88  $fstorage->create();
89  include_once("./classes/class.ilFileSystemGUI.php");
90  $fs_gui = new ilFileSystemGUI($fstorage->getFeedbackPath((int) $_GET["member_id"]));
91  $fs_gui->setTableId("excfbfil".(int)$_GET["ass_id"]."_".(int)$_GET["member_id"]);
92  $fs_gui->setAllowDirectories(false);
93  include_once("./Services/User/classes/class.ilUserUtil.php");
94  $fs_gui->setTitle($lng->txt("exc_fb_files")." - ".
95  ilExAssignment::lookupTitle((int) $_GET["ass_id"])." - ".
96  ilUserUtil::getNamePresentation((int) $_GET["member_id"], false, false, "", true));
97  $pcommand = $fs_gui->getLastPerformedCommand();
98  if ($pcommand["cmd"] == "create_file")
99  {
100  $this->object->sendFeedbackFileNotification($pcommand["name"], (int) $_GET["member_id"],
101  (int) $_GET["ass_id"]);
102  }
103  $ret = $this->ctrl->forwardCommand($fs_gui);
104  }
105  else // assignment files
106  {
107  $this->setAssignmentHeader();
108  $ilTabs->activateTab("ass_files");
109  include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
110  $fstorage = new ilFSStorageExercise($this->object->getId(), (int) $_GET["ass_id"]);
111  $fstorage->create();
112  include_once("./classes/class.ilFileSystemGUI.php");
113  $fs_gui = new ilFileSystemGUI($fstorage->getPath());
114  $fs_gui->setTableId("excassfil".$_GET["ass_id"]);
115  $fs_gui->setAllowDirectories(false);
116  $ret = $this->ctrl->forwardCommand($fs_gui);
117  }
118  break;
119 
120  case "ilinfoscreengui":
121  $ilTabs->activateTab("info");
122  $this->infoScreen(); // forwards command
123  break;
124 
125  case 'ilpermissiongui':
126  $ilTabs->activateTab("permissions");
127  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
128  $perm_gui =& new ilPermissionGUI($this);
129  $ret =& $this->ctrl->forwardCommand($perm_gui);
130  break;
131 
132  case "illearningprogressgui":
133  $ilTabs->activateTab("learning_progress");
134  include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
135 
137  $this->object->getRefId(),
138  $_GET['user_id'] ? $_GET['user_id'] : $ilUser->getId());
139  $this->ctrl->forwardCommand($new_gui);
140  $this->tabs_gui->setTabActive('learning_progress');
141  break;
142 
143  case 'ilrepositorysearchgui':
144  $ilTabs->activateTab("grades");
145  include_once('./Services/Search/classes/class.ilRepositorySearchGUI.php');
146  $rep_search =& new ilRepositorySearchGUI();
147  $rep_search->setCallback($this,'addMembersObject');
148 
149  // Set tabs
150  $this->tabs_gui->setTabActive('members');
151  $this->ctrl->setReturn($this,'members');
152  $ret =& $this->ctrl->forwardCommand($rep_search);
153  #$this->__setSubTabs('members');
154  #$this->tabs_gui->setSubTabActive('members');
155  break;
156 
157  case 'ilobjectcopygui':
158  $ilCtrl->saveParameter($this, 'new_type');
159  $ilCtrl->setReturnByClass(get_class($this),'create');
160 
161  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
162  $cp = new ilObjectCopyGUI($this);
163  $cp->setType('exc');
164  $this->ctrl->forwardCommand($cp);
165  break;
166 
167  case "ilexportgui":
168 // $this->prepareOutput();
169  $ilTabs->activateTab("export");
170  include_once("./Services/Export/classes/class.ilExportGUI.php");
171  $exp_gui = new ilExportGUI($this);
172  $exp_gui->addFormat("xml");
173  $ret = $this->ctrl->forwardCommand($exp_gui);
174 // $this->tpl->show();
175  break;
176 
177  default:
178  if(!$cmd)
179  {
180  $cmd = "infoScreen";
181  }
182 
183  $cmd .= "Object";
184 
185  $this->$cmd();
186 
187  break;
188  }
189 
190  return true;
191  }
192 
193  function createObject($a_reload = false)
194  {
195  global $tpl;
196 
197  $this->getTemplateFile("edit", "exc");
198 
199  if (!$a_reload)
200  {
201  $this->initPropertiesForm("create");
202  }
203  $this->tpl->setVariable("EDIT_FORM", $this->form_gui->getHtml());
204 
205  $this->fillCloneTemplate('DUPLICATE','exc');
206 
207  $this->initImportForm("exc");
208  $this->tpl->setVariable("IMPORT", $this->form->getHTML());
209 
210  }
211 
217  public function initImportForm($a_new_type = "")
218  {
219  global $lng, $ilCtrl;
220 
221  $lng->loadLanguageModule("exc");
222 
223  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
224  $this->form = new ilPropertyFormGUI();
225  $this->form->setTarget("_top");
226 
227  // Import file
228  include_once("./Services/Form/classes/class.ilFileInputGUI.php");
229  $fi = new ilFileInputGUI($lng->txt("import_file"), "importfile");
230  $fi->setSuffixes(array("zip"));
231  $fi->setRequired(true);
232  $this->form->addItem($fi);
233 
234  $this->form->addCommandButton("importFile", $lng->txt("import"));
235  $this->form->addCommandButton("cancel", $lng->txt("cancel"));
236  $this->form->setTitle($lng->txt($a_new_type."_import"));
237  $ilCtrl->setParameter($this, "new_type", $a_new_type);
238 
239  $this->form->setFormAction($ilCtrl->getFormAction($this));
240  }
241 
247  function importFileObject()
248  {
249  global $rbacsystem, $objDefinition, $tpl, $lng;
250 
251  $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
252 
253  // create permission is already checked in createObject. This check here is done to prevent hacking attempts
254  if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
255  {
256  $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->MESSAGE);
257  }
258  $this->ctrl->setParameter($this, "new_type", $new_type);
259  $this->initImportForm($new_type);
260  if ($this->form->checkInput())
261  {
262  // todo: make some check on manifest file
263  include_once("./Services/Export/classes/class.ilImport.php");
264  $imp = new ilImport((int) $_GET['ref_id']);
265  $new_id = $imp->importObject($newObj, $_FILES["importfile"]["tmp_name"],
266  $_FILES["importfile"]["name"], $new_type);
267  // put new object id into tree
268  if ($new_id > 0)
269  {
270  $newObj = ilObjectFactory::getInstanceByObjId($new_id);
271  $newObj->createReference();
272  $newObj->putInTree($_GET["ref_id"]);
273  $newObj->setPermissions($_GET["ref_id"]);
274  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
275  //$this->afterSave($newObj);
276  $this->ctrl->returnToParent($this);
277  }
278  return;
279  }
280 
281  $this->form->setValuesByPost();
282  $tpl->setContent($this->form->getHtml());
283  }
284 
285  function viewObject()
286  {
287  $this->infoScreenObject();
288  }
289 
296  function downloadObject()
297  {
298  global $ilUser, $ilCtrl;
299 
300  $this->checkPermission("read");
301  if (count($_POST["delivered"]))
302  {
303  ilExAssignment::downloadSelectedFiles($this->object->getId(), (int) $_GET["ass_id"],
304  $ilUser->getId(), $_POST["delivered"]);
305  exit;
306  }
307  else
308  {
309  ilUtil::sendFailure($this->lng->txt("please_select_a_delivered_file_to_download"), true);
310  $ilCtrl->redirect($this, "submissionScreen");
311  }
312  }
313 
318  {
319  global $ilCtrl, $tpl, $lng, $ilUser;
320 
321  $this->checkPermission("read");
322 
323  $this->tabs_gui->setTabActive("content");
324  $this->addContentSubTabs("content");
325 
326  if (mktime() > $this->ass->getDeadline())
327  {
328  ilUtil::sendFailure($this->lng->txt("exercise_time_over"), true);
329  $ilCtrl->redirect($this, "submissionScreen");
330  }
331 
332  if (!is_array($_POST["delivered"]) || count($_POST["delivered"]) == 0)
333  {
334  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
335  $ilCtrl->redirect($this, "submissionScreen");
336  }
337  else
338  {
339  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
340  $cgui = new ilConfirmationGUI();
341  $cgui->setFormAction($ilCtrl->getFormAction($this));
342  $cgui->setHeaderText($lng->txt("info_delete_sure"));
343  $cgui->setCancel($lng->txt("cancel"), "submissionScreen");
344  $cgui->setConfirm($lng->txt("delete"), "deleteDelivered");
345 
346  $files = ilExAssignment::getDeliveredFiles($this->object->getId(), (int) $_GET["ass_id"],
347  $ilUser->getId());
348 //var_dump($files);
349  foreach ($_POST["delivered"] as $i)
350  {
351  reset ($files);
352  $title = "";
353  foreach ($files as $f)
354  {
355  if ($f["returned_id"] == $i)
356  {
357  $title = $f["filetitle"];
358  }
359  }
360  $cgui->addItem("delivered[]", $i, $title);
361  }
362 
363  $tpl->setContent($cgui->getHTML());
364  }
365  }
366 
374  {
375  global $ilUser, $ilCtrl;
376 
377  $this->checkPermission("read");
378 
379  if (mktime() > $this->ass->getDeadline())
380  {
381  ilUtil::sendFailure($this->lng->txt("exercise_time_over"), true);
382  $ilCtrl->redirect($this, "submissionScreen");
383  }
384 
385  if (count($_POST["delivered"]) && mktime() < $this->ass->getDeadline())
386  {
387  $this->object->deleteDeliveredFiles($this->object->getId(), (int) $_GET["ass_id"],
388  $_POST["delivered"], $ilUser->id);
389  ilUtil::sendSuccess($this->lng->txt("exc_submitted_files_deleted"), true);
390  }
391  else
392  {
393  ilUtil::sendFailure($this->lng->txt("please_select_a_delivered_file_to_delete"), true);
394  }
395  $ilCtrl->redirect($this, "submissionScreen");
396  }
397 
404  {
405  global $ilUser;
406  require_once "./Services/Utilities/classes/class.ilUtil.php";
407 
408  $this->checkPermission("read");
409 
410  $this->tabs_gui->setTabActive("content");
411  $this->addContentSubTabs("content");
412 
413  if (mktime() > $this->ass->getDeadline())
414  {
415  ilUtil::sendInfo($this->lng->txt("exercise_time_over"));
416  }
417 
418  $this->getTemplateFile("deliver_file", "exc");
419 
420  include_once("./Modules/Exercise/classes/class.ilExcDeliveredFilesTableGUI.php");
421  $tab = new ilExcDeliveredFilesTableGUI($this, "deliver", $this->object, $_GET["ass_id"]);
422  $this->tpl->setVariable("DELIVERED_FILES_TABLE", $tab->getHTML());
423 
424  if (mktime() < $this->ass->getDeadline())
425  {
426  $this->initUploadForm();
427  $this->tpl->setVariable("UPLOAD_SINGLE_FORM", $this->form->getHTML());
428 
429  $this->initZipUploadForm();
430  $this->tpl->setVariable("UPLOAD_MULTI_FORM", $this->form->getHTML());
431  }
432  }
433 
437  public function initUploadForm()
438  {
439  global $lng, $ilCtrl;
440 
441  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
442  $this->form = new ilPropertyFormGUI();
443 
444  // file input
445  include_once("./Services/Form/classes/class.ilFileWizardInputGUI.php");
446  $fi = new ilFileWizardInputGUI($lng->txt("file"), "deliver");
447  $fi->setFilenames(array(0 => ''));
448  //$fi->setInfo($lng->txt(""));
449  $this->form->addItem($fi);
450 
451  $this->form->addCommandButton("deliverFile", $lng->txt("upload"));
452 
453  $this->form->setTitle($lng->txt("file_add"));
454  $this->form->setFormAction($ilCtrl->getFormAction($this));
455  }
456 
460  public function initZipUploadForm()
461  {
462  global $lng, $ilCtrl;
463 
464  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
465  $this->form = new ilPropertyFormGUI();
466 
467  // desc
468  include_once("./Services/Form/classes/class.ilFileInputGUI.php");
469  $fi = new ilFileInputGUI($lng->txt("file"), "deliver");
470  $fi->setSuffixes(array("zip"));
471  $this->form->addItem($fi);
472 
473  $this->form->addCommandButton("deliverUnzip", $lng->txt("upload"));
474 
475  $this->form->setTitle($lng->txt("header_zip"));
476  $this->form->setFormAction($ilCtrl->getFormAction($this));
477  }
478 
482  function deliverFileObject()
483  {
484  global $ilUser, $lng, $ilCtrl;
485 
486  $this->checkPermission("read");
487 
488  $success = false;
489  foreach ($_FILES["deliver"]["name"] as $k => $v)
490  {
491  $file = array(
492  "name" => $_FILES["deliver"]["name"][$k],
493  "type" => $_FILES["deliver"]["type"][$k],
494  "tmp_name" => $_FILES["deliver"]["tmp_name"][$k],
495  "error" => $_FILES["deliver"]["error"][$k],
496  "size" => $_FILES["deliver"]["size"][$k],
497  );
498  if(!$this->object->deliverFile($file, (int) $_GET["ass_id"], $ilUser->id))
499  {
500  ilUtil::sendFailure($this->lng->txt("exc_upload_error"), true);
501  }
502  else
503  {
504  $success = true;
505  }
506  }
507 
508  if($success)
509  {
510  $this->sendNotifications((int)$_GET["ass_id"]);
511  }
512  $ilCtrl->redirect($this, "submissionScreen");
513  }
514 
519  {
520  global $ilCtrl;
521 
522  $this->checkPermission("read");
523 
524  if (preg_match("/zip/",$_FILES["deliver"]["type"]) == 1)
525  {
526  if($this->object->processUploadedFile($_FILES["deliver"]["tmp_name"], "deliverFile", false,
527  (int) $_GET["ass_id"]))
528  {
529  $this->sendNotifications((int)$_GET["ass_id"]);
530  }
531  }
532 
533  $ilCtrl->redirect($this, "submissionScreen");
534  }
535 
540  {
541  global $rbacsystem, $ilUser;
542 
543  $file = ($_POST["file"])
544  ? $_POST["file"]
545  : $_GET["file"];
546 
547  // check read permission
548  $this->checkPermission("read");
549 
550  if (!isset($file))
551  {
552  ilUtil::sendFailure($this->lng->txt("exc_select_one_file"),true);
553  $this->ctrl->redirect($this, "view");
554  }
555 
556  // check, whether file belongs to assignment
557  include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
558  $storage = new ilFSStorageExercise($this->object->getId(), (int) $_GET["ass_id"]);
559  $files = $storage->getFeedbackFiles($ilUser->getId());
560  $file_exist = false;
561  foreach($files as $fb_file)
562  {
563  if($fb_file == urldecode($file))
564  {
565  $file_exist = true;
566  break;
567  }
568  }
569  if(!$file_exist)
570  {
571  echo "FILE DOES NOT EXIST";
572  exit;
573  }
574 
575  // check whether assignment as already started
576  $ass = new ilExAssignment((int) $_GET["ass_id"]);
577  $not_started_yet = false;
578  if ($ass->getStartTime() > 0 && time() - $ass->getStartTime() <= 0)
579  {
580  $not_started_yet = true;
581  }
582 
583  // deliver file
584  if (!$not_started_yet)
585  {
586  $p = $storage->getFeedbackFilePath($ilUser->getId(), urldecode($file));
587  ilUtil::deliverFile($p, urldecode($file));
588  }
589 
590  return true;
591  }
592 
597  {
598  global $rbacsystem;
599 
600  $file = ($_POST["file"])
601  ? $_POST["file"]
602  : $_GET["file"];
603 
604  // check read permission
605  $this->checkPermission("read");
606 
607  if (!isset($file))
608  {
609  ilUtil::sendFailure($this->lng->txt("exc_select_one_file"),true);
610  $this->ctrl->redirect($this, "view");
611  }
612 
613  // check, whether file belongs to assignment
614  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
615  $files = ilExAssignment::getFiles($this->object->getId(), (int) $_GET["ass_id"]);
616  $file_exist = false;
617  foreach($files as $lfile)
618  {
619  if($lfile["name"] == urldecode($file))
620  {
621  $file_exist = true;
622  break;
623  }
624  }
625  if(!$file_exist)
626  {
627  echo "FILE DOES NOT EXIST";
628  exit;
629  }
630 
631  // check whether assignment as already started
632  $ass = new ilExAssignment((int) $_GET["ass_id"]);
633  $not_started_yet = false;
634  if ($ass->getStartTime() > 0 && time() - $ass->getStartTime() <= 0)
635  {
636  $not_started_yet = true;
637  }
638 
639  // deliver file
640  if (!$not_started_yet)
641  {
642  include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
643  $storage = new ilFSStorageExercise($this->object->getId(), (int) $_GET["ass_id"]);
644  $p = $storage->getAssignmentFilePath(urldecode($file));
645  ilUtil::deliverFile($p, urldecode($file));
646  }
647 
648  return true;
649  }
650 
655  function saveObject()
656  {
657  global $rbacadmin;
658 
659  $this->initPropertiesForm("create");
660 
661  if ($this->form_gui->checkInput())
662  {
663  // always call parent method first to create an object_data entry & a reference
664  $newObj = parent::saveObject();
665 
666  // put here your object specific stuff
667 
668  $newObj->setTitle($this->form_gui->getInput("title"));
669  $newObj->setDescription($this->form_gui->getInput("desc"));
670 /* $newObj->setInstruction($this->form_gui->getInput("instruction"));
671  $edit_date =
672  $this->form_gui->getItemByPostVar("edit_date")->getDate();
673  $newObj->setTimestamp($edit_date->get(IL_CAL_UNIX));*/
674 
675  $newObj->saveData();
676  $newObj->update();
677 
678  // always send a message
679  ilUtil::sendSuccess($this->lng->txt("exc_added"),true);
680  ilUtil::redirect("ilias.php?baseClass=ilExerciseHandlerGUI&ref_id=".$newObj->getRefId()."&cmd=addAssignment");
681  }
682  else
683  {
684  $this->form_gui->setValuesByPost();
685  $this->createObject(true);
686  }
687  }
688 
692  function editObject()
693  {
694  global $rbacsystem, $tpl, $ilTabs;
695 
696  $ilTabs->activateTab("settings");
697 
698  $this->checkPermission("write");
699 
700  $this->getTemplateFile("edit", "exc");
701 
702  $this->initPropertiesForm("edit");
703  $this->getPropertiesValues();
704 
705  $this->tpl->setVariable("EDIT_FORM", $this->form_gui->getHtml());
706 
707 /* $this->tpl->setCurrentBlock("FILES");
708  $this->tpl->setVariable("TXT_HEADER_FILE",$this->lng->txt("file_add"));
709  $this->tpl->setVariable("TXT_FILE",$this->lng->txt("file"));
710  $this->tpl->setVariable("TXT_UPLOAD",$this->lng->txt("upload"));
711  $this->tpl->setVariable("FORMACTION_FILE", $this->ctrl->getFormAction($this));
712  $this->tpl->setVariable("TXT_HEADER_ZIP", $this->lng->txt("header_zip"));
713  $this->tpl->setVariable("CMD_FILE_SUBMIT","uploadFile");
714  $this->tpl->parseCurrentBlock();*/
715  }
716 
722  public function initPropertiesForm($a_mode = "create")
723  {
724  global $lng, $ilCtrl;
725 
726  // init form
727  $lng->loadLanguageModule("form");
728  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
729  $this->form_gui = new ilPropertyFormGUI();
730  $this->form_gui->setTableWidth("600px");
731  if ($a_mode == "edit")
732  {
733  $this->form_gui->setTitle($lng->txt("exc_edit_exercise"));
734  }
735  else
736  {
737  $this->form_gui->setTitle($lng->txt("exc_new"));
738  }
739  $this->form_gui->setTitleIcon(ilUtil::getImagePath("icon_exc.gif"));
740  $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
741 
742 
743  // on creation: Type
744  if ($a_mode == "create")
745  {
746  $type_input = new ilHiddenInputGUI("new_type");
747  $type_input->setValue("exc");
748  $this->form_gui->addItem($type_input);
749  }
750 
751  // Title
752  $title_input = new ilTextInputGUI($lng->txt("title"), "title");
753  $title_input->setRequired(true);
754  $title_input->setMaxLength(128);
755  $this->form_gui->addItem($title_input);
756 
757  // Description
758  $desc_input = new ilTextAreaInputGUI($lng->txt("desc"), "desc");
759  $this->form_gui->addItem($desc_input);
760 
761 /* // Work Instructions
762  $desc_input = new ilTextAreaInputGUI($lng->txt("exc_instruction"), "instruction");
763  $this->form_gui->addItem($desc_input);
764 
765  // Edit until...
766  $edit_date = new ilDateTimeInputGUI($lng->txt("exc_edit_until"), "edit_date");
767  //$dt_prop->setDate(new ilDateTime("2006-12-24 15:44:00", IL_CAL_DATETIME);
768  $edit_date->setShowTime(true);
769  //$dt_prop->setInfo("Info text for the start date.");
770  $this->form_gui->addItem($edit_date);*/
771 
772  // files
773  if ($a_mode == "edit")
774  {
775 
776  // show submissions
777  $cb = new ilCheckboxInputGUI($this->lng->txt("exc_show_submissions"), "show_submissions");
778  $cb->setInfo($this->lng->txt("exc_show_submissions_info"));
779  $this->form_gui->addItem($cb);
780 
781  // pass mode
782  $radg = new ilRadioGroupInputGUI($lng->txt("exc_pass_mode"), "pass_mode");
783  $radg->setValue("all");
784  $op1 = new ilRadioOption($lng->txt("exc_pass_all"), "all",
785  $lng->txt("exc_pass_all_info"));
786  $radg->addOption($op1);
787  $op2 = new ilRadioOption($lng->txt("exc_pass_minimum_nr"), "nr",
788  $lng->txt("exc_pass_minimum_nr_info"));
789  $radg->addOption($op2);
790 
791  // minimum number of assignments to pass
792  $ni = new ilNumberInputGUI($lng->txt("exc_min_nr"), "pass_nr");
793  $ni->setSize(4);
794  $ni->setMaxLength(4);
795  $ni->setRequired(true);
796  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
797  $mand = ilExAssignment::countMandatory($this->object->getId());
798  $min = max($mand, 1);
799  $ni->setMinValue($min);
800  $op2->addSubItem($ni);
801 
802  $this->form_gui->addItem($radg);
803 
804 
805  $cbox = new ilCheckboxInputGUI($lng->txt("exc_submission_notification"), "notification");
806  $cbox->setInfo($lng->txt("exc_submission_notification_info"));
807  $this->form_gui->addItem($cbox);
808 
809 
810 /* if(count($files = $this->object->getFiles()))
811  {
812  // Files section header
813  $files_head = new ilFormSectionHeaderGUI();
814  $files_head->setTitle($lng->txt("files"));
815  $this->form_gui->addItem($files_head);
816 
817  foreach($files as $file)
818  {
819  $i++;
820  $file_cb = new ilCheckboxInputGUI($this->lng->txt("exc_ask_delete"),
821  "delete_file_".$i);
822  $file_cb->setOptionTitle($file["name"]);
823  $file_cb->setValue($file["name"]);
824  $this->form_gui->addItem($file_cb);
825  }
826  }
827 */
828  }
829 
830  // save and cancel commands
831  if ($a_mode == "create")
832  {
833  $this->form_gui->addCommandButton("save", $lng->txt("save"));
834  $this->form_gui->addCommandButton("cancel", $lng->txt("cancel"));
835  }
836  else
837  {
838  $this->form_gui->addCommandButton("update", $lng->txt("save"));
839  $this->form_gui->addCommandButton("cancelEdit", $lng->txt("cancel"));
840  }
841  }
842 
847  {
848  global $ilUser;
849 
850  $values["title"] = $this->object->getTitle();
851  $values["desc"] = $this->object->getLongDescription();
852  $values["pass_mode"] = $this->object->getPassMode();
853  $values["show_submissions"] = $this->object->getShowSubmissions();
854 
855  if ($this->object->getPassMode() == "nr")
856  {
857  $values["pass_nr"] = $this->object->getPassNr();
858  }
859 // $values["instruction"] = $this->object->getInstruction();
860 
861  include_once "./Services/Notification/classes/class.ilNotification.php";
862  $values["notification"] = ilNotification::hasNotification(ilNotification::TYPE_EXERCISE_SUBMISSION, $ilUser->getId(), $this->object->getId());
863 
864  $this->form_gui->setValuesByArray($values);
865 
866 
867 //echo "-".$this->object->getTimestamp()."-";
868 /* $edit_date = new ilDateTime($this->object->getTimestamp(), IL_CAL_UNIX);
869  $ed_item = $this->form_gui->getItemByPostVar("edit_date");
870  $ed_item->setDate($edit_date);*/
871  }
872 
876  function updateObject()
877  {
878  global $rbacsystem, $tpl, $ilUser;
879 
880  $this->checkPermission("write");
881 
882  $this->initPropertiesForm("edit");
883  if ($this->form_gui->checkInput())
884  {
885  $this->object->setTitle($this->form_gui->getInput("title"));
886  $this->object->setDescription($this->form_gui->getInput("desc"));
887  $this->object->setPassMode($this->form_gui->getInput("pass_mode"));
888  $this->object->setShowSubmissions($this->form_gui->getInput("show_submissions"));
889  if ($this->object->getPassMode() == "nr")
890  {
891  $this->object->setPassNr($this->form_gui->getInput("pass_nr"));
892  }
893 
894 /* $this->object->setInstruction($this->form_gui->getInput("instruction"));
895  $edit_date =
896  $this->form_gui->getItemByPostVar("edit_date")->getDate();
897  $this->object->setTimestamp($edit_date->get(IL_CAL_UNIX));*/
898 
899  // delete files
900 /* $del_files = array();
901  foreach ($_POST as $k => $v)
902  {
903  if (substr($k, 0, 12) == "delete_file_" && $v != "")
904  {
905  $del_files[] = $v;
906  }
907  }
908 
909  $this->object->deleteFiles($del_files);*/
910 
911  $this->object->update();
912 
913  include_once "./Services/Notification/classes/class.ilNotification.php";
914  ilNotification::setNotification(ilNotification::TYPE_EXERCISE_SUBMISSION, $ilUser->getId(), $this->object->getId(), (bool)$this->form_gui->getInput("notification"));
915 
916  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
917  $this->ctrl->redirect($this, "edit");
918  }
919  else
920  {
921  $this->form_gui->setValuesByPost();
922  $tpl->setContent($this->form_gui->getHTML());
923  }
924 
925  return;
926 
927  $this->object->setInstruction(ilUtil::stripSlashes($_POST["Fobject"]["instruction"]));
928  $this->object->setDate($_POST["d_hour"],$_POST["d_minutes"],$_POST["d_day"],
929  $_POST["d_month"],$_POST["d_year"]);
930  if($_POST["delete_file"])
931  {
932  $this->object->deleteFiles($_POST["delete_file"]);
933  }
934 
935  $this->object->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));
936  $this->object->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
937  $this->update = $this->object->update();
938 
939  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
940 
941  $this->ctrl->redirect($this, "edit");
942  }
943 
944  function cancelEditObject()
945  {
946  $this->ctrl->redirect($this, "view");
947  }
948 
949  function uploadZipObject()
950  {
951  global $rbacsystem;
952 
953  $this->checkPermission("write");
954 
955  if(!$this->object->addUploadedFile($_FILES["zipfile"], true))
956  {
957  ilUtil::sendFailure($this->lng->txt("exc_upload_error"),true);
958  }
959  $this->ctrl->redirect($this, "edit");
960 
961  }
962 
963  function uploadFileObject()
964  {
965  global $rbacsystem;
966 
967  $this->checkPermission("write");
968 
969  if(!$this->object->addUploadedFile($_FILES["file"]))
970  {
971  ilUtil::sendFailure($this->lng->txt("exc_upload_error"),true);
972  }
973  $this->ctrl->redirect($this, "edit");
974  }
975 
976 
981  {
982  global $rbacsystem;
983 
984  $this->checkPermission("write");
985 
986  if ($_POST["downloadReturned"])
987  {
988  $this->object->members_obj->deliverReturnedFiles(key($_POST["downloadReturned"]));
989  exit;
990  }
991  else
992  {
993  switch($_POST["action"])
994  {
995  case "save_status":
996  $this->saveStatusObject();
997  break;
998 
999  case "send_member":
1000  $this->sendMembersObject();
1001  break;
1002 
1003  case "redirectFeedbackMail":
1004  $this->redirectFeedbackMailObject();
1005  break;
1006 
1007  case "delete_member":
1008  $this->deassignMembersObject();
1009  break;
1010  }
1011  }
1012  }
1013 
1018  {
1019  global $ilAccess;
1020 
1021  if ($ilAccess->checkAccess("read", "", $this->object->getRefId()) &&
1022  $this->object->getShowSubmissions() &&
1023  $this->object->getTimestamp() - time() <= 0)
1024  {
1025  // ok: read access + public submissions
1026  }
1027  else
1028  {
1029  $this->checkPermission("write");
1030  }
1031 
1033  $this->object->getId(), (int) $_GET["ass_id"], (int) $_GET["member_id"]))
1034  {
1035  $this->ctrl->redirect($this, "members");
1036  }
1037  exit;
1038  }
1039 
1044  {
1045  $this->checkPermission("write");
1046 
1048  $this->object->getId(), (int) $_GET["ass_id"], (int) $_GET["member_id"], true))
1049  {
1050  $this->ctrl->redirect($this, "members");
1051  }
1052  exit;
1053  }
1054 
1058  function addMembersObject()
1059  {
1060  global $ilAccess,$ilErr;
1061 
1062  $this->checkPermission("write");
1063  if(!count($_POST['user']))
1064  {
1065  ilUtil::sendFailure($this->lng->txt("no_checkbox"));
1066  return false;
1067  }
1068 
1069  if(!$this->object->members_obj->assignMembers($_POST["user"]))
1070  {
1071  ilUtil::sendFailure($this->lng->txt("exc_members_already_assigned"));
1072  return false;
1073  }
1074  else
1075  {
1076  ilUtil::sendSuccess($this->lng->txt("exc_members_assigned"),true);
1077  }
1078 //exit;
1079  $this->ctrl->redirect($this, "members");
1080  return false;
1081  }
1082 
1083 
1087  function membersObject()
1088  {
1089  global $rbacsystem, $tree, $tpl, $ilToolbar, $ilCtrl, $ilTabs;
1090 
1091  $ilTabs->activateTab("grades");
1092 
1093  include_once 'Services/Tracking/classes/class.ilLPMarks.php';
1094 
1095  $this->checkPermission("write");
1096  $this->addSubmissionSubTabs("assignment");
1097 
1098  // assignment selection
1099  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
1100  $ass = ilExAssignment::getAssignmentDataOfExercise($this->object->getId());
1101 
1102  if ($_GET["ass_id"] == "")
1103  {
1104  $a = current($ass);
1105  $_GET["ass_id"] = $a["id"];
1106  }
1107 
1108  reset($ass);
1109  if (count($ass) > 1)
1110  {
1111  $options = array();
1112  foreach ($ass as $a)
1113  {
1114  $options[$a["id"]] = $a["title"];
1115  }
1116  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
1117  $si = new ilSelectInputGUI($this->lng->txt(""), "ass_id");
1118  $si->setOptions($options);
1119  $si->setValue($_GET["ass_id"]);
1120  $ilToolbar->addInputItem($si);
1121 
1122  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
1123  $ilToolbar->addFormButton($this->lng->txt("exc_select_ass"),
1124  "selectAssignment");
1125  $ilToolbar->addSeparator();
1126  }
1127 
1128  // add member
1129  $ilToolbar->addButton($this->lng->txt("exc_add_participant"),
1130  $this->ctrl->getLinkTargetByClass('ilRepositorySearchGUI','start'));
1131 
1132  // add course members button, in case the exercise is inside a course
1133  $parent_id = $tree->getParentId($_GET["ref_id"]);
1134  $parent_obj_id = ilObject::_lookupObjId($parent_id);
1135  $type = ilObject::_lookupType($parent_obj_id);
1136  while ($parent_id != 1 && $type != "crs")
1137  {
1138  $parent_id = $tree->getParentId($parent_id);
1139  $parent_obj_id = ilObject::_lookupObjId($parent_id);
1140  $type = ilObject::_lookupType($parent_obj_id);
1141  }
1142  if ($type == "crs")
1143  {
1144  $this->ctrl->setParameterByClass('ilRepositorySearchGUI', "list_obj", $parent_obj_id);
1145  $this->lng->loadLanguageModule("exercise");
1146 
1147  $ilToolbar->addButton($this->lng->txt("exc_crs_add_members"),
1148  $this->ctrl->getLinkTargetByClass('ilRepositorySearchGUI','listUsers'));
1149  }
1150 
1151  if (count($ass) > 0)
1152  {
1153  include_once("./Modules/Exercise/classes/class.ilExerciseMemberTableGUI.php");
1154  $exc_tab = new ilExerciseMemberTableGUI($this, "members", $this->object, $_GET["ass_id"]);
1155  $tpl->setContent($exc_tab->getHTML());
1156  }
1157  else
1158  {
1159  ilUtil::sendInfo("exc_no_assignments_available");
1160  }
1161  return;
1162  }
1163 
1168  {
1169  global $ilTabs;
1170 
1171  $ilTabs->activateTab("grades");
1172 
1173  $_GET["ass_id"] = ilUtil::stripSlashes($_POST["ass_id"]);
1174  $this->membersObject();
1175  }
1176 
1181  {
1182  global $rbacsystem, $tree, $tpl, $ilToolbar, $ilCtrl, $ilTabs, $lng;
1183 
1184  $this->checkPermission("write");
1185 
1186  $ilTabs->activateTab("grades");
1187  $this->addSubmissionSubTabs("participant");
1188 
1189  // participant selection
1190  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
1191  $ass = ilExAssignment::getAssignmentDataOfExercise($this->object->getId());
1192  $members = $this->object->members_obj->getMembers();
1193 
1194  if (count($members) == 0)
1195  {
1196  ilUtil::sendInfo($lng->txt("exc_no_participants"));
1197  return;
1198  }
1199 
1200  $mems = array();
1201  foreach ($members as $mem_id)
1202  {
1203  if (ilObject::_lookupType($mem_id) == "usr")
1204  {
1205  include_once("./Services/User/classes/class.ilObjUser.php");
1206  $name = ilObjUser::_lookupName($mem_id);
1207  $mems[$mem_id] = $name;
1208  }
1209  }
1210 
1211  $mems = ilUtil::sortArray($mems, "lastname", "asc", false, true);
1212 
1213  if ($_GET["part_id"] == "" && count($mems) > 0)
1214  {
1215  $_GET["part_id"] = key($mems);
1216  }
1217 
1218  reset($mems);
1219  if (count($mems) > 1)
1220  {
1221  $options = array();
1222  foreach ($mems as $k => $m)
1223  {
1224  $options[$k] =
1225  $m["lastname"].", ".$m["firstname"]." [".$m["login"]."]";
1226  }
1227  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
1228  $si = new ilSelectInputGUI($this->lng->txt(""), "part_id");
1229  $si->setOptions($options);
1230  $si->setValue($_GET["part_id"]);
1231  $ilToolbar->addInputItem($si);
1232 
1233  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
1234  $ilToolbar->addFormButton($this->lng->txt("exc_select_part"),
1235  "selectParticipant");
1236  }
1237 
1238  if (count($mems) > 0)
1239  {
1240  include_once("./Modules/Exercise/classes/class.ilExParticipantTableGUI.php");
1241  $part_tab = new ilExParticipantTableGUI($this, "showParticipant",
1242  $this->object, $_GET["part_id"]);
1243  $tpl->setContent($part_tab->getHTML());
1244  }
1245  else
1246  {
1247  ilUtil::sendInfo("exc_no_assignments_available");
1248  }
1249  }
1250 
1255  {
1256  global $ilTabs;
1257 
1258  $ilTabs->activateTab("grades");
1259 
1260  $_GET["part_id"] = ilUtil::stripSlashes($_POST["part_id"]);
1261  $this->showParticipantObject();
1262  }
1263 
1268  {
1269  global $rbacsystem, $tree, $tpl, $ilToolbar, $ilCtrl, $ilTabs, $lng;
1270 
1271  $this->checkPermission("write");
1272 
1273  $ilTabs->activateTab("grades");
1274  $this->addSubmissionSubTabs("grades");
1275 
1276  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
1277  $mem_obj = new ilExerciseMembers($this->object);
1278  $mems = $mem_obj->getMembers();
1279 
1280  if (count($mems) > 0)
1281  {
1282  $ilToolbar->addButton($lng->txt("exc_export_excel"),
1283  $ilCtrl->getLinkTarget($this, "exportExcel"));
1284  }
1285 
1286  include_once("./Modules/Exercise/classes/class.ilExGradesTableGUI.php");
1287  $grades_tab = new ilExGradesTableGUI($this, "showGradesOverview",
1288  $this->object, $mem_obj);
1289  $tpl->setContent($grades_tab->getHTML());
1290  }
1291 
1296  {
1297  $this->checkPermission("write");
1298 
1299  if ($_GET["member_id"] != "")
1300  {
1301  ilExAssignment::updateStatusFeedbackForUser((int) $_GET["ass_id"], (int) $_GET["member_id"], 1);
1302  $login = ilObjUser::_lookupLogin((int) $_GET["member_id"]);
1303 
1304  require_once 'Services/Mail/classes/class.ilMailFormCall.php';
1305  ilUtil::redirect(ilMailFormCall::_getRedirectTarget($this, 'members', array(), array('type' => 'new', 'rcp_to' => urlencode($login))));
1306  }
1307  else if(count($_POST["member"]) > 0)
1308  {
1309  include_once('./Services/User/classes/class.ilObjUser.php');
1310  $logins = array();
1311  foreach($_POST["member"] as $member => $val)
1312  {
1313  $logins[] = ilObjUser::_lookupLogin($member);
1314  ilExAssignment::updateStatusFeedbackForUser((int) $_GET["ass_id"], $member, 1);
1315  }
1316  $logins = implode($logins, ",");
1317 
1318  require_once 'Services/Mail/classes/class.ilMailFormCall.php';
1319  ilUtil::redirect(ilMailFormCall::_getRedirectTarget($this, 'members', array(), array('type' => 'new', 'rcp_to' => $logins)));
1320  }
1321 
1322  ilUtil::sendFailure($this->lng->txt("no_checkbox"),true);
1323  $this->ctrl->redirect($this, "members");
1324  }
1325 
1330  {
1331  $this->checkPermission("write");
1332 
1333  $members = array();
1334 
1335  foreach($this->object->members_obj->getMembers() as $member_id)
1336  {
1337  // update download time
1338  ilExAssignment::updateTutorDownloadTime($this->object->getId(),
1339  (int) $_GET["ass_id"], $member_id);
1340 
1341  // get member object (ilObjUser)
1342  if (ilObject::_exists($member_id))
1343  {
1344  $tmp_obj =& ilObjectFactory::getInstanceByObjId($member_id);
1345  $members[$member_id] = $tmp_obj->getFirstname() . " " . $tmp_obj->getLastname();
1346  unset($tmp_obj);
1347  }
1348  }
1349 
1350  ilExAssignment::downloadAllDeliveredFiles($this->object->getId(),
1351  (int) $_GET["ass_id"], $members);
1352  exit;
1353  }
1354 
1355 
1356  function __getMembersOfObject($a_result,$a_type)
1357  {
1358 
1359  switch($a_type)
1360  {
1361  case "usr":
1362  return $a_result;
1363  case "grp":
1364  include_once "./Modules/Group/classes/class.ilObjGroup.php";
1365 
1366  $all_members = array();
1367  foreach($a_result as $group)
1368  {
1369  $tmp_grp_obj = ilObjectFactory::getInstanceByRefId($group["id"]);
1370 
1371  $members = $tmp_grp_obj->getGroupMemberIds();
1372  $all_members = array_merge($all_members,$members);
1373  }
1374  // FORMAT ARRAY
1375  $all_members = array_unique($all_members);
1376  foreach($all_members as $member)
1377  {
1378  $result[] = array("id" => $member);
1379  }
1380  return $result;
1381  }
1382  return true;
1383  }
1384 
1385  function __showObjectSelect($a_result,$a_type)
1386  {
1387  include_once "./classes/class.ilObjectFactory.php";
1388 
1389  foreach($a_result as $obj)
1390  {
1391  $tmp_obj =& ilObjectFactory::getInstanceByRefId($obj["id"]);
1392  $this->tpl->setCurrentBlock("OBJ_SELECT_ROW");
1393  $this->tpl->setVariable("OBJ_ROW_TITLE",$tmp_obj->getTitle());
1394  $this->tpl->setVariable("OBJ_ROW_ID",$tmp_obj->getRefId());
1395  $this->tpl->setVariable("OBJ_ROW_DESCRIPTION",$tmp_obj->getDescription());
1396  $this->tpl->parseCurrentBlock();
1397 
1398  unset($tmp_obj);
1399  }
1400  $this->tpl->setCurrentBlock("OBJ_SELECT");
1401  $this->tpl->setVariable("OBJ_SELECT_TITLE",$this->lng->txt("title"));
1402  $this->tpl->setVariable("OBJ_SELECT_DESCRIPTION",$this->lng->txt("description"));
1403 
1404  $this->tpl->setVariable("OBJ_BTN1_VALUE",$this->lng->txt("select"));
1405  $this->tpl->setVariable("OBJ_BTN2_VALUE",$this->lng->txt("cancel"));
1406  $this->tpl->parseCurrentBlock();
1407  }
1408 
1413  {
1414  global $ilCtrl;
1415 
1416  $this->checkPermission("write");
1417 
1418  if(!count($_POST["member"]))
1419  {
1420  ilUtil::sendFailure($this->lng->txt("no_checkbox"),true);
1421  }
1422  else
1423  {
1424  $this->object->sendAssignment($this->object->getId(),
1425  (int) $_GET["ass_id"], $_POST["member"]);
1426  ilUtil::sendSuccess($this->lng->txt("exc_sent"),true);
1427  }
1428  $ilCtrl->redirect($this, "members");
1429  }
1430 
1435  {
1436  global $ilCtrl, $tpl, $lng, $ilTabs;
1437 
1438  $this->checkPermission("write");
1439  $ilTabs->activateTab("grades");
1440 
1441  if (!is_array($_POST["member"]) || count($_POST["member"]) == 0)
1442  {
1443  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
1444  $ilCtrl->redirect($this, "members");
1445  }
1446  else
1447  {
1448  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1449  $cgui = new ilConfirmationGUI();
1450  $cgui->setFormAction($ilCtrl->getFormAction($this));
1451  $cgui->setHeaderText($lng->txt("exc_msg_sure_to_deassign_participant"));
1452  $cgui->setCancel($lng->txt("cancel"), "members");
1453  $cgui->setConfirm($lng->txt("remove"), "deassignMembers");
1454 
1455  include_once("./Services/User/classes/class.ilUserUtil.php");
1456  foreach ($_POST["member"] as $k => $m)
1457  {
1458  $cgui->addItem("member[$k]", $m,
1459  ilUserUtil::getNamePresentation((int) $k, false, false, "", true));
1460  }
1461 
1462  $tpl->setContent($cgui->getHTML());
1463  }
1464  }
1465 
1470  {
1471  global $ilCtrl, $lng;
1472 
1473  $this->checkPermission("write");
1474 
1475  if(is_array($_POST["member"]))
1476  {
1477  foreach($_POST["member"] as $usr_id => $member)
1478  {
1479  $this->object->members_obj->deassignMember($usr_id);
1480  }
1481  ilUtil::sendSuccess($lng->txt("exc_msg_participants_removed"), true);
1482  $ilCtrl->redirect($this, "members");
1483  }
1484  else
1485  {
1486  ilUtil::sendFailure($this->lng->txt("no_checkbox"),true);
1487  $ilCtrl->redirect($this, "members");
1488  }
1489  }
1490 
1492  {
1493  $this->checkPermission("write");
1494 
1495  if(!isset($_POST['comments_value']))
1496  {
1497  continue;
1498  }
1499 
1500  $this->object->members_obj->setNoticeForMember($_GET["member_id"],
1501  ilUtil::stripSlashes($_POST["comments_value"]));
1502  ilUtil::sendSuccess($this->lng->txt("exc_members_comments_saved"));
1503  $this->membersObject();
1504  }
1505 
1506 
1511  {
1512  $this->saveStatusObject(true);
1513  }
1514 
1515 
1519  function saveStatusObject($a_part_view = false)
1520  {
1521  global $ilCtrl;
1522 
1523  $this->checkPermission("write");
1524 
1525  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
1526 
1527 // include_once 'Services/Tracking/classes/class.ilLPMarks.php';
1528 
1529  $saved_for = array();
1530 
1531  foreach($_POST["id"] as $key => $value)
1532  {
1533  if (!$a_part_view)
1534  {
1535  if (count($_POST["member"]) > 0 && $_POST["member"][$key] != "1")
1536  {
1537  continue;
1538  }
1539  else
1540  {
1541  if (count($_POST["member"]) > 0)
1542  {
1543  $uname = ilObjUser::_lookupName($key);
1544  $saved_for[] = $uname["lastname"].", ".$uname["firstname"];
1545  }
1546  }
1547  }
1548  if (!$a_part_view)
1549  {
1550  $ass_id = (int) $_GET["ass_id"];
1551  $user_id = (int) $key;
1552  }
1553  else
1554  {
1555  $ass_id = (int) $key;
1556  $user_id = (int) $_GET["part_id"];
1557  }
1558  ilExAssignment::updateStatusOfUser($ass_id, $user_id,
1559  ilUtil::stripSlashes($_POST["status"][$key]));
1560  ilExAssignment::updateNoticeForUser($ass_id, $user_id,
1561  ilUtil::stripSlashes($_POST["notice"][$key]));
1562 
1563  if (ilUtil::stripSlashes($_POST['mark'][$key]) !=
1564  ilExAssignment::lookupMarkOfUser($ass_id, $user_id))
1565  {
1566  ilExAssignment::updateStatusTimeOfUser($ass_id, $user_id);
1567  }
1568 
1569  ilExAssignment::updateMarkOfUser($ass_id, $user_id,
1570  ilUtil::stripSlashes($_POST['mark'][$key]));
1571  ilExAssignment::updateCommentForUser($ass_id, $user_id,
1572  ilUtil::stripSlashes($_POST['lcomment'][$key]));
1573 
1574  }
1575  if (count($saved_for) > 0)
1576  {
1577  $save_for_str = "(".implode($saved_for, " - ").")";
1578  }
1579  ilUtil::sendSuccess($this->lng->txt("exc_status_saved")." ".$save_for_str,true);
1580  if (!$a_part_view)
1581  {
1582  $ilCtrl->redirect($this, "members");
1583  }
1584  else
1585  {
1586  $ilCtrl->redirect($this, "showParticipant");
1587  }
1588  }
1589 
1590  function __getDateSelect($a_type,$a_selected)
1591  {
1592  switch($a_type)
1593  {
1594  case "hour":
1595  for($i=0; $i<24; $i++)
1596  {
1597  $hours[$i] = $i < 10 ? "0".$i : $i;
1598  }
1599  return ilUtil::formSelect($a_selected,"d_hour",$hours,false,true);
1600 
1601  case "minutes":
1602  for($i=0;$i<60;$i++)
1603  {
1604  $minutes[$i] = $i < 10 ? "0".$i : $i;
1605  }
1606  return ilUtil::formSelect($a_selected,"d_minutes",$minutes,false,true);
1607 
1608  case "day":
1609  for($i=1; $i<32; $i++)
1610  {
1611  $days[$i] = $i < 10 ? "0".$i : $i;
1612  }
1613  return ilUtil::formSelect($a_selected,"d_day",$days,false,true);
1614 
1615  case "month":
1616  for($i=1; $i<13; $i++)
1617  {
1618  $month[$i] = $i < 10 ? "0".$i : $i;
1619  }
1620  return ilUtil::formSelect($a_selected,"d_month",$month,false,true);
1621 
1622  case "year":
1623  for($i = date("Y",time());$i < date("Y",time()) + 3;++$i)
1624  {
1625  $year[$i] = $i;
1626  }
1627  return ilUtil::formSelect($a_selected,"d_year",$year,false,true);
1628  }
1629  }
1630 
1631  function __filterAssignedUsers($a_result)
1632  {
1633  foreach($a_result as $user)
1634  {
1635  if(!$this->object->members_obj->isAssigned($user["id"]))
1636  {
1637  $filtered[] = $user;
1638  }
1639  }
1640 
1641  return $filtered ? $filtered : array();
1642  }
1643 
1649  function addSubmissionSubTabs($a_activate)
1650  {
1651  global $ilTabs, $lng, $ilCtrl;
1652 
1653  $ilTabs->addSubTab("assignment", $lng->txt("exc_assignment_view"),
1654  $ilCtrl->getLinkTarget($this, "members"));
1655  $ilTabs->addSubTab("participant", $lng->txt("exc_participant_view"),
1656  $ilCtrl->getLinkTarget($this, "showParticipant"));
1657  $ilTabs->addSubTab("grades", $lng->txt("exc_grades_overview"),
1658  $ilCtrl->getLinkTarget($this, "showGradesOverview"));
1659  $ilTabs->activateSubTab($a_activate);
1660  }
1661 
1667  function addContentSubTabs($a_activate)
1668  {
1669  global $ilTabs, $lng, $ilCtrl, $ilAccess;
1670 
1671  $ilTabs->addSubTab("content", $lng->txt("view"),
1672  $ilCtrl->getLinkTarget($this, "showOverview"));
1673  if ($ilAccess->checkAccess("write", "", $this->ref_id))
1674  {
1675  $ilTabs->addSubTab("list_assignments", $lng->txt("edit"),
1676  $ilCtrl->getLinkTarget($this, "listAssignments"));
1677  }
1678  $ilTabs->activateSubTab($a_activate);
1679  }
1680 
1681 
1687  function getTabs($tabs_gui)
1688  {
1689  global $ilAccess, $ilUser, $lng;
1690 
1691  if ($ilAccess->checkAccess("read", "", $this->object->getRefId()))
1692  {
1693  $tabs_gui->addTab("content",
1694  $lng->txt("exc_assignments"),
1695  $this->ctrl->getLinkTarget($this, "showOverview"));
1696  }
1697 
1698  $next_class = strtolower($this->ctrl->getNextClass());
1699  if ($ilAccess->checkAccess("visible", "", $this->object->getRefId()))
1700  {
1701  $tabs_gui->addTab("info",
1702  $lng->txt("info_short"),
1703  $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary"));
1704  }
1705 
1706  // edit properties
1707  if ($ilAccess->checkAccess("write", "", $this->ref_id))
1708  {
1709  /*$tabs_gui->addTab("assignments",
1710  $lng->txt("exc_edit_assignments"),
1711  $this->ctrl->getLinkTarget($this, 'listAssignments'));*/
1712 
1713  $tabs_gui->addTab("settings",
1714  $lng->txt("settings"),
1715  $this->ctrl->getLinkTarget($this, 'edit'));
1716 
1717  $tabs_gui->addTab("grades",
1718  $lng->txt("exc_submissions_and_grades"),
1719  $this->ctrl->getLinkTarget($this, 'members'));
1720  }
1721 
1722  // learning progress
1723  $save_sort_order = $_GET["sort_order"]; // hack, because exercise sort parameters
1724  $save_sort_by = $_GET["sort_by"]; // must not be forwarded to learning progress
1725  $save_offset = $_GET["offset"];
1726  $_GET["offset"] = $_GET["sort_by"] = $_GET["sort_order"] = "";
1727 
1728  include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
1729  if(ilLearningProgressAccess::checkAccess($this->object->getRefId()))
1730  {
1731  $tabs_gui->addTab('learning_progress',
1732  $lng->txt('learning_progress'),
1733  $this->ctrl->getLinkTargetByClass(array('ilobjexercisegui','illearningprogressgui'),''));
1734  }
1735 
1736  $_GET["sort_order"] = $save_sort_order; // hack, part ii
1737  $_GET["sort_by"] = $save_sort_by;
1738  $_GET["offset"] = $save_offset;
1739 
1740  // export
1741  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
1742  {
1743  $tabs_gui->addTab("export",
1744  $lng->txt("export"),
1745  $this->ctrl->getLinkTargetByClass("ilexportgui", ""));
1746  }
1747 
1748 
1749  // permissions
1750  if ($ilAccess->checkAccess("edit_permission", "", $this->ref_id))
1751  {
1752  $tabs_gui->addTab('permissions',
1753  $lng->txt("perm_settings"),
1754  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"));
1755  }
1756  }
1757 
1763  function infoScreenObject()
1764  {
1765  $this->ctrl->setCmd("showSummary");
1766  $this->ctrl->setCmdClass("ilinfoscreengui");
1767  $this->infoScreen();
1768  }
1769 
1773  function infoScreen()
1774  {
1775  global $ilAccess, $ilUser, $ilTabs, $lng;
1776 
1777  $ilTabs->activateTab("info");
1778 
1779  $this->checkPermission("visible");
1780 
1781  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
1782  $info = new ilInfoScreenGUI($this);
1783 
1784  $info->enablePrivateNotes();
1785 
1786  $info->enableNews();
1787  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
1788  {
1789  $info->enableNewsEditing();
1790  $info->setBlockProperty("news", "settings", true);
1791  }
1792 
1793  // standard meta data
1794  //$info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
1795 
1796  // instructions
1797  $info->addSection($this->lng->txt("exc_overview"));
1798  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
1799  $ass = ilExAssignment::getAssignmentDataOfExercise($this->object->getId());
1800  $cnt = 0;
1801  $mcnt = 0;
1802  foreach ($ass as $a)
1803  {
1804  $cnt++;
1805  if ($a["mandatory"])
1806  {
1807  $mcnt++;
1808  }
1809  }
1810  $info->addProperty($lng->txt("exc_assignments"), $cnt);
1811  $info->addProperty($lng->txt("exc_mandatory"), $mcnt);
1812  if ($this->object->getPassMode() != "nr")
1813  {
1814  $info->addProperty($lng->txt("exc_pass_mode"),
1815  $lng->txt("exc_msg_all_mandatory_ass"));
1816  }
1817  else
1818  {
1819  $info->addProperty($lng->txt("exc_pass_mode"),
1820  sprintf($lng->txt("exc_msg_min_number_ass"), $this->object->getPassNr()));
1821  }
1822 
1823  // feedback from tutor
1824  include_once("Services/Tracking/classes/class.ilLPMarks.php");
1825  if ($ilAccess->checkAccess("read", "", $this->ref_id))
1826  {
1827  $lpcomment = ilLPMarks::_lookupComment($ilUser->getId(), $this->object->getId());
1828  $mark = ilLPMarks::_lookupMark($ilUser->getId(), $this->object->getId());
1829  //$status = ilExerciseMembers::_lookupStatus($this->object->getId(), $ilUser->getId());
1830  $st = $this->object->determinStatusOfUser($ilUser->getId());
1831  $status = $st["overall_status"];
1832  if ($lpcomment != "" || $mark != "" || $status != "notgraded")
1833  {
1834  $info->addSection($this->lng->txt("exc_feedback_from_tutor"));
1835  if ($lpcomment != "")
1836  {
1837  $info->addProperty($this->lng->txt("exc_comment"),
1838  $lpcomment);
1839  }
1840  if ($mark != "")
1841  {
1842  $info->addProperty($this->lng->txt("exc_mark"),
1843  $mark);
1844  }
1845 
1846  //if ($status == "")
1847  //{
1848  // $info->addProperty($this->lng->txt("status"),
1849  // $this->lng->txt("message_no_delivered_files"));
1850  //}
1851  //else
1852  if ($status != "notgraded")
1853  {
1854  $img = '<img border="0" src="'.ilUtil::getImagePath("scorm/".$status.".gif").'" '.
1855  ' alt="'.$lng->txt("exc_".$status).'" title="'.$lng->txt("exc_".$status).
1856  '" style="vertical-align:middle;"/>';
1857 
1858  $add = "";
1859  if ($st["failed_a_mandatory"])
1860  {
1861  $add = " (".$lng->txt("exc_msg_failed_mandatory").")";
1862  }
1863  else if ($status == "failed")
1864  {
1865  $add = " (".$lng->txt("exc_msg_missed_minimum_number").")";
1866  }
1867  $info->addProperty($this->lng->txt("status"),
1868  $img." ".$this->lng->txt("exc_".$status).$add);
1869  }
1870  }
1871  }
1872 
1873  // forward the command
1874  $this->ctrl->forwardCommand($info);
1875  }
1876 
1877 
1883  function _goto($a_target)
1884  {
1885  global $rbacsystem, $ilErr, $lng, $ilAccess;
1886 
1887  if ($ilAccess->checkAccess("read", "", $a_target))
1888  {
1889  $_GET["ref_id"] = $a_target;
1890  $_GET["cmd"] = "showOverview";
1891  $_GET["baseClass"] = "ilExerciseHandlerGUI";
1892  include("ilias.php");
1893  exit;
1894  }
1895  else if ($ilAccess->checkAccess("visible", "", $a_target))
1896  {
1897  $_GET["ref_id"] = $a_target;
1898  $_GET["cmd"] = "infoScreen";
1899  $_GET["baseClass"] = "ilExerciseHandlerGUI";
1900  include("ilias.php");
1901  exit;
1902  }
1903  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
1904  {
1905  $_GET["cmd"] = "frameset";
1906  $_GET["target"] = "";
1907  $_GET["ref_id"] = ROOT_FOLDER_ID;
1908  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
1909  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
1910  include("repository.php");
1911  exit;
1912  }
1913 
1914  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
1915  }
1916 
1920  function addLocatorItems()
1921  {
1922  global $ilLocator;
1923 
1924  if (is_object($this->object))
1925  {
1926  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "infoScreen"), "", $_GET["ref_id"]);
1927  }
1928  }
1929 
1933 
1938  {
1939  global $tpl, $ilTabs, $ilToolbar, $lng, $ilCtrl;
1940 
1941  $this->checkPermission("write");
1942 
1943  $ilTabs->activateTab("content");
1944  $this->addContentSubTabs("list_assignments");
1945 
1946  $ilToolbar->addButton($lng->txt("exc_add_assignment"),
1947  $ilCtrl->getLinkTarget($this, "addAssignment"));
1948 
1949  include_once("./Modules/Exercise/classes/class.ilAssignmentsTableGUI.php");
1950  $t = new ilAssignmentsTableGUI($this, "listAssignments", $this->object);
1951  $tpl->setContent($t->getHTML());
1952  }
1953 
1958  {
1959  global $tpl, $ilTabs;
1960 
1961  $this->checkPermission("write");
1962 
1963  $ilTabs->activateTab("content");
1964  $this->addContentSubTabs("list_assignments");
1965 
1966  $this->initAssignmentForm("create");
1967  $tpl->setContent($this->form->getHTML());
1968  }
1969 
1975  public function initAssignmentForm($a_mode = "create")
1976  {
1977  global $lng, $ilCtrl;
1978 
1979  // init form
1980  $lng->loadLanguageModule("form");
1981  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1982  $this->form = new ilPropertyFormGUI();
1983  $this->form->setTableWidth("600px");
1984  if ($a_mode == "edit")
1985  {
1986  $this->form->setTitle($lng->txt("exc_edit_assignment"));
1987  }
1988  else
1989  {
1990  $this->form->setTitle($lng->txt("exc_new_assignment"));
1991  }
1992  $this->form->setFormAction($ilCtrl->getFormAction($this));
1993 
1994  // title
1995  $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
1996  $ti->setMaxLength(200);
1997  $ti->setRequired(true);
1998  $this->form->addItem($ti);
1999 
2000  // start time y/n
2001  $cb = new ilCheckboxInputGUI($this->lng->txt("exc_start_time"), "start_time_cb");
2002  $this->form->addItem($cb);
2003 
2004  // start time
2005  $edit_date = new ilDateTimeInputGUI("", "start_time");
2006  $edit_date->setShowTime(true);
2007  $cb->addSubItem($edit_date);
2008 
2009  // Deadline
2010  $edit_date = new ilDateTimeInputGUI($lng->txt("exc_deadline"), "deadline");
2011  $edit_date->setShowTime(true);
2012  $edit_date->setRequired(true);
2013  $this->form->addItem($edit_date);
2014 
2015  // mandatory
2016  $cb = new ilCheckboxInputGUI($this->lng->txt("exc_mandatory"), "mandatory");
2017  $cb->setInfo($this->lng->txt("exc_mandatory_info"));
2018  $cb->setChecked(true);
2019  $this->form->addItem($cb);
2020 
2021  // Work Instructions
2022  $desc_input = new ilTextAreaInputGUI($lng->txt("exc_instruction"), "instruction");
2023  $desc_input->setRows(5);
2024  $this->form->addItem($desc_input);
2025 
2026  // files
2027  if ($a_mode == "create")
2028  {
2029  $files = new ilFileWizardInputGUI($this->lng->txt('objs_file'),'files');
2030  $files->setFilenames(array(0 => ''));
2031  $this->form->addItem($files);
2032  }
2033 
2034  // save and cancel commands
2035  if ($a_mode == "create")
2036  {
2037  $this->form->addCommandButton("saveAssignment", $lng->txt("save"));
2038  $this->form->addCommandButton("listAssignments", $lng->txt("cancel"));
2039  }
2040  else
2041  {
2042  $this->form->addCommandButton("updateAssignment", $lng->txt("save"));
2043  $this->form->addCommandButton("listAssignments", $lng->txt("cancel"));
2044  }
2045  }
2046 
2051  public function saveAssignmentObject()
2052  {
2053  global $tpl, $lng, $ilCtrl, $ilTabs;
2054 
2055  $this->checkPermission("write");
2056 
2057  $ilTabs->activateTab("content");
2058  $this->addContentSubTabs("list_assignments");
2059 
2060  $this->initAssignmentForm("create");
2061  if ($this->form->checkInput())
2062  {
2063  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
2064 
2065  $ass = new ilExAssignment();
2066  $ass->setTitle($_POST["title"]);
2067  $ass->setInstruction($_POST["instruction"]);
2068  $ass->setExerciseId($this->object->getId());
2069  $ass->setMandatory($_POST["mandatory"]);
2070 
2071  if ($_POST["start_time_cb"])
2072  {
2073  $date =
2074  $this->form->getItemByPostVar("start_time")->getDate();
2075  $ass->setStartTime($date->get(IL_CAL_UNIX));
2076  }
2077  else
2078  {
2079  $ass->setStartTime(null);
2080  }
2081 
2082  // deadline
2083  $date =
2084  $this->form->getItemByPostVar("deadline")->getDate();
2085  $ass->setDeadline($date->get(IL_CAL_UNIX));
2086 
2087  $ass->save();
2088 
2089  // save files
2090  $ass->uploadAssignmentFiles($_FILES["files"]);
2091 
2092 
2093  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
2094  $ilCtrl->redirect($this, "listAssignments");
2095  }
2096  else
2097  {
2098  $this->form->setValuesByPost();
2099  $tpl->setContent($this->form->getHtml());
2100  }
2101  }
2102 
2107  {
2108  global $tpl, $ilTabs, $tpl;
2109 
2110  $this->checkPermission("write");
2111 
2112  $this->setAssignmentHeader();
2113  $ilTabs->activateTab("ass_settings");
2114 
2115  $this->initAssignmentForm("edit");
2116  $this->getAssignmentValues();
2117  $tpl->setContent($this->form->getHTML());
2118  }
2119 
2124  public function getAssignmentValues()
2125  {
2126  $values = array();
2127 
2128  $ass = new ilExAssignment($_GET["ass_id"]);
2129  $values["title"] = $ass->getTitle();
2130  if ($ass->getStartTime() > 0)
2131  {
2132  $values["start_time_cb"] = true;
2133  }
2134  $values["mandatory"] = $ass->getMandatory();
2135  $values["instruction"] = $ass->getInstruction();
2136 
2137  $this->form->setValuesByArray($values);
2138 
2139  $edit_date = new ilDateTime($ass->getDeadline(), IL_CAL_UNIX);
2140  $ed_item = $this->form->getItemByPostVar("deadline");
2141  $ed_item->setDate($edit_date);
2142 
2143  if ($ass->getStartTime() > 0)
2144  {
2145  $edit_date = new ilDateTime($ass->getStartTime(), IL_CAL_UNIX);
2146  $ed_item = $this->form->getItemByPostVar("start_time");
2147  $ed_item->setDate($edit_date);
2148  }
2149  }
2150 
2155  public function updateAssignmentObject()
2156  {
2157  global $tpl, $lng, $ilCtrl, $ilTabs;
2158 
2159  $this->checkPermission("write");
2160 
2161  $ilTabs->activateTab("content");
2162  $this->addContentSubTabs("list_assignments");
2163 
2164  $this->initAssignmentForm("edit");
2165  if ($this->form->checkInput())
2166  {
2167  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
2168 
2169  $ass = new ilExAssignment($_GET["ass_id"]);
2170  $ass->setTitle($_POST["title"]);
2171  $ass->setInstruction($_POST["instruction"]);
2172  $ass->setExerciseId($this->object->getId());
2173  $ass->setMandatory($_POST["mandatory"]);
2174 
2175  if ($_POST["start_time_cb"])
2176  {
2177  $date =
2178  $this->form->getItemByPostVar("start_time")->getDate();
2179  $ass->setStartTime($date->get(IL_CAL_UNIX));
2180  }
2181  else
2182  {
2183  $ass->setStartTime(null);
2184  }
2185 
2186  // deadline
2187  $date =
2188  $this->form->getItemByPostVar("deadline")->getDate();
2189  $ass->setDeadline($date->get(IL_CAL_UNIX));
2190 
2191  $ass->update();
2192  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
2193  $ilCtrl->redirect($this, "listAssignments");
2194  }
2195  else
2196  {
2197  $this->form->setValuesByPost();
2198  $tpl->setContent($this->form->getHtml());
2199  }
2200  }
2201 
2202 
2207  {
2208  global $ilCtrl, $tpl, $lng, $ilTabs;
2209 
2210  $this->checkPermission("write");
2211 
2212  $ilTabs->activateTab("content");
2213  $this->addContentSubTabs("list_assignments");
2214 
2215  if (!is_array($_POST["id"]) || count($_POST["id"]) == 0)
2216  {
2217  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
2218  $ilCtrl->redirect($this, "listAssignments");
2219  }
2220  else
2221  {
2222  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
2223  $cgui = new ilConfirmationGUI();
2224  $cgui->setFormAction($ilCtrl->getFormAction($this));
2225  $cgui->setHeaderText($lng->txt("exc_conf_del_assignments"));
2226  $cgui->setCancel($lng->txt("cancel"), "listAssignments");
2227  $cgui->setConfirm($lng->txt("delete"), "deleteAssignments");
2228 
2229  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
2230 
2231  foreach ($_POST["id"] as $i)
2232  {
2233  $cgui->addItem("id[]", $i, ilExAssignment::lookupTitle($i));
2234  }
2235 
2236  $tpl->setContent($cgui->getHTML());
2237  }
2238  }
2239 
2244  {
2245  global $ilDB, $ilCtrl, $lng;
2246 
2247  $this->checkPermission("write");
2248 
2249  $delete = false;
2250  if (is_array($_POST["id"]))
2251  {
2252  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
2253  foreach($_POST["id"] as $id)
2254  {
2255  $ass = new ilExAssignment(ilUtil::stripSlashes($id));
2256  $ass->delete();
2257  $delete = true;
2258  }
2259  }
2260 
2261  if ($delete)
2262  {
2263  ilUtil::sendSuccess($lng->txt("exc_assignments_deleted"), true);
2264  }
2265  $ilCtrl->redirect($this, "listAssignments");
2266  }
2267 
2272  {
2273  global $lng, $ilCtrl;
2274 
2275  $this->checkPermission("write");
2276 
2277  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
2278  ilExAssignment::saveAssOrderOfExercise($this->object->getId(), $_POST["order"]);
2279 
2280  ilUtil::sendSuccess($lng->txt("exc_saved_order"), true);
2281  $ilCtrl->redirect($this, "listAssignments");
2282  }
2283 
2288  {
2289  global $lng, $ilCtrl;
2290 
2291  $this->checkPermission("write");
2292 
2293  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
2294  ilExAssignment::orderAssByDeadline($this->object->getId());
2295 
2296  ilUtil::sendSuccess($lng->txt("exc_saved_order"), true);
2297  $ilCtrl->redirect($this, "listAssignments");
2298  }
2299 
2304  {
2305  global $ilTabs, $lng, $ilCtrl, $tpl;
2306 
2307  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
2308  $tpl->setTitle(ilExAssignment::lookupTitle($_GET["ass_id"]));
2309  $tpl->setDescription("");
2310 
2311  $ilTabs->clearTargets();
2312 
2313  $ilTabs->setBackTarget($lng->txt("back"),
2314  $ilCtrl->getLinkTarget($this, "listAssignments"));
2315 
2316  $ilTabs->addTab("ass_settings",
2317  $lng->txt("settings"),
2318  $ilCtrl->getLinkTarget($this, "editAssignment"));
2319 
2320  $ilTabs->addTab("ass_files",
2321  $lng->txt("files"),
2322  $ilCtrl->getLinkTargetByClass("ilfilesystemgui", "listFiles"));
2323 
2324  }
2325 
2326 
2330 
2335  {
2336  global $tpl, $ilTabs, $ilUser;
2337 
2338  $this->checkPermission("read");
2339 
2340  include_once("./Services/Tracking/classes/class.ilLearningProgress.php");
2341  ilLearningProgress::_tracProgress($ilUser->getId(),$this->object->getId(),
2342  $this->object->getRefId(), 'exc');
2343 
2344  $ilTabs->activateTab("content");
2345  $this->addContentSubTabs("content");
2346 
2347  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
2348  include_once("./Services/Accordion/classes/class.ilAccordionGUI.php");
2349  $acc = new ilAccordionGUI();
2350  $acc->setBehaviour("OneOpenSession");
2351  $acc->setId("exc_ow_".$this->object->getId());
2352  $ass_data = ilExAssignment::getAssignmentDataOfExercise($this->object->getId());
2353  include_once("./Modules/Exercise/classes/class.ilExAssignmentGUI.php");
2354  $ass_gui = new ilExAssignmentGUI($this->object);
2355 
2356  foreach ($ass_data as $ass)
2357  {
2358  $acc->addItem($ass_gui->getOverviewHeader($ass),
2359  $ass_gui->getOverviewBody($ass));
2360  }
2361 
2362  $tpl->setContent($acc->getHTML());
2363  }
2364 
2369  {
2370  global $tpl, $ilTabs;
2371 
2372  $this->checkPermission("read");
2373 
2374  $ilTabs->activateTab("content");
2375  $this->addContentSubTabs("content");
2376 
2377  include_once("./Modules/Exercise/classes/class.ilPublicSubmissionsTableGUI.php");
2378  $tab = new ilPublicSubmissionsTableGUI($this, "listPublicSubmissions",
2379  $this->object, (int) $_GET["ass_id"]);
2380  $tpl->setContent($tab->getHTML());
2381  }
2382 
2387  {
2388  $this->checkPermission("write");
2389  $this->object->exportGradesExcel();
2390  exit;
2391  }
2392 
2396  function saveGradesObject()
2397  {
2398  global $ilCtrl, $lng;
2399 
2400  $this->checkPermission("write");
2401  include_once 'Services/Tracking/classes/class.ilLPMarks.php';
2402 
2403  if (is_array($_POST["lcomment"]))
2404  {
2405  foreach ($_POST["lcomment"] as $k => $v)
2406  {
2407  $marks_obj = new ilLPMarks($this->object->getId(), (int) $k);
2408  $marks_obj->setComment(ilUtil::stripSlashes($v));
2409  $marks_obj->setMark(ilUtil::stripSlashes($_POST["mark"][$k]));
2410  $marks_obj->update();
2411  }
2412  }
2413  ilUtil::sendSuccess($lng->txt("exc_msg_saved_grades"), true);
2414  $ilCtrl->redirect($this, "showGradesOverview");
2415  }
2416 
2421  protected function sendNotifications($assignment_id)
2422  {
2423  include_once "./Services/Notification/classes/class.ilNotification.php";
2425 
2426  include_once "./Modules/Exercise/classes/class.ilExerciseMailNotification.php";
2427  $not = new ilExerciseMailNotification();
2429  $not->setAssignmentId($assignment_id);
2430  $not->setRefId($this->ref_id);
2431  $not->setRecipients($users);
2432  $not->send();
2433  }
2434 }
2435 
2436 ?>