ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 ()
 Save the mark schema POST data when the form was submitted. More...
 
 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.

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

100  {
102 
103  $this->saveMarkSchemaFormData();
104  $this->object->getMarkSchema()->addMarkStep();
105  $this->showMarkSchema();
106  }
saveMarkSchemaFormData()
Save the mark schema POST data when the form was submitted.
showMarkSchema(ilPropertyFormGUI $ects_form=null)
Display mark schema.
+ Here is the call graph for this function:

◆ addSimpleMarkSchema()

ilMarkSchemaGUI::addSimpleMarkSchema ( )
protected

Add a simple mark schema to the tests marks.

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

References ensureMarkSchemaCanBeEdited(), and showMarkSchema().

130  {
132 
133  $this->object->getMarkSchema()->createSimpleSchema(
134  $this->lng->txt('failed_short'),
135  $this->lng->txt('failed_official'),
136  0,
137  0,
138  $this->lng->txt('passed_short'),
139  $this->lng->txt('passed_official'),
140  50,
141  1
142  );
143  $this->showMarkSchema();
144  }
showMarkSchema(ilPropertyFormGUI $ects_form=null)
Display mark schema.
+ Here is the call graph for this function:

◆ deleteMarkSteps()

ilMarkSchemaGUI::deleteMarkSteps ( )
protected

Delete selected mark steps.

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

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

150  {
152 
153  if (!isset($_POST['marks']) || !is_array($_POST['marks'])) {
154  $this->showMarkSchema();
155  return;
156  }
157 
158  $this->saveMarkSchemaFormData();
159  $delete_mark_steps = array();
160  foreach ($_POST['marks'] as $mark_step_id) {
161  $delete_mark_steps[] = $mark_step_id;
162  }
163 
164  if (count($delete_mark_steps)) {
165  $this->object->getMarkSchema()->deleteMarkSteps($delete_mark_steps);
166  } else {
167  ilUtil::sendInfo($this->lng->txt('tst_delete_missing_mark'));
168  }
169 
170  $this->showMarkSchema();
171  }
saveMarkSchemaFormData()
Save the mark schema POST data when the form was submitted.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
showMarkSchema(ilPropertyFormGUI $ects_form=null)
Display mark schema.
$_POST["username"]
+ Here is the call graph for this function:

◆ ensureEctsGradesCanBeEdited()

ilMarkSchemaGUI::ensureEctsGradesCanBeEdited ( )
protected

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

References ilUtil\sendFailure().

Referenced by saveEctsForm().

89  {
90  if (!$this->object->canEditEctsGrades()) {
91  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
92  $this->ctrl->redirect($this, 'showMarkSchema');
93  }
94  }
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ 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.

References ilUtil\sendFailure().

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

78  {
79  if (!$this->object->canEditMarks()) {
80  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
81  $this->ctrl->redirect($this, 'showMarkSchema');
82  }
83  }
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ 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.

References $DIC, and ilTestTabsManager\TAB_ID_SETTINGS.

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: saml.php:7

◆ getEctsForm()

ilMarkSchemaGUI::getEctsForm ( )
protected
Returns
ilPropertyFormGUI

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

References $form, $i, ilFormPropertyGUI\setDisabled(), and ilFormPropertyGUI\setInfo().

Referenced by saveEctsForm(), and showMarkSchema().

