ILIAS  trunk Revision v5.2.0beta1-34132-g2d4d73d4a0
ilMarkSchemaGUI Class Reference
+ Collaboration diagram for ilMarkSchemaGUI:

Public Member Functions

 executeCommand ()
 

Protected Member Functions

 ensureMarkSchemaCanBeEdited ()
 
 addMarkStep ()
 
 populateMarkSchemaFormData ()
 
 resetToSimpleMarkSchema ()
 
 deleteMarkSteps ()
 
 saveMarks ()
 
 showMarkSchema ()
 

Protected Attributes

 $object
 
ilLanguage $lng
 
ilCtrl $ctrl
 
ilGlobalPageTemplate $tpl
 
ilToolbarGUI $toolbar
 
ilTabsGUI $tabs
 
UIFactory $ui_factory
 
UIRenderer $ui_renderer
 

Private Member Functions

 populateToolbar (InterruptiveModal $confirmation_modal, string $mark_schema_id)
 
 buildCreateStepButton (string $mark_schema_id)
 

Private Attributes

RequestWrapper $post_wrapper
 
Request $request
 
Refinery $refinery
 

Detailed Description

Definition at line 34 of file class.ilMarkSchemaGUI.php.

Member Function Documentation

◆ addMarkStep()

ilMarkSchemaGUI::addMarkStep ( )
protected

Definition at line 82 of file class.ilMarkSchemaGUI.php.

References ensureMarkSchemaCanBeEdited(), populateMarkSchemaFormData(), and showMarkSchema().

82  : void
83  {
85 
87  $this->object->getMarkSchema()->addMarkStep();
88  $this->showMarkSchema();
89  }
+ Here is the call graph for this function:

◆ buildCreateStepButton()

ilMarkSchemaGUI::buildCreateStepButton ( string  $mark_schema_id)
private

Definition at line 248 of file class.ilMarkSchemaGUI.php.

References $id, ILIAS\Repository\lng(), and ILIAS\UI\Implementation\Component\withAdditionalOnLoadCode().

Referenced by populateToolbar().

