ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilPortfolioExerciseGUI Class Reference

Class ilPortfolioExerciseGUI. More...

+ Collaboration diagram for ilPortfolioExerciseGUI:

Public Member Functions

 __construct ($a_user_id, $a_obj_id)
 
 executeCommand ()
 
 downloadExcAssFile ()
 
 downloadExcSubFile ()
 

Static Public Member Functions

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

Protected Member Functions

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

Static Protected Member Functions

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

Protected Attributes

 $ctrl
 
 $lng
 
 $user_id
 
 $obj_id
 
 $ass_id
 
 $file
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilPortfolioExerciseGUI::__construct (   $a_user_id,
  $a_obj_id 
)

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

References $_GET, and $DIC.

34  {
35  global $DIC;
36 
37  $this->ctrl = $DIC->ctrl();
38  $this->lng = $DIC->language();
39  $this->user_id = $a_user_id;
40  $this->obj_id = $a_obj_id;
41  $this->ass_id = (int) $_GET["ass"];
42  $this->file = trim($_GET["file"]);
43  }
global $DIC
Definition: saml.php:7
$_GET["client_id"]

Member Function Documentation

◆ checkExercise()

static ilPortfolioExerciseGUI::checkExercise (   $a_user_id,
  $a_obj_id,
  $a_add_submit = false,
  $as_array = false 
)
static

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

References $DIC, $exercise, $info, $tree, ilObject\_getAllReferences(), and ilExSubmission\findUserFiles().

Referenced by ilPortfolioRepositoryGUI\getPortfolioList(), and ilObjPortfolioBaseGUI\view().

67  {
68  global $DIC;
69 
70  $tree = $DIC->repositoryTree();
71 
72  $info = array();
73 
74  $exercises = ilExSubmission::findUserFiles($a_user_id, $a_obj_id);
75  // #0022794
76  if (!$exercises) {
77  $exercises = ilExSubmission::findUserFiles($a_user_id, $a_obj_id . ".sec");
78  }
79  if ($exercises) {
80  foreach ($exercises as $exercise) {
81  // #9988
82  $active_ref = false;
83  foreach (ilObject::_getAllReferences($exercise["obj_id"]) as $ref_id) {
84  if (!$tree->isSaved($ref_id)) {
85  $active_ref = true;
86  break;
87  }
88  }
89  if ($active_ref) {
90  $part = self::getExerciseInfo($a_user_id, $exercise["ass_id"], $a_add_submit, $as_array);
91  if ($part) {
92  $info[] = $part;
93  }
94  }
95  }
96  if (sizeof($info) && !$as_array) {
97  return implode("<br />", $info);
98  }
99  }
100  if ($as_array) {
101  return $info;
102  }
103  }
global $DIC
Definition: saml.php:7
static _getAllReferences($a_id)
get all reference ids of object
static findUserFiles($a_user_id, $a_filetitle)
Check if given file was assigned.
$info
Definition: index.php:5
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ downloadExcAssFile()

ilPortfolioExerciseGUI::downloadExcAssFile ( )

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

References $file, and ilUtil\deliverFile().

235  {
236  if ($this->file) {
237  include_once "Modules/Exercise/classes/class.ilExAssignment.php";
238  $ass = new ilExAssignment($this->ass_id);
239  $ass_files = $ass->getFiles();
240  if (count($ass_files) > 0) {
241  foreach ($ass_files as $file) {
242  if ($file["name"] == $this->file) {
243  ilUtil::deliverFile($file["fullpath"], $file["name"]);
244  }
245  }
246  }
247  }
248  }
Exercise assignment.
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
+ Here is the call graph for this function:

◆ downloadExcSubFile()

ilPortfolioExerciseGUI::downloadExcSubFile ( )

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

References $title, ilObjUser\_lookupName(), ilObject\_lookupTitle(), and ilUtil\deliverFile().

251  {
252  $ass = new ilExAssignment($this->ass_id);
253  $submission = new ilExSubmission($ass, $this->user_id);
254  $submitted = $submission->getFiles();
255  if (count($submitted) > 0) {
256  $submitted = array_pop($submitted);
257 
258  $user_data = ilObjUser::_lookupName($submitted["user_id"]);
259  $title = ilObject::_lookupTitle($submitted["obj_id"]) . " - " .
260  $ass->getTitle() . " - " .
261  $user_data["firstname"] . " " .
262  $user_data["lastname"] . " (" .
263  $user_data["login"] . ").zip";
264 
265  ilUtil::deliverFile($submitted["filename"], $title);
266  }
267  }
static _lookupName($a_user_id)
lookup user name
Exercise assignment.
static _lookupTitle($a_id)
lookup object title
Exercise submission //TODO: This class has to much static methods related to delivered "files"...
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
+ Here is the call graph for this function:

