ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
24include_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 $DIC;
47
48 $lng = $DIC['lng'];
49 $ilCtrl = $DIC['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, 'questionOverview');
58 $this->setFormName('questions');
59 $this->addColumn($this->lng->txt('title'), 'title', '33%');
60 $this->addColumn($this->lng->txt('crs_objective_self_assessment'), 'self', '33%%');
61 $this->addColumn($this->lng->txt('crs_objective_final_test'), 'final', '33%');
62
63 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
64 $this->setRowTemplate("tpl.crs_questions_table_row.html", "Modules/Course");
65 $this->disable('sort');
66 $this->enable('header');
67 $this->disable('numinfo');
68 $this->enable('select_all');
69 $this->setLimit(200);
70
71 $this->addCommandButton('saveQuestionOverview', $this->lng->txt('save'));
72 }
73
81 protected function fillRow($a_set)
82 {
83 static $row_counter = 1;
84
85 $this->tpl->setVariable('VAL_TITLE', $a_set['title']);
86 if (strlen($a_set['description'])) {
87 $this->tpl->setVariable('VAL_DESC', $a_set['description']);
88 }
89
90 foreach ($a_set['self_tests'] as $tst) {
91 foreach ($tst['questions'] as $qst) {
92 $this->tpl->setCurrentBlock('self_qst');
93 $this->tpl->setVariable('SELF_QST_TITLE', $qst['title']);
94 if (strlen($qst['description'])) {
95 $this->tpl->setVariable('SELF_QST_DESCRIPTION', $qst['description']);
96 }
97 $this->tpl->setVariable('SELF_QST_POINTS', $qst['points']);
98 $this->tpl->setVariable('SELF_QST_TXT_POINTS', $this->lng->txt('crs_objective_points'));
99 $this->tpl->parseCurrentBlock();
100 }
101 $this->tpl->setCurrentBlock('self_tst');
102 $this->tpl->setVariable('SELF_TST_TITLE', $tst['title']);
103 if (strlen($tst['description'])) {
104 $this->tpl->setVariable('SELF_TST_DESC', $tst['description']);
105 }
106 $this->tpl->setVariable('SELF_TYPE_IMG', ilUtil::getImagePath('icon_tst.svg'));
107 $this->tpl->setVariable('SELF_TYPE_ALT', $this->lng->txt('obj_tst'));
108 $this->tpl->parseCurrentBlock();
109 }
110 if (count($a_set['self_tests'])) {
111 $this->tpl->setVariable('SELF_TXT_ALL_POINTS', $this->lng->txt('crs_objective_all_points'));
112 $this->tpl->setVariable('SELF_TXT_POINTS', $this->lng->txt('crs_objective_points'));
113 $this->tpl->setVariable('SELF_TXT_REQ_POINTS', $this->lng->txt('crs_obj_required_points'));
114 $this->tpl->setVariable('SELF_POINTS', $a_set['self_max_points']);
115 $this->tpl->setVariable('SELF_ID', $a_set['id']);
116 $this->tpl->setVariable('SELF_LIMIT', $a_set['self_limit']);
117 }
118
119 foreach ($a_set['final_tests'] as $tst) {
120 foreach ($tst['questions'] as $qst) {
121 $this->tpl->setCurrentBlock('final_qst');
122 $this->tpl->setVariable('FINAL_QST_TITLE', $qst['title']);
123 if (strlen($qst['description'])) {
124 $this->tpl->setVariable('FINAL_QST_DESCRIPTION', $qst['description']);
125 }
126 $this->tpl->setVariable('FINAL_QST_POINTS', $qst['points']);
127 $this->tpl->setVariable('FINAL_QST_TXT_POINTS', $this->lng->txt('crs_objective_points'));
128 $this->tpl->parseCurrentBlock();
129 }
130 $this->tpl->setCurrentBlock('final_tst');
131 $this->tpl->setVariable('FINAL_TST_TITLE', $tst['title']);
132 if (strlen($tst['description'])) {
133 $this->tpl->setVariable('FINAL_TST_DESC', $tst['description']);
134 }
135 $this->tpl->setVariable('FINAL_TYPE_IMG', ilUtil::getImagePath('icon_tst.svg'));
136 $this->tpl->setVariable('FINAL_TYPE_ALT', $this->lng->txt('obj_tst'));
137 $this->tpl->parseCurrentBlock();
138 }
139 if (count($a_set['final_tests'])) {
140 $this->tpl->setVariable('FINAL_TXT_ALL_POINTS', $this->lng->txt('crs_objective_all_points'));
141 $this->tpl->setVariable('FINAL_TXT_POINTS', $this->lng->txt('crs_objective_points'));
142 $this->tpl->setVariable('FINAL_TXT_REQ_POINTS', $this->lng->txt('crs_obj_required_points'));
143 $this->tpl->setVariable('FINAL_POINTS', $a_set['final_max_points']);
144 $this->tpl->setVariable('FINAL_ID', $a_set['id']);
145 $this->tpl->setVariable('FINAL_LIMIT', $a_set['final_limit']);
146 }
147
148 $this->tpl->setVariable('TST_CSS', ilUtil::switchColor($row_counter++, 'tblrow1', 'tblrow2'));
149 }
150
157 public function parse($a_objective_ids)
158 {
159 include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
160
161 $objectives = array();
162 foreach ($a_objective_ids as $objective_id) {
163 $objective = new ilCourseObjective($this->course_obj, $objective_id);
164
165 // Self assessment tests
166 $question_obj = new ilCourseObjectiveQuestion($objective_id);
167
168 $tests = array();
169 foreach ($question_obj->getSelfAssessmentTests() as $tmp_test) {
170 if (isset($_POST['self'][$objective_id])) {
171 $objective_data['self_limit'] = $_POST['self'][$objective_id];
172 } else {
173 $objective_data['self_limit'] = $tmp_test['limit'];
174 }
175 $questions = array();
176 foreach ($question_obj->getQuestionsOfTest($tmp_test['obj_id']) as $tmp_question) {
177 $qst['title'] = $tmp_question['title'];
178 $qst['description'] = $tmp_question['description'];
179 $qst['points'] = $tmp_question['points'];
180
181 $questions[] = $qst;
182 }
183 $tst['questions'] = $questions;
184 $tst['title'] = ilObject::_lookupTitle($tmp_test['obj_id']);
185 $tst['description'] = ilObject::_lookupDescription($tmp_test['obj_id']);
186
187 $tests[] = $tst;
188 }
189 $objective_data['self_tests'] = $tests;
190 $objective_data['self_max_points'] = $question_obj->getSelfAssessmentPoints();
191
192 // Final tests
193 $tests = array();
194 foreach ($question_obj->getFinalTests() as $tmp_test) {
195 if (isset($_POST['final'][$objective_id])) {
196 $objective_data['final_limit'] = $_POST['final'][$objective_id];
197 } else {
198 $objective_data['final_limit'] = $tmp_test['limit'];
199 }
200
201 $questions = array();
202 foreach ($question_obj->getQuestionsOfTest($tmp_test['obj_id']) as $tmp_question) {
203 $qst['title'] = $tmp_question['title'];
204 $qst['description'] = $tmp_question['description'];
205 $qst['points'] = $tmp_question['points'];
206
207 $questions[] = $qst;
208 }
209 $tst['questions'] = $questions;
210 $tst['title'] = ilObject::_lookupTitle($tmp_test['obj_id']);
211 $tst['description'] = ilObject::_lookupDescription($tmp_test['obj_id']);
212
213 $tests[] = $tst;
214 }
215
216 $objective_data['final_tests'] = $tests;
217 $objective_data['final_max_points'] = $question_obj->getFinalTestPoints();
218
219 $objective_data['id'] = $objective_id;
220 $objective_data['title'] = $objective->getTitle();
221
222 $objective_data['description'] = $objective->getDescription();
223
224 $objectives[] = $objective_data;
225 }
226 $this->setData($objectives ? $objectives : array());
227 }
228}
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
class ilcourseobjectiveQuestion
__construct($a_parent_obj, $a_course_obj)
Constructor.
class ilcourseobjective
static _lookupTitle($a_id)
lookup object title
static _lookupDescription($a_id)
lookup object description
Class ilTable2GUI.
setData($a_data)
set table data @access public
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setLimit($a_limit=0, $a_default_limit=0)
set max.
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.
setFormName($a_formname="")
Set Form name.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
disable($a_module_name)
diesables particular modules of table
enable($a_module_name)
enables particular modules of table
static switchColor($a_num, $a_css1, $a_css2)
switches style sheets for each even $a_num (used for changing colors of different result rows)
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
global $ilCtrl
Definition: ilias.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$DIC
Definition: xapitoken.php:46