ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
15{
17
21 protected $ctrl;
22
26 protected $tabs_gui;
27
31 protected $lng;
32
36 protected $tpl;
37
41 protected $user;
42
43 protected $exercise; // [ilObjExercise]
44 protected $submission; // [ilExSubmission]
45 protected $assignment; // [ilExAssignment]
46
50 protected $type_guis;
51
60 public function __construct(ilObjExercise $a_exercise, ilExAssignment $a_ass, $a_user_id = null)
61 {
62 global $DIC;
63
64 $this->user = $DIC->user();
65 $ilCtrl = $DIC->ctrl();
66 $ilTabs = $DIC->tabs();
67 $lng = $DIC->language();
68 $tpl = $DIC["tpl"];
69 $ilUser = $DIC->user();
70
71 if (!$a_user_id) {
72 $a_user_id = $ilUser->getId();
73 }
74
75 $this->assignment = $a_ass;
76 $this->exercise = $a_exercise;
77 $this->user_id = $a_user_id;
78
79 $this->type_guis = ilExAssignmentTypesGUI::getInstance();
80
81 // #12337
82 if (!$this->exercise->members_obj->isAssigned($a_user_id)) {
83 $this->exercise->members_obj->assignMember($a_user_id);
84 }
85
86 // public submissions ???
87 $public_submissions = false;
88 if ($this->exercise->getShowSubmissions() &&
89 $this->exercise->getTimestamp() - time() <= 0) { // ???
90 $public_submissions = true;
91 }
92 $this->submission = new ilExSubmission($a_ass, $a_user_id, null, false, $public_submissions);
93
94 // :TODO:
95 $this->ctrl = $ilCtrl;
96 $this->tabs_gui = $ilTabs;
97 $this->lng = $lng;
98 $this->tpl = $tpl;
99 }
100
101 public function executeCommand()
102 {
104
105 $class = $ilCtrl->getNextClass($this);
106 $cmd = $ilCtrl->getCmd("listPublicSubmissions");
107
108 switch ($class) {
109 case "ilexsubmissionteamgui":
110 // team gui has no base gui - see we have to handle tabs here
111
112 $this->tabs_gui->clearTargets();
113 $this->tabs_gui->setBackTarget(
114 $this->lng->txt("back"),
115 $this->ctrl->getLinkTarget($this, "returnToParent")
116 );
117
118 // forward to type gui
119 if ($this->submission->getSubmissionType() != ilExSubmission::TYPE_REPO_OBJECT) {
120 $this->tabs_gui->addTab(
121 "submission",
122 $this->lng->txt("exc_submission"),
123 $this->ctrl->getLinkTargetByClass("ilexsubmission" . $this->submission->getSubmissionType() . "gui", "")
124 );
125 }
126
127 $gui = new ilExSubmissionTeamGUI($this->exercise, $this->submission);
128 $ilCtrl->forwardCommand($gui);
129 break;
130
131 case "ilexsubmissiontextgui":
132 $gui = new ilExSubmissionTextGUI($this->exercise, $this->submission);
133 $ilCtrl->forwardCommand($gui);
134 break;
135
136 case "ilexsubmissionfilegui":
137 $gui = new ilExSubmissionFileGUI($this->exercise, $this->submission);
138 $ilCtrl->forwardCommand($gui);
139 break;
140
141 case "ilexsubmissionobjectgui":
142 $gui = new ilExSubmissionObjectGUI($this->exercise, $this->submission);
143 $ilCtrl->forwardCommand($gui);
144 break;
145
146 case "ilexpeerreviewgui":
147 $this->tabs_gui->clearTargets();
148 $this->tabs_gui->setBackTarget(
149 $this->lng->txt("back"),
150 $this->ctrl->getLinkTarget($this, "returnToParent")
151 );
152
153 $peer_gui = new ilExPeerReviewGUI($this->assignment, $this->submission);
154 $this->ctrl->forwardCommand($peer_gui);
155 break;
156
157 default:
158
159
160 // forward to type gui
161 if ($this->type_guis->isExAssTypeGUIClass($class)) {
162 $type_gui = $this->type_guis->getByClassName($class);
163 $type_gui->setSubmission($this->submission);
164 $type_gui->setExercise($this->exercise);
165 return $ilCtrl->forwardCommand($type_gui);
166 }
167
168 $this->{$cmd . "Object"}();
169 break;
170 }
171 }
172
180 public static function getOverviewContent(ilInfoScreenGUI $a_info, ilExSubmission $a_submission, ilObjExercise $a_exc)
181 {
182 global $DIC;
183
184 $ilCtrl = $DIC->ctrl();
185
186 if (!$a_submission->canView()) {
187 return;
188 }
189
190 $ilCtrl->setParameterByClass("ilExSubmissionGUI", "ass_id", $a_submission->getAssignment()->getId());
191
192 if ($a_submission->getAssignment()->hasTeam()) {
193 ilExSubmissionTeamGUI::getOverviewContent($a_info, $a_submission);
194 }
195
196 $submission_type = $a_submission->getSubmissionType();
197 // old handling -> forward to submission type gui class
198 // @todo migrate everything to new concept
199 if ($submission_type != ilExSubmission::TYPE_REPO_OBJECT) {
200 $class = "ilExSubmission" . $submission_type . "GUI";
201 $class::getOverviewContent($a_info, $a_submission);
202 } else { // new: get HTML from assignemt type gui class
203 $sub_gui = new ilExSubmissionGUI($a_exc, $a_submission->getAssignment());
204 $ilCtrl->getHTML($sub_gui, array(
205 "mode" => self::MODE_OVERVIEW_CONTENT,
206 "info" => $a_info,
207 "submission" => $a_submission
208 ));
209 }
210
211 $ilCtrl->setParameterByClass("ilExSubmissionGUI", "ass_id", "");
212 }
213
220 public function getHTML($par)
221 {
222 switch ($par["mode"]) {
223 // get overview content from ass type gui
225 $type_gui = $this->type_guis->getById($par["submission"]->getAssignment()->getType());
226 return $type_gui->getOverviewContent($par["info"], $par["submission"]);
227 break;
228 }
229 }
230
231
236 {
237 $ilTabs = $this->tabs_gui;
240
241 if (!$this->exercise->getShowSubmissions()) {
242 $this->returnToParentObject();
243 }
244
245 $ilTabs->clearTargets();
246 $ilTabs->setBackTarget(
247 $lng->txt("back"),
248 $ilCtrl->getLinkTarget($this, "returnToParent")
249 );
250
251 if ($this->assignment->getType() != ilExAssignment::TYPE_TEXT) {
252 $tab = new ilPublicSubmissionsTableGUI($this, "listPublicSubmissions", $this->assignment);
253 $this->tpl->setContent($tab->getHTML());
254 } else {
255 // #13271
256 $tbl = new ilExAssignmentListTextTableGUI($this, "listPublicSubmissions", $this->assignment, false, true);
257 $this->tpl->setContent($tbl->getHTML());
258 }
259 }
260
265 {
267
268 $file = $_REQUEST["file"];
269
270 if (!isset($file)) {
271 ilUtil::sendFailure($this->lng->txt("exc_select_one_file"), true);
272 $this->ctrl->redirect($this, "view");
273 }
274
275 // check, whether file belongs to assignment
276 $storage = new ilFSStorageExercise($this->exercise->getId(), $this->assignment->getId());
277 $files = $storage->getFeedbackFiles($this->submission->getFeedbackId());
278 $file_exist = false;
279 foreach ($files as $fb_file) {
280 if ($fb_file == $file) {
281 $file_exist = true;
282 break;
283 }
284 }
285 if (!$file_exist) {
286 echo "FILE DOES NOT EXIST";
287 exit;
288 }
289
290 // check whether assignment has already started
291 if (!$this->assignment->notStartedYet()) {
292 // deliver file
293 $p = $storage->getFeedbackFilePath($this->submission->getFeedbackId(), $file);
294 ilUtil::deliverFile($p, $file);
295 }
296
297 return true;
298 }
299
301 {
303
304 $state = ilExcAssMemberState::getInstanceByIds($this->assignment->getId(), $this->user_id);
305
306 // fix bug 28466, this code should be streamlined with the if above and
307 // the presentation of the download link in the ilExAssignmentGUI->addSubmission
308 if (!$state->isGlobalFeedbackFileAccessible($this->submission)) {
309 $ilCtrl->redirect($this, "returnToParent");
310 }
311
312 // this is due to temporary bug in handleGlobalFeedbackFileUpload that missed the last "/"
313 $file = (is_file($this->assignment->getGlobalFeedbackFilePath()))
314 ? $this->assignment->getGlobalFeedbackFilePath()
315 : $this->assignment->getGlobalFeedbackFileStoragePath() . $this->assignment->getFeedbackFile();
316
317 ilUtil::deliverFile($file, $this->assignment->getFeedbackFile());
318 }
319
323 public function downloadFileObject()
324 {
325 $file = $_REQUEST["file"];
326
327 if (!isset($file)) {
328 ilUtil::sendFailure($this->lng->txt("exc_select_one_file"), true);
329 $this->ctrl->redirect($this, "view");
330 }
331
332 // check whether assignment as already started
333 $state = ilExcAssMemberState::getInstanceByIds($this->assignment->getId(), $this->user_id);
334 if ($state->areInstructionsVisible()) {
335 // check, whether file belongs to assignment
336 $files = $this->assignment->getFiles();
337 $file_exist = false;
338 foreach ($files as $lfile) {
339 if ($lfile["name"] == $file) {
340 // deliver file
341 ilUtil::deliverFile($lfile["fullpath"], $file);
342 exit();
343 }
344 }
345 if (!$file_exist) {
346 echo "FILE DOES NOT EXIST";
347 exit;
348 }
349 }
350
351 return true;
352 }
353
354 public function returnToParentObject()
355 {
356 $this->ctrl->returnToParent($this);
357 }
358}
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
Exercise assignment.
Class ilExPeerReviewGUI.
Class ilExSubmissionGUI.
downloadFileObject()
Download assignment file.
__construct(ilObjExercise $a_exercise, ilExAssignment $a_ass, $a_user_id=null)
Constructor.
listPublicSubmissionsObject()
List all submissions.
downloadFeedbackFileObject()
Download feedback file.
static getOverviewContent(ilInfoScreenGUI $a_info, ilExSubmission $a_submission, ilObjExercise $a_exc)
Object-based submissions (ends up as static file)
static getOverviewContent(ilInfoScreenGUI $a_info, ilExSubmission $a_submission)
Object-based submissions (ends up as static file)
Exercise submission //TODO: This class has to much static methods related to delivered "files".
static getInstanceByIds($a_ass_id, $a_user_id=0)
Get instance by IDs (recommended for consumer code)
Class ilInfoScreenGUI.
Class ilObjExercise.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
global $ilCtrl
Definition: ilias.php:18
exit
Definition: login.php:29
$ilUser
Definition: imgupload.php:18
$DIC
Definition: xapitoken.php:46