ILIAS  release_8 Revision v8.24
ilBlogExerciseGUI Class Reference

Class ilBlogExerciseGUI. More...

+ Collaboration diagram for ilBlogExerciseGUI:

Public Member Functions

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

Static Public Member Functions

static checkExercise (int $a_node_id)
 

Protected Member Functions

 downloadExcAssFile ()
 
 downloadExcSubFile ()
 
 finalize ()
 

Static Protected Member Functions

static getExerciseInfo (int $a_assignment_id)
 

Protected Attributes

StandardGUIRequest $blog_request
 
ilCtrl $ctrl
 
ilObjUser $user
 
ilLanguage $lng
 
int $node_id
 
int $ass_id
 
string $file
 
ILIAS DI UIServices $ui
 

Private Attributes

ilGlobalTemplateInterface $main_tpl
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilBlogExerciseGUI::__construct ( int  $a_node_id)

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

39 {
40 global $DIC;
41 $this->main_tpl = $DIC->ui()->mainTemplate();
42
43 $this->ctrl = $DIC->ctrl();
44 $this->user = $DIC->user();
45 $this->lng = $DIC->language();
46 $this->node_id = $a_node_id;
47 $this->blog_request = $DIC->blog()
48 ->internal()
49 ->gui()
50 ->standardRequest();
51
52 $this->ass_id = $this->blog_request->getAssId();
53 $this->file = $this->blog_request->getAssFile();
54 $this->ui = $DIC->ui();
55 }
global $DIC
Definition: feed.php:28

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

+ Here is the call graph for this function:

Member Function Documentation

◆ checkExercise()

static ilBlogExerciseGUI::checkExercise ( int  $a_node_id)
static

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

