ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
5 include_once ('./Services/Object/classes/class.ilObject2GUI.php');
6 
18 {
19  public function getType()
20  {
21  return "excv";
22  }
23 
27  public function create()
28  {
29  global $ilTabs;
30 
31  if($this->id_type == self::WORKSPACE_NODE_ID)
32  {
33  include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
35  {
36  $this->lng->loadLanguageModule("file");
37  ilUtil::sendFailure($this->lng->txt("personal_workspace_quota_exceeded_warning"), true);
38  $this->ctrl->redirect($this, "cancel");
39  }
40  }
41 
42  $this->lng->loadLanguageModule("excv");
43 
44  $ilTabs->setBackTarget($this->lng->txt("back"),
45  $this->ctrl->getLinkTarget($this, "cancel"));
46 
47  include_once "Modules/Exercise/classes/class.ilExerciseVerificationTableGUI.php";
48  $table = new ilExerciseVerificationTableGUI($this, "create");
49  $this->tpl->setContent($table->getHTML());
50  }
51 
55  public function save()
56  {
57  global $ilUser;
58 
59  $exercise_id = $_REQUEST["exc_id"];
60  if($exercise_id)
61  {
62  include_once "Modules/Exercise/classes/class.ilObjExercise.php";
63  $exercise = new ilObjExercise($exercise_id, false);
64 
65  include_once "Modules/Exercise/classes/class.ilObjExerciseVerification.php";
66  $newObj = ilObjExerciseVerification::createFromExercise($exercise, $ilUser->getId());
67  if($newObj)
68  {
70  $this->node_id = null;
71  $this->putObjectInTree($newObj, $parent_id);
72 
73  $this->afterSave($newObj);
74  }
75  else
76  {
77  ilUtil::sendFailure($this->lng->txt("msg_failed"));
78  }
79  }
80  else
81  {
82  ilUtil::sendFailure($this->lng->txt("select_one"));
83  }
84  $this->create();
85  }
86 
87  public function deliver()
88  {
89  $file = $this->object->getFilePath();
90  if($file)
91  {
92  ilUtil::deliverFile($file, $this->object->getTitle().".pdf");
93  }
94  }
95 
102  public function render($a_return = false, $a_url = false)
103  {
104  global $ilUser, $lng;
105 
106  if(!$a_return)
107  {
108  $this->deliver();
109  }
110  else
111  {
112  $tree = new ilWorkspaceTree($ilUser->getId());
113  $wsp_id = $tree->lookupNodeId($this->object->getId());
114 
115  $caption = $lng->txt("wsp_type_excv").' "'.$this->object->getTitle().'"';
116 
117  $valid = true;
118  if(!file_exists($this->object->getFilePath()))
119  {
120  $valid = false;
121  $message = $lng->txt("url_not_found");
122  }
123  else if(!$a_url)
124  {
125  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
127  if(!$access_handler->checkAccess("read", "", $wsp_id))
128  {
129  $valid = false;
130  $message = $lng->txt("permission_denied");
131  }
132  }
133 
134  if($valid)
135  {
136  if(!$a_url)
137  {
138  $a_url = $this->getAccessHandler()->getGotoLink($wsp_id, $this->object->getId());
139  }
140  return '<div><a href="'.$a_url.'">'.$caption.'</a></div>';
141  }
142  else
143  {
144  return '<div>'.$caption.' ('.$message.')</div>';
145  }
146  }
147  }
148 
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  include_once "Modules/Exercise/exceptions/class.ilExerciseException.php";
158  throw new ilExerciseException($this->lng->txt('permission_denied'));
159  }
160 
161  public static function _goto($a_target)
162  {
163  $id = explode("_", $a_target);
164 
165  $_GET["baseClass"] = "ilsharedresourceGUI";
166  $_GET["wsp_id"] = $id[0];
167  include("ilias.php");
168  exit;
169  }
170 }
171 
172 ?>
static createFromExercise(ilObjExercise $a_exercise, $a_user_id)
Import relevant properties from given exercise.
New implementation of ilObjectGUI.
$_GET["client_id"]
static isInPortfolioPage(ilPortfolioPage $a_page, $a_type, $a_id)
getAccessHandler()
Get access handler.
$valid
Access handler for personal workspace.
afterSave(ilObject $a_new_object)
Post (successful) object creation hook.
create()
List all exercises in which current user participated.
Tree handler for personal workspace.
Class ilObjExercise.
List all completed exercises for current user.
save()
create new instance and save it
GUI class for exercise verification.
static isUploadPossible($a_additional_size=null)
$ilUser
Definition: imgupload.php:18
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.
render($a_return=false, $a_url=false)
Render content.
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.
Create new PHPExcel object
obj_idprivate
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
Class to report exception.