ILIAS  eassessment Revision 61809
 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 
48  public function __construct($a_parent_obj, $a_parent_cmd, $a_write_access = false, $a_checked_move = false, $a_total = 0)
49  {
50  parent::__construct($a_parent_obj, $a_parent_cmd);
51 
52  global $lng, $ilCtrl;
53 
54  $this->lng = $lng;
55  $this->ctrl = $ilCtrl;
56  $this->total = $a_total;
57 
58  $this->setWriteAccess($a_write_access);
59  $this->setCheckedMove($a_checked_move);
60 
61  $this->setFormName('questionbrowser');
62  $this->setStyle('table', 'fullwidth');
63  $this->addColumn('','f','1%');
64  $this->addColumn($this->lng->txt("question_id"),'qid', '');
65  $this->addColumn($this->lng->txt("tst_question_title"),'title', '');
66  $this->addColumn($this->lng->txt("tst_sequence"),'sequence', '');
67  $this->addColumn($this->lng->txt("description"),'description', '');
68  $this->addColumn($this->lng->txt("tst_question_type"),'type', '');
69  $this->addColumn($this->lng->txt("points"),'', '');
70  $this->addColumn($this->lng->txt("author"),'author', '');
71  $this->addColumn($this->lng->txt("qpl"),'qpl', '');
72 
73  $this->setPrefix('q_id');
74  $this->setSelectAllCheckbox('q_id');
75 
76  if ($this->getWriteAccess() && !$this->getTotal())
77  {
78  $this->addMultiCommand('removeQuestions', $this->lng->txt('remove_question'));
79  $this->addMultiCommand('moveQuestions', $this->lng->txt('move'));
80  if ($this->checked_move)
81  {
82  $this->addMultiCommand('insertQuestionsBefore', $this->lng->txt('insert_before'));
83  $this->addMultiCommand('insertQuestionsAfter', $this->lng->txt('insert_after'));
84  }
85  }
86 
87 
88  $this->setRowTemplate("tpl.il_as_tst_questions_row.html", "Modules/Test");
89 
90  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
91 
92  $this->disable('sort');
93  $this->enable('header');
94  $this->enable('select_all');
95  }
96 
97  function fillHeader()
98  {
99  foreach ($this->column as $key => $column)
100  {
101  if (strcmp($column['text'], $this->lng->txt("points")) == 0)
102  {
103  $this->column[$key]['text'] = $this->lng->txt("points") . "&nbsp;(" . $this->totalPoints . ")";
104  }
105  }
107  }
108 
116  public function fillRow($data)
117  {
118  global $ilUser,$ilAccess;
119  $this->tpl->setVariable("QUESTION_ORIGINAL_ID", $data["question_id"]);
120  $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
121  if ($this->getWriteAccess() && !$this->getTotal() && $data["obj_fi"] > 0)
122  {
123  $q_id = $data["question_id"];
124  $qpl_ref_id = current(ilObject::_getAllReferences($data["obj_fi"]));
125  $this->tpl->setVariable("QUESTION_TITLE", "<a href=\"" . $this->ctrl->getLinkTarget($this->getParentObject(), "questions") . "&eqid=$q_id&eqpl=$qpl_ref_id" . "\">" . $data["title"] . "</a>");
126  }
127  else
128  {
129  $this->tpl->setVariable("QUESTION_TITLE", $data["title"]);
130  }
131  $this->tpl->setVariable("QUESTION_SEQUENCE", $this->lng->txt("tst_sequence"));
132 
133  if ($this->getWriteAccess() && !$this->getTotal())
134  {
135  if ($data["sequence"] != 1)
136  {
137  $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>");
138  }
139  if ($data["sequence"] != count($this->getData()))
140  {
141  $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>");
142  }
143  }
144  $this->tpl->setVariable("QUESTION_COMMENT", $data["description"]);
145  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
146  $this->tpl->setVariable("QUESTION_TYPE", assQuestion::_getQuestionTypeName($data["type_tag"]));
147  $this->tpl->setVariable("QUESTION_POINTS", $data["points"]);
148  $this->totalPoints += $data["points"];
149  $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]);
150  $this->tpl->setVariable("QUESTION_POOL", ilObject::_lookupTitle($data["obj_fi"]));
151  }
152 
153  public function setWriteAccess($value)
154  {
155  $this->writeAccess = $value;
156  }
157 
158  public function getWriteAccess()
159  {
160  return $this->writeAccess;
161  }
162 
163  public function setCheckedMove($value)
164  {
165  $this->checked_move = $value;
166  }
167 
168  public function getCheckedMove()
169  {
170  return $this->checked_move;
171  }
172 
173  public function setTotal($value)
174  {
175  $this->total = $value;
176  }
177 
178  public function getTotal()
179  {
180  return $this->total;
181  }
182 }
183 ?>