276  {
277  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
278 
279  $disabled = !$this->object->canEditEctsGrades();
280 
281  $form = new ilPropertyFormGUI();
282  $form->setFormAction($this->ctrl->getFormAction($this, 'saveEctsForm'));
283  $form->setTitle($this->lng->txt('ects_output_of_ects_grades'));
284 
285  $allow_ects_marks = new ilCheckboxInputGUI($this->lng->txt('ects_allow_ects_grades'), 'ectcs_status');
286  $allow_ects_marks->setDisabled($disabled);
287  for ($i = ord('a'); $i <= ord('e'); $i++) {
288  $mark = chr($i);
289 
290  $mark_step = new ilNumberInputGUI(chr($i - 32), 'ects_grade_' . $mark);
291  $mark_step->setInfo(
292  $this->lng->txt('ects_grade_desc_prefix') . ' ' . $this->lng->txt('ects_grade_' . $mark . '_desc')
293  );
294  $mark_step->setSize(5);
295  $mark_step->allowDecimals(true);
296  $mark_step->setMinValue(0, true);
297  $mark_step->setMaxValue(100, true);
298  $mark_step->setSuffix($this->lng->txt('percentile'));
299  $mark_step->setRequired(true);
300  $mark_step->setDisabled($disabled);
301  $allow_ects_marks->addSubItem($mark_step);
302  }
303 
304  $mark_step = new ilNonEditableValueGUI('F', 'ects_grade_f');
305  $mark_step->setInfo(
306  $this->lng->txt('ects_grade_desc_prefix') . ' ' . $this->lng->txt('ects_grade_f_desc')
307  );
308  $allow_ects_marks->addSubItem($mark_step);
309 
310  $use_ects_fx = new ilCheckboxInputGUI($this->lng->txt('use_ects_fx'), 'use_ects_fx');
311  $use_ects_fx->setDisabled($disabled);
312  $allow_ects_marks->addSubItem($use_ects_fx);
313 
314  $mark_step = new ilNonEditableValueGUI('FX', 'ects_grade_fx');
315  $mark_step->setInfo(
316  $this->lng->txt('ects_grade_desc_prefix') . ' ' . $this->lng->txt('ects_grade_fx_desc')
317  );
318  $use_ects_fx->addSubItem($mark_step);
319 
320  $threshold = new ilNumberInputGUI($this->lng->txt('ects_fx_threshold'), 'ects_fx_threshold');
321  $threshold->setInfo($this->lng->txt('ects_fx_threshold_info'));
322  $threshold->setSuffix($this->lng->txt('percentile'));
323  $threshold->allowDecimals(true);
324  $threshold->setSize(5);
325  $threshold->setRequired(true);
326  $threshold->setDisabled($disabled);
327  $use_ects_fx->addSubItem($threshold);
328 
329 
330  $form->addItem($allow_ects_marks);
331 
332  if (!$disabled) {
333  $form->addCommandButton('saveEctsForm', $this->lng->txt('save'));
334  }
335 
336  return $form;
337  }
This class represents a property form user interface.
This class represents a checkbox property in a property form.
setInfo($a_info)
Set Information Text.
if(isset($_POST['submit'])) $form
This class represents a number property in a property form.
This class represents a non editable value in a property form.
$i
Definition: disco.tpl.php:19
setDisabled($a_disabled)
Set Disabled.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ objectSupportsEctsGrades()

ilMarkSchemaGUI::objectSupportsEctsGrades ( )
private
Returns
boolean

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

Referenced by showMarkSchema().

202  {
203  require_once 'Modules/Test/interfaces/interface.ilEctsGradesEnabled.php';
204  return $this->object instanceof ilEctsGradesEnabled;
205  }
+ Here is the caller graph for this function:

◆ populateEctsForm()

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

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

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

Referenced by showMarkSchema().

256  {
257  $data = array();
258 
259  $data['ectcs_status'] = $this->object->getECTSOutput();
260  $data['use_ects_fx'] = preg_match('/\d+/', $this->object->getECTSFX());
261  $data['ects_fx_threshold'] = $this->object->getECTSFX();
262 
263  $ects_grades = $this->object->getECTSGrades();
264  for ($i = ord('a'); $i <= ord('e'); $i++) {
265  $mark = chr($i);
266  $data['ects_grade_' . $mark] = $ects_grades[chr($i - 32)];
267  }
268 
269  $form->setValuesByArray($data);
270  }
$i
Definition: disco.tpl.php:19
setValuesByArray($a_values, $a_restrict_to_value_keys=false)
Set form values from an array.
$data
Definition: bench.php:6
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveEctsForm()

ilMarkSchemaGUI::saveEctsForm ( )
protected

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

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

343  {
345 
346  $ects_form = $this->getEctsForm();
347  if (!$ects_form->checkInput()) {
348  $ects_form->setValuesByPost();
349  $this->showMarkSchema($ects_form);
350  return;
351  }
352 
353  $grades = array();
354  for ($i = ord('a'); $i <= ord('e'); $i++) {
355  $mark = chr($i);
356  $grades[chr($i - 32)] = $ects_form->getInput('ects_grade_' . $mark);
357  }
358 
359  $this->object->setECTSGrades($grades);
360  $this->object->setECTSOutput((int) $ects_form->getInput('ectcs_status'));
361  $this->object->setECTSFX(
362  $ects_form->getInput('use_ects_fx') && preg_match('/\d+/', $ects_form->getInput('ects_fx_threshold')) ?
363  $ects_form->getInput('ects_fx_threshold'):
364  null
365  );
366 
367  $this->object->saveECTSStatus();
368 
369  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
370  $ects_form->setValuesByPost();
371  $this->showMarkSchema($ects_form);
372  }
showMarkSchema(ilPropertyFormGUI $ects_form=null)
Display mark schema.
$i
Definition: disco.tpl.php:19
+ Here is the call graph for this function:

