ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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
 __construct (ilObjExercise $a_exercise, ilExSubmission $a_submission)
 
 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
ILIAS Exercise Notification NotificationManager $notification
 
ILIAS Exercise InternalDomainService $domain
 
ILIAS Exercise InternalGUIService $gui
 
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\MetaData\Repository\Validation\Data\__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(VocabulariesInterface $vocabularies)
+ Here is the call graph for this function:

Member Function Documentation

◆ editAssignmentTextObject()

ilExSubmissionTextGUI::editAssignmentTextObject ( ilPropertyFormGUI  $a_form = null)

Definition at line 163 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().

165  : void {
166  $ilCtrl = $this->ctrl;
167 
168  if (!$this->submission->canSubmit()) {
169  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("exercise_time_over"), true);
170  $ilCtrl->redirect($this, "returnToParent");
171  }
172 
173  $this->triggerAssignmentTool();
174 
175  $this->handleTabs();
176 
177  $ilHelp = $this->help;
178  $ilHelp->setScreenIdComponent("exc");
179  $ilHelp->setScreenId("text_submission");
180 
181  if ($a_form === null) {
182  $a_form = $this->initAssignmentTextForm();
183 
184  $files = $this->submission->getFiles();
185  if ($files !== []) {
186  $files = array_shift($files);
187  if (trim($files["atext"]) !== '' && trim($files["atext"]) !== '0') {
188  $text = $a_form->getItemByPostVar("atxt");
189  // mob id to mob src
190  $text->setValue(ilRTE::_replaceMediaObjectImageSrc($files["atext"], 1));
191  }
192  }
193  }
194 
195  $this->tpl->setContent($a_form->getHTML());
196  }
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\$gui, ilExSubmissionBaseGUI\$lng, ilInfoScreenGUI\addProperty(), ilExSubmission\canSubmit(), and ilLanguage\txt().

66  : void {
67  global $DIC;
68 
69  $lng = $DIC->language();
70  $ilCtrl = $DIC->ctrl();
71  $gui = $DIC->exercise()->internal()->gui();
72 
73  if ($a_submission->canSubmit()) {
74  $link = $gui->link(
75  $lng->txt("exc_text_assignment_edit"),
76  $ilCtrl->getLinkTargetByClass(array(ilAssignmentPresentationGUI::class, "ilExSubmissionGUI", "ilExSubmissionTextGUI"), "editAssignmentText")
77  )->primary();
78  } else {
79  $link = $gui->link(
80  $lng->txt("exc_text_assignment_show"),
81  $ilCtrl->getLinkTargetByClass(array(ilAssignmentPresentationGUI::class, "ilExSubmissionGUI", "ilExSubmissionTextGUI"), "showAssignmentText")
82  )->emphasised();
83  }
84  $files_str = $link->render();
85 
86  $a_info->addProperty($lng->txt("exc_files_returned_text"), $files_str);
87  }
ILIAS Exercise InternalGUIService $gui
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 94 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().

