ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
4 include_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 $ilTabs;
29 
30  if ($this->id_type == self::WORKSPACE_NODE_ID) {
31  include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
33  $this->lng->loadLanguageModule("file");
34  ilUtil::sendFailure($this->lng->txt("personal_workspace_quota_exceeded_warning"), true);
35  $this->ctrl->redirect($this, "cancel");
36  }
37  }
38 
39  $this->lng->loadLanguageModule("tstv");
40 
41  $ilTabs->setBackTarget(
42  $this->lng->txt("back"),
43  $this->ctrl->getLinkTarget($this, "cancel")
44  );
45 
46  include_once "Modules/Test/classes/tables/class.ilTestVerificationTableGUI.php";
47  $table = new ilTestVerificationTableGUI($this, "create");
48  $this->tpl->setContent($table->getHTML());
49  }
50 
54  public function save()
55  {
56  global $ilUser;
57 
58  $test_id = $_REQUEST["tst_id"];
59  if ($test_id) {
60  include_once "Modules/Test/classes/class.ilObjTest.php";
61  $test = new ilObjTest($test_id, false);
62 
63  include_once "Modules/Test/classes/class.ilObjTestVerification.php";
64  $newObj = ilObjTestVerification::createFromTest($test, $ilUser->getId());
65  if ($newObj) {
67  $this->node_id = null;
68  $this->putObjectInTree($newObj, $parent_id);
69 
70  $this->afterSave($newObj);
71  } else {
72  ilUtil::sendFailure($this->lng->txt("msg_failed"));
73  }
74  } else {
75  ilUtil::sendFailure($this->lng->txt("select_one"));
76  }
77  $this->create();
78  }
79 
80  public function deliver()
81  {
82  $file = $this->object->getFilePath();
83  if ($file) {
84  ilUtil::deliverFile($file, $this->object->getTitle() . ".pdf");
85  }
86  }
87 
94  public function render($a_return = false, $a_url = false)
95  {
96  global $ilUser, $lng;
97 
98  if (!$a_return) {
99  $this->deliver();
100  } else {
101  $tree = new ilWorkspaceTree($ilUser->getId());
102  $wsp_id = $tree->lookupNodeId($this->object->getId());
103  $caption = $lng->txt("wsp_type_tstv") . ' "' . $this->object->getTitle() . '"';
104 
105  $valid = true;
106  if (!file_exists($this->object->getFilePath())) {
107  $valid = false;
108  $message = $lng->txt("url_not_found");
109  } elseif (!$a_url) {
110  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
112  if (!$access_handler->checkAccess("read", "", $wsp_id)) {
113  $valid = false;
114  $message = $lng->txt("permission_denied");
115  }
116  }
117 
118  if ($valid) {
119  if (!$a_url) {
120  $a_url = $this->getAccessHandler()->getGotoLink($wsp_id, $this->object->getId());
121  }
122  return '<div><a href="' . $a_url . '">' . $caption . '</a></div>';
123  } else {
124  return '<div>' . $caption . ' (' . $message . ')</div>';
125  }
126  }
127  }
128 
130  {
131  global $ilErr;
132 
133  include_once "Services/COPage/classes/class.ilPCVerification.php";
134  if (ilPCVerification::isInPortfolioPage($a_page, $this->object->getType(), $this->object->getId())) {
135  $this->deliver();
136  }
137 
138  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->MESSAGE);
139  }
140 
141  public static function _goto($a_target)
142  {
143  $id = explode("_", $a_target);
144 
145  $_GET["baseClass"] = "ilsharedresourceGUI";
146  $_GET["wsp_id"] = $id[0];
147  include("ilias.php");
148  exit;
149  }
150 }
downloadFromPortfolioPage(ilPortfolioPage $a_page)
New implementation of ilObjectGUI.
render($a_return=false, $a_url=false)
Render content.
$_GET["client_id"]
static isInPortfolioPage(ilPortfolioPage $a_page, $a_type, $a_id)
static createFromTest(ilObjTest $a_test, $a_user_id)
Import relevant properties from given test.
getAccessHandler()
Get access handler.
$valid
if(!array_key_exists('StateId', $_REQUEST)) $id
Access handler for personal workspace.
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.
save()
create new instance and save it
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.
GUI class for test verification.
Create new PHPExcel object
obj_idprivate
create()
List all tests in which current user participated.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
if(empty($password)) $table
Definition: pwgen.php:24
List all completed tests for current user.
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
$test
Definition: Utf8Test.php:84