39 $this->editor_gui = $a_survey_editor_gui;
40 $this->ref_id = $a_survey->
getRefId();
41 $this->
object = $a_survey;
53 $next_class =
$ilCtrl->getNextClass($this);
62 if($rbacsystem->checkAccess(
"write", $this->ref_id))
65 if($_REQUEST[
"new_id"])
71 if($_REQUEST[
"il_hform_subcmd"])
73 $subcmd = $_REQUEST[
"il_hform_subcmd"];
76 $ilCtrl->setParameter($this->editor_gui,
"pgov", $this->current_page);
79 $id = explode(
"_", $_REQUEST[
"il_hform_node"]);
83 if(substr($_REQUEST[
"il_hform_subcmd"], 0, 5) ==
"multi")
85 if($_REQUEST[
"il_hform_multi"])
89 foreach(explode(
";", $_REQUEST[
"il_hform_multi"]) as $item)
91 $id[] = (int)array_pop(explode(
"_", $item));
94 if($subcmd ==
"multiDelete")
96 $subcmd =
"deleteQuestion";
102 if($subcmd ==
"multiDelete")
105 $ilCtrl->redirect($this,
"renderPage");
114 if(substr($subcmd, 0, 11) ==
"addQuestion")
116 $type = explode(
"_", $subcmd);
117 $type = (int)$type[1];
118 $has_content = $this->
addQuestion($type, $this->object->isPoolActive(), $id, $_REQUEST[
"il_hform_node"]);
122 $has_content = $this->$subcmd($id, $_REQUEST[
"il_hform_node"]);
167 $this->log->debug(
"append question, id: ".$a_new_id.
", duplicate: ".$a_duplicate.
", force: ".$a_force_duplicate);
170 $result =
$ilDB->queryF(
"SELECT survey_question_id FROM svy_svy_qst WHERE survey_fi = %s",
172 array($this->object->getSurveyId())
174 $sequence =
$result->numRows();
180 $survey_question_id = $this->
object->duplicateQuestionForSurvey($a_new_id, $a_force_duplicate);
185 $survey_question_id = $a_new_id;
189 if ($this->object->isQuestionInSurvey($survey_question_id))
191 return $survey_question_id;
195 $next_id =
$ilDB->nextId(
'svy_svy_qst');
196 $affectedRows =
$ilDB->manipulateF(
"INSERT INTO svy_svy_qst (survey_question_id, survey_fi,".
197 "question_fi, sequence, tstamp) VALUES (%s, %s, %s, %s, %s)",
198 array(
'integer',
'integer',
'integer',
'integer',
'integer'),
199 array($next_id, $this->object->getSurveyId(), $survey_question_id, $sequence, time())
202 $this->log->debug(
"insert svy_svy_qst, id: ".$next_id.
", qfi: ".$survey_question_id.
", seq: ".$sequence);
204 return $survey_question_id;
216 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
224 $this->
object->loadQuestionsFromDb();
226 $pos = $_REQUEST[
"pgov_pos"];
229 if(substr($pos, -1) !=
"c")
232 $current = $this->
object->getSurveyPages();
233 $current = $current[$this->current_page-1];
234 if(
sizeof($current) == 1)
240 array((
int)$pos, $a_new_id));
244 $block_id = array_pop($current);
245 $block_id = $block_id[
"questionblock_id"];
247 $this->
object->addQuestionToBlock($a_new_id, $block_id);
256 $pos = (int)$pos.
"a";
257 $this->current_page++;
262 $first = $this->
object->getSurveyPages();
264 $first = array_shift($first);
265 $pos = $first[
"question_id"].
"b";
266 $this->current_page = 1;
271 $this->
object->moveQuestions(array($a_new_id), (
int)$pos,
272 ((substr($pos, -1) ==
"a") ? 1 : 0));
274 $this->
object->fixSequenceStructure();
286 $question_ids = $this->
object->getQuestionblockQuestionIds($a_block_id);
287 foreach($question_ids as $qid)
294 $this->
object->loadQuestionsFromDb();
296 $pos = $_REQUEST[
"pgov_pos"];
299 if(substr($pos, -1) !=
"c")
302 $current = $this->
object->getSurveyPages();
303 $current = $current[$this->current_page-1];
304 if(
sizeof($current) == 1)
310 array((
int)$pos)+$new_ids);
314 $block_id = array_pop($current);
315 $block_id = $block_id[
"questionblock_id"];
317 foreach($new_ids as $qid)
319 $this->
object->addQuestionToBlock($qid, $block_id);
333 $pos = (int)$pos.
"a";
338 $first = $this->
object->getSurveyPages();
340 $first = array_shift($first);
341 $pos = $first[
"question_id"].
"b";
346 $this->
object->moveQuestions($new_ids, (
int)$pos,
347 ((substr($pos, -1) ==
"a") ? 1 : 0));
364 include_once
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
366 foreach($questiontypes as $item)
368 if($item[
"questiontype_id"] ==
$a_type)
370 $type_trans = $item[
"type_tag"];
377 if($a_special_position ==
"toolbar")
379 $id = $this->
object->getSurveyPages();
380 if($a_pos && $a_pos !=
"fst")
383 $id = array_pop($id);
384 $id = $id[
"question_id"].
"c";
392 else if($a_special_position ==
"page_end")
394 $id = $this->
object->getSurveyPages();
395 $id = $id[$this->current_page-1];
396 $id = array_pop($id);
397 $id = $id[
"question_id"].
"a";
406 $_GET[
"sel_question_types"] = $type_trans;
407 $_REQUEST[
"pgov_pos"] = $id;
408 $ilCtrl->setParameter($this->editor_gui,
"pgov_pos", $id);
411 $ilTabs->clearSubTabs();
412 $this->editor_gui->createQuestionObject();
416 $this->editor_gui->executeCreateQuestionObject();
424 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
426 $q_gui->object->setObjId($this->object->getId());
427 $q_gui->object->createNewQuestion();
428 $q_gui_class = get_class($q_gui);
431 $ilCtrl->setParameterByClass($q_gui_class,
"pgov", $this->current_page);
432 $ilCtrl->setParameterByClass($q_gui_class,
"pgov_pos",$id);
433 $ilCtrl->setParameterByClass($q_gui_class,
"ref_id", $this->ref_id);
434 $ilCtrl->setParameterByClass($q_gui_class,
"new_for_survey", $this->ref_id);
435 $ilCtrl->setParameterByClass($q_gui_class,
"q_id", $q_gui->object->getId());
436 $ilCtrl->setParameterByClass($q_gui_class,
"sel_question_types", $q_gui->getQuestionType());
437 $ilCtrl->redirectByClass($q_gui_class,
"editQuestion");
451 $this->suppress_clipboard_msg =
true;
454 "source" => $this->current_page,
455 "nodes" => array($a_id),
469 $this->suppress_clipboard_msg =
true;
472 "source" => $this->current_page,
473 "nodes" => array($a_id),
489 $this->suppress_clipboard_msg =
true;
492 "source" => $this->current_page,
510 $this->suppress_clipboard_msg =
true;
513 "source" => $this->current_page,
535 $pages = $this->
object->getSurveyPages();
536 $source = $pages[
$data[
"source"]-1];
537 $target = $pages[$this->current_page-1];
541 foreach($source as $src_qst)
543 if(in_array($src_qst[
"question_id"],
$data[
"nodes"]))
545 $nodes[] = $src_qst[
"question_id"];
551 if($_REQUEST[
"il_hform_node"] ==
"page_end")
554 $a_id = array_pop($a_id);
555 $a_id = $a_id[
"question_id"];
560 if(
$data[
"mode"] ==
"cut")
563 if(
$data[
"source"] == $this->current_page)
566 if(
sizeof($nodes) <=
sizeof($source))
568 $this->
object->moveQuestions($nodes, $a_id, $pos);
576 $source_block_id =
false;
577 if(
sizeof($source) > 1)
579 $source_block_id = $source;
580 $source_block_id = array_shift($source_block_id);
581 $source_block_id = $source_block_id[
"questionblock_id"];
584 if(
sizeof($source) >
sizeof($nodes))
586 foreach($nodes as $qid)
588 $this->
object->removeQuestionFromBlock($qid, $source_block_id);
594 $this->
object->unfoldQuestionblocks(array($source_block_id));
599 if(
sizeof($source) ==
sizeof($nodes) &&
$data[
"source"] < $this->current_page)
601 $this->current_page--;
607 else if(
$data[
"mode"] ==
"copy")
610 foreach($this->object->getSurveyPages() as $page)
612 foreach($page as $question)
614 $titles[] = $question[
"title"];
619 $question_pointer = array();
620 foreach($nodes as $qid)
626 $title = $question->getTitle();
628 foreach($titles as $existing_title)
630 #21278 preg_quote with delimiter
631 if(preg_match(
"/".preg_quote(
$title,
"/").
" \(([0-9]+)\)$/", $existing_title, $match))
633 $max = max($match[1], $max);
638 $title .=
" (".($max+1).
")";
645 $question->setTitle(
$title);
648 $question->saveToDb();
650 $question_pointer[$qid] = $question->getId();
655 $this->
object->cloneTextblocks($question_pointer);
657 $this->
object->loadQuestionsFromDb();
659 $nodes = array_values($question_pointer);
668 $nodes = array_merge(array($a_id), $nodes);
678 $target_block_id = array_shift($target_block_id);
679 $target_block_id = $target_block_id[
"questionblock_id"];
681 foreach($nodes as $qid)
683 $this->
object->addQuestionToBlock($qid, $target_block_id);
687 $this->
object->moveQuestions($nodes, $a_id, $pos);
698 $source_id = (int)array_pop(explode(
"_", $_REQUEST[
"il_hform_source"]));
699 if($_REQUEST[
"il_hform_target"] !=
"droparea_end")
701 $target_id = (int)array_pop(explode(
"_", $_REQUEST[
"il_hform_target"]));
706 $page = $this->
object->getSurveyPages();
707 $page = $page[$this->current_page-1];
708 $last = array_pop($page);
714 $this->
object->moveQuestions(array($source_id),
$target_id, $pos);
726 $ilCtrl->setParameter($this->editor_gui,
"pgov", $this->current_page);
729 $page = $this->
object->getSurveyPages();
730 $page = $page[$this->current_page-1];
733 if($_REQUEST[
"csum"] != md5(print_r($page,
true)))
735 $ilCtrl->redirect($this,
"renderPage");
738 $page = array_shift($page);
739 $block_id = $page[
"questionblock_id"];
742 $this->editor_gui->removeQuestionsForm(array($block_id), array(), array());
746 $this->editor_gui->removeQuestionsForm(array(), array($page[
"question_id"]), array());
761 $a_id = array($a_id);
764 $ilCtrl->setParameter($this->editor_gui,
"pgov", $this->current_page);
765 $this->editor_gui->removeQuestionsForm(array(), $a_id, array());
778 foreach (
$_POST as $key => $value)
780 if (preg_match(
"/id_(\d+)/", $key, $matches))
782 array_push($ids, $matches[1]);
787 $pages = $this->
object->getSurveyPages();
788 $source = $pages[$this->current_page-1];
791 $block_id = array_shift($block_id);
792 $block_id = $block_id[
"questionblock_id"];
794 if(
sizeof($ids) &&
sizeof($source) >
sizeof($ids))
797 if(
sizeof($source)-
sizeof($ids) == 1)
799 $this->
object->unfoldQuestionblocks(array($block_id));
804 foreach($ids as $qid)
806 $this->
object->removeQuestionFromBlock($qid, $block_id);
810 $this->
object->removeQuestions($ids, array());
818 $this->
object->removeQuestions(array(), array($block_id));
823 $this->
object->removeQuestions($ids, array());
827 if($this->current_page > 1)
829 $this->current_page--;
833 $this->
object->saveCompletionStatus();
836 $ilCtrl->setParameter($this,
"pgov", $this->current_page);
837 $ilCtrl->redirect($this,
"renderPage");
847 $this->
callEditor(
"editQuestionblockObject",
"bl_id", $a_id);
858 $this->
callEditor(
"addHeadingObject",
"q_id", $a_id);
869 $this->
callEditor(
"editHeadingObject",
"q_id", $a_id);
880 $this->
callEditor(
"removeHeadingObject",
"q_id", $a_id);
888 $ilTabs->clearSubTabs();
889 $_REQUEST[$a_param] = $a_value;
891 call_user_func(array($this->editor_gui, $a_cmd));
901 $pages = $this->
object->getSurveyPages();
902 $source = $pages[$this->current_page-1];
904 $block_questions = array();
905 $add = $block_id =
false;
906 foreach($source as $idx => $item)
908 if($item[
"question_id"] == $a_id)
910 $block_id = $item[
"questionblock_id"];
915 $block_questions[] = $item[
"question_id"];
922 $this->
object->unfoldQuestionblocks(array($block_id));
927 foreach($block_questions as $qid)
929 $this->
object->removeQuestionFromBlock($qid, $block_id);
934 if(
sizeof($block_questions) > 1)
941 $this->current_page++;
951 $pages = $this->
object->getSurveyPages();
952 $source = $pages[$this->current_page-1];
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, 0);
994 $this->
object->addQuestionToBlock($a_id, $target_block_id);
998 if(
sizeof($source) > 1)
1000 $this->current_page++;
1012 $pages = $this->
object->getSurveyPages();
1013 $source = $pages[$this->current_page-1];
1014 $target = $pages[$this->current_page-2];
1019 $target_block_id =
$target_id[
"questionblock_id"];
1023 if(
sizeof($source) > 1)
1025 $block_id = $source;
1026 $block_id = array_shift($block_id);
1027 $block_id = $block_id[
"questionblock_id"];
1030 if(
sizeof($source) == 2)
1033 $this->
object->unfoldQuestionblocks(array($block_id));
1038 $this->
object->removeQuestionFromBlock($a_id, $block_id);
1043 $this->
object->moveQuestions(array($a_id),
$target_id, 1);
1055 $this->
object->addQuestionToBlock($a_id, $target_block_id);
1058 $this->current_page--;
1071 $data = $this->
object->getSurveyQuestions();
1074 $q_gui =
$data[
"type_tag"].
"GUI";
1075 $ilCtrl->setParameterByClass($q_gui,
"pgov", $this->current_page);
1076 $ilCtrl->setParameterByClass($q_gui,
"q_id", $a_id);
1078 $ilCtrl->redirectByClass($q_gui,
"editQuestion");
1088 include_once
"Services/Form/classes/class.ilPropertyFormGUI.php";
1090 $form->setFormAction(
$ilCtrl->getFormAction($this,
"addQuestionToolbar"));
1091 $form->setTitle(
$lng->txt(
"survey_add_new_question"));
1094 include_once
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
1096 $type_map = array();
1097 foreach($questiontypes as $trans => $item)
1099 $type_map[$item[
"questiontype_id"]] = $trans;
1101 include_once(
"./Services/Form/classes/class.ilSelectInputGUI.php");
1103 $si->setOptions($type_map);
1104 $form->addItem(
$si);
1106 $pages = $this->
object->getSurveyPages();
1109 $pages_drop = array(
"fst"=>
$lng->txt(
"survey_at_beginning"));
1110 foreach($pages as $idx => $questions)
1112 $question = array_shift($questions);
1113 if($question[
"questionblock_id"])
1115 $pages_drop[$idx+1] =
$lng->txt(
"survey_behind_page").
" ".$question[
"questionblock_title"];
1119 $pages_drop[$idx+1] =
$lng->txt(
"survey_behind_page").
" ".strip_tags($question[
"title"]);
1123 $pos->setOptions($pages_drop);
1124 $form->addItem($pos);
1126 $pos->setValue($this->current_page);
1132 $pos->setValue(
"fst");
1133 $form->addItem($pos);
1136 if($this->object->isPoolActive())
1138 $this->editor_gui->createQuestionObject($form);
1141 $form->addCommandButton(
"addQuestionToolbar",
$lng->txt(
"create"));
1142 $form->addCommandButton(
"renderPage",
$lng->txt(
"cancel"));
1144 return $tpl->setContent($form->getHTML());
1154 $pool_active = $this->
object->isPoolActive();
1156 if(!
$_POST[
"usage"] && $pool_active)
1163 $ilCtrl->setParameter($this->editor_gui,
"pgov", $this->current_page);
1178 include_once
"Services/Form/classes/class.ilPropertyFormGUI.php";
1180 $form->setFormAction(
$ilCtrl->getFormAction($this,
"movePage"));
1181 $form->setTitle(
$lng->txt(
"survey_move_page"));
1184 $old_pos->setValue($this->current_page);
1185 $form->addItem($old_pos);
1187 $pages = $this->
object->getSurveyPages();
1190 $pages_drop = array();
1191 if($this->current_page != 1)
1193 $pages_drop[
"fst"] =
$lng->txt(
"survey_at_beginning");
1195 foreach($pages as $idx => $questions)
1197 if(($idx+1) != $this->current_page && ($idx+2) != $this->current_page)
1199 $question = array_shift($questions);
1200 if($question[
"questionblock_id"])
1202 $pages_drop[$idx+1] =
$lng->txt(
"survey_behind_page").
" ".$question[
"questionblock_title"];
1206 $pages_drop[$idx+1] =
$lng->txt(
"survey_behind_page").
" ".strip_tags($question[
"title"]);
1211 $pos->setOptions($pages_drop);
1212 $form->addItem($pos);
1215 $form->addCommandButton(
"movePage",
$lng->txt(
"submit"));
1216 $form->addCommandButton(
"renderPage",
$lng->txt(
"cancel"));
1218 return $tpl->setContent($form->getHTML());
1230 $target_page = $this->current_page-1;
1231 $source_page = $_REQUEST[
"old_pos"]-1;
1233 $pages = $this->
object->getSurveyPages();
1234 foreach($pages[$source_page] as $question)
1236 $questions[] = $question[
"question_id"];
1241 if($_REQUEST[
"pgov"] !=
"fst")
1246 $target = $pages[$target_page];
1255 $this->
object->moveQuestions($questions,
$target[
"question_id"], $position);
1257 if($target_page < $source_page && $position)
1259 $this->current_page++;
1263 $ilCtrl->setParameter($this,
"pgov", $this->current_page);
1264 $ilCtrl->redirect($this,
"renderPage");
1276 include_once
"Services/UIComponent/Button/classes/class.ilLinkButton.php";
1278 if(!$this->has_datasets)
1281 $button->setCaption(
"survey_add_new_question");
1282 $button->setUrl(
$ilCtrl->getLinkTarget($this,
"addQuestionToolbarForm"));
1283 $ilToolbar->addStickyItem($button);
1285 if($this->object->isPoolActive())
1291 is_array($a_pages[$this->current_page-1]))
1293 $last_on_page = $a_pages[$this->current_page-1];
1294 $last_on_page = array_pop($last_on_page);
1295 $last_on_page = $last_on_page[
"question_id"];
1298 $ilCtrl->setParameter($this->editor_gui,
"pgov", $this->current_page);
1299 $ilCtrl->setParameter($this->editor_gui,
"pgov_pos", $last_on_page.
"c");
1301 $cmd = (
$ilUser->getPref(
'svy_insert_type') == 1 ||
1302 strlen(
$ilUser->getPref(
'svy_insert_type')) == 0)
1303 ?
'browseForQuestions'
1304 :
'browseForQuestionblocks';
1307 $button->setCaption(
"browse_for_questions");
1308 $button->setUrl(
$ilCtrl->getLinkTarget($this->editor_gui,
$cmd));
1309 $ilToolbar->addStickyItem($button);
1311 $ilCtrl->setParameter($this->editor_gui,
"pgov",
"");
1312 $ilCtrl->setParameter($this->editor_gui,
"pgov_pos",
"");
1317 $ilToolbar->addSeparator();
1326 $ilCtrl->setParameter($this,
"pg", $this->current_page-1);
1328 $button->setCaption(
"survey_prev_question");
1329 $button->setUrl(
$ilCtrl->getLinkTarget($this,
"renderPage"));
1330 $button->setDisabled(!$this->has_previous_page);
1331 $ilToolbar->addStickyItem($button);
1333 $ilCtrl->setParameter($this,
"pg", $this->current_page+1);
1335 $button->setCaption(
"survey_next_question");
1336 $button->setUrl(
$ilCtrl->getLinkTarget($this,
"renderPage"));
1337 $button->setDisabled(!$this->has_next_page);
1338 $ilToolbar->addStickyItem($button);
1340 $ilCtrl->setParameter($this,
"pg", $this->current_page);
1342 foreach($a_pages as $idx => $questions)
1345 $page = array_shift($page);
1346 if($page[
"questionblock_id"])
1348 $pages_drop[$idx+1] = $page[
"questionblock_title"];
1350 if(
sizeof($questions) > 1)
1352 foreach($questions as $question)
1354 $pages_drop[($idx+1).
"__".$question[
"question_id"]] =
"- ".$question[
"title"];
1360 $pages_drop[$idx+1] = strip_tags($page[
"title"]);
1366 if(
sizeof($pages_drop) > 1)
1370 $ilToolbar->setFormAction(
$ilCtrl->getFormAction($this));
1372 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
1374 $si->addCustomAttribute(
"onChange=\"forms['ilToolbar'].submit();\"");
1375 $si->setOptions($pages_drop);
1376 $si->setValue($this->current_page);
1377 $ilToolbar->addInputItem(
$si,
true);
1381 $cmd->setValue(
"1");
1382 $ilToolbar->addInputItem(
$cmd);
1384 if(!$this->has_datasets)
1386 $ilToolbar->addSeparator();
1388 $ilCtrl->setParameter($this,
"csum", md5(print_r($a_pages[$this->current_page-1],
true)));
1389 $url =
$ilCtrl->getLinkTarget($this,
"deleteBlock");
1390 $ilCtrl->setParameter($this,
"csum",
"");
1393 $button->setCaption(
"survey_delete_page");
1394 $button->setUrl(
$url);
1395 $ilToolbar->addButtonInstance($button);
1397 $ilToolbar->addSeparator();
1400 $button->setCaption(
"survey_move_page");
1401 $button->setUrl(
$ilCtrl->getLinkTarget($this,
"movePageForm"));
1402 $ilToolbar->addButtonInstance($button);
1414 $pages = $this->
object->getSurveyPages();
1415 $this->has_next_page = ($this->current_page <
sizeof($pages));
1416 $this->has_previous_page = ($this->current_page > 1);
1419 if($this->has_datasets)
1421 $link =
$ilCtrl->getLinkTargetByClass(array(
"ilobjsurveygui",
"ilsurveyparticipantsgui"),
"maintenance");
1422 $link =
"<a href=\"".$link.
"\">".
$lng->txt(
"survey_has_datasets_warning_page_view_link").
"</a>";
1426 $ilCtrl->setParameter($this,
"pg", $this->current_page);
1427 $ilCtrl->setParameter($this,
"pgov",
"");
1433 $ttpl =
new ilTemplate(
"tpl.il_svy_svy_page_view.html",
true,
true,
"Modules/Survey");
1434 $ttpl->setVariable(
"FORM_ACTION",
$ilCtrl->getFormAction($this));
1435 $lng->loadLanguageModule(
"form");
1437 $read_only = ($this->has_datasets || !$rbacsystem->checkAccess(
"write", $this->ref_id));
1439 $commands = $multi_commands = array();
1444 if(!
$_SESSION[
"survey_page_view"][$this->ref_id][
"clipboard"])
1446 $multi_commands[] = array(
"cmd"=>
"multiDelete",
"text"=>
$lng->txt(
"delete"));
1447 $multi_commands[] = array(
"cmd"=>
"multiCut",
"text"=>
$lng->txt(
"cut"));
1448 $multi_commands[] = array(
"cmd"=>
"multiCopy",
"text"=>
$lng->txt(
"copy"));
1449 $multi_commands[] = array(
"cmd"=>
"selectAll",
"text"=>
$lng->txt(
"select_all"));
1453 if(!$this->suppress_clipboard_msg)
1457 $multi_commands[] = array(
"cmd"=>
"clearClipboard",
"text"=>
$lng->txt(
"survey_dnd_clear_clipboard"));
1461 $lng->loadLanguageModule(
"content");
1462 $ttpl->setCurrentBlock(
"help_section");
1463 $ttpl->setVariable(
"TXT_ADD_EL",
$lng->txt(
"cont_add_elements"));
1464 include_once(
"./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
1467 $ttpl->setVariable(
"TXT_DRAG",
$lng->txt(
"cont_drag_and_drop_elements"));
1468 $ttpl->setVariable(
"TXT_SEL",
$lng->txt(
"cont_double_click_to_delete"));
1469 $ttpl->parseCurrentBlock();
1471 $ttpl->setVariable(
"DND_INIT_JS",
"initDragElements();");
1476 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
1479 include_once
"./Services/RTE/classes/class.ilTinyMCE.php";
1481 $ttpl->setVariable(
"WYSIWYG_BLOCKFORMATS", $tiny->_buildAdvancedBlockformatsFromHTMLTags($tags));
1482 $ttpl->setVariable(
"WYSIWYG_VALID_ELEMENTS", $tiny->_getValidElementsFromHTMLTags($tags));
1484 $buttons_1 = $tiny->_buildAdvancedButtonsFromHTMLTags(1, $tags);
1485 $buttons_2 = $tiny->_buildAdvancedButtonsFromHTMLTags(2, $tags).
','.
1486 $tiny->_buildAdvancedTableButtonsFromHTMLTags($tags).
1487 ($tiny->getStyleSelect() ?
',styleselect' :
'');
1488 $buttons_3 = $tiny->_buildAdvancedButtonsFromHTMLTags(3, $tags);
1495 if (count($multi_commands) > 0)
1497 foreach($multi_commands as
$cmd)
1499 $ttpl->setCurrentBlock(
"multi_cmd");
1500 $ttpl->setVariable(
"ORG_CMD_MULTI",
"renderPage");
1501 $ttpl->setVariable(
"MULTI_CMD",
$cmd[
"cmd"]);
1502 $ttpl->setVariable(
"MULTI_CMD_TXT",
$cmd[
"text"]);
1503 $ttpl->parseCurrentBlock();
1506 $ttpl->setCurrentBlock(
"multi_cmds");
1507 $ttpl->setVariable(
"MCMD_ALT",
$lng->txt(
"commands"));
1509 $ttpl->parseCurrentBlock();
1513 $ttpl->setVariable(
"NODES", $this->
getPageNodes($pages[$this->current_page-1],
1514 $this->has_previous_page, $this->has_next_page, $read_only));
1516 $tpl->setContent($ttpl->get());
1519 include_once(
"./Services/YUI/classes/class.ilYuiUtil.php");
1521 $tpl->addJavascript(
"./Modules/Survey/js/SurveyPageView.js");
1522 $tpl->addJavascript(
"./Services/RTE/tiny_mce_3_5_11/tiny_mce_src.js");
1535 function getPageNodes(array $a_questions, $a_has_previous_page =
false, $a_has_next_page =
false, $a_readonly =
false)
1539 $ttpl =
new ilTemplate(
"tpl.il_svy_svy_page_view_nodes.html",
true,
true,
"Modules/Survey");
1541 $has_clipboard = (bool)
$_SESSION[
"survey_page_view"][$this->ref_id][
"clipboard"];
1545 $first_question = $a_questions;
1546 $first_question = array_shift($first_question);
1548 if($first_question[
"questionblock_id"])
1552 if(!$a_readonly && !$has_clipboard)
1554 $menu[] = array(
"cmd" =>
"editBlock",
"text" =>
$lng->txt(
"edit"));
1557 if($first_question[
"questionblock_show_blocktitle"])
1559 $block_status =
$lng->txt(
"survey_block_visible");
1563 $block_status =
$lng->txt(
"survey_block_hidden");
1566 $this->
renderPageNode($ttpl,
"block", $first_question[
"questionblock_id"],
1567 $first_question[
"questionblock_title"].
" (".$block_status.
")", $menu,
false,
false, $block_status);
1573 include_once
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
1575 $questionpools = array_keys($this->object->getQuestionpoolTitles(
true));
1579 foreach($a_questions as $idx => $question)
1589 foreach($questiontypes as $trans => $item)
1591 $menu[] = array(
"cmd"=>
"addQuestion_".$item[
"questiontype_id"],
1592 "text"=>
sprintf(
$lng->txt(
"svy_page_add_question"), $trans));
1595 if($this->object->isPoolActive())
1597 $menu[] = array(
"cmd"=>
"addPoolQuestion",
1598 "text"=>
$lng->txt(
"browse_for_questions"));
1603 $menu[] = array(
"cmd" =>
"paste",
"text" =>
$lng->txt(
"survey_dnd_paste"));
1607 $this->
renderPageNode($ttpl,
"droparea", $question[
"question_id"],
null, $menu,
true);
1610 $question_gui = $this->
object->getQuestionGUI($question[
"type_tag"], $question[
"question_id"]);
1611 $question_form = $question_gui->getWorkingForm(array(), $this->object->getShowQuestionTitles(),
1612 $question[
"questionblock_show_questiontext"],
null, $this->object->getSurveyId());
1616 if(!$a_readonly && !$has_clipboard)
1618 $menu[] = array(
"cmd" =>
"editQuestion",
"text" =>
$lng->txt(
"edit"));
1619 $menu[] = array(
"cmd" =>
"cutQuestion",
"text" =>
$lng->txt(
"cut"));
1620 $menu[] = array(
"cmd" =>
"copyQuestion",
"text" =>
$lng->txt(
"copy"));
1622 if(
sizeof($a_questions) > 1 && $idx > 0)
1624 $menu[] = array(
"cmd" =>
"splitPage",
"text" =>
$lng->txt(
"survey_dnd_split_page"));
1626 if($a_has_next_page)
1628 $menu[] = array(
"cmd" =>
"moveNext",
"text" =>
$lng->txt(
"survey_dnd_move_next"));
1630 if($a_has_previous_page)
1632 $menu[] = array(
"cmd" =>
"movePrevious",
"text" =>
$lng->txt(
"survey_dnd_move_previous"));
1635 $menu[] = array(
"cmd" =>
"deleteQuestion",
"text" =>
$lng->txt(
"delete"));
1638 if($question[
"heading"])
1640 $menu[] = array(
"cmd" =>
"editHeading",
"text" =>
$lng->txt(
"survey_edit_heading"));
1641 $menu[] = array(
"cmd" =>
"deleteHeading",
"text" =>
$lng->txt(
"survey_delete_heading"));
1645 $menu[] = array(
"cmd" =>
"addHeading",
"text" =>
$lng->txt(
"add_heading"));
1649 if($first_question[
"questionblock_show_questiontext"])
1651 $question_title_status =
$lng->txt(
"survey_question_text_visible");
1655 $question_title_status =
$lng->txt(
"survey_question_text_hidden");
1658 $this->
renderPageNode($ttpl,
"question", $question[
"question_id"], $question_form, $menu,
1659 false, $question[
"title"], $question_title_status, $question[
"heading"]);
1661 $ilCtrl->setParameter($this,
"eqid",
"");
1673 foreach($questiontypes as $trans => $item)
1675 $menu[] = array(
"cmd"=>
"addQuestion_".$item[
"questiontype_id"],
1676 "text"=>
sprintf(
$lng->txt(
"svy_page_add_question"), $trans));
1679 if($this->object->isPoolActive())
1681 $menu[] = array(
"cmd"=>
"addPoolQuestion",
1682 "text"=>
$lng->txt(
"browse_for_questions"));
1687 $menu[] = array(
"cmd" =>
"paste",
"text" =>
$lng->txt(
"survey_dnd_paste"));
1693 return $ttpl->get();
1719 foreach($a_menu as $mcnt => $menu_item)
1721 $ilCtrl->setParameter($this,
"il_hform_node", $node_id);
1722 $ilCtrl->setParameter($this,
"il_hform_subcmd", $menu_item[
"cmd"]);
1723 $url =
$ilCtrl->getLinkTarget($this,
"renderPage");
1724 $ilCtrl->setParameter($this,
"il_hform_subcmd",
"");
1725 $ilCtrl->setParameter($this,
"il_hform_node",
"");
1728 $a_tpl->
setVariable(
"TXT_MENU_CMD", $menu_item[
"text"]);
1735 include_once
"Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php";
1743 foreach($a_menu as $mcnt => $menu_item)
1745 $ilCtrl->setParameter($this,
"il_hform_node", $node_id);
1746 $ilCtrl->setParameter($this,
"il_hform_subcmd", $menu_item[
"cmd"]);
1747 $url =
$ilCtrl->getLinkTarget($this,
"renderPage");
1748 $ilCtrl->setParameter($this,
"il_hform_subcmd",
"");
1749 $ilCtrl->setParameter($this,
"il_hform_node",
"");
1752 $a_tpl->
setVariable(
"TXT_ACTION_CMD", $menu_item[
"text"]);
1763 $a_content =
"<div class=\"questionheading\">".$a_heading.
"</div>".
1779 $selectable =
false;
1783 $caption =
$lng->txt(
"questionblock");
1787 $caption =
$lng->txt(
"question").
": ".$a_subtitle;
1793 $caption =
$lng->txt(
"heading");
1802 $caption .=
" (".$a_status.
")";
1828 return $lng->txt(
"survey_auto_block_title");
1835 if($node ==
"page_end")
1837 $pos = $this->
object->getSurveyPages();
1838 $pos = array_pop($pos[$this->current_page-1]);
1839 $pos = $pos[
"question_id"].
"a";
1846 $ilCtrl->setParameter($this->editor_gui,
"pgov", $this->current_page);
1847 $ilCtrl->setParameter($this->editor_gui,
"pgov_pos", $pos);
1849 $cmd = (
$ilUser->getPref(
'svy_insert_type') == 1 || strlen(
$ilUser->getPref(
'svy_insert_type')) == 0) ?
'browseForQuestions' :
'browseForQuestionblocks';
sprintf('%.4f', $callTime)
An exception for terminatinating execution or to throw for unit testing.
setVariable($variable, $value='')
Sets a variable value.
static _getQuestionGUI($questiontype, $question_id=-1)
Creates a question gui representation.
static _isComplete($question_id)
Checks whether the question is complete or not.
static get($a_glyph, $a_text="")
Get glyph html.
static getLogger($a_component_id)
Get component logger.
static _getUsedHTMLTags($a_module="")
Returns an array of all allowed HTML tags for text editing.
static _getQuestiontypes()
Creates a list of all available question types.
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
static _hasDatasets($survey_id)
getRefId()
get reference id @access public
cutQuestion($a_id)
Add question to be cut to clipboard.
appendNewQuestionToSurvey($a_new_id, $a_duplicate=true, $a_force_duplicate=false)
Add new question to survey (database part)
determineCurrentPage()
determine current page
insertQuestionBlock($a_block_id)
Copy and insert questions from block.
movePage()
Move current page to new position.
__construct(ilObjSurvey $a_survey, ilSurveyEditorGUI $a_survey_editor_gui)
Constructor.
copyQuestion($a_id)
Add question to be copied to clipboard.
addHeading($a_id)
Add heading to question.
getPageNodes(array $a_questions, $a_has_previous_page=false, $a_has_next_page=false, $a_readonly=false)
Get Form HTML.
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)
Render single of dnd page view.
multiCut($a_id)
Add questions to be cut to clipboard.
deleteBlock()
Confirm removing question block.
editBlock($a_id)
Edit question block.
addQuestionToolbarForm()
Add question to survey form (used in toolbar)
paste($a_id)
Paste from clipboard.
addQuestion($a_type, $a_use_pool, $a_pos, $a_special_position)
Call add question to survey form.
clearClipboard()
Empty clipboard.
dnd()
Move questions in page.
addQuestionToolbar()
Add question to survey action (used in toolbar)
moveNext($a_id)
Move question to next page.
editQuestion($a_id)
Edit question.
splitPage($a_id)
Split current page in 2 pages.
confirmRemoveQuestions()
Remove question(s) from survey.
renderToolbar($a_pages)
Render toolbar form.
movePrevious($a_id)
Move question to previous page.
addPoolQuestion($pos, $node)
getAutoBlockTitle()
Get name for newly created blocks.
deleteHeading($a_id)
Delete question heading.
callEditor($a_cmd, $a_param, $a_value)
movePageForm()
Move current page.
renderPage()
render questions per page
editHeading($a_id)
Edit question heading.
deleteQuestion($a_id)
Confirm removing question(s) from survey.
insertNewQuestion($a_new_id)
Add new question to survey.
multiCopy($a_id)
Add questions to be copied to clipboard.
special template class to simplify handling of ITX/PEAR
touchBlock($block)
overwrites ITX::touchBlock.
parseCurrentBlock($part="DEFAULT")
Überladene Funktion, die auf den aktuelle Block vorher noch ein replace ausführt @access public.
setCurrentBlock($part="DEFAULT")
Überladene Funktion, die sich hier lokal noch den aktuellen Block merkt.
static removeRedundantSeparators($a_string)
Removes redundant seperators and removes ,, and , at the first or last position of the string.
static sendQuestion($a_info="", $a_keep=false)
Send Question to Screen.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static initDragDrop()
Init YUI Drag and Drop.