ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilExAssignmentEditorGUI.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 include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
6 
17 {
21  protected $ctrl;
22 
26  protected $tabs;
27 
31  protected $lng;
32 
36  protected $tpl;
37 
41  protected $toolbar;
42 
46  protected $settings;
47 
51  protected $help;
52 
53  protected $exercise_id; // [int]
54  protected $assignment; // [ilExAssignment]
55  protected $enable_peer_review_completion; // [bool]
56 
65  public function __construct($a_exercise_id, $a_enable_peer_review_completion_settings, ilExAssignment $a_ass = null)
66  {
67  global $DIC;
68 
69  $this->ctrl = $DIC->ctrl();
70  $this->tabs = $DIC->tabs();
71  $this->lng = $DIC->language();
72  $this->tpl = $DIC["tpl"];
73  $this->toolbar = $DIC->toolbar();
74  $this->settings = $DIC->settings();
75  $this->help = $DIC["ilHelp"];
76  $this->exercise_id = $a_exercise_id;
77  $this->assignment = $a_ass;
78  $this->enable_peer_review_completion = (bool) $a_enable_peer_review_completion_settings;
79  }
80 
81  public function executeCommand()
82  {
84  $ilTabs = $this->tabs;
85  $lng = $this->lng;
86 
87  $class = $ilCtrl->getNextClass($this);
88  $cmd = $ilCtrl->getCmd("listAssignments");
89 
90  switch ($class) {
91  case "ilpropertyformgui":
93  $ilCtrl->forwardCommand($form);
94  break;
95 
96  // instruction files
97  case "ilexassignmentfilesystemgui":
98  $this->setAssignmentHeader();
99  $ilTabs->activateTab("ass_files");
100 
101  include_once("./Modules/Exercise/classes/class.ilFSWebStorageExercise.php");
102  $fstorage = new ilFSWebStorageExercise($this->exercise_id, $this->assignment->getId());
103  $fstorage->create();
104 
105  include_once("./Modules/Exercise/classes/class.ilExAssignmentFileSystemGUI.php");
106  $fs_gui = new ilExAssignmentFileSystemGUI($fstorage->getPath());
107  $fs_gui->setTitle($lng->txt("exc_instruction_files"));
108  $fs_gui->setTableId("excassfil" . $this->assignment->getId());
109  $fs_gui->setAllowDirectories(false);
110  $ilCtrl->forwardCommand($fs_gui);
111  break;
112 
113  case "ilexpeerreviewgui":
114  $ilTabs->clearTargets();
115  $ilTabs->setBackTarget(
116  $lng->txt("back"),
117  $ilCtrl->getLinkTarget($this, "listAssignments")
118  );
119 
120  include_once("./Modules/Exercise/classes/class.ilExPeerReviewGUI.php");
121  $peer_gui = new ilExPeerReviewGUI($this->assignment);
122  $ilCtrl->forwardCommand($peer_gui);
123  break;
124 
125  default:
126  $this->{$cmd . "Object"}();
127  break;
128  }
129  }
130 
134  public function listAssignmentsObject()
135  {
136  $tpl = $this->tpl;
137  $ilToolbar = $this->toolbar;
138  $lng = $this->lng;
140 
141  $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "addAssignment"));
142 
143  include_once "Services/Form/classes/class.ilSelectInputGUI.php";
144  $ilToolbar->addStickyItem($this->getTypeDropdown());
145 
146  include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
147  $button = ilSubmitButton::getInstance();
148  $button->setCaption("exc_add_assignment");
149  $button->setCommand("addAssignment");
150  $ilToolbar->addStickyItem($button);
151 
152 
153  include_once("./Modules/Exercise/classes/class.ilAssignmentsTableGUI.php");
154  $t = new ilAssignmentsTableGUI($this, "listAssignments", $this->exercise_id);
155  $tpl->setContent($t->getHTML());
156  }
157 
161  public function addAssignmentObject()
162  {
163  $tpl = $this->tpl;
165 
166  // #16163 - ignore ass id from request
167  $this->assignment = null;
168 
169  if (!(int) $_POST["type"]) {
170  $ilCtrl->redirect($this, "listAssignments");
171  }
172 
173  $form = $this->initAssignmentForm((int) $_POST["type"], "create");
174  $tpl->setContent($form->getHTML());
175  }
176 
182  protected function getTypeDropdown()
183  {
185  $lng = $this->lng;
186 
187  $types = array(
188  ilExAssignment::TYPE_UPLOAD => $lng->txt("exc_type_upload"),
189  ilExAssignment::TYPE_UPLOAD_TEAM => $lng->txt("exc_type_upload_team"),
190  ilExAssignment::TYPE_TEXT => $lng->txt("exc_type_text")
191  );
192  if (!$ilSetting->get('disable_wsp_blogs')) {
193  $types[ilExAssignment::TYPE_BLOG] = $lng->txt("exc_type_blog");
194  }
195  if ($ilSetting->get('user_portfolios')) {
196  $types[ilExAssignment::TYPE_PORTFOLIO] = $lng->txt("exc_type_portfolio");
197  }
198  $ty = new ilSelectInputGUI($lng->txt("exc_assignment_type"), "type");
199  $ty->setOptions($types);
200  $ty->setRequired(true);
201  return $ty;
202  }
203 
210  protected function initAssignmentForm($a_type, $a_mode = "create")
211  {
212  $lng = $this->lng;
214 
215  $lng->loadLanguageModule("form");
216  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
217  $form = new ilPropertyFormGUI();
218  $form->setTableWidth("600px");
219  if ($a_mode == "edit") {
220  $form->setTitle($lng->txt("exc_edit_assignment"));
221  } else {
222  $form->setTitle($lng->txt("exc_new_assignment"));
223  }
224  $form->setFormAction($ilCtrl->getFormAction($this));
225 
226  // title
227  $ti = new ilTextInputGUI($lng->txt("title"), "title");
228  $ti->setMaxLength(200);
229  $ti->setRequired(true);
230  $form->addItem($ti);
231 
232  // type
233  $ty = $this->getTypeDropdown();
234  $ty->setValue($a_type);
235  $ty->setDisabled(true);
236  $form->addItem($ty);
237 
239  $rb_limit_chars = new ilCheckboxInputGUI($lng->txt("exc_limit_characters"), "limit_characters");
240 
241  $min_char_limit = new ilNumberInputGUI($lng->txt("exc_min_char_limit"), "min_char_limit");
242  $min_char_limit->allowDecimals(false);
243  $min_char_limit->setMinValue(0);
244  $min_char_limit->setSize(3);
245 
246  $max_char_limit = new ilNumberInputGUI($lng->txt("exc_max_char_limit"), "max_char_limit");
247  $max_char_limit->allowDecimals(false);
248  $max_char_limit->setMinValue((int) $_POST['min_char_limit'] + 1);
249 
250  $max_char_limit->setSize(3);
251 
252  $rb_limit_chars->addSubItem($min_char_limit);
253  $rb_limit_chars->addSubItem($max_char_limit);
254 
255  $form->addItem($rb_limit_chars);
256  }
257 
258  // portfolio template
260  $rd_template = new ilRadioGroupInputGUI($lng->txt("exc_template"), "template");
261  $rd_template->setRequired(true);
262  $radio_no_template = new ilRadioOption($lng->txt("exc_without_template"), 0, $lng->txt("exc_without_template_info", "without_template_info"));
263  $radio_with_template = new ilRadioOption($lng->txt("exc_with_template"), 1, $lng->txt("exc_with_template_info", "with_template_info"));
264 
265  include_once "Services/Form/classes/class.ilRepositorySelector2InputGUI.php";
266  $repo = new ilRepositorySelector2InputGUI($lng->txt("exc_portfolio_template"), "template_id");
267  $repo->setRequired(true);
268  if ($this->assignment) {
269  $repo->setValue($this->assignment->getPortfolioTemplateId());
270  }
271  $repo->getExplorerGUI()->setSelectableTypes(array("prtt"));
272  $repo->getExplorerGUI()->setTypeWhiteList(array("root", "prtt", "cat", "crs", "grp"));
273  $radio_with_template->addSubItem($repo);
274 
275  $rd_template->addOption($radio_no_template);
276  $rd_template->addOption($radio_with_template);
277  $form->addItem($rd_template);
278  }
279 
280  // mandatory
281  $cb = new ilCheckboxInputGUI($lng->txt("exc_mandatory"), "mandatory");
282  $cb->setInfo($lng->txt("exc_mandatory_info"));
283  $cb->setChecked(true);
284  $form->addItem($cb);
285 
286  // Work Instructions
287  $sub_header = new ilFormSectionHeaderGUI();
288  $sub_header->setTitle($lng->txt("exc_work_instructions"), "work_instructions");
289  $form->addItem($sub_header);
290 
291  $desc_input = new ilTextAreaInputGUI($lng->txt("exc_instruction"), "instruction");
292  $desc_input->setRows(20);
293  $desc_input->setUseRte(true);
294  $desc_input->setRteTagSet("mini");
295  $form->addItem($desc_input);
296 
297  // files
298  if ($a_mode == "create") {
299  $files = new ilFileWizardInputGUI($lng->txt('objs_file'), 'files');
300  $files->setFilenames(array(0 => ''));
301  $form->addItem($files);
302  }
303 
304  // Schedule
305  $sub_header = new ilFormSectionHeaderGUI();
306  $sub_header->setTitle($lng->txt("exc_schedule"), "schedule");
307  $form->addItem($sub_header);
308 
309  // start time
310  $start_date = new ilDateTimeInputGUI($lng->txt("exc_start_time"), "start_time");
311  $start_date->setShowTime(true);
312  $form->addItem($start_date);
313 
314  // Deadline
315  $deadline = new ilDateTimeInputGUI($lng->txt("exc_deadline"), "deadline");
316  $deadline->setShowTime(true);
317  $form->addItem($deadline);
318 
319  // extended Deadline
320  $deadline2 = new ilDateTimeInputGUI($lng->txt("exc_deadline_extended"), "deadline2");
321  $deadline2->setInfo($lng->txt("exc_deadline_extended_info"));
322  $deadline2->setShowTime(true);
323  $deadline->addSubItem($deadline2);
324 
325 
326  // max number of files
330  $type_name = $lng->txt("exc_type_upload");
331  }
333  $type_name = $lng->txt("exc_type_upload_team");
334  }
335 
336  // custom section depending of assignment type
337  $sub_header = new ilFormSectionHeaderGUI();
338  $sub_header->setTitle($type_name);
339  $form->addItem($sub_header);
340  $max_file_tgl = new ilCheckboxInputGUI($lng->txt("exc_max_file_tgl"), "max_file_tgl");
341  $form->addItem($max_file_tgl);
342 
343  $max_file = new ilNumberInputGUI($lng->txt("exc_max_file"), "max_file");
344  $max_file->setInfo($lng->txt("exc_max_file_info"));
345  $max_file->setRequired(true);
346  $max_file->setSize(3);
347  $max_file->setMinValue(1);
348  $max_file_tgl->addSubItem($max_file);
349  }
350 
352  $cbtut = new ilCheckboxInputGUI($lng->txt("exc_team_management_tutor"), "team_tutor");
353  $cbtut->setInfo($lng->txt("exc_team_management_tutor_info"));
354  $cbtut->setChecked(false);
355  $form->addItem($cbtut);
356  }
357  // after submission
358  $sub_header = new ilFormSectionHeaderGUI();
359  $sub_header->setTitle($lng->txt("exc_after_submission"), "after_submission");
360  $form->addItem($sub_header);
362  // peer review
363  $peer = new ilCheckboxInputGUI($lng->txt("exc_peer_review"), "peer");
364  $peer->setInfo($lng->txt("exc_peer_review_ass_setting_info"));
365  $form->addItem($peer);
366  }
367 
368 
369  // global feedback
370 
371  $fb = new ilCheckboxInputGUI($lng->txt("exc_global_feedback_file"), "fb");
372  $form->addItem($fb);
373 
374  $fb_file = new ilFileInputGUI($lng->txt("file"), "fb_file");
375  $fb_file->setRequired(true); // will be disabled on update if file exists - see getAssignmentValues()
376  // $fb_file->setAllowDeletion(true); makes no sense if required (overwrite or keep)
377  $fb->addSubItem($fb_file);
378 
379  $fb_date = new ilRadioGroupInputGUI($lng->txt("exc_global_feedback_file_date"), "fb_date");
380  $fb_date->setRequired(true);
381  $fb_date->addOption(new ilRadioOption($lng->txt("exc_global_feedback_file_date_deadline"), ilExAssignment::FEEDBACK_DATE_DEADLINE));
382  $fb_date->addOption(new ilRadioOption($lng->txt("exc_global_feedback_file_date_upload"), ilExAssignment::FEEDBACK_DATE_SUBMISSION));
383  $fb->addSubItem($fb_date);
384 
385  $fb_cron = new ilCheckboxInputGUI($lng->txt("exc_global_feedback_file_cron"), "fb_cron");
386  $fb_cron->setInfo($lng->txt("exc_global_feedback_file_cron_info"));
387  $fb->addSubItem($fb_cron);
388 
389 
390  if ($a_mode == "create") {
391  $form->addCommandButton("saveAssignment", $lng->txt("save"));
392  $form->addCommandButton("listAssignments", $lng->txt("cancel"));
393  } else {
394  $form->addCommandButton("updateAssignment", $lng->txt("save"));
395  $form->addCommandButton("listAssignments", $lng->txt("cancel"));
396  }
397 
398  return $form;
399  }
400 
407  protected function processForm(ilPropertyFormGUI $a_form)
408  {
409  $lng = $this->lng;
410 
411  $protected_peer_review_groups = false;
412 
413  if ($this->assignment) {
414  if ($this->assignment->getPeerReview()) {
415  include_once "Modules/Exercise/classes/class.ilExPeerReview.php";
416  $peer_review = new ilExPeerReview($this->assignment);
417  if ($peer_review->hasPeerReviewGroups()) {
418  $protected_peer_review_groups = true;
419  }
420  }
421 
422  if ($this->assignment->getFeedbackFile()) {
423  $a_form->getItemByPostVar("fb_file")->setRequired(false); // #15467
424  }
425  }
426 
427  $valid = $a_form->checkInput();
428 
429  if ($protected_peer_review_groups) {
430  // checkInput() will add alert to disabled fields
431  $a_form->getItemByPostVar("deadline")->setAlert(null);
432  $a_form->getItemByPostVar("deadline2")->setAlert(null);
433  }
434 
435  if ($valid) {
436  // dates
437 
438  $time_start = $a_form->getItemByPostVar("start_time")->getDate();
439  $time_start = $time_start
440  ? $time_start->get(IL_CAL_UNIX)
441  : null;
442  $time_deadline = $a_form->getItemByPostVar("deadline")->getDate();
443  $time_deadline = $time_deadline
444  ? $time_deadline->get(IL_CAL_UNIX)
445  : null;
446  $time_deadline_ext = $a_form->getItemByPostVar("deadline2")->getDate();
447  $time_deadline_ext = $time_deadline_ext
448  ? $time_deadline_ext->get(IL_CAL_UNIX)
449  : null;
450 
451  // handle disabled elements
452  if ($protected_peer_review_groups) {
453  $time_deadline = $this->assignment->getDeadline();
454  $time_deadline_ext = $this->assignment->getExtendedDeadline();
455  }
456 
457  // no deadline?
458  if (!$time_deadline) {
459  // peer review
460  if (!$protected_peer_review_groups &&
461  $a_form->getInput("peer")) {
462  $a_form->getItemByPostVar("peer")
463  ->setAlert($lng->txt("exc_needs_deadline"));
464  $valid = false;
465  }
466  // global feedback
467  if ($a_form->getInput("fb") &&
468  $a_form->getInput("fb_date") == ilExAssignment::FEEDBACK_DATE_DEADLINE) {
469  $a_form->getItemByPostVar("fb")
470  ->setAlert($lng->txt("exc_needs_deadline"));
471  $valid = false;
472  }
473  } else {
474  // #18269
475  if ($a_form->getInput("peer")) {
476  $time_deadline_max = max($time_deadline, $time_deadline_ext);
477  $peer_dl = $this->assignment // #18380
478  ? $this->assignment->getPeerReviewDeadline()
479  : null;
480  if ($peer_dl && $peer_dl < $time_deadline_max) {
481  $a_form->getItemByPostVar($peer_dl < $time_deadline_ext
482  ? "deadline2"
483  : "deadline")
484  ->setAlert($lng->txt("exc_peer_deadline_mismatch"));
485  $valid = false;
486  }
487  }
488 
489  if ($time_deadline_ext && $time_deadline_ext < $time_deadline) {
490  $a_form->getItemByPostVar("deadline2")
491  ->setAlert($lng->txt("exc_deadline_ext_mismatch"));
492  $valid = false;
493  }
494 
495  $time_deadline_min = $time_deadline_ext
496  ? min($time_deadline, $time_deadline_ext)
497  : $time_deadline;
498  $time_deadline_max = max($time_deadline, $time_deadline_ext);
499 
500  // start > any deadline ?
501  if ($time_start && $time_deadline_min && $time_start > $time_deadline_min) {
502  $a_form->getItemByPostVar("start_time")
503  ->setAlert($lng->txt("exc_start_date_should_be_before_end_date"));
504  $valid = false;
505  }
506  }
507 
508  if ($valid) {
509  $res = array(
510  // core
511  "type" => $a_form->getInput("type")
512  ,"title" => trim($a_form->getInput("title"))
513  ,"instruction" => trim($a_form->getInput("instruction"))
514  ,"mandatory" => $a_form->getInput("mandatory")
515  // dates
516  ,"start" => $time_start
517  ,"deadline" => $time_deadline
518  ,"deadline_ext" => $time_deadline_ext
519  ,"max_file" => $a_form->getInput("max_file_tgl")
520  ? $a_form->getInput("max_file")
521  : null
522  ,"team_tutor" => $a_form->getInput("team_tutor")
523  );
524  // portfolio template
525  if ($a_form->getInput("template_id") && $a_form->getInput("template")) {
526  $res['template_id'] = $a_form->getInput("template_id");
527  }
528 
529  // text limitations
530  if ($a_form->getInput("limit_characters")) {
531  $res['limit_characters'] = $a_form->getInput("limit_characters");
532  }
533  if ($a_form->getInput("limit_characters") && $a_form->getInput("max_char_limit")) {
534  $res['max_char_limit'] = $a_form->getInput("max_char_limit");
535  }
536  if ($a_form->getInput("limit_characters") && $a_form->getInput("min_char_limit")) {
537  $res['min_char_limit'] = $a_form->getInput("min_char_limit");
538  }
539 
540  // peer
541  if ($a_form->getInput("peer") ||
542  $protected_peer_review_groups) {
543  $res["peer"] = true;
544  }
545 
546  // files
547  if (is_array($_FILES["files"])) {
548  // #15994 - we are keeping the upload files array structure
549  // see ilFSStorageExercise::uploadAssignmentFiles()
550  $res["files"] = $_FILES["files"];
551  }
552 
553  // global feedback
554  if ($a_form->getInput("fb")) {
555  $res["fb"] = true;
556  $res["fb_cron"] = $a_form->getInput("fb_cron");
557  $res["fb_date"] = $a_form->getInput("fb_date");
558  if ($_FILES["fb_file"]["tmp_name"]) {
559  $res["fb_file"] = $_FILES["fb_file"];
560  }
561  }
562 
563  return $res;
564  } else {
565  ilUtil::sendFailure($lng->txt("form_input_not_valid"));
566  }
567  }
568  }
569 
576  protected function importFormToAssignment(ilExAssignment $a_ass, array $a_input)
577  {
578  $is_create = !(bool) $a_ass->getId();
579 
580  $a_ass->setTitle($a_input["title"]);
581  $a_ass->setInstruction($a_input["instruction"]);
582  $a_ass->setMandatory($a_input["mandatory"]);
583 
584  $a_ass->setStartTime($a_input["start"]);
585  $a_ass->setDeadline($a_input["deadline"]);
586  $a_ass->setExtendedDeadline($a_input["deadline_ext"]);
587 
588  $a_ass->setMaxFile($a_input["max_file"]);
589  $a_ass->setTeamTutor($a_input["team_tutor"]);
590 
591  $a_ass->setPortfolioTemplateId($a_input['template_id']);
592 
593  $a_ass->setMinCharLimit($a_input['min_char_limit']);
594  $a_ass->setMaxCharLimit($a_input['max_char_limit']);
595 
596  $a_ass->setPeerReview((bool) $a_input["peer"]);
597 
598  // peer review default values (on separate form)
599  if ($is_create) {
600  $a_ass->setPeerReviewMin(2);
601  $a_ass->setPeerReviewSimpleUnlock(false);
603  $a_ass->setPeerReviewPersonalized(false);
604  $a_ass->setPeerReviewFileUpload(false);
605  $a_ass->setPeerReviewText(true);
606  $a_ass->setPeerReviewRating(true);
607  }
608 
609  if ($a_input["fb"]) {
610  $a_ass->setFeedbackCron($a_input["fb_cron"]); // #13380
611  $a_ass->setFeedbackDate($a_input["fb_date"]);
612  }
613 
614  // id needed for file handling
615  if ($is_create) {
616  $a_ass->save();
617 
618  // #15994 - assignment files
619  if (is_array($a_input["files"])) {
620  $a_ass->uploadAssignmentFiles($a_input["files"]);
621  }
622  } else {
623  // remove global feedback file?
624  if (!$a_input["fb"]) {
625  $a_ass->deleteGlobalFeedbackFile();
626  $a_ass->setFeedbackFile(null);
627  }
628 
629  $a_ass->update();
630  }
631 
632  // add global feedback file?
633  if ($a_input["fb"]) {
634  if (is_array($a_input["fb_file"])) {
635  $a_ass->handleGlobalFeedbackFileUpload($a_input["fb_file"]);
636  $a_ass->update();
637  }
638  }
639  }
640 
645  public function saveAssignmentObject()
646  {
647  $tpl = $this->tpl;
648  $lng = $this->lng;
650 
651  // #16163 - ignore ass id from request
652  $this->assignment = null;
653 
654  $form = $this->initAssignmentForm((int) $_POST["type"], "create");
655  $input = $this->processForm($form);
656  if (is_array($input)) {
657  $ass = new ilExAssignment();
658  $ass->setExerciseId($this->exercise_id);
659  $ass->setType($input["type"]);
660 
661  $this->importFormToAssignment($ass, $input);
662  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
663 
664  // adopt teams for team upload?
665  if ($ass->getType() == ilExAssignment::TYPE_UPLOAD_TEAM) {
666  include_once "Modules/Exercise/classes/class.ilExAssignmentTeam.php";
667  if (sizeof(ilExAssignmentTeam::getAdoptableTeamAssignments($this->exercise_id, $ass->getId()))) {
668  $ilCtrl->setParameter($this, "ass_id", $ass->getId());
669  $ilCtrl->redirect($this, "adoptTeamAssignmentsForm");
670  }
671  }
672 
673  // because of sub-tabs we stay on settings screen
674  $ilCtrl->setParameter($this, "ass_id", $ass->getId());
675  $ilCtrl->redirect($this, "editAssignment");
676  } else {
677  $form->setValuesByPost();
678  $tpl->setContent($form->getHtml());
679  }
680  }
681 
685  public function editAssignmentObject()
686  {
687  $tpl = $this->tpl;
688  $ilTabs = $this->tabs;
689  $tpl = $this->tpl;
690 
691  $this->setAssignmentHeader();
692  $ilTabs->activateTab("ass_settings");
693 
694  $form = $this->initAssignmentForm($this->assignment->getType(), "edit");
695  $this->getAssignmentValues($form);
696  $tpl->setContent($form->getHTML());
697  }
698 
702  public function getAssignmentValues(ilPropertyFormGUI $a_form)
703  {
704  $lng = $this->lng;
706 
707  $values = array();
708  $values["type"] = $this->assignment->getType();
709  $values["title"] = $this->assignment->getTitle();
710  $values["mandatory"] = $this->assignment->getMandatory();
711  $values["instruction"] = $this->assignment->getInstruction();
712  $values['template_id'] = $this->assignment->getPortfolioTemplateId();
713 
714  if ($this->assignment->getPortfolioTemplateId()) {
715  $values["template"] = 1;
716  }
717 
718  if ($this->assignment->getMinCharLimit()) {
719  $values['limit_characters'] = 1;
720  $values['min_char_limit'] = $this->assignment->getMinCharLimit();
721  }
722  if ($this->assignment->getMaxCharLimit()) {
723  $values['limit_characters'] = 1;
724  $values['max_char_limit'] = $this->assignment->getMaxCharLimit();
725  }
726 
727  if ($this->assignment->getStartTime()) {
728  $values["start_time"] = new ilDateTime($this->assignment->getStartTime(), IL_CAL_UNIX);
729  }
730 
731  if ($this->assignment->getType() == ilExAssignment::TYPE_UPLOAD ||
732  $this->assignment->getType() == ilExAssignment::TYPE_UPLOAD_TEAM) {
733  if ($this->assignment->getMaxFile()) {
734  $values["max_file_tgl"] = true;
735  $values["max_file"] = $this->assignment->getMaxFile();
736  }
737  }
738 
739  if ($this->assignment->getType() == ilExAssignment::TYPE_UPLOAD_TEAM) {
740  $values["team_tutor"] = $this->assignment->getTeamTutor();
741  }
742 
743  $a_form->setValuesByArray($values);
744 
745  // global feedback
746  if ($this->assignment->getFeedbackFile()) {
747  $a_form->getItemByPostVar("fb")->setChecked(true);
748  $a_form->getItemByPostVar("fb_file")->setValue(basename($this->assignment->getGlobalFeedbackFilePath()));
749  $a_form->getItemByPostVar("fb_file")->setRequired(false); // #15467
750  $a_form->getItemByPostVar("fb_file")->setInfo(
751  // #16400
752  '<a href="' . $ilCtrl->getLinkTarget($this, "downloadGlobalFeedbackFile") . '">' .
753  $lng->txt("download") . '</a>'
754  );
755  }
756  $a_form->getItemByPostVar("fb_cron")->setChecked($this->assignment->hasFeedbackCron());
757  $a_form->getItemByPostVar("fb_date")->setValue($this->assignment->getFeedbackDate());
758 
759  $this->handleDisabledFields($a_form, true);
760  }
761 
762  protected function setDisabledFieldValues(ilPropertyFormGUI $a_form)
763  {
764  // dates
765  if ($this->assignment->getDeadline() > 0) {
766  $edit_date = new ilDateTime($this->assignment->getDeadline(), IL_CAL_UNIX);
767  $ed_item = $a_form->getItemByPostVar("deadline");
768  $ed_item->setDate($edit_date);
769 
770  if ($this->assignment->getExtendedDeadline() > 0) {
771  $edit_date = new ilDateTime($this->assignment->getExtendedDeadline(), IL_CAL_UNIX);
772  $ed_item = $a_form->getItemByPostVar("deadline2");
773  $ed_item->setDate($edit_date);
774  }
775  }
776 
777  if ($this->assignment->getPeerReview()) {
778  $a_form->getItemByPostVar("peer")->setChecked($this->assignment->getPeerReview());
779  }
780  }
781 
782  protected function handleDisabledFields(ilPropertyFormGUI $a_form, $a_force_set_values = false)
783  {
784  // potentially disabled elements are initialized here to re-use this
785  // method after setValuesByPost() - see updateAssignmentObject()
786 
787  // team assignments do not support peer review
788  // with no active peer review there is nothing to protect
789  if ($this->assignment->getType() != ilExAssignment::TYPE_UPLOAD_TEAM &&
790  $this->assignment->getPeerReview()) {
791  // #14450
792  include_once "Modules/Exercise/classes/class.ilExPeerReview.php";
793  $peer_review = new ilExPeerReview($this->assignment);
794  if ($peer_review->hasPeerReviewGroups()) {
795  // deadline(s) are past and must not change
796  $a_form->getItemByPostVar("deadline")->setDisabled(true);
797  $a_form->getItemByPostVar("deadline2")->setDisabled(true);
798 
799  $a_form->getItemByPostVar("peer")->setDisabled(true);
800  }
801  }
802 
803  if ($a_force_set_values ||
804  ($peer_review && $peer_review->hasPeerReviewGroups())) {
805  $this->setDisabledFieldValues($a_form);
806  }
807  }
808 
813  public function updateAssignmentObject()
814  {
815  $tpl = $this->tpl;
816  $lng = $this->lng;
818  $ilTabs = $this->tabs;
819 
820  $form = $this->initAssignmentForm($this->assignment->getType(), "edit");
821  $input = $this->processForm($form);
822  if (is_array($input)) {
823  $old_deadline = $this->assignment->getDeadline();
824  $old_ext_deadline = $this->assignment->getExtendedDeadline();
825 
826  $this->importFormToAssignment($this->assignment, $input);
827 
828  $new_deadline = $this->assignment->getDeadline();
829  $new_ext_deadline = $this->assignment->getExtendedDeadline();
830 
831  // if deadlines were changed
832  if ($old_deadline != $new_deadline ||
833  $old_ext_deadline != $new_ext_deadline) {
834  $this->assignment->recalculateLateSubmissions();
835  }
836 
837  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
838  $ilCtrl->redirect($this, "editAssignment");
839  } else {
840  $this->setAssignmentHeader();
841  $ilTabs->activateTab("ass_settings");
842 
843  $form->setValuesByPost();
844  $this->handleDisabledFields($form);
845  $tpl->setContent($form->getHtml());
846  }
847  }
848 
853  {
855  $tpl = $this->tpl;
856  $lng = $this->lng;
857 
858  if (!is_array($_POST["id"]) || count($_POST["id"]) == 0) {
859  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
860  $ilCtrl->redirect($this, "listAssignments");
861  } else {
862  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
863  $cgui = new ilConfirmationGUI();
864  $cgui->setFormAction($ilCtrl->getFormAction($this));
865  $cgui->setHeaderText($lng->txt("exc_conf_del_assignments"));
866  $cgui->setCancel($lng->txt("cancel"), "listAssignments");
867  $cgui->setConfirm($lng->txt("delete"), "deleteAssignments");
868 
869  foreach ($_POST["id"] as $i) {
870  $cgui->addItem("id[]", $i, ilExAssignment::lookupTitle($i));
871  }
872 
873  $tpl->setContent($cgui->getHTML());
874  }
875  }
876 
880  public function deleteAssignmentsObject()
881  {
883  $lng = $this->lng;
884 
885  $delete = false;
886  if (is_array($_POST["id"])) {
887  foreach ($_POST["id"] as $id) {
888  $ass = new ilExAssignment(ilUtil::stripSlashes($id));
889  $ass->delete();
890  $delete = true;
891  }
892  }
893 
894  if ($delete) {
895  ilUtil::sendSuccess($lng->txt("exc_assignments_deleted"), true);
896  }
897  $ilCtrl->setParameter($this, "ass_id", "");
898  $ilCtrl->redirect($this, "listAssignments");
899  }
900 
904  public function saveAssignmentOrderObject()
905  {
906  $lng = $this->lng;
908 
909  ilExAssignment::saveAssOrderOfExercise($this->exercise_id, $_POST["order"]);
910 
911  ilUtil::sendSuccess($lng->txt("exc_saved_order"), true);
912  $ilCtrl->redirect($this, "listAssignments");
913  }
914 
919  {
920  $lng = $this->lng;
922 
923  ilExAssignment::orderAssByDeadline($this->exercise_id);
924 
925  ilUtil::sendSuccess($lng->txt("exc_saved_order"), true);
926  $ilCtrl->redirect($this, "listAssignments");
927  }
928 
932  public function setAssignmentHeader()
933  {
934  $ilTabs = $this->tabs;
935  $lng = $this->lng;
937  $tpl = $this->tpl;
938  $ilHelp = $this->help;
939 
940  $tpl->setTitle($this->assignment->getTitle());
941  $tpl->setDescription("");
942 
943  $ilTabs->clearTargets();
944  $ilHelp->setScreenIdComponent("exc");
945 
946  $ilTabs->setBackTarget(
947  $lng->txt("back"),
948  $ilCtrl->getLinkTarget($this, "listAssignments")
949  );
950 
951  $ilTabs->addTab(
952  "ass_settings",
953  $lng->txt("settings"),
954  $ilCtrl->getLinkTarget($this, "editAssignment")
955  );
956 
957  if ($this->assignment->getType() != ilExAssignment::TYPE_UPLOAD_TEAM &&
958  $this->assignment->getPeerReview()) {
959  $ilTabs->addTab(
960  "peer_settings",
961  $lng->txt("exc_peer_review"),
962  $ilCtrl->getLinkTarget($this, "editPeerReview")
963  );
964  }
965 
966  $ilTabs->addTab(
967  "ass_files",
968  $lng->txt("exc_instruction_files"),
969  $ilCtrl->getLinkTargetByClass(array("ilexassignmenteditorgui", "ilexassignmentfilesystemgui"), "listFiles")
970  );
971  }
972 
974  {
976 
977  if (!$this->assignment ||
978  !$this->assignment->getFeedbackFile()) {
979  $ilCtrl->redirect($this, "returnToParent");
980  }
981 
982  ilUtil::deliverFile($this->assignment->getGlobalFeedbackFilePath(), $this->assignment->getFeedbackFile());
983  }
984 
985 
986  //
987  // PEER REVIEW
988  //
989 
990  protected function initPeerReviewForm()
991  {
993  $lng = $this->lng;
994 
995  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
996  $form = new ilPropertyFormGUI();
997  $form->setTitle($lng->txt("exc_peer_review"));
998  $form->setFormAction($ilCtrl->getFormAction($this));
999 
1000  $peer_min = new ilNumberInputGUI($lng->txt("exc_peer_review_min_number"), "peer_min");
1001  $peer_min->setInfo($lng->txt("exc_peer_review_min_number_info")); // #16161
1002  $peer_min->setRequired(true);
1003  $peer_min->setSize(3);
1004  $peer_min->setValue(2);
1005  $form->addItem($peer_min);
1006 
1007  $peer_unlock = new ilRadioGroupInputGUI($lng->txt("exc_peer_review_simple_unlock"), "peer_unlock");
1008  $peer_unlock->addOption(new ilRadioOption($lng->txt("exc_peer_review_simple_unlock_active"), 1));
1009  $peer_unlock->addOption(new ilRadioOption($lng->txt("exc_peer_review_simple_unlock_inactive"), 0));
1010  $peer_unlock->setRequired(true);
1011  $peer_unlock->setValue(0);
1012  $form->addItem($peer_unlock);
1013 
1014  if ($this->enable_peer_review_completion) {
1015  $peer_cmpl = new ilRadioGroupInputGUI($lng->txt("exc_peer_review_completion"), "peer_valid");
1016  $option = new ilRadioOption($lng->txt("exc_peer_review_completion_none"), ilExAssignment::PEER_REVIEW_VALID_NONE);
1017  $option->setInfo($lng->txt("exc_peer_review_completion_none_info"));
1018  $peer_cmpl->addOption($option);
1019  $option = new ilRadioOption($lng->txt("exc_peer_review_completion_one"), ilExAssignment::PEER_REVIEW_VALID_ONE);
1020  $option->setInfo($lng->txt("exc_peer_review_completion_one_info"));
1021  $peer_cmpl->addOption($option);
1022  $option = new ilRadioOption($lng->txt("exc_peer_review_completion_all"), ilExAssignment::PEER_REVIEW_VALID_ALL);
1023  $option->setInfo($lng->txt("exc_peer_review_completion_all_info"));
1024  $peer_cmpl->addOption($option);
1025  $peer_cmpl->setRequired(true);
1026  $peer_cmpl->setValue(ilExAssignment::PEER_REVIEW_VALID_NONE);
1027  $form->addItem($peer_cmpl);
1028  }
1029 
1030  $peer_dl = new ilDateTimeInputGUI($lng->txt("exc_peer_review_deadline"), "peer_dl");
1031  $peer_dl->setInfo($lng->txt("exc_peer_review_deadline_info"));
1032  $peer_dl->setShowTime(true);
1033  $form->addItem($peer_dl);
1034 
1035  $peer_prsl = new ilCheckboxInputGUI($lng->txt("exc_peer_review_personal"), "peer_prsl");
1036  $peer_prsl->setInfo($lng->txt("exc_peer_review_personal_info"));
1037  $form->addItem($peer_prsl);
1038 
1039 
1040  // criteria
1041 
1042  $cats = new ilRadioGroupInputGUI($lng->txt("exc_criteria_catalogues"), "crit_cat");
1043  $form->addItem($cats);
1044 
1045  // default (no catalogue)
1046 
1047  $def = new ilRadioOption($lng->txt("exc_criteria_catalogue_default"), -1);
1048  $cats->addOption($def);
1049 
1050  $peer_text = new ilCheckboxInputGUI($lng->txt("exc_peer_review_text"), "peer_text");
1051  $def->addSubItem($peer_text);
1052 
1053  $peer_char = new ilNumberInputGUI($lng->txt("exc_peer_review_min_chars"), "peer_char");
1054  $peer_char->setInfo($lng->txt("exc_peer_review_min_chars_info"));
1055  $peer_char->setSize(3);
1056  $peer_text->addSubItem($peer_char);
1057 
1058  $peer_rating = new ilCheckboxInputGUI($lng->txt("exc_peer_review_rating"), "peer_rating");
1059  $def->addSubItem($peer_rating);
1060 
1061  $peer_file = new ilCheckboxInputGUI($lng->txt("exc_peer_review_file"), "peer_file");
1062  $peer_file->setInfo($lng->txt("exc_peer_review_file_info"));
1063  $def->addSubItem($peer_file);
1064 
1065  // catalogues
1066 
1067  include_once "Modules/Exercise/classes/class.ilExcCriteriaCatalogue.php";
1068  $cat_objs = ilExcCriteriaCatalogue::getInstancesByParentId($this->exercise_id);
1069  if (sizeof($cat_objs)) {
1070  include_once "Modules/Exercise/classes/class.ilExcCriteria.php";
1071  foreach ($cat_objs as $cat_obj) {
1072  $crits = ilExcCriteria::getInstancesByParentId($cat_obj->getId());
1073 
1074  // only non-empty catalogues
1075  if (sizeof($crits)) {
1076  $titles = array();
1077  foreach ($crits as $crit) {
1078  $titles[] = $crit->getTitle();
1079  }
1080  $opt = new ilRadioOption($cat_obj->getTitle(), $cat_obj->getId());
1081  $opt->setInfo(implode(", ", $titles));
1082  $cats->addOption($opt);
1083  }
1084  }
1085  } else {
1086  // see ilExcCriteriaCatalogueGUI::view()
1087  $url = $ilCtrl->getLinkTargetByClass("ilexccriteriacataloguegui", "");
1088  $def->setInfo('<a href="' . $url . '">[+] ' .
1089  $lng->txt("exc_add_criteria_catalogue") .
1090  '</a>');
1091  }
1092 
1093 
1094  $form->addCommandButton("updatePeerReview", $lng->txt("save"));
1095  $form->addCommandButton("editAssignment", $lng->txt("cancel"));
1096 
1097  return $form;
1098  }
1099 
1100  public function editPeerReviewObject(ilPropertyFormGUI $a_form = null)
1101  {
1102  $tpl = $this->tpl;
1103  $ilTabs = $this->tabs;
1104  $tpl = $this->tpl;
1105 
1106  $this->setAssignmentHeader();
1107  $ilTabs->activateTab("peer_settings");
1108 
1109  if ($a_form === null) {
1110  $a_form = $this->initPeerReviewForm();
1111  $this->getPeerReviewValues($a_form);
1112  }
1113  $tpl->setContent($a_form->getHTML());
1114  }
1115 
1116  protected function getPeerReviewValues($a_form)
1117  {
1118  $values = array();
1119 
1120  if ($this->assignment->getPeerReviewDeadline() > 0) {
1121  $values["peer_dl"] = new ilDateTime($this->assignment->getPeerReviewDeadline(), IL_CAL_UNIX);
1122  }
1123 
1124  $a_form->setValuesByArray($values);
1125 
1126  $this->handleDisabledPeerFields($a_form, true);
1127  }
1128 
1130  {
1131  $a_form->getItemByPostVar("peer_min")->setValue($this->assignment->getPeerReviewMin());
1132  $a_form->getItemByPostVar("peer_prsl")->setChecked($this->assignment->hasPeerReviewPersonalized());
1133  $a_form->getItemByPostVar("peer_unlock")->setValue((int) $this->assignment->getPeerReviewSimpleUnlock());
1134 
1135  if ($this->enable_peer_review_completion) {
1136  $a_form->getItemByPostVar("peer_valid")->setValue($this->assignment->getPeerReviewValid());
1137  }
1138 
1139  $cat = $this->assignment->getPeerReviewCriteriaCatalogue();
1140  if ($cat < 1) {
1141  $cat = -1;
1142 
1143  // default / no catalogue
1144  $a_form->getItemByPostVar("peer_text")->setChecked($this->assignment->hasPeerReviewText());
1145  $a_form->getItemByPostVar("peer_rating")->setChecked($this->assignment->hasPeerReviewRating());
1146  $a_form->getItemByPostVar("peer_file")->setChecked($this->assignment->hasPeerReviewFileUpload());
1147  if ($this->assignment->getPeerReviewChars() > 0) {
1148  $a_form->getItemByPostVar("peer_char")->setValue($this->assignment->getPeerReviewChars());
1149  }
1150  }
1151  $a_form->getItemByPostVar("crit_cat")->setValue($cat);
1152  }
1153 
1154  protected function handleDisabledPeerFields(ilPropertyFormGUI $a_form, $a_force_set_values = false)
1155  {
1156  // #14450
1157  include_once "Modules/Exercise/classes/class.ilExPeerReview.php";
1158  $peer_review = new ilExPeerReview($this->assignment);
1159  if ($peer_review->hasPeerReviewGroups()) {
1160  // JourFixe, 2015-05-11 - editable again
1161  // $a_form->getItemByPostVar("peer_dl")->setDisabled(true);
1162 
1163  $a_form->getItemByPostVar("peer_min")->setDisabled(true);
1164  $a_form->getItemByPostVar("peer_prsl")->setDisabled(true);
1165  $a_form->getItemByPostVar("peer_unlock")->setDisabled(true);
1166 
1167  if ($this->enable_peer_review_completion) {
1168  $a_form->getItemByPostVar("peer_valid")->setDisabled(true);
1169  }
1170 
1171  $a_form->getItemByPostVar("crit_cat")->setDisabled(true);
1172  $a_form->getItemByPostVar("peer_text")->setDisabled(true);
1173  $a_form->getItemByPostVar("peer_char")->setDisabled(true);
1174  $a_form->getItemByPostVar("peer_rating")->setDisabled(true);
1175  $a_form->getItemByPostVar("peer_file")->setDisabled(true);
1176 
1177  // required number input is a problem
1178  $min = new ilHiddenInputGUI("peer_min");
1179  $min->setValue($this->assignment->getPeerReviewMin());
1180  $a_form->addItem($min);
1181  }
1182 
1183  if ($a_force_set_values ||
1184  $peer_review->hasPeerReviewGroups()) {
1185  $this->setDisabledPeerReviewFieldValues($a_form);
1186  }
1187  }
1188 
1189  protected function processPeerReviewForm(ilPropertyFormGUI $a_form)
1190  {
1191  $lng = $this->lng;
1192 
1193  $protected_peer_review_groups = false;
1194  include_once "Modules/Exercise/classes/class.ilExPeerReview.php";
1195  $peer_review = new ilExPeerReview($this->assignment);
1196  if ($peer_review->hasPeerReviewGroups()) {
1197  $protected_peer_review_groups = true;
1198  }
1199 
1200  $valid = $a_form->checkInput();
1201  if ($valid) {
1202  // dates
1203  $time_deadline = $this->assignment->getDeadline();
1204  $time_deadline_ext = $this->assignment->getExtendedDeadline();
1205  $time_deadline_max = max($time_deadline, $time_deadline_ext);
1206 
1207  $date = $a_form->getItemByPostVar("peer_dl")->getDate();
1208  $time_peer = $date
1209  ? $date->get(IL_CAL_UNIX)
1210  : null;
1211 
1212  // peer < any deadline?
1213  if ($time_peer && $time_deadline_max && $time_peer < $time_deadline_max) {
1214  $a_form->getItemByPostVar("peer_dl")
1215  ->setAlert($lng->txt("exc_peer_deadline_mismatch"));
1216  $valid = false;
1217  }
1218 
1219  if (!$protected_peer_review_groups) {
1220  if ($a_form->getInput("crit_cat") < 0 &&
1221  !$a_form->getInput("peer_text") &&
1222  !$a_form->getInput("peer_rating") &&
1223  !$a_form->getInput("peer_file")) {
1224  $a_form->getItemByPostVar("peer_file")
1225  ->setAlert($lng->txt("select_one"));
1226  $valid = false;
1227  }
1228  }
1229 
1230  if ($valid) {
1231  $res = array();
1232  $res["peer_dl"] = $time_peer;
1233 
1234  if ($protected_peer_review_groups) {
1235  $res["peer_min"] = $this->assignment->getPeerReviewMin();
1236  $res["peer_unlock"] = $this->assignment->getPeerReviewSimpleUnlock();
1237  $res["peer_prsl"] = $this->assignment->hasPeerReviewPersonalized();
1238  $res["peer_valid"] = $this->assignment->getPeerReviewValid();
1239 
1240  $res["peer_text"] = $this->assignment->hasPeerReviewText();
1241  $res["peer_rating"] = $this->assignment->hasPeerReviewRating();
1242  $res["peer_file"] = $this->assignment->hasPeerReviewFileUpload();
1243  $res["peer_char"] = $this->assignment->getPeerReviewChars();
1244  $res["crit_cat"] = $this->assignment->getPeerReviewCriteriaCatalogue();
1245 
1246  $res["peer_valid"] = $this->enable_peer_review_completion
1247  ? $res["peer_valid"]
1248  : null;
1249  } else {
1250  $res["peer_min"] = $a_form->getInput("peer_min");
1251  $res["peer_unlock"] = $a_form->getInput("peer_unlock");
1252  $res["peer_prsl"] = $a_form->getInput("peer_prsl");
1253  $res["peer_valid"] = $a_form->getInput("peer_valid");
1254 
1255  $res["peer_text"] = $a_form->getInput("peer_text");
1256  $res["peer_rating"] = $a_form->getInput("peer_rating");
1257  $res["peer_file"] = $a_form->getInput("peer_file");
1258  $res["peer_char"] = $a_form->getInput("peer_char");
1259  $res["crit_cat"] = $a_form->getInput("crit_cat");
1260  }
1261 
1262  return $res;
1263  } else {
1264  ilUtil::sendFailure($lng->txt("form_input_not_valid"));
1265  }
1266  }
1267  }
1268 
1269  protected function importPeerReviewFormToAssignment(ilExAssignment $a_ass, array $a_input)
1270  {
1271  $a_ass->setPeerReviewMin($a_input["peer_min"]);
1272  $a_ass->setPeerReviewDeadline($a_input["peer_dl"]);
1273  $a_ass->setPeerReviewSimpleUnlock($a_input["peer_unlock"]);
1274  $a_ass->setPeerReviewPersonalized($a_input["peer_prsl"]);
1275 
1276  // #18964
1277  $a_ass->setPeerReviewValid($a_input["peer_valid"]
1278  ? $a_input["peer_valid"]
1280 
1281  $a_ass->setPeerReviewFileUpload($a_input["peer_file"]);
1282  $a_ass->setPeerReviewChars($a_input["peer_char"]);
1283  $a_ass->setPeerReviewText($a_input["peer_text"]);
1284  $a_ass->setPeerReviewRating($a_input["peer_rating"]);
1285  $a_ass->setPeerReviewCriteriaCatalogue($a_input["crit_cat"] > 0
1286  ? $a_input["crit_cat"]
1287  : null);
1288 
1289  $a_ass->update();
1290  }
1291 
1292  protected function updatePeerReviewObject()
1293  {
1294  $tpl = $this->tpl;
1295  $lng = $this->lng;
1296  $ilCtrl = $this->ctrl;
1297  $ilTabs = $this->tabs;
1298 
1299  $form = $this->initPeerReviewForm();
1300  $input = $this->processPeerReviewForm($form);
1301  if (is_array($input)) {
1302  $this->importPeerReviewFormToAssignment($this->assignment, $input);
1303 
1304  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
1305  $ilCtrl->redirect($this, "editPeerReview");
1306  } else {
1307  $this->setAssignmentHeader();
1308  $ilTabs->activateTab("peer_settings");
1309 
1310  $form->setValuesByPost();
1312  $tpl->setContent($form->getHtml());
1313  }
1314  }
1315 
1316 
1317  //
1318  // TEAM
1319  //
1320 
1322  {
1323  $ilCtrl = $this->ctrl;
1324  $ilTabs = $this->tabs;
1325  $lng = $this->lng;
1326  $tpl = $this->tpl;
1327 
1328  if (!$this->assignment) {
1329  $ilCtrl->redirect($this, "listAssignments");
1330  }
1331 
1332  $ilTabs->clearTargets();
1333  $ilTabs->setBackTarget(
1334  $lng->txt("back"),
1335  $ilCtrl->getLinkTarget($this, "listAssignments")
1336  );
1337 
1338  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1339  $form = new ilPropertyFormGUI();
1340  $form->setTitle($lng->txt("exc_team_assignment_adopt"));
1341  $form->setFormAction($ilCtrl->getFormAction($this, "adoptTeamAssignments"));
1342 
1343  include_once "Modules/Exercise/classes/class.ilExAssignmentTeam.php";
1344  $options = ilExAssignmentTeam::getAdoptableTeamAssignments($this->assignment->getExerciseId());
1345 
1346  // we must not have existing teams in assignment
1347  if (array_key_exists($this->assignment->getId(), $options)) {
1348  $ilCtrl->redirect($this, "listAssignments");
1349  }
1350 
1351  $teams = new ilRadioGroupInputGUI($lng->txt("exc_assignment"), "ass_adpt");
1352  $teams->setValue(-1);
1353 
1354  $teams->addOption(new ilRadioOption($lng->txt("exc_team_assignment_adopt_none"), -1));
1355 
1356  foreach ($options as $id => $item) {
1357  $option = new ilRadioOption($item["title"], $id);
1358  $option->setInfo($lng->txt("exc_team_assignment_adopt_teams") . ": " . $item["teams"]);
1359  $teams->addOption($option);
1360  }
1361 
1362  $form->addItem($teams);
1363 
1364  $form->addCommandButton("adoptTeamAssignments", $lng->txt("save"));
1365  $form->addCommandButton("listAssignments", $lng->txt("cancel"));
1366 
1367  $tpl->setContent($form->getHTML());
1368  }
1369 
1370  public function adoptTeamAssignmentsObject()
1371  {
1372  $ilCtrl = $this->ctrl;
1373  $lng = $this->lng;
1374 
1375  $src_ass_id = (int) $_POST["ass_adpt"];
1376 
1377  if ($this->assignment &&
1378  $src_ass_id > 0) {
1379  include_once "Modules/Exercise/classes/class.ilExAssignmentTeam.php";
1380  ilExAssignmentTeam::adoptTeams($src_ass_id, $this->assignment->getId());
1381 
1382  ilUtil::sendSuccess($lng->txt("settings_saved"), true);
1383  }
1384 
1385  $ilCtrl->redirect($this, "listAssignments");
1386  }
1387 }
$files
Definition: add-vimline.php:18
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
Class ilExAssignmentEditorGUI.
This class represents an option in a radio group.
setTitle($a_val)
Set title.
Exercise assignment.
getItemByPostVar($a_post_var)
Get Item by POST variable.
This class represents a selection list property in a property form.
This class represents a property form user interface.
editPeerReviewObject(ilPropertyFormGUI $a_form=null)
setMaxFile($a_value)
Set max number of uploads.
setFeedbackFile($a_value)
Set (global) feedback file.
setPeerReviewMin($a_value)
Set peer review minimum.
global $DIC
Definition: saml.php:7
confirmAssignmentsDeletionObject()
Confirm assignments deletion.
setMaxCharLimit($a_val)
Set limit maximum characters.
setTeamTutor($a_value)
Set team management by tutor.
setPortfolioTemplateId($a_val)
Set portfolio template id.
setPeerReviewFileUpload($a_val)
Set peer review file upload.
This class represents a section header in a property form.
This class represents a file property in a property form.
getId()
Get assignment id.
processForm(ilPropertyFormGUI $a_form)
Custom form validation.
setMinCharLimit($a_val)
Set limit minimum characters.
$valid
This class represents a file wizard property in a property form.
setPeerReview($a_value)
Toggle peer review.
setPeerReviewDeadline($a_val)
Set peer review deadline (timestamp)
if(!array_key_exists('StateId', $_REQUEST)) $id
save()
Save assignment.
setAssignmentHeader()
Set assignment header.
This class represents a checkbox property in a property form.
setPeerReviewValid($a_value)
Set peer review validation.
setTitle($a_val)
Set title.
addItem($a_item)
Add Item (Property, SectionHeader).
static adoptTeams($a_source_ass_id, $a_target_ass_id, $a_user_id=null, $a_exc_ref_id=null)
const IL_CAL_UNIX
setInfo($a_info)
Set Info.
setInstruction($a_val)
Set instruction.
This class represents a date/time property in a property form.
global $ilCtrl
Definition: ilias.php:18
allowDecimals($a_value)
Toggle Decimals.
static getAdoptableTeamAssignments($a_exercise_id, $a_exclude_ass_id=null, $a_user_id=null)
setInfo($a_info)
Set Information Text.
getTypeDropdown()
Get type selection dropdown.
getAssignmentValues(ilPropertyFormGUI $a_form)
Get current values for assignment from.
$a_type
Definition: workflow.php:92
setStartTime($a_val)
Set start time (timestamp)
This class represents a hidden form property in a property form.
Exercise peer review.
setDeadline($a_val)
Set deadline (timestamp)
This class represents a property in a property form.
addOption($a_option)
Add Option.
foreach($_POST as $key=> $value) $res
if(isset($_POST['submit'])) $form
static saveAssOrderOfExercise($a_ex_id, $a_order)
Save ordering of all assignments of an exercise.
static getInstancesByParentId($a_parent_id)
addSubItem($a_item)
Add Subitem.
processPeerReviewForm(ilPropertyFormGUI $a_form)
handleDisabledPeerFields(ilPropertyFormGUI $a_form, $a_force_set_values=false)
setPeerReviewCriteriaCatalogue($a_value)
Set peer review criteria catalogue id.
This class represents a number property in a property form.
setPeerReviewPersonalized($a_val)
Set peer review personalized.
setPeerReviewRating($a_val)
Set peer review rating.
Class ilExPeerReviewGUI.
uploadAssignmentFiles($a_files)
Upload assignment files (from creation form)
setPeerReviewSimpleUnlock($a_value)
Set peer review simple unlock.
__construct($a_exercise_id, $a_enable_peer_review_completion_settings, ilExAssignment $a_ass=null)
Constructor.
This class represents a text property in a property form.
checkInput()
Check Post Input.
Date and time handling
setPeerReviewText($a_val)
Set peer review text.
handleGlobalFeedbackFileUpload(array $a_file)
setMaxLength($a_maxlength)
Set Max Length.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
setOptions($a_options)
Set Options.
handleDisabledFields(ilPropertyFormGUI $a_form, $a_force_set_values=false)
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
setFeedbackCron($a_value)
Toggle (global) feedback file cron.
orderAssignmentsByDeadlineObject()
Order by deadline.
settings()
Definition: settings.php:2
static getInstancesByParentId($a_parent_id)
saveAssignmentOrderObject()
Save assignments order.
setFeedbackDate($a_value)
Set (global) feedback file availability date.
importFormToAssignment(ilExAssignment $a_ass, array $a_input)
Import form values to assignment.
global $ilSetting
Definition: privfeed.php:17
setDate($a_date, $a_format)
Set date.
This class represents a text area property in a property form.
setPeerReviewChars($a_value)
Set peer review minimum characters.
$i
Definition: disco.tpl.php:19
$def
Definition: croninfo.php:21
initAssignmentForm($a_type, $a_mode="create")
Init assignment form.
$url
importPeerReviewFormToAssignment(ilExAssignment $a_ass, array $a_input)
setDisabledPeerReviewFieldValues(ilPropertyFormGUI $a_form)
setMandatory($a_val)
Set mandatory.
static orderAssByDeadline($a_ex_id)
Order assignments by deadline date.
setExtendedDeadline($a_val)
Set extended deadline (timestamp)
$_POST["username"]
setValuesByArray($a_values, $a_restrict_to_value_keys=false)
Set form values from an array.
setRequired($a_required)
Set Required.
static lookupTitle($a_id)
Lookup title.
setShowTime($a_showtime)
Set Show Time Information.
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
setDisabledFieldValues(ilPropertyFormGUI $a_form)
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
Confirmation screen class.
deleteAssignmentsObject()
Delete assignments.