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(
"defineQuestionblock", $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");
92 $survey_questions = $this->
object->getSurveyQuestions();
93 if (count($survey_questions) > 0)
95 include_once
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
98 $questionpools = $this->
object->getQuestionpoolTitles(
true);
100 $table_data = array();
101 $last_questionblock_id = $position = $block_position = 0;
102 foreach ($survey_questions as $question_id =>
$data)
105 if (
$data[
"questionblock_id"] > 0 &&
106 $data[
"questionblock_id"] != $last_questionblock_id)
108 $id =
"qb_" .
$data[
"questionblock_id"];
110 $table_data[$id] = array(
"id" => $id,
112 "title" =>
$data[
"questionblock_title"]);
114 if (!$this->read_only)
117 if(
sizeof($survey_questions) > 1)
120 $table_data[$id][
"position"] = $position;
123 $table_data[$id][
"url"] = $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd).
124 "&editblock=".$data[
"questionblock_id"];
132 $id =
$data[
"question_id"];
134 $table_data[$id] = array(
"id" => $id,
135 "type" =>
"question",
136 "heading" =>
$data[
"heading"],
137 "title" =>
$data[
"title"],
138 "description" =>
$data[
"description"],
139 "author" =>
$data[
"author"],
140 "block_id" =>
$data[
"questionblock_id"],
141 "obligatory" => (
bool)
$data[
"obligatory"]);
144 foreach ($questiontypes as $trans => $typedata)
146 if (strcmp($typedata[
"type_tag"], $data[
"type_tag"]) == 0)
148 $table_data[$id][
"question_type"] = $trans;
153 if($data[
"original_id"])
155 if(isset($questionpools[$data[
"obj_fi"]]))
157 $table_data[$id][
"pool"] = $questionpools[$data[
"obj_fi"]];
162 $table_data[$id][
"pool"] = $this->lng->txt(
"status_no_permission");
166 if (!$this->read_only)
168 if ($data[
"obj_fi"] > 0)
172 $table_data[$id][
"url"] = $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd) .
173 "&eqid=".$id.
"&eqpl=".$qpl_ref_id;
177 if(
sizeof($survey_questions) > 1)
179 if (!$data[
"questionblock_id"])
182 $table_data[$id][
"position"] = $position;
186 $block_position += 10;
187 $table_data[$id][
"position"] = $block_position;
192 $last_questionblock_id = $data[
"questionblock_id"];
208 switch($a_set[
"type"])
211 if(!$this->read_only)
214 $this->tpl->setCurrentBlock(
"checkable");
215 $this->tpl->setVariable(
"QUESTION_ID", $a_set[
"id"]);
216 $this->tpl->parseCurrentBlock();
219 if($a_set[
"position"])
221 $this->tpl->setCurrentBlock(
"order");
222 $this->tpl->setVariable(
"ORDER_NAME",
"order[".$a_set[
"id"].
"]");
223 $this->tpl->setVariable(
"ORDER_VALUE", $a_set[
"position"]);
224 $this->tpl->parseCurrentBlock();
228 $this->tpl->setVariable(
"TYPE", $lng->txt(
"questionblock"));
232 $this->tpl->setVariable(
"DESCRIPTION", $a_set[
"description"]);
233 $this->tpl->setVariable(
"TYPE", $a_set[
"question_type"]);
234 $this->tpl->setVariable(
"AUTHOR", $a_set[
"author"]);
235 $this->tpl->setVariable(
"POOL", $a_set[
"pool"]);
237 if($a_set[
"heading"])
239 $this->tpl->setCurrentBlock(
"heading");
240 $this->tpl->setVariable(
"TXT_HEADING", $a_set[
"heading"]);
241 $this->tpl->parseCurrentBlock();
244 if($a_set[
"block_id"])
246 $this->tpl->setVariable(
"TITLE_INDENT",
" style=\"padding-left:30px\"");
249 if(!$this->read_only)
252 $this->tpl->setCurrentBlock(
"checkable");
253 $this->tpl->setVariable(
"QUESTION_ID", $a_set[
"id"]);
254 $this->tpl->parseCurrentBlock();
256 if($a_set[
"block_id"])
258 $this->tpl->setVariable(
"CHECKABLE_INDENT",
" style=\"padding-left:30px\"");
262 if($a_set[
"position"])
264 $this->tpl->setCurrentBlock(
"order");
265 if(!$a_set[
"block_id"])
267 $this->tpl->setVariable(
"ORDER_NAME",
"order[q_".$a_set[
"id"].
"]");
271 $this->tpl->setVariable(
"ORDER_NAME",
"block_order[".$a_set[
"block_id"].
"][".$a_set[
"id"].
"]");
273 $this->tpl->setVariable(
"ORDER_VALUE", $a_set[
"position"]);
274 $this->tpl->parseCurrentBlock();
275 if($a_set[
"block_id"])
277 $this->tpl->setVariable(
"ORDER_INDENT",
" style=\"padding-left:30px\"");
282 $checked = $a_set[
"obligatory"] ?
" checked=\"checked\"" :
"";
283 $obligatory =
"<input type=\"checkbox\" name=\"obligatory_".
284 $a_set[
"id"] .
"\" value=\"1\"".$checked.
" />";
286 else if($a_set[
"obligatory"])
288 $obligatory =
"<img src=\"".ilUtil::getImagePath(
"obligatory.png",
"Modules/Survey").
289 "\" alt=\"".$lng->txt(
"question_obligatory").
290 "\" title=\"".$lng->txt(
"question_obligatory").
"\" />";
292 $this->tpl->setVariable(
"OBLIGATORY", $obligatory);
296 if(!$this->read_only)
299 $this->tpl->setCurrentBlock(
"checkable");
300 $this->tpl->setVariable(
"QUESTION_ID", $a_set[
"id"]);
301 $this->tpl->parseCurrentBlock();
302 if($a_set[
"in_block"])
304 $this->tpl->setVariable(
"CHECKABLE_INDENT",
" style=\"padding-left:30px\"");
305 $this->tpl->setVariable(
"TITLE_INDENT",
" style=\"padding-left:30px\"");
309 $this->tpl->setVariable(
"TYPE", $lng->txt(
"heading"));
313 if(!$this->read_only)
315 $this->tpl->setCurrentBlock(
"actions");
317 include_once
"Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php";
319 $list->setId($a_set[
"id"]);
320 $list->setListTitle($lng->txt(
"actions"));
323 $list->addItem($lng->txt(
"edit"),
"", $a_set[
"url"]);
326 if($a_set[
"heading"])
328 $edit = $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd) .
329 "&editheading=" . $a_set[
"id"];
330 $list->addItem($lng->txt(
"survey_edit_heading"),
"", $edit);
332 $rmv = $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd) .
333 "&removeheading=" . $a_set[
"id"];
334 $list->addItem($lng->txt(
"survey_delete_heading"),
"", $rmv);
336 else if($a_set[
"type"] ==
"question")
338 $add = $ilCtrl->getLinkTarget($this->parent_obj,
"addHeading") .
339 "&insertbefore=" . $a_set[
"id"];
340 $list->addItem($lng->txt(
"add_heading"),
"", $add);
343 $this->tpl->setVariable(
"ACTION", $list->getHTML());
345 $this->tpl->parseCurrentBlock();
350 $this->tpl->setCurrentBlock(
"title_edit");
351 $this->tpl->setVariable(
"TITLE", $a_set[
"title"]);
352 $this->tpl->setVariable(
"URL_TITLE", $a_set[
"url"]);
353 $this->tpl->parseCurrentBlock();
357 $this->tpl->setCurrentBlock(
"title_static");
358 $this->tpl->setVariable(
"TITLE", $a_set[
"title"]);
359 $this->tpl->parseCurrentBlock();
364 $this->tpl->setCurrentBlock(
"title_static");
365 $this->tpl->setVariable(
"TITLE", $a_set[
"title"]);
366 $this->tpl->parseCurrentBlock();