ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilPortfolioExerciseGUI Class Reference

Class ilPortfolioExerciseGUI. More...

+ Collaboration diagram for ilPortfolioExerciseGUI:

Public Member Functions

 __construct (int $a_user_id, int $a_obj_id)
 
 executeCommand ()
 
 downloadExcAssFile ()
 
 downloadExcSubFile ()
 
 getSubmitButton (int $ass_id)
 Get submit link. More...
 
 getDownloadSubmissionButton (int $ass_id)
 
 getActionButtons ()
 Get action buttons. More...
 

Static Public Member Functions

static checkExercise (int $a_user_id, int $a_obj_id, bool $a_add_submit=false, bool $as_array=false)
 

Protected Member Functions

 finalize ()
 Finalize and submit portfolio to exercise. More...
 

Static Protected Member Functions

static getExerciseInfo (int $a_user_id, int $a_assignment_id, bool $a_add_submit=false, bool $as_array=false)
 

Protected Attributes

StandardGUIRequest $port_request
 
ilCtrl $ctrl
 
ilLanguage $lng
 
int $user_id
 
int $obj_id
 
int $ass_id
 
string $file
 
ilPortfolioExercise $pe
 
ILIAS DI UIServices $ui
 

Private Attributes

ilGlobalTemplateInterface $main_tpl
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilPortfolioExerciseGUI::__construct ( int  $a_user_id,
int  $a_obj_id 
)

Definition at line 40 of file class.ilPortfolioExerciseGUI.php.

References $DIC, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\ui().

