33 $this->survey_gui = $a_survey_gui;
34 $this->ref_id = $this->survey_gui->ref_id;
35 $this->
object = $this->survey_gui->object;
45 $cmd = $ilCtrl->getCmd(
"renderPage");
46 $next_class = $ilCtrl->getNextClass($this);
55 if($rbacsystem->checkAccess(
"write", $this->ref_id))
69 $ilCtrl->setParameter($this->survey_gui,
"pgov", $this->current_page);
72 $id = explode(
"_",
$_REQUEST[
"il_hform_node"]);
76 if(substr(
$_REQUEST[
"il_hform_subcmd"], 0, 5) ==
"multi")
82 foreach(explode(
";",
$_REQUEST[
"il_hform_multi"]) as $item)
84 $id[] = (int)array_pop(explode(
"_", $item));
87 if($subcmd ==
"multiDelete")
89 $subcmd =
"deleteQuestion";
95 if($subcmd ==
"multiDelete")
98 $ilCtrl->redirect($this,
"renderPage");
107 if(substr($subcmd, 0, 11) ==
"addQuestion")
109 $type = explode(
"_", $subcmd);
110 $type = (int)$type[1];
111 $has_content = $this->
addQuestion($type, $this->object->isPoolActive(), $id,
$_REQUEST[
"il_hform_node"]);
115 $has_content = $this->$subcmd($id,
$_REQUEST[
"il_hform_node"]);
160 $result = $ilDB->queryF(
"SELECT survey_question_id FROM svy_svy_qst WHERE survey_fi = %s",
162 array($this->object->getSurveyId())
164 $sequence =
$result->numRows();
169 $survey_question_id = $this->
object->duplicateQuestionForSurvey($a_new_id, $a_force_duplicate);
174 $survey_question_id = $a_new_id;
178 $next_id = $ilDB->nextId(
'svy_svy_qst');
179 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_svy_qst (survey_question_id, survey_fi,".
180 "question_fi, sequence, tstamp) VALUES (%s, %s, %s, %s, %s)",
181 array(
'integer',
'integer',
'integer',
'integer',
'integer'),
182 array($next_id, $this->object->getSurveyId(), $survey_question_id, $sequence, time())
185 return $survey_question_id;
197 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
205 $this->
object->loadQuestionsFromDb();
210 if(substr($pos, -1) !=
"c")
213 $current = $this->
object->getSurveyPages();
214 $current = $current[$this->current_page-1];
215 if(
sizeof($current) == 1)
221 array((
int)$pos, $a_new_id));
225 $block_id = array_pop($current);
226 $block_id = $block_id[
"questionblock_id"];
228 $this->
object->addQuestionToBlock($a_new_id, $block_id);
237 $pos = (int)$pos.
"a";
238 $this->current_page++;
243 $first = $this->
object->getSurveyPages();
245 $first = array_shift($first);
246 $pos = $first[
"question_id"].
"b";
247 $this->current_page = 1;
252 $this->
object->moveQuestions(array($a_new_id), (
int)$pos,
253 ((substr($pos, -1) ==
"a") ? 1 : 0));
265 $question_ids = $this->
object->getQuestionblockQuestionIds($a_block_id);
266 foreach($question_ids as $qid)
273 $this->
object->loadQuestionsFromDb();
278 if(substr($pos, -1) !=
"c")
281 $current = $this->
object->getSurveyPages();
282 $current = $current[$this->current_page-1];
283 if(
sizeof($current) == 1)
289 array((
int)$pos)+$new_ids);
293 $block_id = array_pop($current);
294 $block_id = $block_id[
"questionblock_id"];
296 foreach($new_ids as $qid)
298 $this->
object->addQuestionToBlock($qid, $block_id);
312 $pos = (int)$pos.
"a";
317 $first = $this->
object->getSurveyPages();
319 $first = array_shift($first);
320 $pos = $first[
"question_id"].
"b";
325 $this->
object->moveQuestions($new_ids, (
int)$pos,
326 ((substr($pos, -1) ==
"a") ? 1 : 0));
338 protected function addQuestion($a_type, $a_use_pool, $a_pos, $a_special_position)
343 include_once
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
345 foreach($questiontypes as $item)
347 if($item[
"questiontype_id"] == $a_type)
349 $type_trans = $item[
"type_tag"];
356 if($a_special_position ==
"toolbar")
358 $id = $this->
object->getSurveyPages();
359 if($a_pos && $a_pos !=
"fst")
362 $id = array_pop($id);
363 $id = $id[
"question_id"].
"c";
371 else if($a_special_position ==
"page_end")
373 $id = $this->
object->getSurveyPages();
374 $id = $id[$this->current_page-1];
375 $id = array_pop($id);
376 $id = $id[
"question_id"].
"a";
385 $_GET[
"sel_question_types"] = $type_trans;
387 $ilCtrl->setParameter($this->survey_gui,
"pgov_pos", $id);
390 $this->survey_gui->createQuestionObject();
394 $this->survey_gui->executeCreateQuestionObject();
401 $this->ref_id.
"&cmd=createQuestionForSurvey&new_for_survey=".
402 $this->ref_id.
"&sel_question_types=".$type_trans.
"&pgov=".$this->current_page.
417 $this->suppress_clipboard_msg =
true;
420 "source" => $this->current_page,
421 "nodes" => array($a_id),
435 $this->suppress_clipboard_msg =
true;
438 "source" => $this->current_page,
439 "nodes" => array($a_id),
453 $this->suppress_clipboard_msg =
true;
456 "source" => $this->current_page,
471 $this->suppress_clipboard_msg =
true;
474 "source" => $this->current_page,
495 $pages = $this->
object->getSurveyPages();
496 $source = $pages[
$data[
"source"]-1];
497 $target = $pages[$this->current_page-1];
498 $nodes = $data[
"nodes"];
502 if(
$_REQUEST[
"il_hform_node"] ==
"page_end")
505 $a_id = array_pop($a_id);
506 $a_id = $a_id[
"question_id"];
511 if($data[
"mode"] ==
"cut")
514 if($data[
"source"] == $this->current_page)
517 if(
sizeof($nodes) <=
sizeof($source))
519 $this->
object->moveQuestions($nodes, $a_id, $pos);
527 $source_block_id =
false;
528 if(
sizeof($source) > 1)
530 $source_block_id = $source;
531 $source_block_id = array_shift($source_block_id);
532 $source_block_id = $source_block_id[
"questionblock_id"];
535 if(
sizeof($source) >
sizeof($nodes))
537 foreach($nodes as $qid)
539 $this->
object->removeQuestionFromBlock($qid, $source_block_id);
545 $this->
object->unfoldQuestionblocks(array($source_block_id));
550 if(
sizeof($source) ==
sizeof($nodes) && $data[
"source"] < $this->current_page)
552 $this->current_page--;
558 else if($data[
"mode"] ==
"copy")
561 foreach($this->object->getSurveyPages() as $page)
563 foreach($page as $question)
565 $titles[] = $question[
"title"];
570 $question_pointer = array();
571 foreach($nodes as $qid)
577 $title = $question->getTitle();
579 foreach($titles as $existing_title)
581 if(preg_match(
"/".preg_quote(
$title).
" \(([0-9]+)\)$/", $existing_title, $match))
583 $max = max($match[1], $max);
588 $title .=
" (".($max+1).
")";
595 $question->setTitle(
$title);
598 $question->saveToDb();
600 $question_pointer[$qid] = $question->getId();
605 $this->
object->cloneTextblocks($question_pointer);
607 $this->
object->loadQuestionsFromDb();
609 $nodes = array_values($question_pointer);
616 if(
sizeof($target) == 1)
618 $nodes = array_merge(array($a_id), $nodes);
627 $target_block_id = $target;
628 $target_block_id = array_shift($target_block_id);
629 $target_block_id = $target_block_id[
"questionblock_id"];
631 foreach($nodes as $qid)
633 $this->
object->addQuestionToBlock($qid, $target_block_id);
637 $this->
object->moveQuestions($nodes, $a_id, $pos);
648 $source_id = (int)array_pop(explode(
"_",
$_REQUEST[
"il_hform_source"]));
649 if(
$_REQUEST[
"il_hform_target"] !=
"page_end")
656 $page = $this->
object->getSurveyPages();
657 $page = $page[$this->current_page-1];
658 $last = array_pop($page);
664 $this->
object->moveQuestions(array($source_id),
$target_id, $pos);
676 $this->survey_gui->questionsSubtabs(
'questions_per_page');
678 $ilCtrl->setParameter($this->survey_gui,
"pgov", $this->current_page);
681 $page = $this->
object->getSurveyPages();
682 $page = $page[$this->current_page-1];
685 if(
$_REQUEST[
"csum"] != md5(print_r($page,
true)))
687 $ilCtrl->redirect($this,
"renderPage");
690 $page = array_shift($page);
691 $block_id = $page[
"questionblock_id"];
694 $this->survey_gui->removeQuestionsForm(array($block_id), array(), array());
698 $this->survey_gui->removeQuestionsForm(array(), array($page[
"question_id"]), array());
711 $a_id = array($a_id);
713 $this->survey_gui->removeQuestionsForm(array(), $a_id, array());
726 foreach (
$_POST as $key => $value)
728 if (preg_match(
"/id_(\d+)/", $key, $matches))
730 array_push($ids, $matches[1]);
735 $pages = $this->
object->getSurveyPages();
736 $source = $pages[$this->current_page-1];
739 $block_id = array_shift($block_id);
740 $block_id = $block_id[
"questionblock_id"];
742 if(
sizeof($ids) &&
sizeof($source) >
sizeof($ids))
745 if(
sizeof($source)-
sizeof($ids) == 1)
747 $this->
object->unfoldQuestionblocks(array($block_id));
752 foreach($ids as $qid)
754 $this->
object->removeQuestionFromBlock($qid, $block_id);
758 $this->
object->removeQuestions($ids, array());
766 $this->
object->removeQuestions(array(), array($block_id));
771 $this->
object->removeQuestions($ids, array());
775 if($this->current_page > 1)
777 $this->current_page--;
781 $this->
object->saveCompletionStatus();
784 $ilCtrl->setParameter($this,
"pgov", $this->current_page);
785 $ilCtrl->redirect($this,
"renderPage");
795 $this->survey_gui->defineQuestionblock($a_id);
806 $this->survey_gui->addHeadingObject(
false, $a_id);
817 $this->survey_gui->addHeadingObject(
false, $a_id);
828 $_GET[
"removeheading"] = $a_id;
829 $this->survey_gui->confirmRemoveHeadingForm();
840 $pages = $this->
object->getSurveyPages();
841 $source = $pages[$this->current_page-1];
843 $block_questions = array();
844 $add = $block_id =
false;
845 foreach($source as $idx => $item)
847 if($item[
"question_id"] == $a_id)
849 $block_id = $item[
"questionblock_id"];
854 $block_questions[] = $item[
"question_id"];
861 $this->
object->unfoldQuestionblocks(array($block_id));
866 foreach($block_questions as $qid)
868 $this->
object->removeQuestionFromBlock($qid, $block_id);
873 if(
sizeof($block_questions) > 1)
880 $this->current_page++;
890 $pages = $this->
object->getSurveyPages();
891 $source = $pages[$this->current_page-1];
897 $target_block_id =
$target_id[
"questionblock_id"];
901 if(
sizeof($source) > 1)
904 $block_id = array_shift($block_id);
905 $block_id = $block_id[
"questionblock_id"];
908 if(
sizeof($source) == 2)
911 $this->
object->unfoldQuestionblocks(array($block_id));
916 $this->
object->removeQuestionFromBlock($a_id, $block_id);
921 $this->
object->moveQuestions(array($a_id),
$target_id, 0);
924 if(
sizeof($target) < 2)
933 $this->
object->addQuestionToBlock($a_id, $target_block_id);
937 if(
sizeof($source) > 1)
939 $this->current_page++;
951 $pages = $this->
object->getSurveyPages();
952 $source = $pages[$this->current_page-1];
953 $target = $pages[$this->current_page-2];
958 $target_block_id =
$target_id[
"questionblock_id"];
962 if(
sizeof($source) > 1)
965 $block_id = array_shift($block_id);
966 $block_id = $block_id[
"questionblock_id"];
969 if(
sizeof($source) == 2)
972 $this->
object->unfoldQuestionblocks(array($block_id));
977 $this->
object->removeQuestionFromBlock($a_id, $block_id);
982 $this->
object->moveQuestions(array($a_id),
$target_id, 1);
985 if(
sizeof($target) < 2)
994 $this->
object->addQuestionToBlock($a_id, $target_block_id);
997 $this->current_page--;
1008 $data = $this->
object->getQuestions(array($a_id));
1012 $pool_id.
"&cmd=editQuestionForSurvey&calling_survey=".
1013 $this->ref_id.
"&q_id=".$a_id.
"&pgov=".$this->current_page);
1023 $this->survey_gui->questionsSubtabs(
'questions_per_page');
1025 include_once
"Services/Form/classes/class.ilPropertyFormGUI.php";
1027 $form->setFormAction($ilCtrl->getFormAction($this,
"addQuestionToolbar"));
1028 $form->setTitle($lng->txt(
"survey_add_new_question"));
1031 include_once
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
1033 $type_map = array();
1034 foreach($questiontypes as $trans => $item)
1036 $type_map[$item[
"questiontype_id"]] = $trans;
1038 include_once(
"./Services/Form/classes/class.ilSelectInputGUI.php");
1041 $form->addItem($si);
1043 $pages = $this->
object->getSurveyPages();
1046 $pages_drop = array(
"fst"=>$lng->txt(
"survey_at_beginning"));
1047 foreach($pages as $idx => $questions)
1049 $question = array_shift($questions);
1050 if($question[
"questionblock_id"])
1052 $pages_drop[$idx+1] = $lng->txt(
"survey_behind_page").
" ".$question[
"questionblock_title"];
1056 $pages_drop[$idx+1] = $lng->txt(
"survey_behind_page").
" ".strip_tags($question[
"title"]);
1061 $form->addItem($pos);
1063 $pos->setValue($this->current_page);
1069 $pos->setValue(
"fst");
1070 $form->addItem($pos);
1073 if($this->object->isPoolActive())
1075 $this->survey_gui->createQuestionObject($form);
1078 $form->addCommandButton(
"addQuestionToolbar", $lng->txt(
"submit"));
1079 $form->addCommandButton(
"renderPage", $lng->txt(
"cancel"));
1081 return $tpl->setContent($form->getHTML());
1091 $pool_active = $this->
object->isPoolActive();
1093 if(!
$_POST[
"usage"] && $pool_active)
1100 $ilCtrl->setParameter($this->survey_gui,
"pgov", $this->current_page);
1115 $this->survey_gui->questionsSubtabs(
'questions_per_page');
1117 include_once
"Services/Form/classes/class.ilPropertyFormGUI.php";
1119 $form->setFormAction($ilCtrl->getFormAction($this,
"movePage"));
1120 $form->setTitle($lng->txt(
"survey_move_page"));
1123 $old_pos->setValue($this->current_page);
1124 $form->addItem($old_pos);
1126 $pages = $this->
object->getSurveyPages();
1129 $pages_drop = array();
1130 if($this->current_page != 1)
1132 $pages_drop[
"fst"] = $lng->txt(
"survey_at_beginning");
1134 foreach($pages as $idx => $questions)
1136 if(($idx+1) != $this->current_page && ($idx+2) != $this->current_page)
1138 $question = array_shift($questions);
1139 if($question[
"questionblock_id"])
1141 $pages_drop[$idx+1] = $lng->txt(
"survey_behind_page").
" ".$question[
"questionblock_title"];
1145 $pages_drop[$idx+1] = $lng->txt(
"survey_behind_page").
" ".strip_tags($question[
"title"]);
1151 $form->addItem($pos);
1154 $form->addCommandButton(
"movePage", $lng->txt(
"submit"));
1155 $form->addCommandButton(
"renderPage", $lng->txt(
"cancel"));
1157 return $tpl->setContent($form->getHTML());
1168 $target_page = $this->current_page-1;
1171 $pages = $this->
object->getSurveyPages();
1172 foreach($pages[$source_page] as $question)
1174 $questions[] = $question[
"question_id"];
1184 $target = $pages[$target_page];
1185 $target = array_shift($target);
1186 $this->
object->moveQuestions($questions, $target[
"question_id"], $position);
1188 if($target_page < $source_page && $position)
1190 $this->current_page++;
1194 $ilCtrl->setParameter($this,
"pgov", $this->current_page);
1195 $ilCtrl->redirect($this,
"renderPage");
1207 if(!$this->has_datasets)
1209 $ilToolbar->addButton($lng->txt(
"survey_add_new_question"), $ilCtrl->getLinkTarget($this,
"addQuestionToolbarForm"));
1211 if($this->object->isPoolActive())
1213 $ilToolbar->addSeparator();
1218 $last_on_page = $a_pages[$this->current_page-1];
1219 $last_on_page = array_pop($last_on_page);
1220 $last_on_page = $last_on_page[
"question_id"];
1223 $ilCtrl->setParameter($this->survey_gui,
"pgov", $this->current_page);
1224 $ilCtrl->setParameter($this->survey_gui,
"pgov_pos", $last_on_page.
"c");
1226 $cmd = ($ilUser->getPref(
'svy_insert_type') == 1 || strlen($ilUser->getPref(
'svy_insert_type')) == 0) ?
'browseForQuestions' :
'browseForQuestionblocks';
1227 $ilToolbar->addButton($lng->txt(
"browse_for_questions"),
1228 $ilCtrl->getLinkTarget($this->survey_gui,
$cmd));
1230 $ilCtrl->setParameter($this->survey_gui,
"pgov",
"");
1231 $ilCtrl->setParameter($this->survey_gui,
"pgov_pos",
"");
1236 $ilToolbar->addSeparator();
1244 $ilCtrl->setParameter($this,
"pg", $this->current_page-1);
1245 $ilToolbar->addLink($lng->txt(
"survey_prev_question"),
1247 $ilCtrl->setParameter($this,
"pg", $this->current_page+1);
1248 $ilToolbar->addLink($lng->txt(
"survey_next_question"),
1250 $ilCtrl->setParameter($this,
"pg", $this->current_page);
1252 foreach($a_pages as $idx => $questions)
1255 $page = array_shift($page);
1256 if($page[
"questionblock_id"])
1258 $pages_drop[$idx+1] = $page[
"questionblock_title"];
1260 if(
sizeof($questions) > 1)
1262 foreach($questions as $question)
1264 $pages_drop[($idx+1).
"__".$question[
"question_id"]] =
"- ".$question[
"title"];
1270 $pages_drop[$idx+1] = strip_tags($page[
"title"]);
1276 if(
sizeof($pages_drop) > 1)
1278 $ilToolbar->addSeparator();
1280 $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
1282 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
1285 $si->setOptions($pages_drop);
1286 $si->setValue($this->current_page);
1287 $ilToolbar->addInputItem($si,
true);
1291 $cmd->setValue(
"1");
1292 $ilToolbar->addInputItem(
$cmd);
1294 if(!$this->has_datasets)
1296 $ilToolbar->addSeparator();
1297 $ilCtrl->setParameter($this,
"csum", md5(print_r($a_pages[$this->current_page-1],
true)));
1298 $ilToolbar->addButton($lng->txt(
"survey_delete_page"), $ilCtrl->getLinkTarget($this,
"deleteBlock"));
1299 $ilCtrl->setParameter($this,
"csum",
"");
1301 $ilToolbar->addSeparator();
1302 $ilToolbar->addButton($lng->txt(
"survey_move_page"), $ilCtrl->getLinkTarget($this,
"movePageForm"));
1314 $this->survey_gui->questionsSubtabs(
'questions_per_page');
1316 $pages = $this->
object->getSurveyPages();
1317 $this->has_next_page = ($this->current_page <
sizeof($pages));
1318 $this->has_previous_page = ($this->current_page > 1);
1319 $this->has_datasets = $this->
object->_hasDatasets($this->object->getSurveyId());
1321 if($this->has_datasets)
1323 $link = $ilCtrl->getLinkTarget($this->survey_gui,
"maintenance");
1324 $link =
"<a href=\"".$link.
"\">".$lng->txt(
"survey_has_datasets_warning_page_view_link").
"</a>";
1325 ilUtil::sendInfo($lng->txt(
"survey_has_datasets_warning_page_view").
" ".$link);
1328 $ilCtrl->setParameter($this,
"pg", $this->current_page);
1329 $ilCtrl->setParameter($this,
"pgov",
"");
1335 $ttpl =
new ilTemplate(
"tpl.il_svy_svy_page_view.html",
true,
true,
"Modules/Survey");
1336 $ttpl->setVariable(
"FORM_ACTION", $ilCtrl->getFormAction($this));
1337 $ttpl->setVariable(
"WYSIWYG_ACTION", $ilCtrl->getFormAction($this));
1338 $lng->loadLanguageModule(
"form");
1340 $read_only = ($this->has_datasets || !$rbacsystem->checkAccess(
"write", $this->ref_id));
1342 $commands = $multi_commands = array();
1347 if(!
$_SESSION[
"survey_page_view"][$this->ref_id][
"clipboard"])
1349 $multi_commands[] = array(
"cmd"=>
"multiDelete",
"text"=>$lng->txt(
"delete"));
1350 $multi_commands[] = array(
"cmd"=>
"multiCut",
"text"=>$lng->txt(
"cut"));
1351 $multi_commands[] = array(
"cmd"=>
"multiCopy",
"text"=>$lng->txt(
"copy"));
1355 if(!$this->suppress_clipboard_msg)
1359 $multi_commands[] = array(
"cmd"=>
"clearClipboard",
"text"=>$lng->txt(
"survey_dnd_clear_clipboard"));
1363 $ttpl->setCurrentBlock(
"help_img");
1365 $ttpl->parseCurrentBlock();
1366 $ttpl->setCurrentBlock(
"help_section");
1367 $ttpl->setVariable(
"TXT_HELP", $lng->txt(
"form_hierarchy_add_elements"));
1368 $ttpl->parseCurrentBlock();
1370 $ttpl->setCurrentBlock(
"help_img");
1372 $ttpl->parseCurrentBlock();
1374 $ttpl->parseCurrentBlock();
1375 $ttpl->setCurrentBlock(
"help_section");
1376 $ttpl->setVariable(
"TXT_HELP", $lng->txt(
"form_hierarchy_drag_drop_help"));
1377 $ttpl->parseCurrentBlock();
1379 $ttpl->setCurrentBlock(
"help_img");
1381 $ttpl->parseCurrentBlock();
1382 $ttpl->setCurrentBlock(
"help_section");
1383 $ttpl->setVariable(
"TXT_HELP", $lng->txt(
"survey_dnd_double_click_to_delete"));
1384 $ttpl->parseCurrentBlock();
1386 $ttpl->setVariable(
"DND_INIT_JS",
"initDragElements();");
1391 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
1394 include_once
"./Services/RTE/classes/class.ilTinyMCE.php";
1396 $ttpl->setVariable(
"WYSIWYG_BLOCKFORMATS", $tiny->_buildAdvancedBlockformatsFromHTMLTags($tags));
1397 $ttpl->setVariable(
"WYSIWYG_VALID_ELEMENTS", $tiny->_getValidElementsFromHTMLTags($tags));
1399 $buttons_1 = $tiny->_buildAdvancedButtonsFromHTMLTags(1, $tags);
1400 $buttons_2 = $tiny->_buildAdvancedButtonsFromHTMLTags(2, $tags).
','.
1401 $tiny->_buildAdvancedTableButtonsFromHTMLTags($tags).
1402 ($tiny->getStyleSelect() ?
',styleselect' :
'');
1403 $buttons_3 = $tiny->_buildAdvancedButtonsFromHTMLTags(3, $tags);
1404 $ttpl->setVariable(
'WYSIWYG_BUTTONS_1', $tiny->_removeRedundantSeparators($buttons_1));
1405 $ttpl->setVariable(
'WYSIWYG_BUTTONS_2', $tiny->_removeRedundantSeparators($buttons_2));
1406 $ttpl->setVariable(
'WYSIWYG_BUTTONS_3', $tiny->_removeRedundantSeparators($buttons_3));
1410 if (count($multi_commands) > 0 || count($commands) > 0)
1413 foreach($commands as
$cmd)
1415 $ttpl->setCurrentBlock(
"cmd");
1416 $ttpl->setVariable(
"ORG_CMD",
"renderPage");
1417 $ttpl->setVariable(
"CMD", $cmd[
"cmd"]);
1418 $ttpl->setVariable(
"CMD_TXT", $cmd[
"text"]);
1419 $ttpl->parseCurrentBlock();
1424 foreach($multi_commands as $cmd)
1426 $ttpl->setCurrentBlock(
"multi_cmd");
1427 $ttpl->setVariable(
"ORG_CMD_MULTI",
"renderPage");
1428 $ttpl->setVariable(
"MULTI_CMD", $cmd[
"cmd"]);
1429 $ttpl->setVariable(
"MULTI_CMD_TXT", $cmd[
"text"]);
1430 $ttpl->parseCurrentBlock();
1435 $ttpl->setCurrentBlock(
"multi_cmds");
1436 $ttpl->setVariable(
"MCMD_ALT", $lng->txt(
"commands"));
1438 $ttpl->parseCurrentBlock();
1441 if ($single || $multi)
1443 $ttpl->setCurrentBlock(
"commands");
1444 $ttpl->parseCurrentBlock();
1449 $ttpl->setVariable(
"NODES", $this->
getPageNodes($pages[$this->current_page-1],
1450 $this->has_previous_page, $this->has_next_page, $read_only));
1452 $tpl->setContent($ttpl->get());
1455 include_once(
"./Services/YUI/classes/class.ilYuiUtil.php");
1457 $tpl->addJavascript(
"./Modules/Survey/js/SurveyPageView.js");
1458 $tpl->addJavascript(
"./Services/RTE/tiny_mce_3_3_9_2/tiny_mce_src.js");
1471 function getPageNodes(array $a_questions, $a_has_previous_page =
false, $a_has_next_page =
false, $a_readonly =
false)
1475 $ttpl =
new ilTemplate(
"tpl.il_svy_svy_page_view_nodes.html",
true,
true,
"Modules/Survey");
1477 $has_clipboard = (bool)
$_SESSION[
"survey_page_view"][$this->ref_id][
"clipboard"];
1481 $first_question = $a_questions;
1482 $first_question = array_shift($first_question);
1484 if($first_question[
"questionblock_id"])
1488 if(!$a_readonly && !$has_clipboard)
1490 $menu[] = array(
"cmd" =>
"editBlock",
"text" => $lng->txt(
"edit"));
1493 if($first_question[
"questionblock_show_blocktitle"])
1495 $block_status = $lng->txt(
"survey_block_visible");
1499 $block_status = $lng->txt(
"survey_block_hidden");
1502 $this->
renderPageNode($ttpl,
"block", $first_question[
"questionblock_id"],
1503 $first_question[
"questionblock_title"].
" (".$block_status.
")", $menu,
false,
false, $block_status);
1509 include_once
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
1512 $counter = $question_count;
1514 foreach($a_questions as $idx => $question)
1524 foreach($questiontypes as $trans => $item)
1526 $menu[] = array(
"cmd"=>
"addQuestion_".$item[
"questiontype_id"],
1527 "text"=> sprintf($lng->txt(
"svy_page_add_question"), $trans));
1530 if($this->object->isPoolActive())
1532 $menu[] = array(
"cmd"=>
"addPoolQuestion",
1533 "text"=> $lng->txt(
"browse_for_questions"));
1538 $menu[] = array(
"cmd" =>
"paste",
"text" => $lng->txt(
"survey_dnd_paste"));
1542 $this->
renderPageNode($ttpl,
"droparea", $question[
"question_id"], null, $menu,
true);
1545 $question_gui = $this->
object->getQuestionGUI($question[
"type_tag"], $question[
"question_id"]);
1546 $question_gui = $question_gui->getWorkingForm(array(), $this->object->getShowQuestionTitles(),
1547 $question[
"questionblock_show_questiontext"], null, $this->
object->getSurveyId());
1551 if(!$a_readonly && !$has_clipboard)
1553 $menu[] = array(
"cmd" =>
"editQuestion",
"text" => $lng->txt(
"edit"));
1554 $menu[] = array(
"cmd" =>
"cutQuestion",
"text" => $lng->txt(
"cut"));
1555 $menu[] = array(
"cmd" =>
"copyQuestion",
"text" => $lng->txt(
"copy"));
1557 if(
sizeof($a_questions) > 1 && $idx > 0)
1559 $menu[] = array(
"cmd" =>
"splitPage",
"text" => $lng->txt(
"survey_dnd_split_page"));
1561 if($a_has_next_page)
1563 $menu[] = array(
"cmd" =>
"moveNext",
"text" => $lng->txt(
"survey_dnd_move_next"));
1565 if($a_has_previous_page)
1567 $menu[] = array(
"cmd" =>
"movePrevious",
"text" => $lng->txt(
"survey_dnd_move_previous"));
1570 $menu[] = array(
"cmd" =>
"deleteQuestion",
"text" => $lng->txt(
"delete"));
1573 if($question[
"heading"])
1575 $menu[] = array(
"cmd" =>
"editHeading",
"text" => $lng->txt(
"survey_edit_heading"));
1576 $menu[] = array(
"cmd" =>
"deleteHeading",
"text" => $lng->txt(
"survey_delete_heading"));
1580 $menu[] = array(
"cmd" =>
"addHeading",
"text" => $lng->txt(
"add_heading"));
1584 if($first_question[
"questionblock_show_questiontext"])
1586 $question_title_status = $lng->txt(
"survey_question_text_visible");
1590 $question_title_status = $lng->txt(
"survey_question_text_hidden");
1593 $this->
renderPageNode($ttpl,
"question", $question[
"question_id"], $question_gui, $menu,
1594 false, $question[
"title"], $question_title_status, $question[
"heading"]);
1596 $ilCtrl->setParameter($this,
"eqid",
"");
1608 foreach($questiontypes as $trans => $item)
1610 $menu[] = array(
"cmd"=>
"addQuestion_".$item[
"questiontype_id"],
1611 "text"=> sprintf($lng->txt(
"svy_page_add_question"), $trans));
1614 if($this->object->isPoolActive())
1616 $menu[] = array(
"cmd"=>
"addPoolQuestion",
1617 "text"=> $lng->txt(
"browse_for_questions"));
1622 $menu[] = array(
"cmd" =>
"paste",
"text" => $lng->txt(
"survey_dnd_paste"));
1628 return $ttpl->get();
1643 function renderPageNode(
ilTemplate $a_tpl, $a_type, $a_id, $a_content = null, array $a_menu = null, $a_spacer =
false, $a_subtitle =
false, $a_status =
false, $a_heading =
false)
1647 $node_id = $a_type.
"_".$a_id;
1649 if($a_content !== null)
1656 $caption = $lng->txt(
"questionblock");
1662 $a_content =
"<div class=\"questionheading\">".$a_heading.
"</div>".
1665 $caption = $lng->txt(
"question").
": ".$a_subtitle;
1671 $caption = $lng->txt(
"heading");
1680 $caption .=
" (".$a_status.
")";
1687 $a_tpl->
setVariable(
"TXT_NODE_CONTENT", $a_content);
1690 $a_tpl->
setVariable(
"VAL_DBLCLICK",
"onDblClick=\"doMouseDblClick(event,this.id);\"");
1698 foreach($a_menu as $mcnt => $menu_item)
1701 $a_tpl->
setVariable(
"TXT_MENU_CMD", $menu_item[
"text"]);
1735 $this->
object->deleteAllUserData();
1748 $this->
object->saveHeading(
"",
$_POST[
"removeheading"]);
1759 $node =
$_POST[
"ajaxform_node"];
1762 $node = explode(
"_", $node);
1763 if($node[0] ==
"heading")
1765 $id = (int)$node[1];
1767 include_once
"Modules/Survey/classes/class.ilObjSurvey.php";
1779 $node =
$_POST[
"ajaxform_node"];
1782 $node = explode(
"_", $node);
1783 if($node[0] ==
"heading")
1785 $id = (int)$node[1];
1786 $content = trim(
$_POST[
"ajaxform_content"]);
1788 $this->
object->saveHeading($content, $id);
1803 return $lng->txt(
"survey_auto_block_title");
1810 if($node ==
"page_end")
1812 $pos = $this->
object->getSurveyPages();
1813 $pos = array_pop($pos[$this->current_page-1]);
1814 $pos = $pos[
"question_id"].
"a";
1821 $ilCtrl->setParameter($this->survey_gui,
"pgov", $this->current_page);
1822 $ilCtrl->setParameter($this->survey_gui,
"pgov_pos", $pos);
1824 $cmd = ($ilUser->getPref(
'svy_insert_type') == 1 || strlen($ilUser->getPref(
'svy_insert_type')) == 0) ?
'browseForQuestions' :
'browseForQuestionblocks';
1825 $ilCtrl->redirect($this->survey_gui,
$cmd);