ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
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  $this->lng->loadLanguageModule("excv");
32 
33  $ilTabs->setBackTarget($this->lng->txt("back"),
34  $this->ctrl->getLinkTarget($this, "cancel"));
35 
36  include_once "Modules/Exercise/classes/class.ilExerciseVerificationTableGUI.php";
37  $table = new ilExerciseVerificationTableGUI($this, "create");
38  $this->tpl->setContent($table->getHTML());
39  }
40 
44  public function save()
45  {
46  global $ilUser;
47 
48  $exercise_id = $_REQUEST["exc_id"];
49  if($exercise_id)
50  {
51  include_once "Modules/Exercise/classes/class.ilObjExercise.php";
52  $exercise = new ilObjExercise($exercise_id, false);
53 
54  include_once "Modules/Exercise/classes/class.ilObjExerciseVerification.php";
55  $newObj = ilObjExerciseVerification::createFromExercise($exercise, $ilUser->getId());
56  if($newObj)
57  {
59  $this->node_id = null;
60  $this->putObjectInTree($newObj, $parent_id);
61 
62  $this->afterSave($newObj);
63  }
64  else
65  {
66  ilUtil::sendFailure($this->lng->txt("msg_failed"));
67  }
68  }
69  else
70  {
71  ilUtil::sendFailure($this->lng->txt("select_one"));
72  }
73  $this->create();
74  }
75 
76  public function deliver()
77  {
78  $file = $this->object->getFilePath();
79  if($file)
80  {
81  ilUtil::deliverFile($file, $this->object->getTitle().".pdf");
82  }
83  }
84 
90  public function render($a_return = false)
91  {
92  global $ilUser;
93 
94  if(!$a_return)
95  {
96  $this->deliver();
97  }
98  else
99  {
100  $tree = new ilWorkspaceTree($ilUser->getId());
101  $wsp_id = $tree->lookupNodeId($this->object->getId());
102 
103  $caption = $this->object->getTitle();
104  $link = $this->getAccessHandler()->getGotoLink($wsp_id, $this->object->getId());
105 
106  return "<a href=\"".$link."\">".$caption."</a>";
107  }
108  }
109 
110  function _goto($a_target)
111  {
112  $id = explode("_", $a_target);
113 
114  $_GET["baseClass"] = "ilsharedresourceGUI";
115  $_GET["wsp_id"] = $id[0];
116  include("ilias.php");
117  exit;
118  }
119 }
120 
121 ?>