ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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)
 

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)
 

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, $DIC, and file.

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"]
Reload workbook from saved file

Member Function Documentation

◆ checkExercise()

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

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

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

Referenced by 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);
91  if ($part) {
92  $info[] = $part;
93  }
94  }
95  }
96  if (sizeof($info)) {
97  return implode("<br />", $info);
98  }
99  }
100  }
global $DIC
Definition: saml.php:7
static _getAllReferences($a_id)
get all reference ids of object
Create styles array
The data for the language used.
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 224 of file class.ilPortfolioExerciseGUI.php.

References $file, ilUtil\deliverFile(), and file.

225  {
226  if ($this->file) {
227  include_once "Modules/Exercise/classes/class.ilExAssignment.php";
228  $ass = new ilExAssignment($this->ass_id);
229  $ass_files = $ass->getFiles();
230  if (count($ass_files) > 0) {
231  foreach ($ass_files as $file) {
232  if ($file["name"] == $this->file) {
233  ilUtil::deliverFile($file["fullpath"], $file["name"]);
234  }
235  }
236  }
237  }
238  }
Exercise assignment.
Reload workbook from saved file
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 240 of file class.ilPortfolioExerciseGUI.php.

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

241  {
242  $ass = new ilExAssignment($this->ass_id);
243  $submission = new ilExSubmission($ass, $this->user_id);
244  $submitted = $submission->getFiles();
245  if (count($submitted) > 0) {
246  $submitted = array_pop($submitted);
247 
248  $user_data = ilObjUser::_lookupName($submitted["user_id"]);
249  $title = ilObject::_lookupTitle($submitted["obj_id"]) . " - " .
250  $ass->getTitle() . " - " .
251  $user_data["firstname"] . " " .
252  $user_data["lastname"] . " (" .
253  $user_data["login"] . ").zip";
254 
255  ilUtil::deliverFile($submitted["filename"], $title);
256  }
257  }
static _lookupName($a_user_id)
lookup user name
Exercise assignment.
static _lookupTitle($a_id)
lookup object title
Exercise submission.
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 262 of file class.ilPortfolioExerciseGUI.php.

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

263  {
264  $lng = $this->lng;
266 
267  include_once "Modules/Exercise/classes/class.ilExSubmissionBaseGUI.php";
268  include_once "Modules/Exercise/classes/class.ilExSubmissionObjectGUI.php";
269  $exc_gui = ilExSubmissionObjectGUI::initGUIForSubmit($this->ass_id);
270  $exc_gui->submitPortfolio($this->obj_id);
271 
272  ilUtil::sendSuccess($lng->txt("prtf_finalized"), true);
273  $ilCtrl->returnToParent($this);
274  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
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 
)
staticprotected

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

References $DIC, $file, $ilCtrl, $info, $lng, ilObject\_getAllReferences(), ilLink\_getStaticLink(), ilObject\_lookupTitle(), ilDatePresentation\formatDate(), ilLinkButton\getInstance(), IL_CAL_DATETIME, ilDatePresentation\setUseRelativeDates(), and ilDatePresentation\useRelativeDates().

