ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 $DIC;
40  $ilCtrl = $DIC['ilCtrl'];
41 
42  $this->object = $object;
43  $this->ctrl = $ilCtrl;
44 
45  $this->is_editable = $this->object->canEditMarks();
46 
47  $this->setId('mark_schema_gui_' . $this->object->getMarkSchemaForeignId());
48  parent::__construct($parent, $cmd);
49 
50  $this->setFormAction($this->ctrl->getFormAction($this->getParentObject(), $cmd));
51  $this->setFormName('form_' . $this->getId());
52 
53  $this->setRowTemplate('tpl.il_as_tst_mark_schema_row.html', 'Modules/Test');
54 
55  $this->setNoEntriesText($this->lng->txt('tst_no_marks_defined'));
56 
57  if ($this->object->canEditMarks()) {
58  $this->addCommandButton('saveMarks', $this->lng->txt('save'));
59  $this->addMultiCommand('deleteMarkSteps', $this->lng->txt('delete'));
60 
61  $this->setSelectAllCheckbox('marks[]');
62  } else {
63  $this->disable('select_all');
64  }
65 
66  $this->setLimit(PHP_INT_MAX);
67 
68  $this->initColumns();
69  $this->initData();
70  }
71 
75  protected function initColumns()
76  {
77  $this->addColumn('', '', '1', true);
78  $this->addColumn($this->lng->txt('tst_mark_short_form'), '');
79  $this->addColumn($this->lng->txt('tst_mark_official_form'), '');
80  $this->addColumn($this->lng->txt('tst_mark_minimum_level'), '');
81  $this->addColumn($this->lng->txt('tst_mark_passed'), '', '1');
82  }
83 
87  protected function initData()
88  {
89  $this->object->getMarkSchema()->sort();
90 
91  $data = array();
92 
93  $marks = $this->object->getMarkSchema()->getMarkSteps();
94  foreach ($marks as $key => $value) {
95  $data[] = array(
96  'mark_id' => $key,
97  'mark_short' => $value->getShortName(),
98  'mark_official' => $value->getOfficialName(),
99  'mark_percentage' => $value->getMinimumLevel(),
100  'mark_passed' => $value->getPassed() ? 1 : 0
101  );
102  }
103 
104  $this->setData($data);
105  }
106 
110  public function fillRow($row)
111  {
112  $short_name = new ilTextInputGUI('', 'mark_short_' . $row['mark_id']);
113  $short_name->setValue($row['mark_short']);
114  $short_name->setDisabled(!$this->is_editable);
115  $short_name->setSize(10);
116 
117  $official_name = new ilTextInputGUI('', 'mark_official_' . $row['mark_id']);
118  $official_name->setSize(20);
119  $official_name->setDisabled(!$this->object->canEditMarks());
120  $official_name->setValue($row['mark_official']);
121 
122  $percentage = new ilNumberInputGUI('', 'mark_percentage_' . $row['mark_id']);
123  $percentage->allowDecimals(true);
124  $percentage->setValue($row['mark_percentage']);
125  $percentage->setSize(10);
126  $percentage->setDisabled(!$this->is_editable);
127  $percentage->setMinValue(0);
128  $percentage->setMaxValue(100);
129 
130  $this->tpl->setVariable('VAL_MARK_ID', $row['mark_id']);
131  $this->tpl->setVariable('VAL_CHECKBOX', ilUtil::formCheckbox(false, 'marks[]', $row['mark_id'], !$this->is_editable));
132  $this->tpl->setVariable('VAL_SHORT_NAME', $short_name->render());
133  $this->tpl->setVariable('VAL_OFFICIAL_NAME', $official_name->render());
134  $this->tpl->setVariable('VAL_PERCENTAGE', $percentage->render());
135  $this->tpl->setVariable('VAL_PASSED_CHECKBOX', ilUtil::formCheckbox((bool) $row['mark_passed'], 'passed_' . $row['mark_id'], '1', !$this->is_editable));
136  }
137 }
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
__construct($a_parent_obj, $a_parent_cmd="", $a_template_context="")
ilTable2GUI constructor.
global $DIC
Definition: saml.php:7
setNoEntriesText($a_text)
Set text for an empty table.
setId($a_val)
Set id.
global $ilCtrl
Definition: ilias.php:18
Class ilTable2GUI.
setSelectAllCheckbox($a_select_all_checkbox, $a_select_all_on_top=false)
Set the name of the checkbox that should be toggled with a select all button.
This class represents a number property in a property form.
addMultiCommand($a_cmd, $a_text)
Add Command button.
This class represents a text property in a property form.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
$row
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
disable($a_module_name)
diesables particular modules of table
setFormName($a_formname="")
Set Form name.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
getId()
Get element id.
$key
Definition: croninfo.php:18
static formCheckbox($checked, $varname, $value, $disabled=false)
??? public
setLimit($a_limit=0, $a_default_limit=0)