34 $this->editor_gui = $a_survey_editor_gui;
35 $this->ref_id = $a_survey->
getRefId();
36 $this->
object = $a_survey;
46 $cmd = $ilCtrl->getCmd(
"renderPage");
47 $next_class = $ilCtrl->getNextClass($this);
56 if($rbacsystem->checkAccess(
"write", $this->ref_id))
70 $ilCtrl->setParameter($this->editor_gui,
"pgov", $this->current_page);
73 $id = explode(
"_",
$_REQUEST[
"il_hform_node"]);
77 if(substr(
$_REQUEST[
"il_hform_subcmd"], 0, 5) ==
"multi")
83 foreach(explode(
";",
$_REQUEST[
"il_hform_multi"]) as $item)
85 $id[] = (int)array_pop(explode(
"_", $item));
88 if($subcmd ==
"multiDelete")
90 $subcmd =
"deleteQuestion";
96 if($subcmd ==
"multiDelete")
99 $ilCtrl->redirect($this,
"renderPage");
108 if(substr($subcmd, 0, 11) ==
"addQuestion")
110 $type = explode(
"_", $subcmd);
111 $type = (int)$type[1];
112 $has_content = $this->
addQuestion($type, $this->object->isPoolActive(), $id,
$_REQUEST[
"il_hform_node"]);
116 $has_content = $this->$subcmd($id,
$_REQUEST[
"il_hform_node"]);
161 $result = $ilDB->queryF(
"SELECT survey_question_id FROM svy_svy_qst WHERE survey_fi = %s",
163 array($this->object->getSurveyId())
165 $sequence =
$result->numRows();
170 $survey_question_id = $this->
object->duplicateQuestionForSurvey($a_new_id, $a_force_duplicate);
175 $survey_question_id = $a_new_id;
179 $next_id = $ilDB->nextId(
'svy_svy_qst');
180 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_svy_qst (survey_question_id, survey_fi,".
181 "question_fi, sequence, tstamp) VALUES (%s, %s, %s, %s, %s)",
182 array(
'integer',
'integer',
'integer',
'integer',
'integer'),
183 array($next_id, $this->object->getSurveyId(), $survey_question_id, $sequence, time())
186 return $survey_question_id;
196 global $rbacsystem, $ilDB,
$lng;
198 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
206 $this->
object->loadQuestionsFromDb();
211 if(substr($pos, -1) !=
"c")
214 $current = $this->
object->getSurveyPages();
215 $current = $current[$this->current_page-1];
216 if(
sizeof($current) == 1)
222 array((
int)$pos, $a_new_id));
226 $block_id = array_pop($current);
227 $block_id = $block_id[
"questionblock_id"];
229 $this->
object->addQuestionToBlock($a_new_id, $block_id);
238 $pos = (int)$pos.
"a";
239 $this->current_page++;
244 $first = $this->
object->getSurveyPages();
246 $first = array_shift($first);
247 $pos = $first[
"question_id"].
"b";
248 $this->current_page = 1;
253 $this->
object->moveQuestions(array($a_new_id), (
int)$pos,
254 ((substr($pos, -1) ==
"a") ? 1 : 0));
266 $question_ids = $this->
object->getQuestionblockQuestionIds($a_block_id);
267 foreach($question_ids as $qid)
274 $this->
object->loadQuestionsFromDb();
279 if(substr($pos, -1) !=
"c")
282 $current = $this->
object->getSurveyPages();
283 $current = $current[$this->current_page-1];
284 if(
sizeof($current) == 1)
290 array((
int)$pos)+$new_ids);
294 $block_id = array_pop($current);
295 $block_id = $block_id[
"questionblock_id"];
297 foreach($new_ids as $qid)
299 $this->
object->addQuestionToBlock($qid, $block_id);
313 $pos = (int)$pos.
"a";
318 $first = $this->
object->getSurveyPages();
320 $first = array_shift($first);
321 $pos = $first[
"question_id"].
"b";
326 $this->
object->moveQuestions($new_ids, (
int)$pos,
327 ((substr($pos, -1) ==
"a") ? 1 : 0));
339 protected function addQuestion($a_type, $a_use_pool, $a_pos, $a_special_position)
344 include_once
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
346 foreach($questiontypes as $item)
348 if($item[
"questiontype_id"] == $a_type)
350 $type_trans = $item[
"type_tag"];
357 if($a_special_position ==
"toolbar")
359 $id = $this->
object->getSurveyPages();
360 if($a_pos && $a_pos !=
"fst")
363 $id = array_pop($id);
364 $id = $id[
"question_id"].
"c";
372 else if($a_special_position ==
"page_end")
374 $id = $this->
object->getSurveyPages();
375 $id = $id[$this->current_page-1];
376 $id = array_pop($id);
377 $id = $id[
"question_id"].
"a";
386 $_GET[
"sel_question_types"] = $type_trans;
388 $ilCtrl->setParameter($this->editor_gui,
"pgov_pos", $id);
391 $this->editor_gui->createQuestionObject();
395 $this->editor_gui->executeCreateQuestionObject();
403 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
405 $q_gui->object->setObjId($this->object->getId());
406 $q_gui->object->createNewQuestion();
407 $q_gui_class = get_class($q_gui);
410 $ilCtrl->setParameterByClass($q_gui_class,
"pgov", $this->current_page);
411 $ilCtrl->setParameterByClass($q_gui_class,
"pgov_pos",$id);
412 $ilCtrl->setParameterByClass($q_gui_class,
"ref_id", $this->ref_id);
413 $ilCtrl->setParameterByClass($q_gui_class,
"new_for_survey", $this->ref_id);
414 $ilCtrl->setParameterByClass($q_gui_class,
"q_id", $q_gui->object->getId());
415 $ilCtrl->setParameterByClass($q_gui_class,
"sel_question_types", $q_gui->getQuestionType());
416 $ilCtrl->redirectByClass($q_gui_class,
"editQuestion");
430 $this->suppress_clipboard_msg =
true;
433 "source" => $this->current_page,
434 "nodes" => array($a_id),
448 $this->suppress_clipboard_msg =
true;
451 "source" => $this->current_page,
452 "nodes" => array($a_id),
466 $this->suppress_clipboard_msg =
true;
469 "source" => $this->current_page,
484 $this->suppress_clipboard_msg =
true;
487 "source" => $this->current_page,
508 $pages = $this->
object->getSurveyPages();
509 $source = $pages[$data[
"source"]-1];
510 $target = $pages[$this->current_page-1];
514 foreach($source as $src_qst)
516 if(in_array($src_qst[
"question_id"], $data[
"nodes"]))
518 $nodes[] = $src_qst[
"question_id"];
524 if(
$_REQUEST[
"il_hform_node"] ==
"page_end")
527 $a_id = array_pop($a_id);
528 $a_id = $a_id[
"question_id"];
533 if($data[
"mode"] ==
"cut")
536 if($data[
"source"] == $this->current_page)
539 if(
sizeof($nodes) <=
sizeof($source))
541 $this->
object->moveQuestions($nodes, $a_id, $pos);
549 $source_block_id =
false;
550 if(
sizeof($source) > 1)
552 $source_block_id = $source;
553 $source_block_id = array_shift($source_block_id);
554 $source_block_id = $source_block_id[
"questionblock_id"];
557 if(
sizeof($source) >
sizeof($nodes))
559 foreach($nodes as $qid)
561 $this->
object->removeQuestionFromBlock($qid, $source_block_id);
567 $this->
object->unfoldQuestionblocks(array($source_block_id));
572 if(
sizeof($source) ==
sizeof($nodes) && $data[
"source"] < $this->current_page)
574 $this->current_page--;
580 else if($data[
"mode"] ==
"copy")
583 foreach($this->object->getSurveyPages() as $page)
585 foreach($page as $question)
587 $titles[] = $question[
"title"];
592 $question_pointer = array();
593 foreach($nodes as $qid)
599 $title = $question->getTitle();
601 foreach($titles as $existing_title)
603 if(preg_match(
"/".preg_quote($title).
" \(([0-9]+)\)$/", $existing_title, $match))
605 $max = max($match[1], $max);
610 $title .=
" (".($max+1).
")";
617 $question->setTitle($title);
620 $question->saveToDb();
622 $question_pointer[$qid] = $question->getId();
627 $this->
object->cloneTextblocks($question_pointer);
629 $this->
object->loadQuestionsFromDb();
631 $nodes = array_values($question_pointer);
638 if(
sizeof($target) == 1)
640 $nodes = array_merge(array($a_id), $nodes);
649 $target_block_id = $target;
650 $target_block_id = array_shift($target_block_id);
651 $target_block_id = $target_block_id[
"questionblock_id"];
653 foreach($nodes as $qid)
655 $this->
object->addQuestionToBlock($qid, $target_block_id);
659 $this->
object->moveQuestions($nodes, $a_id, $pos);
670 $source_id = (int)array_pop(explode(
"_",
$_REQUEST[
"il_hform_source"]));
671 if(
$_REQUEST[
"il_hform_target"] !=
"page_end")
678 $page = $this->
object->getSurveyPages();
679 $page = $page[$this->current_page-1];
680 $last = array_pop($page);
686 $this->
object->moveQuestions(array($source_id),
$target_id, $pos);
698 $ilCtrl->setParameter($this->editor_gui,
"pgov", $this->current_page);
701 $page = $this->
object->getSurveyPages();
702 $page = $page[$this->current_page-1];
705 if(
$_REQUEST[
"csum"] != md5(print_r($page,
true)))
707 $ilCtrl->redirect($this,
"renderPage");
710 $page = array_shift($page);
711 $block_id = $page[
"questionblock_id"];
714 $this->editor_gui->removeQuestionsForm(array($block_id), array(), array());
718 $this->editor_gui->removeQuestionsForm(array(), array($page[
"question_id"]), array());
733 $a_id = array($a_id);
736 $ilCtrl->setParameter($this->editor_gui,
"pgov", $this->current_page);
737 $this->editor_gui->removeQuestionsForm(array(), $a_id, array());
750 foreach (
$_POST as $key => $value)
752 if (preg_match(
"/id_(\d+)/", $key, $matches))
754 array_push($ids, $matches[1]);
759 $pages = $this->
object->getSurveyPages();
760 $source = $pages[$this->current_page-1];
763 $block_id = array_shift($block_id);
764 $block_id = $block_id[
"questionblock_id"];
766 if(
sizeof($ids) &&
sizeof($source) >
sizeof($ids))
769 if(
sizeof($source)-
sizeof($ids) == 1)
771 $this->
object->unfoldQuestionblocks(array($block_id));
776 foreach($ids as $qid)
778 $this->
object->removeQuestionFromBlock($qid, $block_id);
782 $this->
object->removeQuestions($ids, array());
790 $this->
object->removeQuestions(array(), array($block_id));
795 $this->
object->removeQuestions($ids, array());
799 if($this->current_page > 1)
801 $this->current_page--;
805 $this->
object->saveCompletionStatus();
808 $ilCtrl->setParameter($this,
"pgov", $this->current_page);
809 $ilCtrl->redirect($this,
"renderPage");
819 $this->
callEditor(
"editQuestionblockObject",
"bl_id", $a_id);
830 $this->
callEditor(
"addHeadingObject",
"q_id", $a_id);
841 $this->
callEditor(
"editHeadingObject",
"q_id", $a_id);
852 $this->
callEditor(
"removeHeadingObject",
"q_id", $a_id);
860 $ilTabs->clearSubTabs();
863 call_user_func(array($this->editor_gui, $a_cmd));
873 $pages = $this->
object->getSurveyPages();
874 $source = $pages[$this->current_page-1];
876 $block_questions = array();
877 $add = $block_id =
false;
878 foreach($source as $idx => $item)
880 if($item[
"question_id"] == $a_id)
882 $block_id = $item[
"questionblock_id"];
887 $block_questions[] = $item[
"question_id"];
894 $this->
object->unfoldQuestionblocks(array($block_id));
899 foreach($block_questions as $qid)
901 $this->
object->removeQuestionFromBlock($qid, $block_id);
906 if(
sizeof($block_questions) > 1)
913 $this->current_page++;
923 $pages = $this->
object->getSurveyPages();
924 $source = $pages[$this->current_page-1];
930 $target_block_id =
$target_id[
"questionblock_id"];
934 if(
sizeof($source) > 1)
937 $block_id = array_shift($block_id);
938 $block_id = $block_id[
"questionblock_id"];
941 if(
sizeof($source) == 2)
944 $this->
object->unfoldQuestionblocks(array($block_id));
949 $this->
object->removeQuestionFromBlock($a_id, $block_id);
954 $this->
object->moveQuestions(array($a_id),
$target_id, 0);
957 if(
sizeof($target) < 2)
966 $this->
object->addQuestionToBlock($a_id, $target_block_id);
970 if(
sizeof($source) > 1)
972 $this->current_page++;
984 $pages = $this->
object->getSurveyPages();
985 $source = $pages[$this->current_page-1];
986 $target = $pages[$this->current_page-2];
991 $target_block_id =
$target_id[
"questionblock_id"];
995 if(
sizeof($source) > 1)
998 $block_id = array_shift($block_id);
999 $block_id = $block_id[
"questionblock_id"];
1002 if(
sizeof($source) == 2)
1005 $this->
object->unfoldQuestionblocks(array($block_id));
1010 $this->
object->removeQuestionFromBlock($a_id, $block_id);
1015 $this->
object->moveQuestions(array($a_id),
$target_id, 1);
1018 if(
sizeof($target) < 2)
1027 $this->
object->addQuestionToBlock($a_id, $target_block_id);
1030 $this->current_page--;
1043 $data = $this->
object->getSurveyQuestions();
1044 $data = $data[$a_id];
1046 $q_gui = $data[
"type_tag"].
"GUI";
1047 $ilCtrl->setParameterByClass($q_gui,
"pgov", $this->current_page);
1048 $ilCtrl->setParameterByClass($q_gui,
"q_id", $a_id);
1050 $ilCtrl->redirectByClass($q_gui,
"editQuestion");
1060 include_once
"Services/Form/classes/class.ilPropertyFormGUI.php";
1062 $form->setFormAction($ilCtrl->getFormAction($this,
"addQuestionToolbar"));
1063 $form->setTitle($lng->txt(
"survey_add_new_question"));
1066 include_once
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
1068 $type_map = array();
1069 foreach($questiontypes as $trans => $item)
1071 $type_map[$item[
"questiontype_id"]] = $trans;
1073 include_once(
"./Services/Form/classes/class.ilSelectInputGUI.php");
1075 $si->setOptions($type_map);
1076 $form->addItem(
$si);
1078 $pages = $this->
object->getSurveyPages();
1081 $pages_drop = array(
"fst"=>$lng->txt(
"survey_at_beginning"));
1082 foreach($pages as $idx => $questions)
1084 $question = array_shift($questions);
1085 if($question[
"questionblock_id"])
1087 $pages_drop[$idx+1] = $lng->txt(
"survey_behind_page").
" ".$question[
"questionblock_title"];
1091 $pages_drop[$idx+1] = $lng->txt(
"survey_behind_page").
" ".strip_tags($question[
"title"]);
1096 $form->addItem($pos);
1098 $pos->setValue($this->current_page);
1104 $pos->setValue(
"fst");
1105 $form->addItem($pos);
1108 if($this->object->isPoolActive())
1110 $this->editor_gui->createQuestionObject($form);
1113 $form->addCommandButton(
"addQuestionToolbar", $lng->txt(
"create"));
1114 $form->addCommandButton(
"renderPage", $lng->txt(
"cancel"));
1116 return $tpl->setContent($form->getHTML());
1126 $pool_active = $this->
object->isPoolActive();
1128 if(!
$_POST[
"usage"] && $pool_active)
1135 $ilCtrl->setParameter($this->editor_gui,
"pgov", $this->current_page);
1150 include_once
"Services/Form/classes/class.ilPropertyFormGUI.php";
1152 $form->setFormAction($ilCtrl->getFormAction($this,
"movePage"));
1153 $form->setTitle($lng->txt(
"survey_move_page"));
1156 $old_pos->setValue($this->current_page);
1157 $form->addItem($old_pos);
1159 $pages = $this->
object->getSurveyPages();
1162 $pages_drop = array();
1163 if($this->current_page != 1)
1165 $pages_drop[
"fst"] = $lng->txt(
"survey_at_beginning");
1167 foreach($pages as $idx => $questions)
1169 if(($idx+1) != $this->current_page && ($idx+2) != $this->current_page)
1171 $question = array_shift($questions);
1172 if($question[
"questionblock_id"])
1174 $pages_drop[$idx+1] = $lng->txt(
"survey_behind_page").
" ".$question[
"questionblock_title"];
1178 $pages_drop[$idx+1] = $lng->txt(
"survey_behind_page").
" ".strip_tags($question[
"title"]);
1184 $form->addItem($pos);
1187 $form->addCommandButton(
"movePage", $lng->txt(
"submit"));
1188 $form->addCommandButton(
"renderPage", $lng->txt(
"cancel"));
1190 return $tpl->setContent($form->getHTML());
1201 $target_page = $this->current_page-1;
1204 $pages = $this->
object->getSurveyPages();
1205 foreach($pages[$source_page] as $question)
1207 $questions[] = $question[
"question_id"];
1217 $target = $pages[$target_page];
1218 $target = array_shift($target);
1219 $this->
object->moveQuestions($questions, $target[
"question_id"], $position);
1221 if($target_page < $source_page && $position)
1223 $this->current_page++;
1227 $ilCtrl->setParameter($this,
"pgov", $this->current_page);
1228 $ilCtrl->redirect($this,
"renderPage");
1240 if(!$this->has_datasets)
1242 $ilToolbar->addButton($lng->txt(
"survey_add_new_question"), $ilCtrl->getLinkTarget($this,
"addQuestionToolbarForm"));
1244 if($this->object->isPoolActive())
1246 $ilToolbar->addSeparator();
1250 is_array($a_pages[$this->current_page-1]))
1252 $last_on_page = $a_pages[$this->current_page-1];
1253 $last_on_page = array_pop($last_on_page);
1254 $last_on_page = $last_on_page[
"question_id"];
1257 $ilCtrl->setParameter($this->editor_gui,
"pgov", $this->current_page);
1258 $ilCtrl->setParameter($this->editor_gui,
"pgov_pos", $last_on_page.
"c");
1260 $cmd = ($ilUser->getPref(
'svy_insert_type') == 1 || strlen($ilUser->getPref(
'svy_insert_type')) == 0) ?
'browseForQuestions' :
'browseForQuestionblocks';
1261 $ilToolbar->addButton($lng->txt(
"browse_for_questions"),
1262 $ilCtrl->getLinkTarget($this->editor_gui,
$cmd));
1264 $ilCtrl->setParameter($this->editor_gui,
"pgov",
"");
1265 $ilCtrl->setParameter($this->editor_gui,
"pgov_pos",
"");
1270 $ilToolbar->addSeparator();
1278 $ilCtrl->setParameter($this,
"pg", $this->current_page-1);
1279 $ilToolbar->addLink($lng->txt(
"survey_prev_question"),
1281 $ilCtrl->setParameter($this,
"pg", $this->current_page+1);
1282 $ilToolbar->addLink($lng->txt(
"survey_next_question"),
1284 $ilCtrl->setParameter($this,
"pg", $this->current_page);
1286 foreach($a_pages as $idx => $questions)
1289 $page = array_shift($page);
1290 if($page[
"questionblock_id"])
1292 $pages_drop[$idx+1] = $page[
"questionblock_title"];
1294 if(
sizeof($questions) > 1)
1296 foreach($questions as $question)
1298 $pages_drop[($idx+1).
"__".$question[
"question_id"]] =
"- ".$question[
"title"];
1304 $pages_drop[$idx+1] = strip_tags($page[
"title"]);
1310 if(
sizeof($pages_drop) > 1)
1312 $ilToolbar->addSeparator();
1314 $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
1316 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
1318 $si->addCustomAttribute(
"onChange=\"forms['ilToolbar'].submit();\"");
1319 $si->setOptions($pages_drop);
1320 $si->setValue($this->current_page);
1321 $ilToolbar->addInputItem(
$si,
true);
1325 $cmd->setValue(
"1");
1326 $ilToolbar->addInputItem(
$cmd);
1328 if(!$this->has_datasets)
1330 $ilToolbar->addSeparator();
1331 $ilCtrl->setParameter($this,
"csum", md5(print_r($a_pages[$this->current_page-1],
true)));
1332 $ilToolbar->addButton($lng->txt(
"survey_delete_page"), $ilCtrl->getLinkTarget($this,
"deleteBlock"));
1333 $ilCtrl->setParameter($this,
"csum",
"");
1335 $ilToolbar->addSeparator();
1336 $ilToolbar->addButton($lng->txt(
"survey_move_page"), $ilCtrl->getLinkTarget($this,
"movePageForm"));
1348 $pages = $this->
object->getSurveyPages();
1349 $this->has_next_page = ($this->current_page <
sizeof($pages));
1350 $this->has_previous_page = ($this->current_page > 1);
1351 $this->has_datasets = $this->
object->_hasDatasets($this->object->getSurveyId());
1353 if($this->has_datasets)
1355 $link = $ilCtrl->getLinkTargetByClass(array(
"ilobjsurveygui",
"ilsurveyparticipantsgui"),
"maintenance");
1356 $link =
"<a href=\"".$link.
"\">".$lng->txt(
"survey_has_datasets_warning_page_view_link").
"</a>";
1357 ilUtil::sendInfo($lng->txt(
"survey_has_datasets_warning_page_view").
" ".$link);
1360 $ilCtrl->setParameter($this,
"pg", $this->current_page);
1361 $ilCtrl->setParameter($this,
"pgov",
"");
1367 $ttpl =
new ilTemplate(
"tpl.il_svy_svy_page_view.html",
true,
true,
"Modules/Survey");
1368 $ttpl->setVariable(
"FORM_ACTION", $ilCtrl->getFormAction($this));
1369 $ttpl->setVariable(
"WYSIWYG_ACTION", $ilCtrl->getFormAction($this));
1370 $lng->loadLanguageModule(
"form");
1372 $read_only = ($this->has_datasets || !$rbacsystem->checkAccess(
"write", $this->ref_id));
1374 $commands = $multi_commands = array();
1379 if(!
$_SESSION[
"survey_page_view"][$this->ref_id][
"clipboard"])
1381 $multi_commands[] = array(
"cmd"=>
"multiDelete",
"text"=>$lng->txt(
"delete"));
1382 $multi_commands[] = array(
"cmd"=>
"multiCut",
"text"=>$lng->txt(
"cut"));
1383 $multi_commands[] = array(
"cmd"=>
"multiCopy",
"text"=>$lng->txt(
"copy"));
1384 $multi_commands[] = array(
"cmd"=>
"selectAll",
"text"=>$lng->txt(
"select_all"));
1388 if(!$this->suppress_clipboard_msg)
1392 $multi_commands[] = array(
"cmd"=>
"clearClipboard",
"text"=>$lng->txt(
"survey_dnd_clear_clipboard"));
1396 $ttpl->setCurrentBlock(
"help_img");
1398 $ttpl->parseCurrentBlock();
1399 $ttpl->setCurrentBlock(
"help_section");
1400 $ttpl->setVariable(
"TXT_HELP", $lng->txt(
"form_hierarchy_add_elements"));
1401 $ttpl->parseCurrentBlock();
1403 $ttpl->setCurrentBlock(
"help_img");
1405 $ttpl->parseCurrentBlock();
1407 $ttpl->parseCurrentBlock();
1408 $ttpl->setCurrentBlock(
"help_section");
1409 $ttpl->setVariable(
"TXT_HELP", $lng->txt(
"form_hierarchy_drag_drop_help"));
1410 $ttpl->parseCurrentBlock();
1412 $ttpl->setCurrentBlock(
"help_img");
1414 $ttpl->parseCurrentBlock();
1415 $ttpl->setCurrentBlock(
"help_section");
1416 $ttpl->setVariable(
"TXT_HELP", $lng->txt(
"survey_dnd_double_click_to_delete"));
1417 $ttpl->parseCurrentBlock();
1419 $ttpl->setVariable(
"DND_INIT_JS",
"initDragElements();");
1424 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
1427 include_once
"./Services/RTE/classes/class.ilTinyMCE.php";
1429 $ttpl->setVariable(
"WYSIWYG_BLOCKFORMATS", $tiny->_buildAdvancedBlockformatsFromHTMLTags($tags));
1430 $ttpl->setVariable(
"WYSIWYG_VALID_ELEMENTS", $tiny->_getValidElementsFromHTMLTags($tags));
1432 $buttons_1 = $tiny->_buildAdvancedButtonsFromHTMLTags(1, $tags);
1433 $buttons_2 = $tiny->_buildAdvancedButtonsFromHTMLTags(2, $tags).
','.
1434 $tiny->_buildAdvancedTableButtonsFromHTMLTags($tags).
1435 ($tiny->getStyleSelect() ?
',styleselect' :
'');
1436 $buttons_3 = $tiny->_buildAdvancedButtonsFromHTMLTags(3, $tags);
1437 $ttpl->setVariable(
'WYSIWYG_BUTTONS_1', $tiny->_removeRedundantSeparators($buttons_1));
1438 $ttpl->setVariable(
'WYSIWYG_BUTTONS_2', $tiny->_removeRedundantSeparators($buttons_2));
1439 $ttpl->setVariable(
'WYSIWYG_BUTTONS_3', $tiny->_removeRedundantSeparators($buttons_3));
1443 if (count($multi_commands) > 0 || count($commands) > 0)
1446 foreach($commands as
$cmd)
1448 $ttpl->setCurrentBlock(
"cmd");
1449 $ttpl->setVariable(
"ORG_CMD",
"renderPage");
1450 $ttpl->setVariable(
"CMD", $cmd[
"cmd"]);
1451 $ttpl->setVariable(
"CMD_TXT", $cmd[
"text"]);
1452 $ttpl->parseCurrentBlock();
1457 foreach($multi_commands as $cmd)
1459 $ttpl->setCurrentBlock(
"multi_cmd");
1460 $ttpl->setVariable(
"ORG_CMD_MULTI",
"renderPage");
1461 $ttpl->setVariable(
"MULTI_CMD", $cmd[
"cmd"]);
1462 $ttpl->setVariable(
"MULTI_CMD_TXT", $cmd[
"text"]);
1463 $ttpl->parseCurrentBlock();
1468 $ttpl->setCurrentBlock(
"multi_cmds");
1469 $ttpl->setVariable(
"MCMD_ALT", $lng->txt(
"commands"));
1471 $ttpl->parseCurrentBlock();
1474 if ($single || $multi)
1476 $ttpl->setCurrentBlock(
"commands");
1477 $ttpl->parseCurrentBlock();
1482 $ttpl->setVariable(
"NODES", $this->
getPageNodes($pages[$this->current_page-1],
1483 $this->has_previous_page, $this->has_next_page, $read_only));
1485 $tpl->setContent($ttpl->get());
1488 include_once(
"./Services/YUI/classes/class.ilYuiUtil.php");
1490 $tpl->addJavascript(
"./Modules/Survey/js/SurveyPageView.js");
1491 $tpl->addJavascript(
"./Services/RTE/tiny_mce_3_5_11/tiny_mce_src.js");
1504 function getPageNodes(array $a_questions, $a_has_previous_page =
false, $a_has_next_page =
false, $a_readonly =
false)
1508 $ttpl =
new ilTemplate(
"tpl.il_svy_svy_page_view_nodes.html",
true,
true,
"Modules/Survey");
1510 $has_clipboard = (bool)
$_SESSION[
"survey_page_view"][$this->ref_id][
"clipboard"];
1514 $first_question = $a_questions;
1515 $first_question = array_shift($first_question);
1517 if($first_question[
"questionblock_id"])
1521 if(!$a_readonly && !$has_clipboard)
1523 $menu[] = array(
"cmd" =>
"editBlock",
"text" => $lng->txt(
"edit"));
1526 if($first_question[
"questionblock_show_blocktitle"])
1528 $block_status = $lng->txt(
"survey_block_visible");
1532 $block_status = $lng->txt(
"survey_block_hidden");
1535 $this->
renderPageNode($ttpl,
"block", $first_question[
"questionblock_id"],
1536 $first_question[
"questionblock_title"].
" (".$block_status.
")", $menu,
false,
false, $block_status);
1542 include_once
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
1544 $questionpools = array_keys($this->object->getQuestionpoolTitles(
true));
1546 $counter = $question_count;
1548 foreach($a_questions as $idx => $question)
1558 foreach($questiontypes as $trans => $item)
1560 $menu[] = array(
"cmd"=>
"addQuestion_".$item[
"questiontype_id"],
1561 "text"=> sprintf($lng->txt(
"svy_page_add_question"), $trans));
1564 if($this->object->isPoolActive())
1566 $menu[] = array(
"cmd"=>
"addPoolQuestion",
1567 "text"=> $lng->txt(
"browse_for_questions"));
1572 $menu[] = array(
"cmd" =>
"paste",
"text" => $lng->txt(
"survey_dnd_paste"));
1576 $this->
renderPageNode($ttpl,
"droparea", $question[
"question_id"], null, $menu,
true);
1579 $question_gui = $this->
object->getQuestionGUI($question[
"type_tag"], $question[
"question_id"]);
1580 $question_form = $question_gui->getWorkingForm(array(), $this->object->getShowQuestionTitles(),
1581 $question[
"questionblock_show_questiontext"], null, $this->
object->getSurveyId());
1585 if(!$a_readonly && !$has_clipboard)
1587 $menu[] = array(
"cmd" =>
"editQuestion",
"text" => $lng->txt(
"edit"));
1588 $menu[] = array(
"cmd" =>
"cutQuestion",
"text" => $lng->txt(
"cut"));
1589 $menu[] = array(
"cmd" =>
"copyQuestion",
"text" => $lng->txt(
"copy"));
1591 if(
sizeof($a_questions) > 1 && $idx > 0)
1593 $menu[] = array(
"cmd" =>
"splitPage",
"text" => $lng->txt(
"survey_dnd_split_page"));
1595 if($a_has_next_page)
1597 $menu[] = array(
"cmd" =>
"moveNext",
"text" => $lng->txt(
"survey_dnd_move_next"));
1599 if($a_has_previous_page)
1601 $menu[] = array(
"cmd" =>
"movePrevious",
"text" => $lng->txt(
"survey_dnd_move_previous"));
1604 $menu[] = array(
"cmd" =>
"deleteQuestion",
"text" => $lng->txt(
"delete"));
1607 if($question[
"heading"])
1609 $menu[] = array(
"cmd" =>
"editHeading",
"text" => $lng->txt(
"survey_edit_heading"));
1610 $menu[] = array(
"cmd" =>
"deleteHeading",
"text" => $lng->txt(
"survey_delete_heading"));
1614 $menu[] = array(
"cmd" =>
"addHeading",
"text" => $lng->txt(
"add_heading"));
1618 if($first_question[
"questionblock_show_questiontext"])
1620 $question_title_status = $lng->txt(
"survey_question_text_visible");
1624 $question_title_status = $lng->txt(
"survey_question_text_hidden");
1627 $this->
renderPageNode($ttpl,
"question", $question[
"question_id"], $question_form, $menu,
1628 false, $question[
"title"], $question_title_status, $question[
"heading"]);
1630 $ilCtrl->setParameter($this,
"eqid",
"");
1642 foreach($questiontypes as $trans => $item)
1644 $menu[] = array(
"cmd"=>
"addQuestion_".$item[
"questiontype_id"],
1645 "text"=> sprintf($lng->txt(
"svy_page_add_question"), $trans));
1648 if($this->object->isPoolActive())
1650 $menu[] = array(
"cmd"=>
"addPoolQuestion",
1651 "text"=> $lng->txt(
"browse_for_questions"));
1656 $menu[] = array(
"cmd" =>
"paste",
"text" => $lng->txt(
"survey_dnd_paste"));
1662 return $ttpl->get();
1677 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)
1681 $node_id = $a_type.
"_".$a_id;
1683 if($a_content !== null)
1690 $caption = $lng->txt(
"questionblock");
1696 $a_content =
"<div class=\"questionheading\">".$a_heading.
"</div>".
1699 $caption = $lng->txt(
"question").
": ".$a_subtitle;
1705 $caption = $lng->txt(
"heading");
1714 $caption .=
" (".$a_status.
")";
1721 $a_tpl->
setVariable(
"TXT_NODE_CONTENT", $a_content);
1724 $a_tpl->
setVariable(
"VAL_DBLCLICK",
" onDblClick=\"doMouseDblClick(event,this.id);\"");
1732 foreach($a_menu as $mcnt => $menu_item)
1735 $a_tpl->
setVariable(
"TXT_MENU_CMD", $menu_item[
"text"]);
1769 $node =
$_POST[
"ajaxform_node"];
1772 $node = explode(
"_", $node);
1773 if($node[0] ==
"heading")
1775 $id = (int)$node[1];
1777 include_once
"Modules/Survey/classes/class.ilObjSurvey.php";
1789 $node =
$_POST[
"ajaxform_node"];
1792 $node = explode(
"_", $node);
1793 if($node[0] ==
"heading")
1795 $id = (int)$node[1];
1796 $content = trim(
$_POST[
"ajaxform_content"]);
1798 $this->
object->saveHeading($content, $id);
1813 return $lng->txt(
"survey_auto_block_title");
1820 if($node ==
"page_end")
1822 $pos = $this->
object->getSurveyPages();
1823 $pos = array_pop($pos[$this->current_page-1]);
1824 $pos = $pos[
"question_id"].
"a";
1831 $ilCtrl->setParameter($this->editor_gui,
"pgov", $this->current_page);
1832 $ilCtrl->setParameter($this->editor_gui,
"pgov_pos", $pos);
1834 $cmd = ($ilUser->getPref(
'svy_insert_type') == 1 || strlen($ilUser->getPref(
'svy_insert_type')) == 0) ?
'browseForQuestions' :
'browseForQuestionblocks';
1835 $ilCtrl->redirect($this->editor_gui,
$cmd);