70        $this->tabs = 
$DIC->tabs();
 
   71        $this->help = 
$DIC[
"ilHelp"];
 
   72        $this->toolbar = 
$DIC->toolbar();
 
   73        $this->
user = $DIC->user();
 
   74        $this->tree = 
$DIC->repositoryTree();
 
   79        $this->parent_gui = $a_parent_gui;
 
   80        $this->
object = $this->parent_gui->object;
 
   86        $this->ctrl->saveParameter($this, array(
"pgov", 
"pgov_pos"));
 
   88        $this->print_options = array(
 
  100        $cmd = $this->ctrl->getCmd(
"questions");
 
  102        if ($_REQUEST[
"pgov"]) {
 
  103            if ($cmd == 
"questions") {
 
  104                $this->ctrl->setCmdClass(
"ilsurveypagegui");
 
  105                $this->ctrl->setCmd(
"renderpage");
 
  106            } elseif ($cmd == 
"confirmRemoveQuestions") {
 
  108                $this->ctrl->setCmdClass(
"ilsurveypagegui");
 
  109                $this->ctrl->setCmd(
"confirmRemoveQuestions");
 
  113        $next_class = $this->ctrl->getNextClass($this);
 
  114        switch ($next_class) {
 
  115            case 'ilsurveypagegui':
 
  117                include_once 
'./Modules/Survey/classes/class.ilSurveyPageGUI.php';
 
  119                $this->ctrl->forwardCommand($pg);
 
  124                if (stristr($next_class, 
"questiongui")) {
 
  125                    $ilTabs->clearTargets();
 
  126                    $this->ctrl->saveParameter($this, array(
"new_for_survey"));
 
  128                    include_once 
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
 
  130                    if (is_object($q_gui->object)) {
 
  132                        $ilHelp->setScreenIdComponent(
"spl_qt" . $q_gui->object->getQuestionTypeId());
 
  135                    $q_gui->setBackUrl($this->ctrl->getLinkTarget($this, 
"questions"));
 
  136                    $q_gui->setQuestionTabs();
 
  137                    $this->ctrl->forwardCommand($q_gui);
 
  139                    if (!(
int) $_REQUEST[
"new_for_survey"]) {
 
  141                        $this->tpl->setTitle($this->lng->txt(
"question") . 
": " . $q_gui->object->getTitle());
 
  155        if ($a_cmd == 
"questions" && $_REQUEST[
"pgov"]) {
 
  159        $hidden_tabs = array();
 
  160        $template = $this->
object->getTemplate();
 
  162            include_once 
"Services/Administration/classes/class.ilSettingsTemplate.php";
 
  164            $hidden_tabs = 
$template->getHiddenTabs();
 
  169            $this->lng->txt(
"survey_per_page_view"),
 
  170            $this->ctrl->getLinkTargetByClass(
"ilsurveypagegui", 
"renderPage")
 
  173        if (!in_array(
"survey_question_editor", $hidden_tabs)) {
 
  174            $this->ctrl->setParameter($this, 
"pgov", 
"");
 
  177                $this->lng->txt(
"survey_question_editor"),
 
  178                $this->ctrl->getLinkTarget($this, 
"questions")
 
  180            $this->ctrl->setParameter($this, 
"pgov", $_REQUEST[
"pgov"]);
 
  185            $this->lng->txt(
"print_view"),
 
  186            $this->ctrl->getLinkTarget($this, 
"printView")
 
  189        if ($this->object->getSurveyPages()) {
 
  190            if ($a_cmd == 
"page") {
 
  191                $this->ctrl->setParameterByClass(
"ilsurveyexecutiongui", 
"pgov", max(1, $_REQUEST[
"pg"]));
 
  193            $this->ctrl->setParameterByClass(
"ilsurveyexecutiongui", 
"prvw", 1);
 
  196                $this->lng->txt(
"preview"),
 
  197                $this->ctrl->getLinkTargetByClass(array(
"ilobjsurveygui", 
"ilsurveyexecutiongui"), 
"preview")
 
  201        $ilTabs->activateSubTab($a_cmd);
 
  215        if (
$_GET[
"new_id"] > 0) {
 
  217            $existing = $this->
object->getExistingQuestions();
 
  218            if (!in_array(
$_GET[
"new_id"], $existing)) {
 
  219                $inserted = $this->
object->insertQuestion(
$_GET[
"new_id"]);
 
  229        $read_only = $hasDatasets;
 
  234            include_once 
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
 
  236                $qtypes[
$data[
"type_tag"]] = $translation;
 
  239            $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
 
  240            include_once 
"Services/Form/classes/class.ilPropertyFormGUI.php";
 
  241            $types = 
new ilSelectInputGUI($this->lng->txt(
"create_new"), 
"sel_question_types");
 
  242            $types->setOptions($qtypes);
 
  243            $ilToolbar->addStickyItem($types, 
"");
 
  245            include_once 
"Services/UIComponent/Button/classes/class.ilLinkButton.php";
 
  246            include_once 
"Services/UIComponent/Button/classes/class.ilSubmitButton.php";
 
  249            $button->setCaption(
"svy_create_question");
 
  250            $button->setCommand(
"createQuestion");
 
  251            $ilToolbar->addStickyItem($button);
 
  253            if ($this->object->isPoolActive()) {
 
  254                $ilToolbar->addSeparator();
 
  256                $cmd = (
$ilUser->getPref(
'svy_insert_type') == 1 ||
 
  257                    strlen(
$ilUser->getPref(
'svy_insert_type')) == 0)
 
  258                    ? 
'browseForQuestions' 
  259                    : 
'browseForQuestionblocks';
 
  262                $button->setCaption(
"browse_for_questions");
 
  263                $button->setUrl($this->ctrl->getLinkTarget($this, $cmd));
 
  264                $ilToolbar->addStickyItem($button);
 
  267            $ilToolbar->addSeparator();
 
  270            $button->setCaption(
"add_heading");
 
  271            $button->setUrl($this->ctrl->getLinkTarget($this, 
"addHeading"));
 
  272            $ilToolbar->addInputItem($button);
 
  275            $link = $this->ctrl->getLinkTargetByClass(
"ilsurveyparticipantsgui", 
"maintenance");
 
  276            $link = 
"<a href=\"" . $link . 
"\">" . $this->lng->txt(
"survey_has_datasets_warning_page_view_link") . 
"</a>";
 
  277            ilUtil::sendInfo($this->lng->txt(
"survey_has_datasets_warning_page_view") . 
" " . $link);
 
  282        include_once 
"Modules/Survey/classes/class.ilSurveyQuestionTableGUI.php";
 
  289        $this->tpl->setContent(
$table->getHTML());
 
  301    protected function gatherSelectedTableItems($allow_blocks = 
true, $allow_questions = 
true, $allow_headings = 
false, $allow_questions_in_blocks = 
false)
 
  303        $block_map = array();
 
  304        foreach ($this->object->getSurveyQuestions() as $item) {
 
  305            $block_map[$item[
"question_id"]] = $item[
"questionblock_id"];
 
  308        $questions = $blocks = $headings = array();
 
  312                if ($allow_questions && preg_match(
"/cb_(\d+)/", 
$key, $matches)) {
 
  313                    if (($allow_questions_in_blocks || !$block_map[$matches[1]]) &&
 
  314                        !in_array($block_map[$matches[1]], $blocks)) {
 
  315                        array_push($questions, $matches[1]);
 
  319                if ($allow_blocks && preg_match(
"/cb_qb_(\d+)/", 
$key, $matches)) {
 
  320                    array_push($blocks, $matches[1]);
 
  323                if ($allow_headings && preg_match(
"/cb_tb_(\d+)/", 
$key, $matches)) {
 
  324                    array_push($headings, $matches[1]);
 
  329        return array(
"questions" => $questions,
 
  331            "headings" => $headings);
 
  336        if (isset(
$_POST[
"order"])) {
 
  340            foreach (array_keys(
$_POST[
"order"]) as 
$id) {
 
  342                if (substr(
$id, 0, 3) == 
"qb_") {
 
  343                    $block_id = substr(
$id, 3);
 
  344                    $block = 
$_POST[
"block_order"][$block_id];
 
  346                    foreach (array_keys($block) as $question_id) {
 
  348                        $order[$question_id] = $position;
 
  351                    $question_id = substr(
$id, 2);
 
  353                    $order[$question_id] = $position;
 
  356            $this->
object->updateOrder($order);
 
  359        $obligatory = array();
 
  361            if (preg_match(
"/obligatory_(\d+)/", 
$key, $matches)) {
 
  362                $obligatory[$matches[1]] = 1;
 
  365        $this->
object->setObligatoryStates($obligatory);
 
  367        $this->ctrl->redirect($this, 
"questions");
 
  373        if (count($items[
"blocks"])) {
 
  375            $this->
object->unfoldQuestionblocks($items[
"blocks"]);
 
  379        $this->ctrl->redirect($this, 
"questions");
 
  386        $move_questions = $items[
"questions"];
 
  387        foreach ($items[
"blocks"] as $block_id) {
 
  388            foreach ($this->object->getQuestionblockQuestionIds($block_id) as $qid) {
 
  389                array_push($move_questions, $qid);
 
  392        if (count($move_questions) == 0) {
 
  394            $this->ctrl->redirect($this, 
"questions");
 
  396            $_SESSION[
"move_questions"] = $move_questions;
 
  397            ilUtil::sendInfo($this->lng->txt(
"select_target_position_for_move_question"));
 
  419            while (!$insert_id && 
sizeof(
$_POST[
"id"])) {
 
  421                if (preg_match(
"/^cb_(\d+)$/", 
$target, $matches)) {
 
  423                    if (in_array($matches[1], $items[
"questions"])) {
 
  424                        $insert_id = $matches[1];
 
  427                if (!$insert_id && preg_match(
"/^cb_qb_(\d+)$/", 
$target, $matches)) {
 
  428                    $ids = $this->
object->getQuestionblockQuestionIds($matches[1]);
 
  430                        if ($insert_mode == 0) {
 
  431                            $insert_id = $ids[0];
 
  432                        } elseif ($insert_mode == 1) {
 
  433                            $insert_id = $ids[count($ids)-1];
 
  444            $this->
object->moveQuestions(
$_SESSION[
"move_questions"], $insert_id, $insert_mode);
 
  448        $this->ctrl->redirect($this, 
"questions");
 
  454        if (count($items[
"blocks"]) + count($items[
"questions"]) + count($items[
"headings"]) > 0) {
 
  459            ilUtil::sendInfo($this->lng->txt(
"no_question_selected_for_removal"), 
true);
 
  460            $this->ctrl->redirect($this, 
"questions");
 
  466        include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
 
  468        $cgui->setHeaderText($this->lng->txt(
"survey_sure_delete_questions"));
 
  470        $cgui->setFormAction($this->ctrl->getFormAction($this, 
"confirmRemoveQuestions"));
 
  471        $cgui->setCancel($this->lng->txt(
"cancel"), 
"questions");
 
  472        $cgui->setConfirm($this->lng->txt(
"confirm"), 
"confirmRemoveQuestions");
 
  475        $surveyquestions =&$this->
object->getSurveyQuestions();
 
  476        include_once 
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
 
  477        foreach ($surveyquestions as $question_id => 
$data) {
 
  478            if (in_array(
$data[
"question_id"], $checked_questions)) {
 
  482                    "id_" . 
$data[
"question_id"],
 
  483                    $data[
"question_id"],
 
  486            } elseif ((in_array(
$data[
"questionblock_id"], $checked_questionblocks))) {
 
  490                    "id_qb_" . 
$data[
"questionblock_id"],
 
  491                    $data[
"questionblock_id"],
 
  494            } elseif (in_array(
$data[
"question_id"], $checked_headings)) {
 
  496                    "id_tb_" . 
$data[
"question_id"],
 
  497                    $data[
"question_id"],
 
  503        $this->tpl->setContent($cgui->getHTML());
 
  508        $checked_questions = array();
 
  509        $checked_questionblocks = array();
 
  510        $checked_headings = array();
 
  512            if (preg_match(
"/id_(\d+)/", 
$key, $matches)) {
 
  513                array_push($checked_questions, $matches[1]);
 
  515            if (preg_match(
"/id_qb_(\d+)/", 
$key, $matches)) {
 
  516                array_push($checked_questionblocks, $matches[1]);
 
  518            if (preg_match(
"/id_tb_(\d+)/", 
$key, $matches)) {
 
  519                array_push($checked_headings, $matches[1]);
 
  523        if (
sizeof($checked_questions) || 
sizeof($checked_questionblocks)) {
 
  524            $this->
object->removeQuestions($checked_questions, $checked_questionblocks);
 
  526        if ($checked_headings) {
 
  527            foreach ($checked_headings as $q_id) {
 
  528                $this->
object->saveHeading(
"", $q_id);
 
  531        $this->
object->saveCompletionStatus();
 
  533        $this->ctrl->redirect($this, 
"questions");
 
  541        $copy_questions = $items[
"questions"];
 
  542        foreach ($items[
"blocks"] as $block_id) {
 
  543            foreach ($this->object->getQuestionblockQuestionIds($block_id) as $qid) {
 
  544                array_push($copy_questions, $qid);
 
  547        $copy_questions = array_unique($copy_questions);
 
  550        if (count($copy_questions)) {
 
  551            foreach ($copy_questions as $idx => $question_id) {
 
  553                if ($question->getOriginalId()) {
 
  554                    unset($copy_questions[$idx]);
 
  558        if (count($copy_questions) == 0) {
 
  559            ilUtil::sendInfo($this->lng->txt(
"no_question_selected_for_copy_to_pool"), 
true);
 
  560            $this->ctrl->redirect($this, 
"questions");
 
  564            include_once 
"Services/Form/classes/class.ilPropertyFormGUI.php";
 
  567            $form->setFormAction($this->ctrl->getFormAction($this, 
"executeCreateQuestion"));
 
  570            $ids->setValue(implode(
";", $copy_questions));
 
  571            $form->addItem($ids);
 
  573            $questionpools =&$this->
object->getAvailableQuestionpools(
false, 
false, 
true, 
"write");
 
  574            $pools = 
new ilSelectInputGUI($this->lng->txt(
"survey_copy_select_questionpool"), 
"sel_spl");
 
  575            $pools->setOptions($questionpools);
 
  576            $form->addItem($pools);
 
  578            $form->addCommandButton(
"executeCopyQuestionsToPool", $this->lng->txt(
"submit"));
 
  579            $form->addCommandButton(
"questions", $this->lng->txt(
"cancel"));
 
  581            return $this->tpl->setContent(
$form->getHTML());
 
  587        $question_ids = explode(
";", 
$_POST[
"question_ids"]);
 
  590        foreach ($question_ids as $qid) {
 
  593            $new_question->setId();
 
  594            $new_question->setObjId($pool_id);
 
  595            $new_question->saveToDb();
 
  602        $this->ctrl->redirect($this, 
"questions");
 
  612        if (!$this->object->isPoolActive()) {
 
  614            $_GET[
"sel_question_types"] = 
$_POST[
"sel_question_types"];
 
  621            include_once 
"Services/Form/classes/class.ilPropertyFormGUI.php";
 
  624            $sel_question_types = (strlen(
$_POST[
"sel_question_types"])) ? 
$_POST[
"sel_question_types"] : 
$_GET[
"sel_question_types"];
 
  625            $this->ctrl->setParameter($this, 
"sel_question_types", $sel_question_types);
 
  626            $form->setFormAction($this->ctrl->getFormAction($this, 
"executeCreateQuestion"));
 
  632        $usage->setRequired(
true);
 
  633        $no_pool = 
new ilRadioOption($this->lng->txt(
"survey_no_pool"), 1);
 
  634        $usage->addOption($no_pool);
 
  635        $existing_pool = 
new ilRadioOption($this->lng->txt(
"survey_existing_pool"), 3);
 
  636        $usage->addOption($existing_pool);
 
  637        $new_pool = 
new ilRadioOption($this->lng->txt(
"survey_new_pool"), 2);
 
  638        $usage->addOption($new_pool);
 
  639        $form->addItem($usage);
 
  641        if (isset(
$_SESSION[
"svy_qpool_choice"])) {
 
  642            $usage->setValue(
$_SESSION[
"svy_qpool_choice"]);
 
  648        $questionpools =&$this->
object->getAvailableQuestionpools(
false, 
true, 
true, 
"write");
 
  649        $pools = 
new ilSelectInputGUI($this->lng->txt(
"select_questionpool"), 
"sel_spl");
 
  650        $pools->setOptions($questionpools);
 
  651        $existing_pool->addSubItem($pools);
 
  655        $name->setMaxLength(50);
 
  656        $new_pool->addSubItem(
$name);
 
  662        $form->addCommandButton(
"executeCreateQuestion", $this->lng->txt(
"submit"));
 
  663        $form->addCommandButton(
"questions", $this->lng->txt(
"cancel"));
 
  665        return $this->tpl->setContent(
$form->getHTML());
 
  672        $q_type = 
$_GET[
"sel_question_types"];
 
  675        if (
$_POST[
"usage"] == 1) {
 
  676            $obj_id = $this->
object->getId();
 
  679        elseif (
$_POST[
"usage"] == 3 && strlen(
$_POST[
"sel_spl"])) {
 
  683        elseif (
$_POST[
"usage"] == 2 && strlen(
$_POST[
"name_spl"])) {
 
  691            $this->ctrl->setParameter($this, 
"sel_question_types", $q_type);
 
  692            $this->ctrl->redirect($this, 
"createQuestion");
 
  698        include_once 
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
 
  700        $q_gui->object->setObjId($obj_id); 
 
  701        $q_gui->object->createNewQuestion();
 
  702        $q_gui_class = get_class($q_gui);
 
  704        if ($_REQUEST[
"pgov"]) {
 
  705            $this->ctrl->setParameterByClass($q_gui_class, 
"pgov", $_REQUEST[
"pgov"]);
 
  706            $this->ctrl->setParameterByClass($q_gui_class, 
"pgov_pos", $_REQUEST[
"pgov_pos"]);
 
  709        $this->ctrl->setParameterByClass($q_gui_class, 
"ref_id", $this->object->getRefId());
 
  710        $this->ctrl->setParameterByClass($q_gui_class, 
"new_for_survey", $this->object->getRefId());
 
  711        $this->ctrl->setParameterByClass($q_gui_class, 
"q_id", $q_gui->object->getId());
 
  712        $this->ctrl->setParameterByClass($q_gui_class, 
"sel_question_types", $q_gui->getQuestionType());
 
  713        $this->ctrl->redirectByClass($q_gui_class, 
"editQuestion");
 
  720        $parent_ref = 
$tree->getParentId($this->object->getRefId());
 
  722        include_once 
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
 
  724        $qpl->setType(
"spl");
 
  725        $qpl->setTitle(
$name);
 
  726        $qpl->setDescription(
"");
 
  728        $qpl->createReference();
 
  729        $qpl->putInTree($parent_ref);
 
  730        $qpl->setPermissions($parent_ref);
 
  734        return $qpl->getId();
 
  748        if (!isset($_REQUEST[
"pgov"])) {
 
  749            $link = $this->ctrl->getLinkTarget($this, 
"questions");
 
  751            $link = $this->ctrl->getLinkTargetByClass(
"ilsurveypagegui", 
"renderpage");
 
  753        $ilTabs->setBackTarget($this->lng->txt(
"menubacktosurvey"), $link);
 
  756        include_once 
"Services/Form/classes/class.ilSelectInputGUI.php";
 
  757        $types = 
new ilSelectInputGUI($this->lng->txt(
"display_all_available"), 
"datatype");
 
  758        $types->setOptions(array(
 
  759            1 =>  $this->lng->txt(
"questions"),
 
  760            2 =>  $this->lng->txt(
"questionblocks")
 
  762        $types->setValue(
$ilUser->getPref(
'svy_insert_type'));
 
  763        $ilToolbar->addInputItem($types, 
true);
 
  764        $ilToolbar->addFormButton($this->lng->txt(
"change"), 
"changeDatatype");
 
  765        $ilToolbar->setFormAction($this->ctrl->getFormAction($this, 
"changeDatatype"));
 
  774        switch (
$_POST[
"datatype"]) {
 
  776                $this->ctrl->redirect($this, 
'browseForQuestionblocks');
 
  781                $this->ctrl->redirect($this, 
'browseForQuestions');
 
  790        include_once 
"./Modules/Survey/classes/tables/class.ilSurveyQuestionbrowserTableGUI.php";
 
  792        $table_gui->setEditable(
true);
 
  793        $this->tpl->setContent($table_gui->getHTML());
 
  798        include_once 
"./Modules/Survey/classes/tables/class.ilSurveyQuestionbrowserTableGUI.php";
 
  800        $table_gui->writeFilterToSession();
 
  801        $this->ctrl->redirect($this, 
'browseForQuestions');
 
  806        include_once 
"./Modules/Survey/classes/tables/class.ilSurveyQuestionbrowserTableGUI.php";
 
  808        $table_gui->resetFilter();
 
  809        $this->ctrl->redirect($this, 
'browseForQuestions');
 
  814        $inserted_objects = 0;
 
  815        if (is_array(
$_POST[
'q_id'])) {
 
  816            if ($_REQUEST[
"pgov"]) {
 
  817                include_once 
"Modules/Survey/classes/class.ilSurveyPageGUI.php";
 
  819                $page_gui->determineCurrentPage();
 
  824            foreach (
$_POST[
'q_id'] as $question_id) {
 
  825                if (!$_REQUEST[
"pgov"]) {
 
  826                    $this->
object->insertQuestion($question_id);
 
  829                    $page_gui->insertNewQuestion($question_id);
 
  834        if ($inserted_objects) {
 
  835            $this->
object->saveCompletionStatus();
 
  837            if (!$_REQUEST[
"pgov"]) {
 
  838                $this->ctrl->redirect($this, 
"questions");
 
  840                $target_page = $_REQUEST[
"pgov"];
 
  841                if (substr($_REQUEST[
"pgov_pos"], -1) == 
"c") {
 
  843                    if ((
int) $_REQUEST[
"pgov_pos"]) {
 
  849                $this->ctrl->setParameterByClass(
"ilsurveypagegui", 
"pgov", $target_page);
 
  850                $this->ctrl->redirectByClass(
"ilsurveypagegui", 
"renderpage");
 
  854            $this->ctrl->redirect($this, 
'browseForQuestions');
 
  862        include_once 
"./Modules/Survey/classes/tables/class.ilSurveyQuestionblockbrowserTableGUI.php";
 
  864        $table_gui->setEditable(
true);
 
  865        $this->tpl->setContent($table_gui->getHTML());
 
  870        include_once 
"./Modules/Survey/classes/tables/class.ilSurveyQuestionblockbrowserTableGUI.php";
 
  872        $table_gui->writeFilterToSession();
 
  873        $this->ctrl->redirect($this, 
'browseForQuestionblocks');
 
  878        include_once 
"./Modules/Survey/classes/tables/class.ilSurveyQuestionblockbrowserTableGUI.php";
 
  880        $table_gui->resetFilter();
 
  881        $this->ctrl->redirect($this, 
'browseForQuestionblocks');
 
  886        $inserted_objects = 0;
 
  887        if (is_array(
$_POST[
'cb'])) {
 
  888            if ($_REQUEST[
"pgov"]) {
 
  889                include_once 
"Modules/Survey/classes/class.ilSurveyPageGUI.php";
 
  891                $page_gui->determineCurrentPage();
 
  896            foreach (
$_POST[
'cb'] as $questionblock_id) {
 
  897                if (!$_REQUEST[
"pgov"]) {
 
  898                    $this->
object->insertQuestionblock($questionblock_id);
 
  900                    $page_gui->insertQuestionblock($questionblock_id);
 
  905        if ($inserted_objects) {
 
  906            $this->
object->saveCompletionStatus();
 
  907            ilUtil::sendSuccess(($inserted_objects == 1) ? $this->lng->txt(
"questionblock_inserted") : $this->lng->txt(
"questionblocks_inserted"), 
true);
 
  908            if (!$_REQUEST[
"pgov"]) {
 
  909                $this->ctrl->redirect($this, 
"questions");
 
  911                $target_page = $_REQUEST[
"pgov"];
 
  912                if (substr($_REQUEST[
"pgov_pos"], -1) == 
"c") {
 
  915                $this->ctrl->setParameterByClass(
"ilsurveypagegui", 
"pgov", $target_page);
 
  916                $this->ctrl->redirectByClass(
"ilsurveypagegui", 
"renderpage");
 
  920            $this->ctrl->redirect($this, 
'browseForQuestionblocks');
 
  931        $block_id = (int) $_REQUEST[
"bl_id"];
 
  932        $this->ctrl->setParameter($this, 
"bl_id", $block_id);
 
  939        $this->tpl->setContent($a_form->getHTML());
 
  947            if (
sizeof(
$_POST[
"qids"])) {
 
  948                $items[
"questions"] = 
$_POST[
"qids"];
 
  950            if (count($items[
"questions"]) < 2) {
 
  951                ilUtil::sendInfo($this->lng->txt(
"qpl_define_questionblock_select_missing"), 
true);
 
  952                $this->ctrl->redirect($this, 
"questions");
 
  959        $this->tpl->setContent($a_form->getHTML());
 
  964        include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
 
  966        $form->setFormAction($this->ctrl->getFormAction($this, 
"saveDefineQuestionblock"));
 
  967        $form->setTitle($this->lng->txt(
"define_questionblock"));
 
  970        $title->setRequired(
true);
 
  973        $toggle_blocktitle = 
new ilCheckboxInputGUI($this->lng->txt(
"survey_show_blocktitle"), 
"show_blocktitle");
 
  974        $toggle_blocktitle->setInfo($this->lng->txt(
"survey_show_blocktitle_description"));
 
  975        $form->addItem($toggle_blocktitle);
 
  977        $toggle_questiontitle = 
new ilCheckboxInputGUI($this->lng->txt(
"show_questiontext"), 
"show_questiontext");
 
  978        $toggle_questiontitle->setInfo($this->lng->txt(
"show_questiontext_description"));
 
  979        $form->addItem($toggle_questiontitle);
 
  983            $title->setValue($questionblock[
"title"]);
 
  984            $toggle_blocktitle->setChecked($questionblock[
"show_blocktitle"]);
 
  985            $toggle_questiontitle->setChecked($questionblock[
"show_questiontext"]);
 
  987            $toggle_blocktitle->setChecked(
true);
 
  988            $toggle_questiontitle->setChecked(
true);
 
  991        $form->addCommandButton(
"saveDefineQuestionblock", $this->lng->txt(
"save"));
 
  992        $form->addCommandButton(
"questions", $this->lng->txt(
"cancel"));
 
  995        if (!$a_question_ids && 
$_POST[
"qids"]) {
 
  996            $a_question_ids = 
$_POST[
"qids"];
 
  999        if ($a_question_ids) {
 
 1000            foreach ($a_question_ids as $q_id) {
 
 1002                $hidden->setValue($q_id);
 
 1003                $form->addItem($hidden);
 
 1012        $block_id = (int) $_REQUEST[
"bl_id"];
 
 1015        $this->ctrl->setParameter($this, 
"bl_id", $block_id);
 
 1017        if (!$block_id && !is_array($q_ids)) {
 
 1018            $this->ctrl->redirect($this, 
"questions");
 
 1022        if (
$form->checkInput()) {
 
 1024            $show_questiontext = 
$form->getInput(
"show_questiontext");
 
 1025            $show_blocktitle = 
$form->getInput(
"show_blocktitle") ;
 
 1027                $this->
object->modifyQuestionblock(
 
 1034                $this->
object->createQuestionblock(
 
 1043            $this->ctrl->redirect($this, 
"questions");
 
 1046        $form->setValuesByPost();
 
 1057        $survey_questions = $this->
object->getSurveyQuestions();
 
 1059        include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
 
 1061        $form->setFormAction($this->ctrl->getFormAction($this, 
""));
 
 1065        $heading->setRows(10);
 
 1066        $heading->setCols(80);
 
 1067        $heading->setUseRte(
true);
 
 1068        include_once 
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
 
 1071        $heading->setRTESupport($this->object->getId(), 
"svy", 
"survey");
 
 1072        $heading->setRequired(
true);
 
 1073        $form->addItem($heading);
 
 1075        $insertbefore = 
new ilSelectInputGUI($this->lng->txt(
"insert"), 
"insertbefore");
 
 1077        foreach ($survey_questions as 
$key => $value) {
 
 1078            $options[
$key] = $this->lng->txt(
"before") . 
": \"" . $value[
"title"] . 
"\"";
 
 1080        $insertbefore->setOptions(
$options);
 
 1081        $insertbefore->setRequired(
true);
 
 1082        $form->addItem($insertbefore);
 
 1084        $form->addCommandButton(
"saveHeading", $this->lng->txt(
"save"));
 
 1085        $form->addCommandButton(
"questions", $this->lng->txt(
"cancel"));
 
 1087        if ($a_question_id) {
 
 1088            $form->setTitle($this->lng->txt(
"edit_heading"));
 
 1090            $heading->setValue($this->object->prepareTextareaOutput($survey_questions[$a_question_id][
"heading"]));
 
 1091            $insertbefore->setValue($a_question_id);
 
 1092            $insertbefore->setDisabled(
true);
 
 1094            $form->setTitle($this->lng->txt(
"add_heading"));
 
 1102        $q_id = $_REQUEST[
"q_id"];
 
 1103        $this->ctrl->setParameter($this, 
"q_id", $q_id);
 
 1111        $this->tpl->setContent($a_form->getHTML());
 
 1116        $q_id = $_REQUEST[
"q_id"];
 
 1117        $this->ctrl->setParameter($this, 
"q_id", $q_id);
 
 1125        $this->tpl->setContent($a_form->getHTML());
 
 1131        $q_id = (int) $_REQUEST[
"q_id"];
 
 1132        $this->ctrl->setParameter($this, 
"q_id", $q_id);
 
 1135        if (
$form->checkInput()) {
 
 1136            include_once 
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
 
 1137            $this->
object->saveHeading(
 
 1139                    $form->getInput(
"heading"),
 
 1143                $form->getInput(
"insertbefore")
 
 1145            $this->ctrl->redirect($this, 
"questions");
 
 1148        $form->setValuesByPost();
 
 1154        $q_id = (int) $_REQUEST[
"q_id"];
 
 1155        $this->ctrl->setParameter($this, 
"q_id", $q_id);
 
 1158            $this->ctrl->redirect($this, 
"questions");
 
 1163        include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
 
 1165        $cgui->setHeaderText($this->lng->txt(
"confirm_remove_heading"));
 
 1167        $cgui->setFormAction($this->ctrl->getFormAction($this, 
"confirmedRemoveHeading"));
 
 1168        $cgui->setCancel($this->lng->txt(
"cancel"), 
"questions");
 
 1169        $cgui->setConfirm($this->lng->txt(
"confirm"), 
"confirmedRemoveHeading");
 
 1171        $this->tpl->setContent($cgui->getHTML());
 
 1176        $q_id = (int) $_REQUEST[
"q_id"];
 
 1178            $this->ctrl->redirect($this, 
"questions");
 
 1181        $this->
object->saveHeading(
"", $q_id);
 
 1182        $this->ctrl->redirect($this, 
"questions");
 
 1197        if (!$current_title = (
int) $_REQUEST[
'export_label']) {
 
 1198            $current_title = $this->
object->getShowQuestionTitles();
 
 1207        include_once 
"Services/Form/classes/class.ilSelectInputGUI.php";
 
 1208        $label = 
new ilSelectInputGUI($this->lng->txt(
"title") . 
"/" . $this->lng->txt(
"label"), 
"export_label");
 
 1210        #19448 comment none and label only options. 
 1211        $label->setOptions($this->print_options);
 
 1212        $label->setValue($current_title);
 
 1214        $ilToolbar->addStickyItem($label, 
true);
 
 1216        $ilToolbar->setFormAction($this->ctrl->getFormAction($this, 
"printView"));
 
 1218        include_once 
"Services/UIComponent/Button/classes/class.ilSubmitButton.php";
 
 1220        $button->setCaption(
"show");
 
 1221        $button->setCommand(
"printView");
 
 1222        $ilToolbar->addStickyItem($button);
 
 1224        $ilToolbar->addSeparator();
 
 1226        include_once 
"Services/UIComponent/Button/classes/class.ilLinkButton.php";
 
 1228        $button->setCaption(
"print");
 
 1229        $button->setOnClick(
"window.print(); return false;");
 
 1230        $button->setOmitPreventDoubleSubmission(
true);
 
 1231        $ilToolbar->addButtonInstance($button);
 
 1233        include_once 
'./Services/WebServices/RPC/classes/class.ilRPCServerSettings.php';
 
 1235            $this->ctrl->setParameter($this, 
"export_label", $current_title);
 
 1236            $this->ctrl->setParameter($this, 
"pdf", 
"1");
 
 1237            $pdf_url = $this->ctrl->getLinkTarget($this, 
"printView");
 
 1238            $this->ctrl->setParameter($this, 
"pdf", 
"");
 
 1239            $this->ctrl->setParameter($this, 
"export_label", 
"");
 
 1242            $button->setCaption(
"pdf_export");
 
 1243            $button->setUrl($pdf_url);
 
 1244            $button->setOmitPreventDoubleSubmission(
true);
 
 1245            $ilToolbar->addButtonInstance($button);
 
 1249        if (array_key_exists(
"pdf", 
$_GET) && (
$_GET[
"pdf"] == 1)) {
 
 1250            require_once(
'Services/MathJax/classes/class.ilMathJax.php');
 
 1254        $template = 
new ilTemplate(
"tpl.il_svy_svy_printview.html", 
true, 
true, 
"Modules/Survey");
 
 1256        $pages =&$this->
object->getSurveyPages();
 
 1258        foreach ($pages as $page) {
 
 1259            if (count($page) > 0) {
 
 1260                foreach ($page as $question) {
 
 1261                    $questionGUI = $this->
object->getQuestionGUI($question[
"type_tag"], $question[
"question_id"]);
 
 1262                    if (is_object($questionGUI)) {
 
 1263                        if (strlen($question[
"heading"])) {
 
 1264                            $template->setCurrentBlock(
"textblock");
 
 1265                            $template->setVariable(
"TEXTBLOCK", $question[
"heading"]);
 
 1269                        $template->setVariable(
"QUESTION_DATA", $questionGUI->getPrintView($current_title, $question[
"questionblock_show_questiontext"], $this->object->getSurveyId()));
 
 1272                        if ($question[
"obligatory"]) {
 
 1277                if (count($page) > 1 && $page[0][
"questionblock_show_blocktitle"]) {
 
 1279                    $template->setVariable(
"BLOCKTITLE", $page[0][
"questionblock_title"]);
 
 1290            $template->setVariable(
"TEXT_REQUIRED", $this->lng->txt(
"required_field"));
 
 1294        if (array_key_exists(
"pdf", 
$_GET) && (
$_GET[
"pdf"] == 1)) {
 
 1295            $printbody = 
new ilTemplate(
"tpl.il_as_tst_print_body.html", 
true, 
true, 
"Modules/Test");
 
 1296            $printbody->setVariable(
"TITLE", 
sprintf($this->lng->txt(
"tst_result_user_name"), $uname));
 
 1297            $printbody->setVariable(
"ADM_CONTENT", 
$template->get());
 
 1298            $printoutput = $printbody->get();
 
 1299            $printoutput = preg_replace(
"/href=\".*?\"/", 
"", $printoutput);
 
 1300            $fo = $this->
object->processPrintoutput2FO($printoutput);
 
 1303            require_once(
'Services/MathJax/classes/class.ilMathJax.php');
 
 1307                ->insertLatexImages($fo);
 
 1310            if (!$fo || !$this->object->deliverPDFfromFO($fo)) {
 
 1312                $this->ctrl->redirect($this, 
"printView");
 
 1315            $this->tpl->setVariable(
"ADM_CONTENT", 
$template->get());
 
sprintf('%.4f', $callTime)
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
An exception for terminatinating execution or to throw for unit testing.
static _getQuestionGUI($questiontype, $question_id=-1)
Creates a question gui representation.
static _getQuestionTypeName($type_tag)
Return the translation for a given question type tag.
static _changeOriginalId($a_question_id, $a_original_id, $a_object_id)
Change original id of existing question in db.
Confirmation screen class.
static getInstance()
Singleton: get instance.
const PURPOSE_DEFERRED_PDF
const RENDER_PNG_AS_FO_FILE
static _getUsedHTMLTagsAsString($a_module="")
Returns a string of all allowed HTML tags for text editing.
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)
static _getQuestionblock($questionblock_id)
Returns the database row for a given question block.
static _lookupObjId($a_id)
static getInstance()
Get singelton instance.
const ILIAS_IMG_MANAGER_PLUGIN
This class represents an option in a radio group.
Settings template application class.
filterQuestionblockBrowserObject()
editHeadingObject(ilPropertyFormGUI $a_form=null)
browseForQuestionblocksObject()
initHeadingForm($a_question_id=null)
resetfilterQuestionBrowserObject()
saveDefineQuestionblockObject()
removeQuestionsForm($checked_questionblocks, $checked_questions, $checked_headings)
insertQuestionsBeforeObject()
confirmRemoveQuestionsObject()
copyQuestionsToPoolObject()
insertQuestionblocksObject()
filterQuestionBrowserObject()
addHeadingObject(ilPropertyFormGUI $a_form=null)
executeCreateQuestionObject()
createQuestionblockObject(ilPropertyFormGUI $a_form=null)
executeCopyQuestionsToPoolObject()
__construct(ilObjSurveyGUI $a_parent_gui)
setBrowseForQuestionsSubtabs()
gatherSelectedTableItems($allow_blocks=true, $allow_questions=true, $allow_headings=false, $allow_questions_in_blocks=false)
Gather (and filter) selected items from table gui.
unfoldQuestionblockObject()
browseForQuestionsObject()
resetfilterQuestionblockBrowserObject()
createQuestionPool($name="dummy")
insertQuestions($insert_mode)
insertQuestionsAfterObject()
initQuestionblockForm($a_block_id=null, $a_question_ids=null)
editQuestionblockObject(ilPropertyFormGUI $a_form=null)
confirmedRemoveHeadingObject()
createQuestionObject(ilPropertyFormGUI $a_form=null)
printViewObject()
Creates a print view of the survey questions.
Survey question table GUI class.
special template class to simplify handling of ITX/PEAR
This class represents a text area property in a property form.
This class represents a text property in a property form.
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 stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
if(!array_key_exists('StateId', $_REQUEST)) $id
if(empty($password)) $table
if(isset($_POST['submit'])) $form