ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
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)
 
 autoSaveObject ()
 
 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 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

ILIAS Exercise Submission SubmissionManager $sub_manager
 
ilObjUser $user
 
ilHelpGUI $help
 
- Protected Attributes inherited from ilExSubmissionBaseGUI
ILIAS Exercise Notification NotificationManager $notification
 
ILIAS Exercise InternalDomainService $domain
 
ILIAS Exercise InternalGUIService $gui
 
ilObjUser $user
 
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

@ilCtrl_Calls ilExSubmissionTextGUI:

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

Constructor & Destructor Documentation

◆ __construct()

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

Reimplemented from ilExSubmissionBaseGUI.

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

36 {
37 global $DIC;
38
39 parent::__construct($a_exercise, $a_submission);
40 $this->user = $DIC->user();
41 $this->help = $DIC["ilHelp"];
42 $this->sub_manager = $DIC->exercise()->internal()->domain()->submission(
43 $a_submission->getAssignment()->getId()
44 );
45 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

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

+ Here is the call graph for this function:

Member Function Documentation

◆ autoSaveObject()

ilExSubmissionTextGUI::autoSaveObject ( )

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

255 : void
256 {
257 $ilCtrl = $this->ctrl;
258
259 if (!$this->submission->canSubmit()) {
260 return;
261 }
262
263 $form = $this->initAssignmentTextForm();
264
265 // we are not using a purifier, so we have to set the valid RTE tags
266 // :TODO:
267 $rte = $form->getItemByPostVar("atxt");
268 $rte->setRteTags(ilRTESettings::_getUsedHTMLTags("exc_ass"));
269
270 if ($form->checkInput()) {
271 $text = trim($form->getInput("atxt"));
272
273 $returned_id = $this->submission->updateTextSubmission(
274 // mob src to mob id
276 );
277
278 // no empty text
279 if ($returned_id) {
280 // mob usage
281 $mobs = ilRTE::_getMediaObjects($text, 0);
282 foreach ($mobs as $mob) {
283 if (ilObjMediaObject::_exists($mob)) {
284 ilObjMediaObject::_removeUsage($mob, 'exca~:html', $this->submission->getUserId());
285 ilObjMediaObject::_saveUsage($mob, 'exca:html', $returned_id);
286 }
287 }
288 } else {
289 $this->handleRemovedUpload();
290 }
291 }
292 }
initAssignmentTextForm(bool $a_read_only=false)
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
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.
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.
static _getUsedHTMLTags(string $module='')
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.
$text
Definition: xapiexit.php:21

References $text, ilObjMediaObject\_exists(), ilRTE\_getMediaObjects(), ilRTESettings\_getUsedHTMLTags(), ilObjMediaObject\_removeUsage(), ilRTE\_replaceMediaObjectImageSrc(), and ilObjMediaObject\_saveUsage().

+ Here is the call graph for this function:

◆ editAssignmentTextObject()

ilExSubmissionTextGUI::editAssignmentTextObject ( ?ilPropertyFormGUI  $a_form = null)

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

149 : void {
150 $ilCtrl = $this->ctrl;
151
152 if (!$this->submission->canSubmit()) {
153 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("exercise_time_over"), true);
154 $ilCtrl->redirect($this, "returnToParent");
155 }
156
157 $this->triggerAssignmentTool();
158
159 $this->handleTabs();
160
161 $ilHelp = $this->help;
162 $ilHelp->setScreenIdComponent("exc");
163 $ilHelp->setScreenId("text_submission");
164
165 if ($a_form === null) {
166 $a_form = $this->initAssignmentTextForm();
167
168 $sub = $this->sub_manager->getSubmissionsOfUser($this->submission->getUserId())->current();
169 if ($sub) {
170 if (trim($sub->getText()) !== '' && trim($sub->getText()) !== '0') {
171 $text = $a_form->getItemByPostVar("atxt");
172 // mob id to mob src
173 $text->setValue(ilRTE::_replaceMediaObjectImageSrc($sub->getText(), 1));
174 }
175 }
176 }
177
178 $this->tpl->addJavaScript("assets/js/exc-auto-saver.js");
179 $this->lng->toJS("exc_auto_saved_minutes_s");
180 $this->lng->toJS("exc_auto_saved_minutes_p");
181 $mess_tpl = new ilTemplate("tpl.exc_auto_save_mess.html", true, true, "components/ILIAS/Exercise");
182 $mess_tpl->setVariable("MESS", $this->lng->txt("exc_auto_save_info"));
183 $mess_tpl->setVariable("MESS_LAST_SAVE", $this->lng->txt("exc_auto_last_save"));
184 $mbox = $this->gui->ui()->factory()->messageBox()->info($mess_tpl->get());
185 $sec_tpl = new ilTemplate("tpl.exc_auto_save_section.html", true, true, "components/ILIAS/Exercise");
186 $sec_tpl->setVariable("AUTO_SAVE_URL", $ilCtrl->getLinkTargetByClass(self::class, "autoSave"));
187 $sec_tpl->setVariable("MBOX", $this->gui->ui()->renderer()->render($mbox));
188 $sec_tpl->setVariable("FORM", $a_form->getHTML());
189 $this->tpl->setContent($sec_tpl->get());
190 }
redirect(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
@inheritDoc
setScreenIdComponent(string $a_comp)
special template class to simplify handling of ITX/PEAR

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ executeCommand()

ilExSubmissionTextGUI::executeCommand ( )

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

47 : void
48 {
49 $ilCtrl = $this->ctrl;
50
51 if (!$this->assignment ||
52 $this->assignment->getType() != ilExAssignment::TYPE_TEXT ||
53 !$this->submission->canView()) {
54 return;
55 }
56
57 $class = $ilCtrl->getNextClass($this);
58 $cmd = $ilCtrl->getCmd("showassignmenttext");
59
60 switch ($class) {
61 default:
62 $this->{$cmd . "Object"}();
63 break;
64 }
65 }
getNextClass($a_gui_class=null)
@inheritDoc

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

+ Here is the call graph for this function:

◆ getOverviewContent()

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

Reimplemented from ilExSubmissionBaseGUI.

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

70 : void {
71 global $DIC;
72
73 $lng = $DIC->language();
74 $ilCtrl = $DIC->ctrl();
75 $gui = $DIC->exercise()->internal()->gui();
76
77 if ($a_submission->canSubmit()) {
78 $link = $gui->link(
79 $lng->txt("exc_text_assignment_edit"),
80 $ilCtrl->getLinkTargetByClass(array(ilAssignmentPresentationGUI::class, "ilExSubmissionGUI", "ilExSubmissionTextGUI"), "editAssignmentText")
81 )->primary();
82 } else {
83 $link = $gui->link(
84 $lng->txt("exc_text_assignment_show"),
85 $ilCtrl->getLinkTargetByClass(array(ilAssignmentPresentationGUI::class, "ilExSubmissionGUI", "ilExSubmissionTextGUI"), "showAssignmentText")
86 )->emphasised();
87 }
88 $files_str = $link->render();
89
90 $a_info->addProperty($lng->txt("exc_files_returned_text"), $files_str);
91 }
ILIAS Exercise InternalGUIService $gui
addProperty(string $a_name, string $a_value, string $a_link="")
add a property to current section
txt(string|LanguageIdentifier $a_topic, ?int $n=null)
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...

References ilExSubmissionBaseGUI\$gui, ilExSubmissionBaseGUI\$lng, and ilLanguage\txt().

+ Here is the call graph for this function:

◆ initAssignmentTextForm()

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

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

101 $ilCtrl = $this->ctrl;
103
104 $form = new ilPropertyFormGUI();
105 $form->setTitle($this->lng->txt("exc_assignment") . " \"" . $this->assignment->getTitle() . "\"");
106
107 if (!$a_read_only) {
108 $text = new ilTextAreaInputGUI($this->lng->txt("exc_your_text"), "atxt");
109 $text->setRequired(
110 $this->mandatory_manager->isMandatoryForUser($this->submission->getAssignment()->getId(), $this->user->getId())
111 );
112 $text->setRows(15);
113 $text->setMaxNumOfChars($this->assignment->getMaxCharLimit());
114 $text->setMinNumOfChars($this->assignment->getMinCharLimit());
115
116 if ($text->isCharLimited()) {
117 $char_msg = "";
118 if ($this->assignment->getMinCharLimit() !== 0) {
119 $char_msg .= $lng->txt("exc_min_char_limit") . ": " . $this->assignment->getMinCharLimit();
120 }
121 if ($this->assignment->getMaxCharLimit() !== 0) {
122 $char_msg .= " " . $lng->txt("exc_max_char_limit") . ": " . $this->assignment->getMaxCharLimit();
123 }
124 $text->setInfo($char_msg);
125 }
126
127 $form->addItem($text);
128
129 if ((new ilRTESettings($this->lng, $this->user))->getRichTextEditor() === "tinymce") {
130 $text->setUseRte(true);
131 $text->setRteTagSet("mini");
132 }
133
134 $form->setFormAction($ilCtrl->getFormAction($this, "updateAssignmentText"));
135 $form->addCommandButton("updateAssignmentTextAndReturn", $this->lng->txt("save_return"));
136 $form->addCommandButton("updateAssignmentText", $this->lng->txt("save"));
137 $form->addCommandButton("returnToParent", $this->lng->txt("cancel"));
138 } else {
139 $form->setFormAction($ilCtrl->getFormAction($this, "returnToParent"));
140 $text = new ilNonEditableValueGUI($this->lng->txt("exc_files_returned_text"), "atxt", true);
141 $form->addItem($text);
142 }
143
144 return $form;
145 }
This class represents a non editable value in a property form.
This class represents a property form user interface.
This class represents a text area property in a property form.

