ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilAssQuestionSkillUsagesTableGUI.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 {
14  const TABLE_ID = 'iaqsutg';
15 
16  const CMD_SHOW = 'show';
17 
21  private $myCtrl;
22 
26  private $myTpl;
27 
31  private $myLng;
32 
36  private $myDb;
37 
46  {
47  $this->myCtrl = $myCtrl;
48  $this->myTpl = $myTpl;
49  $this->myLng = $myLng;
50  $this->myDb = $myDb;
51 
52  $this->poolId = $poolId;
53 
54  $this->setId(self::TABLE_ID.$this->poolId);
55  $this->setPrefix(self::TABLE_ID.$this->poolId);
56  parent::__construct($this, self::CMD_SHOW);
57 
58  $this->setRowTemplate("tpl.il_as_qpl_skl_assign_stat_row.html", "Modules/TestQuestionPool");#
59 
60  $this->setDefaultOrderField("qpl_qst_skl_usg_skill_col");
61  $this->setDefaultOrderDirection("asc");
62  }
63 
64  public function executeCommand()
65  {
66  switch( $this->myCtrl->getNextClass() )
67  {
68  case strtolower(__CLASS__):
69  case '':
70 
71  $command = $this->myCtrl->getCmd(self::CMD_SHOW).'Cmd';
72  $this->$command();
73  break;
74 
75  default:
76 
77  throw new ilTestQuestionPoolException('unsupported next class');
78  }
79  }
80 
81  private function showCmd()
82  {
83  $this->initColumns();
84 
85 
86  $this->setData($this->buildTableRowsArray(
88  ));
89 
90  $this->myTpl->setContent($this->myCtrl->getHTML($this));
91  }
92 
93  protected function initColumns()
94  {
95  $this->addColumn($this->myLng->txt('qpl_qst_skl_usg_skill_col'), 'skill_title', '50%');
96  $this->addColumn($this->myLng->txt('qpl_qst_skl_usg_numq_col'), 'num_questions', '');
97  $this->addColumn($this->myLng->txt('qpl_qst_skl_usg_sklpnt_col'), 'max_skill_points', '');
98  }
99 
100  public function fillRow($data)
101  {
102  $this->tpl->setVariable('SKILL_TITLE', $data['skill_title']);
103  $this->tpl->setVariable('SKILL_PATH', $data['skill_path']);
104  $this->tpl->setVariable('NUM_QUESTIONS', $data['num_questions']);
105  $this->tpl->setVariable('MAX_SKILL_POINTS', $data['max_skill_points']);
106  }
107 
108  public function numericOrdering($a_field)
109  {
110  switch($a_field)
111  {
112  case 'num_questions':
113  case 'max_skill_points':
114  return true;
115  }
116 
117  return false;
118  }
119 
120  private function getUniqueAssignedSkillsStats()
121  {
122  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionSkillAssignmentList.php';
123  $assignmentList = new ilAssQuestionSkillAssignmentList($this->myDb);
124 
125  $assignmentList->setParentObjId($this->poolId);
126  $assignmentList->loadFromDb();
127  $assignmentList->loadAdditionalSkillData();
128 
129  return $assignmentList->getUniqueAssignedSkills();
130  }
131 
132  private function buildTableRowsArray($assignedSkills)
133  {
134  $rows = array();
135 
136  foreach($assignedSkills as $assignedSkill)
137  {
138  $rows[] = array(
139  'skill_title' => $assignedSkill['skill_title'],
140  'skill_path' => $assignedSkill['skill_path'],
141  'num_questions' => $assignedSkill['num_assigns'],
142  'max_skill_points' => $assignedSkill['max_points'],
143  );
144  }
145 
146  return $rows;
147  }
148 }
This class provides processing control methods.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
setId($a_val)
Set id.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
Interface ilDBInterface.
Class ilTable2GUI.
special template class to simplify handling of ITX/PEAR
setPrefix($a_prefix)
setRowTemplate($a_template, $a_template_dir="")
Set row template.
Create styles array
The data for the language used.
language handling
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.
__construct(ilCtrl $myCtrl, ilTemplate $myTpl, ilLanguage $myLng, ilDBInterface $myDb, $poolId)