ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 {
22  protected $ctrl;
23 
27  protected $tabs_gui;
28 
32  protected $lng;
33 
37  protected $tpl;
38 
42  protected $user;
43 
44  protected $exercise; // [ilObjExercise]
45  protected $submission; // [ilExSubmission]
46  protected $assignment; // [ilExAssignment]
47 
56  public function __construct(ilObjExercise $a_exercise, ilExAssignment $a_ass, $a_user_id = null)
57  {
58  global $DIC;
59 
60  $this->user = $DIC->user();
61  $ilCtrl = $DIC->ctrl();
62  $ilTabs = $DIC->tabs();
63  $lng = $DIC->language();
64  $tpl = $DIC["tpl"];
65  $ilUser = $DIC->user();
66 
67  if (!$a_user_id) {
68  $a_user_id = $ilUser->getId();
69  }
70 
71  $this->assignment = $a_ass;
72  $this->exercise = $a_exercise;
73 
74  // #12337
75  if (!$this->exercise->members_obj->isAssigned($a_user_id)) {
76  $this->exercise->members_obj->assignMember($a_user_id);
77  }
78 
79  // public submissions ???
80  $public_submissions = false;
81  if ($this->exercise->getShowSubmissions() &&
82  $this->exercise->getTimestamp() - time() <= 0) { // ???
83  $public_submissions = true;
84  }
85  $this->submission = new ilExSubmission($a_ass, $a_user_id, null, false, $public_submissions);
86 
87  // :TODO:
88  $this->ctrl = $ilCtrl;
89  $this->tabs_gui = $ilTabs;
90  $this->lng = $lng;
91  $this->tpl = $tpl;
92  }
93 
94  public function executeCommand()
95  {
97 
98  $class = $ilCtrl->getNextClass($this);
99  $cmd = $ilCtrl->getCmd("listPublicSubmissions");
100 
101  switch ($class) {
102  case "ilexsubmissionteamgui":
103  // team gui has no base gui - see we have to handle tabs here
104 
105  $this->tabs_gui->clearTargets();
106  $this->tabs_gui->setBackTarget(
107  $this->lng->txt("back"),
108  $this->ctrl->getLinkTarget($this, "returnToParent")
109  );
110 
111  $this->tabs_gui->addTab(
112  "submission",
113  $this->lng->txt("exc_submission"),
114  $this->ctrl->getLinkTargetByClass("ilexsubmission" . $this->submission->getSubmissionType() . "gui", "")
115  );
116 
117  include_once "Modules/Exercise/classes/class.ilExSubmissionTeamGUI.php";
118  $gui = new ilExSubmissionTeamGUI($this->exercise, $this->submission);
119  $ilCtrl->forwardCommand($gui);
120  break;
121 
122  case "ilexsubmissiontextgui":
123  include_once "Modules/Exercise/classes/class.ilExSubmissionTextGUI.php";
124  $gui = new ilExSubmissionTextGUI($this->exercise, $this->submission);
125  $ilCtrl->forwardCommand($gui);
126  break;
127 
128  case "ilexsubmissionfilegui":
129  include_once "Modules/Exercise/classes/class.ilExSubmissionFileGUI.php";
130  $gui = new ilExSubmissionFileGUI($this->exercise, $this->submission);
131  $ilCtrl->forwardCommand($gui);
132  break;
133 
134  case "ilexsubmissionobjectgui":
135  include_once "Modules/Exercise/classes/class.ilExSubmissionObjectGUI.php";
136  $gui = new ilExSubmissionObjectGUI($this->exercise, $this->submission);
137  $ilCtrl->forwardCommand($gui);
138  break;
139 
140  case "ilexpeerreviewgui":
141  $this->tabs_gui->clearTargets();
142  $this->tabs_gui->setBackTarget(
143  $this->lng->txt("back"),
144  $this->ctrl->getLinkTarget($this, "returnToParent")
145  );
146 
147  include_once("./Modules/Exercise/classes/class.ilExPeerReviewGUI.php");
148  $peer_gui = new ilExPeerReviewGUI($this->assignment, $this->submission);
149  $this->ctrl->forwardCommand($peer_gui);
150  break;
151 
152  default:
153  $this->{$cmd . "Object"}();
154  break;
155  }
156  }
157 
158  public static function getOverviewContent(ilInfoScreenGUI $a_info, ilExSubmission $a_submission)
159  {
160  global $DIC;
161 
162  $ilCtrl = $DIC->ctrl();
163 
164  if (!$a_submission->canView()) {
165  return;
166  }
167 
168  $ilCtrl->setParameterByClass("ilExSubmissionGUI", "ass_id", $a_submission->getAssignment()->getId());
169 
170  if ($a_submission->getAssignment()->hasTeam()) {
171  include_once "Modules/Exercise/classes/class.ilExSubmissionTeamGUI.php";
172  ilExSubmissionTeamGUI::getOverviewContent($a_info, $a_submission);
173  }
174 
175  $submission_type = $a_submission->getSubmissionType();
176  $class = "ilExSubmission" . $submission_type . "GUI";
177  include_once "Modules/Exercise/classes/class." . $class . ".php";
178  $class::getOverviewContent($a_info, $a_submission);
179 
180  $ilCtrl->setParameterByClass("ilExSubmissionGUI", "ass_id", "");
181  }
182 
183 
187  public function listPublicSubmissionsObject()
188  {
189  $ilTabs = $this->tabs_gui;
191  $lng = $this->lng;
192 
193  if (!$this->exercise->getShowSubmissions()) {
194  $this->returnToParentObject();
195  }
196 
197  $ilTabs->clearTargets();
198  $ilTabs->setBackTarget(
199  $lng->txt("back"),
200  $ilCtrl->getLinkTarget($this, "returnToParent")
201  );
202 
203  if ($this->assignment->getType() != ilExAssignment::TYPE_TEXT) {
204  include_once("./Modules/Exercise/classes/class.ilPublicSubmissionsTableGUI.php");
205  $tab = new ilPublicSubmissionsTableGUI($this, "listPublicSubmissions", $this->assignment);
206  $this->tpl->setContent($tab->getHTML());
207  } else {
208  // #13271
209  include_once "Modules/Exercise/classes/class.ilExAssignmentListTextTableGUI.php";
210  $tbl = new ilExAssignmentListTextTableGUI($this, "listPublicSubmissions", $this->assignment, false, true);
211  $this->tpl->setContent($tbl->getHTML());
212  }
213  }
214 
218  public function downloadFeedbackFileObject()
219  {
221 
222  $file = $_REQUEST["file"];
223 
224  if (!isset($file)) {
225  ilUtil::sendFailure($this->lng->txt("exc_select_one_file"), true);
226  $this->ctrl->redirect($this, "view");
227  }
228 
229  // check, whether file belongs to assignment
230  include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
231  $storage = new ilFSStorageExercise($this->exercise->getId(), $this->assignment->getId());
232  $files = $storage->getFeedbackFiles($this->submission->getFeedbackId());
233  $file_exist = false;
234  foreach ($files as $fb_file) {
235  if ($fb_file == $file) {
236  $file_exist = true;
237  break;
238  }
239  }
240  if (!$file_exist) {
241  echo "FILE DOES NOT EXIST";
242  exit;
243  }
244 
245  // check whether assignment has already started
246  if (!$this->assignment->notStartedYet()) {
247  // deliver file
248  $p = $storage->getFeedbackFilePath($this->submission->getFeedbackId(), $file);
250  }
251 
252  return true;
253  }
254 
256  {
258 
259  $needs_dl = ($this->assignment->getFeedbackDate() == ilExAssignment::FEEDBACK_DATE_DEADLINE);
260 
261  if (!$this->assignment ||
262  !$this->assignment->getFeedbackFile() ||
263  ($needs_dl && !$this->assignment->afterDeadlineStrict()) ||
264  (!$needs_dl && !$this->submission->hasSubmitted())) {
265  $ilCtrl->redirect($this, "returnToParent");
266  }
267 
268  // this is due to temporary bug in handleGlobalFeedbackFileUpload that missed the last "/"
269  $file = (is_file($this->assignment->getGlobalFeedbackFilePath()))
270  ? $this->assignment->getGlobalFeedbackFilePath()
271  : $this->assignment->getGlobalFeedbackFileStoragePath() . $this->assignment->getFeedbackFile();
272 
273  ilUtil::deliverFile($file, $this->assignment->getFeedbackFile());
274  }
275 
279  public function downloadFileObject()
280  {
281  $file = $_REQUEST["file"];
282 
283  if (!isset($file)) {
284  ilUtil::sendFailure($this->lng->txt("exc_select_one_file"), true);
285  $this->ctrl->redirect($this, "view");
286  }
287 
288  // check whether assignment as already started
289  if (!$this->assignment->notStartedYet()) {
290  // check, whether file belongs to assignment
291  $files = $this->assignment->getFiles();
292  $file_exist = false;
293  foreach ($files as $lfile) {
294  if ($lfile["name"] == $file) {
295  // deliver file
296  ilUtil::deliverFile($lfile["fullpath"], $file);
297  exit();
298  }
299  }
300  if (!$file_exist) {
301  echo "FILE DOES NOT EXIST";
302  exit;
303  }
304  }
305 
306  return true;
307  }
308 
309  public function returnToParentObject()
310  {
311  $this->ctrl->returnToParent($this);
312  }
313 }
$files
Definition: add-vimline.php:18
downloadFileObject()
Download assignment file.
Class ilInfoScreenGUI.
Exercise assignment.
global $DIC
Definition: saml.php:7
$tbl
Definition: example_048.php:81
downloadFeedbackFileObject()
Download feedback file.
listPublicSubmissionsObject()
List all submissions.
user()
Definition: user.php:4
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 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)
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.
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.