ILIAS  release_7 Revision v7.30-3-g800a261c036
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 $this->lng->loadLanguageModule("tstv");
32
33 $ilTabs->setBackTarget(
34 $this->lng->txt("back"),
35 $this->ctrl->getLinkTarget($this, "cancel")
36 );
37
38 include_once "Modules/Test/classes/tables/class.ilTestVerificationTableGUI.php";
39 $table = new ilTestVerificationTableGUI($this, "create");
40 $this->tpl->setContent($table->getHTML());
41 }
42
46 public function save()
47 {
48 global $DIC;
49 $ilUser = $DIC['ilUser'];
50
51 $objectId = $_REQUEST["tst_id"];
52 if ($objectId) {
53 $certificateVerificationFileService = new ilCertificateVerificationFileService(
54 $DIC->language(),
55 $DIC->database(),
56 $DIC->logger()->root(),
58 );
59
60 $userCertificateRepository = new ilUserCertificateRepository();
61
62 $userCertificatePresentation = $userCertificateRepository->fetchActiveCertificateForPresentation(
63 (int) $ilUser->getId(),
64 (int) $objectId
65 );
66
67 try {
68 $newObj = $certificateVerificationFileService->createFile($userCertificatePresentation);
69 } catch (\Exception $exception) {
70 ilUtil::sendFailure($this->lng->txt('error_creating_certificate_pdf'));
71 return $this->create();
72 }
73
74 if ($newObj) {
76 $this->node_id = null;
77 $this->putObjectInTree($newObj, $parent_id);
78
79 $this->afterSave($newObj);
80 } else {
81 ilUtil::sendFailure($this->lng->txt("msg_failed"));
82 }
83 } else {
84 ilUtil::sendFailure($this->lng->txt("select_one"));
85 }
86 $this->create();
87 }
88
89 public function deliver()
90 {
91 $file = $this->object->getFilePath();
92 if ($file) {
93 ilUtil::deliverFile($file, $this->object->getTitle() . ".pdf");
94 }
95 }
96
103 public function render($a_return = false, $a_url = false)
104 {
105 global $DIC;
106 $ilUser = $DIC['ilUser'];
107 $lng = $DIC['lng'];
108
109 if (!$a_return) {
110 $this->deliver();
111 } else {
112 $tree = new ilWorkspaceTree($ilUser->getId());
113 $wsp_id = $tree->lookupNodeId($this->object->getId());
114 $caption = $lng->txt("wsp_type_tstv") . ' "' . $this->object->getTitle() . '"';
115
116 $valid = true;
117 if (!file_exists($this->object->getFilePath())) {
118 $valid = false;
119 $message = $lng->txt("url_not_found");
120 } elseif (!$a_url) {
121 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
123 if (!$access_handler->checkAccess("read", "", $wsp_id)) {
124 $valid = false;
125 $message = $lng->txt("permission_denied");
126 }
127 }
128
129 if ($valid) {
130 if (!$a_url) {
131 $a_url = $this->getAccessHandler()->getGotoLink($wsp_id, $this->object->getId());
132 }
133 return '<div><a href="' . $a_url . '">' . $caption . '</a></div>';
134 } else {
135 return '<div>' . $caption . ' (' . $message . ')</div>';
136 }
137 }
138 }
139
141 {
142 global $DIC;
143 $ilErr = $DIC['ilErr'];
144
145 include_once "Services/COPage/classes/class.ilPCVerification.php";
146 if (ilPCVerification::isInPortfolioPage($a_page, $this->object->getType(), $this->object->getId())) {
147 $this->deliver();
148 }
149
150 $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->MESSAGE);
151 }
152
153 public static function _goto($a_target)
154 {
155 $id = explode("_", $a_target);
156
157 $_GET["baseClass"] = "ilsharedresourceGUI";
158 $_GET["wsp_id"] = $id[0];
159 include("ilias.php");
160 exit;
161 }
162}
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
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
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
exit
Definition: login.php:29
$message
Definition: xapiexit.php:14