77 : string {
78 $be = new ilBlogExercise($a_node_id);
79
80 $info = [];
81
82 foreach ($be->getAssignmentsOfBlog() as $ass) {
83 $part = self::getExerciseInfo($ass["ass_id"]);
84 if ($part) {
85 $info[] = $part;
86 }
87 }
88 if (count($info) > 0) {
89 return implode("<br />", $info);
90 }
91 return "";
92 }
static getExerciseInfo(int $a_assignment_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References getExerciseInfo().

+ Here is the call graph for this function:

◆ downloadExcAssFile()

ilBlogExerciseGUI::downloadExcAssFile ( )
protected

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

204 : void
205 {
206 if ($this->file) {
207 $ass = new ilExAssignment($this->ass_id);
208 $ass_files = $ass->getFiles();
209 if (count($ass_files) > 0) {
210 foreach ($ass_files as $file) {
211 if ($file["name"] == $this->file) {
212 ilFileDelivery::deliverFileLegacy($file["fullpath"], $file["name"]);
213 }
214 }
215 }
216 }
217 }
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 ilFileDelivery\deliverFileLegacy().

+ Here is the call graph for this function:

◆ downloadExcSubFile()

ilBlogExerciseGUI::downloadExcSubFile ( )
protected

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

219 : void
220 {
222
223 $ass = new ilExAssignment($this->ass_id);
224 $submission = new ilExSubmission($ass, $ilUser->getId());
225 $submitted = $submission->getFiles();
226 if (count($submitted) > 0) {
227 $submitted = array_pop($submitted);
228
229 $user_data = ilObjUser::_lookupName($submitted["user_id"]);
230 $title = ilObject::_lookupTitle($submitted["obj_id"]) . " - " .
231 $ass->getTitle() . " - " .
232 $user_data["firstname"] . " " .
233 $user_data["lastname"] . " (" .
234 $user_data["login"] . ").zip";
235
236 ilFileDelivery::deliverFileLegacy($submitted["filename"], $title);
237 }
238 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupName(int $a_user_id)
lookup user name
static _lookupTitle(int $obj_id)
$ilUser
Definition: imgupload.php:34

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

+ Here is the call graph for this function:

◆ executeCommand()

ilBlogExerciseGUI::executeCommand ( )

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

57 : void
58 {
59 $ilCtrl = $this->ctrl;
60
61 if (!$this->ass_id) {
62 $this->ctrl->returnToParent($this);
63 }
64
65 $next_class = $ilCtrl->getNextClass($this);
66 $cmd = $ilCtrl->getCmd();
67
68 switch ($next_class) {
69 default:
70 $this->$cmd();
71 break;
72 }
73 }

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

+ Here is the call graph for this function:

◆ finalize()

ilBlogExerciseGUI::finalize ( )
protected

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

240 : void
241 {
242 $ilCtrl = $this->ctrl;
244
245 $exc_gui = ilExSubmissionObjectGUI::initGUIForSubmit($this->ass_id);
246 $exc_gui->submitBlog($this->node_id);
247
248 $this->main_tpl->setOnScreenMessage('success', $lng->txt("blog_finalized"), true);
249 $ilCtrl->returnToParent($this);
250 }
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 $lng, and ilExSubmissionObjectGUI\initGUIForSubmit().

+ Here is the call graph for this function:

◆ getActionButtons()

ilBlogExerciseGUI::getActionButtons ( )

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

301 : array
302 {
303 $be = new ilBlogExercise($this->node_id);
304
305 $buttons = [];
306 foreach ($be->getAssignmentsOfBlog() as $exercise) {
307 $ass_id = $exercise["ass_id"];
308 $buttons[$ass_id] = [];
309 $submit_button = $this->getSubmitButton($ass_id);
310 if ($submit_button) {
311 $buttons[$ass_id][] = $submit_button;
312 }
313 $download_button = $this->getDownloadSubmissionButton($ass_id);
314 if ($download_button) {
315 $buttons[$ass_id][] = $download_button;
316 }
317 }
318
319 return $buttons;
320 }
getDownloadSubmissionButton(int $ass_id)
getSubmitButton(int $ass_id)
Get submit link.

References $exercise.

◆ getDownloadSubmissionButton()

ilBlogExerciseGUI::getDownloadSubmissionButton ( int  $ass_id)
Exceptions
ilCtrlException
ilExcUnknownAssignmentTypeException

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

281 $ilCtrl = $this->ctrl;
283 $ui = $this->ui;
284
285 // submitted files
286 $submission = new ilExSubmission(new ilExAssignment($ass_id), $this->user->getId());
287 if ($submission->hasSubmitted()) {
288 // #16888
289 $submitted = $submission->getSelectedObject();
290 if ($submitted["ts"] != "") {
291 $ilCtrl->setParameterByClass("ilblogexercisegui", "ass", $ass_id);
292 $dl_link = $ilCtrl->getLinkTargetByClass("ilblogexercisegui", "downloadExcSubFile");
293 $ilCtrl->setParameterByClass("ilblogexercisegui", "ass", "");
294 return $ui->factory()->button()->standard($lng->txt("blog_download_submission"), $dl_link);
295 }
296 }
297 return null;
298 }
ILIAS DI UIServices $ui
This describes a standard button.
Definition: Standard.php:27

◆ getExerciseInfo()

static ilBlogExerciseGUI::getExerciseInfo ( int  $a_assignment_id)
staticprotected

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

96 : string {
97 global $DIC;
98
99 $ui = $DIC->ui();
100
101 $links = [];
102 $buttons = [];
103 $elements = [];
104 $items = [];
105
106 $lng = $DIC->language();
107 $ilCtrl = $DIC->ctrl();
108 $ilUser = $DIC->user();
109
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 $exc_ref_id = current(ilObject::_getAllReferences($exercise_id));
121 $exc_link = ilLink::_getStaticLink($exc_ref_id, "exc");
122
123 $text = sprintf(
124 $lng->txt("blog_exercise_info"),
125 $ass->getTitle(),
126 ilObject::_lookupTitle($exercise_id)
127 );
128 $links[] = $ui->factory()->link()->standard(ilObject::_lookupTitle($exercise_id), $exc_link);
129
130 // submit button
131 if (!$times_up) {
132 $ilCtrl->setParameterByClass("ilblogexercisegui", "ass", $a_assignment_id);
133 $submit_link = $ilCtrl->getLinkTargetByClass("ilblogexercisegui", "finalize");
134 $ilCtrl->setParameterByClass("ilblogexercisegui", "ass", "");
135
136 $buttons[] = $ui->factory()->button()->primary($lng->txt("blog_finalize_blog"), $submit_link);
137 }
138
139 // submitted files
140 $submission = new ilExSubmission($ass, $ilUser->getId());
141 if ($submission->hasSubmitted()) {
142 // #16888
143 $submitted = $submission->getSelectedObject();
144
145 $ilCtrl->setParameterByClass("ilblogexercisegui", "ass", $a_assignment_id);
146 $dl_link = $ilCtrl->getLinkTargetByClass("ilblogexercisegui", "downloadExcSubFile");
147 $ilCtrl->setParameterByClass("ilblogexercisegui", "ass", "");
148
151
152 $text .= "<br />" . sprintf(
153 $lng->txt("blog_exercise_submitted_info"),
155 ""
156 );
157
159 $buttons[] = $ui->factory()->button()->standard($lng->txt("blog_download_submission"), $dl_link);
160 }
161
162
163 // work instructions incl. files
164
165 $tooltip = "";
166
167 $inst = $ass->getInstruction();
168 if ($inst) {
169 $tooltip .= nl2br($inst);
170 }
171
172 $ass_files = $ass->getFiles();
173 if (count($ass_files) > 0) {
174 $tooltip .= "<br /><br />";
175
176 foreach ($ass_files as $file) {
177 $ilCtrl->setParameterByClass("ilblogexercisegui", "ass", $a_assignment_id);
178 $ilCtrl->setParameterByClass("ilblogexercisegui", "file", urlencode($file["name"]));
179 $dl_link = $ilCtrl->getLinkTargetByClass("ilblogexercisegui", "downloadExcAssFile");
180 $ilCtrl->setParameterByClass("ilblogexercisegui", "file", "");
181 $ilCtrl->setParameterByClass("ilblogexercisegui", "ass", "");
182
183 $items[] = $ui->renderer()->render($ui->factory()->button()->shy($file["name"], $dl_link));
184 }
185 $list = $ui->factory()->listing()->unordered($items);
186 $tooltip .= $ui->renderer()->render($list);
187 }
188
189 if ($tooltip) {
190 $modal = $ui->factory()->modal()->roundtrip($lng->txt("exc_instruction"), $ui->factory()->legacy($tooltip))
191 ->withCancelButtonLabel("close");
192 $elements[] = $modal;
193 $buttons[] = $ui->factory()->button()->standard($lng->txt("exc_instruction"), '#')
194 ->withOnClick($modal->getShowSignal());
195 }
196
197 $elements[] = $ui->factory()->messageBox()->info($text)
198 ->withLinks($links)
199 ->withButtons($buttons);
200
201 return $ui->renderer()->render($elements);
202 }
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)
@classDescription Date and time handling
static _getAllReferences(int $id)
get all reference ids for object ID

