ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
36 {
37 
38  private $mode = 0;
39  private $objective = null;
40  private $objective_lm = null;
41 
42  private $objective_id = 0;
43  private $course_obj;
44 
52  public function __construct($a_parent_obj,$a_course_obj,$a_objective_id,$a_mode)
53  {
54  global $lng,$ilCtrl;
55 
56  $this->objective_id = $a_objective_id;
57  $this->course_obj = $a_course_obj;
58 
59  $this->lng = $lng;
60  $this->lng->loadLanguageModule('crs');
61  $this->ctrl = $ilCtrl;
62 
63  parent::__construct($a_parent_obj,'materialAssignment');
64  $this->setFormName('assignments');
65  $this->addColumn($this->lng->txt('type'),'type',"1px");
66  $this->addColumn($this->lng->txt('title'),'title','99%');
67 
68  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
69  $this->setRowTemplate("tpl.crs_objective_list_questions_row.html","Modules/Course");
70  $this->disable('sort');
71  $this->disable('header');
72  $this->disable('numinfo');
73  $this->disable('select_all');
74 
75  #$this->setDefaultOrderField('title');
76  $this->setLimit(200);
77 
78  $this->mode = $a_mode;
79  switch($a_mode)
80  {
82  $this->addCommandButton('updateSelfAssessmentAssignment',$this->lng->txt('crs_wiz_next'));
83  $this->addCommandButton('materialAssignment',$this->lng->txt('crs_wiz_back'));
84  break;
85 
87  $this->addCommandButton('updateFinalTestAssignment',$this->lng->txt('crs_wiz_next'));
88  $this->addCommandButton('selfAssessmentAssignment',$this->lng->txt('crs_wiz_back'));
89  break;
90  }
91 
92  $this->initQuestionAssignments();
93  }
94 
102  protected function fillRow($a_set)
103  {
104  foreach($a_set['sub'] as $sub_data)
105  {
106  if($a_set['random'])
107  {
108  break;
109  }
110 
111 
112  if($sub_data['description'])
113  {
114  $this->tpl->setVariable('QST_DESCRIPTION',$sub_data['description']);
115  }
116  $this->tpl->setCurrentBlock('qst');
117  $this->tpl->setVariable('QST_TITLE',$sub_data['title']);
118  $this->tpl->setVariable('QST_ID',$a_set['id'].'_'.$sub_data['id']);
119 
120  switch($this->mode)
121  {
123  if($this->objective_qst_obj->isSelfAssessmentQuestion($sub_data['id']))
124  {
125  $this->tpl->setVariable('QST_CHECKED','checked="checked"');
126  }
127  break;
128 
130  if($this->objective_qst_obj->isFinalTestQuestion($sub_data['id']))
131  {
132  $this->tpl->setVariable('QST_CHECKED','checked="checked"');
133  }
134  break;
135  }
136  $this->tpl->parseCurrentBlock();
137  }
138  if(count($a_set['sub']) and !$a_set['random'])
139  {
140  $this->tpl->setVariable('TXT_QUESTIONS',$this->lng->txt('objs_qst'));
141  }
142  if($a_set['random'])
143  {
144  $this->tpl->setVariable('VAL_WARN',$this->lng->txt('crs_objective_random_warn'));
145  }
146 
147  $this->tpl->setVariable('VAL_ID',$a_set['id']);
148 
149  $this->tpl->setVariable('ROW_TYPE_IMG',ilUtil::getTypeIconPath($a_set['type'],$a_set['obj_id'],'tiny'));
150  $this->tpl->setVariable('ROW_TYPE_ALT',$this->lng->txt('obj_'.$a_set['type']));
151 
152  $this->tpl->setVariable('VAL_TITLE',$a_set['title']);
153  if(strlen($a_set['description']))
154  {
155  $this->tpl->setVariable('VAL_DESC',$a_set['description']);
156  }
157  }
158 
166  public function parse($a_assignable)
167  {
168  global $objDefinition;
169 
170  $tests = array();
171  foreach($a_assignable as $node)
172  {
173  $tmp_data = array();
174  $subobjects = array();
175 
176  if(!$tmp_tst = ilObjectFactory::getInstanceByRefId((int) $node['ref_id'],false))
177  {
178  continue;
179  }
180 
181  include_once './Modules/Test/classes/class.ilObjTest.php';
182  $tmp_data['random'] = ilObjTest::_lookupRandomTest($node['obj_id']);
183 
184  foreach($qst = $this->sortQuestions($tmp_tst->getAllQuestions()) as $question_data)
185  {
186  $tmp_question = ilObjTest::_instanciateQuestion($question_data['question_id']);
187 
188  $sub['title'] = $tmp_question->getTitle();
189  $sub['description'] = $tmp_question->getComment();
190  $sub['id'] = $question_data['question_id'];
191 
192  $subobjects[] = $sub;
193 
194  }
195  $tmp_data['title'] = $node['title'];
196  $tmp_data['description'] = $node['description'];
197  $tmp_data['type'] = $node['type'];
198  $tmp_data['id'] = $node['child'];
199  $tmp_data['obj_id'] = $node['obj_id'];
200  $tmp_data['sub'] = $subobjects;
201 
202  $tests[] = $tmp_data;
203  }
204 
205  $this->setData($tests);
206  }
207 
214  protected function initQuestionAssignments()
215  {
216  include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
217  $this->objective_qst_obj = new ilCourseObjectiveQuestion($this->objective_id);
218 
219  return true;
220  }
221 
229  protected function sortQuestions($a_qst_ids)
230  {
231  return ilUtil::sortArray($a_qst_ids,'title','asc');
232  }
233 
234 }
235 ?>