ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
ilMarkSchemaGUI Class Reference
+ Collaboration diagram for ilMarkSchemaGUI:

Public Member Functions

 executeCommand ()
 Controller method. More...
 

Protected Member Functions

 ensureMarkSchemaCanBeEdited ()
 
 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 81 of file class.ilMarkSchemaGUI.php.

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

82  {
84 
85  $this->saveMarkSchemaFormData();
86  $this->object->getMarkSchema()->addMarkStep();
87  $this->showMarkSchema();
88  }
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 113 of file class.ilMarkSchemaGUI.php.

References ensureMarkSchemaCanBeEdited(), and showMarkSchema().

114  {
116 
117  $this->object->getMarkSchema()->createSimpleSchema(
118  $this->lng->txt('failed_short'), $this->lng->txt('failed_official'),
119  0, 0,
120  $this->lng->txt('passed_short'), $this->lng->txt('passed_official'),
121  50, 1
122  );
123  $this->showMarkSchema();
124  }
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 129 of file class.ilMarkSchemaGUI.php.

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

130  {
132 
133  if(!isset($_POST['marks']) || !is_array($_POST['marks']))
134  {
135  $this->showMarkSchema();
136  return;
137  }
138 
139  $this->saveMarkSchemaFormData();
140  $delete_mark_steps = array();
141  foreach($_POST['marks'] as $mark_step_id)
142  {
143  $delete_mark_steps[] = $mark_step_id;
144  }
145 
146  if(count($delete_mark_steps))
147  {
148  $this->object->getMarkSchema()->deleteMarkSteps($delete_mark_steps);
149  }
150  else
151  {
152  ilUtil::sendInfo($this->lng->txt('tst_delete_missing_mark'));
153  }
154 
155  $this->showMarkSchema();
156  }
$_POST['username']
Definition: cron.php:12
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.
+ Here is the call graph for this function:

◆ ensureMarkSchemaCanBeEdited()

ilMarkSchemaGUI::ensureMarkSchemaCanBeEdited ( )
protected

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

References ilUtil\sendFailure().

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

70  {
71  if(!$this->object->canEditMarks())
72  {
73  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
74  $this->ctrl->redirect($this, 'showMarkSchema');
75  }
76  }
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 60 of file class.ilMarkSchemaGUI.php.

References $cmd.

61  {
62  $cmd = $this->ctrl->getCmd('showMarkSchema');
63  $this->$cmd();
64  }
$cmd
Definition: sahs_server.php:35

◆ getEctsForm()

ilMarkSchemaGUI::getEctsForm ( )
protected
Returns
ilPropertyFormGUI

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

References ilSubEnabledFormPropertyGUI\addSubItem(), and ilFormPropertyGUI\setInfo().

Referenced by saveEctsForm(), and showMarkSchema().

