ILIAS  Release_3_10_x_branch Revision 61812
 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 
107  if($sub_data['description'])
108  {
109  $this->tpl->setVariable('QST_DESCRIPTION',$sub_data['description']);
110  }
111  $this->tpl->setCurrentBlock('qst');
112  $this->tpl->setVariable('QST_TITLE',$sub_data['title']);
113  $this->tpl->setVariable('QST_ID',$a_set['id'].'_'.$sub_data['id']);
114 
115  switch($this->mode)
116  {
118  if($this->objective_qst_obj->isSelfAssessmentQuestion($sub_data['id']))
119  {
120  $this->tpl->setVariable('QST_CHECKED','checked="checked"');
121  }
122  break;
123 
125  if($this->objective_qst_obj->isFinalTestQuestion($sub_data['id']))
126  {
127  $this->tpl->setVariable('QST_CHECKED','checked="checked"');
128  }
129  break;
130  }
131  $this->tpl->parseCurrentBlock();
132  }
133  if(count($a_set['sub']))
134  {
135  $this->tpl->setVariable('TXT_QUESTIONS',$this->lng->txt('objs_qst'));
136  }
137 
138  $this->tpl->setVariable('VAL_ID',$a_set['id']);
139 
140  $this->tpl->setVariable('ROW_TYPE_IMG',ilUtil::getTypeIconPath($a_set['type'],$a_set['obj_id'],'tiny'));
141  $this->tpl->setVariable('ROW_TYPE_ALT',$this->lng->txt('obj_'.$a_set['type']));
142 
143  $this->tpl->setVariable('VAL_TITLE',$a_set['title']);
144  if(strlen($a_set['description']))
145  {
146  $this->tpl->setVariable('VAL_DESC',$a_set['description']);
147  }
148  }
149 
157  public function parse($a_assignable)
158  {
159  global $objDefinition;
160 
161  $tests = array();
162  foreach($a_assignable as $node)
163  {
164  $tmp_data = array();
165  $subobjects = array();
166 
167  if(!$tmp_tst = ilObjectFactory::getInstanceByRefId((int) $node['ref_id'],false))
168  {
169  continue;
170  }
171 
172  foreach($qst = $this->sortQuestions($tmp_tst->getAllQuestions()) as $question_data)
173  {
174  $tmp_question = ilObjTest::_instanciateQuestion($question_data['question_id']);
175 
176  $sub['title'] = $tmp_question->getTitle();
177  $sub['description'] = $tmp_question->getComment();
178  $sub['id'] = $question_data['question_id'];
179 
180  $subobjects[] = $sub;
181 
182  }
183  $tmp_data['title'] = $node['title'];
184  $tmp_data['description'] = $node['description'];
185  $tmp_data['type'] = $node['type'];
186  $tmp_data['id'] = $node['child'];
187  $tmp_data['obj_id'] = $node['obj_id'];
188  $tmp_data['sub'] = $subobjects;
189 
190  $tests[] = $tmp_data;
191  }
192 
193  $this->setData($tests);
194  }
195 
202  protected function initQuestionAssignments()
203  {
204  include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
205  $this->objective_qst_obj = new ilCourseObjectiveQuestion($this->objective_id);
206 
207  return true;
208  }
209 
217  protected function sortQuestions($a_qst_ids)
218  {
219  return ilUtil::sortArray($a_qst_ids,'title','asc');
220  }
221 
222 }
223 ?>