97  $ilCtrl = $this->ctrl;
98  $lng = $this->lng;
99 
100  $form = new ilPropertyFormGUI();
101  $form->setTitle($this->lng->txt("exc_assignment") . " \"" . $this->assignment->getTitle() . "\"");
102 
103  if (!$a_read_only) {
104  $text = new ilTextAreaInputGUI($this->lng->txt("exc_your_text"), "atxt");
105  $text->setRequired(
106  $this->mandatory_manager->isMandatoryForUser($this->submission->getAssignment()->getId(), $this->user->getId())
107  );
108  $text->setRows(15);
109  $text->setMaxNumOfChars($this->assignment->getMaxCharLimit());
110  $text->setMinNumOfChars($this->assignment->getMinCharLimit());
111 
112  if ($text->isCharLimited()) {
113  $char_msg = "";
114  if ($this->assignment->getMinCharLimit() !== 0) {
115  $char_msg .= $lng->txt("exc_min_char_limit") . ": " . $this->assignment->getMinCharLimit();
116  }
117  if ($this->assignment->getMaxCharLimit() !== 0) {
118  $char_msg .= " " . $lng->txt("exc_max_char_limit") . ": " . $this->assignment->getMaxCharLimit();
119  }
120  $text->setInfo($char_msg);
121  }
122 
123  $form->addItem($text);
124 
125  if (ilObjAdvancedEditing::_getRichTextEditor() === "tinymce") {
126  // custom rte tags
127  $text->setUseRte(true);
128  $text->setRTESupport($this->submission->getUserId(), "exca~", "exc_ass");
129 
130  // see ilObjForumGUI
131  $text->disableButtons(array(
132  'charmap',
133  'undo',
134  'redo',
135  'alignleft',
136  'aligncenter',
137  'alignright',
138  'alignjustify',
139  'anchor',
140  'fullscreen',
141  'cut',
142  'copy',
143  'paste',
144  'pastetext',
145  'code',
146  // 'formatselect' #13234
147  ));
148  }
149 
150  $form->setFormAction($ilCtrl->getFormAction($this, "updateAssignmentText"));
151  $form->addCommandButton("updateAssignmentTextAndReturn", $this->lng->txt("save_return"));
152  $form->addCommandButton("updateAssignmentText", $this->lng->txt("save"));
153  $form->addCommandButton("returnToParent", $this->lng->txt("cancel"));
154  } else {
155  $form->setFormAction($ilCtrl->getFormAction($this, "returnToParent"));
156  $text = new ilNonEditableValueGUI($this->lng->txt("exc_files_returned_text"), "atxt", true);
157  $form->addItem($text);
158  }
159 
160  return $form;
161  }
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 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 261 of file class.ilExSubmissionTextGUI.php.

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

261  : void
262  {
263  if (!$this->submission->isTutor()) {
264  $this->handleTabs();
265  }
266 
267  $a_form = $this->initAssignmentTextForm(true);
268 
269  $files = $this->submission->getFiles();
270  if ($files !== []) {
271  $files = array_shift($files);
272  if (trim($files["atext"]) !== '' && trim($files["atext"]) !== '0') {
273  if ($files["late"] &&
274  !$this->submission->hasPeerReviewAccess()) {
275  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("exc_late_submission"));
276  }
277 
278  $text = $a_form->getItemByPostVar("atxt");
279  // mob id to mob src
280  $text->setValue(nl2br(ilRTE::_replaceMediaObjectImageSrc($files["atext"], 1)));
281  }
282  }
283  $this->tpl->setContent($a_form->getHTML());
284  }
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 198 of file class.ilExSubmissionTextGUI.php.

References updateAssignmentTextObject().

198  : void
199  {
200  $this->updateAssignmentTextObject(true);
201  }
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 207 of file class.ilExSubmissionTextGUI.php.

References ilExSubmissionBaseGUI\$ctrl, 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().

209  : void {
210  $ilCtrl = $this->ctrl;
211 
212  if (!$this->submission->canSubmit()) {
213  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("exercise_time_over"), true);
214  $ilCtrl->redirect($this, "returnToParent");
215  }
216 
217  $form = $this->initAssignmentTextForm();
218 
219  // we are not using a purifier, so we have to set the valid RTE tags
220  // :TODO:
221  $rte = $form->getItemByPostVar("atxt");
222  $rte->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("exc_ass"));
223 
224  if ($form->checkInput()) {
225  $text = trim($form->getInput("atxt"));
226 
227  $returned_id = $this->submission->updateTextSubmission(
228  // mob src to mob id
230  );
231 
232  // no empty text
233  if ($returned_id) {
234  // #16532 - always send notifications
235  $this->handleNewUpload();
236 
237  // mob usage
238  $mobs = ilRTE::_getMediaObjects($text, 0);
239  foreach ($mobs as $mob) {
240  if (ilObjMediaObject::_exists($mob)) {
241  ilObjMediaObject::_removeUsage($mob, 'exca~:html', $this->submission->getUserId());
242  ilObjMediaObject::_saveUsage($mob, 'exca:html', $returned_id);
243  }
244  }
245  } else {
246  $this->handleRemovedUpload();
247  }
248 
249  $this->tpl->setOnScreenMessage('success', $this->lng->txt("exc_text_saved"), true);
250  if ($a_return) {
251  $ilCtrl->redirect($this, "returnToParent");
252  } else {
253  $ilCtrl->redirect($this, "editAssignmentText");
254  }
255  }
256 
257  $form->setValuesByPost();
258  $this->editAssignmentTextObject($form);
259  }
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)
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: