ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilExSubmissionGUI.php
Go to the documentation of this file.
1 <?php
2 
20 
31 {
32  public const MODE_OVERVIEW_CONTENT = 1;
33  protected \ILIAS\Exercise\InternalDomainService $domain;
34  protected \ILIAS\Exercise\InternalGUIService $gui;
35 
36  protected ilCtrl $ctrl;
37  protected ilTabsGUI $tabs_gui;
38  protected ilLanguage $lng;
40  protected ilObjUser $user;
45  protected ?int $user_id;
46  protected GUIRequest $request;
47 
48  public function __construct(
49  ilObjExercise $a_exercise,
50  ilExAssignment $a_ass,
51  ?int $a_user_id = null
52  ) {
53  global $DIC;
54 
55  $service = $DIC->exercise()->internal();
56  $this->gui = $gui = $service->gui();
57  $this->domain = $domain = $service->domain();
58 
59  $this->user = $domain->user();
60  $ilCtrl = $gui->ctrl();
61  $ilTabs = $gui->tabs();
62  $lng = $domain->lng();
63  $tpl = $gui->ui()->mainTemplate();
64 
65  if (!$a_user_id) {
66  $a_user_id = $this->user->getId();
67  }
68 
69  $this->assignment = $a_ass;
70  $this->exercise = $a_exercise;
71  $this->user_id = $a_user_id;
72 
73  $this->type_guis = $gui->assignment()->types();
74 
75  // #12337
76  if (!$this->exercise->members_obj->isAssigned($a_user_id)) {
77  $this->exercise->members_obj->assignMember($a_user_id);
78  }
79 
80  // public submissions ???
81  $public_submissions = false;
82  if ($this->exercise->getShowSubmissions() &&
83  $this->exercise->getTimestamp() - time() <= 0) { // ???
84  $public_submissions = true;
85  }
86  $this->submission = new ilExSubmission($a_ass, $a_user_id, null, false, $public_submissions);
87 
88  // :TODO:
89  $this->ctrl = $ilCtrl;
90  $this->tabs_gui = $ilTabs;
91  $this->lng = $lng;
92  $this->tpl = $tpl;
93  $this->request = $DIC->exercise()->internal()->gui()->request();
94  $this->domain = $DIC->exercise()->internal()->domain();
95  }
96 
100  public function executeCommand(): void
101  {
102  $ilCtrl = $this->ctrl;
103 
104  $class = $ilCtrl->getNextClass($this);
105  $cmd = $ilCtrl->getCmd("listPublicSubmissions");
106 
107  switch ($class) {
108  case "ilexsubmissionteamgui":
109  // team gui has no base gui - see we have to handle tabs here
110 
111  $this->tabs_gui->clearTargets();
112  $this->tabs_gui->setBackTarget(
113  $this->lng->txt("back"),
114  $this->ctrl->getLinkTarget($this, "returnToParent")
115  );
116 
117  // forward to type gui
118  if ($this->submission->getSubmissionType() != ilExSubmission::TYPE_REPO_OBJECT) {
119  $this->tabs_gui->addTab(
120  "submission",
121  $this->lng->txt("exc_submission"),
122  $this->ctrl->getLinkTargetByClass("ilexsubmission" . $this->submission->getSubmissionType() . "gui", "")
123  );
124  }
125 
126  $gui = $this->gui->getTeamSubmissionGUI($this->exercise, $this->submission);
127  $ilCtrl->forwardCommand($gui);
128  break;
129 
130  case "ilexsubmissiontextgui":
131  $gui = new ilExSubmissionTextGUI($this->exercise, $this->submission);
132  $ilCtrl->forwardCommand($gui);
133  break;
134 
135  case "ilexsubmissionfilegui":
136  $gui = new ilExSubmissionFileGUI($this->exercise, $this->submission);
137  $ilCtrl->forwardCommand($gui);
138  break;
139 
140  case "ilexsubmissionobjectgui":
141  $gui = new ilExSubmissionObjectGUI($this->exercise, $this->submission);
142  $ilCtrl->forwardCommand($gui);
143  break;
144 
145  case "ilexpeerreviewgui":
146  /*
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  $ilCtrl->forwardCommand($type_gui);
166  }
167 
168  $this->{$cmd . "Object"}();
169  break;
170  }
171  }
172 
173  public static function getOverviewContent(
174  ilInfoScreenGUI $a_info,
175  ilExSubmission $a_submission,
176  ilObjExercise $a_exc
177  ): void {
178  global $DIC;
179  $ilCtrl = $DIC->ctrl();
180 
181  if (!$a_submission->canView()) {
182  return;
183  }
184 
185  $ilCtrl->setParameterByClass("ilExSubmissionGUI", "ass_id", $a_submission->getAssignment()->getId());
186 
187  if ($a_submission->getAssignment()->hasTeam()) {
188  ilExSubmissionTeamGUI::getOverviewContent($a_info, $a_submission);
189  }
190 
191  $submission_type = $a_submission->getSubmissionType();
192  // old handling -> forward to submission type gui class
193  // @todo migrate everything to new concept
194  if ($submission_type != ilExSubmission::TYPE_REPO_OBJECT) {
195  $class = "ilExSubmission" . $submission_type . "GUI";
197  $class::getOverviewContent($a_info, $a_submission);
198  } else { // new: get HTML from assignemt type gui class
199  $sub_gui = new ilExSubmissionGUI($a_exc, $a_submission->getAssignment());
200  $ilCtrl->getHTML($sub_gui, array(
201  "mode" => self::MODE_OVERVIEW_CONTENT,
202  "info" => $a_info,
203  "submission" => $a_submission
204  ));
205  }
206 
207  $ilCtrl->setParameterByClass("ilExSubmissionGUI", "ass_id", "");
208  }
209 
213  public function getHTML(array $par): string
214  {
215  switch ($par["mode"]) {
216  // get overview content from ass type gui
217  case self::MODE_OVERVIEW_CONTENT:
218  $type_gui = $this->type_guis->getById($par["submission"]->getAssignment()->getType());
219  $type_gui->getOverviewContent($par["info"], $par["submission"]);
220  break;
221  }
222  return "";
223  }
224 
225  public function listPublicSubmissionsObject(): void
226  {
227  $ilTabs = $this->tabs_gui;
228  $ilCtrl = $this->ctrl;
229  $lng = $this->lng;
230 
231  if (!$this->exercise->getShowSubmissions()) {
232  $this->returnToParentObject();
233  }
234 
235  $ilTabs->clearTargets();
236  $ilTabs->setBackTarget(
237  $lng->txt("back"),
238  $ilCtrl->getLinkTarget($this, "returnToParent")
239  );
240 
241  if ($this->assignment->getType() != ilExAssignment::TYPE_TEXT) {
242  $tab = new ilPublicSubmissionsTableGUI($this, "listPublicSubmissions", $this->assignment);
243  $this->tpl->setContent($tab->getHTML());
244  } else {
245  // #13271
246  $tbl = new ilExAssignmentListTextTableGUI($this, "listPublicSubmissions", $this->assignment, false, true);
247  $this->tpl->setContent($tbl->getHTML());
248  }
249  }
250 
254  public function downloadFeedbackFileObject(): bool
255  {
256  $file = $this->request->getFile();
257 
258  if (!isset($file)) {
259  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("exc_select_one_file"), true);
260  $this->ctrl->redirect($this, "view");
261  }
262 
263  $this->domain->assignment()->tutorFeedbackFile($this->assignment->getId())
264  ->deliver($this->user_id, $file);
265  return true;
266  }
267 
268  public function downloadGlobalFeedbackFileObject(): void
269  {
270  $ilCtrl = $this->ctrl;
271 
272  $state = ilExcAssMemberState::getInstanceByIds($this->assignment->getId(), $this->user_id);
273 
274  // fix bug 28466, this code should be streamlined with the if above and
275  // the presentation of the download link in the ilExAssignmentGUI->addSubmission
276  if (!$state->isGlobalFeedbackFileAccessible($this->submission)) {
277  $ilCtrl->redirect($this, "returnToParent");
278  }
279 
280  $this->domain->assignment()->sampleSolution($this->assignment->getId())->deliver();
281  }
282 
283  public function downloadFileObject(): bool
284  {
285  $file = $this->request->getFile();
286 
287  if (!isset($file)) {
288  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("exc_select_one_file"), true);
289  $this->ctrl->redirect($this, "view");
290  }
291 
292  // check whether assignment as already started
293  $state = ilExcAssMemberState::getInstanceByIds($this->assignment->getId(), $this->user_id);
294  if ($state->areInstructionsVisible()) {
295  // check, whether file belongs to assignment
296  $files = $this->assignment->getFiles();
297  $file_exist = false;
298  foreach ($files as $lfile) {
299  if ($lfile["name"] == $file) {
300  $this->domain->assignment()->instructionFiles($this->assignment->getId())->deliver($lfile["fullpath"], $file);
301  }
302  }
303  if (!$file_exist) {
304  return false;
305  }
306  }
307 
308  return true;
309  }
310 
311  public function returnToParentObject(): void
312  {
313  $this->ctrl->returnToParent($this);
314  }
315 }
Exercise assignment.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
downloadFeedbackFileObject()
Download feedback file.
ILIAS Exercise InternalDomainService $domain
ilExAssignmentTypesGUI $type_guis
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
Class ilObjExercise.
getNextClass($a_gui_class=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:22
static getInstanceByIds(int $a_ass_id, int $a_user_id=0)
__construct(ilObjExercise $a_exercise, ilExAssignment $a_ass, ?int $a_user_id=null)
static getOverviewContent(ilInfoScreenGUI $a_info, ilExSubmission $a_submission)
ilGlobalTemplateInterface $tpl
Exercise submission //TODO: This class has many static methods related to delivered "files"...
ILIAS Exercise InternalGUIService $gui
Exercise gui request wrapper.
$service
Definition: ltiservices.php:40
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Object-based submissions (ends up as static file)
Class ilExSubmissionGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...