ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilExSubmissionTextGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilExSubmissionTextGUI:
+ Collaboration diagram for ilExSubmissionTextGUI:

Public Member Functions

 __construct (ilObjExercise $a_exercise, ilExSubmission $a_submission)
 
 executeCommand ()
 
 editAssignmentTextObject (ilPropertyFormGUI $a_form=null)
 
 updateAssignmentTextAndReturnObject ()
 
 updateAssignmentTextObject (bool $a_return=false)
 
 showAssignmentTextObject ()
 
- Public Member Functions inherited from ilExSubmissionBaseGUI
 returnToParentObject ()
 

Static Public Member Functions

static getOverviewContent (ilInfoScreenGUI $a_info, ilExSubmission $a_submission)
 
- Static Public Member Functions inherited from ilExSubmissionBaseGUI
static getOverviewContent (ilInfoScreenGUI $a_info, ilExSubmission $a_submission)
 

Protected Member Functions

 initAssignmentTextForm (bool $a_read_only=false)
 
- Protected Member Functions inherited from ilExSubmissionBaseGUI
 handleTabs ()
 
 handleNewUpload (bool $a_no_notifications=false)
 
 handleRemovedUpload ()
 
 triggerAssignmentTool ()
 

Protected Attributes

ilObjUser $user
 
ilHelpGUI $help
 
- Protected Attributes inherited from ilExSubmissionBaseGUI
ilCtrl $ctrl
 
ilTabsGUI $tabs_gui
 
ilLanguage $lng
 
ilGlobalTemplateInterface $tpl
 
ilObjExercise $exercise
 
ilExSubmission $submission
 
ilExAssignment $assignment
 
MandatoryAssignmentsManager $mandatory_manager
 
ContextServices $tool_context
 
ilExAssignmentTypesGUI $type_guis
 
int $requested_ref_id
 
GUIRequest $request
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Object-based submissions (ends up as static file)

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

ilExSubmissionTextGUI:

Definition at line 27 of file class.ilExSubmissionTextGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilExSubmissionTextGUI::__construct ( ilObjExercise  $a_exercise,
ilExSubmission  $a_submission 
)

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

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), ILIAS\Repository\help(), and ILIAS\Repository\user().

35  {
36  global $DIC;
37 
38  parent::__construct($a_exercise, $a_submission);
39  $this->user = $DIC->user();
40  $this->help = $DIC["ilHelp"];
41  }
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ editAssignmentTextObject()

ilExSubmissionTextGUI::editAssignmentTextObject ( ilPropertyFormGUI  $a_form = null)

Definition at line 160 of file class.ilExSubmissionTextGUI.php.

References ilExSubmissionBaseGUI\$ctrl, $help, ilRTE\_replaceMediaObjectImageSrc(), ilExSubmissionBaseGUI\handleTabs(), initAssignmentTextForm(), ILIAS\Repository\lng(), ilCtrl\redirect(), ilHelpGUI\setScreenIdComponent(), and ilExSubmissionBaseGUI\triggerAssignmentTool().

Referenced by updateAssignmentTextObject().

