ILIAS  release_7 Revision v7.30-3-g800a261c036
ilBlogExerciseGUI Class Reference

Class ilBlogExerciseGUI. More...

+ Collaboration diagram for ilBlogExerciseGUI:

Public Member Functions

 __construct ($a_node_id)
 
 executeCommand ()
 
 getSubmitButton (int $ass_id)
 Get submit link. More...
 
 getDownloadSubmissionButton (int $ass_id)
 Get download button. More...
 
 getActionButtons ()
 Get action buttons. More...
 

Static Public Member Functions

static checkExercise ($a_node_id)
 

Protected Member Functions

 downloadExcAssFile ()
 
 downloadExcSubFile ()
 
 finalize ()
 Finalize and submit blog to exercise. More...
 

Static Protected Member Functions

static getExerciseInfo ($a_assignment_id)
 

Protected Attributes

 $ctrl
 
 $user
 
 $lng
 
 $node_id
 
 $ass_id
 
 $file
 
 $ui
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilBlogExerciseGUI::__construct (   $a_node_id)

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

39 {
40 global $DIC;
41
42 $this->ctrl = $DIC->ctrl();
43 $this->user = $DIC->user();
44 $this->lng = $DIC->language();
45 $this->node_id = $a_node_id;
46 $this->ass_id = (int) $_GET["ass"];
47 $this->file = trim(ilUtil::stripSlashes($_GET["file"]));
48 $this->ui = $DIC->ui();
49 }
user()
Definition: user.php:4
$_GET["client_id"]
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
global $DIC
Definition: goto.php:24
ui()
Definition: ui.php:5

References $_GET, $DIC, ilUtil\stripSlashes(), ui(), and user().

+ Here is the call graph for this function:

Member Function Documentation

◆ checkExercise()

static ilBlogExerciseGUI::checkExercise (   $a_node_id)
static

Definition at line 71 of file class.ilBlogExerciseGUI.php.

72 {
73 $be = new ilBlogExercise($a_node_id);
74
75 foreach ($be->getAssignmentsOfBlog() as $ass) {
76 $part = self::getExerciseInfo($ass["ass_id"]);
77 if ($part) {
78 $info[] = $part;
79 }
80 }
81 if (sizeof($info)) {
82 return implode("<br />", $info);
83 }
84 return "";
85 }
static getExerciseInfo($a_assignment_id)

References getExerciseInfo().

+ Here is the call graph for this function:

◆ downloadExcAssFile()

ilBlogExerciseGUI::downloadExcAssFile ( )
protected

Definition at line 195 of file class.ilBlogExerciseGUI.php.

196 {
197 if ($this->file) {
198 $ass = new ilExAssignment($this->ass_id);
199 $ass_files = $ass->getFiles();
200 if (count($ass_files) > 0) {
201 foreach ($ass_files as $file) {
202 if ($file["name"] == $this->file) {
203 ilUtil::deliverFile($file["fullpath"], $file["name"]);
204 }
205 }
206 }
207 }
208 }
Exercise assignment.
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.

References $file, and ilUtil\deliverFile().

+ Here is the call graph for this function:

◆ downloadExcSubFile()

ilBlogExerciseGUI::downloadExcSubFile ( )
protected

Definition at line 210 of file class.ilBlogExerciseGUI.php.

211 {
213
214 $ass = new ilExAssignment($this->ass_id);
215 $submission = new ilExSubmission($ass, $ilUser->getId());
216 $submitted = $submission->getFiles();
217 if (count($submitted) > 0) {
218 $submitted = array_pop($submitted);
219
220 $user_data = ilObjUser::_lookupName($submitted["user_id"]);
221 $title = ilObject::_lookupTitle($submitted["obj_id"]) . " - " .
222 $ass->getTitle() . " - " .
223 $user_data["firstname"] . " " .
224 $user_data["lastname"] . " (" .
225 $user_data["login"] . ").zip";
226
227 ilUtil::deliverFile($submitted["filename"], $title);
228 }
229 }
Exercise submission //TODO: This class has to much static methods related to delivered "files".
static _lookupName($a_user_id)
lookup user name
static _lookupTitle($a_id)
lookup object title
$ilUser
Definition: imgupload.php:18

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

+ Here is the call graph for this function:

◆ executeCommand()

ilBlogExerciseGUI::executeCommand ( )

Definition at line 51 of file class.ilBlogExerciseGUI.php.

52 {
53 $ilCtrl = $this->ctrl;
54
55 if (!$this->ass_id) {
56 $this->ctrl->returnToParent($this);
57 }
58
59 $next_class = $ilCtrl->getNextClass($this);
60 $cmd = $ilCtrl->getCmd();
61
62 switch ($next_class) {
63 default:
64 $this->$cmd();
65 break;
66 }
67
68 return true;
69 }

References $ctrl.

◆ finalize()

ilBlogExerciseGUI::finalize ( )
protected

Finalize and submit blog to exercise.

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

235 {
236 $ilCtrl = $this->ctrl;
238
239 $exc_gui = ilExSubmissionObjectGUI::initGUIForSubmit($this->ass_id);
240 $exc_gui->submitBlog($this->node_id);
241
242 ilUtil::sendSuccess($lng->txt("blog_finalized"), true);
243 $ilCtrl->returnToParent($this);
244 }
static initGUIForSubmit($a_ass_id, $a_user_id=null)

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

+ Here is the call graph for this function:

◆ getActionButtons()

ilBlogExerciseGUI::getActionButtons ( )

Get action buttons.

Returns
array

Definition at line 304 of file class.ilBlogExerciseGUI.php.

305 {
306 $be = new ilBlogExercise($this->node_id);
307
308 $buttons = [];
309 foreach ($be->getAssignmentsOfBlog() as $exercise) {
310 $ass_id = $exercise["ass_id"];
311 $buttons[$ass_id] = [];
312 $submit_button = $this->getSubmitButton($ass_id);
313 if ($submit_button != null) {
314 $buttons[$ass_id][] = $submit_button;
315 }
316 $download_button = $this->getDownloadSubmissionButton($ass_id);
317 if ($download_button != null) {
318 $buttons[$ass_id][] = $download_button;
319 }
320 }
321
322 return $buttons;
323 }
getDownloadSubmissionButton(int $ass_id)
Get download button.
getSubmitButton(int $ass_id)
Get submit link.

References $ass_id, $exercise, getDownloadSubmissionButton(), and getSubmitButton().

+ Here is the call graph for this function:

◆ getDownloadSubmissionButton()

ilBlogExerciseGUI::getDownloadSubmissionButton ( int  $ass_id)

Get download button.

Parameters

return

Definition at line 276 of file class.ilBlogExerciseGUI.php.

277 {
278 $ilCtrl = $this->ctrl;
280 $ui = $this->ui;
281
282 // submitted files
283 $submission = new ilExSubmission(new ilExAssignment($ass_id), $this->user->getId());
284 if ($submission->hasSubmitted()) {
285 // #16888
286 $submitted = $submission->getSelectedObject();
287 if ($submitted["ts"] != "") {
288 $ilCtrl->setParameterByClass("ilblogexercisegui", "ass", $ass_id);
289 $dl_link = $ilCtrl->getLinkTargetByClass("ilblogexercisegui", "downloadExcSubFile");
290 $ilCtrl->setParameterByClass("ilblogexercisegui", "ass", "");
291 $button = $ui->factory()->button()->standard($lng->txt("blog_download_submission"), $dl_link);
292 return $button;
293 }
294 }
295 return null;
296 }

References $ass_id, $ctrl, $lng, $ui, and user().

Referenced by getActionButtons().

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

◆ getExerciseInfo()

static ilBlogExerciseGUI::getExerciseInfo (   $a_assignment_id)
staticprotected

Definition at line 87 of file class.ilBlogExerciseGUI.php.

88 {
89 global $DIC;
90
91 $ui = $DIC->ui();
92
93 $links = [];
94 $buttons = [];
95 $elements = [];
96
97 $lng = $DIC->language();
98 $ilCtrl = $DIC->ctrl();
99 $ilUser = $DIC->user();
100
101 $ass = new ilExAssignment($a_assignment_id);
102 $exercise_id = $ass->getExerciseId();
103 if (!$exercise_id) {
104 return;
105 }
106
107 // is the assignment still open?
108 $times_up = $ass->afterDeadlineStrict();
109
110 // exercise goto
111 $exc_ref_id = array_shift(ilObject::_getAllReferences($exercise_id));
112 $exc_link = ilLink::_getStaticLink($exc_ref_id, "exc");
113
114 $text = sprintf(
115 $lng->txt("blog_exercise_info"),
116 $ass->getTitle(),
117 ilObject::_lookupTitle($exercise_id)
118 );
119 $links[] = $ui->factory()->link()->standard(ilObject::_lookupTitle($exercise_id), $exc_link);
120
121 // submit button
122 if (!$times_up) {
123 $ilCtrl->setParameterByClass("ilblogexercisegui", "ass", $a_assignment_id);
124 $submit_link = $ilCtrl->getLinkTargetByClass("ilblogexercisegui", "finalize");
125 $ilCtrl->setParameterByClass("ilblogexercisegui", "ass", "");
126
127 $buttons[] = $ui->factory()->button()->primary($lng->txt("blog_finalize_blog"), $submit_link);
128 }
129
130 // submitted files
131 $submission = new ilExSubmission($ass, $ilUser->getId());
132 if ($submission->hasSubmitted()) {
133 // #16888
134 $submitted = $submission->getSelectedObject();
135
136 $ilCtrl->setParameterByClass("ilblogexercisegui", "ass", $a_assignment_id);
137 $dl_link = $ilCtrl->getLinkTargetByClass("ilblogexercisegui", "downloadExcSubFile");
138 $ilCtrl->setParameterByClass("ilblogexercisegui", "ass", "");
139
142
143 $text .= "<br />" . sprintf(
144 $lng->txt("blog_exercise_submitted_info"),
146 ""
147 );
148
150 $buttons[] = $ui->factory()->button()->standard($lng->txt("blog_download_submission"), $dl_link);
151 }
152
153
154 // work instructions incl. files
155
156 $tooltip = "";
157
158 $inst = $ass->getInstruction();
159 if ($inst) {
160 $tooltip .= nl2br($inst);
161 }
162
163 $ass_files = $ass->getFiles();
164 if (count($ass_files) > 0) {
165 $tooltip .= "<br /><br />";
166
167 foreach ($ass_files as $file) {
168 $ilCtrl->setParameterByClass("ilblogexercisegui", "ass", $a_assignment_id);
169 $ilCtrl->setParameterByClass("ilblogexercisegui", "file", urlencode($file["name"]));
170 $dl_link = $ilCtrl->getLinkTargetByClass("ilblogexercisegui", "downloadExcAssFile");
171 $ilCtrl->setParameterByClass("ilblogexercisegui", "file", "");
172 $ilCtrl->setParameterByClass("ilblogexercisegui", "ass", "");
173
174 $items[] = $ui->renderer()->render($ui->factory()->button()->shy($file["name"], $dl_link));
175 }
176 $list = $ui->factory()->listing()->unordered($items);
177 $tooltip .= $ui->renderer()->render($list);
178 }
179
180 if ($tooltip) {
181 $modal = $ui->factory()->modal()->roundtrip($lng->txt("exc_instruction"), $ui->factory()->legacy($tooltip))
182 ->withCancelButtonLabel("close");
183 $elements[] = $modal;
184 $buttons[] = $ui->factory()->button()->standard($lng->txt("exc_instruction"), '#')
185 ->withOnClick($modal->getShowSignal());
186 }
187
188 $elements[] = $ui->factory()->messageBox()->info($text)
189 ->withLinks($links)
190 ->withButtons($buttons);
191
192 return $ui->renderer()->render($elements);
193 }
const IL_CAL_DATETIME
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
static setUseRelativeDates($a_status)
set use relative dates
static useRelativeDates()
check if relative dates are used
@classDescription Date and time handling
static _getAllReferences($a_id)
get all reference ids of object

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

Referenced by checkExercise().

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

◆ getSubmitButton()

ilBlogExerciseGUI::getSubmitButton ( int  $ass_id)

Get submit link.

Parameters
int$ass_id
Returns
object

Definition at line 252 of file class.ilBlogExerciseGUI.php.

253 {
254 $ilCtrl = $this->ctrl;
255 $ui = $this->ui;
257
258 $state = ilExcAssMemberState::getInstanceByIds($ass_id, $this->user->getId());
259
260 if ($state->isSubmissionAllowed()) {
261 $ilCtrl->setParameterByClass("ilblogexercisegui", "ass", $ass_id);
262 $submit_link = $ilCtrl->getLinkTargetByClass("ilblogexercisegui", "finalize");
263 $ilCtrl->setParameterByClass("ilblogexercisegui", "ass", "");
264 $button = $ui->factory()->button()->primary($lng->txt("blog_finalize_blog"), $submit_link);
265 return $button;
266 }
267 return null;
268 }
static getInstanceByIds($a_ass_id, $a_user_id=0)
Get instance by IDs (recommended for consumer code)

References $ass_id, $ctrl, $lng, $ui, ilExcAssMemberState\getInstanceByIds(), and user().

Referenced by getActionButtons().

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

Field Documentation

◆ $ass_id

ilBlogExerciseGUI::$ass_id
protected

◆ $ctrl

ilBlogExerciseGUI::$ctrl
protected

◆ $file

ilBlogExerciseGUI::$file
protected

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

Referenced by downloadExcAssFile(), and getExerciseInfo().

◆ $lng

ilBlogExerciseGUI::$lng
protected

◆ $node_id

ilBlogExerciseGUI::$node_id
protected

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

◆ $ui

ilBlogExerciseGUI::$ui
protected

◆ $user

ilBlogExerciseGUI::$user
protected

Definition at line 22 of file class.ilBlogExerciseGUI.php.

Referenced by downloadExcSubFile().


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