ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
13{
14 public function getType()
15 {
16 return "excv";
17 }
18
22 public function create()
23 {
24 $ilTabs = $this->tabs_gui;
25
26 if ($this->id_type == self::WORKSPACE_NODE_ID) {
28 $this->lng->loadLanguageModule("file");
29 ilUtil::sendFailure($this->lng->txt("personal_resources_quota_exceeded_warning"), true);
30 $this->ctrl->redirect($this, "cancel");
31 }
32 }
33
34 $this->lng->loadLanguageModule("excv");
35
36 $ilTabs->setBackTarget(
37 $this->lng->txt("back"),
38 $this->ctrl->getLinkTarget($this, "cancel")
39 );
40
41 $table = new ilExerciseVerificationTableGUI($this, "create");
42 $this->tpl->setContent($table->getHTML());
43 }
44
48 public function save()
49 {
50 global $DIC;
51
53
54 $objectId = $_REQUEST["exc_id"];
55 if ($objectId) {
56 $certificateVerificationFileService = new ilCertificateVerificationFileService(
57 $DIC->language(),
58 $DIC->database(),
59 $DIC->logger()->root(),
61 );
62
63 $userCertificateRepository = new ilUserCertificateRepository();
64
65 $userCertificatePresentation = $userCertificateRepository->fetchActiveCertificateForPresentation(
66 (int) $ilUser->getId(),
67 (int) $objectId
68 );
69
70 try {
71 $newObj = $certificateVerificationFileService->createFile($userCertificatePresentation);
72 } catch (\Exception $exception) {
73 ilUtil::sendFailure($this->lng->txt('error_creating_certificate_pdf'));
74 return $this->create();
75 }
76
77 if ($newObj) {
79 $this->node_id = null;
80 $this->putObjectInTree($newObj, $parent_id);
81
82 $this->afterSave($newObj);
83 } else {
84 ilUtil::sendFailure($this->lng->txt("msg_failed"));
85 }
86 } else {
87 ilUtil::sendFailure($this->lng->txt("select_one"));
88 }
89 $this->create();
90 }
91
92 public function deliver()
93 {
94 $file = $this->object->getFilePath();
95 if ($file) {
96 ilUtil::deliverFile($file, $this->object->getTitle() . ".pdf");
97 }
98 }
99
106 public function render($a_return = false, $a_url = false)
107 {
110
111 if (!$a_return) {
112 $this->deliver();
113 } else {
114 $tree = new ilWorkspaceTree($ilUser->getId());
115 $wsp_id = $tree->lookupNodeId($this->object->getId());
116
117 $caption = $lng->txt("wsp_type_excv") . ' "' . $this->object->getTitle() . '"';
118
119 $valid = true;
120 if (!file_exists($this->object->getFilePath())) {
121 $valid = false;
122 $message = $lng->txt("url_not_found");
123 } elseif (!$a_url) {
125 if (!$access_handler->checkAccess("read", "", $wsp_id)) {
126 $valid = false;
127 $message = $lng->txt("permission_denied");
128 }
129 }
130
131 if ($valid) {
132 if (!$a_url) {
133 $a_url = $this->getAccessHandler()->getGotoLink($wsp_id, $this->object->getId());
134 }
135 return '<div><a href="' . $a_url . '">' . $caption . '</a></div>';
136 } else {
137 return '<div>' . $caption . ' (' . $message . ')</div>';
138 }
139 }
140 }
141
143 {
144 if (ilPCVerification::isInPortfolioPage($a_page, $this->object->getType(), $this->object->getId())) {
145 $this->deliver();
146 }
147
148 throw new ilExerciseException($this->lng->txt('permission_denied'));
149 }
150
151 public static function _goto($a_target)
152 {
153 $id = explode("_", $a_target);
154
155 $_GET["baseClass"] = "ilsharedresourceGUI";
156 $_GET["wsp_id"] = $id[0];
157 include("ilias.php");
158 exit;
159 }
160}
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
static isUploadPossible($a_additional_size=null)
Exercise exceptions class.
List all completed exercises for current user.
GUI class for exercise verification.
create()
List all exercises in which current user participated.
render($a_return=false, $a_url=false)
Render content.
getType()
Functions that must be overwritten.
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.
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
exit
Definition: login.php:29
$ilUser
Definition: imgupload.php:18
$message
Definition: xapiexit.php:14
$DIC
Definition: xapitoken.php:46