ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilExSubmissionTextGUI Class Reference

Object-based submissions (ends up as static file) More...

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

Public Member Functions

 __construct (ilObjExercise $a_exercise, ilExSubmission $a_submission)
 Constructor. More...
 
 executeCommand ()
 
 editAssignmentTextObject (ilPropertyFormGUI $a_form=null)
 
 updateAssignmentTextAndReturnObject ()
 
 updateAssignmentTextObject ($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 ($a_read_only=false)
 
- Protected Member Functions inherited from ilExSubmissionBaseGUI
 handleTabs ()
 
 handleNewUpload ($a_no_notifications=false)
 
 handleRemovedUpload ()
 

Protected Attributes

 $user
 
 $help
 
- Protected Attributes inherited from ilExSubmissionBaseGUI
 $ctrl
 
 $tabs_gui
 
 $lng
 
 $tpl
 
 $exercise
 
 $submission
 
 $assignment
 

Detailed Description

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

ilExSubmissionTextGUI:

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

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

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

References $DIC, and user().

29  {
30  global $DIC;
31 
32  parent::__construct($a_exercise, $a_submission);
33  $this->user = $DIC->user();
34  $this->help = $DIC["ilHelp"];
35  }
global $DIC
Definition: saml.php:7
user()
Definition: user.php:4
+ Here is the call graph for this function:

Member Function Documentation

◆ editAssignmentTextObject()

ilExSubmissionTextGUI::editAssignmentTextObject ( ilPropertyFormGUI  $a_form = null)

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

References ilExSubmissionBaseGUI\$ctrl, $files, $help, $ilCtrl, $ilUser, $text, $user, ilRTE\_replaceMediaObjectImageSrc(), ilDatePresentation\formatDate(), ilExSubmissionBaseGUI\handleTabs(), IL_CAL_UNIX, initAssignmentTextForm(), ilUtil\sendFailure(), ilUtil\sendInfo(), and time.

Referenced by updateAssignmentTextObject().

151  {
154 
155  if (!$this->submission->canSubmit()) {
156  ilUtil::sendFailure($this->lng->txt("exercise_time_over"), true);
157  $ilCtrl->redirect($this, "returnToParent");
158  }
159 
160  $deadline = max($this->assignment->getDeadline(), $this->assignment->getExtendedDeadline());
161  if ($deadline) {
162  $deadline = $this->assignment->getPersonalDeadline($ilUser->getId());
163 
164  // extended deadline date should not be presented anywhere
165  // see ilExAssignmentGUI::addSchedule()
166  $dl_info = ilDatePresentation::formatDate(new ilDateTime($deadline, IL_CAL_UNIX));
167 
168  // #16151 - extended deadline warning (only after deadline passed)
169  if ($deadline < time()) {
171  $dl = '<br /><span class="warning">' . sprintf($this->lng->txt("exc_late_submission_warning"), $dl) . '</span>';
172  $dl_info .= $dl;
173  }
174 
175  ilUtil::sendInfo($this->lng->txt("exc_edit_until") . ": " . $dl_info);
176  }
177 
178  $this->handleTabs();
179 
180  $ilHelp = $this->help;
181  $ilHelp->setScreenIdComponent("exc");
182  $ilHelp->setScreenId("text_submission");
183 
184  if (!$a_form) {
185  $a_form = $this->initAssignmentTextForm();
186 
187  $files = $this->submission->getFiles();
188  if ($files) {
189  $files = array_shift($files);
190  if (trim($files["atext"])) {
191  $text = $a_form->getItemByPostVar("atxt");
192  // mob id to mob src
193  $text->setValue(ilRTE::_replaceMediaObjectImageSrc($files["atext"], 1));
194  }
195  }
196  }
197 
198  $this->tpl->setContent($a_form->getHTML());
199  }
$files
Definition: add-vimline.php:18
getItemByPostVar($a_post_var)
Get Item by POST variable.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date public.
initAssignmentTextForm($a_read_only=false)
const IL_CAL_UNIX
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$text
Definition: errorreport.php:18
Date and time handling
$ilUser
Definition: imgupload.php:18
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilExSubmissionTextGUI::executeCommand ( )

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

References ilExSubmissionBaseGUI\$ctrl, $ilCtrl, and ilExAssignment\TYPE_TEXT.

38  {
40 
41  if (!$this->assignment ||
42  $this->assignment->getType() != ilExAssignment::TYPE_TEXT ||
43  !$this->submission->canView()) {
44  return;
45  }
46 
47  $class = $ilCtrl->getNextClass($this);
48  $cmd = $ilCtrl->getCmd("showassignmenttext");
49 
50  switch ($class) {
51  default:
52  $this->{$cmd . "Object"}();
53  break;
54  }
55  }
global $ilCtrl
Definition: ilias.php:18

◆ getOverviewContent()

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

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

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

58  {
59  global $DIC;
60 
61  $lng = $DIC->language();
62  $ilCtrl = $DIC->ctrl();
63 
64  if ($a_submission->canSubmit()) {
65  $button = ilLinkButton::getInstance();
66  $button->setPrimary(true);
67  $button->setCaption("exc_text_assignment_edit");
68  $button->setUrl($ilCtrl->getLinkTargetByClass(array("ilExSubmissionGUI", "ilExSubmissionTextGUI"), "editAssignmentText"));
69  $files_str = $button->render();
70  } else {
71  $button = ilLinkButton::getInstance();
72  $button->setCaption("exc_text_assignment_show");
73  $button->setUrl($ilCtrl->getLinkTargetByClass(array("ilExSubmissionGUI", "ilExSubmissionTextGUI"), "showAssignmentText"));
74  $files_str = $button->render();
75  }
76 
77  $a_info->addProperty($lng->txt("exc_files_returned_text"), $files_str);
78  }
global $DIC
Definition: saml.php:7
global $ilCtrl
Definition: ilias.php:18
Create styles array
The data for the language used.
addProperty($a_name, $a_value, $a_link="")
add a property to current section
+ Here is the call graph for this function:

◆ initAssignmentTextForm()

ilExSubmissionTextGUI::initAssignmentTextForm (   $a_read_only = false)
protected

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

References ilExSubmissionBaseGUI\$ctrl, $form, $ilCtrl, ilExSubmissionBaseGUI\$lng, $text, and array.

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

86  {
88  $lng = $this->lng;
89 
90  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
91  $form = new ilPropertyFormGUI();
92  $form->setTitle($this->lng->txt("exc_assignment") . " \"" . $this->assignment->getTitle() . "\"");
93 
94  if (!$a_read_only) {
95  $text = new ilTextAreaInputGUI($this->lng->txt("exc_your_text"), "atxt");
96  $text->setRequired((bool) $this->submission->getAssignment()->getMandatory());
97  $text->setRows(40);
98  $text->setMaxNumOfChars($this->assignment->getMaxCharLimit());
99  $text->setMinNumOfChars($this->assignment->getMinCharLimit());
100 
101  if ($text->isCharLimited()) {
102  $char_msg = "";
103  if ($this->assignment->getMinCharLimit()) {
104  $char_msg .= $lng->txt("exc_min_char_limit") . ": " . $this->assignment->getMinCharLimit();
105  }
106  if ($this->assignment->getMaxCharLimit()) {
107  $char_msg .= " " . $lng->txt("exc_max_char_limit") . ": " . $this->assignment->getMaxCharLimit();
108  }
109  $text->setInfo($char_msg);
110  }
111 
112  $form->addItem($text);
113 
114  // custom rte tags
115  $text->setUseRte(true);
116  $text->setRTESupport($this->submission->getUserId(), "exca~", "exc_ass");
117 
118  // see ilObjForumGUI
119  $text->disableButtons(array(
120  'charmap',
121  'undo',
122  'redo',
123  'justifyleft',
124  'justifycenter',
125  'justifyright',
126  'justifyfull',
127  'anchor',
128  'fullscreen',
129  'cut',
130  'copy',
131  'paste',
132  'pastetext',
133  'code',
134  // 'formatselect' #13234
135  ));
136 
137  $form->setFormAction($ilCtrl->getFormAction($this, "updateAssignmentText"));
138  $form->addCommandButton("updateAssignmentTextAndReturn", $this->lng->txt("save_return"));
139  $form->addCommandButton("updateAssignmentText", $this->lng->txt("save"));
140  $form->addCommandButton("returnToParent", $this->lng->txt("cancel"));
141  } else {
142  $form->setFormAction($ilCtrl->getFormAction($this, "returnToParent"));
143  $text = new ilNonEditableValueGUI($this->lng->txt("exc_files_returned_text"), "atxt", true);
144  $form->addItem($text);
145  }
146 
147  return $form;
148  }
This class represents a property form user interface.
global $ilCtrl
Definition: ilias.php:18
if(isset($_POST['submit'])) $form
$text
Definition: errorreport.php:18
Create styles array
The data for the language used.
This class represents a non editable value in a property form.
This class represents a text area property in a property form.
+ Here is the caller graph for this function:

◆ showAssignmentTextObject()

ilExSubmissionTextGUI::showAssignmentTextObject ( )

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

References $files, $text, ilRTE\_replaceMediaObjectImageSrc(), ilExSubmissionBaseGUI\handleTabs(), initAssignmentTextForm(), and ilUtil\sendFailure().

264  {
265  if (!$this->submission->isTutor()) {
266  $this->handleTabs();
267  }
268 
269  $a_form = $this->initAssignmentTextForm(true);
270 
271  $files = $this->submission->getFiles();
272  if ($files) {
273  $files = array_shift($files);
274  if (trim($files["atext"])) {
275  if ($files["late"] &&
276  !$this->submission->hasPeerReviewAccess()) {
277  ilUtil::sendFailure($this->lng->txt("exc_late_submission"));
278  }
279 
280  $text = $a_form->getItemByPostVar("atxt");
281  // mob id to mob src
282  $text->setValue(nl2br(ilRTE::_replaceMediaObjectImageSrc($files["atext"], 1)));
283  }
284  }
285 
286  $this->tpl->setContent($a_form->getHTML());
287  }
$files
Definition: add-vimline.php:18
initAssignmentTextForm($a_read_only=false)
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
$text
Definition: errorreport.php:18
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:

◆ updateAssignmentTextAndReturnObject()

ilExSubmissionTextGUI::updateAssignmentTextAndReturnObject ( )

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

References updateAssignmentTextObject().

202  {
203  $this->updateAssignmentTextObject(true);
204  }
+ Here is the call graph for this function:

◆ updateAssignmentTextObject()

ilExSubmissionTextGUI::updateAssignmentTextObject (   $a_return = false)

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

References ilExSubmissionBaseGUI\$ctrl, $form, $ilCtrl, $mobs, $text, ilObjMediaObject\_exists(), ilRTE\_getMediaObjects(), ilObjAdvancedEditing\_getUsedHTMLTags(), ilObjMediaObject\_removeUsage(), ilRTE\_replaceMediaObjectImageSrc(), ilObjMediaObject\_saveUsage(), editAssignmentTextObject(), ilExSubmissionBaseGUI\handleNewUpload(), ilExSubmissionBaseGUI\handleRemovedUpload(), initAssignmentTextForm(), ilUtil\sendFailure(), and ilUtil\sendSuccess().

Referenced by updateAssignmentTextAndReturnObject().

207  {
209 
210  if (!$this->submission->canSubmit()) {
211  ilUtil::sendFailure($this->lng->txt("exercise_time_over"), true);
212  $ilCtrl->redirect($this, "returnToParent");
213  }
214 
215  $form = $this->initAssignmentTextForm();
216 
217  // we are not using a purifier, so we have to set the valid RTE tags
218  // :TODO:
219  include_once("./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php");
220  $rte = $form->getItemByPostVar("atxt");
221  $rte->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("exc_ass"));
222 
223  if ($form->checkInput()) {
224  $text = trim($form->getInput("atxt"));
225 
226  $existing = $this->submission->getFiles();
227 
228  $returned_id = $this->submission->updateTextSubmission(
229  // mob src to mob id
231  );
232 
233  // no empty text
234  if ($returned_id) {
235  // #16532 - always send notifications
236  $this->handleNewUpload();
237 
238  // mob usage
239  include_once "Services/MediaObjects/classes/class.ilObjMediaObject.php";
241  foreach ($mobs as $mob) {
242  if (ilObjMediaObject::_exists($mob)) {
243  ilObjMediaObject::_removeUsage($mob, 'exca~:html', $this->submission->getUserId());
244  ilObjMediaObject::_saveUsage($mob, 'exca:html', $returned_id);
245  }
246  }
247  } else {
248  $this->handleRemovedUpload();
249  }
250 
251  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
252  if ($a_return) {
253  $ilCtrl->redirect($this, "returnToParent");
254  } else {
255  $ilCtrl->redirect($this, "editAssignmentText");
256  }
257  }
258 
259  $form->setValuesByPost();
261  }
static _getMediaObjects($a_text, $a_direction=0)
Returns all media objects found in the passed string.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static _getUsedHTMLTags($a_module="")
Returns an array of all allowed HTML tags for text editing.
initAssignmentTextForm($a_read_only=false)
static _removeUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
Remove usage of mob in another container.
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
global $ilCtrl
Definition: ilias.php:18
handleNewUpload($a_no_notifications=false)
if(isset($_POST['submit'])) $form
$mobs
$text
Definition: errorreport.php:18
editAssignmentTextObject(ilPropertyFormGUI $a_form=null)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static _exists($a_id, $a_reference=false, $a_type=null)
checks wether a lm content object with specified id exists or not
static _saveUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
Save usage of mob within another container (e.g.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $help

ilExSubmissionTextGUI::$help
protected

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

Referenced by editAssignmentTextObject().

◆ $user

ilExSubmissionTextGUI::$user
protected

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

Referenced by editAssignmentTextObject().


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