ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilTestSkillLevelThresholdsTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Services/Table/classes/class.ilTable2GUI.php';
5 
13 {
15 
17  {
18  $this->skillLevelThresholdList = $skillLevelThresholdList;
19  }
20 
21  public function getSkillLevelThresholdList()
22  {
24  }
25 
26  public function __construct($parentOBJ, $parentCmd, ilCtrl $ctrl, ilLanguage $lng)
27  {
28  parent::__construct($parentOBJ, $parentCmd);
29 
30  $this->lng = $lng;
31  $this->ctrl = $ctrl;
32 
33  $this->setStyle('table', 'fullwidth');
34 
35  $this->setRowTemplate("tpl.tst_skl_thresholds_row.html", "Modules/Test");
36 
37  $this->enable('header');
38  $this->disable('sort');
39  $this->disable('select_all');
40 
41  $this->initColumns();
42 
43  $this->setFormAction($ctrl->getFormAction($parentOBJ));
44 
45  $this->addCommandButton(
46  ilTestSkillLevelThresholdsGUI::CMD_SAVE_SKILL_THRESHOLDS, $this->lng->txt('tst_save_thresholds')
47  );
48  }
49 
50  private function initColumns()
51  {
52  $this->addColumn($this->lng->txt('tst_competence'),'conpetence', '50%');
53  $this->addColumn($this->lng->txt('tst_num_questions'),'num_questions', '10%');
54  $this->addColumn($this->lng->txt('tst_max_comp_points'),'max_comp_points', '10%');
55  $this->addColumn($this->lng->txt('tst_level'),'level', '10%');
56  $this->addColumn($this->lng->txt('tst_threshold'),'threshold', '');
57  }
58 
59  public function fillRow($data)
60  {
61  $skill = $data['skill'];
62  $levels = $skill->getLevelData();
63 
64  $this->tpl->setCurrentBlock('competence');
65  $this->tpl->setVariable('ROWSPAN', $this->getRowspan(count($levels)));
66  include_once("./Services/Skill/classes/class.ilBasicSkill.php");
67  $this->tpl->setVariable('COMPETENCE', ilBasicSkill::_lookupTitle($skill->getId(), $data['skill_tref_id']));
68  $this->tpl->setVariable('NUM_QUESTIONS', $data['num_assigns']);
69  $this->tpl->setVariable('MAX_COMP_POINTS', $data['max_points']);
70  $this->tpl->parseCurrentBlock();
71 
72  $this->tpl->setCurrentBlock('tbl_content');
73 
74  for($i = 0, $max = count($levels); $i < $max; $i++)
75  {
76  $level = $levels[$i];
77 
78  $this->tpl->setVariable('LEVEL', $level['title']);
79 
80  $this->tpl->setVariable('THRESHOLD', $this->buildThresholdInput(
81  $data['skill_base_id'], $data['skill_tref_id'], $level['id']
82  ));
83 
84  if( $i < ($max - 1) )
85  {
86  $this->tpl->parseCurrentBlock();
87  $this->tpl->setVariable("CSS_ROW", $this->css_row);
88  $this->tpl->setVariable("CSS_NO_BORDER", 'ilBorderlessRow');
89  }
90  }
91  }
92 
93  private function getRowspan($numLevels)
94  {
95  if($numLevels == 0)
96  {
97  return 1;
98  }
99 
100  return $numLevels;
101  }
102 
103  private function buildThresholdInput($skillBaseId, $skillTrefId, $skillLevelId)
104  {
105  $threshold = $this->skillLevelThresholdList->getThreshold($skillBaseId, $skillTrefId, $skillLevelId);
106 
107  if( $threshold instanceof ilTestSkillLevelThreshold )
108  {
109  $thresholdValue = $threshold->getThreshold();
110  }
111  else
112  {
113  $thresholdValue = '';
114  }
115 
116  $skillKey = $skillBaseId.':'.$skillTrefId;
117 
118  return "<input type\"text\" size=\"2\" name=\"threshold[{$skillKey}][$skillLevelId]\" value=\"{$thresholdValue}\" />";
119  }
120 }