ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilExSubmissionObjectGUI.php
Go to the documentation of this file.
1 <?php
2 
20 
30 {
32 
36  public function __construct(
37  ilObjExercise $a_exercise,
38  ilExSubmission $a_submission
39  ) {
40  parent::__construct($a_exercise, $a_submission);
41  $this->selected_wsp_obj_id = $this->request->getSelectedWspObjId();
42  }
43 
44  public function executeCommand(): void
45  {
46  $ilCtrl = $this->ctrl;
47 
48  if (!$this->submission->canView()) {
49  $this->returnToParentObject();
50  }
51 
52  $class = $ilCtrl->getNextClass($this);
53  $cmd = $ilCtrl->getCmd();
54 
55  switch ($class) {
56  default:
57  $this->{$cmd . "Object"}();
58  break;
59  }
60  }
61 
62  public static function getOverviewContent(
63  ilInfoScreenGUI $a_info,
64  ilExSubmission $a_submission
65  ): void {
66  switch ($a_submission->getAssignment()->getType()) {
68  self::getOverviewContentBlog($a_info, $a_submission);
69  break;
70 
72  self::getOverviewContentPortfolio($a_info, $a_submission);
73  break;
74  }
75  }
76 
77  protected static function getOverviewContentBlog(
78  ilInfoScreenGUI $a_info,
79  ilExSubmission $a_submission
80  ): void {
81  global $DIC;
82 
83  $lng = $DIC->language();
84  $ilCtrl = $DIC->ctrl();
85 
86  $wsp_tree = new ilWorkspaceTree($a_submission->getUserId());
87 
88  // #12939
89  if (!$wsp_tree->getRootId()) {
90  $wsp_tree->createTreeForUser($a_submission->getUserId());
91  }
92 
93  $files_str = "";
94  $buttons_str = "";
95  $valid_blog = false;
96  $selected_blog = $a_submission->getSelectedObject();
97  if ($selected_blog) {
98  $blog_id = (int) $selected_blog["filetitle"];
99  $node = $wsp_tree->getNodeData($blog_id);
100  if ($node["title"]) {
101  // #10116
102  $ilCtrl->setParameterByClass("ilobjbloggui", "wsp_id", $blog_id);
103  $blog_link = $ilCtrl->getLinkTargetByClass(array("ildashboardgui", "ilpersonalworkspacegui", "ilobjbloggui"), "");
104  $ilCtrl->setParameterByClass("ilobjbloggui", "wsp_id", "");
105  $files_str = '<a href="' . $blog_link . '">' .
106  $node["title"] . '</a>';
107  $valid_blog = true;
108  }
109  // remove invalid resource if no upload yet (see download below)
110  elseif (substr($selected_blog["filename"], -1) == "/") {
111  // #16887
112  $a_submission->deleteResourceObject();
113  }
114  }
115  if ($a_submission->canSubmit()) {
116  if (!$valid_blog) {
117  $button = ilLinkButton::getInstance();
118  $button->setCaption("exc_create_blog");
119  $button->setUrl($ilCtrl->getLinkTargetByClass(array("ilExSubmissionGUI", "ilExSubmissionObjectGUI"), "createBlog"));
120  $buttons_str .= $button->render();
121  }
122  // #10462
123  $blogs = count($wsp_tree->getObjectsFromType("blog"));
124  if ((!$valid_blog && $blogs)
125  || ($valid_blog && $blogs > 1)) {
126  $button = ilLinkButton::getInstance();
127  $button->setCaption("exc_select_blog" . ($valid_blog ? "_change" : ""));
128  $button->setUrl($ilCtrl->getLinkTargetByClass(array("ilExSubmissionGUI", "ilExSubmissionObjectGUI"), "selectBlog"));
129  $buttons_str .= " " . $button->render();
130  }
131  }
132 
133  // todo: move this to ks somehow
134  if ($buttons_str != "") {
135  $files_str .= "<p>" . $buttons_str . "</p>";
136  }
137 
138 
139  if ($files_str) {
140  $a_info->addProperty($lng->txt("exc_blog_returned"), $files_str);
141  }
142  if ($a_submission->hasSubmitted()) {
143  $ilCtrl->setParameterByClass("ilExSubmissionFileGUI", "delivered", $selected_blog["returned_id"]);
144  $dl_link = $ilCtrl->getLinkTargetByClass(array("ilExSubmissionGUI", "ilExSubmissionFileGUI"), "download");
145  $ilCtrl->setParameterByClass("ilExSubmissionFileGUI", "delivered", "");
146 
147  $button = ilLinkButton::getInstance();
148  $button->setCaption("download");
149  $button->setUrl($dl_link);
150 
151  $a_info->addProperty($lng->txt("exc_files_returned"), $button->render());
152  }
153  }
154 
155  protected static function getOverviewContentPortfolio(ilInfoScreenGUI $a_info, ilExSubmission $a_submission): void
156  {
158  global $DIC;
159 
160  $back_ref_id = $DIC->http()->wrapper()->query()->retrieve(
161  "ref_id",
162  $DIC->refinery()->kindlyTo()->int()
163  ) ?? 0;
164 
165  $request = $DIC->exercise()->internal()->gui()->request();
166 
167 
168  $lng = $DIC->language();
169  $ilCtrl = $DIC->ctrl();
170 
171  $files_str = "";
172  $buttons_str = "";
173  $valid_prtf = false;
174  $selected_prtf = $a_submission->getSelectedObject();
175  if ($selected_prtf) {
176  $portfolio_id = (int) $selected_prtf["filetitle"];
177 
178  // #11746
179  if (ilObject::_exists($portfolio_id, false, "prtf")) {
180  $portfolio = new ilObjPortfolio($portfolio_id, false);
181  if ($portfolio->getTitle()) {
182  // #10116 / #12791
183  $ilCtrl->setParameterByClass("ilobjportfoliogui", "prt_id", $portfolio_id);
184 
185  $ref_id = $request->getRefId();
186  $ilCtrl->setParameterByClass("ilobjportfoliogui", "ref_id", $ref_id);
187  $ilCtrl->setParameterByClass("ilobjportfoliogui", "exc_back_ref_id", $back_ref_id);
188 
189  $prtf_link = $ilCtrl->getLinkTargetByClass(array("ildashboardgui", "ilportfoliorepositorygui", "ilobjportfoliogui"), "view");
190  $ilCtrl->setParameterByClass("ilobjportfoliogui", "prt_id", "");
191  $ilCtrl->setParameterByClass("ilobjportfoliogui", "ref_id", "");
192 
193 
194  $files_str = '<a href="' . $prtf_link .
195  '">' . $portfolio->getTitle() . '</a>';
196  $valid_prtf = true;
197  }
198  }
199  // remove invalid resource if no upload yet (see download below)
200  elseif (substr($selected_prtf["filename"], -1) == "/") {
201  // #16887
202  $a_submission->deleteResourceObject();
203  }
204  }
205  if ($a_submission->canSubmit()) {
206  if (!$valid_prtf) {
207  $button = ilLinkButton::getInstance();
208  $button->setCaption("exc_create_portfolio");
209  $button->setUrl($ilCtrl->getLinkTargetByClass(array("ilExSubmissionGUI", "ilExSubmissionObjectGUI"), "createPortfolioFromAssignment"));
210 
211  $buttons_str .= $button->render();
212  }
213  // #10462
214  //selectPortfolio ( remove it? )
215  $prtfs = count(ilObjPortfolio::getPortfoliosOfUser($a_submission->getUserId()));
216  if ((!$valid_prtf && $prtfs)
217  || ($valid_prtf && $prtfs > 1)) {
218  $button = ilLinkButton::getInstance();
219  $button->setCaption("exc_select_portfolio" . ($valid_prtf ? "_change" : ""));
220  $button->setUrl($ilCtrl->getLinkTargetByClass(array("ilExSubmissionGUI", "ilExSubmissionObjectGUI"), "selectPortfolio"));
221  $buttons_str .= " " . $button->render();
222  }
223  if ($valid_prtf) {
224  $button = ilLinkButton::getInstance();
225  $button->setCaption('exc_select_portfolio_unlink');
226  $button->setUrl($ilCtrl->getLinkTargetByClass(array("ilExSubmissionGUI", "ilExSubmissionObjectGUI"), "askUnlinkPortfolio"));
227  $buttons_str .= " " . $button->render();
228  }
229  }
230  // todo: move this to ks somehow
231  if ($buttons_str != "") {
232  $files_str .= "<p>" . $buttons_str . "</p>";
233  }
234  if ($files_str) {
235  $a_info->addProperty($lng->txt("exc_portfolio_returned"), $files_str);
236  }
237  if ($a_submission->hasSubmitted()) {
238  $ilCtrl->setParameterByClass("ilExSubmissionFileGUI", "delivered", $selected_prtf["returned_id"]);
239  $dl_link = $ilCtrl->getLinkTargetByClass(array("ilExSubmissionGUI", "ilExSubmissionFileGUI"), "download");
240  $ilCtrl->setParameterByClass("ilExSubmissionFileGUI", "delivered", "");
241 
242  $button = ilLinkButton::getInstance();
243  $button->setCaption("download");
244  $button->setUrl($dl_link);
245 
246  $a_info->addProperty($lng->txt("exc_files_returned"), $button->render());
247  }
248  }
249 
250  protected function renderResourceSelection(
251  string $a_title,
252  string $a_info,
253  string $a_cmd,
254  string $a_explorer_cmd,
255  array $a_items = null
256  ): void {
257  if (!$this->submission->canSubmit()) {
258  $this->tpl->setOnScreenMessage('info', $this->lng->txt("exercise_time_over"), true);
259  $this->returnToParentObject();
260  }
261 
262  $html = "";
263  $tpl = new ilTemplate("tpl.exc_select_resource.html", true, true, "Modules/Exercise");
264 
265  if (is_array($a_items)) {
266  $tpl->setCurrentBlock("item");
267  foreach ($a_items as $item_id => $item_title) {
268  $tpl->setVariable("ITEM_ID", $item_id);
269  $tpl->setVariable("ITEM_TITLE", $item_title);
271  }
272  $tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
273  $tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
274  $tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
275  $tpl->setVariable("CMD_SUBMIT", $a_cmd);
276  $tpl->setVariable("CMD_CANCEL", "returnToParent");
277  $html = $tpl->get();
278  } elseif ($a_explorer_cmd) {
279  $html = $this->renderWorkspaceExplorer($a_explorer_cmd);
280  }
281 
282 
283  $this->tpl->setOnScreenMessage('info', $this->lng->txt($a_info));
284 
285  $title = $this->lng->txt($a_title) . ": " . $this->assignment->getTitle();
286 
288  $panel->setBody($html);
289  $panel->setHeading($title);
290 
291  $this->tpl->setContent($panel->getHTML());
292  }
293 
294 
295  //
296  // BLOG
297  //
298 
299  protected function createBlogObject(): void
300  {
301  $this->handleTabs();
302 
304  "exc_create_blog",
305  "exc_create_blog_select_info",
306  "saveBlog",
307  "createBlog"
308  );
309  }
310 
311  protected function selectBlogObject(): void
312  {
313  $this->handleTabs();
314 
316  "exc_select_blog",
317  "exc_select_blog_info",
318  "setSelectedBlog",
319  "selectBlog"
320  );
321  }
322 
327  protected function saveBlogObject(): void
328  {
329  if (!$this->submission->canSubmit()) {
330  $this->tpl->setOnScreenMessage('info', $this->lng->txt("exercise_time_over"), true);
331  $this->returnToParentObject();
332  }
333 
334  if ($this->selected_wsp_obj_id == 0) {
335  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("select_one"));
336  $this->createBlogObject();
337  return;
338  }
339 
340  $parent_node = $this->selected_wsp_obj_id;
341 
342  $blog = new ilObjBlog();
343  $blog->setTitle($this->exercise->getTitle() . " - " . $this->assignment->getTitle());
344  $blog->create();
345 
346  $tree = new ilWorkspaceTree($this->submission->getUserId()); // #15993
347 
348  $node_id = $tree->insertObject($parent_node, $blog->getId());
349 
350  $access_handler = new ilWorkspaceAccessHandler($tree);
351  $access_handler->setPermissions($parent_node, $node_id);
352 
353  $this->submission->deleteAllFiles();
354  $this->handleRemovedUpload();
355 
356  $this->submission->addResourceObject($node_id);
357 
358  $this->tpl->setOnScreenMessage('success', $this->lng->txt("exc_blog_created"), true);
359  $this->returnToParentObject();
360  }
361 
366  protected function setSelectedBlogObject(): void
367  {
368  if (!$this->submission->canSubmit()) {
369  $this->tpl->setOnScreenMessage('info', $this->lng->txt("exercise_time_over"), true);
370  $this->returnToParentObject();
371  }
372 
373  if ($this->selected_wsp_obj_id > 0) {
374  $tree = new ilWorkspaceTree($this->submission->getUserId());
375  $node = $tree->getNodeData($this->selected_wsp_obj_id);
376  if ($node && $node["type"] == "blog") {
377  $this->submission->deleteAllFiles();
378  $this->handleRemovedUpload();
379 
380  $this->submission->addResourceObject($node["wsp_id"]);
381 
382  $this->tpl->setOnScreenMessage('success', $this->lng->txt("exc_blog_selected"), true);
383  $this->ctrl->setParameter($this, "blog_id", $node["wsp_id"]);
384  $this->ctrl->redirect($this, "askDirectSubmission");
385  }
386  }
387 
388  $this->selectBlogObject();
389  }
390 
391  protected function renderWorkspaceExplorer(
392  string $a_cmd
393  ): string {
394  $exp2 = null;
395  switch ($a_cmd) {
396  case "selectBlog":
397  $exp2 = new ilWorkspaceExplorerGUI($this->submission->getUserId(), $this, $a_cmd, $this, "setSelectedBlog");
398  $exp2->setTypeWhiteList(array("blog", "wsrt", "wfld"));
399  $exp2->setSelectableTypes(array("blog"));
400  break;
401 
402  case "createBlog":
403  $exp2 = new ilWorkspaceExplorerGUI($this->submission->getUserId(), $this, $a_cmd, $this, "saveBlog");
404  $exp2->setTypeWhiteList(array("wsrt", "wfld"));
405  $exp2->setSelectableTypes(array("wsrt", "wfld"));
406  break;
407  }
408  if (!$exp2->handleCommand()) {
409  return $exp2->getHTML();
410  }
411  exit;
412  }
413 
414 
415  //
416  // PORTFOLIO
417  //
418 
419  protected function selectPortfolioObject(): void
420  {
421  $this->handleTabs();
422 
423  $items = array();
424  $portfolios = ilObjPortfolio::getPortfoliosOfUser($this->submission->getUserId());
425  foreach ($portfolios as $portfolio) {
426  $items[$portfolio["id"]] = $portfolio["title"];
427  }
428 
430  "exc_select_portfolio",
431  "exc_select_portfolio_info",
432  "setSelectedPortfolio",
433  "",
434  $items
435  );
436  }
437 
438  protected function initPortfolioTemplateForm(
439  array $a_templates
440  ): ilPropertyFormGUI {
441  $form = new ilPropertyFormGUI();
442  $form->setTitle($this->lng->txt("exc_create_portfolio") . ": " . $this->assignment->getTitle());
443  $form->setFormAction($this->ctrl->getFormAction($this, "setSelectedPortfolioTemplate"));
444 
445  $prtt = new ilRadioGroupInputGUI($this->lng->txt("obj_prtt"), "prtt");
446  $prtt->setRequired(true);
447  $prtt->addOption(new ilRadioOption($this->lng->txt("exc_create_portfolio_no_template"), -1));
448  foreach ($a_templates as $id => $title) {
449  $prtt->addOption(new ilRadioOption('"' . $title . '"', $id));
450  }
451  $prtt->setValue(-1);
452  $form->addItem($prtt);
453 
454  $form->addCommandButton("setSelectedPortfolioTemplate", $this->lng->txt("save"));
455  $form->addCommandButton("returnToParent", $this->lng->txt("cancel"));
456 
457  return $form;
458  }
459 
460  protected function createPortfolioFromAssignmentObject(): void
461  {
462  global $DIC;
463 
464  $ctrl = $DIC->ctrl();
465 
467 
468  //template id is stored in the DB with the ref_id.
469  $template_id = $this->assignment->getPortfolioTemplateId();
470  //get the object id to compare with a list of template objects.
471  $template_object_id = ilObject::_lookupObjectId($template_id);
472 
473  // select a template, if available
474  if ($templates !== [] && $template_object_id == 0) {
476  return;
477  }
478 
479  $title = $this->exercise->getTitle() . " - " . $this->assignment->getTitle();
480  $ctrl->setParameterByClass("ilObjPortfolioGUI", "exc_id", $this->exercise->getRefId());
481  $ctrl->setParameterByClass("ilObjPortfolioGUI", "ass_id", $this->assignment->getId());
482  $ctrl->setParameterByClass("ilObjPortfolioGUI", "pt", $title);
483 
484  if ($template_object_id > 0) {
485  $ctrl->setParameterByClass("ilObjPortfolioGUI", "prtt", $template_object_id);
486  }
487  $ctrl->setParameterByClass("ilobjportfoliogui", "exc_back_ref_id", $this->requested_ref_id);
488  $ctrl->redirectByClass(array("ildashboardgui", "ilPortfolioRepositoryGUI", "ilObjPortfolioGUI"), "createPortfolioFromAssignment");
489  }
490 
491  protected function createPortfolioTemplateObject(
492  ilPropertyFormGUI $a_form = null
493  ): void {
494  if (!$this->submission->canSubmit()) {
495  $this->tpl->setOnScreenMessage('info', $this->lng->txt("exercise_time_over"), true);
496  $this->returnToParentObject();
497  }
498 
500  if ($templates === []) {
501  $this->returnToParentObject();
502  }
503 
504  if ($a_form === null) {
505  $a_form = $this->initPortfolioTemplateForm($templates);
506  }
507 
508  $this->tpl->setContent($a_form->getHTML());
509  }
510 
515  protected function setSelectedPortfolioTemplateObject(): void
516  {
517  if (!$this->submission->canSubmit()) {
518  $this->tpl->setOnScreenMessage('info', $this->lng->txt("exercise_time_over"), true);
519  $this->returnToParentObject();
520  }
521 
523  if ($templates === []) {
524  $this->ctrl->redirect($this, "returnToParent");
525  }
526 
527  $form = $this->initPortfolioTemplateForm($templates);
528  if ($form->checkInput()) {
529  $prtt = $form->getInput("prtt");
530  if ($prtt > 0 && array_key_exists($prtt, $templates)) {
531  $title = $this->exercise->getTitle() . " - " . $this->assignment->getTitle();
532  $this->ctrl->setParameterByClass("ilObjPortfolioGUI", "exc_id", $this->exercise->getRefId());
533  $this->ctrl->setParameterByClass("ilObjPortfolioGUI", "ass_id", $this->assignment->getId());
534  $this->ctrl->setParameterByClass("ilObjPortfolioGUI", "pt", $title);
535  $this->ctrl->setParameterByClass("ilObjPortfolioGUI", "prtt", $prtt);
536  $this->ctrl->setParameterByClass("ilobjportfoliogui", "exc_back_ref_id", $this->requested_ref_id);
537  $this->ctrl->redirectByClass(array("ildashboardgui", "ilPortfolioRepositoryGUI", "ilObjPortfolioGUI"), "createPortfolioFromTemplate");
538  } else {
539  // do not use template
540  $this->createPortfolioObject();
541  return;
542  }
543  }
544 
545  $form->setValuesByPost();
546  $this->createPortfolioTemplateObject($form);
547  }
548 
553  protected function createPortfolioObject(): void
554  {
555  if (!$this->submission->canSubmit()) {
556  $this->tpl->setOnScreenMessage('info', $this->lng->txt("exercise_time_over"), true);
557  $this->returnToParentObject();
558  }
559 
560  $portfolio = new ilObjPortfolio();
561  $portfolio->setTitle($this->exercise->getTitle() . " - " . $this->assignment->getTitle());
562  $portfolio->create();
563 
564  $this->submission->deleteAllFiles();
565  $this->handleRemovedUpload();
566 
567  $this->submission->addResourceObject($portfolio->getId());
568 
569  $this->tpl->setOnScreenMessage('success', $this->lng->txt("exc_portfolio_created"), true);
570  $this->returnToParentObject();
571  }
572 
577  protected function setSelectedPortfolioObject(): void
578  {
579  if (!$this->submission->canSubmit()) {
580  $this->tpl->setOnScreenMessage('info', $this->lng->txt("exercise_time_over"), true);
581  $this->returnToParentObject();
582  }
583 
584  $prtf_id = $this->request->getResourceObjectId();
585  if ($prtf_id > 0) {
586  $this->submission->deleteAllFiles();
587  $this->handleRemovedUpload();
588 
589  $this->submission->addResourceObject($prtf_id);
590 
591  $this->tpl->setOnScreenMessage('success', $this->lng->txt("exc_portfolio_selected"), true);
592  $this->ctrl->setParameter($this, "prtf_id", $prtf_id);
593  $this->ctrl->redirect($this, "askDirectSubmission");
594  }
595 
596  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("select_one"));
597  $this->selectPortfolioObject();
598  }
599 
600  protected function askUnlinkPortfolioObject(): void
601  {
602  $tpl = $this->tpl;
603 
604  $conf = new ilConfirmationGUI();
605  $conf->setFormAction($this->ctrl->getFormAction($this, "unlinkPortfolio"));
606  $conf->setHeaderText($this->lng->txt("exc_sure_unlink_portfolio", "sure_unlink_portfolio"));
607  $conf->setConfirm($this->lng->txt("confirm"), "unlinkPortfolio");
608  $conf->setCancel($this->lng->txt("cancel"), "returnToParent");
609 
610  $submission = $this->submission->getSelectedObject();
611  $port = new ilObjPortfolio((int) $submission["filetitle"], false);
612 
613  $conf->addItem("id[]", "", $port->getTitle(), ilUtil::getImagePath("icon_prtf.svg"));
614 
615  $tpl->setContent($conf->getHTML());
616  }
617 
618  protected function unlinkPortfolioObject(): void
619  {
620  global $DIC;
621 
622  $user = $DIC->user();
623 
624  //$portfolio = $this->submission->getSelectedObject();
625  //$port_id = $portfolio["returned_id"];
626 
627  //$ilsub = new ilExSubmission($this->assignment, $user->getId());
628  $this->submission->deleteResourceObject();
629 
630  $this->tpl->setOnScreenMessage('success', $this->lng->txt("exc_portfolio_unlinked_from_assignment"), true);
631 
632  $this->ctrl->redirect($this, "returnToParent");
633  }
634 
635  //
636  // SUBMIT BLOG/PORTFOLIO
637  //
638 
639  protected function askDirectSubmissionObject(): void
640  {
641  $tpl = $this->tpl;
642 
643  if (!$this->submission->canSubmit()) {
644  $this->tpl->setOnScreenMessage('info', $this->lng->txt("exercise_time_over"), true);
645  $this->returnToParentObject();
646  }
647 
648  $conf = new ilConfirmationGUI();
649 
650  if ($this->request->getBlogId() > 0) {
651  $this->ctrl->setParameter($this, "blog_id", $this->request->getBlogId());
652  $txt = $this->lng->txt("exc_direct_submit_blog");
653  } else {
654  $this->ctrl->setParameter($this, "prtf_id", $this->request->getPortfolioId());
655  $txt = $this->lng->txt("exc_direct_submit_portfolio");
656  }
657  $conf->setFormAction($this->ctrl->getFormAction($this, "directSubmit"));
658 
659  $conf->setHeaderText($txt);
660  $conf->setConfirm($this->lng->txt("exc_direct_submit"), "directSubmit");
661  $conf->setCancel($this->lng->txt("exc_direct_no_submit"), "returnToParent");
662 
663  $tpl->setContent($conf->getHTML());
664  }
665 
670  protected function directSubmitObject(): void
671  {
672  if (!$this->submission->canSubmit()) {
673  $this->tpl->setOnScreenMessage('info', $this->lng->txt("exercise_time_over"), true);
674  $this->returnToParentObject();
675  }
676 
677  $success = false;
678 
679  // submit current version of blog
680  if ($this->request->getBlogId() > 0) {
681  $success = $this->submitBlog($this->request->getBlogId());
682  $this->ctrl->setParameter($this, "blog_id", "");
683  }
684  // submit current version of portfolio
685  elseif ($this->request->getPortfolioId() > 0) {
686  $success = $this->submitPortfolio($this->request->getPortfolioId());
687  $this->ctrl->setParameter($this, "prtf_id", "");
688  }
689 
690  if ($success) {
691  $this->tpl->setOnScreenMessage('success', $this->lng->txt("settings_saved"), true);
692  } else {
693  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("msg_failed"), true);
694  }
695  $this->ctrl->redirectByClass([ilExerciseHandlerGUI::class, ilObjExerciseGUI::class, ilExSubmissionGUI::class, ilExSubmissionObjectGUI::class], "returnToParent");
696  }
697 
703  public function submitBlog(
704  int $a_blog_id
705  ): bool {
706  if (!$this->submission->canSubmit()) {
707  return false;
708  }
709 
710  $blog_id = $a_blog_id;
711 
712  $blog_gui = new ilObjBlogGUI($blog_id, ilObject2GUI::WORKSPACE_NODE_ID);
713  if ($blog_gui->getObject()) {
714  $file = $blog_gui->buildExportFile();
715  $size = filesize($file);
716  if ($size) {
717  $this->submission->deleteAllFiles();
718 
719  $meta = array(
720  "name" => $blog_id . ".zip",
721  "tmp_name" => $file,
722  "size" => $size
723  );
724  $this->submission->uploadFile($meta, true);
725 
726  // print version
727  $file = $file = $blog_gui->buildExportFile(false, true);
728  $size = filesize($file);
729  if ($size) {
730  $meta = array(
731  "name" => $blog_id . "print.zip",
732  "tmp_name" => $file,
733  "size" => $size
734  );
735  $this->submission->uploadFile($meta, true);
736  }
737 
738  $this->handleNewUpload();
739  return true;
740  }
741  }
742  return false;
743  }
744 
749  public function submitPortfolio(
750  int $a_portfolio_id
751  ): bool {
752  if (!$this->submission->canSubmit()) {
753  return false;
754  }
755 
756  $prtf_id = $a_portfolio_id;
757 
758  $prtf = new ilObjPortfolio($prtf_id, false);
759  if ($prtf->getTitle()) {
760  $port_gui = new ilObjPortfolioGUI($prtf_id);
761  $port_export = new PortfolioHtmlExport($port_gui);
762  $file = $port_export->exportHtml();
763 
764  $size = filesize($file);
765  if ($size) {
766  $this->submission->deleteAllFiles();
767 
768  $meta = array(
769  "name" => $prtf_id . ".zip",
770  "tmp_name" => $file,
771  "size" => $size
772  );
773  $this->submission->uploadFile($meta, true);
774 
775  // print version
776  $port_export->setPrintVersion(true);
777  $file = $port_export->exportHtml();
778  $size = filesize($file);
779  if ($size) {
780  $meta = array(
781  "name" => $prtf_id . "print.zip",
782  "tmp_name" => $file,
783  "size" => $size
784  );
785  $this->submission->uploadFile($meta, true);
786  }
787 
788  $this->handleNewUpload();
789  return true;
790  }
791  }
792  return false;
793  }
794 
798  public static function initGUIForSubmit(
799  int $a_ass_id,
800  int $a_user_id = null
802  global $DIC;
803 
804  $ilUser = $DIC->user();
805 
806  if (!$a_user_id) {
807  $a_user_id = $ilUser->getId();
808  }
809 
810  $ass = new ilExAssignment($a_ass_id);
811  $sub = new ilExSubmission($ass, $a_user_id);
812  $exc_id = $ass->getExerciseId();
813 
814  // #11173 - ref_id is needed for notifications
815  $ref_ids = ilObject::_getAllReferences($exc_id);
816  $exc_ref_id = current($ref_ids);
817  $exc = new ilObjExercise($exc_ref_id, true);
818 
819  return new self($exc, $sub);
820  }
821 }
handleNewUpload(bool $a_no_notifications=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getOverviewContent(ilInfoScreenGUI $a_info, ilExSubmission $a_submission)
exit
Definition: login.php:28
getNodeData(int $a_node_id, ?int $a_tree_pk=null)
get all information of a node.
Class ilInfoScreenGUI.
Exercise assignment.
redirectByClass( $a_class, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
__construct(ilObjExercise $a_exercise, ilExSubmission $a_submission)
setOnScreenMessage(string $type, string $a_txt, bool $a_keep=false)
Set a message to be displayed to the user.
if(isset($_FILES['img_file']) &&is_array($_FILES['img_file'])) $panel
Definition: imgupload.php:198
setTypeWhiteList(array $a_val)
Set type white list.
static _getAllReferences(int $id)
get all reference ids for object ID
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
Exercise submission base gui.
addProperty(string $a_name, string $a_value, string $a_link="")
add a property to current section
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setParameterByClass(string $a_class, string $a_parameter, $a_value)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
createPortfolioTemplateObject(ilPropertyFormGUI $a_form=null)
setVariable(string $variable, $value='')
Sets the given variable to the given value.
static getAvailablePortfolioTemplates(string $a_permission="read")
ilGlobalTemplateInterface $tpl
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
submitBlog(int $a_blog_id)
Submit blog for assignment.
global $DIC
Definition: feed.php:28
static getOverviewContentBlog(ilInfoScreenGUI $a_info, ilExSubmission $a_submission)
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
Portfolio view gui class.
Class ilObjExercise.
$ref_id
Definition: ltiauth.php:67
This class represents a property in a property form.
setContent(string $a_html)
Sets content for standard template.
Class ilObjBlogGUI.
static getPortfoliosOfUser(int $a_user_id)
Get portfolios of user.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Explorer for selecting a personal workspace item.
static _lookupObjectId(int $ref_id)
$txt
Definition: error.php:13
setRequired(bool $a_required)
renderResourceSelection(string $a_title, string $a_info, string $a_cmd, string $a_explorer_cmd, array $a_items=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
static initGUIForSubmit(int $a_ass_id, int $a_user_id=null)
static getInstance()
__construct(Container $dic, ilPlugin $plugin)
$ilUser
Definition: imgupload.php:34
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
submitPortfolio(int $a_portfolio_id)
Submit portfolio for assignment.
createTreeForUser(int $a_user_id)
Create personal workspace tree for user.
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
insertObject(int $a_parent_node_id, int $a_object_id)
Add object to tree.
Object-based submissions (ends up as static file)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...