ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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  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 ?>