ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilExSubmissionGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once "Modules/Exercise/classes/class.ilExSubmissionBaseGUI.php";
5 include_once "Modules/Exercise/classes/class.ilExSubmission.php";
6 
18 {
19  protected $exercise; // [ilObjExercise]
20  protected $submission; // [ilExSubmission]
21  protected $assignment; // [ilExAssignment]
22 
31  public function __construct(ilObjExercise $a_exercise, ilExAssignment $a_ass, $a_user_id = null)
32  {
33  global $ilCtrl, $ilTabs, $lng, $tpl, $ilUser;
34 
35  if(!$a_user_id)
36  {
37  $a_user_id = $ilUser->getId();
38  }
39 
40  $this->assignment = $a_ass;
41  $this->exercise = $a_exercise;
42 
43  // #12337
44  if (!$this->exercise->members_obj->isAssigned($a_user_id))
45  {
46  $this->exercise->members_obj->assignMember($a_user_id);
47  }
48 
49  // public submissions ???
50  $public_submissions = false;
51  if ($this->exercise->getShowSubmissions() &&
52  $this->exercise->getTimestamp() - time() <= 0) // ???
53  {
54  $public_submissions = true;
55  }
56  $this->submission = new ilExSubmission($a_ass, $a_user_id, null, false, $public_submissions);
57 
58  // :TODO:
59  $this->ctrl = $ilCtrl;
60  $this->tabs_gui = $ilTabs;
61  $this->lng = $lng;
62  $this->tpl = $tpl;
63  }
64 
65  public function executeCommand()
66  {
67  global $ilCtrl;
68 
69  $class = $ilCtrl->getNextClass($this);
70  $cmd = $ilCtrl->getCmd("listPublicSubmissions");
71 
72  switch($class)
73  {
74  case "ilexsubmissionteamgui":
75  // team gui has no base gui - see we have to handle tabs here
76 
77  $this->tabs_gui->clearTargets();
78  $this->tabs_gui->setBackTarget($this->lng->txt("back"),
79  $this->ctrl->getLinkTarget($this, "returnToParent"));
80 
81  $this->tabs_gui->addTab("submission", $this->lng->txt("exc_submission"),
82  $this->ctrl->getLinkTargetByClass("ilexsubmission".$this->submission->getSubmissionType()."gui", ""));
83 
84  include_once "Modules/Exercise/classes/class.ilExSubmissionTeamGUI.php";
85  $gui = new ilExSubmissionTeamGUI($this->exercise, $this->submission);
86  $ilCtrl->forwardCommand($gui);
87  break;
88 
89  case "ilexsubmissiontextgui":
90  include_once "Modules/Exercise/classes/class.ilExSubmissionTextGUI.php";
91  $gui = new ilExSubmissionTextGUI($this->exercise, $this->submission);
92  $ilCtrl->forwardCommand($gui);
93  break;
94 
95  case "ilexsubmissionfilegui":
96  include_once "Modules/Exercise/classes/class.ilExSubmissionFileGUI.php";
97  $gui = new ilExSubmissionFileGUI($this->exercise, $this->submission);
98  $ilCtrl->forwardCommand($gui);
99  break;
100 
101  case "ilexsubmissionobjectgui":
102  include_once "Modules/Exercise/classes/class.ilExSubmissionObjectGUI.php";
103  $gui = new ilExSubmissionObjectGUI($this->exercise, $this->submission);
104  $ilCtrl->forwardCommand($gui);
105  break;
106 
107  case "ilexpeerreviewgui":
108  $this->tabs_gui->clearTargets();
109  $this->tabs_gui->setBackTarget($this->lng->txt("back"),
110  $this->ctrl->getLinkTarget($this, "returnToParent"));
111 
112  include_once("./Modules/Exercise/classes/class.ilExPeerReviewGUI.php");
113  $peer_gui = new ilExPeerReviewGUI($this->assignment, $this->submission);
114  $this->ctrl->forwardCommand($peer_gui);
115  break;
116 
117  default:
118  $this->{$cmd."Object"}();
119  break;
120  }
121  }
122 
123  public static function getOverviewContent(ilInfoScreenGUI $a_info, ilExSubmission $a_submission)
124  {
125  global $ilCtrl;
126 
127  if(!$a_submission->canView())
128  {
129  return;
130  }
131 
132  $ilCtrl->setParameterByClass("ilExSubmissionGUI", "ass_id", $a_submission->getAssignment()->getId());
133 
134  if($a_submission->getAssignment()->hasTeam())
135  {
136  include_once "Modules/Exercise/classes/class.ilExSubmissionTeamGUI.php";
137  ilExSubmissionTeamGUI::getOverviewContent($a_info, $a_submission);
138  }
139 
140  $submission_type = $a_submission->getSubmissionType();
141  $class = "ilExSubmission".$submission_type."GUI";
142  include_once "Modules/Exercise/classes/class.".$class.".php";
143  $class::getOverviewContent($a_info, $a_submission);
144 
145  $ilCtrl->setParameterByClass("ilExSubmissionGUI", "ass_id", "");
146  }
147 
148 
153  {
154  global $ilTabs, $ilCtrl, $lng;
155 
156  if(!$this->exercise->getShowSubmissions())
157  {
158  $this->returnToParentObject();
159  }
160 
161  $ilTabs->clearTargets();
162  $ilTabs->setBackTarget($lng->txt("back"),
163  $ilCtrl->getLinkTarget($this, "returnToParent"));
164 
165  if($this->assignment->getType() != ilExAssignment::TYPE_TEXT)
166  {
167  include_once("./Modules/Exercise/classes/class.ilPublicSubmissionsTableGUI.php");
168  $tab = new ilPublicSubmissionsTableGUI($this, "listPublicSubmissions", $this->assignment);
169  $this->tpl->setContent($tab->getHTML());
170  }
171  else
172  {
173  // #13271
174  include_once "Modules/Exercise/classes/class.ilExAssignmentListTextTableGUI.php";
175  $tbl = new ilExAssignmentListTextTableGUI($this, "listPublicSubmissions", $this->assignment, false, true);
176  $this->tpl->setContent($tbl->getHTML());
177  }
178  }
179 
184  {
185  global $ilUser;
186 
187  $file = $_REQUEST["file"];
188 
189  if (!isset($file))
190  {
191  ilUtil::sendFailure($this->lng->txt("exc_select_one_file"),true);
192  $this->ctrl->redirect($this, "view");
193  }
194 
195  // check, whether file belongs to assignment
196  include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
197  $storage = new ilFSStorageExercise($this->exercise->getId(), $this->assignment->getId());
198  $files = $storage->getFeedbackFiles($this->submission->getFeedbackId());
199  $file_exist = false;
200  foreach($files as $fb_file)
201  {
202  if($fb_file == $file)
203  {
204  $file_exist = true;
205  break;
206  }
207  }
208  if(!$file_exist)
209  {
210  echo "FILE DOES NOT EXIST";
211  exit;
212  }
213 
214  // check whether assignment has already started
215  if (!$this->assignment->notStartedYet())
216  {
217  // deliver file
218  $p = $storage->getFeedbackFilePath($this->submission->getFeedbackId(), $file);
220  }
221 
222  return true;
223  }
224 
226  {
227  global $ilCtrl;
228 
229  $needs_dl = ($this->assignment->getFeedbackDate() == ilExAssignment::FEEDBACK_DATE_DEADLINE);
230 
231  if(!$this->assignment ||
232  !$this->assignment->getFeedbackFile() ||
233  ($needs_dl && !$this->assignment->afterDeadlineStrict()) ||
234  (!$needs_dl && !$this->submission->hasSubmitted()))
235  {
236  $ilCtrl->redirect($this, "returnToParent");
237  }
238 
239  // this is due to temporary bug in handleGlobalFeedbackFileUpload that missed the last "/"
240  $file = (is_file($this->assignment->getGlobalFeedbackFilePath()))
241  ? $this->assignment->getGlobalFeedbackFilePath()
242  : $this->assignment->getGlobalFeedbackFileStoragePath().$this->assignment->getFeedbackFile();
243 
244  ilUtil::deliverFile($file, $this->assignment->getFeedbackFile());
245  }
246 
251  {
252  $file = $_REQUEST["file"];
253 
254  if (!isset($file))
255  {
256  ilUtil::sendFailure($this->lng->txt("exc_select_one_file"),true);
257  $this->ctrl->redirect($this, "view");
258  }
259 
260  // check whether assignment as already started
261  if (!$this->assignment->notStartedYet())
262  {
263  // check, whether file belongs to assignment
264  $files = $this->assignment->getFiles();
265  $file_exist = false;
266  foreach($files as $lfile)
267  {
268  if($lfile["name"] == $file)
269  {
270  // deliver file
271  ilUtil::deliverFile($lfile["fullpath"], $file);
272  exit();
273  }
274  }
275  if(!$file_exist)
276  {
277  echo "FILE DOES NOT EXIST";
278  exit;
279  }
280  }
281 
282  return true;
283  }
284 
286  {
287  $this->ctrl->returnToParent($this);
288  }
289 }
$files
Definition: add-vimline.php:18
downloadFileObject()
Download assignment file.
Class ilInfoScreenGUI.
Exercise assignment.
$tbl
Definition: example_048.php:81
$cmd
Definition: sahs_server.php:35
downloadFeedbackFileObject()
Download feedback file.
listPublicSubmissionsObject()
List all submissions.
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
Class ilObjExercise.
Class ilExPeerReviewGUI.
$ilUser
Definition: imgupload.php:18
__construct(ilObjExercise $a_exercise, ilExAssignment $a_ass, $a_user_id=null)
Constructor.
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static getOverviewContent(ilInfoScreenGUI $a_info, ilExSubmission $a_submission)
static getOverviewContent(ilInfoScreenGUI $a_info, ilExSubmission $a_submission)
global $lng
Definition: privfeed.php:17
Exercise submission.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
Object-based submissions (ends up as static file)
Object-based submissions (ends up as static file)
Class ilExSubmissionGUI.