ILIAS  Release_4_2_x_branch Revision 61807
 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 
35 {
36  protected $writeAccess = false;
37  protected $totalPoints = 0;
38  protected $checked_move = false;
39  protected $total = 0;
40 
41  protected $position = 0;
42 
50  public function __construct($a_parent_obj, $a_parent_cmd, $a_write_access = false, $a_checked_move = false, $a_total = 0)
51  {
52  parent::__construct($a_parent_obj, $a_parent_cmd);
53 
54  global $lng, $ilCtrl;
55 
56  $this->lng = $lng;
57  $this->ctrl = $ilCtrl;
58  $this->total = $a_total;
59 
60  $this->setWriteAccess($a_write_access);
61  $this->setCheckedMove($a_checked_move);
62 
63  $this->setFormName('questionbrowser');
64  $this->setStyle('table', 'fullwidth');
65  $this->addColumn('','f','1%');
66  $this->addColumn('','f','1%');
67  $this->addColumn($this->lng->txt("tst_question_title"),'title', '');
68  //$this->addColumn($this->lng->txt("tst_sequence"),'sequence', '');
69  $this->addColumn($this->lng->txt("description"),'description', '');
70  $this->addColumn($this->lng->txt("tst_question_type"),'type', '');
71  $this->addColumn($this->lng->txt("points"),'', '');
72  $this->addColumn($this->lng->txt("author"),'author', '');
73  $this->addColumn($this->lng->txt("qpl"),'qpl', '');
74 
75  $this->setPrefix('q_id');
76  $this->setSelectAllCheckbox('q_id');
77 
78  $this->setExternalSegmentation(true);
79 
80  if ($this->getWriteAccess() && !$this->getTotal())
81  {
82  $this->addMultiCommand('removeQuestions', $this->lng->txt('remove_question'));
83  $this->addMultiCommand('moveQuestions', $this->lng->txt('move'));
84  if ($this->checked_move)
85  {
86  $this->addMultiCommand('insertQuestionsBefore', $this->lng->txt('insert_before'));
87  $this->addMultiCommand('insertQuestionsAfter', $this->lng->txt('insert_after'));
88  }
89  //$this->addMultiCommand('copyToQuestionpool', $this->lng->txt('copy_to_questionpool'));
90  $this->addMultiCommand('copyQuestion', $this->lng->txt('copy'));
91  $this->addMultiCommand('copyAndLinkToQuestionpool', $this->lng->txt('copy_and_link_to_questionpool'));
92 
93  }
94 
95 
96  $this->setRowTemplate("tpl.il_as_tst_questions_row.html", "Modules/Test");
97 
98  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
99 
100  $this->addCommandButton('saveOrder', $this->lng->txt('saveOrder'));
101 
102  $this->disable('sort');
103  $this->enable('header');
104  $this->enable('select_all');
105  }
106 
107  function fillHeader()
108  {
109  foreach ($this->column as $key => $column)
110  {
111  if (strcmp($column['text'], $this->lng->txt("points")) == 0)
112  {
113  $this->column[$key]['text'] = $this->lng->txt("points") . "&nbsp;(" . $this->totalPoints . ")";
114  }
115  }
117  }
118 
126  public function fillRow($data)
127  {
128  global $ilUser,$ilAccess;
129 
130  $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
131  if ($this->getWriteAccess() && !$this->getTotal() && $data["obj_fi"] > 0)
132  {
133  if (!$data['complete']) {
134  $this->tpl->setVariable("IMAGE_WARNING", ilUtil::getImagePath("warning.gif"));
135  $this->tpl->setVariable("ALT_WARNING", $this->lng->txt("warning_question_not_complete"));
136  $this->tpl->setVariable("TITLE_WARNING", $this->lng->txt("warning_question_not_complete"));
137  }
138 
139  $q_id = $data["question_id"];
140  $qpl_ref_id = current(ilObject::_getAllReferences($data["obj_fi"]));
141  $this->tpl->setVariable("QUESTION_TITLE", "<a href=\"" . $this->ctrl->getLinkTarget($this->getParentObject(), "questions") . "&eqid=$q_id&eqpl=$qpl_ref_id" . "\">" . $data["title"] . "</a>");
142  }
143  else
144  {
145  $this->tpl->setVariable("QUESTION_TITLE", $data["title"]);
146  }
147  $this->tpl->setVariable("QUESTION_SEQUENCE", $this->lng->txt("tst_sequence"));
148 
149  if ($this->getWriteAccess() && !$this->getTotal())
150  {
151  if ($data["sequence"] != 1)
152  {
153  $this->tpl->setVariable("BUTTON_UP", "<a href=\"" . $this->ctrl->getLinkTarget($this->getParentObject(), "questions") . "&up=".$data["question_id"]."\"><img src=\"" . ilUtil::getImagePath("a_up.gif") . "\" alt=\"" . $this->lng->txt("up") . "\" border=\"0\" /></a>");
154  }
155  if ($data["sequence"] != count($this->getData()))
156  {
157  $this->tpl->setVariable("BUTTON_DOWN", "<a href=\"" . $this->ctrl->getLinkTarget($this->getParentObject(), "questions") . "&down=".$data["question_id"]."\"><img src=\"" . ilUtil::getImagePath("a_down.gif") . "\" alt=\"" . $this->lng->txt("down") . "\" border=\"0\" /></a>");
158  }
159  }
160  $this->tpl->setVariable("QUESTION_COMMENT", $data["description"]);
161  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
162  $this->tpl->setVariable("QUESTION_TYPE", assQuestion::_getQuestionTypeName($data["type_tag"]));
163  $this->tpl->setVariable("QUESTION_POINTS", $data["points"]);
164  $this->totalPoints += $data["points"];
165  $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]);
166  if (ilObject::_lookupType($data["orig_obj_fi"]) == 'qpl') {
167  $this->tpl->setVariable("QUESTION_POOL", ilObject::_lookupTitle($data["orig_obj_fi"]));
168  }
169  else {
170  $this->tpl->setVariable("QUESTION_POOL", '&nbsp;');
171  }
172 
173 
174  $this->position += 10;
175  $field = "<input type=\"text\" name=\"order[q_".$data["question_id"].
176  "]\" value=\"".$this->position."\" maxlength=\"3\" style=\"width:30px\" />";
177  $this->tpl->setVariable("QUESTION_POSITION", $field);
178  }
179 
180  public function setWriteAccess($value)
181  {
182  $this->writeAccess = $value;
183  }
184 
185  public function getWriteAccess()
186  {
187  return $this->writeAccess;
188  }
189 
190  public function setCheckedMove($value)
191  {
192  $this->checked_move = $value;
193  }
194 
195  public function getCheckedMove()
196  {
197  return $this->checked_move;
198  }
199 
200  public function setTotal($value)
201  {
202  $this->total = $value;
203  }
204 
205  public function getTotal()
206  {
207  return $this->total;
208  }
209 }
210 ?>