ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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
5include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
6include_once './Services/Table/classes/class.ilTable2GUI.php';
7include_once './Modules/Course/exceptions/class.ilLOInvalidConfiguationException.php';
8
18{
19 private $test_type = 0;
20 private $settings = NULL;
21
22
29 public function __construct($a_parent_obj, $a_parent_cmd, $a_container_id, $a_test_type)
30 {
31 $this->test_type = $a_test_type;
32 $this->setId('obj_loc_'.$a_container_id);
33 parent::__construct($a_parent_obj, $a_parent_cmd);
34
35 $this->settings = ilLOSettings::getInstanceByObjId($a_container_id);
36 }
37
42 public function getSettings()
43 {
44 return $this->settings;
45 }
46
50 public function init()
51 {
52 $this->addColumn('','', '20px');
53 $this->addColumn($this->lng->txt('title'),'title');
54 $this->addColumn($this->lng->txt('crs_loc_tbl_tst_type'),'ttype');
55 $this->addColumn($this->lng->txt('crs_loc_tbl_tst_qst_qpl'),'qstqpl');
56
57 $this->addMultiCommand('confirmDeleteTest', $this->lng->txt('crs_loc_delete_assignment'));
58
59 $this->setRowTemplate("tpl.crs_loc_tst_row.html","Modules/Course");
60 $this->setFormAction($GLOBALS['ilCtrl']->getFormAction($this->getParentObject()));
61
62 $this->setDefaultOrderField('title');
63 $this->setDefaultOrderDirection('asc');
64 }
65
70 public function fillRow($set)
71 {
72 global $ilCtrl;
73
74 $this->tpl->setVariable('VAL_ID',$set['ref_id']);
75 $this->tpl->setVariable('VAL_TITLE',$set['title']);
76 include_once './Services/Link/classes/class.ilLink.php';
77
78 $ilCtrl->setParameterByClass('ilobjtestgui','ref_id',$set['ref_id']);
79 $ilCtrl->setParameterByClass('ilobjtestgui','cmd','questionsTabGateway');
80 $this->tpl->setVariable(
81 'TITLE_LINK',
82 $ilCtrl->getLinkTargetByClass('ilobjtestgui')
83 );
84
85
86
87 #$this->tpl->setVariable('TITLE_LINK',ilLink::_getLink($set['ref_id']));
88 if(strlen($set['description']))
89 {
90 $this->tpl->setVariable('VAL_DESC',$set['description']);
91 }
92
93 switch($set['ttype'])
94 {
96 $type = $this->lng->txt('tst_question_set_type_fixed');
97 break;
98
100 $type = $this->lng->txt('tst_question_set_type_random');
101 break;
102 }
103
104 $this->tpl->setVariable('VAL_TTYPE',$type);
105 $this->tpl->setVariable('VAL_QST_QPL',$set['qst_info']);
106
107 if(count($set['qpls']))
108 {
109 foreach($set['qpls'] as $title)
110 {
111 $this->tpl->setCurrentBlock('qpl');
112 $this->tpl->setVariable('MAT_TITLE',$title);
113 $this->tpl->parseCurrentBlock();
114 }
115 $this->tpl->touchBlock('ul_begin');
116 $this->tpl->touchBlock('ul_end');
117 }
118 }
119
124 public function parse($a_tst_ref_id)
125 {
126 include_once './Modules/Test/classes/class.ilObjTest.php';
127 $tst = ilObjectFactory::getInstanceByRefId($a_tst_ref_id,false);
128
129 if(!$tst instanceof ilObjTest)
130 {
131 throw new ilLOInvalidConfigurationException('No valid test given');
132 }
133 $tst_data['ref_id'] = $tst->getRefId();
134 $tst_data['title'] = $tst->getTitle();
135 $tst_data['description'] = $tst->getLongDescription();
136 $tst_data['ttype'] = $tst->getQuestionSetType();
137
138 switch($tst->getQuestionSetType())
139 {
141 $tst_data['qst_info'] = $this->lng->txt('crs_loc_tst_num_qst');
142 $tst_data['qst_info'] .= (' ' . count($tst->getAllQuestions()));
143 break;
144
145 default:
146 // get available assiged question pools
147 include_once './Modules/Test/classes/class.ilTestRandomQuestionSetSourcePoolDefinitionFactory.php';
148 include_once './Modules/Test/classes/class.ilTestRandomQuestionSetSourcePoolDefinitionList.php';
149
151 $GLOBALS['ilDB'],
152 $tst,
154 $GLOBALS['ilDB'],
155 $tst
156 )
157 );
158
159 $list->loadDefinitions();
160
161 // tax translations
162 include_once './Modules/Test/classes/class.ilTestTaxonomyFilterLabelTranslater.php';
163 $translater = new ilTestTaxonomyFilterLabelTranslater($GLOBALS['ilDB']);
164 $translater->loadLabels($list);
165
166 $tst_data['qst_info'] = $this->lng->txt('crs_loc_tst_qpls');
167 $num = 0;
168 foreach ($list as $definition)
169 {
171 $title = $definition->getPoolTitle();
172 $tax_id = $definition->getMappedFilterTaxId();
173 if($tax_id)
174 {
175 $title .= (' -> '. $translater->getTaxonomyTreeLabel($tax_id));
176 }
177 $tax_node = $definition->getMappedFilterTaxNodeId();
178 if($tax_node)
179 {
180 $title .= (' -> ' .$translater->getTaxonomyNodeLabel($tax_node));
181 }
182 $tst_data['qpls'][] = $title;
183 ++$num;
184 }
185 if(!$num)
186 {
187 $tst_data['qst_info'] .= (' '. (int) 0);
188 }
189 break;
190 }
191
192
193 $this->setData(array($tst_data));
194 }
195}
196?>
Class ilLOInvalidConfigurationException.
static getInstanceByObjId($a_obj_id)
get singleton instance
Class ilLOTestAssignmentTableGUI.
__construct($a_parent_obj, $a_parent_cmd, $a_container_id, $a_test_type)
Constructor.
const QUESTION_SET_TYPE_RANDOM
type setting value for random question set
const QUESTION_SET_TYPE_FIXED
type setting value for fixed question set
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
Class ilTable2GUI.
addColumn($a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="")
Add a column to the header.
getParentObject()
Get parent object.
getFormAction()
Get Form action parameter.
setData($a_data)
set table data @access public
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addMultiCommand($a_cmd, $a_text)
Add Command button.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
$GLOBALS['ct_recipient']
global $ilCtrl
Definition: ilias.php:18