ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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

ILIAS Exercise InternalDomainService $exc_domain
 
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 41 of file class.ilPortfolioExerciseGUI.php.

44 {
45 global $DIC;
46 $this->main_tpl = $DIC->ui()->mainTemplate();
47
48 $this->ctrl = $DIC->ctrl();
49 $this->lng = $DIC->language();
50 $this->user_id = $a_user_id;
51 $this->obj_id = $a_obj_id;
52
53 $this->port_request = $DIC->portfolio()
54 ->internal()
55 ->gui()
56 ->standardRequest();
57
58 $this->ass_id = $this->port_request->getExcAssId();
59 $this->file = $this->port_request->getExcFile();
60 $this->ui = $DIC->ui();
61 $this->exc_domain = $DIC->exercise()->internal()->domain();
62 }
global $DIC
Definition: shib_login.php:26

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

+ 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 87 of file class.ilPortfolioExerciseGUI.php.

92 {
93 $pe = new ilPortfolioExercise($a_user_id, $a_obj_id);
94
95 $info = [];
97 $part = self::getExerciseInfo($a_user_id, $exercise["ass_id"], $a_add_submit, $as_array);
98 if ($part) {
99 $info[] = $part;
100 }
101 }
102 if (count($info) && !$as_array) {
103 return implode("<br />", $info);
104 }
105
106 if ($as_array) {
107 return $info;
108 }
109 }
static getExerciseInfo(int $a_user_id, int $a_assignment_id, bool $a_add_submit=false, bool $as_array=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$info
Definition: entry_point.php:21

References $exercise, $info, $pe, ilPortfolioExercise\getAssignmentsOfPortfolio(), and getExerciseInfo().

Referenced by ilPortfolioRepositoryGUI\getPortfolioList().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ downloadExcAssFile()

ilPortfolioExerciseGUI::downloadExcAssFile ( )

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

248 : void
249 {
250 if ($this->file) {
251 $ass = new ilExAssignment($this->ass_id);
252 $ass_files = $ass->getFiles();
253 if (count($ass_files) > 0) {
254 foreach ($ass_files as $file) {
255 if ($file["name"] == $this->file) {
256 ilFileDelivery::deliverFileLegacy($file["fullpath"], $file["name"]);
257 }
258 }
259 }
260 }
261 }
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)

References $file, and ilFileDelivery\deliverFileLegacy().

+ Here is the call graph for this function:

◆ downloadExcSubFile()

ilPortfolioExerciseGUI::downloadExcSubFile ( )

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

263 : void
264 {
265 $ass = new ilExAssignment($this->ass_id);
266 $sub_manager = $this->exc_domain->submission($this->ass_id);
267 $sub = $sub_manager->getSubmissionsOfUser($this->user_id)->current();
268 if ($sub) {
269 $user_data = ilObjUser::_lookupName($this->user_id);
270 $title = ilObject::_lookupTitle($ass->getExerciseId()) . " - " .
271 $ass->getTitle() . " - " .
272 $user_data["firstname"] . " " .
273 $user_data["lastname"] . " (" .
274 $user_data["login"] . ").zip";
275
276 $sub_manager->deliverFile(
277 $this->user_id,
278 $sub->getRid(),
279 $title
280 );
281 }
282 }
static _lookupName(int $a_user_id)
static _lookupTitle(int $obj_id)

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

+ Here is the call graph for this function:

◆ executeCommand()

ilPortfolioExerciseGUI::executeCommand ( )

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

64 : void
65 {
66 $ilCtrl = $this->ctrl;
67
68 if (!$this->ass_id ||
69 !$this->user_id) {
70 $this->ctrl->returnToParent($this);
71 }
72
73 $next_class = $ilCtrl->getNextClass($this);
74 $cmd = $ilCtrl->getCmd();
75
76 switch ($next_class) {
77 default:
78 $this->$cmd();
79 break;
80 }
81 }

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

+ Here is the call graph for this function:

◆ finalize()

ilPortfolioExerciseGUI::finalize ( )
protected

Finalize and submit portfolio to exercise.

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

287 : void
288 {
290 $ilCtrl = $this->ctrl;
291
292 $exc_gui = ilExSubmissionObjectGUI::initGUIForSubmit($this->ass_id);
293 $exc_gui->submitPortfolio($this->obj_id);
294
295 $this->main_tpl->setOnScreenMessage('success', $lng->txt("prtf_finalized"), true);
296 $ilCtrl->returnToParent($this);
297 }
static initGUIForSubmit(int $a_ass_id, ?int $a_user_id=null)
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...

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

+ Here is the call graph for this function:

◆ getActionButtons()

ilPortfolioExerciseGUI::getActionButtons ( )

Get action buttons.

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

