ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f87
class.ilCourseObjectiveQuestionAssignmentTableGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 include_once('./Modules/Course/classes/class.ilCourseObjectiveQuestion.php');
25 include_once('./Services/Table/classes/class.ilTable2GUI.php');
26 // begin-patch lok
27 include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
28 // end-patch lok
29 
39 {
40  // begin-patch lok
41  private $settings = NULL;
42  // end-patch lok
43 
44  private $mode = 0;
45  private $objective = null;
46  private $objective_lm = null;
47 
48  private $objective_id = 0;
49  private $course_obj;
50 
58  public function __construct($a_parent_obj,$a_course_obj,$a_objective_id,$a_mode)
59  {
60  global $lng,$ilCtrl;
61 
62  $this->objective_id = $a_objective_id;
63  $this->course_obj = $a_course_obj;
64 
65  // begin-patch lok
66  $this->settings = ilLOSettings::getInstanceByObjId($this->course_obj->getId());
67  // end-patch lok
68 
69  $this->lng = $lng;
70  $this->lng->loadLanguageModule('crs');
71  $this->ctrl = $ilCtrl;
72 
73  parent::__construct($a_parent_obj,'materialAssignment');
74  $this->setFormName('assignments');
75  $this->addColumn($this->lng->txt('type'),'type',"20px");
76  $this->addColumn($this->lng->txt('title'),'title','');
77 
78  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
79  $this->setRowTemplate("tpl.crs_objective_list_questions_row.html","Modules/Course");
80  $this->disable('sort');
81  $this->disable('header');
82  $this->disable('numinfo');
83  $this->disable('select_all');
84 
85  #$this->setDefaultOrderField('title');
86  $this->setLimit(200);
87 
88  $this->mode = $a_mode;
89  switch($a_mode)
90  {
92  $this->addCommandButton('updateSelfAssessmentAssignment',$this->lng->txt('crs_wiz_next'));
93  $this->addCommandButton('materialAssignment',$this->lng->txt('crs_wiz_back'));
94  break;
95 
97  $this->addCommandButton('updateFinalTestAssignment',$this->lng->txt('crs_wiz_next'));
98  $this->addCommandButton('selfAssessmentAssignment',$this->lng->txt('crs_wiz_back'));
99  break;
100  }
101 
102  $this->initQuestionAssignments();
103  }
104 
105  // begin-patch lok
110  public function getSettings()
111  {
112  return $this->settings;
113  }
114  // end-patch lok
115 
123  protected function fillRow($a_set)
124  {
125  foreach($a_set['sub'] as $sub_data)
126  {
127  if($a_set['random'])
128  {
129  break;
130  }
131 
132 
133  if($sub_data['description'])
134  {
135  $this->tpl->setVariable('QST_DESCRIPTION',$sub_data['description']);
136  }
137  if($sub_data['qst_txt'])
138  {
139  $txt = $sub_data['qst_txt'];
140  if($sub_data['qst_points'])
141  {
142  $this->lng->loadLanguageModule('assessment');
143  $txt .= (' ('.$sub_data['qst_points'].' '.$this->lng->txt('points').')');
144  }
145 
146  $this->tpl->setVariable('QST_DESCRIPTION',$txt);
147  }
148  $this->tpl->setCurrentBlock('qst');
149  $this->tpl->setVariable('QST_TITLE',$sub_data['title']);
150  $this->tpl->setVariable('QST_ID',$a_set['id'].'_'.$sub_data['id']);
151 
152  switch($this->mode)
153  {
155  if($this->objective_qst_obj->isSelfAssessmentQuestion($sub_data['id']))
156  {
157  $this->tpl->setVariable('QST_CHECKED','checked="checked"');
158  }
159  break;
160 
162  if($this->objective_qst_obj->isFinalTestQuestion($sub_data['id']))
163  {
164  $this->tpl->setVariable('QST_CHECKED','checked="checked"');
165  }
166  break;
167  }
168  $this->tpl->parseCurrentBlock();
169  }
170  if(count($a_set['sub']) and !$a_set['random'])
171  {
172  $this->tpl->setVariable('TXT_QUESTIONS',$this->lng->txt('objs_qst'));
173  }
174  if($a_set['random'])
175  {
176  $this->tpl->setVariable('VAL_WARN',$this->lng->txt('crs_objective_random_warn'));
177  }
178 
179  $this->tpl->setVariable('VAL_ID',$a_set['id']);
180 
181  $this->tpl->setVariable('ROW_TYPE_IMG',ilObject::_getIcon($a_set['obj_id'],"tiny", $a_set['type']));
182  $this->tpl->setVariable('ROW_TYPE_ALT',$this->lng->txt('obj_'.$a_set['type']));
183 
184  $this->tpl->setVariable('VAL_TITLE',$a_set['title']);
185  if(strlen($a_set['description']))
186  {
187  $this->tpl->setVariable('VAL_DESC',$a_set['description']);
188  }
189  }
190 
198  public function parse($a_assignable)
199  {
200  global $objDefinition;
201 
202  // begin-patch lok
203  $a_assignable = $this->getTestNode();
204  // end-patch lok
205  $tests = array();
206 
207  foreach($a_assignable as $node)
208  {
209  $tmp_data = array();
210  $subobjects = array();
211 
212  if(!$tmp_tst = ilObjectFactory::getInstanceByRefId((int) $node['ref_id'],false))
213  {
214  continue;
215  }
216 
217  include_once './Modules/Test/classes/class.ilObjTest.php';
218  $tmp_data['random'] = ilObjTest::_lookupRandomTest($node['obj_id']);
219  $tmp_data['random'] = false;
220 
221  foreach($qst = $this->sortQuestions($tmp_tst->getAllQuestions()) as $question_data)
222  {
223  $tmp_question = ilObjTest::_instanciateQuestion($question_data['question_id']);
224  #$sub['qst_txt'] = $tmp_question->_getQuestionText($question_data['question_id']);
225  $sub['qst_txt'] = '';
226  $sub['qst_points'] = $tmp_question->_getMaximumPoints($question_data['question_id']);
227 
228  $sub['title'] = $tmp_question->getTitle();
229  $sub['description'] = $tmp_question->getComment();
230  $sub['id'] = $question_data['question_id'];
231 
232  $subobjects[] = $sub;
233 
234  }
235  $tmp_data['title'] = $node['title'];
236  $tmp_data['description'] = $node['description'];
237  $tmp_data['type'] = $node['type'];
238  $tmp_data['id'] = $node['child'];
239  $tmp_data['obj_id'] = $node['obj_id'];
240  $tmp_data['sub'] = $subobjects;
241 
242  $tests[] = $tmp_data;
243  }
244 
245  $this->setData($tests);
246  }
247  // begin-patch lok
248  protected function getTestNode()
249  {
251  {
252  $tst_ref_id = $this->getSettings()->getInitialTest();
253  if($tst_ref_id)
254  {
255  return array($GLOBALS['tree']->getNodeData($tst_ref_id));
256  }
257  }
259  {
260  $tst_ref_id = $this->getSettings()->getQualifiedTest();
261  if($tst_ref_id)
262  {
263  return array($GLOBALS['tree']->getNodeData($tst_ref_id));
264  }
265  }
266  return array();
267  }
268  // end-patch lok
269 
276  protected function initQuestionAssignments()
277  {
278  include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
279  $this->objective_qst_obj = new ilCourseObjectiveQuestion($this->objective_id);
280 
281  return true;
282  }
283 
291  protected function sortQuestions($a_qst_ids)
292  {
293  return ilUtil::sortArray($a_qst_ids,'title','asc');
294  }
295 
296 }
297 ?>
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
static getInstanceByObjId($a_obj_id)
get singleton instance
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
setFormName($a_formname)
Set Form name.
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static _lookupRandomTest($a_obj_id)
Returns the fact wether the test with passed obj id is a random questions test or not...
& _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
global $ilCtrl
Definition: ilias.php:18
setLimit($a_limit=0, $a_default_limit=0)
set max.
Class ilTable2GUI.
$GLOBALS['ct_recipient']
addColumn($a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="")
Add a column to the header.
$txt
Definition: error.php:10
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
disable($a_module_name)
diesables particular modules of table
global $lng
Definition: privfeed.php:40
TableGUI for question assignments of course objectives.
class ilcourseobjectiveQuestion
__construct($a_parent_obj, $a_course_obj, $a_objective_id, $a_mode)
Constructor.