162  : void {
163  $ilCtrl = $this->ctrl;
164 
165  if (!$this->submission->canSubmit()) {
166  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("exercise_time_over"), true);
167  $ilCtrl->redirect($this, "returnToParent");
168  }
169 
170  $this->triggerAssignmentTool();
171 
172  $this->handleTabs();
173 
174  $ilHelp = $this->help;
175  $ilHelp->setScreenIdComponent("exc");
176  $ilHelp->setScreenId("text_submission");
177 
178  if ($a_form === null) {
179  $a_form = $this->initAssignmentTextForm();
180 
181  $files = $this->submission->getFiles();
182  if ($files !== []) {
183  $files = array_shift($files);
184  if (trim($files["atext"]) !== '' && trim($files["atext"]) !== '0') {
185  $text = $a_form->getItemByPostVar("atxt");
186  // mob id to mob src
187  $text->setValue(ilRTE::_replaceMediaObjectImageSrc($files["atext"], 1));
188  }
189  }
190  }
191 
192  $this->tpl->setContent($a_form->getHTML());
193  }
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
redirect(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
getItemByPostVar(string $a_post_var)
setScreenIdComponent(string $a_comp)
initAssignmentTextForm(bool $a_read_only=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilExSubmissionTextGUI::executeCommand ( )

Definition at line 43 of file class.ilExSubmissionTextGUI.php.

References ilExSubmissionBaseGUI\$ctrl, ilCtrl\getNextClass(), and ilExAssignment\TYPE_TEXT.

43  : void
44  {
45  $ilCtrl = $this->ctrl;
46 
47  if (!$this->assignment ||
48  $this->assignment->getType() != ilExAssignment::TYPE_TEXT ||
49  !$this->submission->canView()) {
50  return;
51  }
52 
53  $class = $ilCtrl->getNextClass($this);
54  $cmd = $ilCtrl->getCmd("showassignmenttext");
55 
56  switch ($class) {
57  default:
58  $this->{$cmd . "Object"}();
59  break;
60  }
61  }
getNextClass($a_gui_class=null)
+ Here is the call graph for this function:

◆ getOverviewContent()

static ilExSubmissionTextGUI::getOverviewContent ( ilInfoScreenGUI  $a_info,
ilExSubmission  $a_submission 
)
static

Definition at line 63 of file class.ilExSubmissionTextGUI.php.

References $DIC, ilExSubmissionBaseGUI\$lng, ilInfoScreenGUI\addProperty(), ilExSubmission\canSubmit(), ilLinkButton\getInstance(), and ilLanguage\txt().

66  : void {
67  global $DIC;
68 
69  $lng = $DIC->language();
70  $ilCtrl = $DIC->ctrl();
71 
72  $button = ilLinkButton::getInstance();
73  if ($a_submission->canSubmit()) {
74  $button->setPrimary(true);
75  $button->setCaption("exc_text_assignment_edit");
76  $button->setUrl($ilCtrl->getLinkTargetByClass(array("ilExSubmissionGUI", "ilExSubmissionTextGUI"), "editAssignmentText"));
77  } else {
78  $button->setCaption("exc_text_assignment_show");
79  $button->setUrl($ilCtrl->getLinkTargetByClass(array("ilExSubmissionGUI", "ilExSubmissionTextGUI"), "showAssignmentText"));
80  }
81  $files_str = $button->render();
82 
83  $a_info->addProperty($lng->txt("exc_files_returned_text"), $files_str);
84  }
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...
addProperty(string $a_name, string $a_value, string $a_link="")
add a property to current section
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

◆ initAssignmentTextForm()

ilExSubmissionTextGUI::initAssignmentTextForm ( bool  $a_read_only = false)
protected

Definition at line 91 of file class.ilExSubmissionTextGUI.php.

References ilExSubmissionBaseGUI\$ctrl, ilExSubmissionBaseGUI\$lng, ilObjAdvancedEditing\_getRichTextEditor(), ILIAS\Repository\lng(), ilFormPropertyGUI\setRequired(), ilLanguage\txt(), and ILIAS\Repository\user().

Referenced by editAssignmentTextObject(), showAssignmentTextObject(), and updateAssignmentTextObject().

94  $ilCtrl = $this->ctrl;
95  $lng = $this->lng;
96 
97  $form = new ilPropertyFormGUI();
98  $form->setTitle($this->lng->txt("exc_assignment") . " \"" . $this->assignment->getTitle() . "\"");
99 
100  if (!$a_read_only) {
101  $text = new ilTextAreaInputGUI($this->lng->txt("exc_your_text"), "atxt");
102  $text->setRequired(
103  $this->mandatory_manager->isMandatoryForUser($this->submission->getAssignment()->getId(), $this->user->getId())
104  );
105  $text->setRows(40);
106  $text->setMaxNumOfChars($this->assignment->getMaxCharLimit());
107  $text->setMinNumOfChars($this->assignment->getMinCharLimit());
108 
109  if ($text->isCharLimited()) {
110  $char_msg = "";
111  if ($this->assignment->getMinCharLimit() !== 0) {
112  $char_msg .= $lng->txt("exc_min_char_limit") . ": " . $this->assignment->getMinCharLimit();
113  }
114  if ($this->assignment->getMaxCharLimit() !== 0) {
115  $char_msg .= " " . $lng->txt("exc_max_char_limit") . ": " . $this->assignment->getMaxCharLimit();
116  }
117  $text->setInfo($char_msg);
118  }
119 
120  $form->addItem($text);
121 
122  if (ilObjAdvancedEditing::_getRichTextEditor() === "tinymce") {
123  // custom rte tags
124  $text->setUseRte(true);
125  $text->setRTESupport($this->submission->getUserId(), "exca~", "exc_ass");
126 
127  // see ilObjForumGUI
128  $text->disableButtons(array(
129  'charmap',
130  'undo',
131  'redo',
132  'alignleft',
133  'aligncenter',
134  'alignright',
135  'alignjustify',
136  'anchor',
137  'fullscreen',
138  'cut',
139  'copy',
140  'paste',
141  'pastetext',
142  'code',
143  // 'formatselect' #13234
144  ));
145  }
146 
147  $form->setFormAction($ilCtrl->getFormAction($this, "updateAssignmentText"));
148  $form->addCommandButton("updateAssignmentTextAndReturn", $this->lng->txt("save_return"));
149  $form->addCommandButton("updateAssignmentText", $this->lng->txt("save"));
150  $form->addCommandButton("returnToParent", $this->lng->txt("cancel"));
151  } else {
152  $form->setFormAction($ilCtrl->getFormAction($this, "returnToParent"));
153  $text = new ilNonEditableValueGUI($this->lng->txt("exc_files_returned_text"), "atxt", true);
154  $form->addItem($text);
155  }
156 
157  return $form;
158  }
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 _getRichTextEditor()
Returns the identifier for the Rich Text Editor.
setRequired(bool $a_required)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a text area property in a property form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showAssignmentTextObject()

ilExSubmissionTextGUI::showAssignmentTextObject ( )

Definition at line 258 of file class.ilExSubmissionTextGUI.php.

References ilRTE\_replaceMediaObjectImageSrc(), ilExSubmissionBaseGUI\handleTabs(), initAssignmentTextForm(), and ILIAS\Repository\lng().

258  : void
259  {
260  if (!$this->submission->isTutor()) {
261  $this->handleTabs();
262  }
263 
264  $a_form = $this->initAssignmentTextForm(true);
265 
266  $files = $this->submission->getFiles();
267  if ($files !== []) {
268  $files = array_shift($files);
269  if (trim($files["atext"]) !== '' && trim($files["atext"]) !== '0') {
270  if ($files["late"] &&
271  !$this->submission->hasPeerReviewAccess()) {
272  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("exc_late_submission"));
273  }
274 
275  $text = $a_form->getItemByPostVar("atxt");
276  // mob id to mob src
277  $text->setValue(nl2br(ilRTE::_replaceMediaObjectImageSrc($files["atext"], 1)));
278  }
279  }
280 
281  $this->tpl->setContent($a_form->getHTML());
282  }
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
initAssignmentTextForm(bool $a_read_only=false)
+ Here is the call graph for this function:

