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 $table_data[$id][
"pool"] = $questionpools[$data[
"obj_fi"]];
158 if (!$this->read_only)
160 if ($data[
"obj_fi"] > 0)
164 $table_data[$id][
"url"] = $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd) .
165 "&eqid=".$id.
"&eqpl=".$qpl_ref_id;
169 if(
sizeof($survey_questions) > 1)
171 if (!$data[
"questionblock_id"])
174 $table_data[$id][
"position"] = $position;
178 $block_position += 10;
179 $table_data[$id][
"position"] = $block_position;
184 $last_questionblock_id = $data[
"questionblock_id"];
200 switch($a_set[
"type"])
203 if(!$this->read_only)
206 $this->tpl->setCurrentBlock(
"checkable");
207 $this->tpl->setVariable(
"QUESTION_ID", $a_set[
"id"]);
208 $this->tpl->parseCurrentBlock();
211 if($a_set[
"position"])
213 $this->tpl->setCurrentBlock(
"order");
214 $this->tpl->setVariable(
"ORDER_NAME",
"order[".$a_set[
"id"].
"]");
215 $this->tpl->setVariable(
"ORDER_VALUE", $a_set[
"position"]);
216 $this->tpl->parseCurrentBlock();
220 $this->tpl->setVariable(
"TYPE", $lng->txt(
"questionblock"));
224 $this->tpl->setVariable(
"DESCRIPTION", $a_set[
"description"]);
225 $this->tpl->setVariable(
"TYPE", $a_set[
"question_type"]);
226 $this->tpl->setVariable(
"AUTHOR", $a_set[
"author"]);
227 $this->tpl->setVariable(
"POOL", $a_set[
"pool"]);
229 if($a_set[
"heading"])
231 $this->tpl->setCurrentBlock(
"heading");
232 $this->tpl->setVariable(
"TXT_HEADING", $a_set[
"heading"]);
233 $this->tpl->parseCurrentBlock();
236 if($a_set[
"block_id"])
238 $this->tpl->setVariable(
"TITLE_INDENT",
" style=\"padding-left:30px\"");
241 if(!$this->read_only)
244 $this->tpl->setCurrentBlock(
"checkable");
245 $this->tpl->setVariable(
"QUESTION_ID", $a_set[
"id"]);
246 $this->tpl->parseCurrentBlock();
248 if($a_set[
"block_id"])
250 $this->tpl->setVariable(
"CHECKABLE_INDENT",
" style=\"padding-left:30px\"");
254 if($a_set[
"position"])
256 $this->tpl->setCurrentBlock(
"order");
257 if(!$a_set[
"block_id"])
259 $this->tpl->setVariable(
"ORDER_NAME",
"order[q_".$a_set[
"id"].
"]");
263 $this->tpl->setVariable(
"ORDER_NAME",
"block_order[".$a_set[
"block_id"].
"][".$a_set[
"id"].
"]");
265 $this->tpl->setVariable(
"ORDER_VALUE", $a_set[
"position"]);
266 $this->tpl->parseCurrentBlock();
267 if($a_set[
"block_id"])
269 $this->tpl->setVariable(
"ORDER_INDENT",
" style=\"padding-left:30px\"");
274 $checked = $a_set[
"obligatory"] ?
" checked=\"checked\"" :
"";
275 $obligatory =
"<input type=\"checkbox\" name=\"obligatory_".
276 $a_set[
"id"] .
"\" value=\"1\"".$checked.
" />";
278 else if($a_set[
"obligatory"])
280 $obligatory =
"<img src=\"".ilUtil::getImagePath(
"obligatory.gif",
"Modules/Survey").
281 "\" alt=\"".$lng->txt(
"question_obligatory").
282 "\" title=\"".$lng->txt(
"question_obligatory").
"\" />";
284 $this->tpl->setVariable(
"OBLIGATORY", $obligatory);
288 if(!$this->read_only)
291 $this->tpl->setCurrentBlock(
"checkable");
292 $this->tpl->setVariable(
"QUESTION_ID", $a_set[
"id"]);
293 $this->tpl->parseCurrentBlock();
294 if($a_set[
"in_block"])
296 $this->tpl->setVariable(
"CHECKABLE_INDENT",
" style=\"padding-left:30px\"");
297 $this->tpl->setVariable(
"TITLE_INDENT",
" style=\"padding-left:30px\"");
301 $this->tpl->setVariable(
"TYPE", $lng->txt(
"heading"));
305 if(!$this->read_only)
307 $this->tpl->setCurrentBlock(
"actions");
309 include_once
"Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php";
311 $list->setId($a_set[
"id"]);
312 $list->setListTitle($lng->txt(
"actions"));
315 $list->addItem($lng->txt(
"edit"),
"", $a_set[
"url"]);
318 if($a_set[
"heading"])
320 $edit = $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd) .
321 "&editheading=" . $a_set[
"id"];
322 $list->addItem($lng->txt(
"survey_edit_heading"),
"", $edit);
324 $rmv = $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd) .
325 "&removeheading=" . $a_set[
"id"];
326 $list->addItem($lng->txt(
"survey_delete_heading"),
"", $rmv);
328 else if($a_set[
"type"] ==
"question")
330 $add = $ilCtrl->getLinkTarget($this->parent_obj,
"addHeading") .
331 "&insertbefore=" . $a_set[
"id"];
332 $list->addItem($lng->txt(
"add_heading"),
"", $add);
335 $this->tpl->setVariable(
"ACTION", $list->getHTML());
337 $this->tpl->parseCurrentBlock();
340 $this->tpl->setCurrentBlock(
"title_edit");
341 $this->tpl->setVariable(
"TITLE", $a_set[
"title"]);
342 $this->tpl->setVariable(
"URL_TITLE", $a_set[
"url"]);
343 $this->tpl->parseCurrentBlock();
347 $this->tpl->setCurrentBlock(
"title_static");
348 $this->tpl->setVariable(
"TITLE", $a_set[
"title"]);
349 $this->tpl->parseCurrentBlock();