ILIAS  release_7 Revision v7.30-3-g800a261c036
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
24include_once('./Modules/Course/classes/class.ilCourseObjectiveQuestion.php');
25include_once('./Services/Table/classes/class.ilTable2GUI.php');
26// begin-patch lok
27include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
28// end-patch lok
29
39{
40 // begin-patch lok
41 private $settings = null;
42 // end-patch lok
43
44 private $mode = 0;
45 private $objective = null;
46 private $objective_lm = null;
47
48 private $objective_id = 0;
49 private $course_obj;
50
58 public function __construct($a_parent_obj, $a_course_obj, $a_objective_id, $a_mode)
59 {
60 global $DIC;
61
62 $lng = $DIC['lng'];
63 $ilCtrl = $DIC['ilCtrl'];
64
65 $this->objective_id = $a_objective_id;
66 $this->course_obj = $a_course_obj;
67
68 // begin-patch lok
69 $this->settings = ilLOSettings::getInstanceByObjId($this->course_obj->getId());
70 // end-patch lok
71
72 $this->lng = $lng;
73 $this->lng->loadLanguageModule('crs');
74 $this->ctrl = $ilCtrl;
75
76 parent::__construct($a_parent_obj, 'materialAssignment');
77 $this->setFormName('assignments');
78 $this->addColumn($this->lng->txt('type'), 'type', "20px");
79 $this->addColumn($this->lng->txt('title'), 'title', '');
80
81 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
82 $this->setRowTemplate("tpl.crs_objective_list_questions_row.html", "Modules/Course");
83 $this->disable('sort');
84 $this->disable('header');
85 $this->disable('numinfo');
86 $this->disable('select_all');
87
88 #$this->setDefaultOrderField('title');
89 $this->setLimit(200);
90
91 $this->mode = $a_mode;
92 switch ($a_mode) {
94 $this->addCommandButton('updateSelfAssessmentAssignment', $this->lng->txt('crs_wiz_next'));
95 break;
96
98 $this->addCommandButton('updateFinalTestAssignment', $this->lng->txt('crs_wiz_next'));
99 break;
100 }
101
103 }
104
105 // begin-patch lok
110 public function getSettings()
111 {
112 return $this->settings;
113 }
114 // end-patch lok
115
123 protected function fillRow($a_set)
124 {
125 foreach ($a_set['sub'] as $sub_data) {
126 if ($a_set['random']) {
127 break;
128 }
129
130
131 if ($sub_data['description']) {
132 $this->tpl->setVariable('QST_DESCRIPTION', $sub_data['description']);
133 }
134 if ($sub_data['qst_txt']) {
135 $txt = $sub_data['qst_txt'];
136 if ($sub_data['qst_points']) {
137 $this->lng->loadLanguageModule('assessment');
138 $txt .= (' (' . $sub_data['qst_points'] . ' ' . $this->lng->txt('points') . ')');
139 }
140
141 $this->tpl->setVariable('QST_DESCRIPTION', $txt);
142 }
143 $this->tpl->setCurrentBlock('qst');
144 $this->tpl->setVariable('QST_TITLE', $sub_data['title']);
145 $this->tpl->setVariable('QST_ID', $a_set['id'] . '_' . $sub_data['id']);
146
147 switch ($this->mode) {
149 if ($this->objective_qst_obj->isSelfAssessmentQuestion($sub_data['id'])) {
150 $this->tpl->setVariable('QST_CHECKED', 'checked="checked"');
151 }
152 break;
153
155 if ($this->objective_qst_obj->isFinalTestQuestion($sub_data['id'])) {
156 $this->tpl->setVariable('QST_CHECKED', 'checked="checked"');
157 }
158 break;
159 }
160 $this->tpl->parseCurrentBlock();
161 }
162 if (count($a_set['sub']) and !$a_set['random']) {
163 $this->tpl->setVariable('TXT_QUESTIONS', $this->lng->txt('objs_qst'));
164 }
165 if ($a_set['random']) {
166 $this->tpl->setVariable('VAL_WARN', $this->lng->txt('crs_objective_random_warn'));
167 }
168
169 $this->tpl->setVariable('VAL_ID', $a_set['id']);
170
171 $this->tpl->setVariable('ROW_TYPE_IMG', ilObject::_getIcon($a_set['obj_id'], "tiny", $a_set['type']));
172 $this->tpl->setVariable('ROW_TYPE_ALT', $this->lng->txt('obj_' . $a_set['type']));
173
174 $this->tpl->setVariable('VAL_TITLE', $a_set['title']);
175 if (strlen($a_set['description'])) {
176 $this->tpl->setVariable('VAL_DESC', $a_set['description']);
177 }
178 }
179
187 public function parse($a_assignable)
188 {
189 global $DIC;
190
191 $objDefinition = $DIC['objDefinition'];
192
193 // begin-patch lok
194 $a_assignable = $this->getTestNode();
195 // end-patch lok
196 $tests = array();
197
198 foreach ($a_assignable as $node) {
199 $tmp_data = array();
200 $subobjects = array();
201
202 if (!$tmp_tst = ilObjectFactory::getInstanceByRefId((int) $node['ref_id'], false)) {
203 continue;
204 }
205
206 include_once './Modules/Test/classes/class.ilObjTest.php';
207 $tmp_data['random'] = ilObjTest::_lookupRandomTest($node['obj_id']);
208 $tmp_data['random'] = false;
209
210 foreach ($qst = $this->sortQuestions($tmp_tst->getAllQuestions()) as $question_data) {
211 $tmp_question = ilObjTest::_instanciateQuestion($question_data['question_id']);
212 #$sub['qst_txt'] = $tmp_question->_getQuestionText($question_data['question_id']);
213 $sub['qst_txt'] = '';
214 $sub['qst_points'] = assQuestion::_getMaximumPoints($question_data['question_id']);
215
216 $sub['title'] = $tmp_question->getTitle();
217 $sub['description'] = $tmp_question->getComment();
218 $sub['id'] = $question_data['question_id'];
219
220 $subobjects[] = $sub;
221 }
222 $tmp_data['title'] = $node['title'];
223 $tmp_data['description'] = $node['description'];
224 $tmp_data['type'] = $node['type'];
225 $tmp_data['id'] = $node['child'];
226 $tmp_data['obj_id'] = $node['obj_id'];
227 $tmp_data['sub'] = $subobjects;
228
229 $tests[] = $tmp_data;
230 }
231
232 $this->setData($tests);
233 }
234 // begin-patch lok
235 protected function getTestNode()
236 {
238 $tst_ref_id = $this->getSettings()->getInitialTest();
239 if ($tst_ref_id) {
240 return array($GLOBALS['DIC']['tree']->getNodeData($tst_ref_id));
241 }
242 }
244 $tst_ref_id = $this->getSettings()->getQualifiedTest();
245 if ($tst_ref_id) {
246 return array($GLOBALS['DIC']['tree']->getNodeData($tst_ref_id));
247 }
248 }
249 return array();
250 }
251 // end-patch lok
252
259 protected function initQuestionAssignments()
260 {
261 include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
262 $this->objective_qst_obj = new ilCourseObjectiveQuestion($this->objective_id);
263
264 return true;
265 }
266
274 protected function sortQuestions($a_qst_ids)
275 {
276 return ilUtil::sortArray($a_qst_ids, 'title', 'asc');
277 }
278}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
An exception for terminatinating execution or to throw for unit testing.
static _getMaximumPoints($question_id)
Returns the maximum points, a learner can reach answering the question.
TableGUI for question assignments of course objectives.
__construct($a_parent_obj, $a_course_obj, $a_objective_id, $a_mode)
Constructor.
class ilcourseobjectiveQuestion
static getInstanceByObjId($a_obj_id)
get singleton instance
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
static _lookupRandomTest($a_obj_id)
Returns the fact wether the test with passed obj id is a random questions test or not.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
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
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
$txt
Definition: error.php:13
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
settings()
Definition: settings.php:2