349 : array
350 {
351 $pe = new ilPortfolioExercise($this->user_id, $this->obj_id);
352
353 $buttons = [];
354 $pages = ilPortfolioPage::getAllPortfolioPages($this->obj_id);
355 foreach ($pe->getAssignmentsOfPortfolio() as $exercise) {
356 $ass_id = $exercise["ass_id"];
357 $buttons[$ass_id] = [];
358 if (count($pages) > 0) {
359 $submit_button = $this->getSubmitButton($ass_id);
360 if ($submit_button) {
361 $buttons[$ass_id][] = $submit_button;
362 }
363 }
364 $download_button = $this->getDownloadSubmissionButton($ass_id);
365 if ($download_button) {
366 $buttons[$ass_id][] = $download_button;
367 }
368 }
369
370 return $buttons;
371 }
getSubmitButton(int $ass_id)
Get submit link.
static getAllPortfolioPages(int $a_portfolio_id)
Get pages of portfolio.

References $ass_id, $exercise, ilPortfolioPage\getAllPortfolioPages(), and ilPortfolioExercise\getAssignmentsOfPortfolio().

+ Here is the call graph for this function:

◆ getDownloadSubmissionButton()

ilPortfolioExerciseGUI::getDownloadSubmissionButton ( int  $ass_id)

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

325 $ilCtrl = $this->ctrl;
327 $ui = $this->ui;
328
329 // submitted files
330 $submission = new ilExSubmission(new ilExAssignment($ass_id), $this->user_id);
331 if ($submission->hasSubmitted()) {
332 // #16888
333 $submitted = $submission->getSelectedObject();
334 if ($submitted?->getTimestamp() != "") {
335 $ilCtrl->setParameterByClass("ilportfolioexercisegui", "ass", $ass_id);
336 $dl_link = $ilCtrl->getLinkTargetByClass("ilportfolioexercisegui", "downloadExcSubFile");
337 $ilCtrl->setParameterByClass("ilportfolioexercisegui", "ass", "");
338 $button = $ui->factory()->button()->standard($lng->txt("prtf_download_submission"), $dl_link);
339 return $button;
340 }
341 }
342 return null;
343 }
Exercise submission //TODO: This class has many static methods related to delivered "files".
This describes a standard button.
Definition: Standard.php:27

◆ 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 118 of file class.ilPortfolioExerciseGUI.php.

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

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

Referenced by checkExercise().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSubmitButton()

ilPortfolioExerciseGUI::getSubmitButton ( int  $ass_id)

Get submit link.

Exceptions
ilCtrlException

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

306 $ilCtrl = $this->ctrl;
307 $ui = $this->ui;
309
310 $state = ilExcAssMemberState::getInstanceByIds($ass_id, $this->user_id);
311
312 if ($state->isSubmissionAllowed()) {
313 $ilCtrl->setParameterByClass("ilportfolioexercisegui", "ass", $ass_id);
314 $submit_link = $ilCtrl->getLinkTargetByClass("ilportfolioexercisegui", "finalize");
315 $ilCtrl->setParameterByClass("ilportfolioexercisegui", "ass", "");
316 $button = $ui->factory()->button()->primary($lng->txt("prtf_finalize_portfolio"), $submit_link);
317 return $button;
318 }
319 return null;
320 }
static getInstanceByIds(int $a_ass_id, int $a_user_id=0)
This describes a standard button.
Definition: Primary.php:27

Field Documentation

◆ $ass_id

int ilPortfolioExerciseGUI::$ass_id
protected

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

◆ $ctrl

ilCtrl ilPortfolioExerciseGUI::$ctrl
protected

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

Referenced by executeCommand(), and finalize().

◆ $exc_domain

ILIAS Exercise InternalDomainService ilPortfolioExerciseGUI::$exc_domain
protected

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

◆ $file

string ilPortfolioExerciseGUI::$file
protected

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

Referenced by downloadExcAssFile(), and getExerciseInfo().

◆ $lng

ilLanguage ilPortfolioExerciseGUI::$lng
protected

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

Referenced by finalize(), and getExerciseInfo().

◆ $main_tpl

ilGlobalTemplateInterface ilPortfolioExerciseGUI::$main_tpl
private

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

◆ $obj_id

int ilPortfolioExerciseGUI::$obj_id
protected

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

◆ $pe

ilPortfolioExercise ilPortfolioExerciseGUI::$pe
protected

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

Referenced by checkExercise().

◆ $port_request

StandardGUIRequest ilPortfolioExerciseGUI::$port_request
protected

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

◆ $ui

ILIAS DI UIServices ilPortfolioExerciseGUI::$ui
protected

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

Referenced by getExerciseInfo().

◆ $user_id

int ilPortfolioExerciseGUI::$user_id
protected

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


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