43  {
44  global $DIC;
45  $this->main_tpl = $DIC->ui()->mainTemplate();
46 
47  $this->ctrl = $DIC->ctrl();
48  $this->lng = $DIC->language();
49  $this->user_id = $a_user_id;
50  $this->obj_id = $a_obj_id;
51 
52  $this->port_request = $DIC->portfolio()
53  ->internal()
54  ->gui()
55  ->standardRequest();
56 
57  $this->ass_id = $this->port_request->getExcAssId();
58  $this->file = $this->port_request->getExcFile();
59  $this->ui = $DIC->ui();
60  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ checkExercise()

static ilPortfolioExerciseGUI::checkExercise ( int  $a_user_id,
int  $a_obj_id,
bool  $a_add_submit = false,
bool  $as_array = false 
)
static
Todo:
get rid of mixed return type
Returns
array|string|void

Definition at line 85 of file class.ilPortfolioExerciseGUI.php.

References $exercise, and ilPortfolioExercise\getAssignmentsOfPortfolio().

Referenced by ilPortfolioRepositoryGUI\getPortfolioList().

90  {
91  $pe = new ilPortfolioExercise($a_user_id, $a_obj_id);
92 
93  $info = [];
94  foreach ($pe->getAssignmentsOfPortfolio() as $exercise) {
95  $part = self::getExerciseInfo($a_user_id, $exercise["ass_id"], $a_add_submit, $as_array);
96  if ($part) {
97  $info[] = $part;
98  }
99  }
100  if (count($info) && !$as_array) {
101  return implode("<br />", $info);
102  }
103 
104  if ($as_array) {
105  return $info;
106  }
107  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ downloadExcAssFile()

ilPortfolioExerciseGUI::downloadExcAssFile ( )

Definition at line 246 of file class.ilPortfolioExerciseGUI.php.

References ilFileDelivery\deliverFileLegacy().

246  : void
247  {
248  if ($this->file) {
249  $ass = new ilExAssignment($this->ass_id);
250  $ass_files = $ass->getFiles();
251  if (count($ass_files) > 0) {
252  foreach ($ass_files as $file) {
253  if ($file["name"] == $this->file) {
254  ilFileDelivery::deliverFileLegacy($file["fullpath"], $file["name"]);
255  }
256  }
257  }
258  }
259  }
Exercise assignment.
static deliverFileLegacy(string $a_file, ?string $a_filename=null, ?string $a_mime=null, ?bool $isInline=false, ?bool $removeAfterDelivery=false, ?bool $a_exit_after=true)
+ Here is the call graph for this function:

◆ downloadExcSubFile()

ilPortfolioExerciseGUI::downloadExcSubFile ( )

Definition at line 261 of file class.ilPortfolioExerciseGUI.php.

References ilObjUser\_lookupName(), ilObject\_lookupTitle(), and ilFileDelivery\deliverFileLegacy().

261  : void
262  {
263  $ass = new ilExAssignment($this->ass_id);
264  $submission = new ilExSubmission($ass, $this->user_id);
265  $submitted = $submission->getFiles();
266  if (count($submitted) > 0) {
267  $submitted = array_pop($submitted);
268 
269  $user_data = ilObjUser::_lookupName($submitted["user_id"]);
270  $title = ilObject::_lookupTitle($submitted["obj_id"]) . " - " .
271  $ass->getTitle() . " - " .
272  $user_data["firstname"] . " " .
273  $user_data["lastname"] . " (" .
274  $user_data["login"] . ").zip";
275 
276  ilFileDelivery::deliverFileLegacy($submitted["filename"], $title);
277  }
278  }
Exercise assignment.
static _lookupName(int $a_user_id)
lookup user name
static deliverFileLegacy(string $a_file, ?string $a_filename=null, ?string $a_mime=null, ?bool $isInline=false, ?bool $removeAfterDelivery=false, ?bool $a_exit_after=true)
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ executeCommand()

ilPortfolioExerciseGUI::executeCommand ( )

Definition at line 62 of file class.ilPortfolioExerciseGUI.php.

References $ctrl, and ILIAS\Repository\ctrl().

62  : void
63  {
64  $ilCtrl = $this->ctrl;
65 
66  if (!$this->ass_id ||
67  !$this->user_id) {
68  $this->ctrl->returnToParent($this);
69  }
70 
71  $next_class = $ilCtrl->getNextClass($this);
72  $cmd = $ilCtrl->getCmd();
73 
74  switch ($next_class) {
75  default:
76  $this->$cmd();
77  break;
78  }
79  }
+ Here is the call graph for this function:

◆ finalize()

ilPortfolioExerciseGUI::finalize ( )
protected

Finalize and submit portfolio to exercise.

Definition at line 283 of file class.ilPortfolioExerciseGUI.php.

References $ctrl, $lng, ilExSubmissionObjectGUI\initGUIForSubmit(), and ilLanguage\txt().

283  : void
284  {
285  $lng = $this->lng;
286  $ilCtrl = $this->ctrl;
287 
288  $exc_gui = ilExSubmissionObjectGUI::initGUIForSubmit($this->ass_id);
289  $exc_gui->submitPortfolio($this->obj_id);
290 
291  $this->main_tpl->setOnScreenMessage('success', $lng->txt("prtf_finalized"), true);
292  $ilCtrl->returnToParent($this);
293  }
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...
static initGUIForSubmit(int $a_ass_id, int $a_user_id=null)
+ Here is the call graph for this function:

◆ getActionButtons()

ilPortfolioExerciseGUI::getActionButtons ( )

Get action buttons.

Definition at line 345 of file class.ilPortfolioExerciseGUI.php.

References $ass_id, $exercise, ilPortfolioExercise\getAssignmentsOfPortfolio(), getDownloadSubmissionButton(), and getSubmitButton().

345  : array
346  {
347  $pe = new ilPortfolioExercise($this->user_id, $this->obj_id);
348 
349  $buttons = [];
350  foreach ($pe->getAssignmentsOfPortfolio() as $exercise) {
351  $ass_id = $exercise["ass_id"];
352  $buttons[$ass_id] = [];
353  $submit_button = $this->getSubmitButton($ass_id);
354  if ($submit_button) {
355  $buttons[$ass_id][] = $submit_button;
356  }
357  $download_button = $this->getDownloadSubmissionButton($ass_id);
358  if ($download_button) {
359  $buttons[$ass_id][] = $download_button;
360  }
361  }
362 
363  return $buttons;
364  }
getSubmitButton(int $ass_id)
Get submit link.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ getDownloadSubmissionButton()

ilPortfolioExerciseGUI::getDownloadSubmissionButton ( int  $ass_id)

Definition at line 318 of file class.ilPortfolioExerciseGUI.php.

References $ctrl, $lng, $ui, and ilLanguage\txt().

Referenced by getActionButtons().

321  $ilCtrl = $this->ctrl;
322  $lng = $this->lng;
323  $ui = $this->ui;
324 
325  // submitted files
326  $submission = new ilExSubmission(new ilExAssignment($ass_id), $this->user_id);
327  if ($submission->hasSubmitted()) {
328  // #16888
329  $submitted = $submission->getSelectedObject();
330  if ($submitted["ts"] != "") {
331  $ilCtrl->setParameterByClass("ilportfolioexercisegui", "ass", $ass_id);
332  $dl_link = $ilCtrl->getLinkTargetByClass("ilportfolioexercisegui", "downloadExcSubFile");
333  $ilCtrl->setParameterByClass("ilportfolioexercisegui", "ass", "");
334  $button = $ui->factory()->button()->standard($lng->txt("prtf_download_submission"), $dl_link);
335  return $button;
336  }
337  }
338  return null;
339  }
Exercise assignment.
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...
This describes a standard button.
Definition: Standard.php:26
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getExerciseInfo()

static ilPortfolioExerciseGUI::getExerciseInfo ( int  $a_user_id,
int  $a_assignment_id,
bool  $a_add_submit = false,
bool  $as_array = false 
)
staticprotected
Deprecated:
Returns
string|array
Exceptions
ilCtrlException
ilDateTimeException
ilExcUnknownAssignmentTypeException

Definition at line 116 of file class.ilPortfolioExerciseGUI.php.

References $DIC, ilObject\_getAllReferences(), ilLink\_getStaticLink(), ilObject\_lookupTitle(), ilDatePresentation\formatDate(), IL_CAL_DATETIME, ilDatePresentation\setUseRelativeDates(), ilLanguage\txt(), and ilDatePresentation\useRelativeDates().

121  {
122  global $DIC;
123 
124  $ui = $DIC->ui();
125 
126  $links = [];
127  $buttons = [];
128  $elements = [];
129 
130  $lng = $DIC->language();
131  $ilCtrl = $DIC->ctrl();
132  $rel = false;
133 
134  $ass = new ilExAssignment($a_assignment_id);
135  $exercise_id = $ass->getExerciseId();
136  if (!$exercise_id) {
137  return "";
138  }
139 
140  // is the assignment still open?
141  $times_up = $ass->afterDeadlineStrict();
142 
143  // exercise goto
144  $ref_ids = ilObject::_getAllReferences($exercise_id);
145  $exc_ref_id = array_shift($ref_ids);
146  $exc_link = ilLink::_getStaticLink($exc_ref_id, "exc");
147 
148  $info_arr["ass_title"] = $ass->getTitle();
149  $text = sprintf(
150  $lng->txt("prtf_exercise_info"),
151  $ass->getTitle(),
152  ilObject::_lookupTitle($exercise_id)
153  );
154  $links[] = $ui->factory()->link()->standard(ilObject::_lookupTitle($exercise_id), $exc_link);
155  $info_arr["exc_title"] = ilObject::_lookupTitle($exercise_id);
156 
157  // submit button
158  if ($a_add_submit && !$times_up && !$as_array) {
159  $ilCtrl->setParameterByClass("ilportfolioexercisegui", "ass", $a_assignment_id);
160  $submit_link = $ilCtrl->getLinkTargetByClass("ilportfolioexercisegui", "finalize");
161  $ilCtrl->setParameterByClass("ilportfolioexercisegui", "ass", "");
162 
163  $buttons[] = $ui->factory()->button()->primary($lng->txt("prtf_finalize_portfolio"), $submit_link);
164  }
165 
166  // submitted files
167  $submission = new ilExSubmission($ass, $a_user_id);
168  $info_arr["submitted"] = false;
169  if ($submission->hasSubmitted()) {
170  // #16888
171  $submitted = $submission->getSelectedObject();
172 
173  if (!$as_array) {
174  $ilCtrl->setParameterByClass("ilportfolioexercisegui", "ass", $a_assignment_id);
175  $dl_link = $ilCtrl->getLinkTargetByClass("ilportfolioexercisegui", "downloadExcSubFile");
176  $ilCtrl->setParameterByClass("ilportfolioexercisegui", "ass", "");
177 
180 
181  $text .= "<p>" . sprintf(
182  $lng->txt("prtf_exercise_submitted_info"),
184  ""
185  ) . "</p>";
186  $buttons[] = $ui->factory()->button()->standard($lng->txt("prtf_download_submission"), $dl_link);
187  }
188 
190  $info_arr["submitted_date"] = ilDatePresentation::formatDate(new ilDateTime($submitted["ts"], IL_CAL_DATETIME));
191  $info_arr["submitted"] = true;
192  if ($submitted["ts"] == "") {
193  $info_arr["submitted"] = false;
194  }
195  }
196 
197  // work instructions incl. files
198 
199  $tooltip = "";
200 
201  $inst = $ass->getInstruction();
202  if ($inst) {
203  $tooltip .= nl2br($inst);
204  }
205 
206  $ass_files = $ass->getFiles();
207  if (!$as_array && count($ass_files) > 0) {
208  if ($tooltip) {
209  $tooltip .= "<br /><br />";
210  }
211 
212  $items = [];
213 
214  foreach ($ass_files as $file) {
215  $ilCtrl->setParameterByClass("ilportfolioexercisegui", "ass", $a_assignment_id);
216  $ilCtrl->setParameterByClass("ilportfolioexercisegui", "file", urlencode($file["name"]));
217  $dl_link = $ilCtrl->getLinkTargetByClass("ilportfolioexercisegui", "downloadExcAssFile");
218  $ilCtrl->setParameterByClass("ilportfolioexercisegui", "file", "");
219  $ilCtrl->setParameterByClass("ilportfolioexercisegui", "ass", "");
220 
221  $items[] = $ui->renderer()->render($ui->factory()->button()->shy($file["name"], $dl_link));
222  }
223  $list = $ui->factory()->listing()->unordered($items);
224  $tooltip .= $ui->renderer()->render($list);
225  }
226 
227  if ($tooltip) {
228  $modal = $ui->factory()->modal()->roundtrip($lng->txt("exc_instruction"), $ui->factory()->legacy($tooltip))
229  ->withCancelButtonLabel("close");
230  $elements[] = $modal;
231  $buttons[] = $ui->factory()->button()->standard($lng->txt("exc_instruction"), '#')
232  ->withOnClick($modal->getShowSignal());
233  }
234 
235  if ($as_array) {
236  return $info_arr;
237  }
238 
239  $elements[] = $ui->factory()->messageBox()->info($text)
240  ->withLinks($links)
241  ->withButtons($buttons);
242 
243  return $ui->renderer()->render($elements);
244  }
Exercise assignment.
const IL_CAL_DATETIME
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...
static _getAllReferences(int $id)
get all reference ids for object ID
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
global $DIC
Definition: feed.php:28
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static setUseRelativeDates(bool $a_status)
set use relative dates
+ Here is the call graph for this function:

◆ getSubmitButton()

ilPortfolioExerciseGUI::getSubmitButton ( int  $ass_id)

Get submit link.

Exceptions
ilCtrlException

Definition at line 299 of file class.ilPortfolioExerciseGUI.php.

References $ctrl, $lng, $ui, ilExcAssMemberState\getInstanceByIds(), and ilLanguage\txt().

Referenced by getActionButtons().

302  $ilCtrl = $this->ctrl;
303  $ui = $this->ui;
304  $lng = $this->lng;
305 
306  $state = ilExcAssMemberState::getInstanceByIds($ass_id, $this->user_id);
307 
308  if ($state->isSubmissionAllowed()) {
309  $ilCtrl->setParameterByClass("ilportfolioexercisegui", "ass", $ass_id);
310  $submit_link = $ilCtrl->getLinkTargetByClass("ilportfolioexercisegui", "finalize");
311  $ilCtrl->setParameterByClass("ilportfolioexercisegui", "ass", "");
312  $button = $ui->factory()->button()->primary($lng->txt("prtf_finalize_portfolio"), $submit_link);
313  return $button;
314  }
315  return null;
316  }
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...
This describes a standard button.
Definition: Primary.php:26
static getInstanceByIds(int $a_ass_id, int $a_user_id=0)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ass_id