◆ executeCommand()

ilPortfolioExerciseGUI::executeCommand ( )

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

References $ctrl, and $ilCtrl.

46  {
48 
49  if (!$this->ass_id ||
50  !$this->user_id) {
51  $this->ctrl->returnToParent($this);
52  }
53 
54  $next_class = $ilCtrl->getNextClass($this);
55  $cmd = $ilCtrl->getCmd();
56 
57  switch ($next_class) {
58  default:
59  $this->$cmd();
60  break;
61  }
62 
63  return true;
64  }
global $ilCtrl
Definition: ilias.php:18

◆ finalize()

ilPortfolioExerciseGUI::finalize ( )
protected

Finalize and submit portfolio to exercise.

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

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

273  {
274  $lng = $this->lng;
276 
277  include_once "Modules/Exercise/classes/class.ilExSubmissionBaseGUI.php";
278  include_once "Modules/Exercise/classes/class.ilExSubmissionObjectGUI.php";
279  $exc_gui = ilExSubmissionObjectGUI::initGUIForSubmit($this->ass_id);
280  $exc_gui->submitPortfolio($this->obj_id);
281 
282  ilUtil::sendSuccess($lng->txt("prtf_finalized"), true);
283  $ilCtrl->returnToParent($this);
284  }
global $ilCtrl
Definition: ilias.php:18
static initGUIForSubmit($a_ass_id, $a_user_id=null)
+ Here is the call graph for this function:

◆ getExerciseInfo()

static ilPortfolioExerciseGUI::getExerciseInfo (   $a_user_id,
  $a_assignment_id,
  $a_add_submit = false,
  $as_array = false 
)
staticprotected

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

References $DIC, $file, $ilCtrl, $links, $list, $lng, $text, ilObject\_getAllReferences(), ilLink\_getStaticLink(), ilObject\_lookupTitle(), ilDatePresentation\formatDate(), IL_CAL_DATETIME, ilDatePresentation\setUseRelativeDates(), and ilDatePresentation\useRelativeDates().