103  {
104  global $DIC;
105 
106  $lng = $DIC->language();
107  $ilCtrl = $DIC->ctrl();
108 
109  include_once "Modules/Exercise/classes/class.ilExAssignment.php";
110  $ass = new ilExAssignment($a_assignment_id);
111  $exercise_id = $ass->getExerciseId();
112  if (!$exercise_id) {
113  return;
114  }
115 
116  // is the assignment still open?
117  $times_up = $ass->afterDeadlineStrict();
118 
119  // exercise goto
120  include_once "./Services/Link/classes/class.ilLink.php";
121  $exc_ref_id = array_shift(ilObject::_getAllReferences($exercise_id));
122  $exc_link = ilLink::_getStaticLink($exc_ref_id, "exc");
123 
124  $info = sprintf(
125  $lng->txt("prtf_exercise_info"),
126  $ass->getTitle(),
127  "<a href=\"" . $exc_link . "\">" .
128  ilObject::_lookupTitle($exercise_id) . "</a>"
129  );
130 
131  // submit button
132  if ($a_add_submit && !$times_up) {
133  $ilCtrl->setParameterByClass("ilportfolioexercisegui", "ass", $a_assignment_id);
134  $submit_link = $ilCtrl->getLinkTargetByClass("ilportfolioexercisegui", "finalize");
135  $ilCtrl->setParameterByClass("ilportfolioexercisegui", "ass", "");
136 
137  include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
138  $button = ilLinkButton::getInstance();
139  $button->setCaption("prtf_finalize_portfolio");
140  $button->setPrimary(true);
141  $button->setUrl($submit_link);
142  $info .= " " . $button->render();
143  }
144 
145  // submitted files
146  include_once "Modules/Exercise/classes/class.ilExSubmission.php";
147  $submission = new ilExSubmission($ass, $a_user_id);
148  if ($submission->hasSubmitted()) {
149  // #16888
150  $submitted = $submission->getSelectedObject();
151 
152  $ilCtrl->setParameterByClass("ilportfolioexercisegui", "ass", $a_assignment_id);
153  $dl_link = $ilCtrl->getLinkTargetByClass("ilportfolioexercisegui", "downloadExcSubFile");
154  $ilCtrl->setParameterByClass("ilportfolioexercisegui", "ass", "");
155 
158 
159  include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
160  $button = ilLinkButton::getInstance();
161  $button->setCaption("download");
162  $button->setUrl($dl_link);
163 
164  $info .= "<p>" . sprintf(
165  $lng->txt("prtf_exercise_submitted_info"),
167  $button->render()
168  ) . "</p>";
169 
171  }
172 
173 
174  // work instructions incl. files
175 
176  $tooltip = "";
177 
178  $inst = $ass->getInstruction();
179  if ($inst) {
180  $tooltip .= nl2br($inst);
181  }
182 
183  $ass_files = $ass->getFiles();
184  if (count($ass_files) > 0) {
185  if ($tooltip) {
186  $tooltip .= "<br /><br />";
187  }
188 
189  foreach ($ass_files as $file) {
190  $ilCtrl->setParameterByClass("ilportfolioexercisegui", "ass", $a_assignment_id);
191  $ilCtrl->setParameterByClass("ilportfolioexercisegui", "file", urlencode($file["name"]));
192  $dl_link = $ilCtrl->getLinkTargetByClass("ilportfolioexercisegui", "downloadExcAssFile");
193  $ilCtrl->setParameterByClass("ilportfolioexercisegui", "file", "");
194  $ilCtrl->setParameterByClass("ilportfolioexercisegui", "ass", "");
195 
196  $tooltip .= $file["name"] . ": <a href=\"" . $dl_link . "\">" .
197  $lng->txt("download") . "</a>";
198  }
199  }
200 
201  if ($tooltip) {
202  $ol_id = "exc_ass_" . $a_assignment_id;
203 
204  include_once "Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php";
205  $overlay = new ilOverlayGUI($ol_id);
206 
207  // overlay
208  $overlay->setAnchor($ol_id . "_tr");
209  $overlay->setTrigger($ol_id . "_tr", "click", $ol_id . "_tr");
210  $overlay->setAutoHide(false);
211  // $overlay->setCloseElementId($cl_id);
212  $overlay->add();
213 
214  // trigger
215  $overlay->addTrigger($ol_id . "_tr", "click", $ol_id . "_tr");
216 
217  $info .= "<p id=\"" . $ol_id . "_tr\"><a href=\"#\">" . $lng->txt("exc_instruction") . "</a></p>" .
218  "<div id=\"" . $ol_id . "\" style=\"display:none; background-color:white; border: 1px solid #bbb; padding: 10px;\">" . $tooltip . "</div>";
219  }
220 
221  return $info;
222  }
Exercise assignment.
const IL_CAL_DATETIME
global $DIC
Definition: saml.php:7
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date public.
static setUseRelativeDates($a_status)
set use relative dates
static _lookupTitle($a_id)
lookup object title
static _getAllReferences($a_id)
get all reference ids of object
static useRelativeDates()
check if relative dates are used
global $ilCtrl
Definition: ilias.php:18
This is a utility class for the yui overlays.
Date and time handling
Exercise submission.
$info
Definition: index.php:5
+ 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: