ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilExSubmissionFileGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
13{
14 public function executeCommand()
15 {
16 global $ilCtrl;
17
18 if(!$this->submission->canView())
19 {
20 $this->returnToParentObject();
21 }
22
23 $class = $ilCtrl->getNextClass($this);
24 $cmd = $ilCtrl->getCmd("submissionScreen");
25
26 switch($class)
27 {
28 default:
29 $this->{$cmd."Object"}();
30 break;
31 }
32 }
33
34 public static function getOverviewContent(ilInfoScreenGUI $a_info, ilExSubmission $a_submission)
35 {
36 global $lng, $ilCtrl;
37
38 $titles = array();
39 foreach($a_submission->getFiles() as $file)
40 {
41 $titles[] = $file["filetitle"];
42 }
43 $files_str = implode($titles, ", ");
44 if ($files_str == "")
45 {
46 $files_str = $lng->txt("message_no_delivered_files");
47 }
48
49 // no team == no submission
50 if(!$a_submission->hasNoTeamYet())
51 {
52 if ($a_submission->canSubmit())
53 {
54 $title = (count($titles) == 0
55 ? $lng->txt("exc_hand_in")
56 : $lng->txt("exc_edit_submission"));
57
58 $button = ilLinkButton::getInstance();
59 $button->setPrimary(true);
60 $button->setCaption($title, false);
61 $button->setUrl($ilCtrl->getLinkTargetByClass(array("ilExSubmissionGUI", "ilExSubmissionFileGUI"), "submissionScreen"));
62 $files_str.= " ".$button->render();
63 }
64 else
65 {
66 if (count($titles) > 0)
67 {
68 $button = ilLinkButton::getInstance();
69 $button->setCaption("already_delivered_files");
70 $button->setUrl($ilCtrl->getLinkTargetByClass(array("ilExSubmissionGUI", "ilExSubmissionFileGUI"), "submissionScreen"));
71 $files_str.= " ".$button->render();
72 }
73 }
74 }
75
76 $a_info->addProperty($lng->txt("exc_files_returned"), $files_str);
77 }
78
85 {
86 global $ilToolbar, $ilHelp, $ilUser;
87
88
89 $this->handleTabs();
90
91 $ilHelp->setScreenIdComponent("exc");
92 $ilHelp->setScreenId("submissions");
93
94 if (!$this->submission->canSubmit())
95 {
96 ilUtil::sendInfo($this->lng->txt("exercise_time_over"));
97 }
98 else
99 {
100 $max_files = $this->submission->getAssignment()->getMaxFile();
101
102 if($this->submission->canAddFile())
103 {
104 // #15883 - extended deadline warning
105 $deadline = $this->assignment->getPersonalDeadline($ilUser->getId());
106 if($deadline &&
107 time() > $deadline)
108 {
110 $dl = sprintf($this->lng->txt("exc_late_submission_warning"), $dl);
111 $dl = '<span class="warning">'.$dl.'</span>';
112 $ilToolbar->addText($dl);
113 }
114
115 $ilToolbar->addButton($this->lng->txt("file_add"),
116 $this->ctrl->getLinkTarget($this, "uploadForm"));
117
118 if(!$max_files ||
119 $max_files > 1)
120 {
121 $ilToolbar->addButton($this->lng->txt("header_zip"),
122 $this->ctrl->getLinkTarget($this, "uploadZipForm"));
123 }
124 }
125
126 if($max_files)
127 {
128 ilUtil::sendInfo(sprintf($this->lng->txt("exc_max_file_reached"), $max_files));
129 }
130 }
131
132 include_once("./Modules/Exercise/classes/class.ilExcDeliveredFilesTableGUI.php");
133 $tab = new ilExcDeliveredFilesTableGUI($this, "submissionScreen", $this->submission);
134 $this->tpl->setContent($tab->getHTML());
135 }
136
140 public function uploadFormObject(ilPropertyFormGUI $a_form = null)
141 {
142 if (!$this->submission->canSubmit())
143 {
144 $this->ctrl->redirect($this, "submissionScreen");
145 }
146
147 $this->tabs_gui->clearTargets();
148 $this->tabs_gui->setBackTarget($this->lng->txt("back"),
149 $this->ctrl->getLinkTarget($this, "submissionScreen"));
150
151 global $ilHelp;
152 $ilHelp->setScreenIdComponent("exc");
153 $ilHelp->setScreenId("upload_submission");
154
155 if(!$a_form)
156 {
157 $a_form = $this->initUploadForm();
158 }
159 $this->tpl->setContent($a_form->getHTML());
160 }
161
165 public function uploadZipFormObject(ilPropertyFormGUI $a_form = null)
166 {
167 if (!$this->submission->canSubmit())
168 {
169 $this->ctrl->redirect($this, "submissionScreen");
170 }
171
172 $this->tabs_gui->clearTargets();
173 $this->tabs_gui->setBackTarget($this->lng->txt("back"),
174 $this->ctrl->getLinkTarget($this, "submissionScreen"));
175
176 if(!$a_form)
177 {
178 $a_form = $this->initZipUploadForm();
179 }
180 $this->tpl->setContent($a_form->getHTML());
181 }
182
186 protected function initUploadForm()
187 {
188 global $lng, $ilCtrl;
189
190 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
191 $form = new ilPropertyFormGUI();
192
193 // file input
194 include_once("./Services/Form/classes/class.ilFileWizardInputGUI.php");
195 $fi = new ilFileWizardInputGUI($lng->txt("file"), "deliver");
196 $fi->setFilenames(array(0 => ''));
197 $fi->setRequired(true);
198 $form->addItem($fi);
199
200 $form->addCommandButton("uploadFile", $lng->txt("upload"));
201 $form->addCommandButton("submissionScreen", $lng->txt("cancel"));
202
203 $form->setTitle($lng->txt("file_add"));
204 $form->setFormAction($ilCtrl->getFormAction($this, "uploadFile"));
205
206 return $form;
207 }
208
212 protected function initZipUploadForm()
213 {
214 global $lng, $ilCtrl;
215
216 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
217 $form = new ilPropertyFormGUI();
218
219 include_once("./Services/Form/classes/class.ilFileInputGUI.php");
220 $fi = new ilFileInputGUI($lng->txt("file"), "deliver");
221 $fi->setSuffixes(array("zip"));
222 $fi->setRequired(true);
223 $form->addItem($fi);
224
225 $form->addCommandButton("uploadZip", $lng->txt("upload"));
226 $form->addCommandButton("submissionScreen", $lng->txt("cancel"));
227
228 $form->setTitle($lng->txt("header_zip"));
229 $form->setFormAction($ilCtrl->getFormAction($this, "uploadZip"));
230
231 return $form;
232 }
233
238 {
239 global $ilCtrl;
240
241 // #15322
242 if (!$this->submission->canSubmit())
243 {
244 ilUtil::sendInfo($this->lng->txt("exercise_time_over"), true);
245 }
246 else
247 {
248 $form = $this->initUploadForm();
249 if(!$form->checkInput())
250 {
251 return $this->uploadFormObject($form);
252 }
253
254 $success = false;
255 foreach ($_FILES["deliver"]["name"] as $k => $v)
256 {
257 $file = array(
258 "name" => $_FILES["deliver"]["name"][$k],
259 "type" => $_FILES["deliver"]["type"][$k],
260 "tmp_name" => $_FILES["deliver"]["tmp_name"][$k],
261 "error" => $_FILES["deliver"]["error"][$k],
262 "size" => $_FILES["deliver"]["size"][$k],
263 );
264 if(!$this->submission->uploadFile($file))
265 {
266 ilUtil::sendFailure($this->lng->txt("exc_upload_error"), true);
267 }
268 else
269 {
270 $success = true;
271 }
272 }
273
274 if($success)
275 {
276 ilUtil::sendSuccess($this->lng->txt("file_added"), true);
277 $this->handleNewUpload();
278 }
279 }
280
281 $ilCtrl->redirect($this, "submissionScreen");
282 }
283
288 {
289 global $ilCtrl;
290
291 // #15322
292 if (!$this->submission->canSubmit())
293 {
294 ilUtil::sendInfo($this->lng->txt("exercise_time_over"), true);
295 }
296 else
297 {
298 $form = $this->initZipUploadForm();
299 if(!$form->checkInput())
300 {
301 return $this->uploadZipFormObject($form);
302 }
303
304 if (preg_match("/zip/",$_FILES["deliver"]["type"]) == 1)
305 {
306 if($this->submission->processUploadedZipFile($_FILES["deliver"]["tmp_name"]))
307 {
308 ilUtil::sendSuccess($this->lng->txt("file_added"), true);
309 $this->handleNewUpload();
310 }
311 }
312 }
313
314 $ilCtrl->redirect($this, "submissionScreen");
315 }
316
321 {
322 global $ilCtrl, $tpl, $lng;
323
324 if (!$this->submission->canSubmit())
325 {
326 ilUtil::sendFailure($this->lng->txt("exercise_time_over"), true);
327 $ilCtrl->redirect($this, "submissionScreen");
328 }
329
330 if (!is_array($_POST["delivered"]) || count($_POST["delivered"]) == 0)
331 {
332 ilUtil::sendFailure($lng->txt("no_checkbox"), true);
333 $ilCtrl->redirect($this, "submissionScreen");
334 }
335 else
336 {
337 $this->tabs_gui->clearTargets();
338 $this->tabs_gui->setBackTarget($this->lng->txt("back"),
339 $this->ctrl->getLinkTarget($this, "submissionScreen"));
340
341 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
342 $cgui = new ilConfirmationGUI();
343 $cgui->setFormAction($ilCtrl->getFormAction($this));
344 $cgui->setHeaderText($lng->txt("info_delete_sure"));
345 $cgui->setCancel($lng->txt("cancel"), "submissionScreen");
346 $cgui->setConfirm($lng->txt("delete"), "deleteDelivered");
347
348 $files = $this->submission->getFiles();
349
350 foreach ($_POST["delivered"] as $i)
351 {
352 reset ($files);
353 $title = "";
354 foreach ($files as $f)
355 {
356 if ($f["returned_id"] == $i)
357 {
358 $title = $f["filetitle"];
359 }
360 }
361 $cgui->addItem("delivered[]", $i, $title);
362 }
363
364 $tpl->setContent($cgui->getHTML());
365 }
366 }
367
375 {
376 global $ilCtrl;
377
378 if (!$this->submission->canSubmit())
379 {
380 ilUtil::sendFailure($this->lng->txt("exercise_time_over"), true);
381 }
382 else if (!count($_POST["delivered"]))
383 {
384 ilUtil::sendFailure($this->lng->txt("please_select_a_delivered_file_to_delete"), true);
385 }
386 else
387 {
388 $this->submission->deleteSelectedFiles($_POST["delivered"]);
389 $this->handleRemovedUpload();
390
391 ilUtil::sendSuccess($this->lng->txt("exc_submitted_files_deleted"), true);
392 }
393 $ilCtrl->redirect($this, "submissionScreen");
394 }
395
399 function downloadReturnedObject($a_only_new = false)
400 {
401 $peer_review_mask_filename = false;
402
403 if($this->submission->canView())
404 {
405 $peer_review_mask_filename = $this->submission->hasPeerReviewAccess();
406 }
407 else
408 {
409 // no access
410 return;
411 }
412
413 $this->submission->downloadFiles(null, $a_only_new, $peer_review_mask_filename);
414 $this->returnToParentObject();
415 }
416
421 {
422 $this->downloadReturnedObject(true);
423 }
424
431 function downloadObject()
432 {
433 global $ilCtrl;
434
435 if(!$this->submission->canView())
436 {
437 $this->returnToParentObject();
438 }
439
440 if (count($_REQUEST["delivered"]))
441 {
442 if(!is_array($_REQUEST["delivered"]))
443 {
444 $_REQUEST["delivered"] = array($_REQUEST["delivered"]);
445 }
446 $this->submission->downloadFiles($_REQUEST["delivered"]);
447 exit;
448 }
449 else
450 {
451 ilUtil::sendFailure($this->lng->txt("please_select_a_delivered_file_to_download"), true);
452 $ilCtrl->redirect($this, "submissionScreen");
453 }
454 }
455}
sprintf('%.4f', $callTime)
global $tpl
Definition: ilias.php:8
$success
Definition: Utf8Test.php:86
$files
Definition: add-vimline.php:18
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
Confirmation screen class.
static formatDate(ilDateTime $date)
Format a date @access public.
@classDescription Date and time handling
Exercise submission base gui.
handleNewUpload($a_no_notifications=false)
uploadZipFormObject(ilPropertyFormGUI $a_form=null)
Display form for zip file upload.
confirmDeleteDeliveredObject()
Confirm deletion of delivered files.
static getOverviewContent(ilInfoScreenGUI $a_info, ilExSubmission $a_submission)
initZipUploadForm()
Init upload form form.
deleteDeliveredObject()
Delete file(s) submitted by user.
downloadNewReturnedObject()
Download newly submitted files of user.
downloadObject()
User downloads (own) submitted files.
initUploadForm()
Init upload form form.
submissionScreenObject()
Displays a form which allows members to deliver their solutions.
downloadReturnedObject($a_only_new=false)
Download submitted files of user.
uploadFormObject(ilPropertyFormGUI $a_form=null)
Display form for single file upload.
Exercise submission.
getFiles(array $a_file_ids=null, $a_only_valid=false, $a_min_timestamp=null)
This class represents a file property in a property form.
This class represents a file wizard property in a property form.
Class ilInfoScreenGUI.
addProperty($a_name, $a_value, $a_link="")
add a property to current section
static getInstance()
Factory.
This class represents a property form user interface.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file
$cmd
Definition: sahs_server.php:35
$ilUser
Definition: imgupload.php:18