106  {
107  global $DIC;
108 
109  $ui = $DIC->ui();
110 
111  $links = [];
112  $buttons = [];
113  $elements = [];
114 
115  $lng = $DIC->language();
116  $ilCtrl = $DIC->ctrl();
117 
118  include_once "Modules/Exercise/classes/class.ilExAssignment.php";
119  $ass = new ilExAssignment($a_assignment_id);
120  $exercise_id = $ass->getExerciseId();
121  if (!$exercise_id) {
122  return;
123  }
124 
125  // is the assignment still open?
126  $times_up = $ass->afterDeadlineStrict();
127 
128  // exercise goto
129  include_once "./Services/Link/classes/class.ilLink.php";
130  $exc_ref_id = array_shift(ilObject::_getAllReferences($exercise_id));
131  $exc_link = ilLink::_getStaticLink($exc_ref_id, "exc");
132 
133  $info_arr["ass_title"] = $ass->getTitle();
134  $text = sprintf(
135  $lng->txt("prtf_exercise_info"),
136  $ass->getTitle(),
137  ilObject::_lookupTitle($exercise_id)
138  );
139  $links[] = $ui->factory()->link()->standard(ilObject::_lookupTitle($exercise_id), $exc_link);
140  $info_arr["exc_title"] = ilObject::_lookupTitle($exercise_id);
141 
142  // submit button
143  if ($a_add_submit && !$times_up && !$as_array) {
144  $ilCtrl->setParameterByClass("ilportfolioexercisegui", "ass", $a_assignment_id);
145  $submit_link = $ilCtrl->getLinkTargetByClass("ilportfolioexercisegui", "finalize");
146  $ilCtrl->setParameterByClass("ilportfolioexercisegui", "ass", "");
147 
148  $buttons[] = $ui->factory()->button()->primary($lng->txt("prtf_finalize_portfolio"), $submit_link);
149  }
150 
151  // submitted files
152  include_once "Modules/Exercise/classes/class.ilExSubmission.php";
153  $submission = new ilExSubmission($ass, $a_user_id);
154  $info_arr["submitted"] = false;
155  if ($submission->hasSubmitted()) {
156  // #16888
157  $submitted = $submission->getSelectedObject();
158 
159  if (!$as_array) {
160  $ilCtrl->setParameterByClass("ilportfolioexercisegui", "ass", $a_assignment_id);
161  $dl_link = $ilCtrl->getLinkTargetByClass("ilportfolioexercisegui", "downloadExcSubFile");
162  $ilCtrl->setParameterByClass("ilportfolioexercisegui", "ass", "");
163 
166 
167  $text .= "<p>" . sprintf(
168  $lng->txt("prtf_exercise_submitted_info"),
170  ""
171  ) . "</p>";
172  $buttons[] = $ui->factory()->button()->standard($lng->txt("prtf_download_submission"), $dl_link);
173  }
174 
176  $info_arr["submitted_date"] = ilDatePresentation::formatDate(new ilDateTime($submitted["ts"], IL_CAL_DATETIME));
177  $info_arr["submitted"] = true;
178  if ($submitted["ts"] == "") {
179  $info_arr["submitted"] = false;
180  }
181  }
182 
183  // work instructions incl. files
184 
185  $tooltip = "";
186 
187  $inst = $ass->getInstruction();
188  if ($inst) {
189  $tooltip .= nl2br($inst);
190  }
191 
192  $ass_files = $ass->getFiles();
193  if (!$as_array) {
194  if (count($ass_files) > 0) {
195  if ($tooltip) {
196  $tooltip .= "<br /><br />";
197  }
198 
199  $items = [];
200 
201  foreach ($ass_files as $file) {
202  $ilCtrl->setParameterByClass("ilportfolioexercisegui", "ass", $a_assignment_id);
203  $ilCtrl->setParameterByClass("ilportfolioexercisegui", "file", urlencode($file["name"]));
204  $dl_link = $ilCtrl->getLinkTargetByClass("ilportfolioexercisegui", "downloadExcAssFile");
205  $ilCtrl->setParameterByClass("ilportfolioexercisegui", "file", "");
206  $ilCtrl->setParameterByClass("ilportfolioexercisegui", "ass", "");
207 
208  $items[] = $ui->renderer()->render($ui->factory()->button()->shy($file["name"], $dl_link));
209  }
210  $list = $ui->factory()->listing()->unordered($items);
211  $tooltip .= $ui->renderer()->render($list);
212  }
213  }
214 
215  if ($tooltip) {
216  $modal = $ui->factory()->modal()->roundtrip($lng->txt("exc_instruction"), $ui->factory()->legacy($tooltip))
217  ->withCancelButtonLabel("close");
218  $elements[] = $modal;
219  $buttons[] = $ui->factory()->button()->standard($lng->txt("exc_instruction"), '#')
220  ->withOnClick($modal->getShowSignal());
221  }
222 
223  if ($as_array) {
224  return $info_arr;
225  }
226 
227  $elements[] = $ui->factory()->messageBox()->info($text)
228  ->withLinks($links)
229  ->withButtons($buttons);
230 
231  return $ui->renderer()->render($elements);
232  }
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41
Exercise assignment.
const IL_CAL_DATETIME
global $DIC
Definition: saml.php:7
static setUseRelativeDates($a_status)
set use relative dates
static _lookupTitle($a_id)
lookup object title
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
static _getAllReferences($a_id)
get all reference ids of object
static useRelativeDates()
check if relative dates are used
global $ilCtrl
Definition: ilias.php:18
$text
Definition: errorreport.php:18
Date and time handling
Exercise submission //TODO: This class has to much static methods related to delivered "files"...
$links
+ Here is the call graph for this function:

Field Documentation

◆ $ass_id

ilPortfolioExerciseGUI::$ass_id
protected

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

◆ $ctrl

ilPortfolioExerciseGUI::$ctrl
protected

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

Referenced by executeCommand(), and finalize().

◆ $file

ilPortfolioExerciseGUI::$file
protected

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

Referenced by downloadExcAssFile(), and getExerciseInfo().

◆ $lng

ilPortfolioExerciseGUI::$lng
protected

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

Referenced by finalize(), and getExerciseInfo().

◆ $obj_id

ilPortfolioExerciseGUI::$obj_id
protected

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

◆ $user_id

ilPortfolioExerciseGUI::$user_id
protected

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


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