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
00041 include_once "./classes/class.ilObjectGUI.php";
00042 include_once "./survey/classes/inc.SurveyConstants.php";
00043
00044 class ilObjSurveyGUI extends ilObjectGUI
00045 {
00050 function ilObjSurveyGUI()
00051 {
00052 global $lng, $ilCtrl, $rbacsystem;
00053
00054 $this->type = "svy";
00055 $lng->loadLanguageModule("survey");
00056 $this->ctrl =& $ilCtrl;
00057 $this->ctrl->saveParameter($this, "ref_id");
00058
00059 $this->ilObjectGUI("",$_GET["ref_id"], true, false);
00060 if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
00061 {
00062 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00063 }
00064 }
00065
00066 function backToRepositoryObject()
00067 {
00068 include_once "./classes/class.ilUtil.php";
00069 $path = $this->tree->getPathFull($this->object->getRefID());
00070 ilUtil::redirect($this->getReturnLocation("cancel","./repository.php?cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
00071 }
00072
00076 function &executeCommand()
00077 {
00078 $cmd = $this->ctrl->getCmd("properties");
00079 $next_class = $this->ctrl->getNextClass($this);
00080 $this->ctrl->setReturn($this, "properties");
00081 $this->prepareOutput();
00082
00083
00084 switch($next_class)
00085 {
00086 case "ilinfoscreengui":
00087 $this->infoScreen();
00088 break;
00089 case 'ilmdeditorgui':
00090 include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
00091 $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
00092 $md_gui->addObserver($this->object,'MDUpdateListener','General');
00093
00094 $this->ctrl->forwardCommand($md_gui);
00095 break;
00096
00097 case "ilsurveyevaluationgui":
00098 include_once("./survey/classes/class.ilSurveyEvaluationGUI.php");
00099 $eval_gui = new ilSurveyEvaluationGUI($this->object);
00100 $ret =& $this->ctrl->forwardCommand($eval_gui);
00101 break;
00102
00103 case "ilsurveyexecutiongui":
00104 include_once("./survey/classes/class.ilSurveyExecutionGUI.php");
00105 $exec_gui = new ilSurveyExecutionGUI($this->object);
00106 $ret =& $this->ctrl->forwardCommand($exec_gui);
00107 break;
00108
00109 case 'ilpermissiongui':
00110 include_once("./classes/class.ilPermissionGUI.php");
00111 $perm_gui =& new ilPermissionGUI($this);
00112 $ret =& $this->ctrl->forwardCommand($perm_gui);
00113 break;
00114
00115 default:
00116 $cmd.= "Object";
00117 $ret =& $this->$cmd();
00118 break;
00119 }
00120 if (strtolower($_GET["baseClass"]) != "iladministrationgui" &&
00121 $this->getCreationMode() != true)
00122 {
00123 $this->tpl->show();
00124 }
00125 }
00126
00131 function saveObject()
00132 {
00133 global $rbacadmin;
00134
00135
00136 $newObj = parent::saveObject();
00137
00138 sendInfo($this->lng->txt("object_added"),true);
00139
00140 ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
00141 "&baseClass=ilObjSurveyGUI");
00142 }
00143
00149 function cancelObject($in_rep = false)
00150 {
00151 sendInfo($this->lng->txt("msg_cancel"),true);
00152 ilUtil::redirect("repository.php?cmd=frameset&ref_id=".$_GET["ref_id"]);
00153 }
00154
00162 function cancelPropertiesObject()
00163 {
00164 sendInfo($this->lng->txt("msg_cancel"), true);
00165 $this->ctrl->redirect($this, "properties");
00166 }
00167
00175 function savePropertiesObject()
00176 {
00177 include_once "./classes/class.ilUtil.php";
00178 $this->object->setTitle(ilUtil::stripSlashes($_POST["title"]));
00179 $this->object->setDescription(ilUtil::stripSlashes($_POST["description"]));
00180 $this->object->setAuthor(ilUtil::stripSlashes($_POST["author"]));
00181 $result = $this->object->setStatus($_POST["status"]);
00182 if ($result)
00183 {
00184 sendInfo($result, true);
00185 }
00186 $this->object->setEvaluationAccess($_POST["evaluation_access"]);
00187 $this->object->setStartDate(sprintf("%04d-%02d-%02d", $_POST["start_date"]["y"], $_POST["start_date"]["m"], $_POST["start_date"]["d"]));
00188 $this->object->setStartDateEnabled($_POST["checked_start_date"]);
00189 $this->object->setEndDate(sprintf("%04d-%02d-%02d", $_POST["end_date"]["y"], $_POST["end_date"]["m"], $_POST["end_date"]["d"]));
00190 $this->object->setEndDateEnabled($_POST["checked_end_date"]);
00191
00192 include_once "./classes/class.ilObjAdvancedEditing.php";
00193 $introduction = ilUtil::stripSlashes($_POST["introduction"], true, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("survey"));
00194 $this->object->setIntroduction($introduction);
00195 $outro = ilUtil::stripSlashes($_POST["outro"], true, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("survey"));
00196 $this->object->setOutro($outro);
00197
00198 $this->object->setAnonymize($_POST["anonymize"]);
00199 if ($_POST["showQuestionTitles"])
00200 {
00201 $this->object->showQuestionTitles();
00202 }
00203 else
00204 {
00205 $this->object->hideQuestionTitles();
00206 }
00207 $this->update = $this->object->update();
00208 $this->object->saveToDb();
00209 if (strcmp($_SESSION["info"], "") != 0)
00210 {
00211 sendInfo($_SESSION["info"] . "<br />" . $this->lng->txt("msg_obj_modified"), true);
00212 }
00213 else
00214 {
00215 sendInfo($this->lng->txt("msg_obj_modified"), true);
00216 }
00217 $this->ctrl->redirect($this, "properties");
00218 }
00219
00227 function handleWriteAccess()
00228 {
00229 global $ilAccess;
00230 if (!$ilAccess->checkAccess("write", "", $this->ref_id))
00231 {
00232
00233 sendInfo($this->lng->txt("cannot_edit_survey"), TRUE);
00234 $this->ctrl->redirect($this, "infoScreen");
00235 }
00236 }
00237
00245 function propertiesObject()
00246 {
00247 $this->handleWriteAccess();
00248
00249 include_once "./classes/class.ilUtil.php";
00250 $this->lng->loadLanguageModule("jscalendar");
00251 $this->tpl->addBlockFile("CALENDAR_LANG_JAVASCRIPT", "calendar_javascript", "tpl.calendar.html");
00252 $this->tpl->setCurrentBlock("calendar_javascript");
00253 $this->tpl->setVariable("FULL_SUNDAY", $this->lng->txt("l_su"));
00254 $this->tpl->setVariable("FULL_MONDAY", $this->lng->txt("l_mo"));
00255 $this->tpl->setVariable("FULL_TUESDAY", $this->lng->txt("l_tu"));
00256 $this->tpl->setVariable("FULL_WEDNESDAY", $this->lng->txt("l_we"));
00257 $this->tpl->setVariable("FULL_THURSDAY", $this->lng->txt("l_th"));
00258 $this->tpl->setVariable("FULL_FRIDAY", $this->lng->txt("l_fr"));
00259 $this->tpl->setVariable("FULL_SATURDAY", $this->lng->txt("l_sa"));
00260 $this->tpl->setVariable("SHORT_SUNDAY", $this->lng->txt("s_su"));
00261 $this->tpl->setVariable("SHORT_MONDAY", $this->lng->txt("s_mo"));
00262 $this->tpl->setVariable("SHORT_TUESDAY", $this->lng->txt("s_tu"));
00263 $this->tpl->setVariable("SHORT_WEDNESDAY", $this->lng->txt("s_we"));
00264 $this->tpl->setVariable("SHORT_THURSDAY", $this->lng->txt("s_th"));
00265 $this->tpl->setVariable("SHORT_FRIDAY", $this->lng->txt("s_fr"));
00266 $this->tpl->setVariable("SHORT_SATURDAY", $this->lng->txt("s_sa"));
00267 $this->tpl->setVariable("FULL_JANUARY", $this->lng->txt("l_01"));
00268 $this->tpl->setVariable("FULL_FEBRUARY", $this->lng->txt("l_02"));
00269 $this->tpl->setVariable("FULL_MARCH", $this->lng->txt("l_03"));
00270 $this->tpl->setVariable("FULL_APRIL", $this->lng->txt("l_04"));
00271 $this->tpl->setVariable("FULL_MAY", $this->lng->txt("l_05"));
00272 $this->tpl->setVariable("FULL_JUNE", $this->lng->txt("l_06"));
00273 $this->tpl->setVariable("FULL_JULY", $this->lng->txt("l_07"));
00274 $this->tpl->setVariable("FULL_AUGUST", $this->lng->txt("l_08"));
00275 $this->tpl->setVariable("FULL_SEPTEMBER", $this->lng->txt("l_09"));
00276 $this->tpl->setVariable("FULL_OCTOBER", $this->lng->txt("l_10"));
00277 $this->tpl->setVariable("FULL_NOVEMBER", $this->lng->txt("l_11"));
00278 $this->tpl->setVariable("FULL_DECEMBER", $this->lng->txt("l_12"));
00279 $this->tpl->setVariable("SHORT_JANUARY", $this->lng->txt("s_01"));
00280 $this->tpl->setVariable("SHORT_FEBRUARY", $this->lng->txt("s_02"));
00281 $this->tpl->setVariable("SHORT_MARCH", $this->lng->txt("s_03"));
00282 $this->tpl->setVariable("SHORT_APRIL", $this->lng->txt("s_04"));
00283 $this->tpl->setVariable("SHORT_MAY", $this->lng->txt("s_05"));
00284 $this->tpl->setVariable("SHORT_JUNE", $this->lng->txt("s_06"));
00285 $this->tpl->setVariable("SHORT_JULY", $this->lng->txt("s_07"));
00286 $this->tpl->setVariable("SHORT_AUGUST", $this->lng->txt("s_08"));
00287 $this->tpl->setVariable("SHORT_SEPTEMBER", $this->lng->txt("s_09"));
00288 $this->tpl->setVariable("SHORT_OCTOBER", $this->lng->txt("s_10"));
00289 $this->tpl->setVariable("SHORT_NOVEMBER", $this->lng->txt("s_11"));
00290 $this->tpl->setVariable("SHORT_DECEMBER", $this->lng->txt("s_12"));
00291 $this->tpl->setVariable("ABOUT_CALENDAR", $this->lng->txt("about_calendar"));
00292 $this->tpl->setVariable("ABOUT_CALENDAR_LONG", $this->lng->txt("about_calendar_long"));
00293 $this->tpl->setVariable("ABOUT_TIME_LONG", $this->lng->txt("about_time"));
00294 $this->tpl->setVariable("PREV_YEAR", $this->lng->txt("prev_year"));
00295 $this->tpl->setVariable("PREV_MONTH", $this->lng->txt("prev_month"));
00296 $this->tpl->setVariable("GO_TODAY", $this->lng->txt("go_today"));
00297 $this->tpl->setVariable("NEXT_MONTH", $this->lng->txt("next_month"));
00298 $this->tpl->setVariable("NEXT_YEAR", $this->lng->txt("next_year"));
00299 $this->tpl->setVariable("SEL_DATE", $this->lng->txt("select_date"));
00300 $this->tpl->setVariable("DRAG_TO_MOVE", $this->lng->txt("drag_to_move"));
00301 $this->tpl->setVariable("PART_TODAY", $this->lng->txt("part_today"));
00302 $this->tpl->setVariable("DAY_FIRST", $this->lng->txt("day_first"));
00303 $this->tpl->setVariable("CLOSE", $this->lng->txt("close"));
00304 $this->tpl->setVariable("TODAY", $this->lng->txt("today"));
00305 $this->tpl->setVariable("TIME_PART", $this->lng->txt("time_part"));
00306 $this->tpl->setVariable("DEF_DATE_FORMAT", $this->lng->txt("def_date_format"));
00307 $this->tpl->setVariable("TT_DATE_FORMAT", $this->lng->txt("tt_date_format"));
00308 $this->tpl->setVariable("WK", $this->lng->txt("wk"));
00309 $this->tpl->setVariable("TIME", $this->lng->txt("time"));
00310 $this->tpl->parseCurrentBlock();
00311 $this->tpl->setCurrentBlock("CalendarJS");
00312 $this->tpl->setVariable("LOCATION_JAVASCRIPT_CALENDAR", "./survey/js/calendar/calendar.js");
00313 $this->tpl->setVariable("LOCATION_JAVASCRIPT_CALENDAR_SETUP", "./survey/js/calendar/calendar-setup.js");
00314 $this->tpl->setVariable("LOCATION_JAVASCRIPT_CALENDAR_STYLESHEET", "./survey/js/calendar/calendar.css");
00315 $this->tpl->parseCurrentBlock();
00316
00317 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_properties.html", true);
00318 $this->tpl->setCurrentBlock("adm_content");
00319 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00320 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
00321 $this->tpl->setVariable("VALUE_TITLE", ilUtil::prepareFormOutput($this->object->getTitle()));
00322 $this->tpl->setVariable("TEXT_AUTHOR", $this->lng->txt("author"));
00323 $this->tpl->setVariable("VALUE_AUTHOR", ilUtil::prepareFormOutput($this->object->getAuthor()));
00324 $this->tpl->setVariable("TEXT_DESCRIPTION", $this->lng->txt("description"));
00325 $this->tpl->setVariable("VALUE_DESCRIPTION", ilUtil::prepareFormOutput($this->object->getDescription()));
00326 $this->tpl->setVariable("TEXT_INTRODUCTION", $this->lng->txt("introduction"));
00327 $this->tpl->setVariable("VALUE_INTRODUCTION", ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($this->object->getIntroduction())));
00328 $this->tpl->setVariable("TEXT_OUTRO", $this->lng->txt("outro"));
00329 $this->tpl->setVariable("VALUE_OUTRO", $this->object->prepareTextareaOutput($this->object->getOutro()));
00330 $this->tpl->setVariable("TEXT_STATUS", $this->lng->txt("status"));
00331 $this->tpl->setVariable("TEXT_START_DATE", $this->lng->txt("start_date"));
00332 $this->tpl->setVariable("VALUE_START_DATE", ilUtil::makeDateSelect("start_date", $this->object->getStartYear(), $this->object->getStartMonth(), $this->object->getStartDay()));
00333 $this->tpl->setVariable("IMG_START_DATE_CALENDAR", ilUtil::getImagePath("calendar.png"));
00334 $this->tpl->setVariable("TXT_START_DATE_CALENDAR", $this->lng->txt("open_calendar"));
00335 $this->tpl->setVariable("TEXT_END_DATE", $this->lng->txt("end_date"));
00336 $this->tpl->setVariable("VALUE_END_DATE", ilUtil::makeDateSelect("end_date", $this->object->getEndYear(), $this->object->getEndMonth(), $this->object->getEndDay()));
00337 $this->tpl->setVariable("IMG_END_DATE_CALENDAR", ilUtil::getImagePath("calendar.png"));
00338 $this->tpl->setVariable("TXT_END_DATE_CALENDAR", $this->lng->txt("open_calendar"));
00339 $this->tpl->setVariable("TEXT_EVALUATION_ACCESS", $this->lng->txt("evaluation_access"));
00340 $this->tpl->setVariable("VALUE_OFFLINE", $this->lng->txt("offline"));
00341 $this->tpl->setVariable("VALUE_ONLINE", $this->lng->txt("online"));
00342 $this->tpl->setVariable("TEXT_ENABLED", $this->lng->txt("enabled"));
00343 $this->tpl->setVariable("VALUE_OFF", $this->lng->txt("off"));
00344 $this->tpl->setVariable("VALUE_ALL", $this->lng->txt("evaluation_access_all"));
00345 $this->tpl->setVariable("VALUE_PARTICIPANTS", $this->lng->txt("evaluation_access_participants"));
00346 $this->tpl->setVariable("TEXT_ANONYMIZATION", $this->lng->txt("anonymize_survey"));
00347 $this->tpl->setVariable("ANON_VALUE_OFF", $this->lng->txt("anonymize_personalized"));
00348 $this->tpl->setVariable("ANON_VALUE_ON", $this->lng->txt("anonymize_with_code"));
00349 $this->tpl->setVariable("ANON_VALUE_FREEACCESS", $this->lng->txt("anonymize_without_code"));
00350
00351 switch ($this->object->getAnonymize())
00352 {
00353 case ANONYMIZE_OFF:
00354 $this->tpl->setVariable("ANON_SELECTED_OFF", " selected=\"selected\"");
00355 break;
00356 case ANONYMIZE_ON:
00357 $this->tpl->setVariable("ANON_SELECTED_ON", " selected=\"selected\"");
00358 break;
00359 case ANONYMIZE_FREEACCESS:
00360 $this->tpl->setVariable("ANON_SELECTED_FREEACCESS", " selected=\"selected\"");
00361 break;
00362 }
00363
00364 if ($this->object->getEndDateEnabled())
00365 {
00366 $this->tpl->setVariable("CHECKED_END_DATE", " checked=\"checked\"");
00367 }
00368 if ($this->object->getStartDateEnabled())
00369 {
00370 $this->tpl->setVariable("CHECKED_START_DATE", " checked=\"checked\"");
00371 }
00372 switch ($this->object->getEvaluationAccess())
00373 {
00374 case EVALUATION_ACCESS_OFF:
00375 $this->tpl->setVariable("SELECTED_OFF", " selected=\"selected\"");
00376 break;
00377 case EVALUATION_ACCESS_ALL:
00378 $this->tpl->setVariable("SELECTED_ALL", " selected=\"selected\"");
00379 break;
00380 case EVALUATION_ACCESS_PARTICIPANTS:
00381 $this->tpl->setVariable("SELECTED_PARTICIPANTS", " selected=\"selected\"");
00382 break;
00383 }
00384 if ($this->object->getStatus() == STATUS_ONLINE)
00385 {
00386 $this->tpl->setVariable("SELECTED_ONLINE", " selected=\"selected\"");
00387 }
00388 else
00389 {
00390 $this->tpl->setVariable("SELECTED_OFFLINE", " selected=\"selected\"");
00391 }
00392 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00393 $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
00394 $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
00395 $this->tpl->setVariable("TEXT_SHOW_QUESTIONTITLES", $this->lng->txt("svy_show_questiontitles"));
00396 if ($this->object->getShowQuestionTitles())
00397 {
00398 $this->tpl->setVariable("QUESTIONTITLES_CHECKED", " checked=\"checked\"");
00399 }
00400 $this->tpl->parseCurrentBlock();
00401 include_once "./Services/RTE/classes/class.ilRTE.php";
00402 $rtestring = ilRTE::_getRTEClassname();
00403 include_once "./Services/RTE/classes/class.$rtestring.php";
00404 $rte = new $rtestring();
00405 $rte->removePlugin("ibrowser");
00406 include_once "./classes/class.ilObject.php";
00407 $obj_id = ilObject::_lookupObjectId($_GET["ref_id"]);
00408 $obj_type = ilObject::_lookupType($_GET["ref_id"], TRUE);
00409 $rte->addRTESupport($obj_id, $obj_type, "survey");
00410 }
00411
00419 function filterQuestionsObject()
00420 {
00421 $this->browseForQuestionsObject($_POST["sel_questionpool"]);
00422 }
00423
00431 function resetFilterQuestionsObject()
00432 {
00433 $this->browseForQuestionsObject("", true);
00434 }
00435
00443 function changeDatatypeObject()
00444 {
00445 $this->browseForQuestionsObject("", true, $_POST["datatype"]);
00446 }
00447
00455 function insertQuestionsObject()
00456 {
00457
00458 $inserted_objects = 0;
00459 foreach ($_POST as $key => $value)
00460 {
00461 if (preg_match("/cb_(\d+)/", $key, $matches))
00462 {
00463 if ($_GET["browsetype"] == 1)
00464 {
00465 $this->object->insertQuestion($matches[1]);
00466 }
00467 else
00468 {
00469 $this->object->insertQuestionBlock($matches[1]);
00470 }
00471 $inserted_objects++;
00472 }
00473 }
00474 if ($inserted_objects)
00475 {
00476 $this->object->saveCompletionStatus();
00477 sendInfo($this->lng->txt("questions_inserted"), true);
00478 $this->ctrl->redirect($this, "questions");
00479 }
00480 else
00481 {
00482 if ($_GET["browsetype"] == 1)
00483 {
00484 sendInfo($this->lng->txt("insert_missing_question"));
00485 }
00486 else
00487 {
00488 sendInfo($this->lng->txt("insert_missing_questionblock"));
00489 }
00490 $this->browseForQuestionsObject("", false, $_GET["browsetype"]);
00491 }
00492 }
00493
00501 function removeQuestionsObject()
00502 {
00503 $checked_questions = array();
00504 $checked_questionblocks = array();
00505 foreach ($_POST as $key => $value)
00506 {
00507 if (preg_match("/cb_(\d+)/", $key, $matches))
00508 {
00509 array_push($checked_questions, $matches[1]);
00510 }
00511 if (preg_match("/cb_qb_(\d+)/", $key, $matches))
00512 {
00513 array_push($checked_questionblocks, $matches[1]);
00514 }
00515 }
00516 if (count($checked_questions) + count($checked_questionblocks) > 0)
00517 {
00518 sendInfo($this->lng->txt("remove_questions"));
00519 $this->removeQuestionsForm($checked_questions, $checked_questionblocks);
00520 return;
00521 }
00522 else
00523 {
00524 sendInfo($this->lng->txt("no_question_selected_for_removal"), true);
00525 $this->ctrl->redirect($this, "questions");
00526 }
00527 }
00528
00536 function browseForQuestionsObject($filter_questionpool = "", $reset_filter = false, $browsequestions = 1)
00537 {
00538 global $rbacsystem;
00539
00540 if (strcmp($this->ctrl->getCmd(), "filterQuestions") != 0)
00541 {
00542 if (array_key_exists("sel_questionpool", $_GET)) $filter_questionpool = $_GET["sel_questionpool"];
00543 }
00544 if (strcmp($this->ctrl->getCmd(), "changeDatatype") != 0)
00545 {
00546 if (array_key_exists("browsetype", $_GET)) $browsequestions = $_GET["browsetype"];
00547 }
00548 if ($_POST["cmd"]["back"]) {
00549 $show_questionbrowser = false;
00550 }
00551
00552 $add_parameter = "&insert_question=1";
00553
00554 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_questionbrowser.html", true);
00555 $this->tpl->addBlockFile("A_BUTTONS", "a_buttons", "tpl.il_svy_svy_action_buttons.html", true);
00556 $this->tpl->addBlockFile("FILTER_QUESTION_MANAGER", "filter_questions", "tpl.il_svy_svy_filter_questions.html", true);
00557
00558 $questionpools =& $this->object->getQuestionpoolTitles();
00559 if (count($questionpools) == 0)
00560 {
00561 sendInfo($this->lng->txt("no_questions_available"));
00562 return;
00563 }
00564
00565 $filter_type = $_GET["sel_filter_type"];
00566 if (!$filter_type)
00567 {
00568 $filter_type = $_POST["sel_filter_type"];
00569 }
00570 if ($reset_filter)
00571 {
00572 $filter_type = "";
00573 }
00574 $add_parameter .= "&sel_filter_type=$filter_type";
00575
00576 $filter_text = $_GET["filter_text"];
00577 if (!$filter_text)
00578 {
00579 $filter_text = $_POST["filter_text"];
00580 }
00581 if ($reset_filter)
00582 {
00583 $filter_text = "";
00584 }
00585 $add_parameter .= "&filter_text=$filter_text";
00586
00587 $add_parameter .= "&browsetype=$browsequestions";
00588 $filter_fields = array(
00589 "title" => $this->lng->txt("title"),
00590 "comment" => $this->lng->txt("description"),
00591 "author" => $this->lng->txt("author"),
00592 );
00593 $this->tpl->setCurrentBlock("filterrow");
00594 foreach ($filter_fields as $key => $value)
00595 {
00596 $this->tpl->setVariable("VALUE_FILTER_TYPE", "$key");
00597 $this->tpl->setVariable("NAME_FILTER_TYPE", "$value");
00598 if (!$reset_filter)
00599 {
00600 if (strcmp($filter_type, $key) == 0)
00601 {
00602 $this->tpl->setVariable("VALUE_FILTER_SELECTED", " selected=\"selected\"");
00603 }
00604 }
00605 $this->tpl->parseCurrentBlock();
00606 }
00607
00608 $filter_question_type = $_POST["sel_question_type"];
00609 if (!$filter_question_type)
00610 {
00611 $filter_question_type = $_GET["sel_question_type"];
00612 }
00613 if ($reset_filter)
00614 {
00615 $filter_question_type = "";
00616 }
00617 $add_parameter .= "&sel_question_type=$filter_question_type";
00618
00619 if ($browsequestions)
00620 {
00621 $questiontypes =& $this->object->_getQuestiontypes();
00622 foreach ($questiontypes as $key => $value)
00623 {
00624 $this->tpl->setCurrentBlock("questiontype_row");
00625 $this->tpl->setVariable("VALUE_QUESTION_TYPE", $value);
00626 $this->tpl->setVariable("TEXT_QUESTION_TYPE", $this->lng->txt($value));
00627 if (strcmp($filter_question_type, $value) == 0)
00628 {
00629 $this->tpl->setVariable("SELECTED_QUESTION_TYPE", " selected=\"selected\"");
00630 }
00631 $this->tpl->parseCurrentBlock();
00632 }
00633 }
00634
00635 if ($reset_filter)
00636 {
00637 $filter_questionpool = "";
00638 }
00639 $add_parameter .= "&sel_questionpool=$filter_questionpool";
00640
00641 if ($browsequestions)
00642 {
00643 foreach ($questionpools as $key => $value)
00644 {
00645 $this->tpl->setCurrentBlock("questionpool_row");
00646 $this->tpl->setVariable("VALUE_QUESTIONPOOL", $key);
00647 $this->tpl->setVariable("TEXT_QUESTIONPOOL", $value);
00648 if (strcmp($filter_questionpool, $key) == 0)
00649 {
00650 $this->tpl->setVariable("SELECTED_QUESTIONPOOL", " selected=\"selected\"");
00651 }
00652 $this->tpl->parseCurrentBlock();
00653 }
00654 }
00655
00656 if ($browsequestions)
00657 {
00658 $this->tpl->setCurrentBlock("question_filters");
00659 $this->tpl->setVariable("SHOW_QUESTION_TYPES", $this->lng->txt("filter_show_question_types"));
00660 $this->tpl->setVariable("TEXT_ALL_QUESTION_TYPES", $this->lng->txt("filter_all_question_types"));
00661 $this->tpl->setVariable("SHOW_QUESTIONPOOLS", $this->lng->txt("filter_show_questionpools"));
00662 $this->tpl->setVariable("TEXT_ALL_QUESTIONPOOLS", $this->lng->txt("filter_all_questionpools"));
00663 $this->tpl->parseCurrentBlock();
00664 }
00665
00666 $this->tpl->setCurrentBlock("filter_questions");
00667 $this->tpl->setVariable("FILTER_TEXT", $this->lng->txt("filter"));
00668 $this->tpl->setVariable("TEXT_FILTER_BY", $this->lng->txt("by"));
00669 if (!$_POST["cmd"]["reset"]) {
00670 $this->tpl->setVariable("VALUE_FILTER_TEXT", $filter_text);
00671 }
00672 $this->tpl->setVariable("VALUE_SUBMIT_FILTER", $this->lng->txt("set_filter"));
00673 $this->tpl->setVariable("VALUE_RESET_FILTER", $this->lng->txt("reset_filter"));
00674 $this->tpl->setVariable("OPTION_QUESTIONS", $this->lng->txt("questions"));
00675 $this->tpl->setVariable("OPTION_QUESTIONBLOCKS", $this->lng->txt("questionblocks"));
00676 if ($browsequestions)
00677 {
00678 $this->tpl->setVariable("SELECTED_QUESTIONS", " selected=\"selected\"");
00679 }
00680 else
00681 {
00682 $this->tpl->setVariable("SELECTED_QUESTIONBLOCKS", " selected=\"selected\"");
00683 }
00684 $this->tpl->setVariable("TEXT_DATATYPE", $this->lng->txt("display_all_available"));
00685 $this->tpl->setVariable("BTN_CHANGE", $this->lng->txt("change"));
00686 $this->tpl->parseCurrentBlock();
00687
00688 if ($_POST["cmd"]["reset"])
00689 {
00690 $_POST["filter_text"] = "";
00691 }
00692 $startrow = 0;
00693 if ($_GET["prevrow"])
00694 {
00695 $startrow = $_GET["prevrow"];
00696 }
00697 if ($_GET["nextrow"])
00698 {
00699 $startrow = $_GET["nextrow"];
00700 }
00701 if ($_GET["startrow"])
00702 {
00703 $startrow = $_GET["startrow"];
00704 }
00705 if (!$_GET["sort"])
00706 {
00707
00708 $_GET["sort"] = array("title" => "ASC");
00709 }
00710 if ($browsequestions)
00711 {
00712 $table = $this->object->getQuestionsTable($_GET["sort"], $filter_text, $filter_type, $startrow, 1, $filter_question_type, $filter_questionpool);
00713 }
00714 else
00715 {
00716 $table = $this->object->getQuestionblocksTable($_GET["sort"], $filter_text, $filter_type, $startrow);
00717 }
00718 $colors = array("tblrow1", "tblrow2");
00719 $counter = 0;
00720 $questionblock_id = 0;
00721 if ($browsequestions)
00722 {
00723 include_once "./classes/class.ilFormat.php";
00724 foreach ($table["rows"] as $data)
00725 {
00726 if ($rbacsystem->checkAccess("write", $data["ref_id"])) {
00727 $this->tpl->setCurrentBlock("QTab");
00728 if ($data["complete"]) {
00729
00730 $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
00731 }
00732 $this->tpl->setVariable("QUESTION_TITLE", "<strong>" . $data["title"] . "</strong>");
00733 $this->tpl->setVariable("PREVIEW", "[<a href=\"" . "ilias.php?baseClass=ilObjSurveyQuestionPoolGUI&ref_id=" . $data["ref_id"] . "&cmd=preview&preview=" . $data["question_id"] . " \" target=\"_blank\">" . $this->lng->txt("preview") . "</a>]");
00734 $this->tpl->setVariable("QUESTION_COMMENT", $data["description"]);
00735 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($data["type_tag"]));
00736 $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]);
00737 $this->tpl->setVariable("QUESTION_CREATED", ilFormat::formatDate(ilFormat::ftimestamp2dateDB($data["created"]), "date"));
00738 $this->tpl->setVariable("QUESTION_UPDATED", ilFormat::formatDate(ilFormat::ftimestamp2dateDB($data["TIMESTAMP14"]), "date"));
00739 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
00740 $this->tpl->setVariable("QUESTION_POOL", $questionpools[$data["obj_fi"]]);
00741 $this->tpl->parseCurrentBlock();
00742 $counter++;
00743 }
00744 }
00745 if ($table["rowcount"] > count($table["rows"]))
00746 {
00747 $nextstep = $table["nextrow"] + $table["step"];
00748 if ($nextstep > $table["rowcount"])
00749 {
00750 $nextstep = $table["rowcount"];
00751 }
00752 $sort = "";
00753 if (is_array($_GET["sort"]))
00754 {
00755 $key = key($_GET["sort"]);
00756 $sort = "&sort[$key]=" . $_GET["sort"]["$key"];
00757 }
00758 $counter = 1;
00759 for ($i = 0; $i < $table["rowcount"]; $i += $table["step"])
00760 {
00761 $this->tpl->setCurrentBlock("pages_questions");
00762 if ($table["startrow"] == $i)
00763 {
00764 $this->tpl->setVariable("PAGE_NUMBER", "<span class=\"inactivepage\">$counter</span>");
00765 }
00766 else
00767 {
00768 $this->tpl->setVariable("PAGE_NUMBER", "<a href=\"" . $this->ctrl->getLinkTarget($this, "browseForQuestions") . $add_parameter . "$sort&nextrow=$i" . "\">$counter</a>");
00769 }
00770 $this->tpl->parseCurrentBlock();
00771 $counter++;
00772 }
00773 $this->tpl->setCurrentBlock("questions_navigation_bottom");
00774 $this->tpl->setVariable("TEXT_ITEM", $this->lng->txt("item"));
00775 $this->tpl->setVariable("TEXT_ITEM_START", $table["startrow"] + 1);
00776 $end = $table["startrow"] + $table["step"];
00777 if ($end > $table["rowcount"])
00778 {
00779 $end = $table["rowcount"];
00780 }
00781 $this->tpl->setVariable("TEXT_ITEM_END", $end);
00782 $this->tpl->setVariable("TEXT_OF", strtolower($this->lng->txt("of")));
00783 $this->tpl->setVariable("TEXT_ITEM_COUNT", $table["rowcount"]);
00784 $this->tpl->setVariable("TEXT_PREVIOUS", $this->lng->txt("previous"));
00785 $this->tpl->setVariable("TEXT_NEXT", $this->lng->txt("next"));
00786 $this->tpl->setVariable("HREF_PREV_ROWS", $this->ctrl->getLinkTarget($this, "browseForQuestions") . $add_parameter . "$sort&prevrow=" . $table["prevrow"]);
00787 $this->tpl->setVariable("HREF_NEXT_ROWS", $this->ctrl->getLinkTarget($this, "browseForQuestions") . $add_parameter . "$sort&nextrow=" . $table["nextrow"]);
00788 $this->tpl->parseCurrentBlock();
00789 }
00790 }
00791 else
00792 {
00793 foreach ($table["rows"] as $data)
00794 {
00795 $this->tpl->setCurrentBlock("questionblock_row");
00796 $this->tpl->setVariable("QUESTIONBLOCK_ID", $data["questionblock_id"]);
00797 $this->tpl->setVariable("QUESTIONBLOCK_TITLE", "<strong>" . $data["title"] . "</strong>");
00798 $this->tpl->setVariable("SURVEY_TITLE", $data["surveytitle"]);
00799 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
00800 $this->tpl->setVariable("QUESTIONS_TITLE", $data["questions"]);
00801 $this->tpl->parseCurrentBlock();
00802 $counter++;
00803 }
00804 if ($table["rowcount"] > count($table["rows"]))
00805 {
00806 $nextstep = $table["nextrow"] + $table["step"];
00807 if ($nextstep > $table["rowcount"])
00808 {
00809 $nextstep = $table["rowcount"];
00810 }
00811 $sort = "";
00812 if (is_array($_GET["sort"]))
00813 {
00814 $key = key($_GET["sort"]);
00815 $sort = "&sort[$key]=" . $_GET["sort"]["$key"];
00816 }
00817 $counter = 1;
00818 for ($i = 0; $i < $table["rowcount"]; $i += $table["step"])
00819 {
00820 $this->tpl->setCurrentBlock("pages_questionblocks");
00821 if ($table["startrow"] == $i)
00822 {
00823 $this->tpl->setVariable("PAGE_NUMBER", "<strong>$counter</strong>");
00824 }
00825 else
00826 {
00827 $this->tpl->setVariable("PAGE_NUMBER", "<a href=\"" . $this->ctrl->getLinkTarget($this, "browseForQuestions") . $add_parameter . "$sort&nextrow=$i" . "\">$counter</a>");
00828 }
00829 $this->tpl->parseCurrentBlock();
00830 $counter++;
00831 }
00832 $this->tpl->setCurrentBlock("questionblocks_navigation_bottom");
00833 $this->tpl->setVariable("TEXT_ITEM", $this->lng->txt("item"));
00834 $this->tpl->setVariable("TEXT_ITEM_START", $table["startrow"] + 1);
00835 $end = $table["startrow"] + $table["step"];
00836 if ($end > $table["rowcount"])
00837 {
00838 $end = $table["rowcount"];
00839 }
00840 $this->tpl->setVariable("TEXT_ITEM_END", $end);
00841 $this->tpl->setVariable("TEXT_OF", strtolower($this->lng->txt("of")));
00842 $this->tpl->setVariable("TEXT_ITEM_COUNT", $table["rowcount"]);
00843 $this->tpl->setVariable("TEXT_PREVIOUS", $this->lng->txt("previous"));
00844 $this->tpl->setVariable("TEXT_NEXT", $this->lng->txt("next"));
00845 $this->tpl->setVariable("HREF_PREV_ROWS", $this->ctrl->getLinkTarget($this, "browseForQuestions") . $add_parameter . "$sort&prevrow=" . $table["prevrow"]);
00846 $this->tpl->setVariable("HREF_NEXT_ROWS", $this->ctrl->getLinkTarget($this, "browseForQuestions") . $add_parameter . "$sort&nextrow=" . $table["nextrow"]);
00847 $this->tpl->parseCurrentBlock();
00848 }
00849 }
00850
00851
00852 if ($counter == 0)
00853 {
00854 $this->tpl->setCurrentBlock("Emptytable");
00855 if ($browsequestions)
00856 {
00857 $this->tpl->setVariable("TEXT_EMPTYTABLE", $this->lng->txt("no_questions_available"));
00858 }
00859 else
00860 {
00861 $this->tpl->setVariable("TEXT_EMPTYTABLE", $this->lng->txt("no_questionblocks_available"));
00862 }
00863 $this->tpl->parseCurrentBlock();
00864 }
00865 else
00866 {
00867 $this->tpl->setCurrentBlock("selectall");
00868 $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
00869 $counter++;
00870 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
00871 $this->tpl->parseCurrentBlock();
00872
00873 $this->tpl->setCurrentBlock("selection");
00874 $this->tpl->setVariable("INSERT", $this->lng->txt("insert"));
00875 $this->tpl->parseCurrentBlock();
00876
00877 $this->tpl->setCurrentBlock("Footer");
00878 include_once "./classes/class.ilUtil.php";
00879 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\">");
00880 $this->tpl->parseCurrentBlock();
00881 }
00882
00883 $sort = array(
00884 "title" => $_GET["sort"]["title"],
00885 "description" => $_GET["sort"]["description"],
00886 "type" => $_GET["sort"]["type"],
00887 "author" => $_GET["sort"]["author"],
00888 "created" => $_GET["sort"]["created"],
00889 "updated" => $_GET["sort"]["updated"],
00890 "qpl" => $_GET["sort"]["qpl"],
00891 "svy" => $_GET["sort"]["svy"]
00892 );
00893 foreach ($sort as $key => $value) {
00894 if (strcmp($value, "ASC") == 0) {
00895 $sort[$key] = "DESC";
00896 } else {
00897 $sort[$key] = "ASC";
00898 }
00899 }
00900
00901 if ($browsequestions)
00902 {
00903 $this->tpl->setCurrentBlock("questions_header");
00904 $this->tpl->setVariable("QUESTION_TITLE", "<a href=\"" . $this->ctrl->getLinkTargetByClass(get_class($this), "browseForQuestions") . "$add_parameter&startrow=" . $table["startrow"] . "&sort[title]=" . $sort["title"] . "\">" . $this->lng->txt("title") . "</a>" . $table["images"]["title"]);
00905 $this->tpl->setVariable("QUESTION_COMMENT", "<a href=\"" . $this->ctrl->getLinkTargetByClass(get_class($this), "browseForQuestions") . "$add_parameter&startrow=" . $table["startrow"] . "&sort[description]=" . $sort["description"] . "\">" . $this->lng->txt("description") . "</a>". $table["images"]["description"]);
00906 $this->tpl->setVariable("QUESTION_TYPE", "<a href=\"" . $this->ctrl->getLinkTargetByClass(get_class($this), "browseForQuestions") . "$add_parameter&startrow=" . $table["startrow"] . "&sort[type]=" . $sort["type"] . "\">" . $this->lng->txt("question_type") . "</a>" . $table["images"]["type"]);
00907 $this->tpl->setVariable("QUESTION_AUTHOR", "<a href=\"" . $this->ctrl->getLinkTargetByClass(get_class($this), "browseForQuestions") . "$add_parameter&startrow=" . $table["startrow"] . "&sort[author]=" . $sort["author"] . "\">" . $this->lng->txt("author") . "</a>" . $table["images"]["author"]);
00908 $this->tpl->setVariable("QUESTION_CREATED", "<a href=\"" . $this->ctrl->getLinkTargetByClass(get_class($this), "browseForQuestions") . "$add_parameter&startrow=" . $table["startrow"] . "&sort[created]=" . $sort["created"] . "\">" . $this->lng->txt("create_date") . "</a>" . $table["images"]["created"]);
00909 $this->tpl->setVariable("QUESTION_UPDATED", "<a href=\"" . $this->ctrl->getLinkTargetByClass(get_class($this), "browseForQuestions") . "$add_parameter&startrow=" . $table["startrow"] . "&sort[updated]=" . $sort["updated"] . "\">" . $this->lng->txt("last_update") . "</a>" . $table["images"]["updated"]);
00910 $this->tpl->setVariable("QUESTION_POOL", "<a href=\"" . $this->ctrl->getLinkTargetByClass(get_class($this), "browseForQuestions") . "$add_parameter&startrow=" . $table["startrow"] . "&sort[qpl]=" . $sort["qpl"] . "\">" . $this->lng->txt("obj_spl") . "</a>" . $table["images"]["qpl"]);
00911 $this->tpl->parseCurrentBlock();
00912 }
00913 else
00914 {
00915 $this->tpl->setCurrentBlock("questionblocks_header");
00916 $this->tpl->setVariable("QUESTIONBLOCK_TITLE", "<a href=\"" . $this->ctrl->getLinkTargetByClass(get_class($this), "browseForQuestions") . "$add_parameter&startrow=" . $table["startrow"] . "&sort[title]=" . $sort["title"] . "\">" . $this->lng->txt("title") . "</a>" . $table["images"]["title"]);
00917 $this->tpl->setVariable("SURVEY_TITLE", "<a href=\"" . $this->ctrl->getLinkTargetByClass(get_class($this), "browseForQuestions") . "$add_parameter&startrow=" . $table["startrow"] . "&sort[svy]=" . $sort["svy"] . "\">" . $this->lng->txt("obj_svy") . "</a>" . $table["images"]["svy"]);
00918 $this->tpl->setVariable("QUESTIONS_TITLE", $this->lng->txt("contains"));
00919 $this->tpl->parseCurrentBlock();
00920 }
00921 $this->tpl->setCurrentBlock("adm_content");
00922
00923 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this) . $add_parameter);
00924 $this->tpl->parseCurrentBlock();
00925 }
00926
00934 function searchQuestionsExecuteObject()
00935 {
00936 include_once "./survey/classes/class.SurveySearch.php";
00937 include_once "./classes/class.ilUtil.php";
00938 $search = new SurveySearch(ilUtil::stripSlashes($_POST["search_term"]), $_POST["concat"], $_POST["search_field"], $_POST["search_type"]);
00939 $search->search();
00940 $results =& $search->search_results;
00941 if (count($results))
00942 {
00943 $this->searchQuestionsObject($results);
00944 }
00945 else
00946 {
00947 sendInfo($this->lng->txt("no_search_results"));
00948 $this->searchQuestionsObject();
00949 }
00950 }
00951
00960 function searchQuestionsObject($search_results = false)
00961 {
00962 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_search_questions.html", true);
00963
00964 if (is_array($search_results))
00965 {
00966 $classes = array("tblrow1", "tblrow2");
00967 $counter = 0;
00968 $titles = $this->object->getQuestionpoolTitles();
00969 $forbidden_pools =& $this->object->getForbiddenQuestionpools();
00970 $existing_questions =& $this->object->getExistingQuestions();
00971 foreach ($search_results as $data)
00972 {
00973 if ((!in_array($data["question_id"], $existing_questions)) && (!in_array($data["obj_fi"], $forbidden_pools)))
00974 {
00975 $this->tpl->setCurrentBlock("result_row");
00976 $this->tpl->setVariable("COLOR_CLASS", $classes[$counter % 2]);
00977 $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
00978 $this->tpl->setVariable("QUESTION_TITLE", $data["title"]);
00979 $this->tpl->setVariable("QUESTION_DESCRIPTION", $data["description"]);
00980 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($data["type_tag"]));
00981 $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]);
00982 $this->tpl->setVariable("QUESTION_POOL", $titles[$data["obj_fi"]]);
00983 $this->tpl->parseCurrentBlock();
00984 $counter++;
00985 }
00986 }
00987 $this->tpl->setCurrentBlock("search_results");
00988 include_once "./classes/class.ilUtil.php";
00989 $this->tpl->setVariable("RESULT_IMAGE", ilUtil::getImagePath("icon_spl_b.gif"));
00990 $this->tpl->setVariable("ALT_IMAGE", $this->lng->txt("found_questions"));
00991 $this->tpl->setVariable("TEXT_QUESTION_TITLE", $this->lng->txt("title"));
00992 $this->tpl->setVariable("TEXT_QUESTION_DESCRIPTION", $this->lng->txt("description"));
00993 $this->tpl->setVariable("TEXT_QUESTION_TYPE", $this->lng->txt("question_type"));
00994 $this->tpl->setVariable("TEXT_QUESTION_AUTHOR", $this->lng->txt("author"));
00995 $this->tpl->setVariable("TEXT_QUESTION_POOL", $this->lng->txt("obj_spl"));
00996 $this->tpl->setVariable("BTN_INSERT", $this->lng->txt("insert"));
00997 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\">");
00998 $this->tpl->setVariable("FOUND_QUESTIONS", $this->lng->txt("found_questions"));
00999 $this->tpl->parseCurrentBlock();
01000 }
01001
01002 sendInfo();
01003 $questiontypes = &$this->object->getQuestiontypes();
01004 foreach ($questiontypes as $questiontype)
01005 {
01006 $this->tpl->setCurrentBlock("questiontypes");
01007 $this->tpl->setVariable("VALUE_QUESTION_TYPE", $questiontype);
01008 $this->tpl->setVariable("TEXT_QUESTION_TYPE", $this->lng->txt($questiontype));
01009 if (strcmp($_POST["search_type"], $questiontype) == 0)
01010 {
01011 $this->tpl->setVariable("SELECTED_SEARCH_TYPE", " selected=\"selected\"");
01012 }
01013 $this->tpl->parseCurrentBlock();
01014 }
01015 $this->tpl->setCurrentBlock("adm_content");
01016 switch ($_POST["search_field"])
01017 {
01018 case "title":
01019 $this->tpl->setVariable("CHECKED_TITLE", " selected=\"selected\"");
01020 break;
01021 case "description":
01022 $this->tpl->setVariable("CHECKED_DESCRIPTION", " selected=\"selected\"");
01023 break;
01024 case "author":
01025 $this->tpl->setVariable("CHECKED_AUTHOR", " selected=\"selected\"");
01026 break;
01027 case "questiontext":
01028 $this->tpl->setVariable("CHECKED_QUESTIONTEXT", " selected=\"selected\"");
01029 break;
01030 case "default":
01031 $this->tpl->setVariable("CHECKED_ALL", " selected=\"selected\"");
01032 break;
01033 }
01034 $this->tpl->setVariable("TEXT_SEARCH_TERM", $this->lng->txt("search_term"));
01035 $this->tpl->setVariable("VALUE_SEARCH_TERM", $_POST["search_term"]);
01036 $this->tpl->setVariable("TEXT_CONCATENATION", $this->lng->txt("concatenation"));
01037 $this->tpl->setVariable("TEXT_AND", $this->lng->txt("and"));
01038 $this->tpl->setVariable("TEXT_OR", $this->lng->txt("or"));
01039 if ($_POST["concat"] == 1)
01040 {
01041 $this->tpl->setVariable("CHECKED_OR", " checked=\"checked\"");
01042 }
01043 else
01044 {
01045 $this->tpl->setVariable("CHECKED_AND", " checked=\"checked\"");
01046 }
01047 $this->tpl->setVariable("TEXT_SEARCH_FOR", $this->lng->txt("search_for"));
01048 $this->tpl->setVariable("SEARCH_FIELD_ALL", $this->lng->txt("search_field_all"));
01049 $this->tpl->setVariable("SEARCH_FIELD_TITLE", $this->lng->txt("title"));
01050 $this->tpl->setVariable("SEARCH_FIELD_DESCRIPTION", $this->lng->txt("description"));
01051 $this->tpl->setVariable("SEARCH_FIELD_AUTHOR", $this->lng->txt("author"));
01052 $this->tpl->setVariable("SEARCH_FIELD_QUESTIONTEXT", $this->lng->txt("question"));
01053 $this->tpl->setVariable("SEARCH_TYPE_ALL", $this->lng->txt("search_type_all"));
01054 $this->tpl->setVariable("BTN_SEARCH", $this->lng->txt("search"));
01055 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this) . "&search_question=1&browsetype=1&insert_question=1");
01056 $this->tpl->parseCurrentBlock();
01057 }
01058
01068 function removeQuestionsForm($checked_questions, $checked_questionblocks)
01069 {
01070 sendInfo();
01071 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_remove_questions.html", true);
01072 $colors = array("tblrow1", "tblrow2");
01073 $counter = 0;
01074 $surveyquestions =& $this->object->getSurveyQuestions();
01075 foreach ($surveyquestions as $question_id => $data)
01076 {
01077 if (in_array($data["question_id"], $checked_questions) or (in_array($data["questionblock_id"], $checked_questionblocks)))
01078 {
01079 $this->tpl->setCurrentBlock("row");
01080 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
01081 $this->tpl->setVariable("TEXT_TITLE", $data["title"]);
01082 $this->tpl->setVariable("TEXT_DESCRIPTION", $data["description"]);
01083 $this->tpl->setVariable("TEXT_TYPE", $this->lng->txt($data["type_tag"]));
01084 $this->tpl->setVariable("TEXT_QUESTIONBLOCK", $data["questionblock_title"]);
01085 $this->tpl->parseCurrentBlock();
01086 $counter++;
01087 }
01088 }
01089 foreach ($checked_questions as $id)
01090 {
01091 $this->tpl->setCurrentBlock("hidden");
01092 $this->tpl->setVariable("HIDDEN_NAME", "id_$id");
01093 $this->tpl->setVariable("HIDDEN_VALUE", "$id");
01094 $this->tpl->parseCurrentBlock();
01095 }
01096 foreach ($checked_questionblocks as $id)
01097 {
01098 $this->tpl->setCurrentBlock("hidden");
01099 $this->tpl->setVariable("HIDDEN_NAME", "id_qb_$id");
01100 $this->tpl->setVariable("HIDDEN_VALUE", "$id");
01101 $this->tpl->parseCurrentBlock();
01102 }
01103 $this->tpl->setCurrentBlock("adm_content");
01104 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
01105 $this->tpl->setVariable("TEXT_DESCRIPTION", $this->lng->txt("description"));
01106 $this->tpl->setVariable("TEXT_TYPE", $this->lng->txt("question_type"));
01107 $this->tpl->setVariable("TEXT_QUESTIONBLOCK", $this->lng->txt("questionblock"));
01108 $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
01109 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
01110 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
01111 $this->tpl->parseCurrentBlock();
01112 }
01113
01114
01123 function defineQuestionblock($questionblock_id = "")
01124 {
01125 sendInfo();
01126 if ($questionblock_id)
01127 {
01128 $questionblock = $this->object->getQuestionblock($questionblock_id);
01129 }
01130 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_define_questionblock.html", true);
01131 foreach ($_POST as $key => $value)
01132 {
01133 if (preg_match("/cb_(\d+)/", $key, $matches))
01134 {
01135 $this->tpl->setCurrentBlock("hidden");
01136 $this->tpl->setVariable("HIDDEN_NAME", "cb_$matches[1]");
01137 $this->tpl->setVariable("HIDDEN_VALUE", $matches[1]);
01138 $this->tpl->parseCurrentBlock();
01139 }
01140 }
01141 if ($questionblock_id)
01142 {
01143 $this->tpl->setCurrentBlock("hidden");
01144 $this->tpl->setVariable("HIDDEN_NAME", "questionblock_id");
01145 $this->tpl->setVariable("HIDDEN_VALUE", $questionblock_id);
01146 $this->tpl->parseCurrentBlock();
01147 }
01148 $this->tpl->setCurrentBlock("adm_content");
01149 $this->tpl->setVariable("DEFINE_QUESTIONBLOCK_HEADING", $this->lng->txt("define_questionblock"));
01150 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
01151 if ($questionblock_id)
01152 {
01153 $this->tpl->setVariable("VALUE_TITLE", $questionblock["title"]);
01154 }
01155 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
01156 $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
01157 $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
01158 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
01159 $this->tpl->parseCurrentBlock();
01160 }
01161
01169 function createQuestionObject()
01170 {
01171 global $ilUser;
01172 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_qpl_select.html", true);
01173 $questionpools =& $this->object->getAvailableQuestionpools();
01174 foreach ($questionpools as $key => $value)
01175 {
01176 $this->tpl->setCurrentBlock("option");
01177 $this->tpl->setVariable("VALUE_OPTION", $key);
01178 $this->tpl->setVariable("TEXT_OPTION", $value);
01179 $this->tpl->parseCurrentBlock();
01180 }
01181 $this->tpl->setCurrentBlock("hidden");
01182 $this->tpl->setVariable("HIDDEN_NAME", "sel_question_types");
01183 $this->tpl->setVariable("HIDDEN_VALUE", $_POST["sel_question_types"]);
01184 $this->tpl->parseCurrentBlock();
01185 $this->tpl->setCurrentBlock("adm_content");
01186 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
01187 $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("select_questionpool"));
01188 if (count($questionpools))
01189 {
01190 $this->tpl->setVariable("BTN_SUBMIT", $this->lng->txt("submit"));
01191 }
01192 else
01193 {
01194 sendInfo($this->lng->txt("create_questionpool_before_add_question"));
01195 }
01196 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
01197 $this->tpl->parseCurrentBlock();
01198 }
01199
01207 function cancelCreateQuestionObject()
01208 {
01209 $this->ctrl->redirect($this, "questions");
01210 }
01211
01219 function executeCreateQuestionObject()
01220 {
01221 include_once "./classes/class.ilUtil.php";
01222 ilUtil::redirect("ilias.php?baseClass=ilObjSurveyQuestionPoolGUI&ref_id=" . $_POST["sel_spl"] . "&cmd=createQuestionForSurvey&new_for_survey=".$_GET["ref_id"]."&sel_question_types=".$_POST["sel_question_types"]);
01223 }
01224
01233 function addHeadingObject($question_id = "")
01234 {
01235 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_heading.html", true);
01236 $survey_questions =& $this->object->getSurveyQuestions();
01237 if ($question_id)
01238 {
01239 $_POST["insertbefore"] = $question_id;
01240 $_POST["heading"] = $survey_questions[$question_id]["heading"];
01241 }
01242 foreach ($survey_questions as $key => $value)
01243 {
01244 $this->tpl->setCurrentBlock("insertbefore_row");
01245 $this->tpl->setVariable("VALUE_OPTION", $key);
01246 $option = $this->lng->txt("before") . ": \"" . $value["title"] . "\"";
01247 if (strlen($option) > 80)
01248 {
01249 $option = preg_replace("/^(.{40}).*(.{40})$/", "\\1 [...] \\2", $option);
01250 }
01251 include_once "./classes/class.ilUtil.php";
01252 $this->tpl->setVariable("TEXT_OPTION", ilUtil::prepareFormOutput($option));
01253 if ($key == $_POST["insertbefore"])
01254 {
01255 $this->tpl->setVariable("SELECTED_OPTION", " selected=\"selected\"");
01256 }
01257 $this->tpl->parseCurrentBlock();
01258 }
01259 if ($question_id)
01260 {
01261 $this->tpl->setCurrentBlock("hidden");
01262 $this->tpl->setVariable("INSERTBEFORE_ORIGINAL", $question_id);
01263 $this->tpl->parseCurrentBlock();
01264 }
01265 $this->tpl->setCurrentBlock("adm_content");
01266 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
01267 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
01268 if ($question_id)
01269 {
01270 $this->tpl->setVariable("TEXT_ADD_HEADING", $this->lng->txt("edit_heading"));
01271 $this->tpl->setVariable("SELECT_DISABLED", " disabled=\"disabled\"");
01272 }
01273 else
01274 {
01275 $this->tpl->setVariable("TEXT_ADD_HEADING", $this->lng->txt("add_heading"));
01276 }
01277 $this->tpl->setVariable("TEXT_HEADING", $this->lng->txt("heading"));
01278 $this->tpl->setVariable("VALUE_HEADING", $_POST["heading"]);
01279 $this->tpl->setVariable("TEXT_INSERT", $this->lng->txt("insert"));
01280 $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
01281 $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
01282 $this->tpl->parseCurrentBlock();
01283 }
01284
01292 function confirmInsertQuestionObject()
01293 {
01294
01295 foreach ($_POST as $key => $value) {
01296 if (preg_match("/id_(\d+)/", $key, $matches)) {
01297 if ($_GET["browsetype"] == 1)
01298 {
01299 $this->object->insertQuestion($matches[1]);
01300 }
01301 else
01302 {
01303 $this->object->insertQuestionBlock($matches[1]);
01304 }
01305 }
01306 }
01307 $this->object->saveCompletionStatus();
01308 sendInfo($this->lng->txt("questions_inserted"), true);
01309 $this->ctrl->redirect($this, "questions");
01310 }
01311
01319 function cancelInsertQuestionObject()
01320 {
01321 $this->ctrl->redirect($this, "questions");
01322 }
01323
01331 function saveHeadingObject()
01332 {
01333 if ($_POST["heading"])
01334 {
01335 $insertbefore = $_POST["insertbefore"];
01336 if (!$insertbefore)
01337 {
01338 $insertbefore = $_POST["insertbefore_original"];
01339 }
01340 $this->object->saveHeading($_POST["heading"], $insertbefore);
01341 $this->ctrl->redirect($this, "questions");
01342 }
01343 else
01344 {
01345 sendInfo($this->lng->txt("error_add_heading"));
01346 $this->addHeadingObject();
01347 return;
01348 }
01349 }
01350
01358 function cancelHeadingObject()
01359 {
01360 $this->ctrl->redirect($this, "questions");
01361 }
01362
01370 function confirmRemoveHeadingObject()
01371 {
01372 $this->object->saveHeading("", $_POST["removeheading"]);
01373 $this->ctrl->redirect($this, "questions");
01374 }
01375
01383 function cancelRemoveHeadingObject()
01384 {
01385 $this->ctrl->redirect($this, "questions");
01386 }
01387
01395 function confirmRemoveHeadingForm()
01396 {
01397 sendInfo($this->lng->txt("confirm_remove_heading"));
01398 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_confirm_removeheading.html", true);
01399 $this->tpl->setCurrentBlock("adm_content");
01400 $this->tpl->setVariable("BTN_CONFIRM_REMOVE", $this->lng->txt("confirm"));
01401 $this->tpl->setVariable("BTN_CANCEL_REMOVE", $this->lng->txt("cancel"));
01402 $this->tpl->setVariable("REMOVE_HEADING", $_GET["removeheading"]);
01403 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
01404 $this->tpl->parseCurrentBlock();
01405 }
01406
01414 function confirmRemoveQuestionsObject()
01415 {
01416 $checked_questions = array();
01417 $checked_questionblocks = array();
01418 foreach ($_POST as $key => $value)
01419 {
01420 if (preg_match("/id_(\d+)/", $key, $matches))
01421 {
01422 array_push($checked_questions, $matches[1]);
01423 }
01424 if (preg_match("/id_qb_(\d+)/", $key, $matches))
01425 {
01426 array_push($checked_questionblocks, $matches[1]);
01427 }
01428 }
01429 $this->object->removeQuestions($checked_questions, $checked_questionblocks);
01430 $this->object->saveCompletionStatus();
01431 sendInfo($this->lng->txt("questions_removed"), true);
01432 $this->ctrl->redirect($this, "questions");
01433 }
01434
01442 function cancelRemoveQuestionsObject()
01443 {
01444 $this->ctrl->redirect($this, "questions");
01445 }
01446
01454 function defineQuestionblockObject()
01455 {
01456 $questionblock = array();
01457 foreach ($_POST as $key => $value)
01458 {
01459 if (preg_match("/cb_(\d+)/", $key, $matches))
01460 {
01461 array_push($questionblock, $value);
01462 }
01463 }
01464 if (count($questionblock) < 2)
01465 {
01466 sendInfo($this->lng->txt("qpl_define_questionblock_select_missing"), true);
01467 $this->ctrl->redirect($this, "questions");
01468 }
01469 else
01470 {
01471 $this->defineQuestionblock();
01472 return;
01473 }
01474 }
01475
01483 function saveDefineQuestionblockObject()
01484 {
01485 if ($_POST["title"])
01486 {
01487 if ($_POST["questionblock_id"])
01488 {
01489 include_once "./classes/class.ilUtil.php";
01490 $this->object->modifyQuestionblock($_POST["questionblock_id"], ilUtil::stripSlashes($_POST["title"]));
01491 }
01492 else
01493 {
01494 $questionblock = array();
01495 foreach ($_POST as $key => $value)
01496 {
01497 if (preg_match("/cb_(\d+)/", $key, $matches))
01498 {
01499 array_push($questionblock, $value);
01500 }
01501 }
01502 include_once "./classes/class.ilUtil.php";
01503 $this->object->createQuestionblock(ilUtil::stripSlashes($_POST["title"]), $questionblock);
01504 }
01505 $this->ctrl->redirect($this, "questions");
01506 }
01507 else
01508 {
01509 sendInfo($this->lng->txt("enter_questionblock_title"));
01510 $this->defineQuestionblockObject();
01511 return;
01512 }
01513 }
01514
01522 function unfoldQuestionblockObject()
01523 {
01524 $unfoldblocks = array();
01525 foreach ($_POST as $key => $value)
01526 {
01527 if (preg_match("/cb_qb_(\d+)/", $key, $matches))
01528 {
01529 array_push($unfoldblocks, $matches[1]);
01530 }
01531 }
01532 if (count($unfoldblocks))
01533 {
01534 $this->object->unfoldQuestionblocks($unfoldblocks);
01535 }
01536 else
01537 {
01538 sendInfo($this->lng->txt("qpl_unfold_select_none"), true);
01539 }
01540 $this->ctrl->redirect($this, "questions");
01541 }
01542
01550 function cancelDefineQuestionblockObject()
01551 {
01552 $this->ctrl->redirect($this, "questions");
01553 }
01554
01562 function moveQuestionsObject()
01563 {
01564 $move_questions = array();
01565 foreach ($_POST as $key => $value)
01566 {
01567 if (preg_match("/cb_(\d+)/", $key, $matches))
01568 {
01569 array_push($move_questions, $matches[1]);
01570 }
01571 if (preg_match("/cb_qb_(\d+)/", $key, $matches))
01572 {
01573 $ids = $this->object->getQuestionblockQuestionIds($matches[1]);
01574 foreach ($ids as $qkey => $qid)
01575 {
01576 array_push($move_questions, $qid);
01577 }
01578 }
01579 }
01580 if (count($move_questions) == 0)
01581 {
01582 sendInfo($this->lng->txt("no_question_selected_for_move"), true);
01583 $this->ctrl->redirect($this, "questions");
01584 }
01585 else
01586 {
01587 $_SESSION["move_questions"] = $move_questions;
01588 sendInfo($this->lng->txt("select_target_position_for_move_question"));
01589 $this->questionsObject();
01590 }
01591 }
01592
01600 function insertQuestions($insert_mode)
01601 {
01602
01603 $move_questions = $_SESSION["move_questions"];
01604
01605 $insert_id = -1;
01606 foreach ($_POST as $key => $value)
01607 {
01608 if (preg_match("/^cb_(\d+)$/", $key, $matches))
01609 {
01610 if ($insert_id < 0)
01611 {
01612 $insert_id = $matches[1];
01613 }
01614 }
01615 if (preg_match("/^cb_qb_(\d+)$/", $key, $matches))
01616 {
01617 if ($insert_id < 0)
01618 {
01619 $ids =& $this->object->getQuestionblockQuestionIds($matches[1]);
01620 if (count($ids))
01621 {
01622 if ($insert_mode == 0)
01623 {
01624 $insert_id = $ids[0];
01625 }
01626 else if ($insert_mode == 1)
01627 {
01628 $insert_id = $ids[count($ids)-1];
01629 }
01630 }
01631 }
01632 }
01633 }
01634 if ($insert_id <= 0)
01635 {
01636 sendInfo($this->lng->txt("no_target_selected_for_move"), true);
01637 }
01638 else
01639 {
01640 $this->object->moveQuestions($move_questions, $insert_id, $insert_mode);
01641 }
01642 unset($_SESSION["move_questions"]);
01643 $this->ctrl->redirect($this, "questions");
01644 }
01645
01653 function insertQuestionsBeforeObject()
01654 {
01655 $this->insertQuestions(0);
01656 }
01657
01665 function insertQuestionsAfterObject()
01666 {
01667 $this->insertQuestions(1);
01668 }
01669
01677 function saveObligatoryObject()
01678 {
01679 $obligatory = array();
01680 foreach ($_POST as $key => $value)
01681 {
01682 if (preg_match("/obligatory_(\d+)/", $key, $matches))
01683 {
01684 $obligatory[$matches[1]] = 1;
01685 }
01686 }
01687 $this->object->setObligatoryStates($obligatory);
01688 $this->ctrl->redirect($this, "questions");
01689 }
01690
01698 function questionsObject()
01699 {
01700 $this->handleWriteAccess();
01701
01702 global $rbacsystem;
01703
01704 $hasDatasets = $this->object->_hasDatasets($this->object->getSurveyId());
01705 include_once "./classes/class.ilUtil.php";
01706
01707 if ($_GET["new_id"] > 0)
01708 {
01709
01710 $inserted = $this->object->insertQuestion($_GET["new_id"]);
01711 if (!$inserted)
01712 {
01713 sendInfo($this->lng->txt("survey_error_insert_incomplete_question"));
01714 }
01715 }
01716
01717 if ($_GET["eqid"] and $_GET["eqpl"])
01718 {
01719 ilUtil::redirect("ilias.php?baseClass=ilObjSurveyQuestionPoolGUI&ref_id=" . $_GET["eqpl"] . "&cmd=editQuestionForSurvey&calling_survey=".$_GET["ref_id"]."&q_id=" . $_GET["eqid"]);
01720 }
01721
01722
01723 $_SESSION["calling_survey"] = $this->object->getRefId();
01724 unset($_SESSION["survey_id"]);
01725
01726 if ($_GET["editheading"])
01727 {
01728 $this->addHeadingObject($_GET["editheading"]);
01729 return;
01730 }
01731
01732 if ($_GET["up"] > 0)
01733 {
01734 $this->object->moveUpQuestion($_GET["up"]);
01735 }
01736 if ($_GET["down"] > 0)
01737 {
01738 $this->object->moveDownQuestion($_GET["down"]);
01739 }
01740 if ($_GET["qbup"] > 0)
01741 {
01742 $this->object->moveUpQuestionblock($_GET["qbup"]);
01743 }
01744 if ($_GET["qbdown"] > 0)
01745 {
01746 $this->object->moveDownQuestionblock($_GET["qbdown"]);
01747 }
01748
01749 if ($_GET["removeheading"])
01750 {
01751 $this->confirmRemoveHeadingForm();
01752 return;
01753 }
01754
01755 if ($_GET["editblock"])
01756 {
01757 $this->defineQuestionblock($_GET["editblock"]);
01758 return;
01759 }
01760
01761 if ($_GET["add"])
01762 {
01763
01764 $selected_array = array();
01765 array_push($selected_array, $_GET["add"]);
01766 sendInfo($this->lng->txt("ask_insert_questions"));
01767 $this->insertQuestionsForm($selected_array);
01768 return;
01769 }
01770
01771 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_questions.html", true);
01772
01773 $survey_questions =& $this->object->getSurveyQuestions();
01774 $questionblock_titles =& $this->object->getQuestionblockTitles();
01775 $questionpools =& $this->object->getQuestionpoolTitles();
01776 $colors = array("tblrow1", "tblrow2");
01777 $counter = 0;
01778 $title_counter = 0;
01779 $last_color_class = "";
01780 $obligatory = "<img src=\"" . ilUtil::getImagePath("obligatory.gif", true) . "\" alt=\"" . $this->lng->txt("question_obligatory") . "\" title=\"" . $this->lng->txt("question_obligatory") . "\" />";
01781 if (count($survey_questions) > 0)
01782 {
01783 foreach ($survey_questions as $question_id => $data)
01784 {
01785 $title_counter++;
01786 if (($last_questionblock_id > 0) && ($data["questionblock_id"] == 0))
01787 {
01788 $counter++;
01789 }
01790 if (($last_questionblock_id > 0) && ($data["questionblock_id"] > 0) && ($data["questionblock_id"] != $last_questionblock_id))
01791 {
01792 $counter++;
01793 }
01794 if (($data["questionblock_id"] > 0) and ($data["questionblock_id"] != $last_questionblock_id))
01795 {
01796
01797 $this->tpl->setCurrentBlock("separator");
01798 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
01799 $this->tpl->parseCurrentBlock();
01800 $this->tpl->setCurrentBlock("QTab");
01801 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
01802 $this->tpl->parseCurrentBlock();
01803
01804 $this->tpl->setCurrentBlock("block");
01805 $this->tpl->setVariable("TYPE_ICON", "<img src=\"" . ilUtil::getImagePath("questionblock.gif", true) . "\" alt=\"".$this->lng->txt("questionblock_icon")."\" />");
01806 $this->tpl->setVariable("TEXT_QUESTIONBLOCK", $this->lng->txt("questionblock") . ": " . $data["questionblock_title"]);
01807 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
01808 if ($rbacsystem->checkAccess("write", $this->ref_id) and !$hasDatasets)
01809 {
01810 if ($data["question_id"] != $this->object->questions[0])
01811 {
01812 $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>");
01813 }
01814 $akeys = array_keys($survey_questions);
01815 if ($data["questionblock_id"] != $survey_questions[$akeys[count($akeys)-1]]["questionblock_id"])
01816 {
01817 $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>");
01818 }
01819 $this->tpl->setVariable("TEXT_EDIT", $this->lng->txt("edit"));
01820 $this->tpl->setVariable("HREF_EDIT", $this->ctrl->getLinkTarget($this, "questions") . "&editblock=" . $data["questionblock_id"]);
01821 }
01822 $this->tpl->parseCurrentBlock();
01823 $this->tpl->setCurrentBlock("QTab");
01824 $this->tpl->setVariable("QUESTION_ID", "qb_" . $data["questionblock_id"]);
01825 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
01826 $this->tpl->parseCurrentBlock();
01827 }
01828 if (($last_questionblock_id > 0) && ($data["questionblock_id"] == 0))
01829 {
01830
01831 $this->tpl->setCurrentBlock("separator");
01832 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
01833 $this->tpl->parseCurrentBlock();
01834 $this->tpl->setCurrentBlock("QTab");
01835 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
01836 $this->tpl->parseCurrentBlock();
01837 }
01838 if ($data["heading"])
01839 {
01840 $this->tpl->setCurrentBlock("heading");
01841 $this->tpl->setVariable("TEXT_HEADING", $data["heading"]);
01842 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
01843 if ($rbacsystem->checkAccess("write", $this->ref_id) and !$hasDatasets)
01844 {
01845 $this->tpl->setVariable("TEXT_EDIT", $this->lng->txt("edit"));
01846 $this->tpl->setVariable("HREF_EDIT", $this->ctrl->getLinkTarget($this, "questions") . "&editheading=" . $data["question_id"]);
01847 $this->tpl->setVariable("TEXT_DELETE", $this->lng->txt("remove"));
01848 $this->tpl->setVariable("HREF_DELETE", $this->ctrl->getLinkTarget($this, "questions") . "&removeheading=" . $data["question_id"]);
01849 }
01850 $this->tpl->parseCurrentBlock();
01851 $this->tpl->setCurrentBlock("QTab");
01852 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
01853 $this->tpl->parseCurrentBlock();
01854 }
01855 if (!$data["questionblock_id"])
01856 {
01857 $this->tpl->setCurrentBlock("checkable");
01858 $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
01859 $this->tpl->parseCurrentBlock();
01860 }
01861 $this->tpl->setCurrentBlock("QTab");
01862 include_once "./survey/classes/class.SurveyQuestion.php";
01863 $ref_id = SurveyQuestion::_getRefIdFromObjId($data["obj_fi"]);
01864 if ($rbacsystem->checkAccess("write", $this->ref_id) and !$hasDatasets)
01865 {
01866 $q_id = $data["question_id"];
01867 $qpl_ref_id = $this->object->_getRefIdFromObjId($data["obj_fi"]);
01868 $this->tpl->setVariable("QUESTION_TITLE", "$title_counter. <a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&eqid=$q_id&eqpl=$qpl_ref_id" . "\">" . $data["title"] . "</a>");
01869 }
01870 else
01871 {
01872 $this->tpl->setVariable("QUESTION_TITLE", "$title_counter. ". $data["title"]);
01873 }
01874 $this->tpl->setVariable("TYPE_ICON", "<img src=\"" . ilUtil::getImagePath("question.gif", true) . "\" alt=\"".$this->lng->txt("question_icon")."\" />");
01875 if ($rbacsystem->checkAccess("write", $this->ref_id) and !$hasDatasets)
01876 {
01877 $obligatory_checked = "";
01878 if ($data["obligatory"] == 1)
01879 {
01880 $obligatory_checked = " checked=\"checked\"";
01881 }
01882 $this->tpl->setVariable("QUESTION_OBLIGATORY", "<input type=\"checkbox\" name=\"obligatory_" . $data["question_id"] . "\" value=\"1\"$obligatory_checked />");
01883 }
01884 else
01885 {
01886 if ($data["obligatory"] == 1)
01887 {
01888 $this->tpl->setVariable("QUESTION_OBLIGATORY", $obligatory);
01889 }
01890 }
01891 $this->tpl->setVariable("QUESTION_COMMENT", $data["description"]);
01892 if ($rbacsystem->checkAccess("write", $this->ref_id) and !$hasDatasets)
01893 {
01894 if (!$data["questionblock_id"])
01895 {
01896
01897 if ($data["question_id"] != $this->object->questions[0])
01898 {
01899 $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>");
01900 }
01901 if ($data["question_id"] != $this->object->questions[count($this->object->questions)-1])
01902 {
01903 $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>");
01904 }
01905 }
01906 else
01907 {
01908
01909 if ($data["questionblock_id"] == $last_questionblock_id)
01910 {
01911 $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>");
01912 }
01913 $tmp_questions = array_keys($survey_questions);
01914 $blockkey = array_search($question_id, $tmp_questions);
01915 if (($blockkey !== FALSE) && ($blockkey < count($tmp_questions)-1))
01916 {
01917 if ($data["questionblock_id"] == $survey_questions[$tmp_questions[$blockkey+1]]["questionblock_id"])
01918 {
01919 $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>");
01920 }
01921 }
01922 }
01923 }
01924 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($data["type_tag"]));
01925 $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]);
01926 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
01927 $last_color_class = $colors[$counter % 2];
01928 if (!$data["questionblock_id"])
01929 {
01930 $counter++;
01931 }
01932 $this->tpl->parseCurrentBlock();
01933 $last_questionblock_id = $data["questionblock_id"];
01934 }
01935
01936 if ($rbacsystem->checkAccess("write", $this->ref_id) and !$hasDatasets)
01937 {
01938 $this->tpl->setCurrentBlock("selectall");
01939 $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
01940 $this->tpl->setVariable("COLOR_CLASS", $last_color_class);
01941 $this->tpl->parseCurrentBlock();
01942 if (array_key_exists("move_questions", $_SESSION))
01943 {
01944 $this->tpl->setCurrentBlock("move_buttons");
01945 $this->tpl->setVariable("INSERT_BEFORE", $this->lng->txt("insert_before"));
01946 $this->tpl->setVariable("INSERT_AFTER", $this->lng->txt("insert_after"));
01947 $this->tpl->parseCurrentBlock();
01948 }
01949 $this->tpl->setCurrentBlock("QFooter");
01950 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\">");
01951 $this->tpl->setVariable("REMOVE", $this->lng->txt("remove_question"));
01952 $this->tpl->setVariable("MOVE", $this->lng->txt("move"));
01953 $this->tpl->setVariable("QUESTIONBLOCK", $this->lng->txt("define_questionblock"));
01954 $this->tpl->setVariable("UNFOLD", $this->lng->txt("unfold"));
01955 $this->tpl->parseCurrentBlock();
01956 $this->tpl->setCurrentBlock("actionbuttons");
01957 $this->tpl->setVariable("SAVE", $this->lng->txt("save_obligatory_state"));
01958 $this->tpl->setVariable("HEADING", $this->lng->txt("add_heading"));
01959 $this->tpl->parseCurrentBlock();
01960 }
01961 }
01962 else
01963 {
01964 $this->tpl->setCurrentBlock("Emptytable");
01965 $this->tpl->setVariable("TEXT_EMPTYTABLE", $this->lng->txt("no_questions_available"));
01966 $this->tpl->parseCurrentBlock();
01967 }
01968 if (($last_questionblock_id > 0))
01969 {
01970
01971 $this->tpl->setCurrentBlock("separator");
01972 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
01973 $this->tpl->parseCurrentBlock();
01974 $this->tpl->setCurrentBlock("QTab");
01975 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
01976 $this->tpl->parseCurrentBlock();
01977 }
01978
01979 if ($rbacsystem->checkAccess("write", $this->ref_id) and !$hasDatasets)
01980 {
01981 $this->tpl->setCurrentBlock("QTypes");
01982 $query = "SELECT * FROM survey_questiontype";
01983 $query_result = $this->ilias->db->query($query);
01984 while ($data = $query_result->fetchRow(DB_FETCHMODE_OBJECT))
01985 {
01986 $this->tpl->setVariable("QUESTION_TYPE_ID", $data->type_tag);
01987 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($data->type_tag));
01988 $this->tpl->parseCurrentBlock();
01989 }
01990 $this->tpl->parseCurrentBlock();
01991 }
01992 $this->tpl->setCurrentBlock("adm_content");
01993 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
01994 $this->tpl->setVariable("QUESTION_TITLE", $this->lng->txt("title"));
01995 $this->tpl->setVariable("QUESTION_COMMENT", $this->lng->txt("description"));
01996 $this->tpl->setVariable("QUESTION_OBLIGATORY", $this->lng->txt("obligatory"));
01997 $this->tpl->setVariable("QUESTION_SEQUENCE", $this->lng->txt("sequence"));
01998 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("question_type"));
01999 $this->tpl->setVariable("QUESTION_AUTHOR", $this->lng->txt("author"));
02000
02001 if ($rbacsystem->checkAccess("write", $this->ref_id) and !$hasDatasets)
02002 {
02003 $this->tpl->setVariable("BUTTON_INSERT_QUESTION", $this->lng->txt("browse_for_questions"));
02004 $this->tpl->setVariable("BUTTON_SEARCH_QUESTION", $this->lng->txt("search_questions"));
02005 $this->tpl->setVariable("TEXT_OR", " " . strtolower($this->lng->txt("or")));
02006 $this->tpl->setVariable("TEXT_CREATE_NEW", " " . strtolower($this->lng->txt("or")) . " " . $this->lng->txt("create_new"));
02007 $this->tpl->setVariable("BUTTON_CREATE_QUESTION", $this->lng->txt("create"));
02008 }
02009 if ($hasDatasets)
02010 {
02011 sendInfo($this->lng->txt("survey_has_datasets_warning"));
02012 }
02013
02014 $this->tpl->parseCurrentBlock();
02015 }
02016
02024 function evaluationObject()
02025 {
02026 include_once("./survey/classes/class.ilSurveyEvaluationGUI.php");
02027 $eval_gui = new ilSurveyEvaluationGUI($this->object);
02028 $this->ctrl->setCmdClass(get_class($eval_gui));
02029 $this->ctrl->redirect($eval_gui, "evaluation");
02030 }
02031
02039 function outUserGroupTable($a_type, $id_array, $block_result, $block_row, $title_text, $buttons)
02040 {
02041 global $rbacsystem;
02042
02043 $rowclass = array("tblrow1", "tblrow2");
02044 switch($a_type)
02045 {
02046 case "usr":
02047 include_once "./classes/class.ilObjUser.php";
02048 $counter = 0;
02049 foreach ($id_array as $user_id)
02050 {
02051 $this->tpl->setCurrentBlock($block_row);
02052 $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
02053 if (ilObjUser::_lookupLogin($user_id))
02054 {
02055 $user = new ilObjUser($user_id);
02056 $this->tpl->setVariable("COUNTER", $user->getId());
02057 $this->tpl->setVariable("VALUE_LOGIN", $user->getLogin());
02058 $this->tpl->setVariable("VALUE_FIRSTNAME", $user->getFirstname());
02059 $this->tpl->setVariable("VALUE_LASTNAME", $user->getLastname());
02060 }
02061 else
02062 {
02063 $this->tpl->setVariable("COUNTER", $user_id);
02064 $this->tpl->setVariable("VALUE_LOGIN", $this->lng->txt("deleted_user"));
02065 $this->tpl->setVariable("VALUE_FIRSTNAME", $this->lng->txt("unknown"));
02066 $this->tpl->setVariable("VALUE_LASTNAME", $this->lng->txt("unknown"));
02067 }
02068 $counter++;
02069 $this->tpl->parseCurrentBlock();
02070 }
02071 if (count($id_array))
02072 {
02073 $this->tpl->setCurrentBlock("selectall_$block_result");
02074 $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
02075 $counter++;
02076 $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
02077 $this->tpl->parseCurrentBlock();
02078 }
02079 $this->tpl->setCurrentBlock($block_result);
02080 include_once "./classes/class.ilUtil.php";
02081 $this->tpl->setVariable("TEXT_USER_TITLE", "<img src=\"" . ilUtil::getImagePath("icon_usr.gif") . "\" alt=\"".$this->lng->txt("obj_usr")."\" /> " . $title_text);
02082 $this->tpl->setVariable("TEXT_LOGIN", $this->lng->txt("login"));
02083 $this->tpl->setVariable("TEXT_FIRSTNAME", $this->lng->txt("firstname"));
02084 $this->tpl->setVariable("TEXT_LASTNAME", $this->lng->txt("lastname"));
02085 if ($rbacsystem->checkAccess('invite', $this->object->getRefId()))
02086 {
02087 foreach ($buttons as $cat)
02088 {
02089 $this->tpl->setVariable("VALUE_" . strtoupper($cat), $this->lng->txt($cat));
02090 }
02091 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\">");
02092 }
02093 $this->tpl->parseCurrentBlock();
02094 break;
02095 case "grp":
02096 include_once "./classes/class.ilObjGroup.php";
02097 $counter = 0;
02098 foreach ($id_array as $group_id)
02099 {
02100 $group = new ilObjGroup($group_id);
02101 $this->tpl->setCurrentBlock($block_row);
02102 $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
02103 $this->tpl->setVariable("COUNTER", $group->getRefId());
02104 $this->tpl->setVariable("VALUE_TITLE", $group->getTitle());
02105 $this->tpl->setVariable("VALUE_DESCRIPTION", $group->getDescription());
02106 $counter++;
02107 $this->tpl->parseCurrentBlock();
02108 }
02109 if (count($id_array))
02110 {
02111 $this->tpl->setCurrentBlock("selectall_$block_result");
02112 $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
02113 $counter++;
02114 $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
02115 $this->tpl->parseCurrentBlock();
02116 }
02117 $this->tpl->setCurrentBlock($block_result);
02118 include_once "./classes/class.ilUtil.php";
02119 $this->tpl->setVariable("TEXT_GROUP_TITLE", "<img src=\"" . ilUtil::getImagePath("icon_grp.gif") . "\" alt=\"".$this->lng->txt("obj_grp")."\" /> " . $title_text);
02120 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
02121 $this->tpl->setVariable("TEXT_DESCRIPTION", $this->lng->txt("description"));
02122 if ($rbacsystem->checkAccess('invite', $this->object->getRefId()))
02123 {
02124 foreach ($buttons as $cat)
02125 {
02126 $this->tpl->setVariable("VALUE_" . strtoupper($cat), $this->lng->txt($cat));
02127 }
02128 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\">");
02129 }
02130 $this->tpl->parseCurrentBlock();
02131 break;
02132 case "role":
02133 include_once "./classes/class.ilObjRole.php";
02134 $counter = 0;
02135 foreach ($id_array as $role_id)
02136 {
02137 $role = new ilObjRole($role_id);
02138 $this->tpl->setCurrentBlock($block_row);
02139 $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
02140 $this->tpl->setVariable("COUNTER", $role->getId());
02141 $this->tpl->setVariable("VALUE_TITLE", $role->getTitle());
02142 $this->tpl->setVariable("VALUE_DESCRIPTION", $role->getDescription());
02143 $counter++;
02144 $this->tpl->parseCurrentBlock();
02145 }
02146 if (count($id_array))
02147 {
02148 $this->tpl->setCurrentBlock("selectall_$block_result");
02149 $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
02150 $counter++;
02151 $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
02152 $this->tpl->parseCurrentBlock();
02153 }
02154 $this->tpl->setCurrentBlock($block_result);
02155 include_once "./classes/class.ilUtil.php";
02156 $this->tpl->setVariable("TEXT_ROLE_TITLE", "<img src=\"" . ilUtil::getImagePath("icon_role.gif") . "\" alt=\"".$this->lng->txt("obj_role")."\" /> " . $title_text);
02157 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
02158 $this->tpl->setVariable("TEXT_DESCRIPTION", $this->lng->txt("description"));
02159 if ($rbacsystem->checkAccess('invite', $this->object->getRefId()))
02160 {
02161 foreach ($buttons as $cat)
02162 {
02163 $this->tpl->setVariable("VALUE_" . strtoupper($cat), $this->lng->txt($cat));
02164 }
02165 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\">");
02166 }
02167 $this->tpl->parseCurrentBlock();
02168 break;
02169 }
02170 }
02171
02179 function cancelInvitationStatusObject()
02180 {
02181 $this->ctrl->redirect($this, "invite");
02182 }
02183
02191 function saveInvitationStatusObject()
02192 {
02193 $this->object->setInvitationAndMode($_POST["invitation"], $_POST["mode"]);
02194 $this->object->saveToDb();
02195 $this->ctrl->redirect($this, "invite");
02196 }
02197
02205 function searchInvitationObject()
02206 {
02207 $this->inviteObject();
02208 }
02209
02217 function disinviteUserGroupObject()
02218 {
02219
02220 if (is_array($_POST["invited_users"]))
02221 {
02222 foreach ($_POST["invited_users"] as $user_id)
02223 {
02224 $this->object->disinviteUser($user_id);
02225 }
02226 }
02227 $this->ctrl->redirect($this, "invite");
02228 }
02229
02237 function inviteUserGroupObject()
02238 {
02239
02240 if (is_array($_POST["user_select"]))
02241 {
02242 foreach ($_POST["user_select"] as $user_id)
02243 {
02244 $this->object->inviteUser($user_id);
02245 }
02246 }
02247
02248 if (is_array($_POST["group_select"]))
02249 {
02250 foreach ($_POST["group_select"] as $group_id)
02251 {
02252 $this->object->inviteGroup($group_id);
02253 }
02254 }
02255
02256 if (is_array($_POST["role_select"]))
02257 {
02258 foreach ($_POST["role_select"] as $role_id)
02259 {
02260 $this->object->inviteRole($role_id);
02261 }
02262 }
02263 $this->ctrl->redirect($this, "invite");
02264 }
02265
02266
02274 function inviteObject()
02275 {
02276 global $rbacsystem;
02277
02278 if ((!$rbacsystem->checkAccess("read", $this->ref_id)) && (!$rbacsystem->checkAccess("write", $this->ref_id)))
02279 {
02280
02281 sendInfo($this->lng->txt("cannot_edit_survey"), true);
02282 $path = $this->tree->getPathFull($this->object->getRefID());
02283 include_once "./classes/class.ilUtil.php";
02284 ilUtil::redirect($this->getReturnLocation("cancel","./repository.php?cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
02285 return;
02286 }
02287 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_invite.html", true);
02288
02289 if ($this->object->getStatus() == STATUS_OFFLINE)
02290 {
02291 $this->tpl->setCurrentBlock("survey_offline");
02292 $this->tpl->setVariable("SURVEY_OFFLINE_MESSAGE", $this->lng->txt("survey_offline_message"));
02293 $this->tpl->parseCurrentBlock();
02294 return;
02295 }
02296
02297 $concat = ($_POST["concatenation"]) ? $_POST["concatenation"] : "or";
02298 $searchfor = ($_POST["search_for"]) ? $_POST["search_for"] : array("usr");
02299
02300 if (strcmp($this->ctrl->getCmd(), "searchInvitation") == 0)
02301 {
02302 if (is_array($_POST["search_for"]))
02303 {
02304 if (in_array("usr", $_POST["search_for"]) or in_array("grp", $_POST["search_for"]) or in_array("role", $_POST["search_for"]))
02305 {
02306 include_once "./classes/class.ilSearch.php";
02307 $search =& new ilSearch($ilUser->id);
02308 $search->setSearchString($_POST["search_term"]);
02309 $search->setCombination($concat);
02310 $search->setSearchFor($searchfor);
02311 $search->setSearchType("new");
02312 if($search->validate($message))
02313 {
02314 $search->performSearch();
02315 }
02316 if ($message)
02317 {
02318 sendInfo($message);
02319 }
02320 if(!$search->getNumberOfResults() && $search->getSearchFor())
02321 {
02322 sendInfo($this->lng->txt("search_no_match"));
02323 }
02324 $buttons = array("add");
02325 $invited_users = $this->object->getInvitedUsers();
02326 if ($searchresult = $search->getResultByType("usr"))
02327 {
02328 $users = array();
02329 foreach ($searchresult as $result_array)
02330 {
02331 if (!in_array($result_array["id"], $invited_users))
02332 {
02333 array_push($users, $result_array["id"]);
02334 }
02335 }
02336 $this->outUserGroupTable("usr", $users, "user_result", "user_row", $this->lng->txt("search_users"), $buttons);
02337 }
02338 $searchresult = array();
02339 if ($searchresult = $search->getResultByType("grp"))
02340 {
02341 $groups = array();
02342 foreach ($searchresult as $result_array)
02343 {
02344 array_push($groups, $result_array["id"]);
02345 }
02346 $this->outUserGroupTable("grp", $groups, "group_result", "group_row", $this->lng->txt("search_groups"), $buttons);
02347 }
02348 $searchresult = array();
02349 if ($searchresult = $search->getResultByType("role"))
02350 {
02351 $roles = array();
02352 foreach ($searchresult as $result_array)
02353 {
02354 array_push($roles, $result_array["id"]);
02355 }
02356 $this->outUserGroupTable("role", $roles, "role_result", "role_row", $this->lng->txt("search_roles"), $buttons);
02357 }
02358 }
02359 }
02360 else
02361 {
02362 sendInfo($this->lng->txt("no_user_or_group_selected"));
02363 }
02364 }
02365
02366 if (($this->object->getInvitationMode() == MODE_PREDEFINED_USERS) and ($this->object->getInvitation() == INVITATION_ON))
02367 {
02368 if ($rbacsystem->checkAccess('invite', $this->ref_id))
02369 {
02370 $this->tpl->setCurrentBlock("invitation");
02371 $this->tpl->setVariable("SEARCH_INVITATION", $this->lng->txt("search_invitation"));
02372 $this->tpl->setVariable("SEARCH_TERM", $this->lng->txt("search_term"));
02373 $this->tpl->setVariable("SEARCH_FOR", $this->lng->txt("search_for"));
02374 $this->tpl->setVariable("SEARCH_USERS", $this->lng->txt("objs_usr"));
02375 $this->tpl->setVariable("SEARCH_GROUPS", $this->lng->txt("objs_grp"));
02376 $this->tpl->setVariable("SEARCH_ROLES", $this->lng->txt("objs_role"));
02377 $this->tpl->setVariable("TEXT_CONCATENATION", $this->lng->txt("concatenation"));
02378 $this->tpl->setVariable("TEXT_AND", $this->lng->txt("and"));
02379 $this->tpl->setVariable("TEXT_OR", $this->lng->txt("or"));
02380 $this->tpl->setVariable("VALUE_SEARCH_TERM", $_POST["search_term"]);
02381 if (is_array($searchfor))
02382 {
02383 if (in_array("usr", $searchfor))
02384 {
02385 $this->tpl->setVariable("CHECKED_USERS", " checked=\"checked\"");
02386 }
02387 if (in_array("grp", $searchfor))
02388 {
02389 $this->tpl->setVariable("CHECKED_GROUPS", " checked=\"checked\"");
02390 }
02391 if (in_array("role", $searchfor))
02392 {
02393 $this->tpl->setVariable("CHECKED_ROLES", " checked=\"checked\"");
02394 }
02395 }
02396 if (strcmp($concat, "and") == 0)
02397 {
02398 $this->tpl->setVariable("CHECKED_AND", " checked=\"checked\"");
02399 }
02400 else if (strcmp($concat, "or") == 0)
02401 {
02402 $this->tpl->setVariable("CHECKED_OR", " checked=\"checked\"");
02403 }
02404 $this->tpl->setVariable("SEARCH", $this->lng->txt("search"));
02405 $this->tpl->parseCurrentBlock();
02406 }
02407 }
02408 if ($this->object->getInvitationMode() == MODE_PREDEFINED_USERS)
02409 {
02410 $invited_users = $this->object->getInvitedUsers();
02411 $buttons = array("disinvite");
02412 if (count($invited_users))
02413 {
02414 $this->outUserGroupTable("usr", $invited_users, "invited_user_result", "invited_user_row", $this->lng->txt("invited_users"), $buttons);
02415 }
02416 }
02417 if ($this->object->getInvitation() == INVITATION_ON)
02418 {
02419 $this->tpl->setCurrentBlock("invitation_mode");
02420 $this->tpl->setVariable("TEXT_MODE", $this->lng->txt("invitation_mode"));
02421 $this->tpl->setVariable("VALUE_UNLIMITED", $this->lng->txt("unlimited_users"));
02422 $this->tpl->setVariable("VALUE_PREDEFINED", $this->lng->txt("predefined_users"));
02423 if ($this->object->getInvitationMode() == MODE_PREDEFINED_USERS)
02424 {
02425 $this->tpl->setVariable("SELECTED_PREDEFINED", " selected=\"selected\"");
02426 }
02427 else
02428 {
02429 $this->tpl->setVariable("SELECTED_UNLIMITED", " selected=\"selected\"");
02430 }
02431 $this->tpl->parseCurrentBlock();
02432 }
02433 $this->tpl->setCurrentBlock("adm_content");
02434 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
02435 $this->tpl->setVariable("TEXT_INVITATION", $this->lng->txt("invitation"));
02436 $this->tpl->setVariable("VALUE_ON", $this->lng->txt("on"));
02437 $this->tpl->setVariable("VALUE_OFF", $this->lng->txt("off"));
02438 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
02439 if ($this->object->getInvitation() == INVITATION_ON)
02440 {
02441 $this->tpl->setVariable("SELECTED_ON", " selected=\"selected\"");
02442 }
02443 else
02444 {
02445 $this->tpl->setVariable("SELECTED_OFF", " selected=\"selected\"");
02446 }
02447 if ($rbacsystem->checkAccess("write", $this->ref_id) or $rbacsystem->checkAccess('invite', $this->ref_id)) {
02448 $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
02449 $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
02450 }
02451 $this->tpl->parseCurrentBlock();
02452 }
02453
02461 function deleteAllUserDataObject()
02462 {
02463 sendInfo($this->lng->txt("confirm_delete_all_user_data"));
02464 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_maintenance.html", true);
02465 $this->tpl->setCurrentBlock("confirm_delete");
02466 $this->tpl->setVariable("BTN_CONFIRM_DELETE_ALL", $this->lng->txt("confirm"));
02467 $this->tpl->setVariable("BTN_CANCEL_DELETE_ALL", $this->lng->txt("cancel"));
02468 $this->tpl->parseCurrentBlock();
02469 $this->tpl->setCurrentBlock("adm_content");
02470 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
02471 $this->tpl->parseCurrentBlock();
02472 }
02473
02481 function confirmDeleteAllUserDataObject()
02482 {
02483 $this->object->deleteAllUserData();
02484 sendInfo($this->lng->txt("svy_all_user_data_deleted"), true);
02485 $this->ctrl->redirect($this, "maintenance");
02486 }
02487
02495 function cancelDeleteAllUserDataObject()
02496 {
02497 $this->ctrl->redirect($this, "maintenance");
02498 }
02499
02507 function confirmDeleteSelectedUserDataObject()
02508 {
02509 $this->object->removeSelectedSurveyResults($_POST["chbUser"]);
02510 sendInfo($this->lng->txt("svy_selected_user_data_deleted"), true);
02511 $this->ctrl->redirect($this, "maintenance");
02512 }
02513
02521 function cancelDeleteSelectedUserDataObject()
02522 {
02523 $this->ctrl->redirect($this, "maintenance");
02524 }
02525
02533 function deleteSingleUserResultsObject()
02534 {
02535 if (count($_POST["chbUser"]) == 0)
02536 {
02537 $this->ctrl->redirect($this, "maintenance");
02538 }
02539 sendInfo($this->lng->txt("confirm_delete_single_user_data"));
02540 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_maintenance.html", true);
02541
02542 $this->tpl->setCurrentBlock("confirm_delete_selected");
02543 $this->tpl->setVariable("BTN_CONFIRM_DELETE_SELECTED", $this->lng->txt("confirm"));
02544 $this->tpl->setVariable("BTN_CANCEL_DELETE_SELECTED", $this->lng->txt("cancel"));
02545 $this->tpl->parseCurrentBlock();
02546
02547 foreach ($_POST["chbUser"] as $key => $value)
02548 {
02549 $this->tpl->setCurrentBlock("hidden");
02550 $this->tpl->setVariable("USER_ID", $value);
02551 $this->tpl->parseCurrentBlock();
02552 }
02553
02554 $this->tpl->setCurrentBlock("adm_content");
02555 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
02556 $this->tpl->parseCurrentBlock();
02557 }
02558
02559 function maintenanceObject()
02560 {
02561 $this->handleWriteAccess();
02562
02563 global $rbacsystem;
02564
02565 if ($rbacsystem->checkAccess("write", $this->ref_id))
02566 {
02567 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_maintenance.html", true);
02568 $total =& $this->object->getSurveyParticipants();
02569 if (count($total))
02570 {
02571 $color_class = array("tblrow1", "tblrow2");
02572 $counter = 0;
02573 foreach ($total as $finished_id => $user_data)
02574 {
02575 $user_name = $user_data["name"];
02576 $user_login = $user_data["login"];
02577 $this->tpl->setCurrentBlock("userrow");
02578 $this->tpl->setVariable("ROW_CLASS", $color_class[$counter % 2]);
02579 $this->tpl->setVariable("USER_ID", $finished_id);
02580 $this->tpl->setVariable("VALUE_USER_NAME", $user_name);
02581 $this->tpl->setVariable("VALUE_USER_LOGIN", $user_login);
02582 $last_access = $this->object->_getLastAccess($finished_id);
02583 $this->tpl->setVariable("LAST_ACCESS", ilFormat::formatDate(ilFormat::ftimestamp2datetimeDB($last_access)));
02584 $this->tpl->parseCurrentBlock();
02585 $counter++;
02586 }
02587 $this->tpl->setCurrentBlock("selectall");
02588 $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
02589 $counter++;
02590 $this->tpl->setVariable("ROW_CLASS", $color_class[$counter % 2]);
02591 $this->tpl->parseCurrentBlock();
02592 $this->tpl->setCurrentBlock("participanttable");
02593 $this->tpl->setVariable("USER_NAME", $this->lng->txt("name"));
02594 $this->tpl->setVariable("USER_LOGIN", $this->lng->txt("login"));
02595 $this->tpl->setVariable("LAST_ACCESS", $this->lng->txt("last_access"));
02596 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
02597 $this->tpl->setVariable("ARROW", $this->lng->txt("arrow_downright"));
02598 $this->tpl->setVariable("DELETE", $this->lng->txt("delete_user_data"));
02599 $this->tpl->parseCurrentBlock();
02600
02601 $this->tpl->setCurrentBlock("adm_content");
02602 $this->tpl->setVariable("BTN_DELETE_ALL", $this->lng->txt("svy_delete_all_user_data"));
02603
02604 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
02605 $this->tpl->parseCurrentBlock();
02606 }
02607 else
02608 {
02609 $this->tpl->setCurrentBlock("maintenance_information");
02610 $this->tpl->setVariable("MAINTENANCE_INFORMATION", $this->lng->txt("svy_maintenance_information_no_results"));
02611 $this->tpl->parseCurrentBlock();
02612 }
02613 }
02614 else
02615 {
02616 sendInfo($this->lng->txt("cannot_maintain_survey"));
02617 }
02618 }
02619
02627 function statusObject()
02628 {
02629 $this->handleWriteAccess();
02630 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_status.html", true);
02631 if (!$this->object->isComplete())
02632 {
02633 if (count($this->object->questions) == 0)
02634 {
02635 $this->tpl->setCurrentBlock("list_element");
02636 $this->tpl->setVariable("TEXT_ELEMENT", $this->lng->txt("svy_missing_questions"));
02637 $this->tpl->parseCurrentBlock();
02638 }
02639 if (strcmp($this->object->author, "") == 0)
02640 {
02641 $this->tpl->setCurrentBlock("list_element");
02642 $this->tpl->setVariable("TEXT_ELEMENT", $this->lng->txt("svy_missing_author"));
02643 $this->tpl->parseCurrentBlock();
02644 }
02645 if (strcmp($this->object->title, "") == 0)
02646 {
02647 $this->tpl->setCurrentBlock("list_element");
02648 $this->tpl->setVariable("TEXT_ELEMENT", $this->lng->txt("svy_missing_author"));
02649 $this->tpl->parseCurrentBlock();
02650 }
02651 $this->tpl->setCurrentBlock("status_list");
02652 $this->tpl->setVariable("TEXT_MISSING_ELEMENTS", $this->lng->txt("svy_status_missing_elements"));
02653 $this->tpl->parseCurrentBlock();
02654 }
02655 $this->tpl->setCurrentBlock("adm_content");
02656 if ($this->object->isComplete())
02657 {
02658 $this->tpl->setVariable("TEXT_STATUS_MESSAGE", $this->lng->txt("svy_status_ok"));
02659 $this->tpl->setVariable("STATUS_CLASS", "bold");
02660 }
02661 else
02662 {
02663 $this->tpl->setVariable("TEXT_STATUS_MESSAGE", $this->lng->txt("svy_status_missing"));
02664 $this->tpl->setVariable("STATUS_CLASS", "warning");
02665 }
02666 $this->tpl->parseCurrentBlock();
02667 }
02668
02669
02670
02671
02672 function exportObject()
02673 {
02674 $this->handleWriteAccess();
02675
02676 global $tree;
02677 global $rbacsystem;
02678
02679
02680 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
02681
02682
02683 $this->tpl->setCurrentBlock("btn_cell");
02684 $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "createExportFile"));
02685 $this->tpl->setVariable("BTN_TXT", $this->lng->txt("svy_create_export_file"));
02686 $this->tpl->parseCurrentBlock();
02687
02688 $export_dir = $this->object->getExportDirectory();
02689 $export_files = $this->object->getExportFiles($export_dir);
02690
02691
02692 include_once("./classes/class.ilTableGUI.php");
02693 $tbl = new ilTableGUI();
02694
02695
02696 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
02697
02698
02699 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.export_file_row.html", true);
02700
02701 $num = 0;
02702
02703 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
02704
02705 $tbl->setTitle($this->lng->txt("svy_export_files"));
02706
02707 $tbl->setHeaderNames(array("", $this->lng->txt("svy_file"),
02708 $this->lng->txt("svy_size"), $this->lng->txt("date") ));
02709
02710 $tbl->enabled["sort"] = false;
02711 $tbl->setColumnWidth(array("1%", "49%", "25%", "25%"));
02712
02713
02714 $tbl->setOrderColumn($_GET["sort_by"]);
02715 $tbl->setOrderDirection($_GET["sort_order"]);
02716 $tbl->setLimit($_GET["limit"]);
02717 $tbl->setOffset($_GET["offset"]);
02718 $tbl->setMaxCount($this->maxcount);
02719 $header_params = $this->ctrl->getParameterArray($this, "export");
02720 $tbl->setHeaderVars(array("", "file", "size", "date"), $header_params);
02721
02722
02723 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
02724
02725
02726 $tbl->setMaxCount(count($export_files));
02727 $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
02728
02729 $tbl->render();
02730 if(count($export_files) > 0)
02731 {
02732 $this->tpl->setVariable("COLUMN_COUNTS", 4);
02733
02734 $i=0;
02735 foreach($export_files as $exp_file)
02736 {
02737 $this->tpl->setCurrentBlock("tbl_content");
02738 $this->tpl->setVariable("TXT_FILENAME", $exp_file);
02739
02740 $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
02741 $this->tpl->setVariable("CSS_ROW", $css_row);
02742
02743 $this->tpl->setVariable("TXT_SIZE", filesize($export_dir."/".$exp_file));
02744 $this->tpl->setVariable("CHECKBOX_ID", $exp_file);
02745
02746 $file_arr = explode("__", $exp_file);
02747 $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s",$file_arr[0]));
02748
02749 $this->tpl->parseCurrentBlock();
02750 }
02751 $this->tpl->setCurrentBlock("selectall");
02752 $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
02753 $this->tpl->setVariable("CSS_ROW", $css_row);
02754 $this->tpl->parseCurrentBlock();
02755
02756 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
02757 $this->tpl->setCurrentBlock("tbl_action_btn");
02758 $this->tpl->setVariable("BTN_NAME", "confirmDeleteExportFile");
02759 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
02760 $this->tpl->parseCurrentBlock();
02761
02762 $this->tpl->setCurrentBlock("tbl_action_btn");
02763 $this->tpl->setVariable("BTN_NAME", "downloadExportFile");
02764 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("download"));
02765 $this->tpl->parseCurrentBlock();
02766 }
02767 else
02768 {
02769 $this->tpl->setCurrentBlock("notfound");
02770 $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
02771 $this->tpl->setVariable("NUM_COLS", 3);
02772 $this->tpl->parseCurrentBlock();
02773 }
02774
02775 $this->tpl->parseCurrentBlock();
02776 }
02777
02781 function createExportFileObject()
02782 {
02783 global $rbacsystem;
02784
02785 if ($rbacsystem->checkAccess("write", $this->ref_id))
02786 {
02787 include_once("./survey/classes/class.ilSurveyExport.php");
02788 $survey_exp = new ilSurveyExport($this->object);
02789 $survey_exp->buildExportFile();
02790 $this->ctrl->redirect($this, "export");
02791 }
02792 else
02793 {
02794 sendInfo("cannot_export_survey");
02795 }
02796 }
02797
02803 function importObject()
02804 {
02805 $this->getTemplateFile("import", "svy");
02806 $this->tpl->setCurrentBlock("option_qpl");
02807 include_once("./survey/classes/class.ilObjSurvey.php");
02808 $svy = new ilObjSurvey();
02809 $questionpools =& $svy->getAvailableQuestionpools(true);
02810 if (count($questionpools) == 0)
02811 {
02812 }
02813 else
02814 {
02815 foreach ($questionpools as $key => $value)
02816 {
02817 $this->tpl->setCurrentBlock("option_spl");
02818 $this->tpl->setVariable("OPTION_VALUE", $key);
02819 $this->tpl->setVariable("TXT_OPTION", $value);
02820 $this->tpl->parseCurrentBlock();
02821 }
02822 }
02823 $this->tpl->setVariable("TXT_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool"));
02824 $this->tpl->setVariable("OPTION_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool_option"));
02825 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
02826
02827 $this->tpl->setVariable("BTN_NAME", "upload");
02828 $this->tpl->setVariable("TXT_UPLOAD", $this->lng->txt("upload"));
02829 $this->tpl->setVariable("TXT_IMPORT_TST", $this->lng->txt("import_tst"));
02830 $this->tpl->setVariable("TXT_SELECT_MODE", $this->lng->txt("select_mode"));
02831 $this->tpl->setVariable("TXT_SELECT_FILE", $this->lng->txt("select_file"));
02832
02833 }
02834
02841 function uploadObject($redirect = true)
02842 {
02843 if ($_POST["spl"] < 1)
02844 {
02845 sendInfo($this->lng->txt("svy_select_questionpools"));
02846 $this->importObject();
02847 return;
02848 }
02849 if (strcmp($_FILES["xmldoc"]["tmp_name"], "") == 0)
02850 {
02851 sendInfo($this->lng->txt("svy_select_file_for_import"));
02852 $this->importObject();
02853 return;
02854 }
02855 include_once("./survey/classes/class.ilObjSurvey.php");
02856 $newObj = new ilObjSurvey();
02857 $newObj->setType($_GET["new_type"]);
02858 $newObj->setTitle("dummy");
02859 $newObj->setDescription("dummy");
02860 $newObj->create(true);
02861 $newObj->createReference();
02862 $newObj->putInTree($_GET["ref_id"]);
02863 $newObj->setPermissions($_GET["ref_id"]);
02864 $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
02865
02866
02867 $newObj->importObject($_FILES["xmldoc"], $_POST["spl"]);
02868
02869 $newObj->update();
02870 $newObj->saveToDb();
02871 if ($redirect)
02872 {
02873 include_once "./classes/class.ilUtil.php";
02874 ilUtil::redirect($this->getReturnLocation("upload",$this->ctrl->getTargetScript()."?".$this->link_params));
02875 }
02876 return $newObj->getRefId();
02877 }
02878
02882 function createObject()
02883 {
02884 global $rbacsystem;
02885 $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
02886 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
02887 {
02888 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
02889 }
02890 else
02891 {
02892 $this->getTemplateFile("create", $new_type);
02893
02894 include_once("./survey/classes/class.ilObjSurvey.php");
02895 $svy = new ilObjSurvey();
02896
02897 $surveys =& ilObjSurvey::_getAvailableSurveys(true);
02898 if (count($surveys) > 0)
02899 {
02900 foreach ($surveys as $key => $value)
02901 {
02902 $this->tpl->setCurrentBlock("option_svy");
02903 $this->tpl->setVariable("OPTION_VALUE_SVY", $key);
02904 $this->tpl->setVariable("TXT_OPTION_SVY", $value);
02905 if ($_POST["svy"] == $key)
02906 {
02907 $this->tpl->setVariable("OPTION_SELECTED_SVY", " selected=\"selected\"");
02908 }
02909 $this->tpl->parseCurrentBlock();
02910 }
02911 }
02912
02913 $questionpools =& $svy->getAvailableQuestionpools($use_obj_id = true, $could_be_offline = true);
02914 if (count($questionpools) > 0)
02915 {
02916 foreach ($questionpools as $key => $value)
02917 {
02918 $this->tpl->setCurrentBlock("option_spl");
02919 $this->tpl->setVariable("OPTION_VALUE", $key);
02920 $this->tpl->setVariable("TXT_OPTION", $value);
02921 if ($_POST["spl"] == $key)
02922 {
02923 $this->tpl->setVariable("OPTION_SELECTED", " selected=\"selected\"");
02924 }
02925 $this->tpl->parseCurrentBlock();
02926 }
02927 }
02928
02929 $data = array();
02930 $data["fields"] = array();
02931 include_once "./classes/class.ilUtil.php";
02932 $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
02933 $data["fields"]["desc"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["desc"]);
02934
02935 foreach ($data["fields"] as $key => $val)
02936 {
02937 $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
02938 $this->tpl->setVariable(strtoupper($key), $val);
02939
02940 if ($this->prepare_output)
02941 {
02942 $this->tpl->parseCurrentBlock();
02943 }
02944 }
02945
02946 $this->ctrl->setParameter($this, "new_type", $this->type);
02947
02948
02949 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
02950 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
02951 $this->tpl->setVariable("TXT_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool_short"));
02952 $this->tpl->setVariable("OPTION_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool_option"));
02953 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
02954 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
02955 $this->tpl->setVariable("CMD_SUBMIT", "save");
02956 $this->tpl->setVariable("TARGET", ' target="'.
02957 ilFrameTargetInfo::_getFrame("MainContent").'" ');
02958 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
02959
02960 $this->tpl->setVariable("TXT_IMPORT_SVY", $this->lng->txt("import_svy"));
02961 $this->tpl->setVariable("TXT_SVY_FILE", $this->lng->txt("svy_upload_file"));
02962 $this->tpl->setVariable("TXT_IMPORT", $this->lng->txt("import"));
02963
02964 $this->tpl->setVariable("TXT_DUPLICATE_SVY", $this->lng->txt("duplicate_svy"));
02965 $this->tpl->setVariable("TXT_SELECT_SVY", $this->lng->txt("obj_svy"));
02966 $this->tpl->setVariable("OPTION_SELECT_SVY", $this->lng->txt("select_svy_option"));
02967 $this->tpl->setVariable("TXT_DUPLICATE", $this->lng->txt("duplicate"));
02968
02969 $this->tpl->setVariable("TYPE_IMG", ilUtil::getImagePath('icon_svy.gif'));
02970 $this->tpl->setVariable("ALT_IMG",$this->lng->txt("obj_svy"));
02971 $this->tpl->setVariable("TYPE_IMG2", ilUtil::getImagePath('icon_svy.gif'));
02972 $this->tpl->setVariable("ALT_IMG2",$this->lng->txt("obj_svy"));
02973 $this->tpl->setVariable("TYPE_IMG3", ilUtil::getImagePath('icon_svy.gif'));
02974 $this->tpl->setVariable("ALT_IMG3",$this->lng->txt("obj_svy"));
02975 }
02976 }
02977
02981 function cloneAllObject()
02982 {
02983 if ($_POST["svy"] < 1)
02984 {
02985 sendInfo($this->lng->txt("svy_select_surveys"));
02986 $this->createObject();
02987 return;
02988 }
02989 include_once "./survey/classes/class.ilObjSurvey.php";
02990 include_once "./classes/class.ilUtil.php";
02991 $ref_id = ilObjSurvey::_clone($_POST["svy"]);
02992
02993 sendInfo($this->lng->txt("object_duplicated"),true);
02994
02995 ilUtil::redirect("ilias.php?ref_id=".$ref_id.
02996 "&baseClass=ilObjSurveyGUI");
02997 }
02998
03002 function importFileObject()
03003 {
03004 if ($_POST["spl"] < 1)
03005 {
03006 sendInfo($this->lng->txt("svy_select_questionpools"));
03007 $this->createObject();
03008 return;
03009 }
03010 if (strcmp($_FILES["xmldoc"]["tmp_name"], "") == 0)
03011 {
03012 sendInfo($this->lng->txt("svy_select_file_for_import"));
03013 $this->createObject();
03014 return;
03015 }
03016 $this->ctrl->setParameter($this, "new_type", $this->type);
03017 $ref_id = $this->uploadObject(false);
03018
03019 sendInfo($this->lng->txt("object_imported"),true);
03020
03021 ilUtil::redirect("ilias.php?ref_id=".$ref_id.
03022 "&baseClass=ilObjSurveyGUI");
03023
03024 }
03025
03029 function downloadExportFileObject()
03030 {
03031 if(!isset($_POST["file"]))
03032 {
03033 sendInfo($this->lng->txt("no_checkbox"), true);
03034 $this->ctrl->redirect($this, "export");
03035 }
03036
03037 if (count($_POST["file"]) > 1)
03038 {
03039 sendInfo($this->lng->txt("select_max_one_item"), true);
03040 $this->ctrl->redirect($this, "export");
03041 }
03042
03043
03044 $export_dir = $this->object->getExportDirectory();
03045 include_once "./classes/class.ilUtil.php";
03046 ilUtil::deliverFile($export_dir."/".$_POST["file"][0],
03047 $_POST["file"][0]);
03048 }
03049
03053 function confirmDeleteExportFileObject()
03054 {
03055 if(!isset($_POST["file"]))
03056 {
03057 sendInfo($this->lng->txt("no_checkbox"), true);
03058 $this->ctrl->redirect($this, "export");
03059 }
03060
03061
03062
03063
03064 $_SESSION["ilExportFiles"] = $_POST["file"];
03065
03066 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html", true);
03067
03068 sendInfo($this->lng->txt("info_delete_sure"));
03069
03070 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
03071
03072
03073 $this->tpl->setCurrentBlock("table_header");
03074 $this->tpl->setVariable("TEXT",$this->lng->txt("objects"));
03075 $this->tpl->parseCurrentBlock();
03076
03077
03078 $counter = 0;
03079 include_once "./classes/class.ilUtil.php";
03080 foreach($_POST["file"] as $file)
03081 {
03082 $this->tpl->setCurrentBlock("table_row");
03083 $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_file.gif"));
03084 $this->tpl->setVariable("TEXT_IMG_OBJ", $this->lng->txt("file_icon"));
03085 $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
03086 $this->tpl->setVariable("TEXT_CONTENT", $file);
03087 $this->tpl->parseCurrentBlock();
03088 }
03089
03090
03091 $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
03092 $buttons = array( "cancelDeleteExportFile" => $this->lng->txt("cancel"),
03093 "deleteExportFile" => $this->lng->txt("confirm"));
03094 foreach ($buttons as $name => $value)
03095 {
03096 $this->tpl->setCurrentBlock("operation_btn");
03097 $this->tpl->setVariable("BTN_NAME",$name);
03098 $this->tpl->setVariable("BTN_VALUE",$value);
03099 $this->tpl->parseCurrentBlock();
03100 }
03101 }
03102
03103
03107 function cancelDeleteExportFileObject()
03108 {
03109 session_unregister("ilExportFiles");
03110 $this->ctrl->redirect($this, "export");
03111 }
03112
03113
03117 function deleteExportFileObject()
03118 {
03119 $export_dir = $this->object->getExportDirectory();
03120 foreach($_SESSION["ilExportFiles"] as $file)
03121 {
03122 $exp_file = $export_dir."/".$file;
03123 $exp_dir = $export_dir."/".substr($file, 0, strlen($file) - 4);
03124 if (@is_file($exp_file))
03125 {
03126 unlink($exp_file);
03127 }
03128 if (@is_dir($exp_dir))
03129 {
03130 include_once "./classes/class.ilUtil.php";
03131 ilUtil::delDir($exp_dir);
03132 }
03133 }
03134 $this->ctrl->redirect($this, "export");
03135 }
03136
03137 function setCodeLanguageObject()
03138 {
03139 if (strcmp($_POST["lang"], "-1") != 0)
03140 {
03141 global $ilUser;
03142 $ilUser->writePref("survey_code_language", $_POST["lang"]);
03143 }
03144 $this->ctrl->redirect($this, "codes");
03145 }
03146
03154 function codesObject()
03155 {
03156 $this->handleWriteAccess();
03157
03158 global $rbacsystem;
03159 global $ilUser;
03160
03161 $default_lang = $ilUser->getPref("survey_code_language");
03162
03163 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_codes.html", true);
03164 if ($rbacsystem->checkAccess("write", $this->ref_id))
03165 {
03166 $codecount = $this->object->getSurveyCodesCount();
03167 if ($codecount)
03168 {
03169 $maxentries = $ilUser->getPref("hits_per_page");
03170 if ($maxentries < 1)
03171 {
03172 $maxentries = 9999;
03173 }
03174
03175 $survey_codes =& $this->object->getSurveyCodesTableData($default_lang, $_GET["offset"], $maxentries, $_GET["sort_by"], $_GET["sort_order"]);
03176 $headervars = array("", "counter", "date", "used", "url");
03177
03178 include_once "./classes/class.ilTableGUI.php";
03179 $tbl = new ilTableGUI(0, FALSE);
03180 $tbl->setTitle($this->lng->txt("survey_code"));
03181 $header_names = array(
03182 "",
03183 $this->lng->txt("survey_code"),
03184 $this->lng->txt("create_date"),
03185 $this->lng->txt("survey_code_used"),
03186 $this->lng->txt("survey_code_url")
03187 );
03188 $tbl->setHeaderNames($header_names);
03189
03190 $tbl->disable("sort");
03191 $tbl->disable("auto_sort");
03192 $tbl->disable("title");
03193 $tbl->setLimit($maxentries);
03194 $tbl->setOffset($_GET["offset"]);
03195 $tbl->setData($survey_codes);
03196 $tbl->setMaxCount($codecount);
03197 $tbl->setOrderDirection($_GET["sort_order"]);
03198
03199 $header_params = $this->ctrl->getParameterArray($this, "codes");
03200 $tbl->setHeaderVars($headervars, $header_params);
03201
03202
03203 $tbl->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next"));
03204
03205 $tableoutput = $tbl->render();
03206 $this->tpl->setVariable("CODES_TABLE", $tableoutput);
03207 }
03208 else
03209 {
03210 $this->tpl->setCurrentBlock("emptyrow");
03211 $this->tpl->setVariable("NO_CODES", $this->lng->txt("survey_code_no_codes"));
03212 $this->tpl->parseCurrentBlock();
03213 }
03214
03215 $languages = $this->lng->getInstalledLanguages();
03216 foreach ($languages as $lang)
03217 {
03218 $this->tpl->setCurrentBlock("option_lang");
03219 $this->tpl->setVariable("VALUE_LANG", $lang);
03220 $this->tpl->setVariable("TEXT_LANG", $this->lng->txt("lang_$lang"));
03221 if (strcmp($lang, $default_lang) == 0)
03222 {
03223 $this->tpl->setVariable("SELECTED_LANG", " selected=\"selected\"");
03224 }
03225 $this->tpl->parseCurrentBlock();
03226 }
03227
03228 $this->tpl->setCurrentBlock("adm_content");
03229 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
03230 $this->tpl->setVariable("TEXT_CREATE", $this->lng->txt("create"));
03231 $this->tpl->setVariable("TEXT_SURVEY_CODES", $this->lng->txt("new_survey_codes"));
03232 $this->tpl->setVariable("TEXT_SURVEY_CODES_LANG", $this->lng->txt("survey_codes_lang"));
03233 $this->tpl->setVariable("TEXT_NO_LANGUAGE_SELECTED", $this->lng->txt("please_select"));
03234 $this->tpl->setVariable("VALUE_ACTIVATE", $this->lng->txt("select"));
03235 $this->tpl->parseCurrentBlock();
03236 }
03237 else
03238 {
03239 sendInfo($this->lng->txt("cannot_create_survey_codes"));
03240 }
03241 }
03242
03250 function createSurveyCodesObject()
03251 {
03252 if (preg_match("/\d+/", $_POST["nrOfCodes"]))
03253 {
03254 $this->object->createSurveyCodes($_POST["nrOfCodes"]);
03255 }
03256 else
03257 {
03258 sendInfo($this->lng->txt("enter_valid_number_of_codes"), true);
03259 }
03260 $this->ctrl->redirect($this, "codes");
03261 }
03262
03270 function addConstraintForm($step, &$survey_questions, $questions = false)
03271 {
03272 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_add_constraint.html", true);
03273 if (is_array($questions))
03274 {
03275 foreach ($questions as $question)
03276 {
03277 $this->tpl->setCurrentBlock("option_q");
03278 $this->tpl->setVariable("OPTION_VALUE", $question["question_id"]);
03279 $this->tpl->setVariable("OPTION_TEXT", $question["title"] . " (" . $this->lng->txt($question["type_tag"]) . ")");
03280 if ($question["question_id"] == $_POST["q"])
03281 {
03282 $this->tpl->setVariable("OPTION_CHECKED", " selected=\"selected\"");
03283 }
03284 $this->tpl->parseCurrentBlock();
03285 }
03286 }
03287
03288 if ($step > 1)
03289 {
03290 $relations = $this->object->getAllRelations();
03291 switch ($survey_questions[$_POST["q"]]["type_tag"])
03292 {
03293 case "SurveyNominalQuestion":
03294 foreach ($relations as $rel_id => $relation)
03295 {
03296 if ((strcmp($relation["short"], "=") == 0) or (strcmp($relation["short"], "<>") == 0))
03297 {
03298 $this->tpl->setCurrentBlock("option_r");
03299 $this->tpl->setVariable("OPTION_VALUE", $rel_id);
03300 $this->tpl->setVariable("OPTION_TEXT", $relation["short"]);
03301 if ($rel_id == $_POST["r"])
03302 {
03303 $this->tpl->setVariable("OPTION_CHECKED", " selected=\"selected\"");
03304 }
03305 $this->tpl->parseCurrentBlock();
03306 }
03307 }
03308 break;
03309 case "SurveyOrdinalQuestion":
03310 case "SurveyMetricQuestion":
03311 foreach ($relations as $rel_id => $relation)
03312 {
03313 $this->tpl->setCurrentBlock("option_r");
03314 $this->tpl->setVariable("OPTION_VALUE", $rel_id);
03315 $this->tpl->setVariable("OPTION_TEXT", $relation["short"]);
03316 if ($rel_id == $_POST["r"])
03317 {
03318 $this->tpl->setVariable("OPTION_CHECKED", " selected=\"selected\"");
03319 }
03320 $this->tpl->parseCurrentBlock();
03321 }
03322 break;
03323 }
03324 $this->tpl->setCurrentBlock("select_relation");
03325 $this->tpl->setVariable("SELECT_RELATION", $this->lng->txt("step") . " 2: " . $this->lng->txt("select_relation"));
03326 $this->tpl->parseCurrentBlock();
03327 }
03328
03329 if ($step > 2)
03330 {
03331 $variables =& $this->object->getVariables($_POST["q"]);
03332 switch ($survey_questions[$_POST["q"]]["type_tag"])
03333 {
03334 case "SurveyNominalQuestion":
03335 case "SurveyOrdinalQuestion":
03336 foreach ($variables as $sequence => $row)
03337 {
03338 $this->tpl->setCurrentBlock("option_v");
03339 $this->tpl->setVariable("OPTION_VALUE", $sequence);
03340 $this->tpl->setVariable("OPTION_TEXT", ($sequence+1) . " - " . $row->title);
03341 $this->tpl->parseCurrentBlock();
03342 }
03343 break;
03344 case "SurveyMetricQuestion":
03345 $this->tpl->setCurrentBlock("textfield");
03346 $this->tpl->setVariable("TEXTFIELD_VALUE", "");
03347 $this->tpl->parseCurrentBlock();
03348 break;
03349 }
03350 $this->tpl->setCurrentBlock("select_value");
03351 if (strcmp($survey_questions[$_POST["q"]]["type_tag"], "SurveyMetricQuestion") == 0)
03352 {
03353 $this->tpl->setVariable("SELECT_VALUE", $this->lng->txt("step") . " 3: " . $this->lng->txt("enter_value"));
03354 }
03355 else
03356 {
03357 $this->tpl->setVariable("SELECT_VALUE", $this->lng->txt("step") . " 3: " . $this->lng->txt("select_value"));
03358 }
03359 $this->tpl->parseCurrentBlock();
03360 }
03361
03362 $this->tpl->setCurrentBlock("buttons");
03363 $this->tpl->setVariable("BTN_CONTINUE", $this->lng->txt("continue"));
03364 switch ($step)
03365 {
03366 case 1:
03367 $this->tpl->setVariable("COMMAND", "constraintStep2");
03368 $this->tpl->setVariable("COMMAND_BACK", "constraints");
03369 break;
03370 case 2:
03371 $this->tpl->setVariable("COMMAND", "constraintStep3");
03372 $this->tpl->setVariable("COMMAND_BACK", "constraintStep1");
03373 break;
03374 case 3:
03375 $this->tpl->setVariable("COMMAND", "constraintsAdd");
03376 $this->tpl->setVariable("COMMAND_BACK", "constraintStep2");
03377 break;
03378 }
03379 $this->tpl->setVariable("BTN_BACK", $this->lng->txt("back"));
03380 $this->tpl->parseCurrentBlock();
03381 $this->tpl->setCurrentBlock("adm_content");
03382 $title = "";
03383 if ($survey_questions[$_SESSION["constraintstructure"][$_GET["start"]][0]]["questionblock_id"] > 0)
03384 {
03385 $title = $this->lng->txt("questionblock") . ": " . $survey_questions[$_SESSION["constraintstructure"][$_GET["start"]][0]]["questionblock_title"];
03386 }
03387 else
03388 {
03389 $title = $this->lng->txt($survey_questions[$_SESSION["constraintstructure"][$_GET["start"]][0]]["type_tag"]) . ": " . $survey_questions[$_SESSION["constraintstructure"][$_GET["start"]][0]]["title"];
03390 }
03391 $this->tpl->setVariable("CONSTRAINT_QUESTION_TEXT", $title);
03392 $this->tpl->setVariable("SELECT_PRIOR_QUESTION", $this->lng->txt("step") . " 1: " . $this->lng->txt("select_prior_question"));
03393 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this) . "&start=" . $_GET["start"]);
03394 $this->tpl->parseCurrentBlock();
03395 }
03396
03404 function constraintsAddObject()
03405 {
03406 $survey_questions =& $this->object->getSurveyQuestions();
03407 $structure =& $_SESSION["constraintstructure"];
03408 $include_elements = $_SESSION["includeElements"];
03409 foreach ($include_elements as $elementCounter)
03410 {
03411 if (is_array($structure[$elementCounter]))
03412 {
03413 foreach ($structure[$elementCounter] as $key => $question_id)
03414 {
03415 $this->object->addConstraint($question_id, $_POST["q"], $_POST["r"], $_POST["v"]);
03416 }
03417 }
03418 }
03419 unset($_SESSION["includeElements"]);
03420 unset($_SESSION["constraintstructure"]);
03421 $this->ctrl->redirect($this, "constraints");
03422 }
03423
03431 function constraintStep3Object()
03432 {
03433 $survey_questions =& $this->object->getSurveyQuestions();
03434 $option_questions = array();
03435 array_push($option_questions, array("question_id" => $_POST["q"], "title" => $survey_questions[$_POST["q"]]["title"], "type_tag" => $survey_questions[$_POST["q"]]["type_tag"]));
03436 $this->addConstraintForm(3, $survey_questions, $option_questions);
03437 }
03438
03446 function constraintStep2Object()
03447 {
03448 $survey_questions =& $this->object->getSurveyQuestions();
03449 $option_questions = array();
03450 array_push($option_questions, array("question_id" => $_POST["q"], "title" => $survey_questions[$_POST["q"]]["title"], "type_tag" => $survey_questions[$_POST["q"]]["type_tag"]));
03451 $this->addConstraintForm(2, $survey_questions, $option_questions);
03452 }
03453
03461 function constraintStep1Object()
03462 {
03463 $survey_questions =& $this->object->getSurveyQuestions();
03464 $structure =& $_SESSION["constraintstructure"];
03465 $start = $_GET["start"];
03466 $option_questions = array();
03467 for ($i = 1; $i < $start; $i++)
03468 {
03469 if (is_array($structure[$i]))
03470 {
03471 foreach ($structure[$i] as $key => $question_id)
03472 {
03473 if (strcmp($survey_questions[$question_id]["type_tag"], "SurveyTextQuestion") != 0)
03474 {
03475 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"]));
03476 }
03477 }
03478 }
03479 }
03480 if (count($option_questions) == 0)
03481 {
03482 unset($_SESSION["includeElements"]);
03483 unset($_SESSION["constraintstructure"]);
03484 sendInfo($this->lng->txt("constraints_no_nonessay_available"), true);
03485 $this->ctrl->redirect($this, "constraints");
03486 }
03487 $this->addConstraintForm(1, $survey_questions, $option_questions);
03488 }
03489
03497 function deleteConstraintsObject()
03498 {
03499 $survey_questions =& $this->object->getSurveyQuestions();
03500 $structure =& $_SESSION["constraintstructure"];
03501 foreach ($_POST as $key => $value)
03502 {
03503 if (preg_match("/^constraint_(\d+)_(\d+)/", $key, $matches))
03504 {
03505 foreach ($structure[$matches[1]] as $key => $question_id)
03506 {
03507 $this->object->deleteConstraint($matches[2], $question_id);
03508 }
03509 }
03510 }
03511
03512 $this->ctrl->redirect($this, "constraints");
03513 }
03514
03515 function createConstraintsObject()
03516 {
03517 $include_elements = $_POST["includeElements"];
03518 if ((!is_array($include_elements)) || (count($include_elements) == 0))
03519 {
03520 sendInfo($this->lng->txt("constraints_no_questions_or_questionblocks_selected"), true);
03521 $this->ctrl->redirect($this, "constraints");
03522 }
03523 else if (count($include_elements) >= 1)
03524 {
03525 $_SESSION["includeElements"] = $include_elements;
03526 sort($include_elements, SORT_NUMERIC);
03527 $_GET["start"] = $include_elements[0];
03528 $this->constraintStep1Object();
03529 }
03530 }
03531
03539 function constraintsObject()
03540 {
03541 $this->handleWriteAccess();
03542
03543 global $rbacsystem;
03544
03545 $hasDatasets = $this->object->_hasDatasets($this->object->getSurveyId());
03546 $step = 0;
03547 if (array_key_exists("step", $_GET)) $step = $_GET["step"];
03548 switch ($step)
03549 {
03550 case 1:
03551 $this->constraintStep1Object();
03552 return;
03553 break;
03554 case 2:
03555 return;
03556 break;
03557 case 3:
03558 return;
03559 break;
03560 }
03561
03562 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_constraints_list.html", true);
03563 $survey_questions =& $this->object->getSurveyQuestions();
03564 $last_questionblock_title = "";
03565 $counter = 1;
03566 $structure = array();
03567 $colors = array("tblrow1", "tblrow2");
03568 foreach ($survey_questions as $question_id => $data)
03569 {
03570 $title = $data["title"];
03571 $show = true;
03572 if ($data["questionblock_id"] > 0)
03573 {
03574 $title = $data["questionblock_title"];
03575 $type = $this->lng->txt("questionblock");
03576 if (strcmp($title, $last_questionblock_title) != 0)
03577 {
03578 $last_questionblock_title = $title;
03579 $structure[$counter] = array();
03580 array_push($structure[$counter], $data["question_id"]);
03581 }
03582 else
03583 {
03584 array_push($structure[$counter-1], $data["question_id"]);
03585 $show = false;
03586 }
03587 }
03588 else
03589 {
03590 $structure[$counter] = array($data["question_id"]);
03591 $type = $this->lng->txt("question");
03592 }
03593 if ($show)
03594 {
03595 if ($counter == 1)
03596 {
03597 $this->tpl->setCurrentBlock("description");
03598 $this->tpl->setVariable("DESCRIPTION", $this->lng->txt("constraints_first_question_description"));
03599 $this->tpl->parseCurrentBlock();
03600 }
03601 else
03602 {
03603 $constraints =& $this->object->getConstraints($data["question_id"]);
03604 $rowcount = 0;
03605 if (count($constraints))
03606 {
03607 foreach ($constraints as $constraint)
03608 {
03609 $value = "";
03610 $variables =& $this->object->getVariables($constraint["question"]);
03611 switch ($survey_questions[$constraint["question"]]["type_tag"])
03612 {
03613 case "SurveyMetricQuestion":
03614 $value = $constraint["value"];
03615 break;
03616 case "SurveyNominalQuestion":
03617 case "SurveyOrdinalQuestion":
03618 $value = sprintf("%d", $constraint["value"]+1) . " - " . $variables[$constraint["value"]]->title;
03619 break;
03620 }
03621 $this->tpl->setCurrentBlock("constraint");
03622 $this->tpl->setVariable("CONSTRAINT_TEXT", $survey_questions[$constraint["question"]]["title"] . " " . $constraint["short"] . " $value");
03623 $this->tpl->setVariable("SEQUENCE_ID", $counter);
03624 $this->tpl->setVariable("CONSTRAINT_ID", $constraint["id"]);
03625 $this->tpl->setVariable("COLOR_CLASS", $colors[$rowcount % 2]);
03626 $rowcount++;
03627 $this->tpl->parseCurrentBlock();
03628 }
03629 if ($rbacsystem->checkAccess("write", $this->ref_id) and !$hasDatasets)
03630 {
03631 $this->tpl->setCurrentBlock("delete_button");
03632 $this->tpl->setVariable("BTN_DELETE", $this->lng->txt("delete"));
03633 include_once "./classes/class.ilUtil.php";
03634 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\">");
03635 $this->tpl->parseCurrentBlock();
03636 }
03637 }
03638 else
03639 {
03640 $this->tpl->setCurrentBlock("empty_row");
03641 $this->tpl->setVariable("EMPTY_TEXT", $this->lng->txt("no_available_constraints"));
03642 $this->tpl->setVariable("COLOR_CLASS", $colors[$rowcount % 2]);
03643 $this->tpl->parseCurrentBlock();
03644 }
03645 $this->tpl->setCurrentBlock("question");
03646 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
03647 $this->tpl->setVariable("DEFINED_PRECONDITIONS", $this->lng->txt("existing_constraints"));
03648 $this->tpl->parseCurrentBlock();
03649 }
03650 if ($counter != 1)
03651 {
03652 $this->tpl->setCurrentBlock("include_elements");
03653 $this->tpl->setVariable("QUESTION_NR", "$counter");
03654 $this->tpl->parseCurrentBlock();
03655 }
03656 $this->tpl->setCurrentBlock("constraint_section");
03657 $this->tpl->setVariable("QUESTION_NR", "$counter");
03658 $this->tpl->setVariable("TITLE", "$title");
03659 $icontype = "question.gif";
03660 if ($data["questionblock_id"] > 0)
03661 {
03662 $icontype = "questionblock.gif";
03663 $this->tpl->setVariable("TYPE", "$type: ");
03664 }
03665 include_once "./classes/class.ilUtil.php";
03666 $this->tpl->setVariable("ICON_HREF", ilUtil::getImagePath($icontype, true));
03667 $this->tpl->setVariable("ICON_ALT", $type);
03668 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
03669 $this->tpl->parseCurrentBlock();
03670 $counter++;
03671 }
03672 }
03673 if ($rbacsystem->checkAccess("write", $this->ref_id) and !$hasDatasets)
03674 {
03675 $this->tpl->setCurrentBlock("selectall");
03676 $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
03677 $counter++;
03678 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
03679 $this->tpl->parseCurrentBlock();
03680
03681 $this->tpl->setCurrentBlock("buttons");
03682 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\">");
03683 $this->tpl->setVariable("BTN_CREATE_CONSTRAINTS", $this->lng->txt("constraint_add"));
03684 $this->tpl->parseCurrentBlock();
03685 }
03686 $this->tpl->setCurrentBlock("adm_content");
03687 $this->tpl->setVariable("CONSTRAINTS_INTRODUCTION", $this->lng->txt("constraints_introduction"));
03688 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
03689 $this->tpl->setVariable("CONSTRAINTS_HEADER", $this->lng->txt("constraints_list_of_entities"));
03690 $this->tpl->parseCurrentBlock();
03691 $_SESSION["constraintstructure"] = $structure;
03692 if ($hasDatasets)
03693 {
03694 sendInfo($this->lng->txt("survey_has_datasets_warning"));
03695 }
03696 }
03697
03703 function infoScreenObject()
03704 {
03705 $this->ctrl->setCmd("showSummary");
03706 $this->ctrl->setCmdClass("ilinfoscreengui");
03707 $this->infoScreen();
03708 }
03709
03713 function infoScreen()
03714 {
03715 global $ilAccess;
03716 global $ilUser;
03717
03718 if (!$ilAccess->checkAccess("visible", "", $this->ref_id))
03719 {
03720 $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
03721 }
03722
03723 include_once("classes/class.ilInfoScreenGUI.php");
03724 $info = new ilInfoScreenGUI($this);
03725 include_once "./survey/classes/class.ilSurveyExecutionGUI.php";
03726 $output_gui =& new ilSurveyExecutionGUI($this->object);
03727 $info->setFormAction($this->ctrl->getFormAction($output_gui));
03728 $info->enablePrivateNotes();
03729 $anonymize_key = NULL;
03730 if ($this->object->getAnonymize() == 1)
03731 {
03732 if ($_SESSION["anonymous_id"])
03733 {
03734 $anonymize_key = $_SESSION["anonymous_id"];
03735 }
03736 else if ($_POST["anonymous_id"])
03737 {
03738 $anonymize_key = $_POST["anonymous_id"];
03739 }
03740 }
03741 $canStart = $this->object->canStartSurvey($anonymize_key);
03742 $showButtons = $canStart["result"];
03743 if (!$showButtons) sendInfo(implode("<br />", $canStart["messages"]));
03744
03745 if ($showButtons)
03746 {
03747
03748 if (!$this->object->getAnonymize())
03749 {
03750 $survey_started = $this->object->isSurveyStarted($ilUser->getId(), "");
03751
03752 if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
03753 {
03754 sendInfo($this->lng->txt("anonymous_with_personalized_survey"));
03755 }
03756 else
03757 {
03758 if ($survey_started === 1)
03759 {
03760 sendInfo($this->lng->txt("already_completed_survey"));
03761 }
03762 elseif ($survey_started === 0)
03763 {
03764 $info->addFormButton("resume", $this->lng->txt("resume_survey"));
03765 }
03766 elseif ($survey_started === FALSE)
03767 {
03768 $info->addFormButton("start", $this->lng->txt("start_survey"));
03769 }
03770 }
03771 }
03772
03773 else if ($this->object->getAnonymize() && !$this->object->isAccessibleWithoutCode())
03774 {
03775 if (($_SESSION["AccountId"] == ANONYMOUS_USER_ID) && (strlen($_POST["anonymous_id"]) == 0) && (strlen($_SESSION["anonymous_id"]) == 0))
03776 {
03777 $info->setFormAction($this->ctrl->getFormAction($this));
03778 $info->addSection($this->lng->txt("anonymization"));
03779 $info->addProperty("", $this->lng->txt("anonymize_anonymous_introduction"));
03780 $info->addPropertyTextinput($this->lng->txt("enter_anonymous_id"), "anonymous_id", "", 8, "infoScreen", $this->lng->txt("submit"));
03781 }
03782 else
03783 {
03784 if (strlen($_POST["anonymous_id"]) > 0)
03785 {
03786 if (!$this->object->checkSurveyCode($_POST["anonymous_id"]))
03787 {
03788 sendInfo("wrong_survey_code_used");
03789 }
03790 else
03791 {
03792 $anonymize_key = $_POST["anonymous_id"];
03793 }
03794 }
03795 else if (strlen($_SESSION["anonymous_id"]) > 0)
03796 {
03797 if (!$this->object->checkSurveyCode($_SESSION["anonymous_id"]))
03798 {
03799 sendInfo($this->lng->txt("wrong_survey_code_used"));
03800 }
03801 else
03802 {
03803 $anonymize_key = $_SESSION["anonymous_id"];
03804 }
03805 }
03806 else
03807 {
03808
03809 $anonymize_key = $this->object->getUserAccessCode($ilUser->getId());
03810 if (!strlen($anonymize_key))
03811 {
03812 $anonymize_key = $this->object->createNewAccessCode();
03813 $this->object->saveUserAccessCode($ilUser->getId(), $anonymize_key);
03814 }
03815 }
03816 $info->addHiddenElement("anonymous_id", $anonymize_key);
03817 $survey_started = $this->object->isSurveyStarted($ilUser->getId(), $anonymize_key);
03818 if ($survey_started === 1)
03819 {
03820 sendInfo($this->lng->txt("already_completed_survey"));
03821 }
03822 elseif ($survey_started === 0)
03823 {
03824 $info->addFormButton("resume", $this->lng->txt("resume_survey"));
03825 }
03826 elseif ($survey_started === FALSE)
03827 {
03828 $info->addFormButton("start", $this->lng->txt("start_survey"));
03829 }
03830 }
03831 }
03832 else
03833 {
03834
03835 $survey_started = $this->object->isSurveyStarted($ilUser->getId(), "");
03836 if ($survey_started === 1)
03837 {
03838 sendInfo($this->lng->txt("already_completed_survey"));
03839 }
03840 elseif ($survey_started === 0)
03841 {
03842 $info->addFormButton("resume", $this->lng->txt("resume_survey"));
03843 }
03844 elseif ($survey_started === FALSE)
03845 {
03846 $info->addFormButton("start", $this->lng->txt("start_survey"));
03847 }
03848 }
03849 }
03850
03851 if (strlen($this->object->getIntroduction()))
03852 {
03853 $introduction = $this->object->getIntroduction();
03854 $info->addSection($this->lng->txt("introduction"));
03855 $info->addProperty("", $this->object->prepareTextareaOutput($introduction));
03856 }
03857
03858 $info->addSection($this->lng->txt("svy_general_properties"));
03859 $info->addProperty($this->lng->txt("author"), $this->object->getAuthor());
03860 $info->addProperty($this->lng->txt("title"), $this->object->getTitle());
03861 switch ($this->object->getAnonymize())
03862 {
03863 case ANONYMIZE_OFF:
03864 $info->addProperty($this->lng->txt("anonymization"), $this->lng->txt("anonymize_personalized"));
03865 break;
03866 case ANONYMIZE_ON:
03867 if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
03868 {
03869 $info->addProperty($this->lng->txt("anonymization"), $this->lng->txt("anonymize_with_code"));
03870 }
03871 else
03872 {
03873 $info->addProperty($this->lng->txt("anonymization"), $this->lng->txt("anonymize_registered_user"));
03874 }
03875 break;
03876 case ANONYMIZE_FREEACCESS:
03877 $info->addProperty($this->lng->txt("anonymization"), $this->lng->txt("anonymize_without_code"));
03878 break;
03879 }
03880 include_once "./survey/classes/class.ilObjSurveyAccess.php";
03881 if ($ilAccess->checkAccess("write", "", $this->ref_id) || ilObjSurveyAccess::_hasEvaluationAccess($this->object->getId(), $ilUser->getId()))
03882 {
03883 $info->addProperty($this->lng->txt("evaluation_access"), $this->lng->txt("evaluation_access_info"));
03884 }
03885 $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
03886 $this->ctrl->forwardCommand($info);
03887 }
03888
03889 function addLocatorItems()
03890 {
03891 global $ilLocator;
03892 switch ($this->ctrl->getCmd())
03893 {
03894 case "next":
03895 case "previous":
03896 case "start":
03897 case "resume":
03898 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "infoScreen"));
03899 break;
03900 case "evaluation":
03901 case "checkEvaluationAccess":
03902 case "evaluationdetails":
03903 case "evaluationuser":
03904 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTargetByClass("ilsurveyevaluationgui", "evaluation"));
03905 break;
03906 case "create":
03907 case "save":
03908 case "cancel":
03909 case "importFile":
03910 case "cloneAll":
03911 break;
03912 case "infoScreen":
03913 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "infoScreen"));
03914 break;
03915 default:
03916 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""));
03917 break;
03918 }
03919 }
03920
03926 function getTabs(&$tabs_gui)
03927 {
03928 global $ilAccess;
03929
03930 switch ($this->ctrl->getCmd())
03931 {
03932 case "start":
03933 case "resume":
03934 case "next":
03935 case "previous":
03936
03937 case "evaluation":
03938 case "checkEvaluationAccess":
03939 case "evaluationdetails":
03940 case "evaluationuser":
03941 return;
03942 break;
03943 }
03944
03945
03946 if ($ilAccess->checkAccess("write", "", $this->ref_id))
03947 {
03948 $force_active = ($this->ctrl->getCmd() == "")
03949 ? true
03950 : false;
03951 $tabs_gui->addTarget("properties",
03952 $this->ctrl->getLinkTarget($this,'properties'),
03953 array("properties", "save", "cancel"), "",
03954 "", $force_active);
03955 }
03956
03957 if ($ilAccess->checkAccess("visible", "", $this->ref_id))
03958 {
03959 $tabs_gui->addTarget("info",
03960 $this->ctrl->getLinkTarget($this,'infoScreen'),
03961 array("infoScreen", "showSummary"));
03962 }
03963
03964
03965 if ($ilAccess->checkAccess("write", "", $this->ref_id))
03966 {
03967 $force_active = ($_GET["up"] != "" || $_GET["down"] != "")
03968 ? true
03969 : false;
03970
03971 $tabs_gui->addTarget("survey_questions",
03972 $this->ctrl->getLinkTarget($this,'questions'),
03973 array("questions", "browseForQuestions", "searchQuestions", "createQuestion",
03974 "searchQuestionsExecute",
03975 "filterQuestions", "resetFilterQuestions", "changeDatatype", "insertQuestions",
03976 "removeQuestions", "cancelRemoveQuestions", "confirmRemoveQuestions",
03977 "defineQuestionblock", "saveDefineQuestionblock", "cancelDefineQuestionblock",
03978 "unfoldQuestionblock", "moveQuestions",
03979 "insertQuestionsBefore", "insertQuestionsAfter", "saveObligatory",
03980 "addHeading", "saveHeading", "cancelHeading", "editHeading",
03981 "confirmRemoveHeading", "cancelRemoveHeading"),
03982 "", "", $force_active);
03983
03984
03985 $tabs_gui->addTarget("meta_data",
03986 $this->ctrl->getLinkTargetByClass('ilmdeditorgui','listSection'),
03987 "", "ilmdeditorgui");
03988
03989
03990 $tabs_gui->addTarget("constraints",
03991 $this->ctrl->getLinkTarget($this, "constraints"),
03992 array("constraints", "constraintStep1", "constraintStep2",
03993 "constraintStep3", "constraintsAdd", "createConstraints"),
03994 "");
03995 }
03996
03997 if (($ilAccess->checkAccess("write", "", $this->ref_id)) || ($ilAccess->checkAccess("invite", "", $this->ref_id)))
03998 {
03999
04000 $tabs_gui->addTarget("invite_participants",
04001 $this->ctrl->getLinkTarget($this, "invite"),
04002 array("invite", "saveInvitationStatus",
04003 "cancelInvitationStatus", "searchInvitation", "inviteUserGroup",
04004 "disinviteUserGroup"),
04005 "");
04006 }
04007
04008 if ($ilAccess->checkAccess("write", "", $this->ref_id))
04009 {
04010
04011 $tabs_gui->addTarget("export",
04012 $this->ctrl->getLinkTarget($this,'export'),
04013 array("export", "createExportFile", "confirmDeleteExportFile",
04014 "downloadExportFile"),
04015 ""
04016 );
04017
04018
04019 $tabs_gui->addTarget("maintenance",
04020 $this->ctrl->getLinkTarget($this,'maintenance'),
04021 array("maintenance", "deleteAllUserData"),
04022 "");
04023
04024
04025 $tabs_gui->addTarget("status",
04026 $this->ctrl->getLinkTarget($this,'status'),
04027 array("status"),
04028 "");
04029
04030 if ($this->object->getAnonymize() == 1)
04031 {
04032
04033 $tabs_gui->addTarget("codes",
04034 $this->ctrl->getLinkTarget($this,'codes'),
04035 array("codes", "createSurveyCodes", "setCodeLanguage"),
04036 "");
04037 }
04038
04039
04040 $tabs_gui->addTarget("perm_settings",
04041 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
04042 }
04043 }
04044
04050 function _goto($a_target, $a_access_code = "")
04051 {
04052 global $ilAccess, $ilErr, $lng;
04053 if ($ilAccess->checkAccess("read", "", $a_target))
04054 {
04055 include_once "./classes/class.ilUtil.php";
04056 if (strlen($a_access_code))
04057 {
04058 $_SESSION["anonymous_id"] = $a_access_code;
04059 $_GET["baseClass"] = "ilObjSurveyGUI";
04060 $_GET["cmd"] = "infoScreen";
04061 $_GET["ref_id"] = $a_target;
04062 include("ilias.php");
04063 exit;
04064 }
04065 else
04066 {
04067 $_GET["baseClass"] = "ilObjSurveyGUI";
04068 $_GET["cmd"] = "infoScreen";
04069 $_GET["ref_id"] = $a_target;
04070 include("ilias.php");
04071 exit;
04072 }
04073 }
04074 else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
04075 {
04076 $_GET["cmd"] = "frameset";
04077 $_GET["target"] = "";
04078 $_GET["ref_id"] = ROOT_FOLDER_ID;
04079 sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
04080 ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
04081 include("repository.php");
04082 exit;
04083 }
04084
04085 $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
04086 }
04087
04088 }
04089 ?>