◆ showAssignmentTextObject()

ilExSubmissionTextGUI::showAssignmentTextObject ( )

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

294 : void
295 {
296 if (!$this->submission->isTutor()) {
297 $this->handleTabs();
298 }
299
300 $a_form = $this->initAssignmentTextForm(true);
301
302 $sub = $this->sub_manager->getSubmissionsOfUser($this->submission->getUserId())->current();
303 if ($sub) {
304 if (trim($sub->getText()) !== '' && trim($sub->getText()) !== '0') {
305 if ($sub->getLate() &&
306 !$this->submission->hasPeerReviewAccess()) {
307 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("exc_late_submission"));
308 }
309
310 $text = $a_form->getItemByPostVar("atxt");
311 // mob id to mob src
312 $val = $this->gui->getUIUtil()->formatTextInput($sub->getText());
313 $val = $this->gui->html()->escapeCurly($val);
314 $text->setValue($val);
315 }
316 }
317 $this->tpl->setContent($a_form->getHTML());
318 }

References $text, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ updateAssignmentTextAndReturnObject()

ilExSubmissionTextGUI::updateAssignmentTextAndReturnObject ( )

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

192 : void
193 {
194 $this->updateAssignmentTextObject(true);
195 }
updateAssignmentTextObject(bool $a_return=false)

◆ updateAssignmentTextObject()

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

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

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

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

Field Documentation

◆ $help

ilHelpGUI ilExSubmissionTextGUI::$help
protected

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

◆ $sub_manager

ILIAS Exercise Submission SubmissionManager ilExSubmissionTextGUI::$sub_manager
protected

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

◆ $user

ilObjUser ilExSubmissionTextGUI::$user
protected

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


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