ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilExSubmissionObjectGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
13 {
20  public function executeCommand()
21  {
22  $ilCtrl = $this->ctrl;
23 
24  if (!$this->submission->canView()) {
25  $this->returnToParentObject();
26  }
27 
28  $class = $ilCtrl->getNextClass($this);
29  $cmd = $ilCtrl->getCmd();
30 
31  switch ($class) {
32  default:
33  $this->{$cmd . "Object"}();
34  break;
35  }
36  }
37 
38  public static function getOverviewContent(ilInfoScreenGUI $a_info, ilExSubmission $a_submission)
39  {
40  switch ($a_submission->getAssignment()->getType()) {
42  return self::getOverviewContentBlog($a_info, $a_submission);
43 
45  return self::getOverviewContentPortfolio($a_info, $a_submission);
46  }
47  }
48 
49  protected static function getOverviewContentBlog(ilInfoScreenGUI $a_info, ilExSubmission $a_submission)
50  {
51  global $DIC;
52 
53  $lng = $DIC->language();
54  $ilCtrl = $DIC->ctrl();
55 
56  $wsp_tree = new ilWorkspaceTree($a_submission->getUserId());
57 
58  // #12939
59  if (!$wsp_tree->getRootId()) {
60  $wsp_tree->createTreeForUser($a_submission->getUserId());
61  }
62 
63  $files_str = "";
64  $buttons_str = "";
65  $valid_blog = false;
66  $selected_blog = $a_submission->getSelectedObject();
67  if ($selected_blog) {
68  $blog_id = (int) $selected_blog["filetitle"];
69  $node = $wsp_tree->getNodeData($blog_id);
70  if ($node["title"]) {
71  // #10116
72  $ilCtrl->setParameterByClass("ilobjbloggui", "wsp_id", $blog_id);
73  $blog_link = $ilCtrl->getLinkTargetByClass(array("ildashboardgui", "ilpersonalworkspacegui", "ilobjbloggui"), "");
74  $ilCtrl->setParameterByClass("ilobjbloggui", "wsp_id", "");
75  $files_str = '<a href="' . $blog_link . '">' .
76  $node["title"] . '</a>';
77  $valid_blog = true;
78  }
79  // remove invalid resource if no upload yet (see download below)
80  elseif (substr($selected_blog["filename"], -1) == "/") {
81  // #16887
82  $a_submission->deleteResourceObject($selected_blog["returned_id"]);
83  }
84  }
85  if ($a_submission->canSubmit()) {
86  if (!$valid_blog) {
87  $button = ilLinkButton::getInstance();
88  $button->setCaption("exc_create_blog");
89  $button->setUrl($ilCtrl->getLinkTargetByClass(array("ilExSubmissionGUI", "ilExSubmissionObjectGUI"), "createBlog"));
90  $buttons_str .= $button->render();
91  }
92  // #10462
93  $blogs = sizeof($wsp_tree->getObjectsFromType("blog"));
94  if ((!$valid_blog && $blogs)
95  || ($valid_blog && $blogs > 1)) {
96  $button = ilLinkButton::getInstance();
97  $button->setCaption("exc_select_blog" . ($valid_blog ? "_change" : ""));
98  $button->setUrl($ilCtrl->getLinkTargetByClass(array("ilExSubmissionGUI", "ilExSubmissionObjectGUI"), "selectBlog"));
99  $buttons_str .= " " . $button->render();
100  }
101  }
102 
103  // todo: move this to ks somehow
104  if ($buttons_str != "") {
105  $files_str .= "<p>" . $buttons_str . "</p>";
106  }
107 
108 
109  if ($files_str) {
110  $a_info->addProperty($lng->txt("exc_blog_returned"), $files_str);
111  }
112  if ($a_submission->hasSubmitted()) {
113  $ilCtrl->setParameterByClass("ilExSubmissionFileGUI", "delivered", $selected_blog["returned_id"]);
114  $dl_link = $ilCtrl->getLinkTargetByClass(array("ilExSubmissionGUI", "ilExSubmissionFileGUI"), "download");
115  $ilCtrl->setParameterByClass("ilExSubmissionFileGUI", "delivered", "");
116 
117  $button = ilLinkButton::getInstance();
118  $button->setCaption("download");
119  $button->setUrl($dl_link);
120 
121  $a_info->addProperty($lng->txt("exc_files_returned"), $button->render());
122  }
123  }
124 
125  protected static function getOverviewContentPortfolio(ilInfoScreenGUI $a_info, ilExSubmission $a_submission)
126  {
127  global $DIC;
128 
129  $lng = $DIC->language();
130  $ilCtrl = $DIC->ctrl();
131 
132  $files_str = "";
133  $buttons_str = "";
134  $valid_prtf = false;
135  $selected_prtf = $a_submission->getSelectedObject();
136  if ($selected_prtf) {
137  $portfolio_id = (int) $selected_prtf["filetitle"];
138 
139  // #11746
140  if (ilObject::_exists($portfolio_id, false, "prtf")) {
141  $portfolio = new ilObjPortfolio($portfolio_id, false);
142  if ($portfolio->getTitle()) {
143  // #10116 / #12791
144  $ilCtrl->setParameterByClass("ilobjportfoliogui", "prt_id", $portfolio_id);
145 
146  $ref_id = $_REQUEST['ref_id'];
147  $ilCtrl->setParameterByClass("ilobjportfoliogui", "ref_id", $ref_id);
148 
149  $ilCtrl->setParameterByClass("ilobjportfoliogui", "exc_back_ref_id", (int) $_GET["ref_id"]);
150 
151  $prtf_link = $ilCtrl->getLinkTargetByClass(array("ildashboardgui", "ilportfoliorepositorygui", "ilobjportfoliogui"), "view");
152  $ilCtrl->setParameterByClass("ilobjportfoliogui", "prt_id", "");
153  $ilCtrl->setParameterByClass("ilobjportfoliogui", "ref_id", "");
154 
155 
156  $files_str = '<a href="' . $prtf_link .
157  '">' . $portfolio->getTitle() . '</a>';
158  $valid_prtf = true;
159  }
160  }
161  // remove invalid resource if no upload yet (see download below)
162  elseif (substr($selected_prtf["filename"], -1) == "/") {
163  // #16887
164  $a_submission->deleteResourceObject($selected_prtf["returned_id"]);
165  }
166  }
167  if ($a_submission->canSubmit()) {
168  if (!$valid_prtf) {
169  $button = ilLinkButton::getInstance();
170  $button->setCaption("exc_create_portfolio");
171  $button->setUrl($ilCtrl->getLinkTargetByClass(array("ilExSubmissionGUI", "ilExSubmissionObjectGUI"), "createPortfolioFromAssignment"));
172 
173  $buttons_str .= "" . $button->render();
174  }
175  // #10462
176  //selectPortfolio ( remove it? )
177  $prtfs = sizeof(ilObjPortfolio::getPortfoliosOfUser($a_submission->getUserId()));
178  if ((!$valid_prtf && $prtfs)
179  || ($valid_prtf && $prtfs > 1)) {
180  $button = ilLinkButton::getInstance();
181  $button->setCaption("exc_select_portfolio" . ($valid_prtf ? "_change" : ""));
182  $button->setUrl($ilCtrl->getLinkTargetByClass(array("ilExSubmissionGUI", "ilExSubmissionObjectGUI"), "selectPortfolio"));
183  $buttons_str .= " " . $button->render();
184  }
185  if ($valid_prtf) {
186  $button = ilLinkButton::getInstance();
187  $button->setCaption("exc_select_portfolio" . ($valid_prtf ? "_unlink" : ""));
188  $button->setUrl($ilCtrl->getLinkTargetByClass(array("ilExSubmissionGUI", "ilExSubmissionObjectGUI"), "askUnlinkPortfolio"));
189  $buttons_str .= " " . $button->render();
190  }
191  }
192  // todo: move this to ks somehow
193  if ($buttons_str != "") {
194  $files_str .= "<p>" . $buttons_str . "</p>";
195  }
196  if ($files_str) {
197  $a_info->addProperty($lng->txt("exc_portfolio_returned"), $files_str);
198  }
199  if ($a_submission->hasSubmitted()) {
200  $ilCtrl->setParameterByClass("ilExSubmissionFileGUI", "delivered", $selected_prtf["returned_id"]);
201  $dl_link = $ilCtrl->getLinkTargetByClass(array("ilExSubmissionGUI", "ilExSubmissionFileGUI"), "download");
202  $ilCtrl->setParameterByClass("ilExSubmissionFileGUI", "delivered", "");
203 
204  $button = ilLinkButton::getInstance();
205  $button->setCaption("download");
206  $button->setUrl($dl_link);
207 
208  $a_info->addProperty($lng->txt("exc_files_returned"), $button->render());
209  }
210  }
211 
212  protected function renderResourceSelection($a_title, $a_info, $a_cmd, $a_explorer_cmd, array $a_items = null)
213  {
214  if (!$this->submission->canSubmit()) {
215  ilUtil::sendInfo($this->lng->txt("exercise_time_over"), true);
216  $this->returnToParentObject();
217  }
218 
219  $tpl = new ilTemplate("tpl.exc_select_resource.html", true, true, "Modules/Exercise");
220 
221  if (is_array($a_items)) {
222  $tpl->setCurrentBlock("item");
223  foreach ($a_items as $item_id => $item_title) {
224  $tpl->setVariable("ITEM_ID", $item_id);
225  $tpl->setVariable("ITEM_TITLE", $item_title);
226  $tpl->parseCurrentBlock();
227  }
228  $tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
229  $tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
230  $tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
231  $tpl->setVariable("CMD_SUBMIT", $a_cmd);
232  $tpl->setVariable("CMD_CANCEL", "returnToParent");
233  $html = $tpl->get();
234  } elseif ($a_explorer_cmd) {
235  $html = $this->renderWorkspaceExplorer($a_explorer_cmd);
236  }
237 
238 
239  ilUtil::sendInfo($this->lng->txt($a_info));
240 
241  $title = $this->lng->txt($a_title) . ": " . $this->assignment->getTitle();
242 
244  $panel->setBody($html);
245  $panel->setHeading($title);
246 
247  $this->tpl->setContent($panel->getHTML());
248  }
249 
250 
251  //
252  // BLOG
253  //
254 
255  protected function createBlogObject()
256  {
257  $this->handleTabs();
258 
259  return $this->renderResourceSelection(
260  "exc_create_blog",
261  "exc_create_blog_select_info",
262  "saveBlog",
263  "createBlog"
264  );
265  }
266 
267  protected function selectBlogObject()
268  {
269  $this->handleTabs();
270 
271  return $this->renderResourceSelection(
272  "exc_select_blog",
273  "exc_select_blog_info",
274  "setSelectedBlog",
275  "selectBlog"
276  );
277  }
278 
279  protected function saveBlogObject()
280  {
281  if (!$this->submission->canSubmit()) {
282  ilUtil::sendInfo($this->lng->txt("exercise_time_over"), true);
283  $this->returnToParentObject();
284  }
285 
286  if (!$_GET["sel_wsp_obj"]) {
287  ilUtil::sendFailure($this->lng->txt("select_one"));
288  return $this->createBlogObject();
289  }
290 
291  $parent_node = $_GET["sel_wsp_obj"];
292 
293  $blog = new ilObjBlog();
294  $blog->setTitle($this->exercise->getTitle() . " - " . $this->assignment->getTitle());
295  $blog->create();
296 
297  $tree = new ilWorkspaceTree($this->submission->getUserId()); // #15993
298 
299  $node_id = $tree->insertObject($parent_node, $blog->getId());
300 
301  $access_handler = new ilWorkspaceAccessHandler($tree);
302  $access_handler->setPermissions($parent_node, $node_id);
303 
304  $this->submission->deleteAllFiles();
305  $this->handleRemovedUpload();
306 
307  $this->submission->addResourceObject($node_id);
308 
309  ilUtil::sendSuccess($this->lng->txt("exc_blog_created"), true);
310  $this->returnToParentObject();
311  }
312 
313  protected function setSelectedBlogObject()
314  {
315  if (!$this->submission->canSubmit()) {
316  ilUtil::sendInfo($this->lng->txt("exercise_time_over"), true);
317  $this->returnToParentObject();
318  }
319 
320  if ($_GET["sel_wsp_obj"]) {
321  $tree = new ilWorkspaceTree($this->submission->getUserId());
322  $node = $tree->getNodeData($_GET["sel_wsp_obj"]);
323  if ($node && $node["type"] == "blog") {
324  $this->submission->deleteAllFiles();
325  $this->handleRemovedUpload();
326 
327  $this->submission->addResourceObject($node["wsp_id"]);
328 
329  ilUtil::sendSuccess($this->lng->txt("exc_blog_selected"), true);
330  $this->ctrl->setParameter($this, "blog_id", $node["wsp_id"]);
331  $this->ctrl->redirect($this, "askDirectSubmission");
332  }
333  }
334 
335  // ilUtil::sendFailure($this->lng->txt("select_one_blog"));
336  return $this->selectBlogObject();
337  }
338 
343  protected function renderWorkspaceExplorer($a_cmd)
344  {
345  switch ($a_cmd) {
346  case "selectBlog":
347  $exp2 = new ilWorkspaceExplorerGUI($this->submission->getUserId(), $this, $a_cmd, $this, "setSelectedBlog");
348  $exp2->setTypeWhiteList(array("blog", "wsrt", "wfld"));
349  $exp2->setSelectableTypes(array("blog"));
350  break;
351 
352  case "createBlog":
353  $exp2 = new ilWorkspaceExplorerGUI($this->submission->getUserId(), $this, $a_cmd, $this, "saveBlog");
354  $exp2->setTypeWhiteList(array("wsrt", "wfld"));
355  $exp2->setSelectableTypes(array("wsrt", "wfld"));
356  break;
357  }
358  if (!$exp2->handleCommand()) {
359  return $exp2->getHTML();
360  }
361  exit;
362  }
363 
364 
365  //
366  // PORTFOLIO
367  //
368 
369  protected function selectPortfolioObject()
370  {
371  $this->handleTabs();
372 
373  $items = array();
374  $portfolios = ilObjPortfolio::getPortfoliosOfUser($this->submission->getUserId());
375  if ($portfolios) {
376  foreach ($portfolios as $portfolio) {
377  $items[$portfolio["id"]] = $portfolio["title"];
378  }
379  }
380 
381  return $this->renderResourceSelection(
382  "exc_select_portfolio",
383  "exc_select_portfolio_info",
384  "setSelectedPortfolio",
385  null,
386  $items
387  );
388  }
389 
390  protected function initPortfolioTemplateForm(array $a_templates)
391  {
392  $form = new ilPropertyFormGUI();
393  $form->setTitle($this->lng->txt("exc_create_portfolio") . ": " . $this->assignment->getTitle());
394  $form->setFormAction($this->ctrl->getFormAction($this, "setSelectedPortfolioTemplate"));
395 
396  $prtt = new ilRadioGroupInputGUI($this->lng->txt("obj_prtt"), "prtt");
397  $prtt->setRequired(true);
398  $prtt->addOption(new ilRadioOption($this->lng->txt("exc_create_portfolio_no_template"), -1));
399  foreach ($a_templates as $id => $title) {
400  $prtt->addOption(new ilRadioOption('"' . $title . '"', $id));
401  }
402  $prtt->setValue(-1);
403  $form->addItem($prtt);
404 
405  $form->addCommandButton("setSelectedPortfolioTemplate", $this->lng->txt("save"));
406  $form->addCommandButton("returnToParent", $this->lng->txt("cancel"));
407 
408  return $form;
409  }
410 
412  {
413  global $DIC;
414 
415  $ctrl = $DIC->ctrl();
416 
418 
419  //template id is stored in the DB with the ref_id.
420  $template_id = $this->assignment->getPortfolioTemplateId();
421  //get the object id to compare with a list of template objects.
422  $template_object_id = ilObject::_lookupObjectId($template_id);
423 
424  // select a template, if available
425  if (count($templates) > 0 && $template_object_id == 0) {
427  return;
428  }
429 
430  $title = $this->exercise->getTitle() . " - " . $this->assignment->getTitle();
431  $ctrl->setParameterByClass("ilObjPortfolioGUI", "exc_id", $this->exercise->getRefId());
432  $ctrl->setParameterByClass("ilObjPortfolioGUI", "ass_id", $this->assignment->getId());
433  $ctrl->setParameterByClass("ilObjPortfolioGUI", "pt", $title);
434 
435  if ($template_object_id > 0) {
436  $ctrl->setParameterByClass("ilObjPortfolioGUI", "prtt", $template_object_id);
437  }
438  $ctrl->setParameterByClass("ilobjportfoliogui", "exc_back_ref_id", (int) $_GET["ref_id"]);
439  $ctrl->redirectByClass(array("ildashboardgui", "ilPortfolioRepositoryGUI", "ilObjPortfolioGUI"), "createPortfolioFromAssignment");
440  }
441 
442  protected function createPortfolioTemplateObject(ilPropertyFormGUI $a_form = null)
443  {
444  if (!$this->submission->canSubmit()) {
445  ilUtil::sendInfo($this->lng->txt("exercise_time_over"), true);
446  $this->returnToParentObject();
447  }
448 
450  if (!sizeof($templates)) {
451  $this->returnToParentObject();
452  }
453 
454  if (!$a_form) {
455  $a_form = $this->initPortfolioTemplateForm($templates);
456  }
457 
458  $this->tpl->setContent($a_form->getHTML());
459  }
460 
462  {
463  if (!$this->submission->canSubmit()) {
464  ilUtil::sendInfo($this->lng->txt("exercise_time_over"), true);
465  $this->returnToParentObject();
466  }
467 
469  if (!sizeof($templates)) {
470  $this->ctrl->redirect($this, "returnToParent");
471  }
472 
473  $form = $this->initPortfolioTemplateForm($templates);
474  if ($form->checkInput()) {
475  $prtt = $form->getInput("prtt");
476  if ($prtt > 0 && array_key_exists($prtt, $templates)) {
477  $title = $this->exercise->getTitle() . " - " . $this->assignment->getTitle();
478  $this->ctrl->setParameterByClass("ilObjPortfolioGUI", "exc_id", $this->exercise->getRefId());
479  $this->ctrl->setParameterByClass("ilObjPortfolioGUI", "ass_id", $this->assignment->getId());
480  $this->ctrl->setParameterByClass("ilObjPortfolioGUI", "pt", $title);
481  $this->ctrl->setParameterByClass("ilObjPortfolioGUI", "prtt", $prtt);
482  $this->ctrl->setParameterByClass("ilobjportfoliogui", "exc_back_ref_id", (int) $_GET["ref_id"]);
483  $this->ctrl->redirectByClass(array("ildashboardgui", "ilPortfolioRepositoryGUI", "ilObjPortfolioGUI"), "createPortfolioFromTemplate");
484  } else {
485  // do not use template
486  return $this->createPortfolioObject();
487  }
488  }
489 
490  $form->setValuesByPost();
491  $this->createPortfolioTemplateObject($form);
492  }
493 
494  protected function createPortfolioObject()
495  {
496  if (!$this->submission->canSubmit()) {
497  ilUtil::sendInfo($this->lng->txt("exercise_time_over"), true);
498  $this->returnToParentObject();
499  }
500 
501  $portfolio = new ilObjPortfolio();
502  $portfolio->setTitle($this->exercise->getTitle() . " - " . $this->assignment->getTitle());
503  $portfolio->create();
504 
505  $this->submission->deleteAllFiles();
506  $this->handleRemovedUpload();
507 
508  $this->submission->addResourceObject($portfolio->getId());
509 
510  ilUtil::sendSuccess($this->lng->txt("exc_portfolio_created"), true);
511  $this->returnToParentObject();
512  }
513 
514  protected function setSelectedPortfolioObject()
515  {
516  if (!$this->submission->canSubmit()) {
517  ilUtil::sendInfo($this->lng->txt("exercise_time_over"), true);
518  $this->returnToParentObject();
519  }
520 
521  if ($_POST["item"]) {
522  $this->submission->deleteAllFiles();
523  $this->handleRemovedUpload();
524 
525  $this->submission->addResourceObject($_POST["item"]);
526 
527  ilUtil::sendSuccess($this->lng->txt("exc_portfolio_selected"), true);
528  $this->ctrl->setParameter($this, "prtf_id", $_POST["item"]);
529  $this->ctrl->redirect($this, "askDirectSubmission");
530  }
531 
532  ilUtil::sendFailure($this->lng->txt("select_one"));
533  return $this->selectPortfolioObject();
534  }
535 
536  protected function askUnlinkPortfolioObject()
537  {
538  $tpl = $this->tpl;
539 
540  $conf = new ilConfirmationGUI();
541  $conf->setFormAction($this->ctrl->getFormAction($this, "unlinkPortfolio"));
542  $conf->setHeaderText($this->lng->txt("exc_sure_unlink_portfolio", "sure_unlink_portfolio"));
543  $conf->setConfirm($this->lng->txt("confirm"), "unlinkPortfolio");
544  $conf->setCancel($this->lng->txt("cancel"), "returnToParent");
545 
546  $submission = $this->submission->getSelectedObject();
547  $port = new ilObjPortfolio($submission["filetitle"], false);
548 
549  $conf->addItem("id[]", "", $port->getTitle(), ilUtil::getImagePath("icon_prtf.svg"));
550 
551  $tpl->setContent($conf->getHTML());
552  }
553 
554  protected function unlinkPortfolioObject()
555  {
556  global $DIC;
557 
558  $user = $DIC->user();
559 
560  $portfolio = $this->submission->getSelectedObject();
561  $port_id = $portfolio["returned_id"];
562 
563  $ilsub = new ilExSubmission($this->assignment, $user->getId());
564  $ilsub->deleteResourceObject($port_id);
565 
566  ilUtil::sendSuccess($this->lng->txt("exc_portfolio_unlinked_from_assignment"), true);
567 
568  $this->ctrl->redirect($this, "returnToParent");
569  }
570 
571  //
572  // SUBMIT BLOG/PORTFOLIO
573  //
574 
575  protected function askDirectSubmissionObject()
576  {
577  $tpl = $this->tpl;
578 
579  if (!$this->submission->canSubmit()) {
580  ilUtil::sendInfo($this->lng->txt("exercise_time_over"), true);
581  $this->returnToParentObject();
582  }
583 
584  $conf = new ilConfirmationGUI();
585 
586  if ($_REQUEST["blog_id"]) {
587  $this->ctrl->setParameter($this, "blog_id", $_REQUEST["blog_id"]);
588  $txt = $this->lng->txt("exc_direct_submit_blog");
589  } else {
590  $this->ctrl->setParameter($this, "prtf_id", $_REQUEST["prtf_id"]);
591  $txt = $this->lng->txt("exc_direct_submit_portfolio");
592  }
593  $conf->setFormAction($this->ctrl->getFormAction($this, "directSubmit"));
594 
595  $conf->setHeaderText($txt);
596  $conf->setConfirm($this->lng->txt("exc_direct_submit"), "directSubmit");
597  $conf->setCancel($this->lng->txt("exc_direct_no_submit"), "returnToParent");
598 
599  $tpl->setContent($conf->getHTML());
600  }
601 
602  protected function directSubmitObject()
603  {
604  if (!$this->submission->canSubmit()) {
605  ilUtil::sendInfo($this->lng->txt("exercise_time_over"), true);
606  $this->returnToParentObject();
607  }
608 
609  $success = false;
610 
611  // submit current version of blog
612  if ($_REQUEST["blog_id"]) {
613  $success = $this->submitBlog($_REQUEST["blog_id"]);
614  $this->ctrl->setParameter($this, "blog_id", "");
615  }
616  // submit current version of portfolio
617  elseif ($_REQUEST["prtf_id"]) {
618  $success = $this->submitPortfolio($_REQUEST["prtf_id"]);
619  $this->ctrl->setParameter($this, "prtf_id", "");
620  }
621 
622  if ($success) {
623  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
624  } else {
625  ilUtil::sendFailure($this->lng->txt("msg_failed"), true);
626  }
627  $this->ctrl->redirect($this, "returnToParent");
628  }
629 
636  public function submitBlog($a_blog_id)
637  {
638  if (!$this->submission->canSubmit()) {
639  return;
640  }
641 
642  $blog_id = $a_blog_id;
643 
644  $blog_gui = new ilObjBlogGUI($blog_id, ilObjBlogGUI::WORKSPACE_NODE_ID);
645  if ($blog_gui->object) {
646  $file = $blog_gui->buildExportFile();
647  $size = filesize($file);
648  if ($size) {
649  $this->submission->deleteAllFiles();
650 
651  $meta = array(
652  "name" => $blog_id,
653  "tmp_name" => $file,
654  "size" => $size
655  );
656  $this->submission->uploadFile($meta, true);
657 
658  $this->handleNewUpload();
659  return true;
660  }
661  }
662  return false;
663  }
664 
671  public function submitPortfolio($a_portfolio_id)
672  {
673  if (!$this->submission->canSubmit()) {
674  return;
675  }
676 
677  $prtf_id = $a_portfolio_id;
678 
679  $prtf = new ilObjPortfolio($prtf_id, false);
680  if ($prtf->getTitle()) {
681  $port_gui = new ilObjPortfolioGUI($prtf_id);
682  $port_export = new \ILIAS\Portfolio\Export\PortfolioHtmlExport($port_gui);
683  $file = $port_export->exportHtml();
684 
685  $size = filesize($file);
686  if ($size) {
687  $this->submission->deleteAllFiles();
688 
689  $meta = array(
690  "name" => $prtf_id,
691  "tmp_name" => $file,
692  "size" => $size
693  );
694  $this->submission->uploadFile($meta, true);
695 
696  $this->handleNewUpload();
697  return true;
698  }
699  }
700  return false;
701  }
702 
703  public static function initGUIForSubmit($a_ass_id, $a_user_id = null)
704  {
705  global $DIC;
706 
707  $ilUser = $DIC->user();
708 
709  if (!$a_user_id) {
710  $a_user_id = $ilUser->getId();
711  }
712 
713  $ass = new ilExAssignment($a_ass_id);
714  $sub = new ilExSubmission($ass, $a_user_id);
715  $exc_id = $ass->getExerciseId();
716 
717  // #11173 - ref_id is needed for notifications
718  $exc_ref_id = array_shift(ilObject::_getAllReferences($exc_id));
719  $exc = new ilObjExercise($exc_ref_id, true);
720 
721  return new self($exc, $sub);
722  }
723 }
This class represents an option in a radio group.
$size
Definition: RandomTest.php:84
static getOverviewContent(ilInfoScreenGUI $a_info, ilExSubmission $a_submission)
exit
Definition: login.php:29
Class ilInfoScreenGUI.
Exercise assignment.
submitBlog($a_blog_id)
Submit blog for assignment.
createTreeForUser($a_user_id)
Create personal workspace tree for user.
This class represents a property form user interface.
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
if(isset($_FILES['img_file']) &&is_array($_FILES['img_file'])) $panel
Definition: imgupload.php:138
$_GET["client_id"]
static getPortfoliosOfUser($a_user_id)
Get views of user.
Exercise submission base gui.
Access handler for personal workspace.
createPortfolioTemplateObject(ilPropertyFormGUI $a_form=null)
static getOverviewContentPortfolio(ilInfoScreenGUI $a_info, ilExSubmission $a_submission)
submitPortfolio($a_portfolio_id)
Submit portfolio for assignment.
static _getAllReferences($a_id)
get all reference ids of object
Tree handler for personal workspace.
setTypeWhiteList($a_val)
Set type white list.
static _lookupObjectId($a_ref_id)
lookup object id
static initGUIForSubmit($a_ass_id, $a_user_id=null)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getOverviewContentBlog(ilInfoScreenGUI $a_info, ilExSubmission $a_submission)
Portfolio view gui class.
Class ilObjExercise.
This class represents a property in a property form.
$success
Definition: Utf8Test.php:86
handleNewUpload($a_no_notifications=false)
Class ilObjBlogGUI.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
getNodeData($a_node_id, $a_tree_pk=null)
get all information of a node.
global $DIC
Definition: goto.php:24
Class ilObjBlog.
Explorer for selecting a personal workspace item.
static getAvailablePortfolioTemplates($a_permission="read")
insertObject($a_parent_node_id, $a_object_id)
Add object to tree.
$txt
Definition: error.php:13
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static getInstance()
Get instance.
addProperty($a_name, $a_value, $a_link="")
add a property to current section
deleteResourceObject($a_returned_id)
Remove personal resource to assigment.
Exercise submission //TODO: This class has to much static methods related to delivered "files"...
$ilUser
Definition: imgupload.php:18
$_POST["username"]
setRequired($a_required)
Set Required.
Object-based submissions (ends up as static file)
renderResourceSelection($a_title, $a_info, $a_cmd, $a_explorer_cmd, array $a_items=null)
Confirmation screen class.