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