ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator 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
 __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

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
 
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 33 of file class.ilExSubmissionTextGUI.php.

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

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  }
global $DIC
Definition: shib_login.php:22
__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 147 of file class.ilExSubmissionTextGUI.php.

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

Referenced by updateAssignmentTextObject().

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->setContent($a_form->getHTML());
179  }
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...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
redirect(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
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 47 of file class.ilExSubmissionTextGUI.php.

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

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

◆ getOverviewContent()

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

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

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

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
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: shib_login.php:22
+ 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.

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

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

101  $ilCtrl = $this->ctrl;
102  $lng = $this->lng;
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 (ilObjAdvancedEditing::_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  }
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 244 of file class.ilExSubmissionTextGUI.php.

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

244  : void
245  {
246  if (!$this->submission->isTutor()) {
247  $this->handleTabs();
248  }
249 
250  $a_form = $this->initAssignmentTextForm(true);
251 
252  $sub = $this->sub_manager->getSubmissionsOfUser($this->submission->getUserId())->current();
253  if ($sub) {
254  if (trim($sub->getText()) !== '' && trim($sub->getText()) !== '0') {
255  if ($sub->getLate() &&
256  !$this->submission->hasPeerReviewAccess()) {
257  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("exc_late_submission"));
258  }
259 
260  $text = $a_form->getItemByPostVar("atxt");
261  // mob id to mob src
262  $text->setValue(nl2br(ilRTE::_replaceMediaObjectImageSrc($sub->getText(), 1)));
263  }
264  }
265  $this->tpl->setContent($a_form->getHTML());
266  }
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 181 of file class.ilExSubmissionTextGUI.php.

References updateAssignmentTextObject().

181  : void
182  {
183  $this->updateAssignmentTextObject(true);
184  }
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 190 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().

192  : void {
193  $ilCtrl = $this->ctrl;
194 
195  if (!$this->submission->canSubmit()) {
196  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("exercise_time_over"), true);
197  $ilCtrl->redirect($this, "returnToParent");
198  }
199 
200  $form = $this->initAssignmentTextForm();
201 
202  // we are not using a purifier, so we have to set the valid RTE tags
203  // :TODO:
204  $rte = $form->getItemByPostVar("atxt");
205  $rte->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("exc_ass"));
206 
207  if ($form->checkInput()) {
208  $text = trim($form->getInput("atxt"));
209 
210  $returned_id = $this->submission->updateTextSubmission(
211  // mob src to mob id
213  );
214 
215  // no empty text
216  if ($returned_id) {
217  // #16532 - always send notifications
218  $this->handleNewUpload();
219 
220  // mob usage
221  $mobs = ilRTE::_getMediaObjects($text, 0);
222  foreach ($mobs as $mob) {
223  if (ilObjMediaObject::_exists($mob)) {
224  ilObjMediaObject::_removeUsage($mob, 'exca~:html', $this->submission->getUserId());
225  ilObjMediaObject::_saveUsage($mob, 'exca:html', $returned_id);
226  }
227  }
228  } else {
229  $this->handleRemovedUpload();
230  }
231 
232  $this->tpl->setOnScreenMessage('success', $this->lng->txt("exc_text_saved"), true);
233  if ($a_return) {
234  $ilCtrl->redirect($this, "returnToParent");
235  } else {
236  $ilCtrl->redirect($this, "editAssignmentText");
237  }
238  }
239 
240  $form->setValuesByPost();
241  $this->editAssignmentTextObject($form);
242  }
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)
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.
redirect(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
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 31 of file class.ilExSubmissionTextGUI.php.

Referenced by editAssignmentTextObject().

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