◆ saveMarks()

ilMarkSchemaGUI::saveMarks ( )
protected

Save the mark schema.

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

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

177  {
179 
180  try {
181  $this->saveMarkSchemaFormData();
182  $result = $this->object->checkMarks();
183  } catch (Exception $e) {
184  $result = $this->lng->txt('mark_schema_invalid');
185  }
186 
187  if (is_string($result)) {
188  ilUtil::sendFailure($this->lng->txt($result), true);
189  } else {
190  $this->object->getMarkSchema()->saveToDb($this->object->getMarkSchemaForeignId());
191  $this->object->onMarkSchemaSaved();
192  ilUtil::sendSuccess($this->lng->txt('saved_successfully'), true);
193  }
194 
195  $this->ctrl->redirect($this);
196  }
$result
saveMarkSchemaFormData()
Save the mark schema POST data when the form was submitted.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:

◆ saveMarkSchemaFormData()

ilMarkSchemaGUI::saveMarkSchemaFormData ( )
protected

Save the mark schema POST data when the form was submitted.

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

References $_POST, $key, and ilUtil\stripSlashes().

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

112  {
113  $this->object->getMarkSchema()->flush();
114  foreach ($_POST as $key => $value) {
115  if (preg_match('/mark_short_(\d+)/', $key, $matches)) {
116  $this->object->getMarkSchema()->addMarkStep(
117  ilUtil::stripSlashes($_POST["mark_short_$matches[1]"]),
118  ilUtil::stripSlashes($_POST["mark_official_$matches[1]"]),
119  ilUtil::stripSlashes($_POST["mark_percentage_$matches[1]"]),
120  ilUtil::stripSlashes($_POST["passed_$matches[1]"])
121  );
122  }
123  }
124  }
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
$key
Definition: croninfo.php:18
$_POST["username"]
+ 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 211 of file class.ilMarkSchemaGUI.php.

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

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

212  {
213  if (!$this->object->canEditMarks()) {
214  ilUtil::sendInfo($this->lng->txt('cannot_edit_marks'));
215  }
216 
217  $this->toolbar->setFormAction($this->ctrl->getFormAction($this, 'showMarkSchema'));
218 
219  require_once 'Modules/Test/classes/tables/class.ilMarkSchemaTableGUI.php';
220  $mark_schema_table = new ilMarkSchemaTableGUI($this, 'showMarkSchema', '', $this->object);
221 
222  if ($this->object->canEditMarks()) {
223  require_once 'Services/UIComponent/Button/classes/class.ilSubmitButton.php';
224  $create_simple_mark_schema_button = ilSubmitButton::getInstance();
225  $create_simple_mark_schema_button->setCaption($this->lng->txt('tst_mark_create_simple_mark_schema'), false);
226  $create_simple_mark_schema_button->setCommand('addSimpleMarkSchema');
227  $this->toolbar->addButtonInstance($create_simple_mark_schema_button);
228 
229  require_once 'Services/UIComponent/Button/classes/class.ilButton.php';
230  $create_new_mark_step_button = ilButton::getInstance();
231  $create_new_mark_step_button->setCaption($this->lng->txt('tst_mark_create_new_mark_step'), false);
232  $create_new_mark_step_button->setButtonType(ilButton::BUTTON_TYPE_SUBMIT);
233  $create_new_mark_step_button->setForm('form_' . $mark_schema_table->getId());
234  $create_new_mark_step_button->setName('addMarkStep');
235  $this->toolbar->addButtonInstance($create_new_mark_step_button);
236  }
237 
238 
239  $content_parts = array($mark_schema_table->getHTML());
240 
241  if ($this->objectSupportsEctsGrades() && $this->object->canShowEctsGrades()) {
242  if (!($ects_form instanceof ilPropertyFormGUI)) {
243  $ects_form = $this->getEctsForm();
244  $this->populateEctsForm($ects_form);
245  }
246  $content_parts[] = $ects_form->getHTML();
247  }
248 
249  $this->tpl->setContent(implode('<br />', $content_parts));
250  }
This class represents a property form user interface.
static getInstance()
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
populateEctsForm(ilPropertyFormGUI $form)
const BUTTON_TYPE_SUBMIT
+ 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: