ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilObjExerciseVerificationGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once('./Services/Object/classes/class.ilObject2GUI.php');
6 
18 {
19  public function getType()
20  {
21  return "excv";
22  }
23 
27  public function create()
28  {
29  $ilTabs = $this->tabs_gui;
30 
31  if ($this->id_type == self::WORKSPACE_NODE_ID) {
32  include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
34  $this->lng->loadLanguageModule("file");
35  ilUtil::sendFailure($this->lng->txt("personal_workspace_quota_exceeded_warning"), true);
36  $this->ctrl->redirect($this, "cancel");
37  }
38  }
39 
40  $this->lng->loadLanguageModule("excv");
41 
42  $ilTabs->setBackTarget(
43  $this->lng->txt("back"),
44  $this->ctrl->getLinkTarget($this, "cancel")
45  );
46 
47  include_once "Modules/Exercise/classes/class.ilExerciseVerificationTableGUI.php";
48  $table = new ilExerciseVerificationTableGUI($this, "create");
49  $this->tpl->setContent($table->getHTML());
50  }
51 
55  public function save()
56  {
57  global $DIC;
58 
60 
61  $objectId = $_REQUEST["exc_id"];
62  if ($objectId) {
63  $certificateVerificationFileService = new ilCertificateVerificationFileService(
64  $DIC->language(),
65  $DIC->database(),
66  $DIC->logger()->root(),
68  );
69 
70  $userCertificateRepository = new ilUserCertificateRepository();
71 
72  $userCertificatePresentation = $userCertificateRepository->fetchActiveCertificateForPresentation(
73  (int) $ilUser->getId(),
74  (int) $objectId
75  );
76 
77  try {
78  $newObj = $certificateVerificationFileService->createFile($userCertificatePresentation);
79  } catch (\Exception $exception) {
80  ilUtil::sendFailure($this->lng->txt('error_creating_certificate_pdf'));
81  return $this->create();
82  }
83 
84  if ($newObj) {
86  $this->node_id = null;
87  $this->putObjectInTree($newObj, $parent_id);
88 
89  $this->afterSave($newObj);
90  } else {
91  ilUtil::sendFailure($this->lng->txt("msg_failed"));
92  }
93  } else {
94  ilUtil::sendFailure($this->lng->txt("select_one"));
95  }
96  $this->create();
97  }
98 
99  public function deliver()
100  {
101  $file = $this->object->getFilePath();
102  if ($file) {
103  ilUtil::deliverFile($file, $this->object->getTitle() . ".pdf");
104  }
105  }
106 
113  public function render($a_return = false, $a_url = false)
114  {
116  $lng = $this->lng;
117 
118  if (!$a_return) {
119  $this->deliver();
120  } else {
121  $tree = new ilWorkspaceTree($ilUser->getId());
122  $wsp_id = $tree->lookupNodeId($this->object->getId());
123 
124  $caption = $lng->txt("wsp_type_excv") . ' "' . $this->object->getTitle() . '"';
125 
126  $valid = true;
127  if (!file_exists($this->object->getFilePath())) {
128  $valid = false;
129  $message = $lng->txt("url_not_found");
130  } elseif (!$a_url) {
131  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
133  if (!$access_handler->checkAccess("read", "", $wsp_id)) {
134  $valid = false;
135  $message = $lng->txt("permission_denied");
136  }
137  }
138 
139  if ($valid) {
140  if (!$a_url) {
141  $a_url = $this->getAccessHandler()->getGotoLink($wsp_id, $this->object->getId());
142  }
143  return '<div><a href="' . $a_url . '">' . $caption . '</a></div>';
144  } else {
145  return '<div>' . $caption . ' (' . $message . ')</div>';
146  }
147  }
148  }
149 
151  {
152  include_once "Services/COPage/classes/class.ilPCVerification.php";
153  if (ilPCVerification::isInPortfolioPage($a_page, $this->object->getType(), $this->object->getId())) {
154  $this->deliver();
155  }
156 
157  include_once "Modules/Exercise/exceptions/class.ilExerciseException.php";
158  throw new ilExerciseException($this->lng->txt('permission_denied'));
159  }
160 
161  public static function _goto($a_target)
162  {
163  $id = explode("_", $a_target);
164 
165  $_GET["baseClass"] = "ilsharedresourceGUI";
166  $_GET["wsp_id"] = $id[0];
167  include("ilias.php");
168  exit;
169  }
170 }
New implementation of ilObjectGUI.
global $DIC
Definition: saml.php:7
$_GET["client_id"]
static isInPortfolioPage(ilPortfolioPage $a_page, $a_type, $a_id)
getAccessHandler()
Get access handler.
$valid
if(!array_key_exists('StateId', $_REQUEST)) $id
Access handler for personal workspace.
createFile(ilUserCertificatePresentation $userCertificatePresentation)
afterSave(ilObject $a_new_object)
Post (successful) object creation hook.
create()
List all exercises in which current user participated.
Tree handler for personal workspace.
catch(Exception $e) $message
List all completed exercises for current user.
save()
create new instance and save it
GUI class for exercise verification.
static isUploadPossible($a_additional_size=null)
$ilUser
Definition: imgupload.php:18
Page for user portfolio.
render($a_return=false, $a_url=false)
Render content.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
putObjectInTree(ilObject $a_obj, $a_parent_node_id=null)
Add object to tree at given position.
exit
Definition: backend.php:16
if(empty($password)) $table
Definition: pwgen.php:24
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
Exercise exceptions class.