ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilLOTestAssignmentTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 
5 include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
6 include_once './Services/Table/classes/class.ilTable2GUI.php';
7 include_once './Modules/Course/exceptions/class.ilLOInvalidConfiguationException.php';
8 
18 {
21 
22  private $test_type = 0;
23  private $assignment_type = self::TYPE_SINGLE_ASSIGNMENTS;
24  private $settings = null;
25  private $container_id = 0;
26 
27 
34  public function __construct($a_parent_obj, $a_parent_cmd, $a_container_id, $a_test_type, $a_assignment_type = self::TYPE_SINGLE_ASSIGNMENTS)
35  {
36  $this->test_type = $a_test_type;
37  $this->assignment_type = $a_assignment_type;
38  $this->container_id = $a_container_id;
39 
40  $this->setId('obj_loc_' . $a_container_id);
41  parent::__construct($a_parent_obj, $a_parent_cmd);
42 
43  $this->settings = ilLOSettings::getInstanceByObjId($a_container_id);
44  $this->initTitle();
45  $this->setTopCommands(false);
46  }
47 
48  public function initTitle()
49  {
50  switch ($this->test_type) {
52  if ($this->getAssignmentType() == self::TYPE_SINGLE_ASSIGNMENTS) {
53  if ($this->getSettings()->isInitialTestQualifying()) {
54  $this->setTitle($this->lng->txt('crs_loc_settings_tbl_its_q_all'));
55  } else {
56  $this->setTitle($this->lng->txt('crs_loc_settings_tbl_its_nq_all'));
57  }
58  } else {
59  if ($this->getSettings()->isInitialTestQualifying()) {
60  $this->setTitle($this->lng->txt('crs_loc_settings_tbl_it_q'));
61  } else {
62  $this->setTitle($this->lng->txt('crs_loc_settings_tbl_it_nq'));
63  }
64  }
65  break;
66 
67 
69  if ($this->getAssignmentType() == self::TYPE_SINGLE_ASSIGNMENTS) {
70  $this->setTitle($this->lng->txt('crs_loc_settings_tbl_qts_all'));
71  } else {
72  $this->setTitle($this->lng->txt('crs_loc_settings_tbl_qt'));
73  }
74  break;
75  }
76  }
77 
82  public function getSettings()
83  {
84  return $this->settings;
85  }
86 
87  public function getAssignmentType()
88  {
90  }
91 
95  public function init()
96  {
97  $this->addColumn('', '', '20px');
98  $this->addColumn($this->lng->txt('title'), 'title');
99 
100  if ($this->getAssignmentType() == self::TYPE_MULTIPLE_ASSIGNMENTS) {
101  $this->addColumn($this->lng->txt('crs_objectives'), 'objective');
102  }
103 
104  $this->addColumn($this->lng->txt('crs_loc_tbl_tst_type'), 'ttype');
105  $this->addColumn($this->lng->txt('crs_loc_tbl_tst_qst_qpl'), 'qstqpl');
106 
107 
108  $this->setRowTemplate("tpl.crs_loc_tst_row.html", "Modules/Course");
109  $this->setFormAction($GLOBALS['ilCtrl']->getFormAction($this->getParentObject()));
110 
111  if ($this->getAssignmentType() == self::TYPE_MULTIPLE_ASSIGNMENTS) {
112  $this->addMultiCommand('confirmDeleteTests', $this->lng->txt('crs_loc_delete_assignment'));
113  $this->setDefaultOrderField('objective');
114  $this->setDefaultOrderDirection('asc');
115  } else {
116  $this->addMultiCommand('confirmDeleteTest', $this->lng->txt('crs_loc_delete_assignment'));
117  $this->setDefaultOrderField('title');
118  $this->setDefaultOrderDirection('asc');
119  }
120  }
121 
126  public function fillRow($set)
127  {
128  global $ilCtrl;
129 
130  if ($this->getAssignmentType() == self::TYPE_MULTIPLE_ASSIGNMENTS) {
131  $this->tpl->setVariable('VAL_ID', $set['assignment_id']);
132  } else {
133  $this->tpl->setVariable('VAL_ID', $set['ref_id']);
134  }
135  $this->tpl->setVariable('VAL_TITLE', $set['title']);
136  include_once './Services/Link/classes/class.ilLink.php';
137 
138  $ilCtrl->setParameterByClass('ilobjtestgui', 'ref_id', $set['ref_id']);
139  $ilCtrl->setParameterByClass('ilobjtestgui', 'cmd', 'questionsTabGateway');
140  $this->tpl->setVariable(
141  'TITLE_LINK',
142  $ilCtrl->getLinkTargetByClass('ilobjtestgui')
143  );
144 
145  if ($this->getAssignmentType() == self::TYPE_MULTIPLE_ASSIGNMENTS) {
146  $this->tpl->setCurrentBlock('objectives');
147  $this->tpl->setVariable('VAL_OBJECTIVE', (string) $set['objective']);
148  $this->tpl->parseCurrentBlock();
149  }
150 
151 
152 
153  #$this->tpl->setVariable('TITLE_LINK',ilLink::_getLink($set['ref_id']));
154  if (strlen($set['description'])) {
155  $this->tpl->setVariable('VAL_DESC', $set['description']);
156  }
157 
158  switch ($set['ttype']) {
160  $type = $this->lng->txt('tst_question_set_type_fixed');
161  break;
162 
164  $type = $this->lng->txt('tst_question_set_type_random');
165  break;
166  }
167 
168  $this->tpl->setVariable('VAL_TTYPE', $type);
169  $this->tpl->setVariable('VAL_QST_QPL', $set['qst_info']);
170 
171  if (isset($set['qpls']) && is_array($set['qpls']) && count($set['qpls']) > 0) {
172  foreach ($set['qpls'] as $title) {
173  $this->tpl->setCurrentBlock('qpl');
174  $this->tpl->setVariable('MAT_TITLE', $title);
175  $this->tpl->parseCurrentBlock();
176  }
177  $this->tpl->touchBlock('ul_begin');
178  $this->tpl->touchBlock('ul_end');
179  }
180  }
181 
182  public function parseMultipleAssignments()
183  {
184  include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignments.php';
185  $assignments = ilLOTestAssignments::getInstance($this->container_id);
186 
187  $available = $assignments->getAssignmentsByType($this->test_type);
188  $data = array();
189  foreach ($available as $assignment) {
190  try {
191  $tmp = $this->doParse($assignment->getTestRefId(), $assignment->getObjectiveId());
192  } catch (ilLOInvalidConfigurationException $e) {
193  $assignment->delete();
194  continue;
195  }
196  if ($tmp) {
197  // add assignment id
198  $tmp['assignment_id'] = $assignment->getAssignmentId();
199  $data[] = $tmp;
200  }
201  }
202 
203  $this->setData($data);
204  }
205 
211  public function parse($a_tst_ref_id)
212  {
213  $this->setData(array($this->doParse($a_tst_ref_id)));
214  return true;
215  }
216 
221  protected function doParse($a_tst_ref_id, $a_objective_id = 0)
222  {
223  include_once './Modules/Test/classes/class.ilObjTest.php';
224  $tst = ilObjectFactory::getInstanceByRefId($a_tst_ref_id, false);
225 
226  if (!$tst instanceof ilObjTest) {
227  throw new ilLOInvalidConfigurationException('No valid test given');
228  }
229  $tst_data['ref_id'] = $tst->getRefId();
230  $tst_data['title'] = $tst->getTitle();
231  $tst_data['description'] = $tst->getLongDescription();
232  $tst_data['ttype'] = $tst->getQuestionSetType();
233 
234 
235  if ($this->getAssignmentType() == self::TYPE_MULTIPLE_ASSIGNMENTS) {
236  include_once './Modules/Course/classes/class.ilCourseObjective.php';
237  $tst_data['objective'] = ilCourseObjective::lookupObjectiveTitle($a_objective_id);
238  }
239 
240  switch ($tst->getQuestionSetType()) {
242  $tst_data['qst_info'] = $this->lng->txt('crs_loc_tst_num_qst');
243  $tst_data['qst_info'] .= (' ' . count($tst->getAllQuestions()));
244  break;
245 
246  default:
247  // get available assiged question pools
248  include_once './Modules/Test/classes/class.ilTestRandomQuestionSetSourcePoolDefinitionFactory.php';
249  include_once './Modules/Test/classes/class.ilTestRandomQuestionSetSourcePoolDefinitionList.php';
250 
252  $GLOBALS['ilDB'],
253  $tst,
255  $GLOBALS['ilDB'],
256  $tst
257  )
258  );
259 
260  $list->loadDefinitions();
261 
262  // tax translations
263  include_once './Modules/Test/classes/class.ilTestTaxonomyFilterLabelTranslater.php';
264  $translater = new ilTestTaxonomyFilterLabelTranslater($GLOBALS['ilDB']);
265  $translater->loadLabels($list);
266 
267  $tst_data['qst_info'] = $this->lng->txt('crs_loc_tst_qpls');
268  $num = 0;
269  foreach ($list as $definition) {
271  $title = $definition->getPoolTitle();
272  // fau: taxFilter/typeFilter - get title for extended filter conditions
273  $filterTitle = array();
274  $filterTitle[] = $translater->getTaxonomyFilterLabel($definition->getMappedTaxonomyFilter());
275  $filterTitle[] = $translater->getTypeFilterLabel($definition->getTypeFilter());
276  if (!empty($filterTitle)) {
277  $title .= ' -> ' . implode(' / ', $filterTitle);
278  }
279  #$tax_id = $definition->getMappedFilterTaxId();
280  #if($tax_id)
281  #{
282  # $title .= (' -> '. $translater->getTaxonomyTreeLabel($tax_id));
283  #}
284  #$tax_node = $definition->getMappedFilterTaxNodeId();
285  #if($tax_node)
286  #{
287  # $title .= (' -> ' .$translater->getTaxonomyNodeLabel($tax_node));
288  #}
289  // fau.
290  $tst_data['qpls'][] = $title;
291  ++$num;
292  }
293  if (!$num) {
294  $tst_data['qst_info'] .= (' ' . (int) 0);
295  }
296  break;
297  }
298  return $tst_data;
299  }
300 }
static getInstanceByObjId($a_obj_id)
get singleton instance
static getInstance($a_container_id)
Get instance by container id.
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41
static lookupObjectiveTitle($a_objective_id, $a_add_description=false)
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
$type
const QUESTION_SET_TYPE_RANDOM
type setting value for random question set
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
getParentObject()
Get parent object.
setId($a_val)
Set id.
global $ilCtrl
Definition: ilias.php:18
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
__construct($a_parent_obj, $a_parent_cmd, $a_container_id, $a_test_type, $a_assignment_type=self::TYPE_SINGLE_ASSIGNMENTS)
Constructor.
setTopCommands($a_val)
Set top commands (display command buttons on top of table, too)
Class ilTable2GUI.
Class ilLOTestAssignmentTableGUI.
addMultiCommand($a_cmd, $a_text)
Add Command button.
Class ilLOInvalidConfigurationException.
getFormAction()
Get Form action parameter.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
Create styles array
The data for the language used.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
settings()
Definition: settings.php:2
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.
const QUESTION_SET_TYPE_FIXED
type setting value for fixed question set
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
parse($a_tst_ref_id)
Parse single test assignment.