4 include_once(
"./Services/Table/classes/class.ilTable2GUI.php");
29 $this->
object = $a_survey_obj;
30 $this->read_only = (bool)$a_read_only;
34 $this->
setId(
"il_svy_qst");
42 if(!array_key_exists(
"move_questions",
$_SESSION))
44 $this->
addMultiCommand(
"createQuestionblock", $lng->txt(
"define_questionblock"));
46 $this->
addMultiCommand(
"removeQuestions", $lng->txt(
"remove_question"));
48 $this->
addMultiCommand(
"copyQuestionsToPool", $lng->txt(
"survey_copy_questions_to_pool"));
52 $this->
addMultiCommand(
"insertQuestionsBefore", $lng->txt(
"insert_before"));
53 $this->
addMultiCommand(
"insertQuestionsAfter", $lng->txt(
"insert_after"));
57 $this->
addCommandButton(
"saveObligatory", $lng->txt(
"save_obligatory_state"));
61 $this->
addColumn($lng->txt(
"survey_order"),
"");
65 $this->
addColumn($lng->txt(
"obligatory"),
"");
66 $this->
addColumn($lng->txt(
"description"),
"");
68 $this->
addColumn($lng->txt(
"author"),
"");
69 $this->
addColumn($lng->txt(
"survey_question_pool"),
"");
80 $this->
setRowTemplate(
"tpl.il_svy_svy_question_table.html",
"Modules/Survey");
94 $survey_questions = $this->
object->getSurveyQuestions();
95 if (count($survey_questions) > 0)
97 include_once
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
100 $questionpools = $this->
object->getQuestionpoolTitles(
true);
102 $table_data = array();
103 $last_questionblock_id = $position = $block_position = 0;
104 foreach ($survey_questions as $question_id =>
$data)
107 if (
$data[
"questionblock_id"] > 0 &&
108 $data[
"questionblock_id"] != $last_questionblock_id)
110 $id =
"qb_" .
$data[
"questionblock_id"];
112 $table_data[$id] = array(
"id" => $id,
114 "title" =>
$data[
"questionblock_title"]);
116 if (!$this->read_only)
119 if(
sizeof($survey_questions) > 1)
122 $table_data[$id][
"position"] = $position;
125 $ilCtrl->setParameter($this->parent_obj,
"bl_id",
$data[
"questionblock_id"]);
126 $table_data[$id][
"url"] = $ilCtrl->getLinkTarget($this->parent_obj,
"editQuestionblock");
127 $ilCtrl->setParameter($this->parent_obj,
"bl_id",
"");
135 $id =
$data[
"question_id"];
137 $table_data[$id] = array(
"id" => $id,
138 "type" =>
"question",
139 "heading" =>
$data[
"heading"],
140 "title" =>
$data[
"title"],
141 "description" =>
$data[
"description"],
142 "author" =>
$data[
"author"],
143 "block_id" =>
$data[
"questionblock_id"],
144 "obligatory" => (
bool)
$data[
"obligatory"]);
147 foreach ($questiontypes as $trans => $typedata)
149 if (strcmp($typedata[
"type_tag"], $data[
"type_tag"]) == 0)
151 $table_data[$id][
"question_type"] = $trans;
156 if($data[
"original_id"])
158 if(isset($questionpools[$data[
"obj_fi"]]))
160 $table_data[$id][
"pool"] = $questionpools[$data[
"obj_fi"]];
165 $table_data[$id][
"pool"] = $this->lng->txt(
"status_no_permission");
169 if (!$this->read_only)
171 if ($data[
"obj_fi"] > 0)
174 $q_gui = $data[
"type_tag"].
"GUI";
175 $ilCtrl->setParameterByClass($q_gui,
"q_id", $id);
176 $table_data[$id][
"url"] = $ilCtrl->getLinkTargetByClass($q_gui,
"editQuestion") .
177 $ilCtrl->setParameterByClass($q_gui,
"q_id",
"");
181 if(
sizeof($survey_questions) > 1)
183 if (!$data[
"questionblock_id"])
186 $table_data[$id][
"position"] = $position;
190 $block_position += 10;
191 $table_data[$id][
"position"] = $block_position;
196 $last_questionblock_id = $data[
"questionblock_id"];
212 switch($a_set[
"type"])
215 if(!$this->read_only)
218 $this->tpl->setCurrentBlock(
"checkable");
219 $this->tpl->setVariable(
"QUESTION_ID", $a_set[
"id"]);
220 $this->tpl->parseCurrentBlock();
223 if($a_set[
"position"])
225 $this->tpl->setCurrentBlock(
"order");
226 $this->tpl->setVariable(
"ORDER_NAME",
"order[".$a_set[
"id"].
"]");
227 $this->tpl->setVariable(
"ORDER_VALUE", $a_set[
"position"]);
228 $this->tpl->parseCurrentBlock();
232 $this->tpl->setVariable(
"TYPE", $lng->txt(
"questionblock"));
236 $this->tpl->setVariable(
"DESCRIPTION", $a_set[
"description"]);
237 $this->tpl->setVariable(
"TYPE", $a_set[
"question_type"]);
238 $this->tpl->setVariable(
"AUTHOR", $a_set[
"author"]);
239 $this->tpl->setVariable(
"POOL", $a_set[
"pool"]);
241 if($a_set[
"heading"])
243 $this->tpl->setCurrentBlock(
"heading");
244 $this->tpl->setVariable(
"TXT_HEADING", $a_set[
"heading"]);
245 $this->tpl->parseCurrentBlock();
248 if($a_set[
"block_id"])
250 $this->tpl->setVariable(
"TITLE_INDENT",
" style=\"padding-left:30px\"");
253 if(!$this->read_only)
256 $this->tpl->setCurrentBlock(
"checkable");
257 $this->tpl->setVariable(
"QUESTION_ID", $a_set[
"id"]);
258 $this->tpl->parseCurrentBlock();
260 if($a_set[
"block_id"])
262 $this->tpl->setVariable(
"CHECKABLE_INDENT",
" style=\"padding-left:30px\"");
266 if($a_set[
"position"])
268 $this->tpl->setCurrentBlock(
"order");
269 if(!$a_set[
"block_id"])
271 $this->tpl->setVariable(
"ORDER_NAME",
"order[q_".$a_set[
"id"].
"]");
275 $this->tpl->setVariable(
"ORDER_NAME",
"block_order[".$a_set[
"block_id"].
"][".$a_set[
"id"].
"]");
277 $this->tpl->setVariable(
"ORDER_VALUE", $a_set[
"position"]);
278 $this->tpl->parseCurrentBlock();
279 if($a_set[
"block_id"])
281 $this->tpl->setVariable(
"ORDER_INDENT",
" style=\"padding-left:30px\"");
286 $checked = $a_set[
"obligatory"] ?
" checked=\"checked\"" :
"";
287 $obligatory =
"<input type=\"checkbox\" name=\"obligatory_".
288 $a_set[
"id"] .
"\" value=\"1\"".$checked.
" />";
290 else if($a_set[
"obligatory"])
292 $obligatory =
"<img src=\"".ilUtil::getImagePath(
"obligatory.png",
"Modules/Survey").
293 "\" alt=\"".$lng->txt(
"question_obligatory").
294 "\" title=\"".$lng->txt(
"question_obligatory").
"\" />";
296 $this->tpl->setVariable(
"OBLIGATORY", $obligatory);
300 if(!$this->read_only)
303 $this->tpl->setCurrentBlock(
"checkable");
304 $this->tpl->setVariable(
"QUESTION_ID", $a_set[
"id"]);
305 $this->tpl->parseCurrentBlock();
306 if($a_set[
"in_block"])
308 $this->tpl->setVariable(
"CHECKABLE_INDENT",
" style=\"padding-left:30px\"");
309 $this->tpl->setVariable(
"TITLE_INDENT",
" style=\"padding-left:30px\"");
313 $this->tpl->setVariable(
"TYPE", $lng->txt(
"heading"));
317 if(!$this->read_only)
319 $this->tpl->setCurrentBlock(
"actions");
321 $ilCtrl->setParameter($this->parent_obj,
"q_id", $a_set[
"id"]);
323 include_once
"Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php";
325 $list->setId($a_set[
"id"]);
326 $list->setListTitle($lng->txt(
"actions"));
329 $list->addItem($lng->txt(
"edit"),
"", $a_set[
"url"]);
332 if($a_set[
"heading"])
334 $list->addItem($lng->txt(
"survey_edit_heading"),
"",
335 $ilCtrl->getLinkTarget($this->parent_obj,
"editheading"));
337 $list->addItem($lng->txt(
"survey_delete_heading"),
"",
338 $ilCtrl->getLinkTarget($this->parent_obj,
"removeheading"));
340 else if($a_set[
"type"] ==
"question")
342 $list->addItem($lng->txt(
"add_heading"),
"",
343 $ilCtrl->getLinkTarget($this->parent_obj,
"addHeading"));
346 $this->tpl->setVariable(
"ACTION", $list->getHTML());
348 $ilCtrl->setParameter($this->parent_obj,
"q_id",
"");
350 $this->tpl->parseCurrentBlock();
355 $this->tpl->setCurrentBlock(
"title_edit");
356 $this->tpl->setVariable(
"TITLE", $a_set[
"title"]);
357 $this->tpl->setVariable(
"URL_TITLE", $a_set[
"url"]);
358 $this->tpl->parseCurrentBlock();
362 $this->tpl->setCurrentBlock(
"title_static");
363 $this->tpl->setVariable(
"TITLE", $a_set[
"title"]);
364 $this->tpl->parseCurrentBlock();
369 $this->tpl->setCurrentBlock(
"title_static");
370 $this->tpl->setVariable(
"TITLE", $a_set[
"title"]);
371 $this->tpl->parseCurrentBlock();