ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilCourseObjectivesTableGUI.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('./Services/Table/classes/class.ilTable2GUI.php');
25 include_once './Modules/Course/classes/class.ilCourseObjective.php';
26 include_once('./Modules/Course/classes/class.ilCourseObjectiveMaterials.php');
27 include_once('./Modules/Course/classes/class.ilCourseObjectiveQuestion.php');
28 
37 {
38  protected $course_obj = null;
39 
47  public function __construct($a_parent_obj,$a_course_obj)
48  {
49  global $lng,$ilCtrl;
50 
51  $this->course_obj = $a_course_obj;
52 
53  $this->lng = $lng;
54  $this->lng->loadLanguageModule('crs');
55  $this->ctrl = $ilCtrl;
56 
57  parent::__construct($a_parent_obj,'listObjectives');
58  $this->setFormName('objectives');
59  $this->addColumn('','f',"1px");
60  $this->addColumn($this->lng->txt('position'),'1px');
61  $this->addColumn($this->lng->txt('title'),'title','25%');
62  $this->addColumn($this->lng->txt('crs_objective_assigned_materials'),'materials','25%');
63  $this->addColumn($this->lng->txt('crs_objective_self_assessment'),'self','25%');
64  $this->addColumn($this->lng->txt('crs_objective_final_test'),'final','25%');
65  $this->addColumn($this->lng->txt(''),'5em');
66 
67  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
68  $this->setRowTemplate("tpl.crs_objectives_table_row.html","Modules/Course");
69  $this->disable('sort');
70  $this->enable('header');
71  $this->disable('numinfo');
72  $this->enable('select_all');
73  $this->setLimit(200);
74 
75  $this->addMultiCommand('askDeleteObjective',$this->lng->txt('delete'));
76  $this->addCommandButton('saveSorting',$this->lng->txt('sorting_save'));
77  $this->addCommandButton('create',$this->lng->txt('crs_add_objective'));
78  }
79 
87  protected function fillRow($a_set)
88  {
89  $this->tpl->setVariable('VAL_ID',$a_set['id']);
90  $this->tpl->setVariable('VAL_POSITION',$a_set['position']);
91  $this->tpl->setVariable('VAL_TITLE',$a_set['title']);
92  if(strlen($a_set['description']))
93  {
94  $this->tpl->setVariable('VAL_DESC',$a_set['description']);
95  }
96 
97  // materials
98  foreach($a_set['materials'] as $ref_id => $data)
99  {
100  if($data['items'])
101  {
102  $this->tpl->touchBlock('ul_begin');
103  foreach($data['items'] as $pg_st)
104  {
105  $this->tpl->setCurrentBlock('st_pg');
106  $this->tpl->setVariable('MAT_IMG',ilUtil::getImagePath('icon_'.$pg_st['type'].'_s.gif'));
107  $this->tpl->setVariable('MAT_ALT',$this->lng->txt('obj_'.$pg_st['type']));
108  include_once('Modules/LearningModule/classes/class.ilLMObject.php');
109  $title = ilLMObject::_lookupTitle($pg_st['obj_id']);
110  $this->tpl->setVariable('MAT_TITLE',$title);
111  $this->tpl->parseCurrentBlock();
112  }
113  $this->tpl->touchBlock('ul_end');
114  }
115  else
116  {
117  $this->tpl->touchBlock('new_line');
118  }
119  $this->tpl->setCurrentBlock('mat_row');
120  $this->tpl->setVariable('LM_IMG',ilUtil::getImagePath('icon_'.$data['type'].'_s.gif'));
121  $this->tpl->setVariable('LM_ALT',$this->lng->txt('obj_'.$data['type']));
122  $this->tpl->setVariable('LM_TITLE',ilObject::_lookupTitle($data['obj_id']));
123  $this->tpl->parseCurrentBlock();
124  }
125 
126  // self assessment
127  foreach($a_set['self'] as $test)
128  {
129  foreach($test['questions'] as $question)
130  {
131  $this->tpl->setCurrentBlock('self_qst_row');
132  $this->tpl->setVariable('SELF_QST_TITLE',$question['title']);
133  $this->tpl->parseCurrentBlock();
134  }
135  $this->tpl->setCurrentBlock('self_test_row');
136  $this->tpl->setVariable('SELF_TST_IMG',ilUtil::getImagePath('icon_tst_s.gif'));
137  $this->tpl->setVariable('SELF_TST_ALT',$this->lng->txt('obj_tst'));
138  $this->tpl->setVariable('SELF_TST_TITLE',ilObject::_lookupTitle($test['obj_id']));
139  $this->tpl->parseCurrentBlock();
140  }
141 
142  // final test questions
143  foreach($a_set['final'] as $test)
144  {
145  foreach($test['questions'] as $question)
146  {
147  $this->tpl->setCurrentBlock('final_qst_row');
148  $this->tpl->setVariable('FINAL_QST_TITLE',$question['title']);
149  $this->tpl->parseCurrentBlock();
150  }
151  $this->tpl->setCurrentBlock('final_test_row');
152  $this->tpl->setVariable('FINAL_TST_IMG',ilUtil::getImagePath('icon_tst_s.gif'));
153  $this->tpl->setVariable('FINAL_TST_ALT',$this->lng->txt('obj_tst'));
154  $this->tpl->setVariable('FINAL_TST_TITLE',ilObject::_lookupTitle($test['obj_id']));
155  $this->tpl->parseCurrentBlock();
156  }
157 
158  // Edit Link
159  $this->ctrl->setParameterByClass(get_class($this->getParentObject()),'objective_id',$a_set['id']);
160  $this->tpl->setVariable('EDIT_LINK',$this->ctrl->getLinkTargetByClass(get_class($this->getParentObject()),'edit'));
161  $this->tpl->setVariable('TXT_EDIT',$this->lng->txt('edit'));
162  }
163 
164 
171  public function parse($a_objective_ids)
172  {
173  $position = 1;
174  foreach($a_objective_ids as $objective_id)
175  {
176  $objective = new ilCourseObjective($this->course_obj,$objective_id);
177 
178  $objective_data['id'] = $objective_id;
179  $objective_data['position'] = sprintf("%.1f",$position++);
180  $objective_data['title'] = $objective->getTitle();
181  $objective_data['description'] = $objective->getDescription();
182 
183  // assigned materials
184  $materials = array();
185  $ass_materials = new ilCourseObjectiveMaterials($objective_id);
186  foreach($ass_materials->getMaterials() as $material)
187  {
188  $materials[$material['ref_id']]['obj_id'] = $obj_id = ilObject::_lookupObjId($material['ref_id']);
189  $materials[$material['ref_id']]['type'] = ilObject::_lookupType($obj_id);
190 
191  switch($material['type'])
192  {
193  case 'pg':
194  case 'st':
195  $materials[$material['ref_id']]['items'][] = $material;
196  break;
197  default:
198 
199  }
200 
201 
202  }
203  $objective_data['materials'] = $materials;
204  $question_obj = new ilCourseObjectiveQuestion($objective_id);
205 
206  // self assessment questions
207  $tests = array();
208  foreach($question_obj->getSelfAssessmentTests() as $test)
209  {
210  $questions = array();
211  foreach($question_obj->getQuestionsOfTest($test['obj_id']) as $qst)
212  {
213  $questions[] = $qst;
214  }
215  $tmp_test = $test;
216  $tmp_test['questions'] = $questions;
217 
218  $tests[] = $tmp_test;
219  }
220  $objective_data['self'] = $tests;
221 
222  // final test questions
223  $tests = array();
224  foreach($question_obj->getFinalTests() as $test)
225  {
226  $questions = array();
227  foreach($question_obj->getQuestionsOfTest($test['obj_id']) as $qst)
228  {
229  $questions[] = $qst;
230  }
231  $tmp_test = $test;
232  $tmp_test['questions'] = $questions;
233 
234  $tests[] = $tmp_test;
235  }
236  $objective_data['final'] = $tests;
237 
238  $objectives[] = $objective_data;
239  }
240 
241  $this->setData($objectives ? $objectives : array());
242  }
243 
244 }
245 ?>