263  {
264  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
265 
266  $form = new ilPropertyFormGUI();
267  $form->setFormAction($this->ctrl->getFormAction($this, 'saveEctsForm'));
268  $form->addCommandButton('saveEctsForm', $this->lng->txt('save'));
269  $form->setTitle($this->lng->txt('ects_output_of_ects_grades'));
270 
271  $allow_ects_marks = new ilCheckboxInputGUI($this->lng->txt('ects_allow_ects_grades'), 'ectcs_status');
272  for($i = ord('a'); $i <= ord('e'); $i++)
273  {
274  $mark = chr($i);
275 
276  $mark_step = new ilNumberInputGUI(chr($i - 32), 'ects_grade_' . $mark);
277  $mark_step->setInfo(
278  $this->lng->txt('ects_grade_desc_prefix') . ' ' . $this->lng->txt('ects_grade_' . $mark . '_desc')
279  );
280  $mark_step->setSize(5);
281  $mark_step->allowDecimals(true);
282  $mark_step->setMinValue(0, true);
283  $mark_step->setMaxValue(100, true);
284  $mark_step->setSuffix($this->lng->txt('percentile'));
285  $mark_step->setRequired(true);
286  $allow_ects_marks->addSubItem($mark_step);
287  }
288 
289  $mark_step = new ilNonEditableValueGUI('F', 'ects_grade_f');
290  $mark_step->setInfo(
291  $this->lng->txt('ects_grade_desc_prefix') . ' ' . $this->lng->txt('ects_grade_f_desc')
292  );
293  $allow_ects_marks->addSubItem($mark_step);
294 
295  $use_ects_fx = new ilCheckboxInputGUI($this->lng->txt('use_ects_fx'), 'use_ects_fx');
296  $allow_ects_marks->addSubItem($use_ects_fx);
297 
298  $mark_step = new ilNonEditableValueGUI('FX', 'ects_grade_fx');
299  $mark_step->setInfo(
300  $this->lng->txt('ects_grade_desc_prefix') . ' ' . $this->lng->txt('ects_grade_fx_desc')
301  );
302  $use_ects_fx->addSubItem($mark_step);
303 
304  $threshold = new ilNumberInputGUI($this->lng->txt('ects_fx_threshold'), 'ects_fx_threshold');
305  $threshold->setInfo($this->lng->txt('ects_fx_threshold_info'));
306  $threshold->setSuffix($this->lng->txt('percentile'));
307  $threshold->allowDecimals(true);
308  $threshold->setSize(5);
309  $threshold->setRequired(true);
310  $use_ects_fx->addSubItem($threshold);
311 
312 
313  $form->addItem($allow_ects_marks);
314 
315  return $form;
316  }
This class represents a property form user interface.
This class represents a checkbox property in a property form.
setInfo($a_info)
Set Information Text.
This class represents a number property in a property form.
This class represents a non editable value in a property form.
+ 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 192 of file class.ilMarkSchemaGUI.php.

Referenced by saveEctsForm(), and showMarkSchema().

193  {
194  require_once 'Modules/Test/interfaces/interface.ilEctsGradesEnabled.php';
195  return $this->object instanceof ilEctsGradesEnabled;
196  }
+ Here is the caller graph for this function:

◆ populateEctsForm()

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

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

References $data, and ilPropertyFormGUI\setValuesByArray().

Referenced by showMarkSchema().

242  {
243  $data = array();
244 
245  $data['ectcs_status'] = $this->object->getECTSOutput();
246  $data['use_ects_fx'] = preg_match('/\d+/', $this->object->getECTSFX());
247  $data['ects_fx_threshold'] = $this->object->getECTSFX();
248 
249  $ects_grades = $this->object->getECTSGrades();
250  for($i = ord('a'); $i <= ord('e'); $i++)
251  {
252  $mark = chr($i);
253  $data['ects_grade_' . $mark] = $ects_grades[chr($i - 32)];
254  }
255 
256  $form->setValuesByArray($data);
257  }
setValuesByArray($a_values, $a_restrict_to_value_keys=false)
Set form values from an array.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveEctsForm()

ilMarkSchemaGUI::saveEctsForm ( )
protected

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

References getEctsForm(), objectSupportsEctsGrades(), ilUtil\sendSuccess(), and showMarkSchema().

