ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
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  {
32  include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
34  {
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("tstv");
42 
43  $ilTabs->setBackTarget($this->lng->txt("back"),
44  $this->ctrl->getLinkTarget($this, "cancel"));
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  {
61  include_once "Modules/Test/classes/class.ilObjTest.php";
62  $test = new ilObjTest($test_id, false);
63 
64  include_once "Modules/Test/classes/class.ilObjTestVerification.php";
65  $newObj = ilObjTestVerification::createFromTest($test, $ilUser->getId());
66  if($newObj)
67  {
69  $this->node_id = null;
70  $this->putObjectInTree($newObj, $parent_id);
71 
72  $this->afterSave($newObj);
73  }
74  else
75  {
76  ilUtil::sendFailure($this->lng->txt("msg_failed"));
77  }
78  }
79  else
80  {
81  ilUtil::sendFailure($this->lng->txt("select_one"));
82  }
83  $this->create();
84  }
85 
86  public function deliver()
87  {
88  $file = $this->object->getFilePath();
89  if($file)
90  {
91  ilUtil::deliverFile($file, $this->object->getTitle().".pdf");
92  }
93  }
94 
101  public function render($a_return = false, $a_url = false)
102  {
103  global $ilUser, $lng;
104 
105  if(!$a_return)
106  {
107  $this->deliver();
108  }
109  else
110  {
111  $tree = new ilWorkspaceTree($ilUser->getId());
112  $wsp_id = $tree->lookupNodeId($this->object->getId());
113  $caption = $lng->txt("wsp_type_tstv").' "'.$this->object->getTitle().'"';
114 
115  $valid = true;
116  if(!file_exists($this->object->getFilePath()))
117  {
118  $valid = false;
119  $message = $lng->txt("url_not_found");
120  }
121  else if(!$a_url)
122  {
123  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
125  if(!$access_handler->checkAccess("read", "", $wsp_id))
126  {
127  $valid = false;
128  $message = $lng->txt("permission_denied");
129  }
130  }
131 
132  if($valid)
133  {
134  if(!$a_url)
135  {
136  $a_url = $this->getAccessHandler()->getGotoLink($wsp_id, $this->object->getId());
137  }
138  return '<div><a href="'.$a_url.'">'.$caption.'</a></div>';
139  }
140  else
141  {
142  return '<div>'.$caption.' ('.$message.')</div>';
143  }
144  }
145  }
146 
148  {
149  global $ilErr;
150 
151  include_once "Services/COPage/classes/class.ilPCVerification.php";
152  if(ilPCVerification::isInPortfolioPage($a_page, $this->object->getType(), $this->object->getId()))
153  {
154  $this->deliver();
155  }
156 
157  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->MESSAGE);
158  }
159 
160  public static function _goto($a_target)
161  {
162  $id = explode("_", $a_target);
163 
164  $_GET["baseClass"] = "ilsharedresourceGUI";
165  $_GET["wsp_id"] = $id[0];
166  include("ilias.php");
167  exit;
168  }
169 }
170 
171 ?>
downloadFromPortfolioPage(ilPortfolioPage $a_page)
print $file
exit
Definition: login.php:54
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
Access handler for personal workspace.
afterSave(ilObject $a_new_object)
Post (successful) object creation hook.
Tree handler for personal workspace.
static isUploadPossible($a_additional_size=null)
Page for user portfolio.
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
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.
global $ilUser
Definition: imgupload.php:15
create()
List all tests in which current user participated.
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
List all completed tests for current user.
$test
Definition: Utf8Test.php:85