int ilPortfolioExerciseGUI::$ass_id
protected

Definition at line 34 of file class.ilPortfolioExerciseGUI.php.

Referenced by getActionButtons().

◆ $ctrl

ilCtrl ilPortfolioExerciseGUI::$ctrl
protected

◆ $file

string ilPortfolioExerciseGUI::$file
protected

Definition at line 35 of file class.ilPortfolioExerciseGUI.php.

◆ $lng

ilLanguage ilPortfolioExerciseGUI::$lng
protected

◆ $main_tpl

ilGlobalTemplateInterface ilPortfolioExerciseGUI::$main_tpl
private

Definition at line 38 of file class.ilPortfolioExerciseGUI.php.

◆ $obj_id

int ilPortfolioExerciseGUI::$obj_id
protected

Definition at line 33 of file class.ilPortfolioExerciseGUI.php.

◆ $pe

ilPortfolioExercise ilPortfolioExerciseGUI::$pe
protected

Definition at line 36 of file class.ilPortfolioExerciseGUI.php.

◆ $port_request

StandardGUIRequest ilPortfolioExerciseGUI::$port_request
protected

Definition at line 29 of file class.ilPortfolioExerciseGUI.php.

◆ $ui

ILIAS DI UIServices ilPortfolioExerciseGUI::$ui
protected

◆ $user_id

int ilPortfolioExerciseGUI::$user_id
protected

Definition at line 32 of file class.ilPortfolioExerciseGUI.php.


The documentation for this class was generated from the following file: