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;
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"] !=
"droparea_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 include_once
"Services/UIComponent/Button/classes/class.ilLinkButton.php";
1242 if(!$this->has_datasets)
1245 $button->setCaption(
"survey_add_new_question");
1246 $button->setUrl($ilCtrl->getLinkTarget($this,
"addQuestionToolbarForm"));
1247 $ilToolbar->addButtonInstance($button);
1249 if($this->object->isPoolActive())
1251 $ilToolbar->addSeparator();
1255 is_array($a_pages[$this->current_page-1]))
1257 $last_on_page = $a_pages[$this->current_page-1];
1258 $last_on_page = array_pop($last_on_page);
1259 $last_on_page = $last_on_page[
"question_id"];
1262 $ilCtrl->setParameter($this->editor_gui,
"pgov", $this->current_page);
1263 $ilCtrl->setParameter($this->editor_gui,
"pgov_pos", $last_on_page.
"c");
1265 $cmd = ($ilUser->getPref(
'svy_insert_type') == 1 ||
1266 strlen($ilUser->getPref(
'svy_insert_type')) == 0)
1267 ?
'browseForQuestions'
1268 :
'browseForQuestionblocks';
1271 $button->setCaption(
"browse_for_questions");
1272 $button->setUrl($ilCtrl->getLinkTarget($this->editor_gui,
$cmd));
1273 $ilToolbar->addButtonInstance($button);
1275 $ilCtrl->setParameter($this->editor_gui,
"pgov",
"");
1276 $ilCtrl->setParameter($this->editor_gui,
"pgov_pos",
"");
1281 $ilToolbar->addSeparator();
1290 $ilCtrl->setParameter($this,
"pg", $this->current_page-1);
1292 $button->setCaption(
"survey_prev_question");
1293 $button->setUrl($ilCtrl->getLinkTarget($this,
"renderPage"));
1294 $button->setDisabled(!$this->has_previous_page);
1295 $ilToolbar->addButtonInstance($button);
1297 $ilCtrl->setParameter($this,
"pg", $this->current_page+1);
1299 $button->setCaption(
"survey_next_question");
1300 $button->setUrl($ilCtrl->getLinkTarget($this,
"renderPage"));
1301 $button->setDisabled(!$this->has_next_page);
1302 $ilToolbar->addButtonInstance($button);
1304 $ilCtrl->setParameter($this,
"pg", $this->current_page);
1306 foreach($a_pages as $idx => $questions)
1309 $page = array_shift($page);
1310 if($page[
"questionblock_id"])
1312 $pages_drop[$idx+1] = $page[
"questionblock_title"];
1314 if(
sizeof($questions) > 1)
1316 foreach($questions as $question)
1318 $pages_drop[($idx+1).
"__".$question[
"question_id"]] =
"- ".$question[
"title"];
1324 $pages_drop[$idx+1] = strip_tags($page[
"title"]);
1330 if(
sizeof($pages_drop) > 1)
1332 $ilToolbar->addSeparator();
1334 $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
1336 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
1338 $si->addCustomAttribute(
"onChange=\"forms['ilToolbar'].submit();\"");
1339 $si->setOptions($pages_drop);
1340 $si->setValue($this->current_page);
1341 $ilToolbar->addInputItem(
$si,
true);
1345 $cmd->setValue(
"1");
1346 $ilToolbar->addInputItem(
$cmd);
1348 if(!$this->has_datasets)
1350 $ilToolbar->addSeparator();
1352 $ilCtrl->setParameter($this,
"csum", md5(print_r($a_pages[$this->current_page-1],
true)));
1353 $url = $ilCtrl->getLinkTarget($this,
"deleteBlock");
1354 $ilCtrl->setParameter($this,
"csum",
"");
1357 $button->setCaption(
"survey_delete_page");
1358 $button->setUrl($url);
1359 $ilToolbar->addButtonInstance($button);
1361 $ilToolbar->addSeparator();
1364 $button->setCaption(
"survey_move_page");
1365 $button->setUrl($ilCtrl->getLinkTarget($this,
"movePageForm"));
1366 $ilToolbar->addButtonInstance($button);
1378 $pages = $this->
object->getSurveyPages();
1379 $this->has_next_page = ($this->current_page <
sizeof($pages));
1380 $this->has_previous_page = ($this->current_page > 1);
1381 $this->has_datasets = $this->
object->_hasDatasets($this->object->getSurveyId());
1383 if($this->has_datasets)
1385 $link = $ilCtrl->getLinkTargetByClass(array(
"ilobjsurveygui",
"ilsurveyparticipantsgui"),
"maintenance");
1386 $link =
"<a href=\"".$link.
"\">".$lng->txt(
"survey_has_datasets_warning_page_view_link").
"</a>";
1387 ilUtil::sendInfo($lng->txt(
"survey_has_datasets_warning_page_view").
" ".$link);
1390 $ilCtrl->setParameter($this,
"pg", $this->current_page);
1391 $ilCtrl->setParameter($this,
"pgov",
"");
1397 $ttpl =
new ilTemplate(
"tpl.il_svy_svy_page_view.html",
true,
true,
"Modules/Survey");
1398 $ttpl->setVariable(
"FORM_ACTION", $ilCtrl->getFormAction($this));
1399 $lng->loadLanguageModule(
"form");
1401 $read_only = ($this->has_datasets || !$rbacsystem->checkAccess(
"write", $this->ref_id));
1403 $commands = $multi_commands = array();
1408 if(!
$_SESSION[
"survey_page_view"][$this->ref_id][
"clipboard"])
1410 $multi_commands[] = array(
"cmd"=>
"multiDelete",
"text"=>$lng->txt(
"delete"));
1411 $multi_commands[] = array(
"cmd"=>
"multiCut",
"text"=>$lng->txt(
"cut"));
1412 $multi_commands[] = array(
"cmd"=>
"multiCopy",
"text"=>$lng->txt(
"copy"));
1413 $multi_commands[] = array(
"cmd"=>
"selectAll",
"text"=>$lng->txt(
"select_all"));
1417 if(!$this->suppress_clipboard_msg)
1421 $multi_commands[] = array(
"cmd"=>
"clearClipboard",
"text"=>$lng->txt(
"survey_dnd_clear_clipboard"));
1425 $lng->loadLanguageModule(
"content");
1426 $ttpl->setCurrentBlock(
"help_section");
1427 $ttpl->setVariable(
"TXT_ADD_EL", $lng->txt(
"cont_add_elements"));
1428 include_once(
"./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
1431 $ttpl->setVariable(
"TXT_DRAG", $lng->txt(
"cont_drag_and_drop_elements"));
1432 $ttpl->setVariable(
"TXT_SEL", $lng->txt(
"cont_double_click_to_delete"));
1433 $ttpl->parseCurrentBlock();
1435 $ttpl->setVariable(
"DND_INIT_JS",
"initDragElements();");
1440 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
1443 include_once
"./Services/RTE/classes/class.ilTinyMCE.php";
1445 $ttpl->setVariable(
"WYSIWYG_BLOCKFORMATS", $tiny->_buildAdvancedBlockformatsFromHTMLTags($tags));
1446 $ttpl->setVariable(
"WYSIWYG_VALID_ELEMENTS", $tiny->_getValidElementsFromHTMLTags($tags));
1448 $buttons_1 = $tiny->_buildAdvancedButtonsFromHTMLTags(1, $tags);
1449 $buttons_2 = $tiny->_buildAdvancedButtonsFromHTMLTags(2, $tags).
','.
1450 $tiny->_buildAdvancedTableButtonsFromHTMLTags($tags).
1451 ($tiny->getStyleSelect() ?
',styleselect' :
'');
1452 $buttons_3 = $tiny->_buildAdvancedButtonsFromHTMLTags(3, $tags);
1453 $ttpl->setVariable(
'WYSIWYG_BUTTONS_1', $tiny->_removeRedundantSeparators($buttons_1));
1454 $ttpl->setVariable(
'WYSIWYG_BUTTONS_2', $tiny->_removeRedundantSeparators($buttons_2));
1455 $ttpl->setVariable(
'WYSIWYG_BUTTONS_3', $tiny->_removeRedundantSeparators($buttons_3));
1459 if (count($multi_commands) > 0)
1461 foreach($multi_commands as
$cmd)
1463 $ttpl->setCurrentBlock(
"multi_cmd");
1464 $ttpl->setVariable(
"ORG_CMD_MULTI",
"renderPage");
1465 $ttpl->setVariable(
"MULTI_CMD", $cmd[
"cmd"]);
1466 $ttpl->setVariable(
"MULTI_CMD_TXT", $cmd[
"text"]);
1467 $ttpl->parseCurrentBlock();
1470 $ttpl->setCurrentBlock(
"multi_cmds");
1471 $ttpl->setVariable(
"MCMD_ALT", $lng->txt(
"commands"));
1473 $ttpl->parseCurrentBlock();
1477 $ttpl->setVariable(
"NODES", $this->
getPageNodes($pages[$this->current_page-1],
1478 $this->has_previous_page, $this->has_next_page, $read_only));
1480 $tpl->setContent($ttpl->get());
1483 include_once(
"./Services/YUI/classes/class.ilYuiUtil.php");
1485 $tpl->addJavascript(
"./Modules/Survey/js/SurveyPageView.js");
1486 $tpl->addJavascript(
"./Services/RTE/tiny_mce_3_5_11/tiny_mce_src.js");
1499 function getPageNodes(array $a_questions, $a_has_previous_page =
false, $a_has_next_page =
false, $a_readonly =
false)
1503 $ttpl =
new ilTemplate(
"tpl.il_svy_svy_page_view_nodes.html",
true,
true,
"Modules/Survey");
1505 $has_clipboard = (bool)
$_SESSION[
"survey_page_view"][$this->ref_id][
"clipboard"];
1509 $first_question = $a_questions;
1510 $first_question = array_shift($first_question);
1512 if($first_question[
"questionblock_id"])
1516 if(!$a_readonly && !$has_clipboard)
1518 $menu[] = array(
"cmd" =>
"editBlock",
"text" => $lng->txt(
"edit"));
1521 if($first_question[
"questionblock_show_blocktitle"])
1523 $block_status = $lng->txt(
"survey_block_visible");
1527 $block_status = $lng->txt(
"survey_block_hidden");
1530 $this->
renderPageNode($ttpl,
"block", $first_question[
"questionblock_id"],
1531 $first_question[
"questionblock_title"].
" (".$block_status.
")", $menu,
false,
false, $block_status);
1537 include_once
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
1539 $questionpools = array_keys($this->object->getQuestionpoolTitles(
true));
1541 $counter = $question_count;
1543 foreach($a_questions as $idx => $question)
1553 foreach($questiontypes as $trans => $item)
1555 $menu[] = array(
"cmd"=>
"addQuestion_".$item[
"questiontype_id"],
1556 "text"=> sprintf($lng->txt(
"svy_page_add_question"), $trans));
1559 if($this->object->isPoolActive())
1561 $menu[] = array(
"cmd"=>
"addPoolQuestion",
1562 "text"=> $lng->txt(
"browse_for_questions"));
1567 $menu[] = array(
"cmd" =>
"paste",
"text" => $lng->txt(
"survey_dnd_paste"));
1571 $this->
renderPageNode($ttpl,
"droparea", $question[
"question_id"], null, $menu,
true);
1574 $question_gui = $this->
object->getQuestionGUI($question[
"type_tag"], $question[
"question_id"]);
1575 $question_form = $question_gui->getWorkingForm(array(), $this->object->getShowQuestionTitles(),
1576 $question[
"questionblock_show_questiontext"], null, $this->
object->getSurveyId());
1580 if(!$a_readonly && !$has_clipboard)
1582 $menu[] = array(
"cmd" =>
"editQuestion",
"text" => $lng->txt(
"edit"));
1583 $menu[] = array(
"cmd" =>
"cutQuestion",
"text" => $lng->txt(
"cut"));
1584 $menu[] = array(
"cmd" =>
"copyQuestion",
"text" => $lng->txt(
"copy"));
1586 if(
sizeof($a_questions) > 1 && $idx > 0)
1588 $menu[] = array(
"cmd" =>
"splitPage",
"text" => $lng->txt(
"survey_dnd_split_page"));
1590 if($a_has_next_page)
1592 $menu[] = array(
"cmd" =>
"moveNext",
"text" => $lng->txt(
"survey_dnd_move_next"));
1594 if($a_has_previous_page)
1596 $menu[] = array(
"cmd" =>
"movePrevious",
"text" => $lng->txt(
"survey_dnd_move_previous"));
1599 $menu[] = array(
"cmd" =>
"deleteQuestion",
"text" => $lng->txt(
"delete"));
1602 if($question[
"heading"])
1604 $menu[] = array(
"cmd" =>
"editHeading",
"text" => $lng->txt(
"survey_edit_heading"));
1605 $menu[] = array(
"cmd" =>
"deleteHeading",
"text" => $lng->txt(
"survey_delete_heading"));
1609 $menu[] = array(
"cmd" =>
"addHeading",
"text" => $lng->txt(
"add_heading"));
1613 if($first_question[
"questionblock_show_questiontext"])
1615 $question_title_status = $lng->txt(
"survey_question_text_visible");
1619 $question_title_status = $lng->txt(
"survey_question_text_hidden");
1622 $this->
renderPageNode($ttpl,
"question", $question[
"question_id"], $question_form, $menu,
1623 false, $question[
"title"], $question_title_status, $question[
"heading"]);
1625 $ilCtrl->setParameter($this,
"eqid",
"");
1637 foreach($questiontypes as $trans => $item)
1639 $menu[] = array(
"cmd"=>
"addQuestion_".$item[
"questiontype_id"],
1640 "text"=> sprintf($lng->txt(
"svy_page_add_question"), $trans));
1643 if($this->object->isPoolActive())
1645 $menu[] = array(
"cmd"=>
"addPoolQuestion",
1646 "text"=> $lng->txt(
"browse_for_questions"));
1651 $menu[] = array(
"cmd" =>
"paste",
"text" => $lng->txt(
"survey_dnd_paste"));
1657 return $ttpl->get();
1672 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)
1676 $node_id = $a_type.
"_".$a_id;
1683 foreach($a_menu as $mcnt => $menu_item)
1685 $ilCtrl->setParameter($this,
"il_hform_node", $node_id);
1686 $ilCtrl->setParameter($this,
"il_hform_subcmd", $menu_item[
"cmd"]);
1687 $url = $ilCtrl->getLinkTarget($this,
"renderPage");
1688 $ilCtrl->setParameter($this,
"il_hform_subcmd",
"");
1689 $ilCtrl->setParameter($this,
"il_hform_node",
"");
1692 $a_tpl->
setVariable(
"TXT_MENU_CMD", $menu_item[
"text"]);
1699 include_once
"Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php";
1707 foreach($a_menu as $mcnt => $menu_item)
1709 $ilCtrl->setParameter($this,
"il_hform_node", $node_id);
1710 $ilCtrl->setParameter($this,
"il_hform_subcmd", $menu_item[
"cmd"]);
1711 $url = $ilCtrl->getLinkTarget($this,
"renderPage");
1712 $ilCtrl->setParameter($this,
"il_hform_subcmd",
"");
1713 $ilCtrl->setParameter($this,
"il_hform_node",
"");
1716 $a_tpl->
setVariable(
"TXT_ACTION_CMD", $menu_item[
"text"]);
1723 if($a_content !== null &&
1724 $a_type ==
"question" &&
1727 $a_content =
"<div class=\"questionheading\">".$a_heading.
"</div>".
1733 $a_tpl->
setVariable(
"TXT_NODE_CONTENT_ACTIONS", $a_content);
1737 $a_tpl->
setVariable(
"TXT_NODE_CONTENT_NO_ACTIONS", $a_content);
1740 if($a_content !== null)
1743 $selectable =
false;
1747 $caption = $lng->txt(
"questionblock");
1751 $caption = $lng->txt(
"question").
": ".$a_subtitle;
1757 $caption = $lng->txt(
"heading");
1766 $caption .=
" (".$a_status.
")";
1792 return $lng->txt(
"survey_auto_block_title");
1799 if($node ==
"page_end")
1801 $pos = $this->
object->getSurveyPages();
1802 $pos = array_pop($pos[$this->current_page-1]);
1803 $pos = $pos[
"question_id"].
"a";
1810 $ilCtrl->setParameter($this->editor_gui,
"pgov", $this->current_page);
1811 $ilCtrl->setParameter($this->editor_gui,
"pgov_pos", $pos);
1813 $cmd = ($ilUser->getPref(
'svy_insert_type') == 1 || strlen($ilUser->getPref(
'svy_insert_type')) == 0) ?
'browseForQuestions' :
'browseForQuestionblocks';
1814 $ilCtrl->redirect($this->editor_gui,
$cmd);