ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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  $this->tpl->setVariable('VAL_DESC', $a_set['description']);
85  }
86 
87  foreach ($a_set['self_tests'] as $tst) {
88  foreach ($tst['questions'] as $qst) {
89  $this->tpl->setCurrentBlock('self_qst');
90  $this->tpl->setVariable('SELF_QST_TITLE', $qst['title']);
91  if (strlen($qst['description'])) {
92  $this->tpl->setVariable('SELF_QST_DESCRIPTION', $qst['description']);
93  }
94  $this->tpl->setVariable('SELF_QST_POINTS', $qst['points']);
95  $this->tpl->setVariable('SELF_QST_TXT_POINTS', $this->lng->txt('crs_objective_points'));
96  $this->tpl->parseCurrentBlock();
97  }
98  $this->tpl->setCurrentBlock('self_tst');
99  $this->tpl->setVariable('SELF_TST_TITLE', $tst['title']);
100  if (strlen($tst['description'])) {
101  $this->tpl->setVariable('SELF_TST_DESC', $tst['description']);
102  }
103  $this->tpl->setVariable('SELF_TYPE_IMG', ilUtil::getImagePath('icon_tst.svg'));
104  $this->tpl->setVariable('SELF_TYPE_ALT', $this->lng->txt('obj_tst'));
105  $this->tpl->parseCurrentBlock();
106  }
107  if (count($a_set['self_tests'])) {
108  $this->tpl->setVariable('SELF_TXT_ALL_POINTS', $this->lng->txt('crs_objective_all_points'));
109  $this->tpl->setVariable('SELF_TXT_POINTS', $this->lng->txt('crs_objective_points'));
110  $this->tpl->setVariable('SELF_TXT_REQ_POINTS', $this->lng->txt('crs_obj_required_points'));
111  $this->tpl->setVariable('SELF_POINTS', $a_set['self_max_points']);
112  $this->tpl->setVariable('SELF_ID', $a_set['id']);
113  $this->tpl->setVariable('SELF_LIMIT', $a_set['self_limit']);
114  }
115 
116  foreach ($a_set['final_tests'] as $tst) {
117  foreach ($tst['questions'] as $qst) {
118  $this->tpl->setCurrentBlock('final_qst');
119  $this->tpl->setVariable('FINAL_QST_TITLE', $qst['title']);
120  if (strlen($qst['description'])) {
121  $this->tpl->setVariable('FINAL_QST_DESCRIPTION', $qst['description']);
122  }
123  $this->tpl->setVariable('FINAL_QST_POINTS', $qst['points']);
124  $this->tpl->setVariable('FINAL_QST_TXT_POINTS', $this->lng->txt('crs_objective_points'));
125  $this->tpl->parseCurrentBlock();
126  }
127  $this->tpl->setCurrentBlock('final_tst');
128  $this->tpl->setVariable('FINAL_TST_TITLE', $tst['title']);
129  if (strlen($tst['description'])) {
130  $this->tpl->setVariable('FINAL_TST_DESC', $tst['description']);
131  }
132  $this->tpl->setVariable('FINAL_TYPE_IMG', ilUtil::getImagePath('icon_tst.svg'));
133  $this->tpl->setVariable('FINAL_TYPE_ALT', $this->lng->txt('obj_tst'));
134  $this->tpl->parseCurrentBlock();
135  }
136  if (count($a_set['final_tests'])) {
137  $this->tpl->setVariable('FINAL_TXT_ALL_POINTS', $this->lng->txt('crs_objective_all_points'));
138  $this->tpl->setVariable('FINAL_TXT_POINTS', $this->lng->txt('crs_objective_points'));
139  $this->tpl->setVariable('FINAL_TXT_REQ_POINTS', $this->lng->txt('crs_obj_required_points'));
140  $this->tpl->setVariable('FINAL_POINTS', $a_set['final_max_points']);
141  $this->tpl->setVariable('FINAL_ID', $a_set['id']);
142  $this->tpl->setVariable('FINAL_LIMIT', $a_set['final_limit']);
143  }
144 
145  $this->tpl->setVariable('TST_CSS', ilUtil::switchColor($row_counter++, 'tblrow1', 'tblrow2'));
146  }
147 
154  public function parse($a_objective_ids)
155  {
156  include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
157 
158  $objectives = array();
159  foreach ($a_objective_ids as $objective_id) {
160  $objective = new ilCourseObjective($this->course_obj, $objective_id);
161 
162  // Self assessment tests
163  $question_obj = new ilCourseObjectiveQuestion($objective_id);
164 
165  $tests = array();
166  foreach ($question_obj->getSelfAssessmentTests() as $tmp_test) {
167  if (isset($_POST['self'][$objective_id])) {
168  $objective_data['self_limit'] = $_POST['self'][$objective_id];
169  } else {
170  $objective_data['self_limit'] = $tmp_test['limit'];
171  }
172  $questions = array();
173  foreach ($question_obj->getQuestionsOfTest($tmp_test['obj_id']) as $tmp_question) {
174  $qst['title'] = $tmp_question['title'];
175  $qst['description'] = $tmp_question['description'];
176  $qst['points'] = $tmp_question['points'];
177 
178  $questions[] = $qst;
179  }
180  $tst['questions'] = $questions;
181  $tst['title'] = ilObject::_lookupTitle($tmp_test['obj_id']);
182  $tst['description'] = ilObject::_lookupDescription($tmp_test['obj_id']);
183 
184  $tests[] = $tst;
185  }
186  $objective_data['self_tests'] = $tests;
187  $objective_data['self_max_points'] = $question_obj->getSelfAssessmentPoints();
188 
189  // Final tests
190  $tests = array();
191  foreach ($question_obj->getFinalTests() as $tmp_test) {
192  if (isset($_POST['final'][$objective_id])) {
193  $objective_data['final_limit'] = $_POST['final'][$objective_id];
194  } else {
195  $objective_data['final_limit'] = $tmp_test['limit'];
196  }
197 
198  $questions = array();
199  foreach ($question_obj->getQuestionsOfTest($tmp_test['obj_id']) as $tmp_question) {
200  $qst['title'] = $tmp_question['title'];
201  $qst['description'] = $tmp_question['description'];
202  $qst['points'] = $tmp_question['points'];
203 
204  $questions[] = $qst;
205  }
206  $tst['questions'] = $questions;
207  $tst['title'] = ilObject::_lookupTitle($tmp_test['obj_id']);
208  $tst['description'] = ilObject::_lookupDescription($tmp_test['obj_id']);
209 
210  $tests[] = $tst;
211  }
212 
213  $objective_data['final_tests'] = $tests;
214  $objective_data['final_max_points'] = $question_obj->getFinalTestPoints();
215 
216  $objective_data['id'] = $objective_id;
217  $objective_data['title'] = $objective->getTitle();
218 
219  $objective_data['description'] = $objective->getDescription();
220 
221  $objectives[] = $objective_data;
222  }
223  $this->setData($objectives ? $objectives : array());
224  }
225 }
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
static _lookupTitle($a_id)
lookup object title
global $ilCtrl
Definition: ilias.php:18
Class ilTable2GUI.
class ilcourseobjective
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static _lookupDescription($a_id)
lookup object description
enable($a_module_name)
enables particular modules of table
__construct($a_parent_obj, $a_course_obj)
Constructor.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
Create styles array
The data for the language used.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
disable($a_module_name)
diesables particular modules of table
setFormName($a_formname="")
Set Form name.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
static switchColor($a_num, $a_css1, $a_css2)
switches style sheets for each even $a_num (used for changing colors of different result rows) ...
class ilcourseobjectiveQuestion
$_POST["username"]
setLimit($a_limit=0, $a_default_limit=0)