322  {
323  if(!$this->objectSupportsEctsGrades() && $this->object->canEditEctsGrades())
324  {
325  $this->showMarkSchema();
326  return;
327  }
328 
329  $ects_form = $this->getEctsForm();
330  if(!$ects_form->checkInput())
331  {
332  $ects_form->setValuesByPost();
333  $this->showMarkSchema($ects_form);
334  return;
335  }
336 
337  $grades = array();
338  for($i = ord('a'); $i <= ord('e'); $i++)
339  {
340  $mark = chr($i);
341  $grades[chr($i - 32)] = $ects_form->getInput('ects_grade_' . $mark);
342  }
343 
344  $this->object->setECTSGrades($grades);
345  $this->object->setECTSOutput((int)$ects_form->getInput('ectcs_status'));
346  $this->object->setECTSFX(
347  $ects_form->getInput('use_ects_fx') && preg_match('/\d+/', $ects_form->getInput('ects_fx_threshold')) ?
348  $ects_form->getInput('ects_fx_threshold'):
349  NULL
350  );
351 
352  $this->object->saveECTSStatus();
353 
354  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
355  $ects_form->setValuesByPost();
356  $this->showMarkSchema($ects_form);
357  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
showMarkSchema(ilPropertyFormGUI $ects_form=null)
Display mark schema.
+ Here is the call graph for this function:

◆ saveMarks()

ilMarkSchemaGUI::saveMarks ( )
protected

Save the mark schema.

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

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

162  {
164 
165  try
166  {
167  $this->saveMarkSchemaFormData();
168  $result = $this->object->checkMarks();
169  }
170  catch(Exception $e)
171  {
172  $result = $this->lng->txt('mark_schema_invalid');
173  }
174 
175  if(is_string($result))
176  {
177  ilUtil::sendFailure($this->lng->txt($result), true);
178  }
179  else
180  {
181  $this->object->getMarkSchema()->saveToDb($this->object->getMarkSchemaForeignId());
182  $this->object->onMarkSchemaSaved();
183  ilUtil::sendSuccess($this->lng->txt('saved_successfully'), true);
184  }
185 
186  $this->ctrl->redirect($this);
187  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$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 93 of file class.ilMarkSchemaGUI.php.

References $_POST, and ilUtil\stripSlashes().

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

94  {
95  $this->object->getMarkSchema()->flush();
96  foreach($_POST as $key => $value)
97  {
98  if(preg_match('/mark_short_(\d+)/', $key, $matches))
99  {
100  $this->object->getMarkSchema()->addMarkStep(
101  ilUtil::stripSlashes($_POST["mark_short_$matches[1]"]),
102  ilUtil::stripSlashes($_POST["mark_official_$matches[1]"]),
103  ilUtil::stripSlashes($_POST["mark_percentage_$matches[1]"]),
104  ilUtil::stripSlashes($_POST["passed_$matches[1]"])
105  );
106  }
107  }
108  }
$_POST['username']
Definition: cron.php:12
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
+ 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 202 of file class.ilMarkSchemaGUI.php.

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

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

203  {
204  if(!$this->object->canEditMarks())
205  {
206  ilUtil::sendInfo($this->lng->txt('cannot_edit_marks'));
207  }
208 
209  $this->toolbar->setFormAction($this->ctrl->getFormAction($this, 'showMarkSchema'));
210 
211  if($this->object->canEditMarks())
212  {
213  require_once 'Services/UIComponent/Button/classes/class.ilSubmitButton.php';
214  $create_simple_mark_schema_button = ilSubmitButton::getInstance();
215  $create_simple_mark_schema_button->setCaption($this->lng->txt('tst_mark_create_simple_mark_schema'), false);
216  $create_simple_mark_schema_button->setCommand('addSimpleMarkSchema');
217  $this->toolbar->addButtonInstance($create_simple_mark_schema_button);
218  }
219 
220  require_once 'Modules/Test/classes/tables/class.ilMarkSchemaTableGUI.php';
221  $mark_schema_table = new ilMarkSchemaTableGUI($this, 'showMarkSchema', '', $this->object);
222 
223  $content_parts = array($mark_schema_table->getHTML());
224 
225  if($this->objectSupportsEctsGrades() && $this->object->canEditEctsGrades())
226  {
227  if(!($ects_form instanceof ilPropertyFormGUI))
228  {
229  $ects_form = $this->getEctsForm();
230  $this->populateEctsForm($ects_form);
231  }
232  $content_parts[] = $ects_form->getHTML();
233  }
234 
235  $this->tpl->setContent(implode('<br />', $content_parts));
236  }
This class represents a property form user interface.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
populateEctsForm(ilPropertyFormGUI $form)
+ 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: