ILIAS  release_7 Revision v7.30-3-g800a261c036
ilMarkSchemaGUI Class Reference
+ Collaboration diagram for ilMarkSchemaGUI:

Public Member Functions

 executeCommand ()
 Controller method. More...
 

Protected Member Functions

 ensureMarkSchemaCanBeEdited ()
 
 ensureEctsGradesCanBeEdited ()
 
 addMarkStep ()
 Add a new mark step to the tests marks. More...
 
 saveMarkSchemaFormData ()
 
 addSimpleMarkSchema ()
 Add a simple mark schema to the tests marks. More...
 
 deleteMarkSteps ()
 Delete selected mark steps. More...
 
 saveMarks ()
 Save the mark schema. More...
 
 showMarkSchema (ilPropertyFormGUI $ects_form=null)
 Display mark schema. More...
 
 populateEctsForm (ilPropertyFormGUI $form)
 
 getEctsForm ()
 
 saveEctsForm ()
 

Protected Attributes

 $object
 
 $lng
 
 $ctrl
 
 $tpl
 
 $toolbar
 

Private Member Functions

 objectSupportsEctsGrades ()
 

Detailed Description

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

Member Function Documentation

◆ addMarkStep()

ilMarkSchemaGUI::addMarkStep ( )
protected

Add a new mark step to the tests marks.

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

100 {
102
103 if ($this->saveMarkSchemaFormData()) {
104 $this->object->getMarkSchema()->addMarkStep();
105 } else {
106 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('mark_schema_invalid'), true);
107 }
108 $this->showMarkSchema();
109 }
showMarkSchema(ilPropertyFormGUI $ects_form=null)
Display mark schema.

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

+ Here is the call graph for this function:

◆ addSimpleMarkSchema()

ilMarkSchemaGUI::addSimpleMarkSchema ( )
protected

Add a simple mark schema to the tests marks.

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

147 {
149
150 $this->object->getMarkSchema()->createSimpleSchema(
151 $this->lng->txt('failed_short'),
152 $this->lng->txt('failed_official'),
153 0,
154 0,
155 $this->lng->txt('passed_short'),
156 $this->lng->txt('passed_official'),
157 50,
158 1
159 );
160 $this->showMarkSchema();
161 }

References ensureMarkSchemaCanBeEdited(), and showMarkSchema().

+ Here is the call graph for this function:

◆ deleteMarkSteps()

ilMarkSchemaGUI::deleteMarkSteps ( )
protected

Delete selected mark steps.

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

166 : void
167 {
168 $delete_mark_steps = $_POST['marks'];
170 if (!isset($delete_mark_steps) || !is_array($delete_mark_steps)) {
171 $this->showMarkSchema();
172 return;
173 }
174
175 // test delete
176 $schema = clone $this->object->getMarkSchema();
177 $schema->deleteMarkSteps($delete_mark_steps);
178 $check_result = $schema->checkMarks();
179 if (is_string($check_result)) {
180 ilUtil::sendFailure($this->lng->txt($check_result), true);
181 $this->showMarkSchema();
182 return;
183 }
184
185 // actual delete
186 if (!empty($delete_mark_steps)) {
187 $this->object->getMarkSchema()->deleteMarkSteps($delete_mark_steps);
188 } else {
189 $this->tpl->setOnScreenMessage('info', $this->lng->txt('tst_delete_missing_mark'));
190 }
191 $this->object->getMarkSchema()->saveToDb($this->object->getTestId());
192
193 $this->showMarkSchema();
194 }
$_POST["username"]
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.

References $_POST, ensureMarkSchemaCanBeEdited(), ilUtil\sendFailure(), and showMarkSchema().

+ Here is the call graph for this function:

◆ ensureEctsGradesCanBeEdited()

ilMarkSchemaGUI::ensureEctsGradesCanBeEdited ( )
protected

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

89 {
90 if (!$this->object->canEditEctsGrades()) {
91 ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
92 $this->ctrl->redirect($this, 'showMarkSchema');
93 }
94 }

References ilUtil\sendFailure().

Referenced by saveEctsForm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ensureMarkSchemaCanBeEdited()

