ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilMarkSchemaTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Services/Table/classes/class.ilTable2GUI.php';
5 require_once 'Services/Form/classes/class.ilTextInputGUI.php';
6 require_once 'Services/Form/classes/class.ilNumberInputGUI.php';
7 
14 {
18  protected $ctrl;
19 
23  protected $object;
24 
28  protected $is_editable = true;
29 
34  public function __construct($parent, $cmd, $template_context = '', ilMarkSchemaAware $object = null)
35  {
39  global $ilCtrl;
40 
41  $this->object = $object;
42  $this->ctrl = $ilCtrl;
43 
44  $this->is_editable = $this->object->canEditMarks();
45 
46  $this->setId('mark_schema_gui_' . $this->object->getMarkSchemaForeignId());
47  parent::__construct($parent, $cmd);
48 
49  $this->setFormAction($this->ctrl->getFormAction($this->getParentObject(), $cmd));
50 
51  $this->setRowTemplate('tpl.il_as_tst_mark_schema_row.html', 'Modules/Test');
52 
53  $this->setNoEntriesText($this->lng->txt('tst_no_marks_defined'));
54 
55  if($this->object->canEditMarks())
56  {
57  $this->addCommandButton('addMarkStep', $this->lng->txt('tst_mark_create_new_mark_step'));
58  $this->addCommandButton('saveMarks', $this->lng->txt('save'));
59  $this->addMultiCommand('deleteMarkSteps', $this->lng->txt('delete'));
60 
61  $this->setSelectAllCheckbox('marks[]');
62  }
63  else
64  {
65  $this->disable('select_all');
66  }
67 
68  $this->setLimit(PHP_INT_MAX);
69 
70  $this->initColumns();
71  $this->initData();
72  }
73 
77  protected function initColumns()
78  {
79  $this->addColumn('', '', '1', true);
80  $this->addColumn($this->lng->txt('tst_mark_short_form'), '');
81  $this->addColumn($this->lng->txt('tst_mark_official_form'), '');
82  $this->addColumn($this->lng->txt('tst_mark_minimum_level'), '');
83  $this->addColumn($this->lng->txt('tst_mark_passed'), '', '1');
84  }
85 
89  protected function initData()
90  {
91  $this->object->getMarkSchema()->sort();
92 
93  $data = array();
94 
95  $marks = $this->object->getMarkSchema()->getMarkSteps();
96  foreach($marks as $key => $value)
97  {
98  $data[] = array(
99  'mark_id' => $key,
100  'mark_short' => $value->getShortName(),
101  'mark_official' => $value->getOfficialName(),
102  'mark_percentage' => $value->getMinimumLevel(),
103  'mark_passed' => $value->getPassed() ? 1 : 0
104  );
105  }
106 
107  $this->setData($data);
108  }
109 
113  public function fillRow(array $row)
114  {
115  $short_name = new ilTextInputGUI('', 'mark_short_' . $row['mark_id']);
116  $short_name->setValue($row['mark_short']);
117  $short_name->setDisabled(!$this->is_editable);
118  $short_name->setSize(10);
119 
120  $official_name = new ilTextInputGUI('', 'mark_official_' . $row['mark_id']);
121  $official_name->setSize(20);
122  $official_name->setDisabled(!$this->object->canEditMarks());
123  $official_name->setValue($row['mark_official']);
124 
125  $percentage = new ilNumberInputGUI('', 'mark_percentage_' . $row['mark_id']);
126  $percentage->allowDecimals(true);
127  $percentage->setValue($row['mark_percentage']);
128  $percentage->setSize(10);
129  $percentage->setDisabled(!$this->is_editable);
130  $percentage->setMinValue(0);
131  $percentage->setMaxValue(100);
132 
133  $this->tpl->setVariable('VAL_MARK_ID', $row['mark_id']);
134  $this->tpl->setVariable('VAL_CHECKBOX', ilUtil::formCheckbox(false, 'marks[]', $row['mark_id'], !$this->is_editable));
135  $this->tpl->setVariable('VAL_SHORT_NAME', $short_name->render());
136  $this->tpl->setVariable('VAL_OFFICIAL_NAME', $official_name->render());
137  $this->tpl->setVariable('VAL_PERCENTAGE', $percentage->render());
138  $this->tpl->setVariable('VAL_PASSED_CHECKBOX', ilUtil::formCheckbox((bool)$row['mark_passed'], 'passed_' . $row['mark_id'], '1', !$this->is_editable));
139  }
140 }