Referenced by checkExercise().

+ Here is the caller graph for this function:

◆ getSubmitButton()

ilBlogExerciseGUI::getSubmitButton ( int  $ass_id)

Get submit link.

Exceptions
ilCtrlException

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

259 $ilCtrl = $this->ctrl;
260 $ui = $this->ui;
262
263 $state = ilExcAssMemberState::getInstanceByIds($ass_id, $this->user->getId());
264
265 if ($state->isSubmissionAllowed()) {
266 $ilCtrl->setParameterByClass("ilblogexercisegui", "ass", $ass_id);
267 $submit_link = $ilCtrl->getLinkTargetByClass("ilblogexercisegui", "finalize");
268 $ilCtrl->setParameterByClass("ilblogexercisegui", "ass", "");
269 return $ui->factory()->button()->primary($lng->txt("blog_finalize_blog"), $submit_link);
270 }
271 return null;
272 }
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 ilBlogExerciseGUI::$ass_id
protected

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

◆ $blog_request

StandardGUIRequest ilBlogExerciseGUI::$blog_request
protected

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

◆ $ctrl

ilCtrl ilBlogExerciseGUI::$ctrl
protected

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

Referenced by executeCommand().

◆ $file

string ilBlogExerciseGUI::$file
protected

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

◆ $lng

ilLanguage ilBlogExerciseGUI::$lng
protected

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

◆ $main_tpl

ilGlobalTemplateInterface ilBlogExerciseGUI::$main_tpl
private

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

◆ $node_id

int ilBlogExerciseGUI::$node_id
protected

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

◆ $ui

ILIAS DI UIServices ilBlogExerciseGUI::$ui
protected

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

◆ $user

ilObjUser ilBlogExerciseGUI::$user
protected

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


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