ilMarkSchemaGUI::ensureMarkSchemaCanBeEdited ( )
protected

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

78 {
79 if (!$this->object->canEditMarks()) {
80 ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
81 $this->ctrl->redirect($this, 'showMarkSchema');
82 }
83 }

References ilUtil\sendFailure().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilMarkSchemaGUI::executeCommand ( )

Controller method.

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

65 {
66 global $DIC; /* @var ILIAS\DI\Container $DIC */
67
68 $DIC->tabs()->activateTab(ilTestTabsManager::TAB_ID_SETTINGS);
69
70 $cmd = $this->ctrl->getCmd('showMarkSchema');
71 $this->$cmd();
72 }
global $DIC
Definition: goto.php:24

References $DIC, and ilTestTabsManager\TAB_ID_SETTINGS.

◆ getEctsForm()

ilMarkSchemaGUI::getEctsForm ( )
protected
Returns
ilPropertyFormGUI

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

300 {
301 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
302
303 $disabled = !$this->object->canEditEctsGrades();
304
305 $form = new ilPropertyFormGUI();
306 $form->setFormAction($this->ctrl->getFormAction($this, 'saveEctsForm'));
307 $form->setTitle($this->lng->txt('ects_output_of_ects_grades'));
308
309 $allow_ects_marks = new ilCheckboxInputGUI($this->lng->txt('ects_allow_ects_grades'), 'ectcs_status');
310 $allow_ects_marks->setDisabled($disabled);
311 for ($i = ord('a'); $i <= ord('e'); $i++) {
312 $mark = chr($i);
313
314 $mark_step = new ilNumberInputGUI(chr($i - 32), 'ects_grade_' . $mark);
315 $mark_step->setInfo(
316 $this->lng->txt('ects_grade_desc_prefix') . ' ' . $this->lng->txt('ects_grade_' . $mark . '_desc')
317 );
318 $mark_step->setSize(5);
319 $mark_step->allowDecimals(true);
320 $mark_step->setMinValue(0, true);
321 $mark_step->setMaxValue(100, true);
322 $mark_step->setSuffix($this->lng->txt('percentile'));
323 $mark_step->setRequired(true);
324 $mark_step->setDisabled($disabled);
325 $allow_ects_marks->addSubItem($mark_step);
326 }
327
328 $mark_step = new ilNonEditableValueGUI('F', 'ects_grade_f');
329 $mark_step->setInfo(
330 $this->lng->txt('ects_grade_desc_prefix') . ' ' . $this->lng->txt('ects_grade_f_desc')
331 );
332 $allow_ects_marks->addSubItem($mark_step);
333
334 $use_ects_fx = new ilCheckboxInputGUI($this->lng->txt('use_ects_fx'), 'use_ects_fx');
335 $use_ects_fx->setDisabled($disabled);
336 $allow_ects_marks->addSubItem($use_ects_fx);
337
338 $mark_step = new ilNonEditableValueGUI('FX', 'ects_grade_fx');
339 $mark_step->setInfo(
340 $this->lng->txt('ects_grade_desc_prefix') . ' ' . $this->lng->txt('ects_grade_fx_desc')
341 );
342 $use_ects_fx->addSubItem($mark_step);
343
344 $threshold = new ilNumberInputGUI($this->lng->txt('ects_fx_threshold'), 'ects_fx_threshold');
345 $threshold->setInfo($this->lng->txt('ects_fx_threshold_info'));
346 $threshold->setSuffix($this->lng->txt('percentile'));
347 $threshold->allowDecimals(true);
348 $threshold->setSize(5);
349 $threshold->setRequired(true);
350 $threshold->setDisabled($disabled);
351 $use_ects_fx->addSubItem($threshold);
352
353
354 $form->addItem($allow_ects_marks);
355
356 if (!$disabled) {
357 $form->addCommandButton('saveEctsForm', $this->lng->txt('save'));
358 }
359
360 return $form;
361 }
This class represents a checkbox property in a property form.
This class represents a non editable value in a property form.
This class represents a number property in a property form.
This class represents a property form user interface.
$i
Definition: metadata.php:24

References $i.

Referenced by saveEctsForm(), and showMarkSchema().

+ Here is the caller graph for this function:

◆ objectSupportsEctsGrades()

ilMarkSchemaGUI::objectSupportsEctsGrades ( )
private
Returns
boolean

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

226 {
227 require_once 'Modules/Test/interfaces/interface.ilEctsGradesEnabled.php';
228 return $this->object instanceof ilEctsGradesEnabled;
229 }

Referenced by showMarkSchema().

+ Here is the caller graph for this function:

◆ populateEctsForm()

ilMarkSchemaGUI::populateEctsForm ( ilPropertyFormGUI  $form)
protected
Parameters
ilPropertyFormGUI$form

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

280 {
281 $data = array();
282
283 $data['ectcs_status'] = $this->object->getECTSOutput();
284 $data['use_ects_fx'] = preg_match('/\d+/', $this->object->getECTSFX());
285 $data['ects_fx_threshold'] = $this->object->getECTSFX();
286
287 $ects_grades = $this->object->getECTSGrades();
288 for ($i = ord('a'); $i <= ord('e'); $i++) {
289 $mark = chr($i);
290 $data['ects_grade_' . $mark] = $ects_grades[chr($i - 32)];
291 }
292
293 $form->setValuesByArray($data);
294 }
setValuesByArray($a_values, $a_restrict_to_value_keys=false)
Set form values from an array.
$data
Definition: storeScorm.php:23

References $data, $i, and ilPropertyFormGUI\setValuesByArray().

Referenced by showMarkSchema().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveEctsForm()

ilMarkSchemaGUI::saveEctsForm ( )
protected

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

367 {
369
370 $ects_form = $this->getEctsForm();
371 if (!$ects_form->checkInput()) {
372 $ects_form->setValuesByPost();
373 $this->showMarkSchema($ects_form);
374 return;
375 }
376
377 $grades = array();
378 for ($i = ord('a'); $i <= ord('e'); $i++) {
379 $mark = chr($i);
380 $grades[chr($i - 32)] = $ects_form->getInput('ects_grade_' . $mark);
381 }
382
383 $this->object->setECTSGrades($grades);
384 $this->object->setECTSOutput((int) $ects_form->getInput('ectcs_status'));
385 $this->object->setECTSFX(
386 $ects_form->getInput('use_ects_fx') && preg_match('/\d+/', $ects_form->getInput('ects_fx_threshold')) ?
387 $ects_form->getInput('ects_fx_threshold'):
388 null
389 );
390
391 $this->object->saveECTSStatus();
392
393 ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
394 $ects_form->setValuesByPost();
395 $this->showMarkSchema($ects_form);
396 }

References $i, ensureEctsGradesCanBeEdited(), getEctsForm(), and showMarkSchema().

+ Here is the call graph for this function:

◆ saveMarks()

ilMarkSchemaGUI::saveMarks ( )
protected

Save the mark schema.

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

200 {
202
203 if ($this->saveMarkSchemaFormData()) {
204 $result = $this->object->checkMarks();
205 } else {
206 $result = 'mark_schema_invalid';
207 }
208
209 if (is_string($result)) {
210 ilUtil::sendFailure($this->lng->txt($result), true);
211 } else {
212 $this->object->getMarkSchema()->saveToDb($this->object->getMarkSchemaForeignId());
213 $this->object->onMarkSchemaSaved();
214 $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'), true);
215 $this->object->getMarkSchema()->flush();
216 $this->object->getMarkSchema()->loadFromDb($this->object->getTestId());
217 }
218
219 $this->showMarkSchema();
220 }
$result

References $result, ensureMarkSchemaCanBeEdited(), saveMarkSchemaFormData(), ilUtil\sendFailure(), and showMarkSchema().

+ Here is the call graph for this function:

◆ saveMarkSchemaFormData()

ilMarkSchemaGUI::saveMarkSchemaFormData ( )
protected

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

