ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilCourseObjectiveQuestionsTableGUI.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 
34 {
35  protected $course_obj = null;
36 
44  public function __construct($a_parent_obj,$a_course_obj)
45  {
46  global $lng,$ilCtrl;
47 
48  $this->course_obj = $a_course_obj;
49 
50  $this->lng = $lng;
51  $this->lng->loadLanguageModule('crs');
52  $this->ctrl = $ilCtrl;
53 
54  parent::__construct($a_parent_obj,'questionOverview');
55  $this->setFormName('questions');
56  $this->addColumn($this->lng->txt('title'),'title','33%');
57  $this->addColumn($this->lng->txt('crs_objective_self_assessment'),'self','33%%');
58  $this->addColumn($this->lng->txt('crs_objective_final_test'),'final','33%');
59 
60  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
61  $this->setRowTemplate("tpl.crs_questions_table_row.html","Modules/Course");
62  $this->disable('sort');
63  $this->enable('header');
64  $this->disable('numinfo');
65  $this->enable('select_all');
66  $this->setLimit(200);
67 
68  $this->addCommandButton('saveQuestionOverview',$this->lng->txt('save'));
69  }
70 
78  protected function fillRow($a_set)
79  {
80  static $row_counter = 1;
81 
82  $this->tpl->setVariable('VAL_TITLE',$a_set['title']);
83  if(strlen($a_set['description']))
84  {
85  $this->tpl->setVariable('VAL_DESC',$a_set['description']);
86  }
87 
88  foreach($a_set['self_tests'] as $tst)
89  {
90  foreach($tst['questions'] as $qst)
91  {
92  $this->tpl->setCurrentBlock('self_qst');
93  $this->tpl->setVariable('SELF_QST_TITLE',$qst['title']);
94  if(strlen($qst['description']))
95  {
96  $this->tpl->setVariable('SELF_QST_DESCRIPTION',$qst['description']);
97  }
98  $this->tpl->setVariable('SELF_QST_POINTS',$qst['points']);
99  $this->tpl->setVariable('SELF_QST_TXT_POINTS',$this->lng->txt('crs_objective_points'));
100  $this->tpl->parseCurrentBlock();
101  }
102  $this->tpl->setCurrentBlock('self_tst');
103  $this->tpl->setVariable('SELF_TST_TITLE',$tst['title']);
104  if(strlen($tst['description']))
105  {
106  $this->tpl->setVariable('SELF_TST_DESC',$tst['description']);
107  }
108  $this->tpl->setVariable('SELF_TYPE_IMG',ilUtil::getImagePath('icon_tst_s.gif'));
109  $this->tpl->setVariable('SELF_TYPE_ALT',$this->lng->txt('obj_tst'));
110  $this->tpl->parseCurrentBlock();
111  }
112  if(count($a_set['self_tests']))
113  {
114  $this->tpl->setVariable('SELF_TXT_ALL_POINTS',$this->lng->txt('crs_objective_all_points'));
115  $this->tpl->setVariable('SELF_TXT_POINTS',$this->lng->txt('crs_objective_points'));
116  $this->tpl->setVariable('SELF_TXT_REQ_POINTS',$this->lng->txt('crs_obj_required_points'));
117  $this->tpl->setVariable('SELF_POINTS',$a_set['self_max_points']);
118  $this->tpl->setVariable('SELF_ID',$a_set['id']);
119  $this->tpl->setVariable('SELF_LIMIT',$a_set['self_limit']);
120  }
121 
122  foreach($a_set['final_tests'] as $tst)
123  {
124  foreach($tst['questions'] as $qst)
125  {
126  $this->tpl->setCurrentBlock('final_qst');
127  $this->tpl->setVariable('FINAL_QST_TITLE',$qst['title']);
128  if(strlen($qst['description']))
129  {
130  $this->tpl->setVariable('FINAL_QST_DESCRIPTION',$qst['description']);
131  }
132  $this->tpl->setVariable('FINAL_QST_POINTS',$qst['points']);
133  $this->tpl->setVariable('FINAL_QST_TXT_POINTS',$this->lng->txt('crs_objective_points'));
134  $this->tpl->parseCurrentBlock();
135  }
136  $this->tpl->setCurrentBlock('final_tst');
137  $this->tpl->setVariable('FINAL_TST_TITLE',$tst['title']);
138  if(strlen($tst['description']))
139  {
140  $this->tpl->setVariable('FINAL_TST_DESC',$tst['description']);
141  }
142  $this->tpl->setVariable('FINAL_TYPE_IMG',ilUtil::getImagePath('icon_tst_s.gif'));
143  $this->tpl->setVariable('FINAL_TYPE_ALT',$this->lng->txt('obj_tst'));
144  $this->tpl->parseCurrentBlock();
145  }
146  if(count($a_set['final_tests']))
147  {
148  $this->tpl->setVariable('FINAL_TXT_ALL_POINTS',$this->lng->txt('crs_objective_all_points'));
149  $this->tpl->setVariable('FINAL_TXT_POINTS',$this->lng->txt('crs_objective_points'));
150  $this->tpl->setVariable('FINAL_TXT_REQ_POINTS',$this->lng->txt('crs_obj_required_points'));
151  $this->tpl->setVariable('FINAL_POINTS',$a_set['final_max_points']);
152  $this->tpl->setVariable('FINAL_ID',$a_set['id']);
153  $this->tpl->setVariable('FINAL_LIMIT',$a_set['final_limit']);
154  }
155 
156  $this->tpl->setVariable('TST_CSS',ilUtil::switchColor($row_counter++,'tblrow1','tblrow2'));
157 
158  }
159 
166  public function parse($a_objective_ids)
167  {
168  include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
169 
170  $objectives = array();
171  foreach($a_objective_ids as $objective_id)
172  {
173  $objective = new ilCourseObjective($this->course_obj,$objective_id);
174 
175  // Self assessment tests
176  $question_obj = new ilCourseObjectiveQuestion($objective_id);
177 
178  $tests = array();
179  foreach($question_obj->getSelfAssessmentTests() as $tmp_test)
180  {
181  if(isset($_POST['self'][$objective_id]))
182  {
183  $objective_data['self_limit'] = $_POST['self'][$objective_id];
184  }
185  else
186  {
187  $objective_data['self_limit'] = $tmp_test['limit'];
188  }
189  $questions = array();
190  foreach($question_obj->getQuestionsOfTest($tmp_test['obj_id']) as $tmp_question)
191  {
192  $qst['title'] = $tmp_question['title'];
193  $qst['description'] = $tmp_question['description'];
194  $qst['points'] = $tmp_question['points'];
195 
196  $questions[] = $qst;
197  }
198  $tst['questions'] = $questions;
199  $tst['title'] = ilObject::_lookupTitle($tmp_test['obj_id']);
200  $tst['description'] = ilObject::_lookupDescription($tmp_test['obj_id']);
201 
202  $tests[] = $tst;
203  }
204  $objective_data['self_tests'] = $tests;
205  $objective_data['self_max_points'] = $question_obj->getSelfAssessmentPoints();
206 
207  // Final tests
208  $tests = array();
209  foreach($question_obj->getFinalTests() as $tmp_test)
210  {
211  if(isset($_POST['final'][$objective_id]))
212  {
213  $objective_data['final_limit'] = $_POST['final'][$objective_id];
214  }
215  else
216  {
217  $objective_data['final_limit'] = $tmp_test['limit'];
218  }
219 
220  $questions = array();
221  foreach($question_obj->getQuestionsOfTest($tmp_test['obj_id']) as $tmp_question)
222  {
223  $qst['title'] = $tmp_question['title'];
224  $qst['description'] = $tmp_question['description'];
225  $qst['points'] = $tmp_question['points'];
226 
227  $questions[] = $qst;
228  }
229  $tst['questions'] = $questions;
230  $tst['title'] = ilObject::_lookupTitle($tmp_test['obj_id']);
231  $tst['description'] = ilObject::_lookupDescription($tmp_test['obj_id']);
232 
233  $tests[] = $tst;
234  }
235 
236  $objective_data['final_tests'] = $tests;
237  $objective_data['final_max_points'] = $question_obj->getFinalTestPoints();
238 
239  $objective_data['id'] = $objective_id;
240  $objective_data['title'] = $objective->getTitle();
241 
242  $objective_data['description'] = $objective->getDescription();
243 
244  $objectives[] = $objective_data;
245 
246  }
247  $this->setData($objectives ? $objectives : array());
248  }
249 }
250 ?>