ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilObjSCORMVerificationGUI.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 "scov";
22  }
23 
27  public function create()
28  {
29  global $DIC;
30  $ilTabs = $DIC['ilTabs'];
31 
32  if ($this->id_type == self::WORKSPACE_NODE_ID) {
33  include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
35  $this->lng->loadLanguageModule("file");
36  ilUtil::sendFailure($this->lng->txt("personal_workspace_quota_exceeded_warning"), true);
37  $this->ctrl->redirect($this, "cancel");
38  }
39  }
40 
41  $this->lng->loadLanguageModule("scov");
42 
43  $ilTabs->setBackTarget(
44  $this->lng->txt("back"),
45  $this->ctrl->getLinkTarget($this, "cancel")
46  );
47 
48  include_once "Modules/ScormAicc/classes/Verification/class.ilSCORMVerificationTableGUI.php";
49  $table = new ilSCORMVerificationTableGUI($this, "create");
50  $this->tpl->setContent($table->getHTML());
51  }
52 
56  public function save()
57  {
58  global $DIC;
59 
60  $ilUser = $DIC->user();
61 
62  $objectId = $_REQUEST["lm_id"];
63  if ($objectId) {
64  $certificateVerificationFileService = new ilCertificateVerificationFileService(
65  $DIC->language(),
66  $DIC->database(),
67  $DIC->logger()->root(),
69  );
70 
71  $userCertificateRepository = new ilUserCertificateRepository();
72 
73  $userCertificatePresentation = $userCertificateRepository->fetchActiveCertificateForPresentation(
74  (int) $ilUser->getId(),
75  (int) $objectId
76  );
77 
78  try {
79  $newObj = $certificateVerificationFileService->createFile($userCertificatePresentation);
80  } catch (\Exception $exception) {
81  ilUtil::sendFailure($this->lng->txt('error_creating_certificate_pdf'));
82  return $this->create();
83  }
84 
85  if ($newObj) {
87  $this->node_id = null;
88  $this->putObjectInTree($newObj, $parent_id);
89 
90  $this->afterSave($newObj);
91  } else {
92  ilUtil::sendFailure($this->lng->txt("msg_failed"));
93  }
94  } else {
95  ilUtil::sendFailure($this->lng->txt("select_one"));
96  }
97  $this->create();
98  }
99 
100  public function deliver()
101  {
102  $file = $this->object->getFilePath();
103  if ($file) {
104  ilUtil::deliverFile($file, $this->object->getTitle() . ".pdf");
105  }
106  }
107 
114  public function render($a_return = false, $a_url = false)
115  {
116  global $DIC;
117  $ilUser = $DIC['ilUser'];
118  $lng = $DIC['lng'];
119 
120  if (!$a_return) {
121  $this->deliver();
122  } else {
123  $tree = new ilWorkspaceTree($ilUser->getId());
124  $wsp_id = $tree->lookupNodeId($this->object->getId());
125 
126  $caption = $lng->txt("wsp_type_scov") . ' "' . $this->object->getTitle() . '"';
127 
128  $valid = true;
129  if (!file_exists($this->object->getFilePath())) {
130  $valid = false;
131  $message = $lng->txt("url_not_found");
132  } elseif (!$a_url) {
133  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
135  if (!$access_handler->checkAccess("read", "", $wsp_id)) {
136  $valid = false;
137  $message = $lng->txt("permission_denied");
138  }
139  }
140 
141  if ($valid) {
142  if (!$a_url) {
143  $a_url = $this->getAccessHandler()->getGotoLink($wsp_id, $this->object->getId());
144  }
145  return '<div><a href="' . $a_url . '">' . $caption . '</a></div>';
146  } else {
147  return '<div>' . $caption . ' (' . $message . ')</div>';
148  }
149  }
150  }
151 
153  {
154  global $DIC;
155  $ilErr = $DIC['ilErr'];
156 
157  include_once "Services/COPage/classes/class.ilPCVerification.php";
158  if (ilPCVerification::isInPortfolioPage($a_page, $this->object->getType(), $this->object->getId())) {
159  $this->deliver();
160  }
161 
162  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->MESSAGE);
163  }
164 
165  public static function _goto($a_target)
166  {
167  $id = explode("_", $a_target);
168 
169  $_GET["baseClass"] = "ilsharedresourceGUI";
170  $_GET["wsp_id"] = $id[0];
171  include("ilias.php");
172  exit;
173  }
174 }
List all completed learning modules for current user.
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
save()
create new instance and save it
downloadFromPortfolioPage(ilPortfolioPage $a_page)
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.
Tree handler for personal workspace.
catch(Exception $e) $message
static isUploadPossible($a_additional_size=null)
$ilUser
Definition: imgupload.php:18
Page for user portfolio.
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
render($a_return=false, $a_url=false)
Render content.
create()
List all tests in which current user participated.
if(empty($password)) $table
Definition: pwgen.php:24
GUI class for scorm verification.
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.