249  {
250  return $this->ui_factory->button()->standard(
251  $this->lng->txt('tst_mark_create_new_mark_step'),
252  ''
254  fn(string $id): string =>
255  "{$id}.addEventListener('click', "
256  . ' (e) => {'
257  . ' e.preventDefault();'
258  . ' e.target.name = "cmd[addMarkStep]";'
259  . " let form = document.getElementById('form_{$mark_schema_id}');"
260  . ' let submitter = e.target.cloneNode();'
261  . ' submitter.style.visibility = "hidden";'
262  . ' form.appendChild(submitter);'
263  . ' form.requestSubmit(submitter);'
264  . ' }'
265  . ');'
266  );
267  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteMarkSteps()

ilMarkSchemaGUI::deleteMarkSteps ( )
protected

Definition at line 141 of file class.ilMarkSchemaGUI.php.

References ensureMarkSchemaCanBeEdited(), ILIAS\Repository\lng(), ILIAS\Repository\object(), ILIAS\Repository\refinery(), and showMarkSchema().

141  : void
142  {
143  $marks_trafo = $this->refinery->custom()->transformation(
144  function ($vs): ?array {
145  if ($vs === null || !is_array($vs)) {
146  return null;
147  }
148  return $vs;
149  }
150  );
151  $deleted_mark_steps = null;
152  if ($this->post_wrapper->has('marks')) {
153  $deleted_mark_steps = $this->post_wrapper->retrieve(
154  'marks',
155  $marks_trafo
156  );
157  }
158 
160  if (!isset($deleted_mark_steps) || !is_array($deleted_mark_steps)) {
161  $this->showMarkSchema();
162  return;
163  }
164 
165  // test delete
166  $schema = clone $this->object->getMarkSchema();
167  $schema->deleteMarkSteps($deleted_mark_steps);
168  $check_result = $schema->checkMarks();
169  if (is_string($check_result)) {
170  $this->tpl->setOnScreenMessage('failure', $this->lng->txt($check_result), true);
171  $this->showMarkSchema();
172  return;
173  }
174 
175  // actual delete
176  if (!empty($deleted_mark_steps)) {
177  $this->object->getMarkSchema()->deleteMarkSteps($deleted_mark_steps);
178  } else {
179  $this->tpl->setOnScreenMessage('info', $this->lng->txt('tst_delete_missing_mark'));
180  }
181  $this->object->getMarkSchema()->saveToDb($this->object->getTestId());
182 
183  $this->showMarkSchema();
184  }
+ Here is the call graph for this function:

◆ ensureMarkSchemaCanBeEdited()

ilMarkSchemaGUI::ensureMarkSchemaCanBeEdited ( )
protected

Definition at line 74 of file class.ilMarkSchemaGUI.php.

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\object().

Referenced by addMarkStep(), deleteMarkSteps(), resetToSimpleMarkSchema(), and saveMarks().

74  : void
75  {
76  if (!$this->object->canEditMarks()) {
77  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
78  $this->ctrl->redirect($this, 'showMarkSchema');
79  }
80  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilMarkSchemaGUI::executeCommand ( )

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

References ILIAS\Repository\ctrl(), ilTestTabsManager\TAB_ID_SETTINGS, and ILIAS\Repository\tabs().

67  : void
68  {
69  $this->tabs->activateTab(ilTestTabsManager::TAB_ID_SETTINGS);
70  $cmd = $this->ctrl->getCmd('showMarkSchema');
71  $this->$cmd();
72  }
+ Here is the call graph for this function:

◆ populateMarkSchemaFormData()

ilMarkSchemaGUI::populateMarkSchemaFormData ( )
protected

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

References ILIAS\LTI\ToolProvider\$key, and ilUtil\stripSlashes().

Referenced by addMarkStep(), and saveMarks().

91  : bool
92  {
93  $no_save_error = true;
94  $this->object->getMarkSchema()->flush();
95  $postdata = $this->request->getParsedBody();
96  foreach ($postdata as $key => $value) {
97  if (preg_match('/mark_short_(\d+)/', $key, $matches)) {
98  $passed = "0";
99  if (isset($postdata["passed_$matches[1]"])) {
100  $passed = "1";
101  }
102 
103  $percentage = str_replace(',', '.', ilUtil::stripSlashes($postdata["mark_percentage_$matches[1]"]));
104  if (!is_numeric($percentage)
105  || (float) $percentage < 0.0
106  || (float) $percentage > 100.0) {
107  $percentage = 0;
108  $no_save_error = false;
109  }
110 
111  $this->object->getMarkSchema()->addMarkStep(
112  ilUtil::stripSlashes($postdata["mark_short_$matches[1]"]),
113  ilUtil::stripSlashes($postdata["mark_official_$matches[1]"]),
114  (float) $percentage,
115  (int) ilUtil::stripSlashes($passed)
116  );
117  }
118  }
119 
120  return $no_save_error;
121  }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateToolbar()

ilMarkSchemaGUI::populateToolbar ( InterruptiveModal  $confirmation_modal,
string  $mark_schema_id 
)
private

Definition at line 236 of file class.ilMarkSchemaGUI.php.

References buildCreateStepButton(), ILIAS\Repository\lng(), and ILIAS\Repository\toolbar().

Referenced by showMarkSchema().

236  : void
237  {
238  $create_simple_schema_button = $this->ui_factory->button()->standard(
239  $this->lng->txt('tst_mark_reset_to_simple_mark_schema'),
240  $confirmation_modal->getShowSignal()
241  );
242  $this->toolbar->addComponent($create_simple_schema_button);
243 
244  $create_step_button = $this->buildCreateStepButton($mark_schema_id);
245  $this->toolbar->addComponent($create_step_button);
246  }
buildCreateStepButton(string $mark_schema_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetToSimpleMarkSchema()

ilMarkSchemaGUI::resetToSimpleMarkSchema ( )
protected

Definition at line 123 of file class.ilMarkSchemaGUI.php.

References ensureMarkSchemaCanBeEdited(), ILIAS\Repository\lng(), ILIAS\Repository\object(), and showMarkSchema().

123  : void
124  {
126 
127  $this->object->getMarkSchema()->createSimpleSchema(
128  $this->lng->txt('failed_short'),
129  $this->lng->txt('failed_official'),
130  0,
131  0,
132  $this->lng->txt('passed_short'),
133  $this->lng->txt('passed_official'),
134  50,
135  1
136  );
137  $this->object->getMarkSchema()->saveToDb($this->object->getTestId());
138  $this->showMarkSchema();
139  }
+ Here is the call graph for this function:

◆ saveMarks()

ilMarkSchemaGUI::saveMarks ( )
protected

Definition at line 186 of file class.ilMarkSchemaGUI.php.

References ensureMarkSchemaCanBeEdited(), ILIAS\Repository\lng(), ILIAS\Repository\object(), populateMarkSchemaFormData(), and showMarkSchema().

186  : void
187  {
189 
190  if ($this->populateMarkSchemaFormData()) {
191  $result = $this->object->checkMarks();
192  } else {
193  $result = 'mark_schema_invalid';
194  }
195 
196  if (is_string($result)) {
197  $this->tpl->setOnScreenMessage('failure', $this->lng->txt($result), true);
198  } else {
199  $this->object->getMarkSchema()->saveToDb($this->object->getMarkSchemaForeignId());
200  $this->object->onMarkSchemaSaved();
201  $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'), true);
202  $this->object->getMarkSchema()->flush();
203  $this->object->getMarkSchema()->loadFromDb($this->object->getTestId());
204  }
205 
206  $this->showMarkSchema();
207  }
+ Here is the call graph for this function:

◆ showMarkSchema()

ilMarkSchemaGUI::showMarkSchema ( )
protected

Definition at line 209 of file class.ilMarkSchemaGUI.php.

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ILIAS\Repository\object(), populateToolbar(), and ILIAS\Repository\toolbar().

Referenced by addMarkStep(), deleteMarkSteps(), resetToSimpleMarkSchema(), and saveMarks().

209  : void
210  {
211  if (!$this->object->canEditMarks()) {
212  $this->tpl->setOnScreenMessage('info', $this->lng->txt('cannot_edit_marks'));
213  }
214 
215  $this->toolbar->setFormAction($this->ctrl->getFormAction($this, 'showMarkSchema'));
216 
217  $mark_schema_table = new ilMarkSchemaTableGUI($this, 'showMarkSchema', $this->object);
218  $mark_schema_table->setShowRowsSelector(false);
219 
220  $rendered_modal = '';
221  if ($this->object->canEditMarks()) {
222  $confirmation_modal = $this->ui_factory->modal()->interruptive(
223  $this->lng->txt('tst_mark_reset_to_simple_mark_schema'),
224  $this->lng->txt('tst_mark_reset_to_simple_mark_schema_confirmation'),
225  $this->ctrl->getFormAction($this, 'resetToSimpleMarkSchema')
226  )->withActionButtonLabel($this->lng->txt('tst_mark_reset_to_simple_mark_schema'));
227  $this->populateToolbar($confirmation_modal, $mark_schema_table->getId());
228  $rendered_modal = $this->ui_renderer->render($confirmation_modal);
229  }
230 
231  $this->tpl->setContent(
232  $mark_schema_table->getHTML() . $rendered_modal
233  );
234  }
populateToolbar(InterruptiveModal $confirmation_modal, string $mark_schema_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilCtrl ilMarkSchemaGUI::$ctrl
protected

Definition at line 42 of file class.ilMarkSchemaGUI.php.

◆ $lng

ilLanguage ilMarkSchemaGUI::$lng
protected

Definition at line 41 of file class.ilMarkSchemaGUI.php.

◆ $object

ilMarkSchemaGUI::$object
protected

Definition at line 40 of file class.ilMarkSchemaGUI.php.

◆ $post_wrapper

RequestWrapper ilMarkSchemaGUI::$post_wrapper
private

Definition at line 36 of file class.ilMarkSchemaGUI.php.

◆ $refinery

Refinery ilMarkSchemaGUI::$refinery
private

Definition at line 38 of file class.ilMarkSchemaGUI.php.

◆ $request

Request ilMarkSchemaGUI::$request
private

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

◆ $tabs

ilTabsGUI ilMarkSchemaGUI::$tabs
protected

Definition at line 45 of file class.ilMarkSchemaGUI.php.

◆ $toolbar

ilToolbarGUI ilMarkSchemaGUI::$toolbar
protected

Definition at line 44 of file class.ilMarkSchemaGUI.php.

◆ $tpl

ilGlobalPageTemplate ilMarkSchemaGUI::$tpl
protected

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

◆ $ui_factory

UIFactory ilMarkSchemaGUI::$ui_factory
protected

Definition at line 46 of file class.ilMarkSchemaGUI.php.

◆ $ui_renderer

UIRenderer ilMarkSchemaGUI::$ui_renderer
protected

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


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