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