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