112 {
113 $no_save_error = true;
114 $this->object->getMarkSchema()->flush();
115 $postdata = $_POST;
116 foreach ($postdata as $key => $value) {
117 if (preg_match('/mark_short_(\d+)/', $key, $matches)) {
118 $passed = "0";
119 if (isset($postdata["passed_$matches[1]"])) {
120 $passed = "1";
121 }
122
123 $percentage = str_replace(',', '.', ilUtil::stripSlashes($postdata["mark_percentage_$matches[1]"]));
124 if (!is_numeric($percentage)
125 || (float) $percentage < 0.0
126 || (float) $percentage > 100.0) {
127 $percentage = 0;
128 $no_save_error = false;
129 }
130
131 $this->object->getMarkSchema()->addMarkStep(
132 ilUtil::stripSlashes($postdata["mark_short_$matches[1]"]),
133 ilUtil::stripSlashes($postdata["mark_official_$matches[1]"]),
134 (float) $percentage,
135 (int) ilUtil::stripSlashes($passed)
136 );
137 }
138 }
139
140 return $no_save_error;
141 }
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled

References $_POST, and ilUtil\stripSlashes().

Referenced by addMarkStep(), and saveMarks().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showMarkSchema()

ilMarkSchemaGUI::showMarkSchema ( ilPropertyFormGUI  $ects_form = null)
protected

Display mark schema.

Parameters
ilPropertyFormGUI$ects_form

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

236 {
237 if (!$this->object->canEditMarks()) {
238 ilUtil::sendInfo($this->lng->txt('cannot_edit_marks'));
239 }
240
241 $this->toolbar->setFormAction($this->ctrl->getFormAction($this, 'showMarkSchema'));
242
243 require_once 'Modules/Test/classes/tables/class.ilMarkSchemaTableGUI.php';
244 $mark_schema_table = new ilMarkSchemaTableGUI($this, 'showMarkSchema', '', $this->object);
245
246 if ($this->object->canEditMarks()) {
247 require_once 'Services/UIComponent/Button/classes/class.ilSubmitButton.php';
248 $create_simple_mark_schema_button = ilSubmitButton::getInstance();
249 $create_simple_mark_schema_button->setCaption($this->lng->txt('tst_mark_create_simple_mark_schema'), false);
250 $create_simple_mark_schema_button->setCommand('addSimpleMarkSchema');
251 $this->toolbar->addButtonInstance($create_simple_mark_schema_button);
252
253 require_once 'Services/UIComponent/Button/classes/class.ilButton.php';
254 $create_new_mark_step_button = ilButton::getInstance();
255 $create_new_mark_step_button->setCaption($this->lng->txt('tst_mark_create_new_mark_step'), false);
256 $create_new_mark_step_button->setButtonType(ilButton::BUTTON_TYPE_SUBMIT);
257 $create_new_mark_step_button->setForm('form_' . $mark_schema_table->getId());
258 $create_new_mark_step_button->setName('addMarkStep');
259 $this->toolbar->addButtonInstance($create_new_mark_step_button);
260 }
261
262
263 $content_parts = array($mark_schema_table->getHTML());
264
265 if ($this->objectSupportsEctsGrades() && $this->object->canShowEctsGrades()) {
266 if (!($ects_form instanceof ilPropertyFormGUI)) {
267 $ects_form = $this->getEctsForm();
268 $this->populateEctsForm($ects_form);
269 }
270 $content_parts[] = $ects_form->getHTML();
271 }
272
273 $this->tpl->setContent(implode('<br />', $content_parts));
274 }
const BUTTON_TYPE_SUBMIT
static getInstance()
populateEctsForm(ilPropertyFormGUI $form)
static getInstance()
Factory.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.

References ilButton\BUTTON_TYPE_SUBMIT, getEctsForm(), ilButton\getInstance(), ilSubmitButton\getInstance(), objectSupportsEctsGrades(), populateEctsForm(), and ilUtil\sendInfo().

Referenced by addMarkStep(), addSimpleMarkSchema(), deleteMarkSteps(), saveEctsForm(), and saveMarks().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilMarkSchemaGUI::$ctrl
protected

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

◆ $lng

ilMarkSchemaGUI::$lng
protected

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

◆ $object

ilMarkSchemaGUI::$object
protected

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

◆ $toolbar

ilMarkSchemaGUI::$toolbar
protected

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

◆ $tpl

ilMarkSchemaGUI::$tpl
protected

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


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