◆ updateAssignmentTextAndReturnObject()

ilExSubmissionTextGUI::updateAssignmentTextAndReturnObject ( )

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

References updateAssignmentTextObject().

195  : void
196  {
197  $this->updateAssignmentTextObject(true);
198  }
updateAssignmentTextObject(bool $a_return=false)
+ Here is the call graph for this function:

◆ updateAssignmentTextObject()

ilExSubmissionTextGUI::updateAssignmentTextObject ( bool  $a_return = false)
Exceptions
ilExcUnknownAssignmentTypeException
ilExerciseException

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

References ilExSubmissionBaseGUI\$ctrl, $mobs, ilObjMediaObject\_exists(), ilRTE\_getMediaObjects(), ilObjAdvancedEditing\_getUsedHTMLTags(), ilObjMediaObject\_removeUsage(), ilRTE\_replaceMediaObjectImageSrc(), ilObjMediaObject\_saveUsage(), editAssignmentTextObject(), ilExSubmissionBaseGUI\handleNewUpload(), ilExSubmissionBaseGUI\handleRemovedUpload(), initAssignmentTextForm(), ILIAS\Repository\lng(), and ilCtrl\redirect().

Referenced by updateAssignmentTextAndReturnObject().

206  : void {
207  $ilCtrl = $this->ctrl;
208 
209  if (!$this->submission->canSubmit()) {
210  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("exercise_time_over"), true);
211  $ilCtrl->redirect($this, "returnToParent");
212  }
213 
214  $form = $this->initAssignmentTextForm();
215 
216  // we are not using a purifier, so we have to set the valid RTE tags
217  // :TODO:
218  $rte = $form->getItemByPostVar("atxt");
219  $rte->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("exc_ass"));
220 
221  if ($form->checkInput()) {
222  $text = trim($form->getInput("atxt"));
223 
224  $returned_id = $this->submission->updateTextSubmission(
225  // mob src to mob id
227  );
228 
229  // no empty text
230  if ($returned_id) {
231  // #16532 - always send notifications
232  $this->handleNewUpload();
233 
234  // mob usage
235  $mobs = ilRTE::_getMediaObjects($text, 0);
236  foreach ($mobs as $mob) {
237  if (ilObjMediaObject::_exists($mob)) {
238  ilObjMediaObject::_removeUsage($mob, 'exca~:html', $this->submission->getUserId());
239  ilObjMediaObject::_saveUsage($mob, 'exca:html', $returned_id);
240  }
241  }
242  } else {
243  $this->handleRemovedUpload();
244  }
245 
246  $this->tpl->setOnScreenMessage('success', $this->lng->txt("exc_text_saved"), true);
247  if ($a_return) {
248  $ilCtrl->redirect($this, "returnToParent");
249  } else {
250  $ilCtrl->redirect($this, "editAssignmentText");
251  }
252  }
253 
254  $form->setValuesByPost();
255  $this->editAssignmentTextObject($form);
256  }
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
static _getMediaObjects(string $a_text, int $a_direction=0)
Returns all media objects found in the passed string.
handleNewUpload(bool $a_no_notifications=false)
$mobs
Definition: imgupload.php:70
redirect(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
static _saveUsage(int $a_mob_id, string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
Save usage of mob within another container (e.g.
editAssignmentTextObject(ilPropertyFormGUI $a_form=null)
static _exists(int $id, bool $reference=false, ?string $type=null)
static _removeUsage(int $a_mob_id, string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
Remove usage of mob in another container.
initAssignmentTextForm(bool $a_read_only=false)
static _getUsedHTMLTags(string $a_module="")
Returns an array of all allowed HTML tags for text editing.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $help

ilHelpGUI ilExSubmissionTextGUI::$help
protected

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

Referenced by editAssignmentTextObject().

◆ $user

ilObjUser ilExSubmissionTextGUI::$user
protected

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


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