ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilTestQuestionsTableGUI.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 
36 {
37  protected $writeAccess = false;
38  protected $totalPoints = 0;
39  protected $checked_move = false;
40  protected $total = 0;
41 
42  protected $position = 0;
43 
51  public function __construct($a_parent_obj, $a_parent_cmd, $a_write_access = false, $a_checked_move = false, $a_total = 0)
52  {
53  parent::__construct($a_parent_obj, $a_parent_cmd);
54 
55  global $lng, $ilCtrl;
56 
57  $this->lng = $lng;
58  $this->ctrl = $ilCtrl;
59  $this->total = $a_total;
60 
61  $this->setWriteAccess($a_write_access);
62  $this->setCheckedMove($a_checked_move);
63 
64  $this->setFormName('questionbrowser');
65  $this->setStyle('table', 'fullwidth');
66  $this->addColumn('','f','1%');
67  $this->addColumn('','f','1%');
68  $this->addColumn($this->lng->txt("tst_question_title"),'title', '');
69  //$this->addColumn($this->lng->txt("tst_sequence"),'sequence', '');
70  if( $a_parent_obj->object->areObligationsEnabled() )
71  {
72  $this->addColumn($this->lng->txt("obligatory"),'obligatory', '');
73  }
74  $this->addColumn($this->lng->txt("description"),'description', '');
75  $this->addColumn($this->lng->txt("tst_question_type"),'type', '');
76  $this->addColumn($this->lng->txt("points"),'', '');
77  $this->addColumn($this->lng->txt("author"),'author', '');
78  $this->addColumn($this->lng->txt("qpl"),'qpl', '');
79 
80  $this->setPrefix('q_id');
81  $this->setSelectAllCheckbox('q_id');
82 
83  $this->setExternalSegmentation(true);
84 
85  if ($this->getWriteAccess() && !$this->getTotal())
86  {
87  $this->addMultiCommand('removeQuestions', $this->lng->txt('remove_question'));
88  $this->addMultiCommand('moveQuestions', $this->lng->txt('move'));
89  if ($this->checked_move)
90  {
91  $this->addMultiCommand('insertQuestionsBefore', $this->lng->txt('insert_before'));
92  $this->addMultiCommand('insertQuestionsAfter', $this->lng->txt('insert_after'));
93  }
94  //$this->addMultiCommand('copyToQuestionpool', $this->lng->txt('copy_to_questionpool'));
95  $this->addMultiCommand('copyQuestion', $this->lng->txt('copy'));
96  $this->addMultiCommand('copyAndLinkToQuestionpool', $this->lng->txt('copy_and_link_to_questionpool'));
97 
98  }
99 
100 
101  $this->setRowTemplate("tpl.il_as_tst_questions_row.html", "Modules/Test");
102 
103  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
104 
105  if( $a_parent_obj->object->areObligationsEnabled() )
106  {
107  $this->addCommandButton('saveOrderAndObligations', $this->lng->txt('saveOrderAndObligations'));
108  }
109  else
110  {
111  $this->addCommandButton('saveOrderAndObligations', $this->lng->txt('saveOrder'));
112  }
113 
114  $this->disable('sort');
115  $this->enable('header');
116  $this->enable('select_all');
117  }
118 
119  function fillHeader()
120  {
121  foreach ($this->column as $key => $column)
122  {
123  if (strcmp($column['text'], $this->lng->txt("points")) == 0)
124  {
125  $this->column[$key]['text'] = $this->lng->txt("points") . "&nbsp;(" . $this->totalPoints . ")";
126  }
127  }
129  }
130 
138  public function fillRow($data)
139  {
140  global $ilUser,$ilAccess;
141 
142  $q_id = $data["question_id"];
143 
144  $this->tpl->setVariable("QUESTION_ID", $q_id);
145  if ($this->getWriteAccess() && !$this->getTotal() && $data["obj_fi"] > 0)
146  {
147  if (!$data['complete']) {
148  $this->tpl->setVariable("IMAGE_WARNING", ilUtil::getImagePath("warning.png"));
149  $this->tpl->setVariable("ALT_WARNING", $this->lng->txt("warning_question_not_complete"));
150  $this->tpl->setVariable("TITLE_WARNING", $this->lng->txt("warning_question_not_complete"));
151  }
152 
153 
154  $qpl_ref_id = current(ilObject::_getAllReferences($data["obj_fi"]));
155  $this->tpl->setVariable("QUESTION_TITLE", "<a href=\"" . $this->ctrl->getLinkTarget($this->getParentObject(), "questions") . "&eqid=$q_id&eqpl=$qpl_ref_id" . "\">" . $data["title"] . "</a>");
156 
157  // obligatory checkbox (when obligation is possible)
158  if( $data["obligationPossible"] )
159  {
160  $CHECKED = $data["obligatory"] ? "checked=\"checked\" " : "";
161  $OBLIGATORY = "<input type=\"checkbox\" name=\"obligatory[$q_id]\" value=\"1\" $CHECKED/>";
162  }
163  else
164  {
165  $OBLIGATORY = "";
166  }
167  }
168  else
169  {
170  global $lng;
171 
172  $this->tpl->setVariable("QUESTION_TITLE", $data["title"]);
173 
174  // obligatory icon
175  if( $data["obligatory"] )
176  {
177  $OBLIGATORY = "<img src=\"".ilUtil::getImagePath("obligatory.gif", "Modules/Test").
178  "\" alt=\"".$lng->txt("question_obligatory").
179  "\" title=\"".$lng->txt("question_obligatory")."\" />";
180  }
181  else $OBLIGATORY = '';
182  }
183 
184  if( $this->parent_obj->object->areObligationsEnabled() )
185  {
186  $this->tpl->setVariable("QUESTION_OBLIGATORY", $OBLIGATORY);
187  }
188 
189  $this->tpl->setVariable("QUESTION_SEQUENCE", $this->lng->txt("tst_sequence"));
190 
191  if ($this->getWriteAccess() && !$this->getTotal())
192  {
193  if ($data["sequence"] != 1)
194  {
195  $this->tpl->setVariable("BUTTON_UP", "<a href=\"" . $this->ctrl->getLinkTarget($this->getParentObject(), "questions") . "&up=".$data["question_id"]."\"><img src=\"" . ilUtil::getImagePath("a_up.png") . "\" alt=\"" . $this->lng->txt("up") . "\" border=\"0\" /></a>");
196  }
197  if ($data["sequence"] != count($this->getData()))
198  {
199  $this->tpl->setVariable("BUTTON_DOWN", "<a href=\"" . $this->ctrl->getLinkTarget($this->getParentObject(), "questions") . "&down=".$data["question_id"]."\"><img src=\"" . ilUtil::getImagePath("a_down.png") . "\" alt=\"" . $this->lng->txt("down") . "\" border=\"0\" /></a>");
200  }
201  }
202 
203  $this->tpl->setVariable("QUESTION_COMMENT", $data["description"]);
204 
205  $this->tpl->setVariable("QUESTION_COMMENT", $data["description"]);
206  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
207  $this->tpl->setVariable("QUESTION_TYPE", assQuestion::_getQuestionTypeName($data["type_tag"]));
208  $this->tpl->setVariable("QUESTION_POINTS", $data["points"]);
209  $this->totalPoints += $data["points"];
210  $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]);
211  if (ilObject::_lookupType($data["orig_obj_fi"]) == 'qpl') {
212  $this->tpl->setVariable("QUESTION_POOL", ilObject::_lookupTitle($data["orig_obj_fi"]));
213  }
214  else {
215  $this->tpl->setVariable("QUESTION_POOL", $this->lng->txt('tst_question_not_from_pool_info'));
216  }
217 
218 
219  $this->position += 10;
220  $field = "<input type=\"text\" name=\"order[q_".$data["question_id"].
221  "]\" value=\"".$this->position."\" maxlength=\"3\" style=\"width:30px\" />";
222  $this->tpl->setVariable("QUESTION_POSITION", $field);
223  }
224 
225  public function setWriteAccess($value)
226  {
227  $this->writeAccess = $value;
228  }
229 
230  public function getWriteAccess()
231  {
232  return $this->writeAccess;
233  }
234 
235  public function setCheckedMove($value)
236  {
237  $this->checked_move = $value;
238  }
239 
240  public function getCheckedMove()
241  {
242  return $this->checked_move;
243  }
244 
245  public function setTotal($value)
246  {
247  $this->total = $value;
248  }
249 
250  public function getTotal()
251  {
252  return $this->total;
253  }
254 }
255 ?>