00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00040 include_once "./classes/class.ilObjectGUI.php";
00041 include_once "./Modules/Survey/classes/inc.SurveyConstants.php";
00042
00043 class ilObjSurveyGUI extends ilObjectGUI
00044 {
00049 function ilObjSurveyGUI()
00050 {
00051 global $lng, $ilCtrl;
00052
00053 $this->type = "svy";
00054 $lng->loadLanguageModule("survey");
00055 $this->ctrl =& $ilCtrl;
00056 $this->ctrl->saveParameter($this, "ref_id");
00057
00058 $this->ilObjectGUI("",$_GET["ref_id"], true, false);
00059 }
00060
00061 function backToRepositoryObject()
00062 {
00063 include_once "./Services/Utilities/classes/class.ilUtil.php";
00064 $path = $this->tree->getPathFull($this->object->getRefID());
00065 ilUtil::redirect($this->getReturnLocation("cancel","./repository.php?cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
00066 }
00067
00071 function &executeCommand()
00072 {
00073 global $ilAccess, $ilNavigationHistory;
00074
00075
00076 if (!$this->getCreationMode() &&
00077 $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
00078 {
00079 $ilNavigationHistory->addItem($_GET["ref_id"],
00080 "ilias.php?baseClass=ilObjSurveyGUI&cmd=infoScreen&ref_id=".$_GET["ref_id"], "svy");
00081 }
00082
00083 $cmd = $this->ctrl->getCmd("properties");
00084 $next_class = $this->ctrl->getNextClass($this);
00085 $this->ctrl->setReturn($this, "properties");
00086 $this->prepareOutput();
00087
00088
00089 switch($next_class)
00090 {
00091 case "ilinfoscreengui":
00092 $this->infoScreen();
00093 break;
00094 case 'ilmdeditorgui':
00095 include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
00096 $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
00097 $md_gui->addObserver($this->object,'MDUpdateListener','General');
00098
00099 $this->ctrl->forwardCommand($md_gui);
00100 break;
00101
00102 case "ilsurveyevaluationgui":
00103 include_once("./Modules/Survey/classes/class.ilSurveyEvaluationGUI.php");
00104 $eval_gui = new ilSurveyEvaluationGUI($this->object);
00105 $ret =& $this->ctrl->forwardCommand($eval_gui);
00106 break;
00107
00108 case "ilsurveyexecutiongui":
00109 include_once("./Modules/Survey/classes/class.ilSurveyExecutionGUI.php");
00110 $exec_gui = new ilSurveyExecutionGUI($this->object);
00111 $ret =& $this->ctrl->forwardCommand($exec_gui);
00112 break;
00113
00114 case 'ilpermissiongui':
00115 include_once("./classes/class.ilPermissionGUI.php");
00116 $perm_gui =& new ilPermissionGUI($this);
00117 $ret =& $this->ctrl->forwardCommand($perm_gui);
00118 break;
00119
00120 default:
00121 $cmd.= "Object";
00122 $ret =& $this->$cmd();
00123 break;
00124 }
00125 if (strtolower($_GET["baseClass"]) != "iladministrationgui" &&
00126 $this->getCreationMode() != true)
00127 {
00128 $this->tpl->show();
00129 }
00130 }
00131
00136 function saveObject()
00137 {
00138 global $rbacadmin;
00139
00140
00141 $newObj = parent::saveObject();
00142
00143 ilUtil::sendInfo($this->lng->txt("object_added"),true);
00144 ilUtil::redirect("ilias.php?baseClass=ilObjSurveyGUI&ref_id=".$newObj->getRefId()."&cmd=properties");
00145 }
00146
00152 function cancelObject($in_rep = false)
00153 {
00154 ilUtil::sendInfo($this->lng->txt("msg_cancel"),true);
00155 ilUtil::redirect("repository.php?cmd=frameset&ref_id=".$_GET["ref_id"]);
00156 }
00157
00165 function cancelPropertiesObject()
00166 {
00167 ilUtil::sendInfo($this->lng->txt("msg_cancel"), true);
00168 $this->ctrl->redirect($this, "properties");
00169 }
00170
00178 function savePropertiesObject()
00179 {
00180 include_once "./Services/Utilities/classes/class.ilUtil.php";
00181 $status = STATUS_OFFLINE;
00182 if ($_POST["status"] == 1)
00183 {
00184 $status = STATUS_ONLINE;
00185 }
00186 $result = $this->object->setStatus($status);
00187 if ($result)
00188 {
00189 ilUtil::sendInfo($result, true);
00190 }
00191 $this->object->setEvaluationAccess($_POST["evaluation_access"]);
00192 $this->object->setStartDate(sprintf("%04d-%02d-%02d", $_POST["start_date"]["y"], $_POST["start_date"]["m"], $_POST["start_date"]["d"]));
00193 $this->object->setStartDateEnabled($_POST["checked_start_date"]);
00194 $this->object->setEndDate(sprintf("%04d-%02d-%02d", $_POST["end_date"]["y"], $_POST["end_date"]["m"], $_POST["end_date"]["d"]));
00195 $this->object->setEndDateEnabled($_POST["checked_end_date"]);
00196
00197 include_once "./classes/class.ilObjAdvancedEditing.php";
00198 $introduction = ilUtil::stripSlashes($_POST["introduction"], true, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("survey"));
00199 $this->object->setIntroduction($introduction);
00200 $outro = ilUtil::stripSlashes($_POST["outro"], true, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("survey"));
00201 $this->object->setOutro($outro);
00202
00203 $hasDatasets = $this->object->_hasDatasets($this->object->getSurveyId());
00204 if (!$hasDatasets)
00205 {
00206 $anonymize = $_POST["anonymize"];
00207 if ($anonymize)
00208 {
00209 $codes = $_POST["codes"];
00210 $anonymize += $codes;
00211 }
00212 $this->object->setAnonymize($anonymize);
00213 }
00214 if ($_POST["showQuestionTitles"])
00215 {
00216 $this->object->showQuestionTitles();
00217 }
00218 else
00219 {
00220 $this->object->hideQuestionTitles();
00221 }
00222 $this->update = $this->object->update();
00223 $this->object->saveToDb();
00224 if (strcmp($_SESSION["info"], "") != 0)
00225 {
00226 ilUtil::sendInfo($_SESSION["info"] . "<br />" . $this->lng->txt("settings_saved"), true);
00227 }
00228 else
00229 {
00230 ilUtil::sendInfo($this->lng->txt("settings_saved"), true);
00231 }
00232 $this->ctrl->redirect($this, "properties");
00233 }
00234
00242 function handleWriteAccess()
00243 {
00244 global $ilAccess;
00245 if (!$ilAccess->checkAccess("write", "", $this->ref_id))
00246 {
00247
00248 ilUtil::sendInfo($this->lng->txt("cannot_edit_survey"), TRUE);
00249 $this->ctrl->redirect($this, "infoScreen");
00250 }
00251 }
00252
00260 function propertiesObject()
00261 {
00262 $this->handleWriteAccess();
00263
00264 if (strlen($this->ctrl->getCmdClass()) == 0) $this->ctrl->setCmdClass("ilobjsurveygui");
00265 include_once "./Services/Utilities/classes/class.ilUtil.php";
00266 $this->lng->loadLanguageModule("jscalendar");
00267 $this->tpl->addBlockFile("CALENDAR_LANG_JAVASCRIPT", "calendar_javascript", "tpl.calendar.html");
00268 $this->tpl->setCurrentBlock("calendar_javascript");
00269 $this->tpl->setVariable("FULL_SUNDAY", $this->lng->txt("l_su"));
00270 $this->tpl->setVariable("FULL_MONDAY", $this->lng->txt("l_mo"));
00271 $this->tpl->setVariable("FULL_TUESDAY", $this->lng->txt("l_tu"));
00272 $this->tpl->setVariable("FULL_WEDNESDAY", $this->lng->txt("l_we"));
00273 $this->tpl->setVariable("FULL_THURSDAY", $this->lng->txt("l_th"));
00274 $this->tpl->setVariable("FULL_FRIDAY", $this->lng->txt("l_fr"));
00275 $this->tpl->setVariable("FULL_SATURDAY", $this->lng->txt("l_sa"));
00276 $this->tpl->setVariable("SHORT_SUNDAY", $this->lng->txt("s_su"));
00277 $this->tpl->setVariable("SHORT_MONDAY", $this->lng->txt("s_mo"));
00278 $this->tpl->setVariable("SHORT_TUESDAY", $this->lng->txt("s_tu"));
00279 $this->tpl->setVariable("SHORT_WEDNESDAY", $this->lng->txt("s_we"));
00280 $this->tpl->setVariable("SHORT_THURSDAY", $this->lng->txt("s_th"));
00281 $this->tpl->setVariable("SHORT_FRIDAY", $this->lng->txt("s_fr"));
00282 $this->tpl->setVariable("SHORT_SATURDAY", $this->lng->txt("s_sa"));
00283 $this->tpl->setVariable("FULL_JANUARY", $this->lng->txt("l_01"));
00284 $this->tpl->setVariable("FULL_FEBRUARY", $this->lng->txt("l_02"));
00285 $this->tpl->setVariable("FULL_MARCH", $this->lng->txt("l_03"));
00286 $this->tpl->setVariable("FULL_APRIL", $this->lng->txt("l_04"));
00287 $this->tpl->setVariable("FULL_MAY", $this->lng->txt("l_05"));
00288 $this->tpl->setVariable("FULL_JUNE", $this->lng->txt("l_06"));
00289 $this->tpl->setVariable("FULL_JULY", $this->lng->txt("l_07"));
00290 $this->tpl->setVariable("FULL_AUGUST", $this->lng->txt("l_08"));
00291 $this->tpl->setVariable("FULL_SEPTEMBER", $this->lng->txt("l_09"));
00292 $this->tpl->setVariable("FULL_OCTOBER", $this->lng->txt("l_10"));
00293 $this->tpl->setVariable("FULL_NOVEMBER", $this->lng->txt("l_11"));
00294 $this->tpl->setVariable("FULL_DECEMBER", $this->lng->txt("l_12"));
00295 $this->tpl->setVariable("SHORT_JANUARY", $this->lng->txt("s_01"));
00296 $this->tpl->setVariable("SHORT_FEBRUARY", $this->lng->txt("s_02"));
00297 $this->tpl->setVariable("SHORT_MARCH", $this->lng->txt("s_03"));
00298 $this->tpl->setVariable("SHORT_APRIL", $this->lng->txt("s_04"));
00299 $this->tpl->setVariable("SHORT_MAY", $this->lng->txt("s_05"));
00300 $this->tpl->setVariable("SHORT_JUNE", $this->lng->txt("s_06"));
00301 $this->tpl->setVariable("SHORT_JULY", $this->lng->txt("s_07"));
00302 $this->tpl->setVariable("SHORT_AUGUST", $this->lng->txt("s_08"));
00303 $this->tpl->setVariable("SHORT_SEPTEMBER", $this->lng->txt("s_09"));
00304 $this->tpl->setVariable("SHORT_OCTOBER", $this->lng->txt("s_10"));
00305 $this->tpl->setVariable("SHORT_NOVEMBER", $this->lng->txt("s_11"));
00306 $this->tpl->setVariable("SHORT_DECEMBER", $this->lng->txt("s_12"));
00307 $this->tpl->setVariable("ABOUT_CALENDAR", $this->lng->txt("about_calendar"));
00308 $this->tpl->setVariable("ABOUT_CALENDAR_LONG", $this->lng->txt("about_calendar_long"));
00309 $this->tpl->setVariable("ABOUT_TIME_LONG", $this->lng->txt("about_time"));
00310 $this->tpl->setVariable("PREV_YEAR", $this->lng->txt("prev_year"));
00311 $this->tpl->setVariable("PREV_MONTH", $this->lng->txt("prev_month"));
00312 $this->tpl->setVariable("GO_TODAY", $this->lng->txt("go_today"));
00313 $this->tpl->setVariable("NEXT_MONTH", $this->lng->txt("next_month"));
00314 $this->tpl->setVariable("NEXT_YEAR", $this->lng->txt("next_year"));
00315 $this->tpl->setVariable("SEL_DATE", $this->lng->txt("select_date"));
00316 $this->tpl->setVariable("DRAG_TO_MOVE", $this->lng->txt("drag_to_move"));
00317 $this->tpl->setVariable("PART_TODAY", $this->lng->txt("part_today"));
00318 $this->tpl->setVariable("DAY_FIRST", $this->lng->txt("day_first"));
00319 $this->tpl->setVariable("CLOSE", $this->lng->txt("close"));
00320 $this->tpl->setVariable("TODAY", $this->lng->txt("today"));
00321 $this->tpl->setVariable("TIME_PART", $this->lng->txt("time_part"));
00322 $this->tpl->setVariable("DEF_DATE_FORMAT", $this->lng->txt("def_date_format"));
00323 $this->tpl->setVariable("TT_DATE_FORMAT", $this->lng->txt("tt_date_format"));
00324 $this->tpl->setVariable("WK", $this->lng->txt("wk"));
00325 $this->tpl->setVariable("TIME", $this->lng->txt("time"));
00326 $this->tpl->parseCurrentBlock();
00327 $this->tpl->setCurrentBlock("CalendarJS");
00328 $this->tpl->setVariable("LOCATION_JAVASCRIPT_CALENDAR", "./Modules/Survey/js/calendar/calendar.js");
00329 $this->tpl->setVariable("LOCATION_JAVASCRIPT_CALENDAR_SETUP", "./Modules/Survey/js/calendar/calendar-setup.js");
00330 $this->tpl->setVariable("LOCATION_JAVASCRIPT_CALENDAR_STYLESHEET", "./Modules/Survey/js/calendar/calendar.css");
00331 $this->tpl->parseCurrentBlock();
00332
00333 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_properties.html", "Modules/Survey");
00334 $this->tpl->setCurrentBlock("adm_content");
00335 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "properties"));
00336 $this->tpl->setVariable("TEXT_INTRODUCTION", $this->lng->txt("introduction"));
00337 $this->tpl->setVariable("VALUE_INTRODUCTION", ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($this->object->getIntroduction())));
00338 $this->tpl->setVariable("TEXT_OUTRO", $this->lng->txt("outro"));
00339 $this->tpl->setVariable("VALUE_OUTRO", ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($this->object->getOutro())));
00340 $this->tpl->setVariable("TEXT_STATUS", $this->lng->txt("online"));
00341 $this->tpl->setVariable("TEXT_START_DATE", $this->lng->txt("start_date"));
00342 $this->tpl->setVariable("VALUE_START_DATE", ilUtil::makeDateSelect("start_date", $this->object->getStartYear(), $this->object->getStartMonth(), $this->object->getStartDay()));
00343 $this->tpl->setVariable("IMG_START_DATE_CALENDAR", ilUtil::getImagePath("calendar.png"));
00344 $this->tpl->setVariable("TXT_START_DATE_CALENDAR", $this->lng->txt("open_calendar"));
00345 $this->tpl->setVariable("TEXT_END_DATE", $this->lng->txt("end_date"));
00346 $this->tpl->setVariable("VALUE_END_DATE", ilUtil::makeDateSelect("end_date", $this->object->getEndYear(), $this->object->getEndMonth(), $this->object->getEndDay()));
00347 $this->tpl->setVariable("IMG_END_DATE_CALENDAR", ilUtil::getImagePath("calendar.png"));
00348 $this->tpl->setVariable("TXT_END_DATE_CALENDAR", $this->lng->txt("open_calendar"));
00349 $this->tpl->setVariable("TEXT_EVALUATION_ACCESS", $this->lng->txt("evaluation_access"));
00350 $this->tpl->setVariable("DESCRIPTION_EVALUATION_ACCESS", $this->lng->txt("evaluation_access_description"));
00351 $this->tpl->setVariable("TEXT_ENABLED", $this->lng->txt("enabled"));
00352 $this->tpl->setVariable("VALUE_OFF", $this->lng->txt("evaluation_access_off"));
00353 $this->tpl->setVariable("VALUE_ALL", $this->lng->txt("evaluation_access_all"));
00354 $this->tpl->setVariable("VALUE_PARTICIPANTS", $this->lng->txt("evaluation_access_participants"));
00355
00356 $this->tpl->setVariable("TEXT_ANONYMIZATION", $this->lng->txt("anonymization"));
00357
00358 $hasDatasets = $this->object->_hasDatasets($this->object->getSurveyId());
00359 if ($hasDatasets)
00360 {
00361 $this->tpl->setVariable("DISABLED_ANONYMIZATION", " disabled=\"disabled\"");
00362 }
00363
00364 $this->tpl->setVariable("DESCRIPTION_ANONYMIZATION", $this->lng->txt("anonymize_survey_description"));
00365 $this->tpl->setVariable("ANON_VALUE_OFF", $this->lng->txt("off"));
00366 $this->tpl->setVariable("ANON_VALUE_ON", $this->lng->txt("on_additional"));
00367 $this->tpl->setVariable("VALUE_NOCODES", $this->lng->txt("anonymize_without_code"));
00368 $this->tpl->setVariable("VALUE_CODES", $this->lng->txt("anonymize_with_code"));
00369 switch ($this->object->getAnonymize())
00370 {
00371 case ANONYMIZE_OFF:
00372 $this->tpl->setVariable("ANON_CHECKED_OFF", " checked=\"checked\"");
00373 $this->tpl->setVariable("CHECKED_CODES", " checked=\"checked\"");
00374 break;
00375 case ANONYMIZE_ON:
00376 $this->tpl->setVariable("ANON_CHECKED_ON", " checked=\"checked\"");
00377 $this->tpl->setVariable("CHECKED_CODES", " checked=\"checked\"");
00378 break;
00379 case ANONYMIZE_FREEACCESS:
00380 $this->tpl->setVariable("ANON_CHECKED_ON", " checked=\"checked\"");
00381 $this->tpl->setVariable("CHECKED_NOCODES", " checked=\"checked\"");
00382 break;
00383 }
00384
00385 if ($this->object->getEndDateEnabled())
00386 {
00387 $this->tpl->setVariable("CHECKED_END_DATE", " checked=\"checked\"");
00388 }
00389 if ($this->object->getStartDateEnabled())
00390 {
00391 $this->tpl->setVariable("CHECKED_START_DATE", " checked=\"checked\"");
00392 }
00393 switch ($this->object->getEvaluationAccess())
00394 {
00395 case EVALUATION_ACCESS_OFF:
00396 $this->tpl->setVariable("CHECKED_OFF", " checked=\"checked\"");
00397 break;
00398 case EVALUATION_ACCESS_ALL:
00399 $this->tpl->setVariable("CHECKED_ALL", " checked=\"checked\"");
00400 break;
00401 case EVALUATION_ACCESS_PARTICIPANTS:
00402 $this->tpl->setVariable("CHECKED_PARTICIPANTS", " checked=\"checked\"");
00403 break;
00404 }
00405 if ($this->object->getStatus() == STATUS_ONLINE)
00406 {
00407 $this->tpl->setVariable("CHECKED_STATUS", " checked=\"checked\"");
00408 }
00409 $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
00410 $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
00411 $this->tpl->setVariable("TEXT_SHOW_QUESTIONTITLES", $this->lng->txt("svy_show_questiontitles"));
00412 if ($this->object->getShowQuestionTitles())
00413 {
00414 $this->tpl->setVariable("QUESTIONTITLES_CHECKED", " checked=\"checked\"");
00415 }
00416 $this->tpl->parseCurrentBlock();
00417
00418 include_once "./Services/RTE/classes/class.ilRTE.php";
00419 $rtestring = ilRTE::_getRTEClassname();
00420 include_once "./Services/RTE/classes/class.$rtestring.php";
00421 $rte = new $rtestring();
00422 include_once "./classes/class.ilObject.php";
00423 $obj_id = ilObject::_lookupObjectId($_GET["ref_id"]);
00424 $obj_type = ilObject::_lookupType($_GET["ref_id"], TRUE);
00425 $rte->addRTESupport($obj_id, $obj_type, "survey");
00426 }
00427
00435 function filterQuestionsObject()
00436 {
00437 $this->browseForQuestionsObject($_POST["sel_questionpool"]);
00438 }
00439
00447 function resetFilterQuestionsObject()
00448 {
00449 $this->browseForQuestionsObject("", true);
00450 }
00451
00459 function changeDatatypeObject()
00460 {
00461 $this->ctrl->setParameter($this, "browsetype", $_POST["datatype"]);
00462 $this->ctrl->redirect($this, "browseForQuestions");
00463 }
00464
00472 function insertQuestionsObject()
00473 {
00474
00475 $inserted_objects = 0;
00476 foreach ($_POST as $key => $value)
00477 {
00478 if (preg_match("/cb_(\d+)/", $key, $matches))
00479 {
00480 if ($_GET["browsetype"] == 1)
00481 {
00482 $this->object->insertQuestion($matches[1]);
00483 }
00484 else
00485 {
00486 $this->object->insertQuestionBlock($matches[1]);
00487 }
00488 $inserted_objects++;
00489 }
00490 }
00491 if ($inserted_objects)
00492 {
00493 $this->object->saveCompletionStatus();
00494 ilUtil::sendInfo($this->lng->txt("questions_inserted"), true);
00495 $this->ctrl->redirect($this, "questions");
00496 }
00497 else
00498 {
00499 if ($_GET["browsetype"] == 1)
00500 {
00501 ilUtil::sendInfo($this->lng->txt("insert_missing_question"));
00502 }
00503 else
00504 {
00505 ilUtil::sendInfo($this->lng->txt("insert_missing_questionblock"));
00506 }
00507 $this->browseForQuestionsObject("", false, $_GET["browsetype"]);
00508 }
00509 }
00510
00518 function removeQuestionsObject()
00519 {
00520 $checked_questions = array();
00521 $checked_questionblocks = array();
00522 foreach ($_POST as $key => $value)
00523 {
00524 if (preg_match("/cb_(\d+)/", $key, $matches))
00525 {
00526 array_push($checked_questions, $matches[1]);
00527 }
00528 if (preg_match("/cb_qb_(\d+)/", $key, $matches))
00529 {
00530 array_push($checked_questionblocks, $matches[1]);
00531 }
00532 }
00533 if (count($checked_questions) + count($checked_questionblocks) > 0)
00534 {
00535 ilUtil::sendInfo($this->lng->txt("remove_questions"));
00536 $this->removeQuestionsForm($checked_questions, $checked_questionblocks);
00537 return;
00538 }
00539 else
00540 {
00541 ilUtil::sendInfo($this->lng->txt("no_question_selected_for_removal"), true);
00542 $this->ctrl->redirect($this, "questions");
00543 }
00544 }
00545
00553 function browseForQuestionsObject($filter_questionpool = "", $reset_filter = false, $browsequestions = 1)
00554 {
00555 global $rbacsystem;
00556
00557 $this->setBrowseForQuestionsSubtabs();
00558 if (strcmp($this->ctrl->getCmd(), "filterQuestions") != 0)
00559 {
00560 if (array_key_exists("sel_questionpool", $_GET)) $filter_questionpool = $_GET["sel_questionpool"];
00561 }
00562 $browsequestions = (array_key_exists("browsetype", $_GET)) ? $_GET["browsetype"] : 1;
00563 $this->ctrl->setParameter($this, "browsetype", $browsequestions);
00564 if ($_POST["cmd"]["back"])
00565 {
00566 $show_questionbrowser = false;
00567 }
00568
00569 $add_parameter = "&insert_question=1";
00570
00571 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_questionbrowser.html", "Modules/Survey");
00572 $this->tpl->addBlockFile("A_BUTTONS", "a_buttons", "tpl.il_svy_svy_action_buttons.html", "Modules/Survey");
00573 $this->tpl->addBlockFile("FILTER_QUESTION_MANAGER", "filter_questions", "tpl.il_svy_svy_filter_questions.html", "Modules/Survey");
00574
00575 $questionpools =& $this->object->getQuestionpoolTitles();
00576 if (count($questionpools) == 0)
00577 {
00578 ilUtil::sendInfo($this->lng->txt("no_questions_available"));
00579 return;
00580 }
00581 $filter_type = $_GET["sel_filter_type"];
00582 if (!$filter_type)
00583 {
00584 $filter_type = $_POST["sel_filter_type"];
00585 }
00586 if ($reset_filter)
00587 {
00588 $filter_type = "";
00589 }
00590 $add_parameter .= "&sel_filter_type=$filter_type";
00591
00592 $filter_text = $_GET["filter_text"];
00593 if (!$filter_text)
00594 {
00595 $filter_text = $_POST["filter_text"];
00596 }
00597 if ($reset_filter)
00598 {
00599 $filter_text = "";
00600 }
00601 $add_parameter .= "&filter_text=$filter_text";
00602
00603 $filter_fields = array(
00604 "title" => $this->lng->txt("title"),
00605 "comment" => $this->lng->txt("description"),
00606 "author" => $this->lng->txt("author"),
00607 );
00608 $this->tpl->setCurrentBlock("filterrow");
00609 foreach ($filter_fields as $key => $value)
00610 {
00611 $this->tpl->setVariable("VALUE_FILTER_TYPE", "$key");
00612 $this->tpl->setVariable("NAME_FILTER_TYPE", "$value");
00613 if (!$reset_filter)
00614 {
00615 if (strcmp($filter_type, $key) == 0)
00616 {
00617 $this->tpl->setVariable("VALUE_FILTER_SELECTED", " selected=\"selected\"");
00618 }
00619 }
00620 $this->tpl->parseCurrentBlock();
00621 }
00622
00623 $filter_question_type = $_POST["sel_question_type"];
00624 if (!$filter_question_type)
00625 {
00626 $filter_question_type = $_GET["sel_question_type"];
00627 }
00628 if ($reset_filter)
00629 {
00630 $filter_question_type = "";
00631 }
00632 $add_parameter .= "&sel_question_type=$filter_question_type";
00633
00634 if ($browsequestions)
00635 {
00636 $questiontypes =& $this->object->_getQuestiontypes();
00637 foreach ($questiontypes as $key => $value)
00638 {
00639 $this->tpl->setCurrentBlock("questiontype_row");
00640 $this->tpl->setVariable("VALUE_QUESTION_TYPE", $value);
00641 $this->tpl->setVariable("TEXT_QUESTION_TYPE", $this->lng->txt($value));
00642 if (strcmp($filter_question_type, $value) == 0)
00643 {
00644 $this->tpl->setVariable("SELECTED_QUESTION_TYPE", " selected=\"selected\"");
00645 }
00646 $this->tpl->parseCurrentBlock();
00647 }
00648 }
00649
00650 if ($reset_filter)
00651 {
00652 $filter_questionpool = "";
00653 }
00654 $add_parameter .= "&sel_questionpool=$filter_questionpool";
00655
00656 if ($browsequestions)
00657 {
00658 foreach ($questionpools as $key => $value)
00659 {
00660 $this->tpl->setCurrentBlock("questionpool_row");
00661 $this->tpl->setVariable("VALUE_QUESTIONPOOL", $key);
00662 $this->tpl->setVariable("TEXT_QUESTIONPOOL", $value);
00663 if (strcmp($filter_questionpool, $key) == 0)
00664 {
00665 $this->tpl->setVariable("SELECTED_QUESTIONPOOL", " selected=\"selected\"");
00666 }
00667 $this->tpl->parseCurrentBlock();
00668 }
00669 }
00670
00671 if ($browsequestions)
00672 {
00673 $this->tpl->setCurrentBlock("question_filters");
00674 $this->tpl->setVariable("SHOW_QUESTION_TYPES", $this->lng->txt("filter_show_question_types"));
00675 $this->tpl->setVariable("TEXT_ALL_QUESTION_TYPES", $this->lng->txt("filter_all_question_types"));
00676 $this->tpl->setVariable("SHOW_QUESTIONPOOLS", $this->lng->txt("filter_show_questionpools"));
00677 $this->tpl->setVariable("TEXT_ALL_QUESTIONPOOLS", $this->lng->txt("filter_all_questionpools"));
00678 $this->tpl->parseCurrentBlock();
00679 }
00680
00681 $this->tpl->setCurrentBlock("filter_questions");
00682 $this->tpl->setVariable("FILTER_TEXT", $this->lng->txt("filter"));
00683 $this->tpl->setVariable("TEXT_FILTER_BY", $this->lng->txt("by"));
00684 if (!$_POST["cmd"]["reset"])
00685 {
00686 $this->tpl->setVariable("VALUE_FILTER_TEXT", $filter_text);
00687 }
00688 $this->tpl->setVariable("VALUE_SUBMIT_FILTER", $this->lng->txt("set_filter"));
00689 $this->tpl->setVariable("VALUE_RESET_FILTER", $this->lng->txt("reset_filter"));
00690 $this->tpl->setVariable("OPTION_QUESTIONS", $this->lng->txt("questions"));
00691 $this->tpl->setVariable("OPTION_QUESTIONBLOCKS", $this->lng->txt("questionblocks"));
00692 if ($browsequestions)
00693 {
00694 $this->tpl->setVariable("SELECTED_QUESTIONS", " selected=\"selected\"");
00695 }
00696 else
00697 {
00698 $this->tpl->setVariable("SELECTED_QUESTIONBLOCKS", " selected=\"selected\"");
00699 }
00700 $this->tpl->setVariable("TEXT_DATATYPE", $this->lng->txt("display_all_available"));
00701 $this->tpl->setVariable("BTN_CHANGE", $this->lng->txt("change"));
00702 $this->tpl->parseCurrentBlock();
00703
00704 if ($_POST["cmd"]["reset"])
00705 {
00706 $_POST["filter_text"] = "";
00707 }
00708 $startrow = 0;
00709 if ($_GET["prevrow"])
00710 {
00711 $startrow = $_GET["prevrow"];
00712 }
00713 if ($_GET["nextrow"])
00714 {
00715 $startrow = $_GET["nextrow"];
00716 }
00717 if ($_GET["startrow"])
00718 {
00719 $startrow = $_GET["startrow"];
00720 }
00721 $sort = ($_GET["sort"]) ? $_GET["sort"] : "title";
00722 $sortorder = ($_GET["sortorder"]) ? $_GET["sortorder"] : "ASC";
00723 $this->ctrl->setParameter($this, "sort", $sort);
00724 $this->ctrl->setParameter($this, "sortorder", $sortorder);
00725 if ($browsequestions)
00726 {
00727 $table = $this->object->getQuestionsTable($sort, $sortorder, $filter_text, $filter_type, $startrow, 1, $filter_question_type, $filter_questionpool);
00728 }
00729 else
00730 {
00731 $table = $this->object->getQuestionblocksTable($sort, $sortorder, $filter_text, $filter_type, $startrow);
00732 }
00733 $colors = array("tblrow1", "tblrow2");
00734 $counter = 0;
00735 $questionblock_id = 0;
00736 if ($browsequestions)
00737 {
00738 include_once "./classes/class.ilFormat.php";
00739 foreach ($table["rows"] as $data)
00740 {
00741 if ($rbacsystem->checkAccess("write", $data["ref_id"]))
00742 {
00743 if ($data["complete"])
00744 {
00745
00746 $this->tpl->setCurrentBlock("checkable");
00747 $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
00748 $this->tpl->setVariable("COUNTER", $data["question_id"]);
00749 $this->tpl->parseCurrentBlock();
00750 }
00751 $this->tpl->setCurrentBlock("QTab");
00752 $this->tpl->setVariable("QUESTION_TITLE", "<strong>" . $data["title"] . "</strong>");
00753 $this->tpl->setVariable("TEXT_PREVIEW", $this->lng->txt("preview"));
00754 $this->tpl->setVariable("URL_PREVIEW", "ilias.php?baseClass=ilObjSurveyQuestionPoolGUI&ref_id=" . $data["ref_id"] . "&cmd=preview&preview=" . $data["question_id"]);
00755 $this->tpl->setVariable("COUNTER", $data["question_id"]);
00756 $this->tpl->setVariable("QUESTION_COMMENT", $data["description"]);
00757 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($data["type_tag"]));
00758 $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]);
00759 $this->tpl->setVariable("QUESTION_CREATED", ilFormat::formatDate(ilFormat::ftimestamp2dateDB($data["created"]), "date"));
00760 $this->tpl->setVariable("QUESTION_UPDATED", ilFormat::formatDate(ilFormat::ftimestamp2dateDB($data["TIMESTAMP14"]), "date"));
00761 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
00762 $this->tpl->setVariable("QUESTION_POOL", $questionpools[$data["obj_fi"]]);
00763 $this->tpl->parseCurrentBlock();
00764 $counter++;
00765 }
00766 }
00767 if ($table["rowcount"] > count($table["rows"]))
00768 {
00769 $nextstep = $table["nextrow"] + $table["step"];
00770 if ($nextstep > $table["rowcount"])
00771 {
00772 $nextstep = $table["rowcount"];
00773 }
00774 $counter = 1;
00775 for ($i = 0; $i < $table["rowcount"]; $i += $table["step"])
00776 {
00777 $this->tpl->setCurrentBlock("pages_questions");
00778 if ($table["startrow"] == $i)
00779 {
00780 $this->tpl->setVariable("PAGE_NUMBER", "<span class=\"inactivepage\">$counter</span>");
00781 }
00782 else
00783 {
00784 $this->tpl->setVariable("PAGE_NUMBER", "<a href=\"" . $this->ctrl->getLinkTarget($this, "browseForQuestions") . $add_parameter . "&nextrow=$i" . "\">$counter</a>");
00785 }
00786 $this->tpl->parseCurrentBlock();
00787 $counter++;
00788 }
00789 $this->tpl->setCurrentBlock("questions_navigation_bottom");
00790 $this->tpl->setVariable("TEXT_ITEM", $this->lng->txt("item"));
00791 $this->tpl->setVariable("TEXT_ITEM_START", $table["startrow"] + 1);
00792 $end = $table["startrow"] + $table["step"];
00793 if ($end > $table["rowcount"])
00794 {
00795 $end = $table["rowcount"];
00796 }
00797 $this->tpl->setVariable("TEXT_ITEM_END", $end);
00798 $this->tpl->setVariable("TEXT_OF", strtolower($this->lng->txt("of")));
00799 $this->tpl->setVariable("TEXT_ITEM_COUNT", $table["rowcount"]);
00800 $this->tpl->setVariable("TEXT_PREVIOUS", $this->lng->txt("previous"));
00801 $this->tpl->setVariable("TEXT_NEXT", $this->lng->txt("next"));
00802 $this->tpl->setVariable("HREF_PREV_ROWS", $this->ctrl->getLinkTarget($this, "browseForQuestions") . $add_parameter . "&prevrow=" . $table["prevrow"]);
00803 $this->tpl->setVariable("HREF_NEXT_ROWS", $this->ctrl->getLinkTarget($this, "browseForQuestions") . $add_parameter . "&nextrow=" . $table["nextrow"]);
00804 $this->tpl->parseCurrentBlock();
00805 }
00806 }
00807 else
00808 {
00809 foreach ($table["rows"] as $data)
00810 {
00811 $this->tpl->setCurrentBlock("questionblock_row");
00812 $this->tpl->setVariable("QUESTIONBLOCK_ID", $data["questionblock_id"]);
00813 $this->tpl->setVariable("QUESTIONBLOCK_TITLE", "<strong>" . $data["title"] . "</strong>");
00814 $this->tpl->setVariable("SURVEY_TITLE", $data["surveytitle"]);
00815 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
00816 $this->tpl->setVariable("QUESTIONS_TITLE", $data["questions"]);
00817 $this->tpl->parseCurrentBlock();
00818 $counter++;
00819 }
00820 if ($table["rowcount"] > count($table["rows"]))
00821 {
00822 $nextstep = $table["nextrow"] + $table["step"];
00823 if ($nextstep > $table["rowcount"])
00824 {
00825 $nextstep = $table["rowcount"];
00826 }
00827 $counter = 1;
00828 for ($i = 0; $i < $table["rowcount"]; $i += $table["step"])
00829 {
00830 $this->tpl->setCurrentBlock("pages_questionblocks");
00831 if ($table["startrow"] == $i)
00832 {
00833 $this->tpl->setVariable("PAGE_NUMBER", "<strong>$counter</strong>");
00834 }
00835 else
00836 {
00837 $this->tpl->setVariable("PAGE_NUMBER", "<a href=\"" . $this->ctrl->getLinkTarget($this, "browseForQuestions") . $add_parameter . "&nextrow=$i" . "\">$counter</a>");
00838 }
00839 $this->tpl->parseCurrentBlock();
00840 $counter++;
00841 }
00842 $this->tpl->setCurrentBlock("questionblocks_navigation_bottom");
00843 $this->tpl->setVariable("TEXT_ITEM", $this->lng->txt("item"));
00844 $this->tpl->setVariable("TEXT_ITEM_START", $table["startrow"] + 1);
00845 $end = $table["startrow"] + $table["step"];
00846 if ($end > $table["rowcount"])
00847 {
00848 $end = $table["rowcount"];
00849 }
00850 $this->tpl->setVariable("TEXT_ITEM_END", $end);
00851 $this->tpl->setVariable("TEXT_OF", strtolower($this->lng->txt("of")));
00852 $this->tpl->setVariable("TEXT_ITEM_COUNT", $table["rowcount"]);
00853 $this->tpl->setVariable("TEXT_PREVIOUS", $this->lng->txt("previous"));
00854 $this->tpl->setVariable("TEXT_NEXT", $this->lng->txt("next"));
00855 $this->tpl->setVariable("HREF_PREV_ROWS", $this->ctrl->getLinkTarget($this, "browseForQuestions") . $add_parameter . "&prevrow=" . $table["prevrow"]);
00856 $this->tpl->setVariable("HREF_NEXT_ROWS", $this->ctrl->getLinkTarget($this, "browseForQuestions") . $add_parameter . "&nextrow=" . $table["nextrow"]);
00857 $this->tpl->parseCurrentBlock();
00858 }
00859 }
00860
00861
00862 if ($counter == 0)
00863 {
00864 $this->tpl->setCurrentBlock("Emptytable");
00865 if ($browsequestions)
00866 {
00867 $this->tpl->setVariable("TEXT_EMPTYTABLE", $this->lng->txt("no_questions_available"));
00868 }
00869 else
00870 {
00871 $this->tpl->setVariable("TEXT_EMPTYTABLE", $this->lng->txt("no_questionblocks_available"));
00872 }
00873 $this->tpl->parseCurrentBlock();
00874 }
00875 else
00876 {
00877 $this->tpl->setCurrentBlock("selectall");
00878 $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
00879 $counter++;
00880 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
00881 $this->tpl->parseCurrentBlock();
00882
00883 $this->tpl->setCurrentBlock("selection");
00884 $this->tpl->setVariable("INSERT", $this->lng->txt("insert"));
00885 $this->tpl->parseCurrentBlock();
00886
00887 $this->tpl->setCurrentBlock("Footer");
00888 include_once "./Services/Utilities/classes/class.ilUtil.php";
00889 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\">");
00890 $this->tpl->parseCurrentBlock();
00891 }
00892
00893 $sortarray = array(
00894 "title" => (strcmp($sort, "title") == 0) ? $sortorder : "",
00895 "description" => (strcmp($sort, "description") == 0) ? $sortorder : "",
00896 "type" => (strcmp($sort, "type") == 0) ? $sortorder : "",
00897 "author" => (strcmp($sort, "author") == 0) ? $sortorder : "",
00898 "created" => (strcmp($sort, "created") == 0) ? $sortorder : "",
00899 "updated" => (strcmp($sort, "updated") == 0) ? $sortorder : "",
00900 "qpl" => (strcmp($sort, "qpl") == 0) ? $sortorder : "",
00901 "svy" => (strcmp($sort, "svy") == 0) ? $sortorder : ""
00902 );
00903 foreach ($sortarray as $key => $value)
00904 {
00905 if (strcmp($value, "ASC") == 0)
00906 {
00907 $sortarray[$key] = "DESC";
00908 }
00909 else
00910 {
00911 $sortarray[$key] = "ASC";
00912 }
00913 }
00914
00915 if ($browsequestions)
00916 {
00917 $this->tpl->setCurrentBlock("questions_header");
00918 $this->ctrl->setParameter($this, "sort", "title");
00919 $this->ctrl->setParameter($this, "sortorder", $sortarray["title"]);
00920 $this->tpl->setVariable("QUESTION_TITLE", "<a href=\"" . $this->ctrl->getLinkTargetByClass(get_class($this), "browseForQuestions") . "$add_parameter&startrow=" . $table["startrow"] . "\">" . $this->lng->txt("title") . "</a>" . $table["images"]["title"]);
00921 $this->ctrl->setParameter($this, "sort", "description");
00922 $this->ctrl->setParameter($this, "sortorder", $sortarray["description"]);
00923 $this->tpl->setVariable("QUESTION_COMMENT", "<a href=\"" . $this->ctrl->getLinkTargetByClass(get_class($this), "browseForQuestions") . "$add_parameter&startrow=" . $table["startrow"] . "\">" . $this->lng->txt("description") . "</a>". $table["images"]["description"]);
00924 $this->ctrl->setParameter($this, "sort", "type");
00925 $this->ctrl->setParameter($this, "sortorder", $sortarray["type"]);
00926 $this->tpl->setVariable("QUESTION_TYPE", "<a href=\"" . $this->ctrl->getLinkTargetByClass(get_class($this), "browseForQuestions") . "$add_parameter&startrow=" . $table["startrow"] . "\">" . $this->lng->txt("question_type") . "</a>" . $table["images"]["type"]);
00927 $this->ctrl->setParameter($this, "sort", "author");
00928 $this->ctrl->setParameter($this, "sortorder", $sortarray["author"]);
00929 $this->tpl->setVariable("QUESTION_AUTHOR", "<a href=\"" . $this->ctrl->getLinkTargetByClass(get_class($this), "browseForQuestions") . "$add_parameter&startrow=" . $table["startrow"] . "\">" . $this->lng->txt("author") . "</a>" . $table["images"]["author"]);
00930 $this->ctrl->setParameter($this, "sort", "created");
00931 $this->ctrl->setParameter($this, "sortorder", $sortarray["created"]);
00932 $this->tpl->setVariable("QUESTION_CREATED", "<a href=\"" . $this->ctrl->getLinkTargetByClass(get_class($this), "browseForQuestions") . "$add_parameter&startrow=" . $table["startrow"] . "\">" . $this->lng->txt("create_date") . "</a>" . $table["images"]["created"]);
00933 $this->ctrl->setParameter($this, "sort", "updated");
00934 $this->ctrl->setParameter($this, "sortorder", $sortarray["updated"]);
00935 $this->tpl->setVariable("QUESTION_UPDATED", "<a href=\"" . $this->ctrl->getLinkTargetByClass(get_class($this), "browseForQuestions") . "$add_parameter&startrow=" . $table["startrow"] . "\">" . $this->lng->txt("last_update") . "</a>" . $table["images"]["updated"]);
00936 $this->ctrl->setParameter($this, "sort", "qpl");
00937 $this->ctrl->setParameter($this, "sortorder", $sortarray["qpl"]);
00938 $this->tpl->setVariable("QUESTION_POOL", "<a href=\"" . $this->ctrl->getLinkTargetByClass(get_class($this), "browseForQuestions") . "$add_parameter&startrow=" . $table["startrow"] . "\">" . $this->lng->txt("obj_spl") . "</a>" . $table["images"]["qpl"]);
00939 $this->tpl->parseCurrentBlock();
00940 }
00941 else
00942 {
00943 $this->tpl->setCurrentBlock("questionblocks_header");
00944 $this->ctrl->setParameter($this, "sort", "title");
00945 $this->ctrl->setParameter($this, "sortorder", $sortarray["title"]);
00946 $this->tpl->setVariable("QUESTIONBLOCK_TITLE", "<a href=\"" . $this->ctrl->getLinkTargetByClass(get_class($this), "browseForQuestions") . "$add_parameter&startrow=" . $table["startrow"] . "\">" . $this->lng->txt("title") . "</a>" . $table["images"]["title"]);
00947 $this->ctrl->setParameter($this, "sort", "svy");
00948 $this->ctrl->setParameter($this, "sortorder", $sortarray["svy"]);
00949 $this->tpl->setVariable("SURVEY_TITLE", "<a href=\"" . $this->ctrl->getLinkTargetByClass(get_class($this), "browseForQuestions") . "$add_parameter&startrow=" . $table["startrow"] . "\">" . $this->lng->txt("obj_svy") . "</a>" . $table["images"]["svy"]);
00950 $this->tpl->setVariable("QUESTIONS_TITLE", $this->lng->txt("contains"));
00951 $this->tpl->parseCurrentBlock();
00952 }
00953 $this->tpl->setCurrentBlock("adm_content");
00954
00955 $this->ctrl->setParameter($this, "sort", $sort);
00956 $this->ctrl->setParameter($this, "sortorder", $sortorder);
00957 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "browseForQuestions") . $add_parameter);
00958 $this->tpl->parseCurrentBlock();
00959 }
00960
00970 function removeQuestionsForm($checked_questions, $checked_questionblocks)
00971 {
00972 ilUtil::sendInfo();
00973 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_remove_questions.html", "Modules/Survey");
00974 $colors = array("tblrow1", "tblrow2");
00975 $counter = 0;
00976 $surveyquestions =& $this->object->getSurveyQuestions();
00977 foreach ($surveyquestions as $question_id => $data)
00978 {
00979 if (in_array($data["question_id"], $checked_questions) or (in_array($data["questionblock_id"], $checked_questionblocks)))
00980 {
00981 $this->tpl->setCurrentBlock("row");
00982 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
00983 $this->tpl->setVariable("TEXT_TITLE", $data["title"]);
00984 $this->tpl->setVariable("TEXT_DESCRIPTION", $data["description"]);
00985 $this->tpl->setVariable("TEXT_TYPE", $this->lng->txt($data["type_tag"]));
00986 $this->tpl->setVariable("TEXT_QUESTIONBLOCK", $data["questionblock_title"]);
00987 $this->tpl->parseCurrentBlock();
00988 $counter++;
00989 }
00990 }
00991 foreach ($checked_questions as $id)
00992 {
00993 $this->tpl->setCurrentBlock("hidden");
00994 $this->tpl->setVariable("HIDDEN_NAME", "id_$id");
00995 $this->tpl->setVariable("HIDDEN_VALUE", "$id");
00996 $this->tpl->parseCurrentBlock();
00997 }
00998 foreach ($checked_questionblocks as $id)
00999 {
01000 $this->tpl->setCurrentBlock("hidden");
01001 $this->tpl->setVariable("HIDDEN_NAME", "id_qb_$id");
01002 $this->tpl->setVariable("HIDDEN_VALUE", "$id");
01003 $this->tpl->parseCurrentBlock();
01004 }
01005 $this->tpl->setCurrentBlock("adm_content");
01006 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
01007 $this->tpl->setVariable("TEXT_DESCRIPTION", $this->lng->txt("description"));
01008 $this->tpl->setVariable("TEXT_TYPE", $this->lng->txt("question_type"));
01009 $this->tpl->setVariable("TEXT_QUESTIONBLOCK", $this->lng->txt("questionblock"));
01010 $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
01011 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
01012 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "confirmRemoveQuestions"));
01013 $this->tpl->parseCurrentBlock();
01014 }
01015
01016
01025 function defineQuestionblock($questionblock_id = "")
01026 {
01027 $this->questionsSubtabs("questions");
01028 ilUtil::sendInfo();
01029 if ($questionblock_id)
01030 {
01031 $questionblock = $this->object->getQuestionblock($questionblock_id);
01032 }
01033 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_define_questionblock.html", "Modules/Survey");
01034 foreach ($_POST as $key => $value)
01035 {
01036 if (preg_match("/cb_(\d+)/", $key, $matches))
01037 {
01038 $this->tpl->setCurrentBlock("hidden");
01039 $this->tpl->setVariable("HIDDEN_NAME", "cb_$matches[1]");
01040 $this->tpl->setVariable("HIDDEN_VALUE", $matches[1]);
01041 $this->tpl->parseCurrentBlock();
01042 }
01043 }
01044 if ($questionblock_id)
01045 {
01046 $this->tpl->setCurrentBlock("hidden");
01047 $this->tpl->setVariable("HIDDEN_NAME", "questionblock_id");
01048 $this->tpl->setVariable("HIDDEN_VALUE", $questionblock_id);
01049 $this->tpl->parseCurrentBlock();
01050 }
01051 $this->tpl->setCurrentBlock("adm_content");
01052 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
01053 if ($questionblock_id)
01054 {
01055 $this->tpl->setVariable("VALUE_TITLE", $questionblock["title"]);
01056 }
01057 $this->tpl->setVariable("TXT_QUESTIONTEXT_DESCRIPTION", $this->lng->txt("show_questiontext_description"));
01058 $this->tpl->setVariable("TXT_QUESTIONTEXT", $this->lng->txt("show_questiontext"));
01059 if (($questionblock["show_questiontext"]) || (strlen($questionblock_id) == 0))
01060 {
01061 $this->tpl->setVariable("CHECKED_QUESTIONTEXT", " checked=\"checked\"");
01062 }
01063 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
01064 $this->tpl->setVariable("HEADING_QUESTIONBLOCK", $this->lng->txt("define_questionblock"));
01065 $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
01066 $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
01067 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "saveDefineQuestionblock"));
01068 $this->tpl->parseCurrentBlock();
01069 }
01070
01078 function createQuestionObject()
01079 {
01080 global $ilUser;
01081 $this->questionsSubtabs("questions");
01082 $tpl = new ilTemplate("tpl.il_svy_svy_qpl_select.html", TRUE, TRUE, "Modules/Survey");
01083 $questionpools =& $this->object->getAvailableQuestionpools(FALSE, TRUE, TRUE, "write");
01084 if (count($questionpools))
01085 {
01086 foreach ($questionpools as $key => $value)
01087 {
01088 $tpl->setCurrentBlock("option");
01089 $tpl->setVariable("VALUE_OPTION", $key);
01090 $tpl->setVariable("TEXT_OPTION", $value);
01091 $tpl->parseCurrentBlock();
01092 }
01093 $tpl->setCurrentBlock("selection");
01094 $tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("select_questionpool"));
01095 $tpl->parseCurrentBlock();
01096 }
01097 else
01098 {
01099 $tpl->setCurrentBlock("selection");
01100 $tpl->setVariable("TXT_QPL_ENTER", $this->lng->txt("cat_create_spl"));
01101 $tpl->parseCurrentBlock();
01102 }
01103 $tpl->setVariable("BTN_SUBMIT", $this->lng->txt("submit"));
01104 $sel_question_types = (strlen($_POST["sel_question_types"])) ? $_POST["sel_question_types"] : $_GET["sel_question_types"];
01105 $this->ctrl->setParameter($this, "sel_question_types", $sel_question_types);
01106 $tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "executeCreateQuestion"));
01107 $tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
01108 $this->tpl->setVariable("ADM_CONTENT", $tpl->get());
01109 }
01110
01118 function cancelCreateQuestionObject()
01119 {
01120 $this->ctrl->redirect($this, "questions");
01121 }
01122
01130 function executeCreateQuestionObject()
01131 {
01132 if (strlen($_POST["sel_spl"]))
01133 {
01134 include_once "./Services/Utilities/classes/class.ilUtil.php";
01135 ilUtil::redirect("ilias.php?baseClass=ilObjSurveyQuestionPoolGUI&ref_id=" . $_POST["sel_spl"] . "&cmd=createQuestionForSurvey&new_for_survey=".$_GET["ref_id"]."&sel_question_types=".$_GET["sel_question_types"]);
01136 }
01137 elseif (strlen($_POST["name_spl"]))
01138 {
01139 $ref_id = $this->createQuestionPool($_POST["name_spl"]);
01140 ilUtil::redirect("ilias.php?baseClass=ilObjSurveyQuestionPoolGUI&ref_id=" . $ref_id . "&cmd=createQuestionForSurvey&new_for_survey=".$_GET["ref_id"]."&sel_question_types=".$_GET["sel_question_types"]);
01141 }
01142 else
01143 {
01144 ilUtil::sendInfo($this->lng->txt("err_no_pool_name"), true);
01145 $this->ctrl->setParameter($this, "sel_question_types", $_GET["sel_question_types"]);
01146 $this->ctrl->redirect($this, "createQuestion");
01147 }
01148 }
01149
01156 private function createQuestionPool($name = "dummy")
01157 {
01158 global $tree;
01159 $parent_ref = $tree->getParentId($this->object->getRefId());
01160 include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
01161 $qpl = new ilObjSurveyQuestionPool();
01162 $qpl->setType("spl");
01163 $qpl->setTitle($name);
01164 $qpl->setDescription("");
01165 $qpl->create();
01166 $qpl->createReference();
01167 $qpl->putInTree($parent_ref);
01168 $qpl->setPermissions($parent_ref);
01169 $qpl->setOnline(1);
01170 $qpl->saveToDb();
01171 return $qpl->getRefId();
01172 }
01173
01182 function addHeadingObject($question_id = "")
01183 {
01184 $this->questionsSubtabs("questions");
01185 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_heading.html", "Modules/Survey");
01186 $survey_questions =& $this->object->getSurveyQuestions();
01187 if ($question_id)
01188 {
01189 $_POST["insertbefore"] = $question_id;
01190 $_POST["heading"] = $survey_questions[$question_id]["heading"];
01191 }
01192 foreach ($survey_questions as $key => $value)
01193 {
01194 $this->tpl->setCurrentBlock("insertbefore_row");
01195 $this->tpl->setVariable("VALUE_OPTION", $key);
01196 $option = $this->lng->txt("before") . ": \"" . $value["title"] . "\"";
01197 if (strlen($option) > 80)
01198 {
01199 $option = preg_replace("/^(.{40}).*(.{40})$/", "\\1 [...] \\2", $option);
01200 }
01201 include_once "./Services/Utilities/classes/class.ilUtil.php";
01202 $this->tpl->setVariable("TEXT_OPTION", ilUtil::prepareFormOutput($option));
01203 if ($key == $_POST["insertbefore"])
01204 {
01205 $this->tpl->setVariable("SELECTED_OPTION", " selected=\"selected\"");
01206 }
01207 $this->tpl->parseCurrentBlock();
01208 }
01209 if ($question_id)
01210 {
01211 $this->tpl->setCurrentBlock("hidden");
01212 $this->tpl->setVariable("INSERTBEFORE_ORIGINAL", $question_id);
01213 $this->tpl->parseCurrentBlock();
01214 }
01215 $this->tpl->setCurrentBlock("adm_content");
01216 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "saveHeading"));
01217 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
01218 if ($question_id)
01219 {
01220 $this->tpl->setVariable("TEXT_ADD_HEADING", $this->lng->txt("edit_heading"));
01221 $this->tpl->setVariable("SELECT_DISABLED", " disabled=\"disabled\"");
01222 }
01223 else
01224 {
01225 $this->tpl->setVariable("TEXT_ADD_HEADING", $this->lng->txt("add_heading"));
01226 }
01227 $this->tpl->setVariable("TEXT_HEADING", $this->lng->txt("heading"));
01228 $this->tpl->setVariable("VALUE_HEADING", $_POST["heading"]);
01229 $this->tpl->setVariable("TEXT_INSERT", $this->lng->txt("insert"));
01230 $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
01231 $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
01232 $this->tpl->parseCurrentBlock();
01233 include_once "./Services/RTE/classes/class.ilRTE.php";
01234 $rtestring = ilRTE::_getRTEClassname();
01235 include_once "./Services/RTE/classes/class.$rtestring.php";
01236 $rte = new $rtestring();
01237 $rte->removePlugin("ibrowser");
01238 include_once "./classes/class.ilObject.php";
01239 $obj_id = ilObject::_lookupObjectId($_GET["ref_id"]);
01240 $obj_type = ilObject::_lookupType($_GET["ref_id"], TRUE);
01241 $rte->addRTESupport($obj_id, $obj_type, "survey");
01242 }
01243
01251 function confirmInsertQuestionObject()
01252 {
01253
01254 foreach ($_POST as $key => $value) {
01255 if (preg_match("/id_(\d+)/", $key, $matches)) {
01256 if ($_GET["browsetype"] == 1)
01257 {
01258 $this->object->insertQuestion($matches[1]);
01259 }
01260 else
01261 {
01262 $this->object->insertQuestionBlock($matches[1]);
01263 }
01264 }
01265 }
01266 $this->object->saveCompletionStatus();
01267 ilUtil::sendInfo($this->lng->txt("questions_inserted"), true);
01268 $this->ctrl->redirect($this, "questions");
01269 }
01270
01278 function cancelInsertQuestionObject()
01279 {
01280 $this->ctrl->redirect($this, "questions");
01281 }
01282
01290 function saveHeadingObject()
01291 {
01292 if ($_POST["heading"])
01293 {
01294 $insertbefore = $_POST["insertbefore"];
01295 if (!$insertbefore)
01296 {
01297 $insertbefore = $_POST["insertbefore_original"];
01298 }
01299 include_once "./classes/class.ilObjAdvancedEditing.php";
01300 $this->object->saveHeading(ilUtil::stripSlashes($_POST["heading"], TRUE, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("survey")), $insertbefore);
01301 $this->ctrl->redirect($this, "questions");
01302 }
01303 else
01304 {
01305 ilUtil::sendInfo($this->lng->txt("error_add_heading"));
01306 $this->addHeadingObject();
01307 return;
01308 }
01309 }
01310
01318 function cancelHeadingObject()
01319 {
01320 $this->ctrl->redirect($this, "questions");
01321 }
01322
01330 function confirmRemoveHeadingObject()
01331 {
01332 $this->object->saveHeading("", $_POST["removeheading"]);
01333 $this->ctrl->redirect($this, "questions");
01334 }
01335
01343 function cancelRemoveHeadingObject()
01344 {
01345 $this->ctrl->redirect($this, "questions");
01346 }
01347
01355 function confirmRemoveHeadingForm()
01356 {
01357 ilUtil::sendInfo($this->lng->txt("confirm_remove_heading"));
01358 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_confirm_removeheading.html", "Modules/Survey");
01359 $this->tpl->setCurrentBlock("adm_content");
01360 $this->tpl->setVariable("BTN_CONFIRM_REMOVE", $this->lng->txt("confirm"));
01361 $this->tpl->setVariable("BTN_CANCEL_REMOVE", $this->lng->txt("cancel"));
01362 $this->tpl->setVariable("REMOVE_HEADING", $_GET["removeheading"]);
01363 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "confirmRemoveHeading"));
01364 $this->tpl->parseCurrentBlock();
01365 }
01366
01374 function confirmRemoveQuestionsObject()
01375 {
01376 $checked_questions = array();
01377 $checked_questionblocks = array();
01378 foreach ($_POST as $key => $value)
01379 {
01380 if (preg_match("/id_(\d+)/", $key, $matches))
01381 {
01382 array_push($checked_questions, $matches[1]);
01383 }
01384 if (preg_match("/id_qb_(\d+)/", $key, $matches))
01385 {
01386 array_push($checked_questionblocks, $matches[1]);
01387 }
01388 }
01389 $this->object->removeQuestions($checked_questions, $checked_questionblocks);
01390 $this->object->saveCompletionStatus();
01391 ilUtil::sendInfo($this->lng->txt("questions_removed"), true);
01392 $this->ctrl->redirect($this, "questions");
01393 }
01394
01402 function cancelRemoveQuestionsObject()
01403 {
01404 $this->ctrl->redirect($this, "questions");
01405 }
01406
01414 function defineQuestionblockObject()
01415 {
01416 $questionblock = array();
01417 foreach ($_POST as $key => $value)
01418 {
01419 if (preg_match("/cb_(\d+)/", $key, $matches))
01420 {
01421 array_push($questionblock, $value);
01422 }
01423 }
01424 if (count($questionblock) < 2)
01425 {
01426 ilUtil::sendInfo($this->lng->txt("qpl_define_questionblock_select_missing"), true);
01427 $this->ctrl->redirect($this, "questions");
01428 }
01429 else
01430 {
01431 $this->defineQuestionblock();
01432 return;
01433 }
01434 }
01435
01443 function saveDefineQuestionblockObject()
01444 {
01445 if ($_POST["title"])
01446 {
01447 $show_questiontext = ($_POST["show_questiontext"]) ? 1 : 0;
01448 if ($_POST["questionblock_id"])
01449 {
01450 include_once "./Services/Utilities/classes/class.ilUtil.php";
01451 $this->object->modifyQuestionblock($_POST["questionblock_id"], ilUtil::stripSlashes($_POST["title"]), $show_questiontext);
01452 }
01453 else
01454 {
01455 $questionblock = array();
01456 foreach ($_POST as $key => $value)
01457 {
01458 if (preg_match("/cb_(\d+)/", $key, $matches))
01459 {
01460 array_push($questionblock, $value);
01461 }
01462 }
01463 include_once "./Services/Utilities/classes/class.ilUtil.php";
01464 $this->object->createQuestionblock(ilUtil::stripSlashes($_POST["title"]), $show_questiontext, $questionblock);
01465 }
01466 $this->ctrl->redirect($this, "questions");
01467 }
01468 else
01469 {
01470 ilUtil::sendInfo($this->lng->txt("enter_questionblock_title"));
01471 $this->defineQuestionblockObject();
01472 return;
01473 }
01474 }
01475
01483 function unfoldQuestionblockObject()
01484 {
01485 $unfoldblocks = array();
01486 foreach ($_POST as $key => $value)
01487 {
01488 if (preg_match("/cb_qb_(\d+)/", $key, $matches))
01489 {
01490 array_push($unfoldblocks, $matches[1]);
01491 }
01492 }
01493 if (count($unfoldblocks))
01494 {
01495 $this->object->unfoldQuestionblocks($unfoldblocks);
01496 }
01497 else
01498 {
01499 ilUtil::sendInfo($this->lng->txt("qpl_unfold_select_none"), true);
01500 }
01501 $this->ctrl->redirect($this, "questions");
01502 }
01503
01511 function cancelDefineQuestionblockObject()
01512 {
01513 $this->ctrl->redirect($this, "questions");
01514 }
01515
01523 function moveQuestionsObject()
01524 {
01525 $move_questions = array();
01526 foreach ($_POST as $key => $value)
01527 {
01528 if (preg_match("/cb_(\d+)/", $key, $matches))
01529 {
01530 array_push($move_questions, $matches[1]);
01531 }
01532 if (preg_match("/cb_qb_(\d+)/", $key, $matches))
01533 {
01534 $ids = $this->object->getQuestionblockQuestionIds($matches[1]);
01535 foreach ($ids as $qkey => $qid)
01536 {
01537 array_push($move_questions, $qid);
01538 }
01539 }
01540 }
01541 if (count($move_questions) == 0)
01542 {
01543 ilUtil::sendInfo($this->lng->txt("no_question_selected_for_move"), true);
01544 $this->ctrl->redirect($this, "questions");
01545 }
01546 else
01547 {
01548 $_SESSION["move_questions"] = $move_questions;
01549 ilUtil::sendInfo($this->lng->txt("select_target_position_for_move_question"));
01550 $this->questionsObject();
01551 }
01552 }
01553
01561 function insertQuestions($insert_mode)
01562 {
01563
01564 $move_questions = $_SESSION["move_questions"];
01565
01566 $insert_id = -1;
01567 foreach ($_POST as $key => $value)
01568 {
01569 if (preg_match("/^cb_(\d+)$/", $key, $matches))
01570 {
01571 if ($insert_id < 0)
01572 {
01573 $insert_id = $matches[1];
01574 }
01575 }
01576 if (preg_match("/^cb_qb_(\d+)$/", $key, $matches))
01577 {
01578 if ($insert_id < 0)
01579 {
01580 $ids =& $this->object->getQuestionblockQuestionIds($matches[1]);
01581 if (count($ids))
01582 {
01583 if ($insert_mode == 0)
01584 {
01585 $insert_id = $ids[0];
01586 }
01587 else if ($insert_mode == 1)
01588 {
01589 $insert_id = $ids[count($ids)-1];
01590 }
01591 }
01592 }
01593 }
01594 }
01595 if ($insert_id <= 0)
01596 {
01597 ilUtil::sendInfo($this->lng->txt("no_target_selected_for_move"), true);
01598 }
01599 else
01600 {
01601 $this->object->moveQuestions($move_questions, $insert_id, $insert_mode);
01602 }
01603 unset($_SESSION["move_questions"]);
01604 $this->ctrl->redirect($this, "questions");
01605 }
01606
01614 function insertQuestionsBeforeObject()
01615 {
01616 $this->insertQuestions(0);
01617 }
01618
01626 function insertQuestionsAfterObject()
01627 {
01628 $this->insertQuestions(1);
01629 }
01630
01638 function saveObligatoryObject()
01639 {
01640 $obligatory = array();
01641 foreach ($_POST as $key => $value)
01642 {
01643 if (preg_match("/obligatory_(\d+)/", $key, $matches))
01644 {
01645 $obligatory[$matches[1]] = 1;
01646 }
01647 }
01648 $this->object->setObligatoryStates($obligatory);
01649 $this->ctrl->redirect($this, "questions");
01650 }
01651
01659 function questionsObject()
01660 {
01661 $this->handleWriteAccess();
01662 global $rbacsystem;
01663
01664 $hasDatasets = $this->object->_hasDatasets($this->object->getSurveyId());
01665 include_once "./Services/Utilities/classes/class.ilUtil.php";
01666 if ((!$rbacsystem->checkAccess("read", $this->ref_id)) && (!$rbacsystem->checkAccess("write", $this->ref_id)))
01667 {
01668
01669 ilUtil::sendInfo($this->lng->txt("cannot_edit_survey"), true);
01670 $path = $this->tree->getPathFull($this->object->getRefID());
01671 ilUtil::redirect($this->getReturnLocation("cancel","./repository.php?cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
01672 return;
01673 }
01674
01675 if ($_GET["new_id"] > 0)
01676 {
01677
01678 $inserted = $this->object->insertQuestion($_GET["new_id"]);
01679 if (!$inserted)
01680 {
01681 ilUtil::sendInfo($this->lng->txt("survey_error_insert_incomplete_question"));
01682 }
01683 }
01684
01685 if ($_GET["eqid"] and $_GET["eqpl"])
01686 {
01687 ilUtil::redirect("ilias.php?baseClass=ilObjSurveyQuestionPoolGUI&ref_id=" . $_GET["eqpl"] . "&cmd=editQuestionForSurvey&calling_survey=".$_GET["ref_id"]."&q_id=" . $_GET["eqid"]);
01688 }
01689
01690
01691 $_SESSION["calling_survey"] = $this->object->getRefId();
01692 unset($_SESSION["survey_id"]);
01693
01694 if ($_GET["editheading"])
01695 {
01696 $this->addHeadingObject($_GET["editheading"]);
01697 return;
01698 }
01699
01700 if ($_GET["up"] > 0)
01701 {
01702 $this->object->moveUpQuestion($_GET["up"]);
01703 }
01704 if ($_GET["down"] > 0)
01705 {
01706 $this->object->moveDownQuestion($_GET["down"]);
01707 }
01708 if ($_GET["qbup"] > 0)
01709 {
01710 $this->object->moveUpQuestionblock($_GET["qbup"]);
01711 }
01712 if ($_GET["qbdown"] > 0)
01713 {
01714 $this->object->moveDownQuestionblock($_GET["qbdown"]);
01715 }
01716
01717 if ($_GET["removeheading"])
01718 {
01719 $this->confirmRemoveHeadingForm();
01720 return;
01721 }
01722
01723 if ($_GET["editblock"])
01724 {
01725 $this->defineQuestionblock($_GET["editblock"]);
01726 return;
01727 }
01728
01729 if ($_GET["add"])
01730 {
01731
01732 $selected_array = array();
01733 array_push($selected_array, $_GET["add"]);
01734 ilUtil::sendInfo($this->lng->txt("ask_insert_questions"));
01735 $this->insertQuestionsForm($selected_array);
01736 return;
01737 }
01738
01739 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_questions.html", "Modules/Survey");
01740
01741 $survey_questions =& $this->object->getSurveyQuestions();
01742 $questionblock_titles =& $this->object->getQuestionblockTitles();
01743 $questionpools =& $this->object->getQuestionpoolTitles();
01744 $colors = array("tblrow1", "tblrow2");
01745 $counter = 0;
01746 $title_counter = 0;
01747 $last_color_class = "";
01748 $obligatory = "<img src=\"" . ilUtil::getImagePath("obligatory.gif", "Modules/Survey") . "\" alt=\"" . $this->lng->txt("question_obligatory") . "\" title=\"" . $this->lng->txt("question_obligatory") . "\" />";
01749 if (count($survey_questions) > 0)
01750 {
01751 foreach ($survey_questions as $question_id => $data)
01752 {
01753 $title_counter++;
01754 if (($last_questionblock_id > 0) && ($data["questionblock_id"] == 0))
01755 {
01756 $counter++;
01757 }
01758 if (($last_questionblock_id > 0) && ($data["questionblock_id"] > 0) && ($data["questionblock_id"] != $last_questionblock_id))
01759 {
01760 $counter++;
01761 }
01762 if (($data["questionblock_id"] > 0) and ($data["questionblock_id"] != $last_questionblock_id))
01763 {
01764
01765 $this->tpl->setCurrentBlock("separator");
01766 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
01767 $this->tpl->parseCurrentBlock();
01768 $this->tpl->setCurrentBlock("QTab");
01769 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
01770 $this->tpl->parseCurrentBlock();
01771
01772 $this->tpl->setCurrentBlock("block");
01773 $this->tpl->setVariable("TYPE_ICON", "<img src=\"" . ilUtil::getImagePath("questionblock.gif", "Modules/Survey") . "\" alt=\"".$this->lng->txt("questionblock_icon")."\" />");
01774 $this->tpl->setVariable("TEXT_QUESTIONBLOCK", $this->lng->txt("questionblock") . ": " . $data["questionblock_title"]);
01775 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
01776 if ($rbacsystem->checkAccess("write", $this->ref_id) and !$hasDatasets)
01777 {
01778 if ($data["question_id"] != $this->object->questions[0])
01779 {
01780 $this->tpl->setVariable("BUTTON_UP", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "$&qbup=" . $data["questionblock_id"] . "\"><img src=\"" . ilUtil::getImagePath("a_up.gif") . "\" alt=\"" . $this->lng->txt("up") . "\" title=\"" . $this->lng->txt("up") . "\" border=\"0\" /></a>");
01781 }
01782 $akeys = array_keys($survey_questions);
01783 if ($data["questionblock_id"] != $survey_questions[$akeys[count($akeys)-1]]["questionblock_id"])
01784 {
01785 $this->tpl->setVariable("BUTTON_DOWN", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&qbdown=" . $data["questionblock_id"] . "\"><img src=\"" . ilUtil::getImagePath("a_down.gif") . "\" alt=\"" . $this->lng->txt("down") . "\" title=\"" . $this->lng->txt("down") . "\" border=\"0\" /></a>");
01786 }
01787 $this->tpl->setVariable("TEXT_EDIT", $this->lng->txt("edit"));
01788 $this->tpl->setVariable("HREF_EDIT", $this->ctrl->getLinkTarget($this, "questions") . "&editblock=" . $data["questionblock_id"]);
01789 }
01790 $this->tpl->parseCurrentBlock();
01791 $this->tpl->setCurrentBlock("QTab");
01792 $this->tpl->setVariable("QUESTION_ID", "qb_" . $data["questionblock_id"]);
01793 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
01794 $this->tpl->parseCurrentBlock();
01795 }
01796 if (($last_questionblock_id > 0) && ($data["questionblock_id"] == 0))
01797 {
01798
01799 $this->tpl->setCurrentBlock("separator");
01800 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
01801 $this->tpl->parseCurrentBlock();
01802 $this->tpl->setCurrentBlock("QTab");
01803 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
01804 $this->tpl->parseCurrentBlock();
01805 }
01806 if ($data["heading"])
01807 {
01808 $this->tpl->setCurrentBlock("heading");
01809 $this->tpl->setVariable("TEXT_HEADING", $data["heading"]);
01810 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
01811 if ($rbacsystem->checkAccess("write", $this->ref_id) and !$hasDatasets)
01812 {
01813 $this->tpl->setVariable("TEXT_EDIT", $this->lng->txt("edit"));
01814 $this->tpl->setVariable("HREF_EDIT", $this->ctrl->getLinkTarget($this, "questions") . "&editheading=" . $data["question_id"]);
01815 $this->tpl->setVariable("TEXT_DELETE", $this->lng->txt("remove"));
01816 $this->tpl->setVariable("HREF_DELETE", $this->ctrl->getLinkTarget($this, "questions") . "&removeheading=" . $data["question_id"]);
01817 }
01818 $this->tpl->parseCurrentBlock();
01819 $this->tpl->setCurrentBlock("QTab");
01820 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
01821 $this->tpl->parseCurrentBlock();
01822 }
01823 if (!$data["questionblock_id"])
01824 {
01825 $this->tpl->setCurrentBlock("checkable");
01826 $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
01827 $this->tpl->parseCurrentBlock();
01828 }
01829 $this->tpl->setCurrentBlock("QTab");
01830 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
01831 $ref_id = SurveyQuestion::_getRefIdFromObjId($data["obj_fi"]);
01832 if ($rbacsystem->checkAccess("write", $this->ref_id) and !$hasDatasets)
01833 {
01834 $q_id = $data["question_id"];
01835 $qpl_ref_id = $this->object->_getRefIdFromObjId($data["obj_fi"]);
01836 $this->tpl->setVariable("QUESTION_TITLE", "$title_counter. <a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&eqid=$q_id&eqpl=$qpl_ref_id" . "\">" . $data["title"] . "</a>");
01837 }
01838 else
01839 {
01840 $this->tpl->setVariable("QUESTION_TITLE", "$title_counter. ". $data["title"]);
01841 }
01842 $this->tpl->setVariable("TYPE_ICON", "<img src=\"" . ilUtil::getImagePath("question.gif", "Modules/Survey") . "\" alt=\"".$this->lng->txt("question_icon")."\" />");
01843 if ($rbacsystem->checkAccess("write", $this->ref_id) and !$hasDatasets)
01844 {
01845 $obligatory_checked = "";
01846 if ($data["obligatory"] == 1)
01847 {
01848 $obligatory_checked = " checked=\"checked\"";
01849 }
01850 $this->tpl->setVariable("QUESTION_OBLIGATORY", "<input type=\"checkbox\" name=\"obligatory_" . $data["question_id"] . "\" value=\"1\"$obligatory_checked />");
01851 }
01852 else
01853 {
01854 if ($data["obligatory"] == 1)
01855 {
01856 $this->tpl->setVariable("QUESTION_OBLIGATORY", $obligatory);
01857 }
01858 }
01859 $this->tpl->setVariable("QUESTION_COMMENT", $data["description"]);
01860 if ($rbacsystem->checkAccess("write", $this->ref_id) and !$hasDatasets)
01861 {
01862 if (!$data["questionblock_id"])
01863 {
01864
01865 if ($data["question_id"] != $this->object->questions[0])
01866 {
01867 $this->tpl->setVariable("BUTTON_UP", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&up=" . $data["question_id"] . "\"><img src=\"" . ilUtil::getImagePath("a_up.gif") . "\" alt=\"".$this->lng->txt("up")."\" border=\"0\" /></a>");
01868 }
01869 if ($data["question_id"] != $this->object->questions[count($this->object->questions)-1])
01870 {
01871 $this->tpl->setVariable("BUTTON_DOWN", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&down=" . $data["question_id"] . "\"><img src=\"" . ilUtil::getImagePath("a_down.gif") . "\" alt=\"".$this->lng->txt("down")."\" border=\"0\" /></a>");
01872 }
01873 }
01874 else
01875 {
01876
01877 if ($data["questionblock_id"] == $last_questionblock_id)
01878 {
01879 $this->tpl->setVariable("BUTTON_UP", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&up=" . $data["question_id"] . "\"><img src=\"" . ilUtil::getImagePath("a_up.gif") . "\" alt=\"".$this->lng->txt("up")."\" border=\"0\" /></a>");
01880 }
01881 $tmp_questions = array_keys($survey_questions);
01882 $blockkey = array_search($question_id, $tmp_questions);
01883 if (($blockkey !== FALSE) && ($blockkey < count($tmp_questions)-1))
01884 {
01885 if ($data["questionblock_id"] == $survey_questions[$tmp_questions[$blockkey+1]]["questionblock_id"])
01886 {
01887 $this->tpl->setVariable("BUTTON_DOWN", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&down=" . $data["question_id"] . "\"><img src=\"" . ilUtil::getImagePath("a_down.gif") . "\" alt=\"".$this->lng->txt("down")."\" border=\"0\" /></a>");
01888 }
01889 }
01890 }
01891 }
01892 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($data["type_tag"]));
01893 $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]);
01894 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
01895 $last_color_class = $colors[$counter % 2];
01896 if (!$data["questionblock_id"])
01897 {
01898 $counter++;
01899 }
01900 $this->tpl->parseCurrentBlock();
01901 $last_questionblock_id = $data["questionblock_id"];
01902 }
01903
01904 if ($rbacsystem->checkAccess("write", $this->ref_id) and !$hasDatasets)
01905 {
01906 $this->tpl->setCurrentBlock("selectall");
01907 $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
01908 $this->tpl->setVariable("COLOR_CLASS", $last_color_class);
01909 $this->tpl->parseCurrentBlock();
01910 if (array_key_exists("move_questions", $_SESSION))
01911 {
01912 $this->tpl->setCurrentBlock("move_buttons");
01913 $this->tpl->setVariable("INSERT_BEFORE", $this->lng->txt("insert_before"));
01914 $this->tpl->setVariable("INSERT_AFTER", $this->lng->txt("insert_after"));
01915 $this->tpl->parseCurrentBlock();
01916 }
01917 $this->tpl->setCurrentBlock("QFooter");
01918 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\">");
01919 $this->tpl->setVariable("REMOVE", $this->lng->txt("remove_question"));
01920 $this->tpl->setVariable("MOVE", $this->lng->txt("move"));
01921 $this->tpl->setVariable("QUESTIONBLOCK", $this->lng->txt("define_questionblock"));
01922 $this->tpl->setVariable("UNFOLD", $this->lng->txt("unfold"));
01923 $this->tpl->setVariable("SAVE", $this->lng->txt("save_obligatory_state"));
01924 $this->tpl->parseCurrentBlock();
01925 }
01926 }
01927 else
01928 {
01929 $this->tpl->setCurrentBlock("Emptytable");
01930 $this->tpl->setVariable("TEXT_EMPTYTABLE", $this->lng->txt("no_questions_available"));
01931 $this->tpl->parseCurrentBlock();
01932 }
01933 if (($last_questionblock_id > 0))
01934 {
01935
01936 $this->tpl->setCurrentBlock("separator");
01937 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
01938 $this->tpl->parseCurrentBlock();
01939 $this->tpl->setCurrentBlock("QTab");
01940 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
01941 $this->tpl->parseCurrentBlock();
01942 }
01943
01944 if ($rbacsystem->checkAccess("write", $this->ref_id) and !$hasDatasets)
01945 {
01946 $this->tpl->setCurrentBlock("QTypes");
01947 $query = "SELECT * FROM survey_questiontype";
01948 $query_result = $this->ilias->db->query($query);
01949 while ($data = $query_result->fetchRow(DB_FETCHMODE_OBJECT))
01950 {
01951 $this->tpl->setVariable("QUESTION_TYPE_ID", $data->type_tag);
01952 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($data->type_tag));
01953 $this->tpl->parseCurrentBlock();
01954 }
01955 $this->tpl->parseCurrentBlock();
01956 }
01957 $this->tpl->setCurrentBlock("adm_content");
01958 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "questions"));
01959 $this->tpl->setVariable("QUESTION_TITLE", $this->lng->txt("title"));
01960 $this->tpl->setVariable("QUESTION_COMMENT", $this->lng->txt("description"));
01961 $this->tpl->setVariable("QUESTION_OBLIGATORY", $this->lng->txt("obligatory"));
01962 $this->tpl->setVariable("QUESTION_SEQUENCE", $this->lng->txt("sequence"));
01963 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("question_type"));
01964 $this->tpl->setVariable("QUESTION_AUTHOR", $this->lng->txt("author"));
01965
01966 if ($rbacsystem->checkAccess("write", $this->ref_id) and !$hasDatasets)
01967 {
01968 $this->tpl->setVariable("BUTTON_INSERT_QUESTION", $this->lng->txt("browse_for_questions"));
01969 $this->tpl->setVariable("TEXT_CREATE_NEW", " " . strtolower($this->lng->txt("or")) . " " . $this->lng->txt("create_new"));
01970 $this->tpl->setVariable("BUTTON_CREATE_QUESTION", $this->lng->txt("create"));
01971 $this->tpl->setVariable("HEADING", $this->lng->txt("add_heading"));
01972 }
01973 if ($hasDatasets)
01974 {
01975 ilUtil::sendInfo($this->lng->txt("survey_has_datasets_warning"));
01976 }
01977
01978 $this->tpl->parseCurrentBlock();
01979 $this->questionsSubtabs("questions");
01980 }
01981
01989 function evaluationObject()
01990 {
01991 include_once("./Modules/Survey/classes/class.ilSurveyEvaluationGUI.php");
01992 $eval_gui = new ilSurveyEvaluationGUI($this->object);
01993 $this->ctrl->setCmdClass(get_class($eval_gui));
01994 $this->ctrl->redirect($eval_gui, "evaluation");
01995 }
01996
02004 function outUserGroupTable($a_type, $id_array, $block_result, $block_row, $title_text, $buttons)
02005 {
02006 global $rbacsystem;
02007
02008 $rowclass = array("tblrow1", "tblrow2");
02009 switch($a_type)
02010 {
02011 case "usr":
02012 include_once './Services/User/classes/class.ilObjUser.php';
02013 $counter = 0;
02014 foreach ($id_array as $user_id)
02015 {
02016 $this->tpl->setCurrentBlock($block_row);
02017 $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
02018 if (ilObjUser::_lookupLogin($user_id))
02019 {
02020 $user = new ilObjUser($user_id);
02021 $this->tpl->setVariable("COUNTER", $user->getId());
02022 $this->tpl->setVariable("VALUE_LOGIN", $user->getLogin());
02023 $this->tpl->setVariable("VALUE_FIRSTNAME", $user->getFirstname());
02024 $this->tpl->setVariable("VALUE_LASTNAME", $user->getLastname());
02025 }
02026 else
02027 {
02028 $this->tpl->setVariable("COUNTER", $user_id);
02029 $this->tpl->setVariable("VALUE_LOGIN", $this->lng->txt("deleted_user"));
02030 $this->tpl->setVariable("VALUE_FIRSTNAME", $this->lng->txt("unknown"));
02031 $this->tpl->setVariable("VALUE_LASTNAME", $this->lng->txt("unknown"));
02032 }
02033 $counter++;
02034 $this->tpl->parseCurrentBlock();
02035 }
02036 if (count($id_array))
02037 {
02038 $this->tpl->setCurrentBlock("selectall_$block_result");
02039 $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
02040 $counter++;
02041 $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
02042 $this->tpl->parseCurrentBlock();
02043 }
02044 $this->tpl->setCurrentBlock($block_result);
02045 include_once "./Services/Utilities/classes/class.ilUtil.php";
02046 $this->tpl->setVariable("TEXT_USER_TITLE", "<img src=\"" . ilUtil::getImagePath("icon_usr.gif") . "\" alt=\"".$this->lng->txt("obj_usr")."\" /> " . $title_text);
02047 $this->tpl->setVariable("TEXT_LOGIN", $this->lng->txt("login"));
02048 $this->tpl->setVariable("TEXT_FIRSTNAME", $this->lng->txt("firstname"));
02049 $this->tpl->setVariable("TEXT_LASTNAME", $this->lng->txt("lastname"));
02050 if ($rbacsystem->checkAccess('invite', $this->object->getRefId()))
02051 {
02052 foreach ($buttons as $cat)
02053 {
02054 $this->tpl->setVariable("VALUE_" . strtoupper($cat), $this->lng->txt($cat));
02055 }
02056 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\">");
02057 }
02058 $this->tpl->parseCurrentBlock();
02059 break;
02060 case "grp":
02061 include_once "./classes/class.ilObjGroup.php";
02062 $counter = 0;
02063 foreach ($id_array as $group_id)
02064 {
02065 $group = new ilObjGroup($group_id);
02066 $this->tpl->setCurrentBlock($block_row);
02067 $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
02068 $this->tpl->setVariable("COUNTER", $group->getRefId());
02069 $this->tpl->setVariable("VALUE_TITLE", $group->getTitle());
02070 $this->tpl->setVariable("VALUE_DESCRIPTION", $group->getDescription());
02071 $counter++;
02072 $this->tpl->parseCurrentBlock();
02073 }
02074 if (count($id_array))
02075 {
02076 $this->tpl->setCurrentBlock("selectall_$block_result");
02077 $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
02078 $counter++;
02079 $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
02080 $this->tpl->parseCurrentBlock();
02081 }
02082 $this->tpl->setCurrentBlock($block_result);
02083 include_once "./Services/Utilities/classes/class.ilUtil.php";
02084 $this->tpl->setVariable("TEXT_GROUP_TITLE", "<img src=\"" . ilUtil::getImagePath("icon_grp.gif") . "\" alt=\"".$this->lng->txt("obj_grp")."\" /> " . $title_text);
02085 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
02086 $this->tpl->setVariable("TEXT_DESCRIPTION", $this->lng->txt("description"));
02087 if ($rbacsystem->checkAccess('invite', $this->object->getRefId()))
02088 {
02089 foreach ($buttons as $cat)
02090 {
02091 $this->tpl->setVariable("VALUE_" . strtoupper($cat), $this->lng->txt($cat));
02092 }
02093 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\">");
02094 }
02095 $this->tpl->parseCurrentBlock();
02096 break;
02097 case "role":
02098 include_once "./classes/class.ilObjRole.php";
02099 $counter = 0;
02100 foreach ($id_array as $role_id)
02101 {
02102 $role = new ilObjRole($role_id);
02103 $this->tpl->setCurrentBlock($block_row);
02104 $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
02105 $this->tpl->setVariable("COUNTER", $role->getId());
02106 $this->tpl->setVariable("VALUE_TITLE", $role->getTitle());
02107 $this->tpl->setVariable("VALUE_DESCRIPTION", $role->getDescription());
02108 $counter++;
02109 $this->tpl->parseCurrentBlock();
02110 }
02111 if (count($id_array))
02112 {
02113 $this->tpl->setCurrentBlock("selectall_$block_result");
02114 $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
02115 $counter++;
02116 $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
02117 $this->tpl->parseCurrentBlock();
02118 }
02119 $this->tpl->setCurrentBlock($block_result);
02120 include_once "./Services/Utilities/classes/class.ilUtil.php";
02121 $this->tpl->setVariable("TEXT_ROLE_TITLE", "<img src=\"" . ilUtil::getImagePath("icon_role.gif") . "\" alt=\"".$this->lng->txt("obj_role")."\" /> " . $title_text);
02122 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
02123 $this->tpl->setVariable("TEXT_DESCRIPTION", $this->lng->txt("description"));
02124 if ($rbacsystem->checkAccess('invite', $this->object->getRefId()))
02125 {
02126 foreach ($buttons as $cat)
02127 {
02128 $this->tpl->setVariable("VALUE_" . strtoupper($cat), $this->lng->txt($cat));
02129 }
02130 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\">");
02131 }
02132 $this->tpl->parseCurrentBlock();
02133 break;
02134 }
02135 }
02136
02144 function cancelInvitationStatusObject()
02145 {
02146 $this->ctrl->redirect($this, "invite");
02147 }
02148
02156 function saveInvitationStatusObject()
02157 {
02158 $this->object->setInvitationAndMode($_POST["invitation"], $_POST["mode"]);
02159 $this->object->saveToDb();
02160 $this->ctrl->redirect($this, "invite");
02161 }
02162
02170 function searchInvitationObject()
02171 {
02172 $this->inviteObject();
02173 }
02174
02182 function disinviteUserGroupObject()
02183 {
02184
02185 if (is_array($_POST["invited_users"]))
02186 {
02187 foreach ($_POST["invited_users"] as $user_id)
02188 {
02189 $this->object->disinviteUser($user_id);
02190 }
02191 }
02192 $this->ctrl->redirect($this, "invite");
02193 }
02194
02202 function inviteUserGroupObject()
02203 {
02204
02205 if (is_array($_POST["user_select"]))
02206 {
02207 foreach ($_POST["user_select"] as $user_id)
02208 {
02209 $this->object->inviteUser($user_id);
02210 }
02211 }
02212
02213 $error = "";
02214 if (is_array($_POST["group_select"]))
02215 {
02216 $invited = 0;
02217 foreach ($_POST["group_select"] as $group_id)
02218 {
02219 $invited += $this->object->inviteGroup($group_id);
02220 }
02221 if ($invited == 0)
02222 {
02223 $error .= $this->lng->txt("no_user_of_group_invited");
02224 }
02225 }
02226
02227 if (is_array($_POST["role_select"]))
02228 {
02229 $invited = 0;
02230 foreach ($_POST["role_select"] as $role_id)
02231 {
02232 $invited += $this->object->inviteRole($role_id);
02233 }
02234 if ($invited == 0)
02235 {
02236 $error .= $this->lng->txt("no_user_of_group_invited");
02237 }
02238 }
02239 if (strlen($error)) ilUtil::sendInfo($error, TRUE);
02240 $this->ctrl->redirect($this, "invite");
02241 }
02242
02243
02251 function inviteObject()
02252 {
02253 global $ilAccess;
02254 global $rbacsystem;
02255
02256 if ((!$rbacsystem->checkAccess("visible,invite", $this->ref_id)) && (!$rbacsystem->checkAccess("write", $this->ref_id)))
02257 {
02258
02259 ilUtil::sendInfo($this->lng->txt("cannot_edit_survey"), true);
02260 $path = $this->tree->getPathFull($this->object->getRefID());
02261 include_once "./Services/Utilities/classes/class.ilUtil.php";
02262 ilUtil::redirect($this->getReturnLocation("cancel","./repository.php?cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
02263 return;
02264 }
02265 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_invite.html", "Modules/Survey");
02266
02267 if ($this->object->getStatus() == STATUS_OFFLINE)
02268 {
02269 $this->tpl->setCurrentBlock("survey_offline");
02270 $this->tpl->setVariable("SURVEY_OFFLINE_MESSAGE", $this->lng->txt("survey_offline_message"));
02271 $this->tpl->parseCurrentBlock();
02272 return;
02273 }
02274
02275 $concat = ($_POST["concatenation"]) ? $_POST["concatenation"] : "or";
02276 $searchfor = ($_POST["search_for"]) ? $_POST["search_for"] : array("usr");
02277
02278 if (strcmp($this->ctrl->getCmd(), "searchInvitation") == 0)
02279 {
02280 if (is_array($_POST["search_for"]))
02281 {
02282 if (in_array("usr", $_POST["search_for"]) or in_array("grp", $_POST["search_for"]) or in_array("role", $_POST["search_for"]))
02283 {
02284 include_once "./classes/class.ilSearch.php";
02285 $search =& new ilSearch($ilUser->id);
02286 $search->setSearchString($_POST["search_term"]);
02287 $search->setCombination($concat);
02288 $search->setSearchFor($searchfor);
02289 $search->setSearchType("new");
02290 if($search->validate($message))
02291 {
02292 $search->performSearch();
02293 }
02294 if ($message)
02295 {
02296 ilUtil::sendInfo($message);
02297 }
02298 if(!$search->getNumberOfResults() && $search->getSearchFor())
02299 {
02300 ilUtil::sendInfo($this->lng->txt("search_no_match"));
02301 }
02302 $buttons = array("add");
02303 $invited_users = $this->object->getInvitedUsers();
02304 if ($searchresult = $search->getResultByType("usr"))
02305 {
02306 $users = array();
02307 foreach ($searchresult as $result_array)
02308 {
02309 if (!in_array($result_array["id"], $invited_users))
02310 {
02311 if ($ilAccess->checkAccessOfUser($result_array["id"], "read", "", $this->object->getRefId(), "svy", $this->object->getId()))
02312 {
02313 array_push($users, $result_array["id"]);
02314 }
02315 }
02316 }
02317 if (count($users))
02318 {
02319 $this->outUserGroupTable("usr", $users, "user_result", "user_row", $this->lng->txt("search_users"), $buttons);
02320 }
02321 else
02322 {
02323 ilUtil::sendInfo($this->lng->txt("search_no_match"));
02324 }
02325 }
02326 $searchresult = array();
02327 if ($searchresult = $search->getResultByType("grp"))
02328 {
02329 $groups = array();
02330 foreach ($searchresult as $result_array)
02331 {
02332 array_push($groups, $result_array["id"]);
02333 }
02334 $this->outUserGroupTable("grp", $groups, "group_result", "group_row", $this->lng->txt("search_groups"), $buttons);
02335 }
02336 $searchresult = array();
02337 if ($searchresult = $search->getResultByType("role"))
02338 {
02339 $roles = array();
02340 foreach ($searchresult as $result_array)
02341 {
02342 array_push($roles, $result_array["id"]);
02343 }
02344 $this->outUserGroupTable("role", $roles, "role_result", "role_row", $this->lng->txt("search_roles"), $buttons);
02345 }
02346 }
02347 }
02348 else
02349 {
02350 ilUtil::sendInfo($this->lng->txt("no_user_or_group_selected"));
02351 }
02352 }
02353
02354 if (($this->object->getInvitationMode() == MODE_PREDEFINED_USERS) and ($this->object->getInvitation() == INVITATION_ON))
02355 {
02356 if ($rbacsystem->checkAccess('invite', $this->ref_id))
02357 {
02358 $this->tpl->setCurrentBlock("invitation");
02359 $this->tpl->setVariable("SEARCH_INVITATION", $this->lng->txt("search_invitation"));
02360 $this->tpl->setVariable("SEARCH_TERM", $this->lng->txt("search_term"));
02361 $this->tpl->setVariable("SEARCH_FOR", $this->lng->txt("search_for"));
02362 $this->tpl->setVariable("SEARCH_USERS", $this->lng->txt("objs_usr"));
02363 $this->tpl->setVariable("SEARCH_GROUPS", $this->lng->txt("objs_grp"));
02364 $this->tpl->setVariable("SEARCH_ROLES", $this->lng->txt("objs_role"));
02365 $this->tpl->setVariable("TEXT_CONCATENATION", $this->lng->txt("concatenation"));
02366 $this->tpl->setVariable("TEXT_AND", $this->lng->txt("and"));
02367 $this->tpl->setVariable("TEXT_OR", $this->lng->txt("or"));
02368 $this->tpl->setVariable("VALUE_SEARCH_TERM", $_POST["search_term"]);
02369 if (is_array($searchfor))
02370 {
02371 if (in_array("usr", $searchfor))
02372 {
02373 $this->tpl->setVariable("CHECKED_USERS", " checked=\"checked\"");
02374 }
02375 if (in_array("grp", $searchfor))
02376 {
02377 $this->tpl->setVariable("CHECKED_GROUPS", " checked=\"checked\"");
02378 }
02379 if (in_array("role", $searchfor))
02380 {
02381 $this->tpl->setVariable("CHECKED_ROLES", " checked=\"checked\"");
02382 }
02383 }
02384 if (strcmp($concat, "and") == 0)
02385 {
02386 $this->tpl->setVariable("CHECKED_AND", " checked=\"checked\"");
02387 }
02388 else if (strcmp($concat, "or") == 0)
02389 {
02390 $this->tpl->setVariable("CHECKED_OR", " checked=\"checked\"");
02391 }
02392 $this->tpl->setVariable("SEARCH", $this->lng->txt("search"));
02393 $this->tpl->parseCurrentBlock();
02394 }
02395 }
02396 if ($this->object->getInvitationMode() == MODE_PREDEFINED_USERS)
02397 {
02398 $invited_users = $this->object->getInvitedUsers();
02399 $buttons = array("disinvite");
02400 if (count($invited_users))
02401 {
02402 $this->outUserGroupTable("usr", $invited_users, "invited_user_result", "invited_user_row", $this->lng->txt("invited_users"), $buttons);
02403 }
02404 }
02405 if ($this->object->getInvitation() == INVITATION_ON)
02406 {
02407 $this->tpl->setCurrentBlock("invitation_mode");
02408 $this->tpl->setVariable("TEXT_MODE", $this->lng->txt("invitation_mode"));
02409 $this->tpl->setVariable("VALUE_UNLIMITED", $this->lng->txt("unlimited_users"));
02410 $this->tpl->setVariable("VALUE_PREDEFINED", $this->lng->txt("predefined_users"));
02411 if ($this->object->getInvitationMode() == MODE_PREDEFINED_USERS)
02412 {
02413 $this->tpl->setVariable("SELECTED_PREDEFINED", " selected=\"selected\"");
02414 }
02415 else
02416 {
02417 $this->tpl->setVariable("SELECTED_UNLIMITED", " selected=\"selected\"");
02418 }
02419 $this->tpl->parseCurrentBlock();
02420 }
02421 $this->tpl->setCurrentBlock("adm_content");
02422 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "invite"));
02423 $this->tpl->setVariable("TEXT_INVITATION", $this->lng->txt("invitation"));
02424 $this->tpl->setVariable("VALUE_ON", $this->lng->txt("on"));
02425 $this->tpl->setVariable("VALUE_OFF", $this->lng->txt("off"));
02426 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
02427 if ($this->object->getInvitation() == INVITATION_ON)
02428 {
02429 $this->tpl->setVariable("SELECTED_ON", " selected=\"selected\"");
02430 }
02431 else
02432 {
02433 $this->tpl->setVariable("SELECTED_OFF", " selected=\"selected\"");
02434 }
02435 if ($rbacsystem->checkAccess("write", $this->ref_id) or $rbacsystem->checkAccess('invite', $this->ref_id)) {
02436 $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
02437 $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
02438 }
02439 $this->tpl->parseCurrentBlock();
02440 }
02441
02449 function deleteAllUserDataObject()
02450 {
02451 ilUtil::sendInfo($this->lng->txt("confirm_delete_all_user_data"));
02452 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_maintenance.html", "Modules/Survey");
02453 $this->tpl->setCurrentBlock("confirm_delete");
02454 $this->tpl->setVariable("BTN_CONFIRM_DELETE_ALL", $this->lng->txt("confirm"));
02455 $this->tpl->setVariable("BTN_CANCEL_DELETE_ALL", $this->lng->txt("cancel"));
02456 $this->tpl->parseCurrentBlock();
02457 $this->tpl->setCurrentBlock("adm_content");
02458 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "deleteAllUserData"));
02459 $this->tpl->parseCurrentBlock();
02460 }
02461
02469 function confirmDeleteAllUserDataObject()
02470 {
02471 $this->object->deleteAllUserData();
02472 ilUtil::sendInfo($this->lng->txt("svy_all_user_data_deleted"), true);
02473 $this->ctrl->redirect($this, "maintenance");
02474 }
02475
02483 function cancelDeleteAllUserDataObject()
02484 {
02485 $this->ctrl->redirect($this, "maintenance");
02486 }
02487
02495 function confirmDeleteSelectedUserDataObject()
02496 {
02497 $this->object->removeSelectedSurveyResults($_POST["chbUser"]);
02498 ilUtil::sendInfo($this->lng->txt("svy_selected_user_data_deleted"), true);
02499 $this->ctrl->redirect($this, "maintenance");
02500 }
02501
02509 function cancelDeleteSelectedUserDataObject()
02510 {
02511 $this->ctrl->redirect($this, "maintenance");
02512 }
02513
02521 function deleteSingleUserResultsObject()
02522 {
02523 if (count($_POST["chbUser"]) == 0)
02524 {
02525 $this->ctrl->redirect($this, "maintenance");
02526 }
02527 ilUtil::sendInfo($this->lng->txt("confirm_delete_single_user_data"));
02528 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_maintenance.html", "Modules/Survey");
02529
02530 $this->tpl->setCurrentBlock("confirm_delete_selected");
02531 $this->tpl->setVariable("BTN_CONFIRM_DELETE_SELECTED", $this->lng->txt("confirm"));
02532 $this->tpl->setVariable("BTN_CANCEL_DELETE_SELECTED", $this->lng->txt("cancel"));
02533 $this->tpl->parseCurrentBlock();
02534
02535 foreach ($_POST["chbUser"] as $key => $value)
02536 {
02537 $this->tpl->setCurrentBlock("hidden");
02538 $this->tpl->setVariable("USER_ID", $value);
02539 $this->tpl->parseCurrentBlock();
02540 }
02541
02542 $this->tpl->setCurrentBlock("adm_content");
02543 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "deleteSingleUserResults"));
02544 $this->tpl->parseCurrentBlock();
02545 }
02546
02547 function maintenanceObject()
02548 {
02549 $this->handleWriteAccess();
02550
02551 global $rbacsystem;
02552
02553 if ($rbacsystem->checkAccess("write", $this->ref_id))
02554 {
02555 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_maintenance.html", "Modules/Survey");
02556 $total =& $this->object->getSurveyParticipants();
02557 if (count($total))
02558 {
02559 $color_class = array("tblrow1", "tblrow2");
02560 $counter = 0;
02561 foreach ($total as $user_data)
02562 {
02563 $user_name = $user_data["sortname"];
02564 $user_login = $user_data["login"];
02565 $this->tpl->setCurrentBlock("userrow");
02566 $this->tpl->setVariable("ROW_CLASS", $color_class[$counter % 2]);
02567 $this->tpl->setVariable("USER_ID", $user_data["active_id"]);
02568 $this->tpl->setVariable("VALUE_USER_NAME", $user_name);
02569 $this->tpl->setVariable("VALUE_USER_LOGIN", $user_login);
02570 $last_access = $this->object->_getLastAccess($user_data["active_id"]);
02571 $this->tpl->setVariable("LAST_ACCESS", ilFormat::formatDate(ilFormat::ftimestamp2datetimeDB($last_access)));
02572 $this->tpl->parseCurrentBlock();
02573 $counter++;
02574 }
02575 $this->tpl->setCurrentBlock("selectall");
02576 $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
02577 $counter++;
02578 $this->tpl->setVariable("ROW_CLASS", $color_class[$counter % 2]);
02579 $this->tpl->parseCurrentBlock();
02580 $this->tpl->setCurrentBlock("participanttable");
02581 $this->tpl->setVariable("USER_NAME", $this->lng->txt("name"));
02582 $this->tpl->setVariable("USER_LOGIN", $this->lng->txt("login"));
02583 $this->tpl->setVariable("LAST_ACCESS", $this->lng->txt("last_access"));
02584 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
02585 $this->tpl->setVariable("ARROW", $this->lng->txt("arrow_downright"));
02586 $this->tpl->setVariable("DELETE", $this->lng->txt("delete_user_data"));
02587 $this->tpl->parseCurrentBlock();
02588
02589 $this->tpl->setCurrentBlock("adm_content");
02590 $this->tpl->setVariable("BTN_DELETE_ALL", $this->lng->txt("svy_delete_all_user_data"));
02591
02592 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "deleteSingleUserResults"));
02593 $this->tpl->parseCurrentBlock();
02594 }
02595 else
02596 {
02597 $this->tpl->setCurrentBlock("maintenance_information");
02598 $this->tpl->setVariable("MAINTENANCE_INFORMATION", $this->lng->txt("svy_maintenance_information_no_results"));
02599 $this->tpl->parseCurrentBlock();
02600 }
02601 }
02602 else
02603 {
02604 ilUtil::sendInfo($this->lng->txt("cannot_maintain_survey"));
02605 }
02606 }
02607
02608
02609
02610
02611 function exportObject()
02612 {
02613 $this->handleWriteAccess();
02614
02615 global $tree;
02616 global $rbacsystem;
02617
02618
02619 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
02620
02621
02622 $this->tpl->setCurrentBlock("btn_cell");
02623 $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "createExportFile"));
02624 $this->tpl->setVariable("BTN_TXT", $this->lng->txt("svy_create_export_file"));
02625 $this->tpl->parseCurrentBlock();
02626
02627 $export_dir = $this->object->getExportDirectory();
02628 $export_files = $this->object->getExportFiles($export_dir);
02629
02630
02631 include_once("./Services/Table/classes/class.ilTableGUI.php");
02632 $tbl = new ilTableGUI();
02633
02634
02635 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
02636
02637
02638 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.export_file_row.html", "Modules/Survey");
02639
02640 $num = 0;
02641
02642 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "export"));
02643
02644 $tbl->setTitle($this->lng->txt("svy_export_files"));
02645
02646 $tbl->setHeaderNames(array("", $this->lng->txt("svy_file"),
02647 $this->lng->txt("svy_size"), $this->lng->txt("date") ));
02648
02649 $tbl->enabled["sort"] = false;
02650 $tbl->setColumnWidth(array("1%", "49%", "25%", "25%"));
02651
02652
02653 $tbl->setOrderColumn($_GET["sort_by"]);
02654 $tbl->setOrderDirection($_GET["sort_order"]);
02655 $tbl->setLimit($_GET["limit"]);
02656 $tbl->setOffset($_GET["offset"]);
02657 $tbl->setMaxCount($this->maxcount);
02658
02659 $header_params = $this->ctrl->getParameterArray($this, "export");
02660 $tbl->setHeaderVars(array("", "file", "size", "date"), $header_params);
02661
02662
02663 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
02664
02665
02666 $tbl->setMaxCount(count($export_files));
02667 $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
02668
02669 $tbl->render();
02670 if(count($export_files) > 0)
02671 {
02672 $this->tpl->setVariable("COLUMN_COUNTS", 4);
02673
02674 $i=0;
02675 foreach($export_files as $exp_file)
02676 {
02677 $this->tpl->setCurrentBlock("tbl_content");
02678 $this->tpl->setVariable("TXT_FILENAME", $exp_file);
02679
02680 $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
02681 $this->tpl->setVariable("CSS_ROW", $css_row);
02682
02683 $this->tpl->setVariable("TXT_SIZE", filesize($export_dir."/".$exp_file));
02684 $this->tpl->setVariable("CHECKBOX_ID", $exp_file);
02685
02686 $file_arr = explode("__", $exp_file);
02687 $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s",$file_arr[0]));
02688
02689 $this->tpl->parseCurrentBlock();
02690 }
02691 $this->tpl->setCurrentBlock("selectall");
02692 $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
02693 $this->tpl->setVariable("CSS_ROW", $css_row);
02694 $this->tpl->parseCurrentBlock();
02695
02696 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
02697 $this->tpl->setCurrentBlock("tbl_action_btn");
02698 $this->tpl->setVariable("BTN_NAME", "confirmDeleteExportFile");
02699 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
02700 $this->tpl->parseCurrentBlock();
02701
02702 $this->tpl->setCurrentBlock("tbl_action_btn");
02703 $this->tpl->setVariable("BTN_NAME", "downloadExportFile");
02704 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("download"));
02705 $this->tpl->parseCurrentBlock();
02706 }
02707 else
02708 {
02709 $this->tpl->setCurrentBlock("notfound");
02710 $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
02711 $this->tpl->setVariable("NUM_COLS", 3);
02712 $this->tpl->parseCurrentBlock();
02713 }
02714
02715 $this->tpl->parseCurrentBlock();
02716 }
02717
02721 function createExportFileObject()
02722 {
02723 global $rbacsystem;
02724
02725 if ($rbacsystem->checkAccess("write", $this->ref_id))
02726 {
02727 include_once("./Modules/Survey/classes/class.ilSurveyExport.php");
02728 $survey_exp = new ilSurveyExport($this->object);
02729 $survey_exp->buildExportFile();
02730 $this->ctrl->redirect($this, "export");
02731 }
02732 else
02733 {
02734 ilUtil::sendInfo("cannot_export_survey");
02735 }
02736 }
02737
02743 function importObject()
02744 {
02745 $this->getTemplateFile("import", "svy");
02746 $this->tpl->setCurrentBlock("option_qpl");
02747 include_once("./Modules/Survey/classes/class.ilObjSurvey.php");
02748 $svy = new ilObjSurvey();
02749 $questionpools =& $svy->getAvailableQuestionpools(TRUE, FALSE, TRUE);
02750 if (count($questionpools) == 0)
02751 {
02752 }
02753 else
02754 {
02755 foreach ($questionpools as $key => $value)
02756 {
02757 $this->tpl->setCurrentBlock("option_spl");
02758 $this->tpl->setVariable("OPTION_VALUE", $key);
02759 $this->tpl->setVariable("TXT_OPTION", $value);
02760 $this->tpl->parseCurrentBlock();
02761 }
02762 }
02763 $this->tpl->setVariable("TXT_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool"));
02764 $this->tpl->setVariable("OPTION_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool_option"));
02765 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "import"));
02766 $this->tpl->setVariable("BTN_NAME", "upload");
02767 $this->tpl->setVariable("TXT_UPLOAD", $this->lng->txt("upload"));
02768 $this->tpl->setVariable("TXT_IMPORT_TST", $this->lng->txt("import_tst"));
02769 $this->tpl->setVariable("TXT_SELECT_MODE", $this->lng->txt("select_mode"));
02770 $this->tpl->setVariable("TXT_SELECT_FILE", $this->lng->txt("select_file"));
02771
02772 }
02773
02780 function uploadObject($redirect = true)
02781 {
02782 if ($_POST["spl"] < 1)
02783 {
02784 ilUtil::sendInfo($this->lng->txt("svy_select_questionpools"));
02785 $this->importObject();
02786 return;
02787 }
02788 if (strcmp($_FILES["xmldoc"]["tmp_name"], "") == 0)
02789 {
02790 ilUtil::sendInfo($this->lng->txt("svy_select_file_for_import"));
02791 $this->importObject();
02792 return;
02793 }
02794
02795 include_once("./Modules/Survey/classes/class.ilObjSurvey.php");
02796 $newObj = new ilObjSurvey();
02797 $newObj->setType($_GET["new_type"]);
02798 $newObj->setTitle("dummy");
02799 $newObj->setDescription("dummy");
02800 $newObj->create(true);
02801 $newObj->createReference();
02802 $newObj->putInTree($_GET["ref_id"]);
02803 $newObj->setPermissions($_GET["ref_id"]);
02804 $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
02805
02806 $error = $newObj->importObject($_FILES["xmldoc"], $_POST["spl"]);
02807 if (strlen($error))
02808 {
02809 $newObj->delete();
02810 $this->ilias->raiseError($error, $this->ilias->error_obj->MESSAGE);
02811 return;
02812 }
02813 else
02814 {
02815 $ref_id = $newObj->getRefId();
02816 }
02817 if ($redirect)
02818 {
02819 include_once "./Services/Utilities/classes/class.ilUtil.php";
02820 ilUtil::redirect($this->getReturnLocation("upload",$this->ctrl->getTargetScript()."?".$this->link_params));
02821 }
02822 return $ref_id;
02823 }
02824
02828 function createObject()
02829 {
02830 global $rbacsystem;
02831 $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
02832 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
02833 {
02834 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
02835 }
02836 else
02837 {
02838 $this->getTemplateFile("create", $new_type);
02839
02840 include_once("./Modules/Survey/classes/class.ilObjSurvey.php");
02841 $svy = new ilObjSurvey();
02842
02843 $this->fillCloneTemplate('DUPLICATE','svy');
02844 $questionpools =& $svy->getAvailableQuestionpools($use_obj_id = TRUE, $could_be_offline = TRUE, $showPath = TRUE);
02845 if (count($questionpools) > 0)
02846 {
02847 foreach ($questionpools as $key => $value)
02848 {
02849 $this->tpl->setCurrentBlock("option_spl");
02850 $this->tpl->setVariable("OPTION_VALUE", $key);
02851 $this->tpl->setVariable("TXT_OPTION", $value);
02852 if ($_POST["spl"] == $key)
02853 {
02854 $this->tpl->setVariable("OPTION_SELECTED", " selected=\"selected\"");
02855 }
02856 $this->tpl->parseCurrentBlock();
02857 }
02858 }
02859
02860 $data = array();
02861 $data["fields"] = array();
02862 include_once "./Services/Utilities/classes/class.ilUtil.php";
02863 $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
02864 $data["fields"]["desc"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["desc"]);
02865
02866 foreach ($data["fields"] as $key => $val)
02867 {
02868 $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
02869 $this->tpl->setVariable(strtoupper($key), $val);
02870
02871 if ($this->prepare_output)
02872 {
02873 $this->tpl->parseCurrentBlock();
02874 }
02875 }
02876
02877 $this->ctrl->setParameter($this, "new_type", $this->type);
02878 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "create"));
02879 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
02880 $this->tpl->setVariable("TXT_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool_short"));
02881 $this->tpl->setVariable("OPTION_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool_option"));
02882 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
02883 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
02884 $this->tpl->setVariable("CMD_SUBMIT", "save");
02885 $this->tpl->setVariable("TARGET", ' target="'.
02886 ilFrameTargetInfo::_getFrame("MainContent").'" ');
02887 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
02888
02889 $this->tpl->setVariable("TXT_IMPORT_SVY", $this->lng->txt("import_svy"));
02890 $this->tpl->setVariable("TXT_SVY_FILE", $this->lng->txt("svy_upload_file"));
02891 $this->tpl->setVariable("TXT_IMPORT", $this->lng->txt("import"));
02892
02893 $this->tpl->setVariable("TYPE_IMG", ilUtil::getImagePath('icon_svy.gif'));
02894 $this->tpl->setVariable("ALT_IMG",$this->lng->txt("obj_svy"));
02895 $this->tpl->setVariable("TYPE_IMG2", ilUtil::getImagePath('icon_svy.gif'));
02896 $this->tpl->setVariable("ALT_IMG2",$this->lng->txt("obj_svy"));
02897 }
02898 }
02899
02903 function importFileObject()
02904 {
02905 if ($_POST["spl"] < 1)
02906 {
02907 ilUtil::sendInfo($this->lng->txt("svy_select_questionpools"));
02908 $this->createObject();
02909 return;
02910 }
02911 if (strcmp($_FILES["xmldoc"]["tmp_name"], "") == 0)
02912 {
02913 ilUtil::sendInfo($this->lng->txt("svy_select_file_for_import"));
02914 $this->createObject();
02915 return;
02916 }
02917 $this->ctrl->setParameter($this, "new_type", $this->type);
02918 $ref_id = $this->uploadObject(false);
02919
02920 ilUtil::sendInfo($this->lng->txt("object_imported"),true);
02921
02922 ilUtil::redirect("ilias.php?ref_id=".$ref_id.
02923 "&baseClass=ilObjSurveyGUI");
02924
02925 }
02926
02930 function downloadExportFileObject()
02931 {
02932 if(!isset($_POST["file"]))
02933 {
02934 ilUtil::sendInfo($this->lng->txt("no_checkbox"), true);
02935 $this->ctrl->redirect($this, "export");
02936 }
02937
02938 if (count($_POST["file"]) > 1)
02939 {
02940 ilUtil::sendInfo($this->lng->txt("select_max_one_item"), true);
02941 $this->ctrl->redirect($this, "export");
02942 }
02943
02944
02945 $export_dir = $this->object->getExportDirectory();
02946 include_once "./Services/Utilities/classes/class.ilUtil.php";
02947 ilUtil::deliverFile($export_dir."/".$_POST["file"][0],
02948 $_POST["file"][0]);
02949 }
02950
02954 function confirmDeleteExportFileObject()
02955 {
02956 if(!isset($_POST["file"]))
02957 {
02958 ilUtil::sendInfo($this->lng->txt("no_checkbox"), true);
02959 $this->ctrl->redirect($this, "export");
02960 }
02961
02962
02963
02964
02965 $_SESSION["ilExportFiles"] = $_POST["file"];
02966
02967 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html", "Modules/Survey");
02968
02969 ilUtil::sendInfo($this->lng->txt("info_delete_sure"));
02970
02971 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "deleteExportFile"));
02972
02973
02974 $this->tpl->setCurrentBlock("table_header");
02975 $this->tpl->setVariable("TEXT",$this->lng->txt("objects"));
02976 $this->tpl->parseCurrentBlock();
02977
02978
02979 $counter = 0;
02980 include_once "./Services/Utilities/classes/class.ilUtil.php";
02981 foreach($_POST["file"] as $file)
02982 {
02983 $this->tpl->setCurrentBlock("table_row");
02984 $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_file.gif"));
02985 $this->tpl->setVariable("TEXT_IMG_OBJ", $this->lng->txt("file_icon"));
02986 $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
02987 $this->tpl->setVariable("TEXT_CONTENT", $file);
02988 $this->tpl->parseCurrentBlock();
02989 }
02990
02991
02992 $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
02993 $buttons = array("deleteExportFile" => $this->lng->txt("confirm"),
02994 "cancelDeleteExportFile" => $this->lng->txt("cancel"));
02995 foreach ($buttons as $name => $value)
02996 {
02997 $this->tpl->setCurrentBlock("operation_btn");
02998 $this->tpl->setVariable("BTN_NAME",$name);
02999 $this->tpl->setVariable("BTN_VALUE",$value);
03000 $this->tpl->parseCurrentBlock();
03001 }
03002 }
03003
03004
03008 function cancelDeleteExportFileObject()
03009 {
03010 session_unregister("ilExportFiles");
03011 $this->ctrl->redirect($this, "export");
03012 }
03013
03014
03018 function deleteExportFileObject()
03019 {
03020 $export_dir = $this->object->getExportDirectory();
03021 foreach($_SESSION["ilExportFiles"] as $file)
03022 {
03023 $exp_file = $export_dir."/".$file;
03024 $exp_dir = $export_dir."/".substr($file, 0, strlen($file) - 4);
03025 if (@is_file($exp_file))
03026 {
03027 unlink($exp_file);
03028 }
03029 if (@is_dir($exp_dir))
03030 {
03031 include_once "./Services/Utilities/classes/class.ilUtil.php";
03032 ilUtil::delDir($exp_dir);
03033 }
03034 }
03035 $this->ctrl->redirect($this, "export");
03036 }
03037
03038 function setCodeLanguageObject()
03039 {
03040 if (strcmp($_POST["lang"], "-1") != 0)
03041 {
03042 global $ilUser;
03043 $ilUser->writePref("survey_code_language", $_POST["lang"]);
03044 }
03045 $this->ctrl->redirect($this, "codes");
03046 }
03047
03055 function codesObject()
03056 {
03057 $this->handleWriteAccess();
03058
03059 if ($this->object->getAnonymize() != 1)
03060 {
03061 return ilUtil::sendInfo($this->lng->txt("survey_codes_no_anonymization"));
03062 }
03063 global $rbacsystem;
03064 global $ilUser;
03065
03066 $default_lang = $ilUser->getPref("survey_code_language");
03067 $tableoutput = "";
03068
03069 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_codes.html", true);
03070 if ($rbacsystem->checkAccess("write", $this->ref_id))
03071 {
03072 $codecount = $this->object->getSurveyCodesCount();
03073 if ($codecount)
03074 {
03075 $maxentries = $ilUser->getPref("hits_per_page");
03076 if ($maxentries < 1)
03077 {
03078 $maxentries = 9999;
03079 }
03080
03081 $survey_codes =& $this->object->getSurveyCodesTableData($default_lang, $_GET["offset"], $maxentries, $_GET["sort_by"], $_GET["sort_order"]);
03082 $headervars = array("", "counter", "date", "used", "url");
03083
03084 include_once "./Services/Table/classes/class.ilTableGUI.php";
03085 $tbl = new ilTableGUI(0, FALSE);
03086 $tbl->setTitle($this->lng->txt("survey_code"));
03087 $header_names = array(
03088 "",
03089 $this->lng->txt("survey_code"),
03090 $this->lng->txt("create_date"),
03091 $this->lng->txt("survey_code_used"),
03092 $this->lng->txt("survey_code_url")
03093 );
03094 $tbl->setHeaderNames($header_names);
03095
03096 $tbl->disable("sort");
03097 $tbl->disable("auto_sort");
03098 $tbl->disable("title");
03099 $tbl->disable("form");
03100 $tbl->enable("action");
03101 $tbl->enable("select_all");
03102 $tbl->setLimit($maxentries);
03103 $tbl->setOffset($_GET["offset"]);
03104 $tbl->setData($survey_codes);
03105 $tbl->setMaxCount($codecount);
03106 $tbl->setOrderDirection($_GET["sort_order"]);
03107 $tbl->setSelectAllCheckbox("chb_code");
03108 $tbl->setFormName("form_codes");
03109 $tbl->addActionButton("deleteCodes", $this->lng->txt("delete"));
03110 $tbl->addActionButton("exportCodes", $this->lng->txt("export"));
03111
03112 $header_params = $this->ctrl->getParameterArray($this, "codes");
03113 $tbl->setHeaderVars($headervars, $header_params);
03114
03115
03116 $tbl->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next"));
03117
03118 $tableoutput = $tbl->render();
03119 $this->tpl->setCurrentBlock("exportall");
03120 $this->tpl->setVariable("VALUE_EXPORT_ALL_CODES", $this->lng->txt("export_all_survey_codes"));
03121 $this->tpl->parseCurrentBlock();
03122 }
03123 else
03124 {
03125 $this->tpl->setCurrentBlock("emptyrow");
03126 $this->tpl->setVariable("NO_CODES", $this->lng->txt("survey_code_no_codes"));
03127 $this->tpl->parseCurrentBlock();
03128 }
03129
03130 $languages = $this->lng->getInstalledLanguages();
03131 foreach ($languages as $lang)
03132 {
03133 $this->tpl->setCurrentBlock("option_lang");
03134 $this->tpl->setVariable("VALUE_LANG", $lang);
03135 $this->tpl->setVariable("TEXT_LANG", $this->lng->txt("lang_$lang"));
03136 if (strcmp($lang, $default_lang) == 0)
03137 {
03138 $this->tpl->setVariable("SELECTED_LANG", " selected=\"selected\"");
03139 }
03140 $this->tpl->parseCurrentBlock();
03141 }
03142
03143 $this->tpl->setCurrentBlock("adm_content");
03144 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "codes"));
03145 $this->tpl->setVariable("CODES_TABLE", $tableoutput);
03146 $this->tpl->setVariable("TEXT_CREATE", $this->lng->txt("create"));
03147 $this->tpl->setVariable("TEXT_SURVEY_CODES", $this->lng->txt("new_survey_codes"));
03148 $this->tpl->setVariable("TEXT_SURVEY_CODES_LANG", $this->lng->txt("survey_codes_lang"));
03149 $this->tpl->setVariable("TEXT_NO_LANGUAGE_SELECTED", $this->lng->txt("please_select"));
03150 $this->tpl->setVariable("VALUE_ACTIVATE", $this->lng->txt("select"));
03151 $this->tpl->parseCurrentBlock();
03152 }
03153 else
03154 {
03155 ilUtil::sendInfo($this->lng->txt("cannot_create_survey_codes"));
03156 }
03157 }
03158
03166 function deleteCodesObject()
03167 {
03168 if (is_array($_POST["chb_code"]) && (count($_POST["chb_code"]) > 0))
03169 {
03170 foreach ($_POST["chb_code"] as $survey_code)
03171 {
03172 $this->object->deleteSurveyCode($survey_code);
03173 }
03174 }
03175 $this->codesObject();
03176 }
03177
03185 function exportCodesObject()
03186 {
03187 if (is_array($_POST["chb_code"]) && (count($_POST["chb_code"]) > 0))
03188 {
03189 $export = $this->object->getSurveyCodesForExport($_POST["chb_code"]);
03190 ilUtil::deliverData($export, ilUtil::getASCIIFilename($this->object->getTitle() . ".txt"));
03191 }
03192 else
03193 {
03194 $this->codesObject();
03195 }
03196 }
03197
03205 function exportAllCodesObject()
03206 {
03207 $export = $this->object->getSurveyCodesForExport(array());
03208 ilUtil::deliverData($export, ilUtil::getASCIIFilename($this->object->getTitle() . ".txt"));
03209 }
03210
03218 function createSurveyCodesObject()
03219 {
03220 if (preg_match("/\d+/", $_POST["nrOfCodes"]))
03221 {
03222 $this->object->createSurveyCodes($_POST["nrOfCodes"]);
03223 }
03224 else
03225 {
03226 ilUtil::sendInfo($this->lng->txt("enter_valid_number_of_codes"), true);
03227 }
03228 $this->ctrl->redirect($this, "codes");
03229 }
03230
03238 function addConstraintForm($step, $postvalues, &$survey_questions, $questions = FALSE)
03239 {
03240 $this->ctrl->saveParameter($this, "preid");
03241 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_add_constraint.html", "Modules/Survey");
03242 if (is_array($questions))
03243 {
03244 foreach ($questions as $question)
03245 {
03246 $this->tpl->setCurrentBlock("option_q");
03247 $this->tpl->setVariable("OPTION_VALUE", $question["question_id"]);
03248 $this->tpl->setVariable("OPTION_TEXT", $question["title"] . " (" . $this->lng->txt($question["type_tag"]) . ")");
03249 if ($question["question_id"] == $postvalues["q"])
03250 {
03251 $this->tpl->setVariable("OPTION_CHECKED", " selected=\"selected\"");
03252 }
03253 $this->tpl->parseCurrentBlock();
03254 }
03255 }
03256 if ($step > 1)
03257 {
03258 $relations = $this->object->getAllRelations();
03259 foreach ($relations as $rel_id => $relation)
03260 {
03261 if (in_array($relation["short"], $survey_questions[$postvalues["q"]]["availableRelations"]))
03262 {
03263 $this->tpl->setCurrentBlock("option_r");
03264 $this->tpl->setVariable("OPTION_VALUE", $rel_id);
03265 $this->tpl->setVariable("OPTION_TEXT", $relation["short"]);
03266 if ($rel_id == $postvalues["r"])
03267 {
03268 $this->tpl->setVariable("OPTION_CHECKED", " selected=\"selected\"");
03269 }
03270 $this->tpl->parseCurrentBlock();
03271 }
03272 }
03273 $this->tpl->setCurrentBlock("select_relation");
03274 $this->tpl->setVariable("SELECT_RELATION", $this->lng->txt("step") . " 2: " . $this->lng->txt("select_relation"));
03275 $this->tpl->parseCurrentBlock();
03276 }
03277
03278 if ($step > 2)
03279 {
03280 $variables =& $this->object->getVariables($postvalues["q"]);
03281 $question_type = $survey_questions[$postvalues["q"]]["type_tag"];
03282 include_once "./Modules/SurveyQuestionPool/classes/class.$question_type.php";
03283 $question = new $question_type();
03284 $question->loadFromDb($postvalues["q"]);
03285 $select_value = $question->getPreconditionSelectValue($postvalues["v"]);
03286 $this->tpl->setCurrentBlock("select_value");
03287 $this->tpl->setVariable("SELECT_VALUE", $select_value);
03288 $this->tpl->parseCurrentBlock();
03289 }
03290
03291 $this->tpl->setCurrentBlock("buttons");
03292 $this->tpl->setVariable("BTN_CONTINUE", $this->lng->txt("continue"));
03293 switch ($step)
03294 {
03295 case 1:
03296 $this->tpl->setVariable("COMMAND", "constraintStep2");
03297 $this->tpl->setVariable("COMMAND_BACK", "constraints");
03298 break;
03299 case 2:
03300 $this->tpl->setVariable("COMMAND", "constraintStep3");
03301 $this->tpl->setVariable("COMMAND_BACK", "constraintStep1");
03302 break;
03303 case 3:
03304 $this->tpl->setVariable("COMMAND", "constraintsAdd");
03305 $this->tpl->setVariable("COMMAND_BACK", "constraintStep2");
03306 break;
03307 }
03308 $this->tpl->setVariable("BTN_BACK", $this->lng->txt("back"));
03309 $this->tpl->parseCurrentBlock();
03310 $this->tpl->setCurrentBlock("adm_content");
03311 $title = "";
03312 if ($survey_questions[$_SESSION["constraintstructure"][$_GET["start"]][0]]["questionblock_id"] > 0)
03313 {
03314 $title = $this->lng->txt("questionblock") . ": " . $survey_questions[$_SESSION["constraintstructure"][$_GET["start"]][0]]["questionblock_title"];
03315 }
03316 else
03317 {
03318 $title = $this->lng->txt($survey_questions[$_SESSION["constraintstructure"][$_GET["start"]][0]]["type_tag"]) . ": " . $survey_questions[$_SESSION["constraintstructure"][$_GET["start"]][0]]["title"];
03319 }
03320 $this->tpl->setVariable("CONSTRAINT_QUESTION_TEXT", $title);
03321 $this->tpl->setVariable("SELECT_PRIOR_QUESTION", $this->lng->txt("step") . " 1: " . $this->lng->txt("select_prior_question"));
03322 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this) . "&start=" . $_GET["start"]);
03323 $this->tpl->parseCurrentBlock();
03324 }
03325
03333 function constraintsAddObject()
03334 {
03335 if (strlen($_POST["v"]) == 0)
03336 {
03337 ilUtil::sendInfo($this->lng->txt("msg_enter_value_for_valid_constraint"));
03338 return $this->constraintStep3Object();
03339 }
03340 $survey_questions =& $this->object->getSurveyQuestions();
03341 $structure =& $_SESSION["constraintstructure"];
03342 $include_elements = $_SESSION["includeElements"];
03343 foreach ($include_elements as $elementCounter)
03344 {
03345 if (is_array($structure[$elementCounter]))
03346 {
03347 foreach ($structure[$elementCounter] as $key => $question_id)
03348 {
03349 if (strlen($_GET["preid"]))
03350 {
03351 $this->object->updateConstraint($question_id, $_POST["q"], $_POST["r"], $_POST["v"]);
03352 }
03353 else
03354 {
03355 $this->object->addConstraint($question_id, $_POST["q"], $_POST["r"], $_POST["v"]);
03356 }
03357 }
03358 }
03359 }
03360 unset($_SESSION["includeElements"]);
03361 unset($_SESSION["constraintstructure"]);
03362 $this->ctrl->redirect($this, "constraints");
03363 }
03364
03372 function constraintStep3Object()
03373 {
03374 $survey_questions =& $this->object->getSurveyQuestions();
03375 $option_questions = array();
03376 if (strlen($_GET["precondition"]))
03377 {
03378 $pc = $this->object->getPrecondition($_GET["precondition"]);
03379 $postvalues = array(
03380 "q" => $pc["question_fi"],
03381 "r" => $pc["relation_id"],
03382 "v" => $pc["value"]
03383 );
03384 $this->ctrl->setParameter($this, "preid", $_GET["precondition"]);
03385 array_push($option_questions, array("question_id" => $pc["question_fi"], "title" => $survey_questions[$pc["question_fi"]]["title"], "type_tag" => $survey_questions[$pc["question_fi"]]["type_tag"]));
03386 $this->addConstraintForm(3, $postvalues, $survey_questions, $option_questions);
03387 }
03388 else
03389 {
03390 array_push($option_questions, array("question_id" => $_POST["q"], "title" => $survey_questions[$_POST["q"]]["title"], "type_tag" => $survey_questions[$_POST["q"]]["type_tag"]));
03391 $this->addConstraintForm(3, $_POST, $survey_questions, $option_questions);
03392 }
03393 }
03394
03402 function constraintStep2Object()
03403 {
03404 $survey_questions =& $this->object->getSurveyQuestions();
03405 $option_questions = array();
03406 array_push($option_questions, array("question_id" => $_POST["q"], "title" => $survey_questions[$_POST["q"]]["title"], "type_tag" => $survey_questions[$_POST["q"]]["type_tag"]));
03407 $this->addConstraintForm(2, $_POST, $survey_questions, $option_questions);
03408 }
03409
03417 function constraintStep1Object()
03418 {
03419 $survey_questions =& $this->object->getSurveyQuestions();
03420 $structure =& $_SESSION["constraintstructure"];
03421 $start = $_GET["start"];
03422 $option_questions = array();
03423 for ($i = 1; $i < $start; $i++)
03424 {
03425 if (is_array($structure[$i]))
03426 {
03427 foreach ($structure[$i] as $key => $question_id)
03428 {
03429 if ($survey_questions[$question_id]["usableForPrecondition"])
03430 {
03431 array_push($option_questions, array("question_id" => $survey_questions[$question_id]["question_id"], "title" => $survey_questions[$question_id]["title"], "type_tag" => $survey_questions[$question_id]["type_tag"]));
03432 }
03433 }
03434 }
03435 }
03436 if (count($option_questions) == 0)
03437 {
03438 unset($_SESSION["includeElements"]);
03439 unset($_SESSION["constraintstructure"]);
03440 ilUtil::sendInfo($this->lng->txt("constraints_no_nonessay_available"), true);
03441 $this->ctrl->redirect($this, "constraints");
03442 }
03443 $this->addConstraintForm(1, $_POST, $survey_questions, $option_questions);
03444 }
03445
03453 function deleteConstraintsObject()
03454 {
03455 $survey_questions =& $this->object->getSurveyQuestions();
03456 $structure =& $_SESSION["constraintstructure"];
03457 foreach ($_POST as $key => $value)
03458 {
03459 if (preg_match("/^constraint_(\d+)_(\d+)/", $key, $matches))
03460 {
03461 foreach ($structure[$matches[1]] as $key => $question_id)
03462 {
03463 $this->object->deleteConstraint($matches[2], $question_id);
03464 }
03465 }
03466 }
03467
03468 $this->ctrl->redirect($this, "constraints");
03469 }
03470
03471 function createConstraintsObject()
03472 {
03473 $include_elements = $_POST["includeElements"];
03474 if ((!is_array($include_elements)) || (count($include_elements) == 0))
03475 {
03476 ilUtil::sendInfo($this->lng->txt("constraints_no_questions_or_questionblocks_selected"), true);
03477 $this->ctrl->redirect($this, "constraints");
03478 }
03479 else if (count($include_elements) >= 1)
03480 {
03481 $_SESSION["includeElements"] = $include_elements;
03482 sort($include_elements, SORT_NUMERIC);
03483 $_GET["start"] = $include_elements[0];
03484 $this->constraintStep1Object();
03485 }
03486 }
03487
03488 function editPreconditionObject()
03489 {
03490 $_SESSION["includeElements"] = array($_GET["start"]);
03491 $this->ctrl->setParameter($this, "precondition", $_GET["precondition"]);
03492 $this->ctrl->setParameter($this, "start", $_GET["start"]);
03493 $this->ctrl->redirect($this, "constraintStep3");
03494 }
03495
03503 function constraintsObject()
03504 {
03505 $this->handleWriteAccess();
03506
03507 global $rbacsystem;
03508
03509 $hasDatasets = $this->object->_hasDatasets($this->object->getSurveyId());
03510 $step = 0;
03511 if (array_key_exists("step", $_GET)) $step = $_GET["step"];
03512 switch ($step)
03513 {
03514 case 1:
03515 $this->constraintStep1Object();
03516 return;
03517 break;
03518 case 2:
03519 return;
03520 break;
03521 case 3:
03522 return;
03523 break;
03524 }
03525
03526 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_constraints_list.html", "Modules/Survey");
03527 $survey_questions =& $this->object->getSurveyQuestions();
03528 $last_questionblock_title = "";
03529 $counter = 1;
03530 $hasPreconditions = FALSE;
03531 $structure = array();
03532 $colors = array("tblrow1", "tblrow2");
03533 foreach ($survey_questions as $question_id => $data)
03534 {
03535 $title = $data["title"];
03536 $show = true;
03537 if ($data["questionblock_id"] > 0)
03538 {
03539 $title = $data["questionblock_title"];
03540 $type = $this->lng->txt("questionblock");
03541 if (strcmp($title, $last_questionblock_title) != 0)
03542 {
03543 $last_questionblock_title = $title;
03544 $structure[$counter] = array();
03545 array_push($structure[$counter], $data["question_id"]);
03546 }
03547 else
03548 {
03549 array_push($structure[$counter-1], $data["question_id"]);
03550 $show = false;
03551 }
03552 }
03553 else
03554 {
03555 $structure[$counter] = array($data["question_id"]);
03556 $type = $this->lng->txt("question");
03557 }
03558 if ($show)
03559 {
03560 if ($counter == 1)
03561 {
03562 $this->tpl->setCurrentBlock("description");
03563 $this->tpl->setVariable("DESCRIPTION", $this->lng->txt("constraints_first_question_description"));
03564 $this->tpl->parseCurrentBlock();
03565 }
03566 else
03567 {
03568 $constraints =& $this->object->getConstraints($data["question_id"]);
03569 $rowcount = 0;
03570 if (count($constraints))
03571 {
03572 $hasPreconditions = TRUE;
03573 foreach ($constraints as $constraint)
03574 {
03575 $this->tpl->setCurrentBlock("constraint");
03576 $this->tpl->setVariable("CONSTRAINT_TEXT", $survey_questions[$constraint["question"]]["title"] . " " . $constraint["short"] . " " . $constraint["valueoutput"]);
03577 $this->tpl->setVariable("SEQUENCE_ID", $counter);
03578 $this->tpl->setVariable("CONSTRAINT_ID", $constraint["id"]);
03579 $this->tpl->setVariable("COLOR_CLASS", $colors[$rowcount % 2]);
03580 $this->tpl->setVariable("TEXT_EDIT_PRECONDITION", $this->lng->txt("edit"));
03581 $this->ctrl->setParameter($this, "precondition", $constraint["id"]);
03582 $this->ctrl->setParameter($this, "start", $counter);
03583 $this->tpl->setVariable("EDIT_PRECONDITION", $this->ctrl->getLinkTarget($this, "editPrecondition"));
03584 $this->ctrl->setParameter($this, "precondition", "");
03585 $this->ctrl->setParameter($this, "start", "");
03586 $rowcount++;
03587 $this->tpl->parseCurrentBlock();
03588 }
03589 }
03590 }
03591 if ($counter != 1)
03592 {
03593 $this->tpl->setCurrentBlock("include_elements");
03594 $this->tpl->setVariable("QUESTION_NR", "$counter");
03595 $this->tpl->parseCurrentBlock();
03596 }
03597 $this->tpl->setCurrentBlock("constraint_section");
03598 $this->tpl->setVariable("QUESTION_NR", "$counter");
03599 $this->tpl->setVariable("TITLE", "$title");
03600 $icontype = "question.gif";
03601 if ($data["questionblock_id"] > 0)
03602 {
03603 $icontype = "questionblock.gif";
03604 $this->tpl->setVariable("TYPE", "$type: ");
03605 }
03606 include_once "./Services/Utilities/classes/class.ilUtil.php";
03607 $this->tpl->setVariable("ICON_HREF", ilUtil::getImagePath($icontype, "Modules/Survey"));
03608 $this->tpl->setVariable("ICON_ALT", $type);
03609 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
03610 $this->tpl->parseCurrentBlock();
03611 $counter++;
03612 }
03613 }
03614 if ($rbacsystem->checkAccess("write", $this->ref_id) and !$hasDatasets)
03615 {
03616 $this->tpl->setCurrentBlock("selectall");
03617 $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
03618 $counter++;
03619 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
03620 if ($hasPreconditions)
03621 {
03622 $this->tpl->setVariable("SELECT_ALL_PRECONDITIONS", $this->lng->txt("select_all"));
03623 }
03624 $this->tpl->parseCurrentBlock();
03625
03626 if ($hasPreconditions)
03627 {
03628 $this->tpl->setCurrentBlock("delete_button");
03629 $this->tpl->setVariable("BTN_DELETE", $this->lng->txt("delete"));
03630 include_once "./Services/Utilities/classes/class.ilUtil.php";
03631 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\">");
03632 $this->tpl->parseCurrentBlock();
03633 }
03634
03635 $this->tpl->setCurrentBlock("buttons");
03636 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\">");
03637 $this->tpl->setVariable("BTN_CREATE_CONSTRAINTS", $this->lng->txt("constraint_add"));
03638 $this->tpl->parseCurrentBlock();
03639 }
03640 $this->tpl->setCurrentBlock("adm_content");
03641 $this->tpl->setVariable("CONSTRAINTS_INTRODUCTION", $this->lng->txt("constraints_introduction"));
03642 $this->tpl->setVariable("DEFINED_PRECONDITIONS", $this->lng->txt("existing_constraints"));
03643 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "constraints"));
03644 $this->tpl->setVariable("CONSTRAINTS_HEADER", $this->lng->txt("constraints_list_of_entities"));
03645 $this->tpl->parseCurrentBlock();
03646 $_SESSION["constraintstructure"] = $structure;
03647 if ($hasDatasets)
03648 {
03649 ilUtil::sendInfo($this->lng->txt("survey_has_datasets_warning"));
03650 }
03651 }
03652
03658 function infoScreenObject()
03659 {
03660 $this->ctrl->setCmd("showSummary");
03661 $this->ctrl->setCmdClass("ilinfoscreengui");
03662 $this->infoScreen();
03663 }
03664
03665 function setNewTemplate()
03666 {
03667 global $tpl;
03668 $tpl = new ilTemplate("tpl.il_svy_svy_main.html", TRUE, TRUE, "Modules/Survey");
03669
03670 $location_stylesheet = ilUtil::getStyleSheetLocation();
03671 $tpl->setVariable("LOCATION_STYLESHEET",$location_stylesheet);
03672 $tpl->setVariable("LOCATION_JAVASCRIPT",dirname($location_stylesheet));
03673 }
03674
03678 function infoScreen()
03679 {
03680 global $ilAccess;
03681 global $ilUser;
03682
03683 if (!$ilAccess->checkAccess("visible", "", $this->ref_id))
03684 {
03685 $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
03686 }
03687
03688 include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
03689 $info = new ilInfoScreenGUI($this);
03690 include_once "./Modules/Survey/classes/class.ilSurveyExecutionGUI.php";
03691 $output_gui =& new ilSurveyExecutionGUI($this->object);
03692 $info->setFormAction($this->ctrl->getFormAction($output_gui, "infoScreen"));
03693 $info->enablePrivateNotes();
03694 $anonymize_key = NULL;
03695 if ($this->object->getAnonymize() == 1)
03696 {
03697 if ($_SESSION["anonymous_id"])
03698 {
03699 $anonymize_key = $_SESSION["anonymous_id"];
03700 }
03701 else if ($_POST["anonymous_id"])
03702 {
03703 $anonymize_key = $_POST["anonymous_id"];
03704 }
03705 }
03706 $canStart = $this->object->canStartSurvey($anonymize_key);
03707 $showButtons = $canStart["result"];
03708 if (!$showButtons) ilUtil::sendInfo(implode("<br />", $canStart["messages"]));
03709
03710 if ($showButtons)
03711 {
03712
03713 if (!$this->object->getAnonymize())
03714 {
03715 $survey_started = $this->object->isSurveyStarted($ilUser->getId(), "");
03716
03717 if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
03718 {
03719 ilUtil::sendInfo($this->lng->txt("anonymous_with_personalized_survey"));
03720 }
03721 else
03722 {
03723 if ($survey_started === 1)
03724 {
03725 ilUtil::sendInfo($this->lng->txt("already_completed_survey"));
03726 }
03727 elseif ($survey_started === 0)
03728 {
03729 $info->addFormButton("resume", $this->lng->txt("resume_survey"));
03730 }
03731 elseif ($survey_started === FALSE)
03732 {
03733 $info->addFormButton("start", $this->lng->txt("start_survey"));
03734 }
03735 }
03736 }
03737
03738 else if ($this->object->getAnonymize() && !$this->object->isAccessibleWithoutCode())
03739 {
03740 if (($_SESSION["AccountId"] == ANONYMOUS_USER_ID) && (strlen($_POST["anonymous_id"]) == 0) && (strlen($_SESSION["anonymous_id"]) == 0))
03741 {
03742 $info->setFormAction($this->ctrl->getFormAction($this, "infoScreen"));
03743 $info->addSection($this->lng->txt("anonymization"));
03744 $info->addProperty("", $this->lng->txt("anonymize_anonymous_introduction"));
03745 $info->addPropertyTextinput($this->lng->txt("enter_anonymous_id"), "anonymous_id", "", 8, "infoScreen", $this->lng->txt("submit"));
03746 }
03747 else
03748 {
03749 if (strlen($_POST["anonymous_id"]) > 0)
03750 {
03751 if (!$this->object->checkSurveyCode($_POST["anonymous_id"]))
03752 {
03753 ilUtil::sendInfo($this->lng->txt("wrong_survey_code_used"));
03754 }
03755 else
03756 {
03757 $anonymize_key = $_POST["anonymous_id"];
03758 }
03759 }
03760 else if (strlen($_SESSION["anonymous_id"]) > 0)
03761 {
03762 if (!$this->object->checkSurveyCode($_SESSION["anonymous_id"]))
03763 {
03764 ilUtil::sendInfo($this->lng->txt("wrong_survey_code_used"));
03765 }
03766 else
03767 {
03768 $anonymize_key = $_SESSION["anonymous_id"];
03769 }
03770 }
03771 else
03772 {
03773
03774 $anonymize_key = $this->object->getUserAccessCode($ilUser->getId());
03775 if (!strlen($anonymize_key))
03776 {
03777 $anonymize_key = $this->object->createNewAccessCode();
03778 $this->object->saveUserAccessCode($ilUser->getId(), $anonymize_key);
03779 }
03780 }
03781 $info->addHiddenElement("anonymous_id", $anonymize_key);
03782 $survey_started = $this->object->isSurveyStarted($ilUser->getId(), $anonymize_key);
03783 if ($survey_started === 1)
03784 {
03785 ilUtil::sendInfo($this->lng->txt("already_completed_survey"));
03786 }
03787 elseif ($survey_started === 0)
03788 {
03789 $info->addFormButton("resume", $this->lng->txt("resume_survey"));
03790 }
03791 elseif ($survey_started === FALSE)
03792 {
03793 $info->addFormButton("start", $this->lng->txt("start_survey"));
03794 }
03795 }
03796 }
03797 else
03798 {
03799
03800 $survey_started = $this->object->isSurveyStarted($ilUser->getId(), "");
03801 if ($survey_started === 1)
03802 {
03803 ilUtil::sendInfo($this->lng->txt("already_completed_survey"));
03804 }
03805 elseif ($survey_started === 0)
03806 {
03807 $info->addFormButton("resume", $this->lng->txt("resume_survey"));
03808 }
03809 elseif ($survey_started === FALSE)
03810 {
03811 $info->addFormButton("start", $this->lng->txt("start_survey"));
03812 }
03813 }
03814 }
03815
03816 if (strlen($this->object->getIntroduction()))
03817 {
03818 $introduction = $this->object->getIntroduction();
03819 $info->addSection($this->lng->txt("introduction"));
03820 $info->addProperty("", $this->object->prepareTextareaOutput($introduction));
03821 }
03822
03823 $info->addSection($this->lng->txt("svy_general_properties"));
03824 $info->addProperty($this->lng->txt("author"), $this->object->getAuthor());
03825 $info->addProperty($this->lng->txt("title"), $this->object->getTitle());
03826 switch ($this->object->getAnonymize())
03827 {
03828 case ANONYMIZE_OFF:
03829 $info->addProperty($this->lng->txt("anonymization"), $this->lng->txt("anonymize_personalized"));
03830 break;
03831 case ANONYMIZE_ON:
03832 if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
03833 {
03834 $info->addProperty($this->lng->txt("anonymization"), $this->lng->txt("info_anonymize_with_code"));
03835 }
03836 else
03837 {
03838 $info->addProperty($this->lng->txt("anonymization"), $this->lng->txt("info_anonymize_registered_user"));
03839 }
03840 break;
03841 case ANONYMIZE_FREEACCESS:
03842 $info->addProperty($this->lng->txt("anonymization"), $this->lng->txt("info_anonymize_without_code"));
03843 break;
03844 }
03845 include_once "./Modules/Survey/classes/class.ilObjSurveyAccess.php";
03846 if ($ilAccess->checkAccess("write", "", $this->ref_id) || ilObjSurveyAccess::_hasEvaluationAccess($this->object->getId(), $ilUser->getId()))
03847 {
03848 $info->addProperty($this->lng->txt("evaluation_access"), $this->lng->txt("evaluation_access_info"));
03849 }
03850 $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
03851 $this->ctrl->forwardCommand($info);
03852 }
03853
03861 function printViewObject()
03862 {
03863 global $ilias;
03864
03865 $this->questionsSubtabs("printview");
03866 $template = new ilTemplate("tpl.il_svy_svy_printview.html", TRUE, TRUE, "Modules/Survey");
03867
03868 if ((strlen($ilias->getSetting("rpc_server_host"))) && (strlen($ilias->getSetting("rpc_server_port"))))
03869 {
03870 $this->ctrl->setParameter($this, "pdf", "1");
03871 $template->setCurrentBlock("pdf_export");
03872 $template->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "printView"));
03873 $this->ctrl->setParameter($this, "pdf", "");
03874 $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
03875 $template->setVariable("PDF_IMG_ALT", $this->lng->txt("pdf_export"));
03876 $template->setVariable("PDF_IMG_URL", ilUtil::getHtmlPath(ilUtil::getImagePath("application-pdf.png")));
03877 $template->parseCurrentBlock();
03878 }
03879 $template->setVariable("PRINT_TEXT", $this->lng->txt("print"));
03880 $template->setVariable("PRINT_URL", "javascript:window.print();");
03881
03882 $pages =& $this->object->getSurveyPages();
03883 foreach ($pages as $page)
03884 {
03885 if (count($page) > 0)
03886 {
03887 foreach ($page as $question)
03888 {
03889 $questionGUI = $this->object->getQuestionGUI($question["type_tag"], $question["question_id"]);
03890 if (is_object($questionGUI))
03891 {
03892 if (strlen($question["heading"]))
03893 {
03894 $template->setCurrentBlock("textblock");
03895 $template->setVariable("TEXTBLOCK", $question["heading"]);
03896 $template->parseCurrentBlock();
03897 }
03898 $template->setCurrentBlock("question");
03899 $template->setVariable("QUESTION_DATA", $questionGUI->getPrintView($this->object->getShowQuestionTitles(), $question["questionblock_show_questiontext"]));
03900 $template->parseCurrentBlock();
03901 }
03902 }
03903 if (count($page) > 1)
03904 {
03905 $template->setCurrentBlock("page");
03906 $template->setVariable("BLOCKTITLE", $page[0]["questionblock_title"]);
03907 $template->parseCurrentBlock();
03908 }
03909 else
03910 {
03911 $template->setCurrentBlock("page");
03912 $template->parseCurrentBlock();
03913 }
03914 }
03915 }
03916 $this->tpl->addCss("./Modules/Survey/templates/default/survey_print.css", "print");
03917 if (array_key_exists("pdf", $_GET) && ($_GET["pdf"] == 1))
03918 {
03919 $printbody = new ilTemplate("tpl.il_as_tst_print_body.html", TRUE, TRUE, "Modules/Test");
03920 $printbody->setVariable("TITLE", sprintf($this->lng->txt("tst_result_user_name"), $uname));
03921 $printbody->setVariable("ADM_CONTENT", $template->get());
03922 $printoutput = $printbody->get();
03923 $printoutput = preg_replace("/href=\".*?\"/", "", $printoutput);
03924 $fo = $this->object->processPrintoutput2FO($printoutput);
03925 $this->object->deliverPDFfromFO($fo);
03926 }
03927 else
03928 {
03929 $this->tpl->setVariable("ADM_CONTENT", $template->get());
03930 }
03931 }
03932
03933 function addLocatorItems()
03934 {
03935 global $ilLocator;
03936 switch ($this->ctrl->getCmd())
03937 {
03938 case "next":
03939 case "previous":
03940 case "start":
03941 case "resume":
03942 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "infoScreen"), "", $_GET["ref_id"]);
03943 break;
03944 case "evaluation":
03945 case "checkEvaluationAccess":
03946 case "evaluationdetails":
03947 case "evaluationuser":
03948 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTargetByClass("ilsurveyevaluationgui", "evaluation"), "", $_GET["ref_id"]);
03949 break;
03950 case "create":
03951 case "save":
03952 case "cancel":
03953 case "importFile":
03954 case "cloneAll":
03955 break;
03956 case "infoScreen":
03957 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "infoScreen"), "", $_GET["ref_id"]);
03958 break;
03959 default:
03960 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $_GET["ref_id"]);
03961 break;
03962 }
03963 }
03964
03972 function questionsSubtabs($a_cmd)
03973 {
03974 $questions = ($a_cmd == 'questions') ? true : false;
03975 $printview = ($a_cmd == 'printview') ? true : false;
03976
03977 $this->tabs_gui->addSubTabTarget("survey_question_editor", $this->ctrl->getLinkTarget($this, "questions"),
03978 "", "", "", $questions);
03979 $this->tabs_gui->addSubTabTarget("print_view", $this->ctrl->getLinkTarget($this, "printView"),
03980 "", "", "", $printview);
03981 }
03989 function setEvalSubtabs()
03990 {
03991 global $ilTabs;
03992 global $ilAccess;
03993
03994 $ilTabs->addSubTabTarget(
03995 "svy_eval_cumulated",
03996 $this->ctrl->getLinkTargetByClass("ilsurveyevaluationgui", "evaluation"),
03997 array("evaluation", "checkEvaluationAccess"),
03998 ""
03999 );
04000
04001 $ilTabs->addSubTabTarget(
04002 "svy_eval_detail",
04003 $this->ctrl->getLinkTargetByClass("ilsurveyevaluationgui", "evaluationdetails"),
04004 array("evaluationdetails"),
04005 ""
04006 );
04007
04008 if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
04009 {
04010 $ilTabs->addSubTabTarget(
04011 "svy_eval_user",
04012 $this->ctrl->getLinkTargetByClass("ilsurveyevaluationgui", "evaluationuser"),
04013 array("evaluationuser"),
04014 ""
04015 );
04016 }
04017 }
04018
04019 function setBrowseForQuestionsSubtabs()
04020 {
04021 global $ilAccess;
04022 global $ilTabs;
04023
04024 if ($ilAccess->checkAccess("write", "", $this->ref_id))
04025 {
04026 $ilTabs->setBackTarget($this->lng->txt("menubacktosurvey"), $this->ctrl->getLinkTarget($this, "questions"));
04027 $ilTabs->addTarget("browse_for_questions",
04028 $this->ctrl->getLinkTarget($this, "browseForQuestions"),
04029 array("browseForQuestions",
04030 "filterQuestions", "resetFilterQuestions", "changeDatatype", "insertQuestions",),
04031 "", ""
04032 );
04033 }
04034 }
04035
04041 function getTabs(&$tabs_gui)
04042 {
04043 global $ilAccess, $ilUser;
04044
04045 switch ($this->ctrl->getCmd())
04046 {
04047 case "browseForQuestions":
04048 case "insertQuestions":
04049 case "filterQuestions":
04050 case "resetFilterQuestions":
04051 case "changeDatatype":
04052
04053 case "start":
04054 case "resume":
04055 case "next":
04056 case "previous":
04057 return;
04058 break;
04059 case "evaluation":
04060 case "checkEvaluationAccess":
04061 case "evaluationdetails":
04062 case "evaluationuser":
04063 $this->setEvalSubtabs();
04064 break;
04065 }
04066
04067
04068 if ($ilAccess->checkAccess("write", "", $this->ref_id))
04069 {
04070 $force_active = ($_GET["up"] != "" || $_GET["down"] != "")
04071 ? true
04072 : false;
04073
04074 $tabs_gui->addTarget("survey_questions",
04075 $this->ctrl->getLinkTarget($this,'questions'),
04076 array("questions", "browseForQuestions", "createQuestion",
04077 "filterQuestions", "resetFilterQuestions", "changeDatatype", "insertQuestions",
04078 "removeQuestions", "cancelRemoveQuestions", "confirmRemoveQuestions",
04079 "defineQuestionblock", "saveDefineQuestionblock", "cancelDefineQuestionblock",
04080 "unfoldQuestionblock", "moveQuestions",
04081 "insertQuestionsBefore", "insertQuestionsAfter", "saveObligatory",
04082 "addHeading", "saveHeading", "cancelHeading", "editHeading",
04083 "confirmRemoveHeading", "cancelRemoveHeading", "printView"),
04084 "", "", $force_active);
04085 }
04086
04087 if ($ilAccess->checkAccess("visible", "", $this->ref_id))
04088 {
04089 $tabs_gui->addTarget("info",
04090 $this->ctrl->getLinkTarget($this,'infoScreen'),
04091 array("infoScreen", "showSummary"));
04092 }
04093
04094
04095 if ($ilAccess->checkAccess("write", "", $this->ref_id))
04096 {
04097 $force_active = ($this->ctrl->getCmd() == "")
04098 ? true
04099 : false;
04100 $tabs_gui->addTarget("properties",
04101 $this->ctrl->getLinkTarget($this,'properties'),
04102 array("properties", "save", "cancel"), "",
04103 "", $force_active);
04104 }
04105
04106
04107 if ($ilAccess->checkAccess("write", "", $this->ref_id))
04108 {
04109
04110 $tabs_gui->addTarget("meta_data",
04111 $this->ctrl->getLinkTargetByClass('ilmdeditorgui','listSection'),
04112 "", "ilmdeditorgui");
04113
04114
04115 $tabs_gui->addTarget("constraints",
04116 $this->ctrl->getLinkTarget($this, "constraints"),
04117 array("constraints", "constraintStep1", "constraintStep2",
04118 "constraintStep3", "constraintsAdd", "createConstraints",
04119 "editPrecondition"),
04120 "");
04121 }
04122 if (($ilAccess->checkAccess("write", "", $this->ref_id)) || ($ilAccess->checkAccess("invite", "", $this->ref_id)))
04123 {
04124
04125 $tabs_gui->addTarget("invitation",
04126 $this->ctrl->getLinkTarget($this, "invite"),
04127 array("invite", "saveInvitationStatus",
04128 "cancelInvitationStatus", "searchInvitation", "inviteUserGroup",
04129 "disinviteUserGroup"),
04130 "");
04131 }
04132 if ($ilAccess->checkAccess("write", "", $this->ref_id))
04133 {
04134
04135 $tabs_gui->addTarget("export",
04136 $this->ctrl->getLinkTarget($this,'export'),
04137 array("export", "createExportFile", "confirmDeleteExportFile",
04138 "downloadExportFile"),
04139 ""
04140 );
04141
04142
04143 $tabs_gui->addTarget("maintenance",
04144 $this->ctrl->getLinkTarget($this,'maintenance'),
04145 array("maintenance", "deleteAllUserData"),
04146 "");
04147
04148 if ($this->object->getAnonymize() == 1)
04149 {
04150
04151 $tabs_gui->addTarget("codes",
04152 $this->ctrl->getLinkTarget($this,'codes'),
04153 array("codes", "createSurveyCodes", "setCodeLanguage", "deleteCodes", "exportCodes"),
04154 "");
04155 }
04156 }
04157
04158 include_once "./Modules/Survey/classes/class.ilObjSurveyAccess.php";
04159 if ($ilAccess->checkAccess("write", "", $this->ref_id) || ilObjSurveyAccess::_hasEvaluationAccess($this->object->getId(), $ilUser->getId()))
04160 {
04161
04162 $tabs_gui->addTarget("svy_evaluation",
04163 $this->ctrl->getLinkTargetByClass("ilsurveyevaluationgui", "evaluation"),
04164 array("evaluation", "checkEvaluationAccess", "evaluationdetails",
04165 "evaluationuser"),
04166 "");
04167 }
04168
04169 if ($ilAccess->checkAccess("edit_permission", "", $this->ref_id))
04170 {
04171
04172 $tabs_gui->addTarget("perm_settings",
04173 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
04174 }
04175 }
04176
04182 function _goto($a_target, $a_access_code = "")
04183 {
04184 global $ilAccess, $ilErr, $lng;
04185 if ($ilAccess->checkAccess("read", "", $a_target))
04186 {
04187 include_once "./Services/Utilities/classes/class.ilUtil.php";
04188 if (strlen($a_access_code))
04189 {
04190 $_SESSION["anonymous_id"] = $a_access_code;
04191 $_GET["baseClass"] = "ilObjSurveyGUI";
04192 $_GET["cmd"] = "infoScreen";
04193 $_GET["ref_id"] = $a_target;
04194 include("ilias.php");
04195 exit;
04196 }
04197 else
04198 {
04199 $_GET["baseClass"] = "ilObjSurveyGUI";
04200 $_GET["cmd"] = "infoScreen";
04201 $_GET["ref_id"] = $a_target;
04202 include("ilias.php");
04203 exit;
04204 }
04205 }
04206 else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
04207 {
04208 $_GET["cmd"] = "frameset";
04209 $_GET["target"] = "";
04210 $_GET["ref_id"] = ROOT_FOLDER_ID;
04211 ilUtil::sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
04212 ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
04213 include("repository.php");
04214 exit;
04215 }
04216
04217 $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
04218 }
04219
04220 }
04221 ?>