ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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.

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

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
+ 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  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ downloadExcAssFile()

ilBlogExerciseGUI::downloadExcAssFile ( )
protected

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

References ilFileDelivery\deliverFileLegacy().

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)
+ Here is the call graph for this function:

◆ downloadExcSubFile()

ilBlogExerciseGUI::downloadExcSubFile ( )
protected

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

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

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  }
getFiles(array $a_file_ids=null, bool $a_only_valid=false, string $a_min_timestamp=null, bool $print_versions=false)
Get submission items (not only files)
Exercise assignment.
static _lookupName(int $a_user_id)
lookup user name
static deliverFileLegacy(string $a_file, ?string $a_filename=null, ?string $a_mime=null, ?bool $isInline=false, ?bool $removeAfterDelivery=false, ?bool $a_exit_after=true)
static _lookupTitle(int $obj_id)
$ilUser
Definition: imgupload.php:34
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ executeCommand()

ilBlogExerciseGUI::executeCommand ( )

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

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

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  }
+ Here is the call graph for this function:

◆ finalize()

ilBlogExerciseGUI::finalize ( )
protected

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

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

240  : void
241  {
242  $ilCtrl = $this->ctrl;
243  $lng = $this->lng;
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  }
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...
static initGUIForSubmit(int $a_ass_id, int $a_user_id=null)
+ Here is the call graph for this function:

◆ getActionButtons()

ilBlogExerciseGUI::getActionButtons ( )

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

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

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  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getDownloadSubmissionButton(int $ass_id)
getSubmitButton(int $ass_id)
Get submit link.
+ Here is the call graph for this function:

◆ getDownloadSubmissionButton()

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

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

References $ctrl, $lng, $ui, ilExSubmission\getSelectedObject(), ilLanguage\txt(), and ILIAS\Repository\user().

Referenced by getActionButtons().

281  $ilCtrl = $this->ctrl;
282  $lng = $this->lng;
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  }
Exercise assignment.
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...
This describes a standard button.
Definition: Standard.php:26
ILIAS DI UIServices $ui
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getExerciseInfo()

static ilBlogExerciseGUI::getExerciseInfo ( int  $a_assignment_id)
staticprotected

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

References $DIC, $ilUser, ilObject\_getAllReferences(), ilLink\_getStaticLink(), ilObject\_lookupTitle(), ilDatePresentation\formatDate(), ilExSubmission\getSelectedObject(), IL_CAL_DATETIME, ilDatePresentation\setUseRelativeDates(), ilLanguage\txt(), and ilDatePresentation\useRelativeDates().

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  }
Exercise assignment.
const IL_CAL_DATETIME
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...
static _getAllReferences(int $id)
get all reference ids for object ID
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
global $DIC
Definition: feed.php:28
static _lookupTitle(int $obj_id)
ILIAS DI UIServices $ui
$ilUser
Definition: imgupload.php:34
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static setUseRelativeDates(bool $a_status)
set use relative dates
+ Here is the call graph for this function:

◆ getSubmitButton()

ilBlogExerciseGUI::getSubmitButton ( int  $ass_id)

Get submit link.

Exceptions
ilCtrlException

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

References $ctrl, $lng, $ui, ilExcAssMemberState\getInstanceByIds(), ilLanguage\txt(), and ILIAS\Repository\user().

Referenced by getActionButtons().

259  $ilCtrl = $this->ctrl;
260  $ui = $this->ui;
261  $lng = $this->lng;
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  }
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...
This describes a standard button.
Definition: Primary.php:26
static getInstanceByIds(int $a_ass_id, int $a_user_id=0)
ILIAS DI UIServices $ui
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ass_id

int ilBlogExerciseGUI::$ass_id
protected

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

Referenced by getActionButtons().

◆ $blog_request

StandardGUIRequest ilBlogExerciseGUI::$blog_request
protected

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

◆ $ctrl

ilCtrl ilBlogExerciseGUI::$ctrl
protected

◆ $file

string ilBlogExerciseGUI::$file
protected

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

◆ $lng

ilLanguage ilBlogExerciseGUI::$lng
protected

◆ $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.

Referenced by getDownloadSubmissionButton(), and getSubmitButton().

◆ $user

ilObjUser ilBlogExerciseGUI::$user
protected

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

Referenced by downloadExcSubFile().


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