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
00038 require_once "./classes/class.ilObjectGUI.php";
00039
00040 require_once "./classes/class.ilUtil.php";
00041 require_once "./classes/class.ilSearch.php";
00042 require_once "./classes/class.ilObjUser.php";
00043 require_once "./classes/class.ilObjGroup.php";
00044 require_once "./survey/classes/class.SurveySearch.php";
00045
00046 define ("TYPE_XLS", "latin1");
00047 define ("TYPE_XLS_MAC", "macos");
00048 define ("TYPE_SPSS", "csv");
00049 define ("TYPE_PRINT", "prnt");
00050
00051
00052 class ilObjSurveyGUI extends ilObjectGUI
00053 {
00058 function ilObjSurveyGUI($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
00059 {
00060 global $lng, $ilCtrl;
00061 $this->type = "svy";
00062 $lng->loadLanguageModule("survey");
00063 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference, false);
00064 if (!defined("ILIAS_MODULE"))
00065 {
00066 $this->setTabTargetScript("adm_object.php");
00067 }
00068 else
00069 {
00070 $this->setTabTargetScript("survey.php");
00071 }
00072 if ($a_prepare_output) {
00073 $this->prepareOutput();
00074 }
00075
00076 $this->ctrl =& $ilCtrl;
00077 $this->ctrl->saveParameter($this, "ref_id");
00078 }
00079
00085 function getCallingScript()
00086 {
00087 return "survey.php";
00088 }
00089
00093 function &executeCommand()
00094 {
00095 $cmd = $this->ctrl->getCmd("properties");
00096 $next_class = $this->ctrl->getNextClass($this);
00097 $this->ctrl->setReturn($this, "properties");
00098
00099
00100 switch($next_class)
00101 {
00102 case 'ilmdeditorgui':
00103 $this->setAdminTabs();
00104 include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
00105
00106 $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
00107 $md_gui->addObserver($this->object,'MDUpdateListener','General');
00108
00109 $this->ctrl->forwardCommand($md_gui);
00110 break;
00111
00112 default:
00113 if (($cmd != "run") and ($cmd != "evaluation") and ($cmd != "evaluationdetails") and ($cmd != "evaluationuser"))
00114 {
00115 $this->setAdminTabs();
00116 }
00117 $cmd.= "Object";
00118 $ret =& $this->$cmd();
00119 break;
00120 }
00121 }
00122
00127 function saveObject()
00128 {
00129 global $rbacadmin;
00130
00131
00132 $newObj = parent::saveObject();
00133
00134 sendInfo($this->lng->txt("object_added"),true);
00135
00136 ilUtil::redirect($this->getReturnLocation("save",$this->ctrl->getTargetScript()."?".$this->link_params));
00137 exit();
00138 }
00139
00140 function updateObject() {
00141
00142 $this->update = $this->object->update();
00143 $this->object->saveToDb();
00144 if (strcmp($_SESSION["info"], "") != 0)
00145 {
00146 sendInfo($_SESSION["info"] . "<br />" . $this->lng->txt("msg_obj_modified"), true);
00147 }
00148 else
00149 {
00150 sendInfo($this->lng->txt("msg_obj_modified"), true);
00151 }
00152 ilUtil::redirect($this->getReturnLocation("update",$this->ctrl->getTargetScript()."?".$this->link_params));
00153 }
00154
00162 function getAddParameter()
00163 {
00164 return "?ref_id=" . $_GET["ref_id"] . "&cmd=" . $_GET["cmd"];
00165 }
00166
00167 function writePropertiesFormData()
00168 {
00169 $this->object->setTitle(ilUtil::stripSlashes($_POST["title"]));
00170 $this->object->setDescription(ilUtil::stripSlashes($_POST["description"]));
00171 $this->object->setAuthor(ilUtil::stripSlashes($_POST["author"]));
00172 $result = $this->object->setStatus($_POST["status"]);
00173 if ($result)
00174 {
00175 sendInfo($result, true);
00176 }
00177 $this->object->setEvaluationAccess($_POST["evaluation_access"]);
00178 $this->object->setStartDate(sprintf("%04d-%02d-%02d", $_POST["start_date"]["y"], $_POST["start_date"]["m"], $_POST["start_date"]["d"]));
00179 $this->object->setStartDateEnabled($_POST["checked_start_date"]);
00180 $this->object->setEndDate(sprintf("%04d-%02d-%02d", $_POST["end_date"]["y"], $_POST["end_date"]["m"], $_POST["end_date"]["d"]));
00181 $this->object->setEndDateEnabled($_POST["checked_end_date"]);
00182 $this->object->setIntroduction(ilUtil::stripSlashes($_POST["introduction"]));
00183 $this->object->setAnonymize($_POST["anonymize"]);
00184 if ($_POST["showQuestionTitles"])
00185 {
00186 $this->object->showQuestionTitles();
00187 }
00188 else
00189 {
00190 $this->object->hideQuestionTitles();
00191 }
00192 }
00193
00201 function runObject() {
00202 global $ilUser;
00203 global $rbacsystem;
00204
00205 if (!$rbacsystem->checkAccess("read", $this->ref_id))
00206 {
00207
00208 $this->ilias->raiseError($this->lng->txt("cannot_read_survey"),$this->ilias->error_obj->MESSAGE);
00209 }
00210
00211 if ($_POST["cmd"]["exit"])
00212 {
00213 $path = $this->tree->getPathFull($this->object->getRefID());
00214 ilUtil::redirect($this->getReturnLocation("cancel",ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH)."/repository.php?cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
00215 exit();
00216 }
00217
00218 $add_parameter = $this->getAddParameter();
00219 $this->tpl->addBlockFile("CONTENT", "content", "tpl.il_svy_svy_content.html", true);
00220 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00221 $title = $this->object->getTitle();
00222
00223
00224 sendInfo();
00225
00226 $this->setLocator();
00227
00228 if (!empty($title))
00229 {
00230 $this->tpl->setVariable("HEADER", $title);
00231 }
00232
00233 if ($this->object->getAnonymize() && !$this->object->isAccessibleWithoutCode())
00234 {
00235 if ($_POST["cmd"]["resume"])
00236 {
00237 $anonymize_key = $this->object->getAnonymousId($_POST["anonymous_id"]);
00238 if ($anonymize_key)
00239 {
00240 $_SESSION["anonymous_id"] = $anonymize_key;
00241 }
00242 else
00243 {
00244 unset($_POST["cmd"]["resume"]);
00245 sendInfo(sprintf($this->lng->txt("error_retrieving_anonymous_survey"), $_POST["anonymous_id"]));
00246 }
00247 if (strlen($_SESSION["anonymous_id"]) == 0)
00248 {
00249 sendInfo(sprintf($this->lng->txt("error_retrieving_anonymous_survey"), $_POST["anonymous_id"]), true);
00250 $this->ctrl->redirect($this, "run");
00251 }
00252 }
00253 }
00254 if ($_POST["cmd"]["start"])
00255 {
00256 if ($this->object->isAccessibleWithoutCode())
00257 {
00258 $_SESSION["anonymous_id"] = $this->object->getRandomSurveyCode();
00259 }
00260 }
00261 $direction = 0;
00262 $page_error = 0;
00263 $error_messages = array();
00264 if ($_POST["cmd"]["start"] or $_POST["cmd"]["previous"] or $_POST["cmd"]["next"] or $_POST["cmd"]["resume"])
00265 {
00266 if (($_POST["cmd"]["start"]) || ($_POST["cmd"]["resume"]))
00267 {
00268 if ($this->object->getAnonymize() && !$this->object->isAccessibleWithoutCode())
00269 {
00270 if ($this->object->checkSurveyCode($_POST["anonymous_id"]))
00271 {
00272 $_SESSION["anonymous_id"] = $_POST["anonymous_id"];
00273 }
00274 else
00275 {
00276 sendInfo(sprintf($this->lng->txt("error_retrieving_anonymous_survey"), $_POST["anonymous_id"]), true);
00277 $this->ctrl->redirect($this, "run");
00278 }
00279 if (strlen($_SESSION["anonymous_id"]) == 0)
00280 {
00281 sendInfo(sprintf($this->lng->txt("error_retrieving_anonymous_survey"), $_POST["anonymous_id"]), true);
00282 $this->ctrl->redirect($this, "run");
00283 }
00284 }
00285 }
00286 $activepage = "";
00287 $direction = 0;
00288 if ($_POST["cmd"]["resume"])
00289 {
00290 $activepage = $this->object->getLastActivePage($ilUser->id);
00291 $direction = 0;
00292 }
00293 if ($_POST["cmd"]["previous"] or $_POST["cmd"]["next"])
00294 {
00295
00296 $page = $this->object->getNextPage($_GET["qid"], 0);
00297 foreach ($page as $data)
00298 {
00299 $save_answer = 0;
00300 $error = 0;
00301 if (strcmp($data["type_tag"], "qt_metric") == 0)
00302 {
00303
00304 $variables =& $this->object->getVariables($data["question_id"]);
00305 $entered_value = $_POST[$data["question_id"] . "_metric_question"];
00306
00307 $entered_value = str_replace(",", ".", $entered_value);
00308 $_POST[$data["question_id"] . "_metric_question"] = $entered_value;
00309 if (((($entered_value < $variables[0]->value1) or (($entered_value > $variables[0]->value2) and ($variables[0]->value2 > 0)))) && $data["obligatory"])
00310 {
00311
00312 $error_messages[$data["question_id"]] = $this->lng->txt("metric_question_out_of_bounds");
00313 $error = 1;
00314 }
00315 if (!is_numeric($entered_value) && ($data["obligatory"]))
00316 {
00317 $error_messages[$data["question_id"]] = $this->lng->txt("metric_question_not_a_value");
00318 $error = 1;
00319 }
00320 if ((strcmp($entered_value, "") == 0) && ($data["obligatory"]))
00321 {
00322
00323 $error_messages[$data["question_id"]] = $this->lng->txt("metric_question_out_of_bounds");
00324 $error = 1;
00325 }
00326 if (($data["subtype"] == SUBTYPE_RATIO_ABSOLUTE) && (intval($entered_value) != doubleval($entered_value)) && ($data["obligatory"]))
00327 {
00328 $error_messages[$data["question_id"]] = $this->lng->txt("metric_question_floating_point");
00329 $error = 1;
00330 }
00331 if (($error == 0) && (strcmp($entered_value, "") != 0))
00332 {
00333 $save_answer = 1;
00334 }
00335 }
00336 if (strcmp($data["type_tag"], "qt_nominal") == 0)
00337 {
00338 $variables =& $this->object->getVariables($data["question_id"]);
00339 $save_answer = 1;
00340 $entered_value = $_POST[$data["question_id"] . "_value"];
00341 if ($data["subtype"] == SUBTYPE_MCSR)
00342 {
00343 if ($data["obligatory"])
00344 {
00345 if (strcmp($entered_value, "") == 0)
00346 {
00347 $error_messages[$data["question_id"]] = $this->lng->txt("nominal_question_not_checked");
00348 $error = 1;
00349 $save_answer = 0;
00350 }
00351 }
00352 }
00353 else
00354 {
00355 if ($data["obligatory"])
00356 {
00357 if (!is_array($entered_value))
00358 {
00359 $error_messages[$data["question_id"]] = $this->lng->txt("nominal_question_mr_not_checked");
00360 $error = 1;
00361 $save_answer = 0;
00362 }
00363 }
00364 }
00365 }
00366 if (strcmp($data["type_tag"], "qt_ordinal") == 0)
00367 {
00368 $variables =& $this->object->getVariables($data["question_id"]);
00369 if ((strcmp($_POST[$data["question_id"] . "_value"], "") == 0) && ($data["obligatory"]))
00370 {
00371
00372 $error_messages[$data["question_id"]] = $this->lng->txt("ordinal_question_not_checked");
00373 $error = 1;
00374 }
00375 if ((strcmp($_POST[$data["question_id"] . "_value"], "") == 0) && !$error)
00376 {
00377 $save_answer = 0;
00378 }
00379 else
00380 {
00381 $save_answer = 1;
00382 }
00383 }
00384 if (strcmp($data["type_tag"], "qt_text") == 0)
00385 {
00386 $variables =& $this->object->getVariables($data["question_id"]);
00387 if ((strcmp($_POST[$data["question_id"] . "_text_question"], "") == 0) && ($data["obligatory"]))
00388 {
00389
00390 $error_messages[$data["question_id"]] = $this->lng->txt("text_question_not_filled_out");
00391 $error = 1;
00392 }
00393 if ((strcmp($_POST[$data["question_id"] . "_text_question"], "") == 0) && (!$data["obligatory"]))
00394 {
00395 $save_answer = 0;
00396 }
00397 else
00398 {
00399 $save_answer = 1;
00400 $maxchars = SurveyTextQuestion::_getMaxChars($data["question_id"]);
00401 if ($maxchars)
00402 {
00403 $_POST[$data["question_id"] . "_text_question"] = substr($_POST[$data["question_id"] . "_text_question"], 0, $maxchars);
00404 }
00405 }
00406 }
00407 $page_error += $error;
00408 if ((!$error) && ($save_answer))
00409 {
00410
00411 $this->object->deleteWorkingData($data["question_id"], $ilUser->id);
00412 switch ($data["type_tag"])
00413 {
00414 case "qt_nominal":
00415 if ($data["subtype"] == SUBTYPE_MCSR)
00416 {
00417 $this->object->saveWorkingData($data["question_id"], $ilUser->id, $_SESSION["anonymous_id"], $_POST[$data["question_id"] . "_value"]);
00418 }
00419 else
00420 {
00421 if (is_array($_POST[$data["question_id"] . "_value"]))
00422 {
00423 foreach ($_POST[$data["question_id"] . "_value"] as $value)
00424 {
00425 $this->object->saveWorkingData($data["question_id"], $ilUser->id, $_SESSION["anonymous_id"], $value);
00426 }
00427 }
00428 else
00429 {
00430 $this->object->saveWorkingData($data["question_id"], $ilUser->id, $_SESSION["anonymous_id"]);
00431 }
00432 }
00433 break;
00434 case "qt_ordinal":
00435 $this->object->saveWorkingData($data["question_id"], $ilUser->id, $_SESSION["anonymous_id"], $_POST[$data["question_id"] . "_value"]);
00436 break;
00437 case "qt_metric":
00438 $this->object->saveWorkingData($data["question_id"], $ilUser->id, $_SESSION["anonymous_id"], $_POST[$data["question_id"] . "_metric_question"]);
00439 break;
00440 case "qt_text":
00441 $this->object->saveWorkingData($data["question_id"], $ilUser->id, $_SESSION["anonymous_id"], 0, ilUtil::stripSlashes($_POST[$data["question_id"] . "_text_question"]));
00442 break;
00443 }
00444 }
00445 }
00446 }
00447 if ($page_error)
00448 {
00449 if ($page_error == 1)
00450 {
00451 sendInfo($this->lng->txt("svy_page_error"));
00452 }
00453 else
00454 {
00455 sendInfo($this->lng->txt("svy_page_errors"));
00456 }
00457 }
00458
00459 if ($_POST["cmd"]["previous"])
00460 {
00461 $activepage = $_GET["qid"];
00462 if (!$page_error)
00463 {
00464 $direction = -1;
00465 }
00466 }
00467 else if ($_POST["cmd"]["next"])
00468 {
00469 $activepage = $_GET["qid"];
00470 if (!$page_error)
00471 {
00472 $direction = 1;
00473 }
00474 }
00475
00476 $page = $this->object->getNextPage($activepage, $direction);
00477 $constraint_true = 0;
00478
00479 if (count($page[0]["constraints"]))
00480 {
00481 while (is_array($page) and ($constraint_true == 0) and (count($page[0]["constraints"])))
00482 {
00483 $constraint_true = 1;
00484 foreach ($page[0]["constraints"] as $constraint)
00485 {
00486 $working_data = $this->object->loadWorkingData($constraint["question"], $ilUser->id);
00487 $constraint_true = $constraint_true & $this->object->checkConstraint($constraint, $working_data);
00488 }
00489 if ($constraint_true == 0)
00490 {
00491 $page = $this->object->getNextPage($page[0]["question_id"], $direction);
00492 }
00493 }
00494 }
00495
00496 $qid = "";
00497 if ($page === 0)
00498 {
00499 $this->runShowIntroductionPage();
00500 return;
00501 }
00502 else if ($page === 1)
00503 {
00504 $this->object->finishSurvey($ilUser->id, $_SESSION["anonymous_id"]);
00505 $this->runShowFinishedPage();
00506 return;
00507 }
00508 else
00509 {
00510 $this->outNavigationButtons("top", $page);
00511 $this->tpl->addBlockFile("NOMINAL_QUESTION", "nominal_question", "tpl.il_svy_out_nominal.html", true);
00512 $this->tpl->addBlockFile("ORDINAL_QUESTION", "ordinal_question", "tpl.il_svy_out_ordinal.html", true);
00513 $this->tpl->addBlockFile("METRIC_QUESTION", "metric_question", "tpl.il_svy_out_metric.html", true);
00514 $this->tpl->addBlockFile("TEXT_QUESTION", "text_question", "tpl.il_svy_out_text.html", true);
00515 $this->tpl->setCurrentBlock("percentage");
00516 $this->tpl->setVariable("PERCENTAGE", (int)(($page[0]["position"])*200));
00517 $this->tpl->setVariable("PERCENTAGE_VALUE", (int)(($page[0]["position"])*100));
00518 $this->tpl->setVariable("HUNDRED_PERCENT", "200");
00519 $this->tpl->setVariable("TEXT_COMPLETED", $this->lng->txt("completed") . ": ");
00520 $this->tpl->parseCurrentBlock();
00521 if (count($page) > 1)
00522 {
00523 $this->tpl->setCurrentBlock("questionblock_title");
00524 $this->tpl->setVariable("TEXT_QUESTIONBLOCK_TITLE", $this->lng->txt("questionblock") . ": " . $page[0]["questionblock_title"]);
00525 $this->tpl->parseCurrentBlock();
00526 }
00527 foreach ($page as $data)
00528 {
00529 $this->tpl->setCurrentBlock("survey_content");
00530 if ($data["heading"])
00531 {
00532 $this->tpl->setVariable("QUESTION_HEADING", $data["heading"]);
00533 }
00534 $question_gui = $this->object->getQuestionGUI($data["type_tag"], $data["question_id"]);
00535 $working_data = $this->object->loadWorkingData($data["question_id"], $ilUser->id);
00536 $question_gui->object->setObligatory($data["obligatory"]);
00537 $question_gui->outWorkingForm($working_data, $this->object->getShowQuestionTitles(), $error_messages[$data["question_id"]]);
00538 $qid = "&qid=" . $data["question_id"];
00539 $this->tpl->parse("survey_content");
00540 }
00541 $this->outNavigationButtons("bottom", $page);
00542 }
00543 $this->tpl->setCurrentBlock("content");
00544 $this->tpl->setVariable("FORM_ACTION", $this->getCallingScript() . "$add_parameter$qid");
00545 $this->tpl->parseCurrentBlock();
00546 }
00547 else
00548 {
00549 $this->runShowIntroductionPage();
00550 }
00551 }
00552
00562 function outNavigationButtons($navigationblock = "top", $page)
00563 {
00564 $prevpage = $this->object->getNextPage($page[0]["question_id"], -1);
00565 $this->tpl->setCurrentBlock($navigationblock . "_prev");
00566 if ($prevpage === 0)
00567 {
00568 $this->tpl->setVariable("BTN_PREV", $this->lng->txt("survey_start"));
00569 }
00570 else
00571 {
00572 $this->tpl->setVariable("BTN_PREV", $this->lng->txt("survey_previous"));
00573 }
00574 $this->tpl->parseCurrentBlock();
00575 $nextpage = $this->object->getNextPage($page[0]["question_id"], 1);
00576 $this->tpl->setCurrentBlock($navigationblock . "_next");
00577 if ($nextpage === 1)
00578 {
00579 $this->tpl->setVariable("BTN_NEXT", $this->lng->txt("survey_finish"));
00580 }
00581 else
00582 {
00583 $this->tpl->setVariable("BTN_NEXT", $this->lng->txt("survey_next"));
00584 }
00585 $this->tpl->parseCurrentBlock();
00586 }
00587
00595 function runShowIntroductionPage()
00596 {
00597 global $ilUser;
00598 global $rbacsystem;
00599 if (($this->object->getAnonymize()) && (strcmp($ilUser->login, "anonymous") == 0))
00600 {
00601 $survey_started = false;
00602 }
00603 else
00604 {
00605 $survey_started = $this->object->isSurveyStarted($ilUser->id, $this->object->getUserSurveyCode());
00606 }
00607
00608 $add_parameter = $this->getAddParameter();
00609 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_introduction.html", true);
00610 if ((strcmp($ilUser->login, "anonymous") == 0) && (!$this->object->getAnonymize()))
00611 {
00612 if ($_POST["cmd"]["cancel"])
00613 {
00614 $path = $this->tree->getPathFull($this->object->getRefID());
00615 ilUtil::redirect($this->getReturnLocation("cancel","../repository.php?cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
00616 return;
00617 }
00618 $this->tpl->setCurrentBlock("back");
00619 $this->tpl->setVariable("BTN_BACK", $this->lng->txt("back"));
00620 $this->tpl->parseCurrentBlock();
00621 $this->tpl->setCurrentBlock("adm_content");
00622 $this->tpl->setVariable("TEXT_INTRODUCTION", $this->lng->txt("anonymous_with_personalized_survey"));
00623 $this->tpl->parseCurrentBlock();
00624 return;
00625 }
00626
00627 if ($this->object->getAnonymize() && !$this->object->isAccessibleWithoutCode())
00628 {
00629 $this->tpl->setCurrentBlock("start");
00630 $anonymize_key = $this->object->getUserSurveyCode();
00631 if (strcmp($ilUser->login, "anonymous") == 0)
00632 {
00633 $this->tpl->setVariable("TEXT_ANONYMIZE", $this->lng->txt("anonymize_anonymous_introduction"));
00634 }
00635 else
00636 if ($survey_started === 0)
00637 {
00638 $this->tpl->setVariable("TEXT_ANONYMIZE", $this->lng->txt("anonymize_resume_introduction"));
00639 }
00640 elseif ($survey_started === false)
00641 {
00642 $this->tpl->setVariable("TEXT_ANONYMIZE", sprintf($this->lng->txt("anonymize_key_introduction"), $anonymize_key));
00643 }
00644 $this->tpl->setVariable("ENTER_ANONYMOUS_ID", $this->lng->txt("enter_anonymous_id"));
00645 $this->tpl->setVariable("ANONYMOUS_ID_VALUE", $_GET["accesscode"]);
00646 $this->tpl->parseCurrentBlock();
00647 }
00648 $this->tpl->setCurrentBlock("start");
00649 $canStart = $this->object->canStartSurvey();
00650 if ($survey_started === 1)
00651 {
00652 sendInfo($this->lng->txt("already_completed_survey"));
00653 $this->tpl->setCurrentBlock("start");
00654 $this->tpl->setVariable("BTN_START", $this->lng->txt("start_survey"));
00655 $this->tpl->setVariable("DISABLED", " disabled=\"disabled\"");
00656 $this->tpl->parseCurrentBlock();
00657 }
00658 if ($survey_started === 0)
00659 {
00660 $this->tpl->setCurrentBlock("resume");
00661 $this->tpl->setVariable("BTN_RESUME", $this->lng->txt("resume_survey"));
00662 switch ($canStart)
00663 {
00664 case SURVEY_START_START_DATE_NOT_REACHED:
00665 sendInfo($this->lng->txt("start_date_not_reached") . " (".ilFormat::formatDate(ilFormat::ftimestamp2dateDB($this->object->getStartYear().$this->object->getStartMonth().$this->object->getStartDay()."000000"), "date") . ")");
00666 $this->tpl->setVariable("DISABLED", " disabled=\"disabled\"");
00667 break;
00668 case SURVEY_START_END_DATE_REACHED:
00669 sendInfo($this->lng->txt("end_date_reached") . " (".ilFormat::formatDate(ilFormat::ftimestamp2dateDB($this->object->getEndYear().$this->object->getEndMonth().$this->object->getEndDay()."000000"), "date") . ")");
00670 $this->tpl->setVariable("DISABLED", " disabled=\"disabled\"");
00671 break;
00672 case SURVEY_START_OFFLINE:
00673 sendInfo($this->lng->txt("survey_is_offline"));
00674 $this->tpl->setVariable("DISABLED", " disabled=\"disabled\"");
00675 break;
00676 }
00677 $this->tpl->parseCurrentBlock();
00678 }
00679 if ($survey_started === false)
00680 {
00681 $this->tpl->setCurrentBlock("start");
00682 $this->tpl->setVariable("BTN_START", $this->lng->txt("start_survey"));
00683 if (!$rbacsystem->checkAccess('participate', $this->object->getRefId()))
00684 {
00685 sendInfo($this->lng->txt("cannot_participate_survey"));
00686 $this->tpl->setVariable("DISABLED", " disabled=\"disabled\"");
00687 }
00688 switch ($canStart)
00689 {
00690 case SURVEY_START_START_DATE_NOT_REACHED:
00691 sendInfo($this->lng->txt("start_date_not_reached") . " (".ilFormat::formatDate(ilFormat::ftimestamp2dateDB($this->object->getStartYear().$this->object->getStartMonth().$this->object->getStartDay()."000000"), "date") . ")");
00692 $this->tpl->setVariable("DISABLED", " disabled=\"disabled\"");
00693 break;
00694 case SURVEY_START_END_DATE_REACHED:
00695 sendInfo($this->lng->txt("end_date_reached") . " (".ilFormat::formatDate(ilFormat::ftimestamp2dateDB($this->object->getEndYear().$this->object->getEndMonth().$this->object->getEndDay()."000000"), "date") . ")");
00696 $this->tpl->setVariable("DISABLED", " disabled=\"disabled\"");
00697 break;
00698 case SURVEY_START_OFFLINE:
00699 sendInfo($this->lng->txt("survey_is_offline"));
00700 $this->tpl->setVariable("DISABLED", " disabled=\"disabled\"");
00701 break;
00702 }
00703 $this->tpl->parseCurrentBlock();
00704 }
00705 $this->tpl->parseCurrentBlock();
00706 $this->tpl->setCurrentBlock("adm_content");
00707 $introduction = $this->object->getIntroduction();
00708 $introduction = preg_replace("/\n/i", "<br />", $introduction);
00709 $this->tpl->setVariable("TEXT_INTRODUCTION", $introduction);
00710 $this->tpl->setVariable("FORM_ACTION", $this->getCallingScript() . "$add_parameter");
00711 $this->tpl->parseCurrentBlock();
00712 }
00713
00721 function runShowFinishedPage()
00722 {
00723
00724 unset($_SESSION["anonymous_id"]);
00725 $add_parameter = $this->getAddParameter();
00726 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_finished.html", true);
00727 $this->tpl->setVariable("TEXT_FINISHED", $this->lng->txt("survey_finished"));
00728 $this->tpl->setVariable("BTN_EXIT", $this->lng->txt("exit"));
00729 $this->tpl->setVariable("FORM_ACTION", $this->getCallingScript() . "$add_parameter");
00730 $this->tpl->parseCurrentBlock();
00731 }
00732
00740 function propertiesObject()
00741 {
00742 global $rbacsystem;
00743
00744 $this->lng->loadLanguageModule("jscalendar");
00745 $this->tpl->addBlockFile("CALENDAR_LANG_JAVASCRIPT", "calendar_javascript", "tpl.calendar.html");
00746 $this->tpl->setCurrentBlock("calendar_javascript");
00747 $this->tpl->setVariable("FULL_SUNDAY", $this->lng->txt("l_su"));
00748 $this->tpl->setVariable("FULL_MONDAY", $this->lng->txt("l_mo"));
00749 $this->tpl->setVariable("FULL_TUESDAY", $this->lng->txt("l_tu"));
00750 $this->tpl->setVariable("FULL_WEDNESDAY", $this->lng->txt("l_we"));
00751 $this->tpl->setVariable("FULL_THURSDAY", $this->lng->txt("l_th"));
00752 $this->tpl->setVariable("FULL_FRIDAY", $this->lng->txt("l_fr"));
00753 $this->tpl->setVariable("FULL_SATURDAY", $this->lng->txt("l_sa"));
00754 $this->tpl->setVariable("SHORT_SUNDAY", $this->lng->txt("s_su"));
00755 $this->tpl->setVariable("SHORT_MONDAY", $this->lng->txt("s_mo"));
00756 $this->tpl->setVariable("SHORT_TUESDAY", $this->lng->txt("s_tu"));
00757 $this->tpl->setVariable("SHORT_WEDNESDAY", $this->lng->txt("s_we"));
00758 $this->tpl->setVariable("SHORT_THURSDAY", $this->lng->txt("s_th"));
00759 $this->tpl->setVariable("SHORT_FRIDAY", $this->lng->txt("s_fr"));
00760 $this->tpl->setVariable("SHORT_SATURDAY", $this->lng->txt("s_sa"));
00761 $this->tpl->setVariable("FULL_JANUARY", $this->lng->txt("l_01"));
00762 $this->tpl->setVariable("FULL_FEBRUARY", $this->lng->txt("l_02"));
00763 $this->tpl->setVariable("FULL_MARCH", $this->lng->txt("l_03"));
00764 $this->tpl->setVariable("FULL_APRIL", $this->lng->txt("l_04"));
00765 $this->tpl->setVariable("FULL_MAY", $this->lng->txt("l_05"));
00766 $this->tpl->setVariable("FULL_JUNE", $this->lng->txt("l_06"));
00767 $this->tpl->setVariable("FULL_JULY", $this->lng->txt("l_07"));
00768 $this->tpl->setVariable("FULL_AUGUST", $this->lng->txt("l_08"));
00769 $this->tpl->setVariable("FULL_SEPTEMBER", $this->lng->txt("l_09"));
00770 $this->tpl->setVariable("FULL_OCTOBER", $this->lng->txt("l_10"));
00771 $this->tpl->setVariable("FULL_NOVEMBER", $this->lng->txt("l_11"));
00772 $this->tpl->setVariable("FULL_DECEMBER", $this->lng->txt("l_12"));
00773 $this->tpl->setVariable("SHORT_JANUARY", $this->lng->txt("s_01"));
00774 $this->tpl->setVariable("SHORT_FEBRUARY", $this->lng->txt("s_02"));
00775 $this->tpl->setVariable("SHORT_MARCH", $this->lng->txt("s_03"));
00776 $this->tpl->setVariable("SHORT_APRIL", $this->lng->txt("s_04"));
00777 $this->tpl->setVariable("SHORT_MAY", $this->lng->txt("s_05"));
00778 $this->tpl->setVariable("SHORT_JUNE", $this->lng->txt("s_06"));
00779 $this->tpl->setVariable("SHORT_JULY", $this->lng->txt("s_07"));
00780 $this->tpl->setVariable("SHORT_AUGUST", $this->lng->txt("s_08"));
00781 $this->tpl->setVariable("SHORT_SEPTEMBER", $this->lng->txt("s_09"));
00782 $this->tpl->setVariable("SHORT_OCTOBER", $this->lng->txt("s_10"));
00783 $this->tpl->setVariable("SHORT_NOVEMBER", $this->lng->txt("s_11"));
00784 $this->tpl->setVariable("SHORT_DECEMBER", $this->lng->txt("s_12"));
00785 $this->tpl->setVariable("ABOUT_CALENDAR", $this->lng->txt("about_calendar"));
00786 $this->tpl->setVariable("ABOUT_CALENDAR_LONG", $this->lng->txt("about_calendar_long"));
00787 $this->tpl->setVariable("ABOUT_TIME_LONG", $this->lng->txt("about_time"));
00788 $this->tpl->setVariable("PREV_YEAR", $this->lng->txt("prev_year"));
00789 $this->tpl->setVariable("PREV_MONTH", $this->lng->txt("prev_month"));
00790 $this->tpl->setVariable("GO_TODAY", $this->lng->txt("go_today"));
00791 $this->tpl->setVariable("NEXT_MONTH", $this->lng->txt("next_month"));
00792 $this->tpl->setVariable("NEXT_YEAR", $this->lng->txt("next_year"));
00793 $this->tpl->setVariable("SEL_DATE", $this->lng->txt("select_date"));
00794 $this->tpl->setVariable("DRAG_TO_MOVE", $this->lng->txt("drag_to_move"));
00795 $this->tpl->setVariable("PART_TODAY", $this->lng->txt("part_today"));
00796 $this->tpl->setVariable("DAY_FIRST", $this->lng->txt("day_first"));
00797 $this->tpl->setVariable("CLOSE", $this->lng->txt("close"));
00798 $this->tpl->setVariable("TODAY", $this->lng->txt("today"));
00799 $this->tpl->setVariable("TIME_PART", $this->lng->txt("time_part"));
00800 $this->tpl->setVariable("DEF_DATE_FORMAT", $this->lng->txt("def_date_format"));
00801 $this->tpl->setVariable("TT_DATE_FORMAT", $this->lng->txt("tt_date_format"));
00802 $this->tpl->setVariable("WK", $this->lng->txt("wk"));
00803 $this->tpl->setVariable("TIME", $this->lng->txt("time"));
00804 $this->tpl->parseCurrentBlock();
00805 $this->tpl->setCurrentBlock("CalendarJS");
00806 $this->tpl->setVariable("LOCATION_JAVASCRIPT_CALENDAR", ilUtil::getJSPath("calendar.js"));
00807 $this->tpl->setVariable("LOCATION_JAVASCRIPT_CALENDAR_SETUP", ilUtil::getJSPath("calendar-setup.js"));
00808 $this->tpl->setVariable("LOCATION_JAVASCRIPT_CALENDAR_STYLESHEET", ilUtil::getJSPath("calendar.css"));
00809 $this->tpl->parseCurrentBlock();
00810
00811 if ((!$rbacsystem->checkAccess("read", $this->ref_id)) && (!$rbacsystem->checkAccess("write", $this->ref_id)))
00812 {
00813
00814 sendInfo($this->lng->txt("cannot_edit_survey"), true);
00815 $path = $this->tree->getPathFull($this->object->getRefID());
00816 ilUtil::redirect($this->getReturnLocation("cancel","../repository.php?cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
00817 return;
00818 }
00819
00820 $add_parameter = $this->getAddParameter();
00821 if ($_POST["cmd"]["save"])
00822 {
00823 $this->writePropertiesFormData();
00824 }
00825 if ($_POST["cmd"]["save"]) {
00826 $this->updateObject();
00827 }
00828 if ($_POST["cmd"]["cancel"]) {
00829 sendInfo($this->lng->txt("msg_cancel"), true);
00830 $path = $this->tree->getPathFull($this->object->getRefID());
00831 ilUtil::redirect($this->getReturnLocation("cancel",ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH)."/repository.php?cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
00832 exit();
00833 }
00834
00835 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_properties.html", true);
00836 $this->tpl->setCurrentBlock("adm_content");
00837 $this->tpl->setVariable("FORM_ACTION", $this->getCallingScript() . $add_parameter);
00838 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
00839 $this->tpl->setVariable("VALUE_TITLE", ilUtil::prepareFormOutput($this->object->getTitle()));
00840 $this->tpl->setVariable("TEXT_AUTHOR", $this->lng->txt("author"));
00841 $this->tpl->setVariable("VALUE_AUTHOR", ilUtil::prepareFormOutput($this->object->getAuthor()));
00842 $this->tpl->setVariable("TEXT_DESCRIPTION", $this->lng->txt("description"));
00843 $this->tpl->setVariable("VALUE_DESCRIPTION", ilUtil::prepareFormOutput($this->object->getDescription()));
00844 $this->tpl->setVariable("TEXT_INTRODUCTION", $this->lng->txt("introduction"));
00845 $this->tpl->setVariable("VALUE_INTRODUCTION", ilUtil::prepareFormOutput($this->object->getIntroduction()));
00846 $this->tpl->setVariable("TEXT_STATUS", $this->lng->txt("status"));
00847 $this->tpl->setVariable("TEXT_START_DATE", $this->lng->txt("start_date"));
00848 $this->tpl->setVariable("VALUE_START_DATE", ilUtil::makeDateSelect("start_date", $this->object->getStartYear(), $this->object->getStartMonth(), $this->object->getStartDay()));
00849 $this->tpl->setVariable("IMG_START_DATE_CALENDAR", ilUtil::getImagePath("calendar.png"));
00850 $this->tpl->setVariable("TXT_START_DATE_CALENDAR", $this->lng->txt("open_calendar"));
00851 $this->tpl->setVariable("TEXT_END_DATE", $this->lng->txt("end_date"));
00852 $this->tpl->setVariable("VALUE_END_DATE", ilUtil::makeDateSelect("end_date", $this->object->getEndYear(), $this->object->getEndMonth(), $this->object->getEndDay()));
00853 $this->tpl->setVariable("IMG_END_DATE_CALENDAR", ilUtil::getImagePath("calendar.png"));
00854 $this->tpl->setVariable("TXT_END_DATE_CALENDAR", $this->lng->txt("open_calendar"));
00855 $this->tpl->setVariable("TEXT_EVALUATION_ACCESS", $this->lng->txt("evaluation_access"));
00856 $this->tpl->setVariable("VALUE_OFFLINE", $this->lng->txt("offline"));
00857 $this->tpl->setVariable("VALUE_ONLINE", $this->lng->txt("online"));
00858 $this->tpl->setVariable("TEXT_ENABLED", $this->lng->txt("enabled"));
00859 $this->tpl->setVariable("VALUE_OFF", $this->lng->txt("off"));
00860 $this->tpl->setVariable("VALUE_ON", $this->lng->txt("on"));
00861 $this->tpl->setVariable("TEXT_ANONYMIZATION", $this->lng->txt("anonymize_survey"));
00862 $this->tpl->setVariable("TEXT_ANONYMIZATION_EXPLANATION", $this->lng->txt("anonymize_survey_explanation"));
00863 $this->tpl->setVariable("ANON_VALUE_OFF", $this->lng->txt("off"));
00864 $this->tpl->setVariable("ANON_VALUE_ON", $this->lng->txt("on"));
00865
00866 if ($this->object->getAnonymize())
00867 {
00868 $this->tpl->setVariable("ANON_SELECTED_ON", " selected=\"selected\"");
00869 }
00870 else
00871 {
00872 $this->tpl->setVariable("ANON_SELECTED_OFF", " selected=\"selected\"");
00873 }
00874
00875 if ($this->object->getEndDateEnabled())
00876 {
00877 $this->tpl->setVariable("CHECKED_END_DATE", " checked=\"checked\"");
00878 }
00879 if ($this->object->getStartDateEnabled())
00880 {
00881 $this->tpl->setVariable("CHECKED_START_DATE", " checked=\"checked\"");
00882 }
00883
00884 if ($this->object->getEvaluationAccess() == EVALUATION_ACCESS_ON)
00885 {
00886 $this->tpl->setVariable("SELECTED_ON", " selected=\"selected\"");
00887 }
00888 else
00889 {
00890 $this->tpl->setVariable("SELECTED_OFF", " selected=\"selected\"");
00891 }
00892 if ($this->object->getStatus() == STATUS_ONLINE)
00893 {
00894 $this->tpl->setVariable("SELECTED_ONLINE", " selected=\"selected\"");
00895 }
00896 else
00897 {
00898 $this->tpl->setVariable("SELECTED_OFFLINE", " selected=\"selected\"");
00899 }
00900 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00901 if ($rbacsystem->checkAccess("write", $this->ref_id)) {
00902 $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
00903 $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
00904 }
00905 $this->tpl->setVariable("TEXT_SHOW_QUESTIONTITLES", $this->lng->txt("svy_show_questiontitles"));
00906 if ($this->object->getShowQuestionTitles())
00907 {
00908 $this->tpl->setVariable("QUESTIONTITLES_CHECKED", " checked=\"checked\"");
00909 }
00910 $this->tpl->parseCurrentBlock();
00911 }
00912
00920 function questionBrowser() {
00921 global $rbacsystem;
00922
00923 $add_parameter = $this->getAddParameter() . "&insert_question=1";
00924
00925 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_questionbrowser.html", true);
00926 $this->tpl->addBlockFile("A_BUTTONS", "a_buttons", "tpl.il_svy_qpl_action_buttons.html", true);
00927 $this->tpl->addBlockFile("FILTER_QUESTION_MANAGER", "filter_questions", "tpl.il_svy_svy_filter_questions.html", true);
00928
00929 $questionpools =& $this->object->getQuestionpoolTitles();
00930
00931 $filter_type = $_GET["sel_filter_type"];
00932 if (!$filter_type)
00933 {
00934 $filter_type = $_POST["sel_filter_type"];
00935 }
00936 if (strcmp($_POST["cmd"]["resetFilter"], "") != 0)
00937 {
00938 $filter_type = "";
00939 }
00940 $add_parameter .= "&sel_filter_type=$filter_type";
00941
00942 $filter_text = $_GET["filter_text"];
00943 if (!$filter_text)
00944 {
00945 $filter_text = $_POST["filter_text"];
00946 }
00947 if (strcmp($_POST["cmd"]["resetFilter"], "") != 0)
00948 {
00949 $filter_text = "";
00950 }
00951 $add_parameter .= "&filter_text=$filter_text";
00952
00953 $browsequestions = 1;
00954 if (strcmp($_POST["cmd"]["datatype"], "") != 0)
00955 {
00956 $browsequestions = $_POST["datatype"];
00957 }
00958 else
00959 {
00960 if (strcmp($_GET["browsetype"], "") != 0)
00961 {
00962 $browsequestions = $_GET["browsetype"];
00963 }
00964 }
00965 $add_parameter .= "&browsetype=$browsequestions";
00966
00967 $filter_fields = array(
00968 "title" => $this->lng->txt("title"),
00969 "comment" => $this->lng->txt("description"),
00970 "author" => $this->lng->txt("author"),
00971 );
00972 $this->tpl->setCurrentBlock("filterrow");
00973 foreach ($filter_fields as $key => $value) {
00974 $this->tpl->setVariable("VALUE_FILTER_TYPE", "$key");
00975 $this->tpl->setVariable("NAME_FILTER_TYPE", "$value");
00976 if (strcmp($_POST["cmd"]["resetFilter"], "") == 0) {
00977 if (strcmp($filter_type, $key) == 0) {
00978 $this->tpl->setVariable("VALUE_FILTER_SELECTED", " selected=\"selected\"");
00979 }
00980 }
00981 $this->tpl->parseCurrentBlock();
00982 }
00983
00984 $filter_question_type = $_POST["sel_question_type"];
00985 if (!$filter_question_type)
00986 {
00987 $filter_question_type = $_GET["sel_question_type"];
00988 }
00989 if (strcmp($_POST["cmd"]["resetFilter"], "") != 0)
00990 {
00991 $filter_question_type = "";
00992 }
00993 $add_parameter .= "&sel_question_type=$filter_question_type";
00994
00995 if ($browsequestions)
00996 {
00997 $questiontypes =& $this->object->_getQuestiontypes();
00998 foreach ($questiontypes as $key => $value)
00999 {
01000 $this->tpl->setCurrentBlock("questiontype_row");
01001 $this->tpl->setVariable("VALUE_QUESTION_TYPE", $value);
01002 $this->tpl->setVariable("TEXT_QUESTION_TYPE", $this->lng->txt($value));
01003 if (strcmp($filter_question_type, $value) == 0)
01004 {
01005 $this->tpl->setVariable("SELECTED_QUESTION_TYPE", " selected=\"selected\"");
01006 }
01007 $this->tpl->parseCurrentBlock();
01008 }
01009 }
01010
01011 if ($_POST["cmd"]["filter"])
01012 {
01013 $filter_questionpool = $_POST["sel_questionpool"];
01014 }
01015 else
01016 {
01017 $filter_questionpool = $_GET["sel_questionpool"];
01018 }
01019 if (strcmp($_POST["cmd"]["resetFilter"], "") != 0)
01020 {
01021 $filter_questionpool = "";
01022 }
01023 $add_parameter .= "&sel_questionpool=$filter_questionpool";
01024
01025 if ($browsequestions)
01026 {
01027 foreach ($questionpools as $key => $value)
01028 {
01029 $this->tpl->setCurrentBlock("questionpool_row");
01030 $this->tpl->setVariable("VALUE_QUESTIONPOOL", $key);
01031 $this->tpl->setVariable("TEXT_QUESTIONPOOL", $value);
01032 if (strcmp($filter_questionpool, $key) == 0)
01033 {
01034 $this->tpl->setVariable("SELECTED_QUESTIONPOOL", " selected=\"selected\"");
01035 }
01036 $this->tpl->parseCurrentBlock();
01037 }
01038 }
01039
01040 if ($browsequestions)
01041 {
01042 $this->tpl->setCurrentBlock("question_filters");
01043 $this->tpl->setVariable("SHOW_QUESTION_TYPES", $this->lng->txt("filter_show_question_types"));
01044 $this->tpl->setVariable("TEXT_ALL_QUESTION_TYPES", $this->lng->txt("filter_all_question_types"));
01045 $this->tpl->setVariable("SHOW_QUESTIONPOOLS", $this->lng->txt("filter_show_questionpools"));
01046 $this->tpl->setVariable("TEXT_ALL_QUESTIONPOOLS", $this->lng->txt("filter_all_questionpools"));
01047 $this->tpl->parseCurrentBlock();
01048 }
01049
01050 $this->tpl->setCurrentBlock("filter_questions");
01051 $this->tpl->setVariable("FILTER_TEXT", $this->lng->txt("filter"));
01052 $this->tpl->setVariable("TEXT_FILTER_BY", $this->lng->txt("by"));
01053 if (!$_POST["cmd"]["reset"]) {
01054 $this->tpl->setVariable("VALUE_FILTER_TEXT", $filter_text);
01055 }
01056 $this->tpl->setVariable("VALUE_SUBMIT_FILTER", $this->lng->txt("set_filter"));
01057 $this->tpl->setVariable("VALUE_RESET_FILTER", $this->lng->txt("reset_filter"));
01058 $this->tpl->setVariable("OPTION_QUESTIONS", $this->lng->txt("questions"));
01059 $this->tpl->setVariable("OPTION_QUESTIONBLOCKS", $this->lng->txt("questionblocks"));
01060 if ($browsequestions)
01061 {
01062 $this->tpl->setVariable("SELECTED_QUESTIONS", " selected=\"selected\"");
01063 }
01064 else
01065 {
01066 $this->tpl->setVariable("SELECTED_QUESTIONBLOCKS", " selected=\"selected\"");
01067 }
01068 $this->tpl->setVariable("TEXT_DATATYPE", $this->lng->txt("display_all_available"));
01069 $this->tpl->setVariable("BTN_CHANGE", $this->lng->txt("change"));
01070 $this->tpl->parseCurrentBlock();
01071
01072 if ($_POST["cmd"]["reset"])
01073 {
01074 $_POST["filter_text"] = "";
01075 }
01076 $startrow = 0;
01077 if ($_GET["prevrow"])
01078 {
01079 $startrow = $_GET["prevrow"];
01080 }
01081 if ($_GET["nextrow"])
01082 {
01083 $startrow = $_GET["nextrow"];
01084 }
01085 if ($_GET["startrow"])
01086 {
01087 $startrow = $_GET["startrow"];
01088 }
01089 if (!$_GET["sort"])
01090 {
01091
01092 $_GET["sort"] = array("title" => "ASC");
01093 }
01094 if ($browsequestions)
01095 {
01096 $table = $this->object->getQuestionsTable($_GET["sort"], $filter_text, $filter_type, $startrow, 1, $filter_question_type, $filter_questionpool);
01097 }
01098 else
01099 {
01100 $table = $this->object->getQuestionblocksTable($_GET["sort"], $filter_text, $filter_type, $startrow);
01101 }
01102 $colors = array("tblrow1", "tblrow2");
01103 $counter = 0;
01104 $questionblock_id = 0;
01105 if ($browsequestions)
01106 {
01107 foreach ($table["rows"] as $data)
01108 {
01109 if ($rbacsystem->checkAccess("write", $data["ref_id"])) {
01110 $this->tpl->setCurrentBlock("QTab");
01111 if ($data["complete"]) {
01112
01113 $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
01114 }
01115 $this->tpl->setVariable("QUESTION_TITLE", "<strong>" . $data["title"] . "</strong>");
01116 $this->tpl->setVariable("PREVIEW", "[<a href=\"" . "questionpool.php?ref_id=" . $data["ref_id"] . "&cmd=preview&preview=" . $data["question_id"] . " \" target=\"_blank\">" . $this->lng->txt("preview") . "</a>]");
01117 $this->tpl->setVariable("QUESTION_COMMENT", $data["description"]);
01118 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($data["type_tag"]));
01119 $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]);
01120 $this->tpl->setVariable("QUESTION_CREATED", ilFormat::formatDate(ilFormat::ftimestamp2dateDB($data["created"]), "date"));
01121 $this->tpl->setVariable("QUESTION_UPDATED", ilFormat::formatDate(ilFormat::ftimestamp2dateDB($data["TIMESTAMP14"]), "date"));
01122 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
01123 $this->tpl->setVariable("QUESTION_POOL", $questionpools[$data["obj_fi"]]);
01124 $this->tpl->parseCurrentBlock();
01125 $counter++;
01126 }
01127 }
01128 if ($table["rowcount"] > count($table["rows"]))
01129 {
01130 $nextstep = $table["nextrow"] + $table["step"];
01131 if ($nextstep > $table["rowcount"])
01132 {
01133 $nextstep = $table["rowcount"];
01134 }
01135 $sort = "";
01136 if (is_array($_GET["sort"]))
01137 {
01138 $key = key($_GET["sort"]);
01139 $sort = "&sort[$key]=" . $_GET["sort"]["$key"];
01140 }
01141 $counter = 1;
01142 for ($i = 0; $i < $table["rowcount"]; $i += $table["step"])
01143 {
01144 $this->tpl->setCurrentBlock("pages_questions");
01145 if ($table["startrow"] == $i)
01146 {
01147 $this->tpl->setVariable("PAGE_NUMBER", "<span class=\"inactivepage\">$counter</span>");
01148 }
01149 else
01150 {
01151 $this->tpl->setVariable("PAGE_NUMBER", "<a href=\"" . $this->getCallingScript() . $add_parameter . "$sort&nextrow=$i" . "\">$counter</a>");
01152 }
01153 $this->tpl->parseCurrentBlock();
01154 $counter++;
01155 }
01156 $this->tpl->setCurrentBlock("questions_navigation_bottom");
01157 $this->tpl->setVariable("TEXT_ITEM", $this->lng->txt("item"));
01158 $this->tpl->setVariable("TEXT_ITEM_START", $table["startrow"] + 1);
01159 $end = $table["startrow"] + $table["step"];
01160 if ($end > $table["rowcount"])
01161 {
01162 $end = $table["rowcount"];
01163 }
01164 $this->tpl->setVariable("TEXT_ITEM_END", $end);
01165 $this->tpl->setVariable("TEXT_OF", strtolower($this->lng->txt("of")));
01166 $this->tpl->setVariable("TEXT_ITEM_COUNT", $table["rowcount"]);
01167 $this->tpl->setVariable("TEXT_PREVIOUS", $this->lng->txt("previous"));
01168 $this->tpl->setVariable("TEXT_NEXT", $this->lng->txt("next"));
01169 $this->tpl->setVariable("HREF_PREV_ROWS", $this->getCallingScript() . $add_parameter . "$sort&prevrow=" . $table["prevrow"]);
01170 $this->tpl->setVariable("HREF_NEXT_ROWS", $this->getCallingScript() . $add_parameter . "$sort&nextrow=" . $table["nextrow"]);
01171 $this->tpl->parseCurrentBlock();
01172 }
01173 }
01174 else
01175 {
01176 foreach ($table["rows"] as $data)
01177 {
01178 $this->tpl->setCurrentBlock("questionblock_row");
01179 $this->tpl->setVariable("QUESTIONBLOCK_ID", $data["questionblock_id"]);
01180 $this->tpl->setVariable("QUESTIONBLOCK_TITLE", "<strong>" . $data["title"] . "</strong>");
01181 $this->tpl->setVariable("SURVEY_TITLE", $data["surveytitle"]);
01182 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
01183 $this->tpl->setVariable("QUESTIONS_TITLE", $data["questions"]);
01184 $this->tpl->parseCurrentBlock();
01185 $counter++;
01186 }
01187 if ($table["rowcount"] > count($table["rows"]))
01188 {
01189 $nextstep = $table["nextrow"] + $table["step"];
01190 if ($nextstep > $table["rowcount"])
01191 {
01192 $nextstep = $table["rowcount"];
01193 }
01194 $sort = "";
01195 if (is_array($_GET["sort"]))
01196 {
01197 $key = key($_GET["sort"]);
01198 $sort = "&sort[$key]=" . $_GET["sort"]["$key"];
01199 }
01200 $counter = 1;
01201 for ($i = 0; $i < $table["rowcount"]; $i += $table["step"])
01202 {
01203 $this->tpl->setCurrentBlock("pages_questionblocks");
01204 if ($table["startrow"] == $i)
01205 {
01206 $this->tpl->setVariable("PAGE_NUMBER", "<strong>$counter</strong>");
01207 }
01208 else
01209 {
01210 $this->tpl->setVariable("PAGE_NUMBER", "<a href=\"" . $this->getCallingScript() . $add_parameter . "$sort&nextrow=$i" . "\">$counter</a>");
01211 }
01212 $this->tpl->parseCurrentBlock();
01213 $counter++;
01214 }
01215 $this->tpl->setCurrentBlock("questionblocks_navigation_bottom");
01216 $this->tpl->setVariable("TEXT_ITEM", $this->lng->txt("item"));
01217 $this->tpl->setVariable("TEXT_ITEM_START", $table["startrow"] + 1);
01218 $end = $table["startrow"] + $table["step"];
01219 if ($end > $table["rowcount"])
01220 {
01221 $end = $table["rowcount"];
01222 }
01223 $this->tpl->setVariable("TEXT_ITEM_END", $end);
01224 $this->tpl->setVariable("TEXT_OF", strtolower($this->lng->txt("of")));
01225 $this->tpl->setVariable("TEXT_ITEM_COUNT", $table["rowcount"]);
01226 $this->tpl->setVariable("TEXT_PREVIOUS", $this->lng->txt("previous"));
01227 $this->tpl->setVariable("TEXT_NEXT", $this->lng->txt("next"));
01228 $this->tpl->setVariable("HREF_PREV_ROWS", $this->getCallingScript() . $add_parameter . "$sort&prevrow=" . $table["prevrow"]);
01229 $this->tpl->setVariable("HREF_NEXT_ROWS", $this->getCallingScript() . $add_parameter . "$sort&nextrow=" . $table["nextrow"]);
01230 $this->tpl->parseCurrentBlock();
01231 }
01232 }
01233
01234
01235 if ($counter == 0) {
01236 $this->tpl->setCurrentBlock("Emptytable");
01237 if ($browsequestions)
01238 {
01239 $this->tpl->setVariable("TEXT_EMPTYTABLE", $this->lng->txt("no_questions_available"));
01240 }
01241 else
01242 {
01243 $this->tpl->setVariable("TEXT_EMPTYTABLE", $this->lng->txt("no_questionblocks_available"));
01244 }
01245 $this->tpl->parseCurrentBlock();
01246 }
01247 else
01248 {
01249
01250 $this->tpl->setCurrentBlock("selection");
01251 $this->tpl->setVariable("INSERT", $this->lng->txt("insert"));
01252 $this->tpl->parseCurrentBlock();
01253
01254 $this->tpl->setCurrentBlock("Footer");
01255 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"\">");
01256 $this->tpl->parseCurrentBlock();
01257 }
01258
01259 $sort = array(
01260 "title" => $_GET["sort"]["title"],
01261 "description" => $_GET["sort"]["description"],
01262 "type" => $_GET["sort"]["type"],
01263 "author" => $_GET["sort"]["author"],
01264 "created" => $_GET["sort"]["created"],
01265 "updated" => $_GET["sort"]["updated"],
01266 "qpl" => $_GET["sort"]["qpl"],
01267 "svy" => $_GET["sort"]["svy"]
01268 );
01269 foreach ($sort as $key => $value) {
01270 if (strcmp($value, "ASC") == 0) {
01271 $sort[$key] = "DESC";
01272 } else {
01273 $sort[$key] = "ASC";
01274 }
01275 }
01276
01277 if ($browsequestions)
01278 {
01279 $this->tpl->setCurrentBlock("questions_header");
01280 $this->tpl->setVariable("QUESTION_TITLE", "<a href=\"" . $this->getCallingScript() . "$add_parameter&startrow=" . $table["startrow"] . "&sort[title]=" . $sort["title"] . "\">" . $this->lng->txt("title") . "</a>" . $table["images"]["title"]);
01281 $this->tpl->setVariable("QUESTION_COMMENT", "<a href=\"" . $this->getCallingScript() . "$add_parameter&startrow=" . $table["startrow"] . "&sort[description]=" . $sort["description"] . "\">" . $this->lng->txt("description") . "</a>". $table["images"]["description"]);
01282 $this->tpl->setVariable("QUESTION_TYPE", "<a href=\"" . $this->getCallingScript() . "$add_parameter&startrow=" . $table["startrow"] . "&sort[type]=" . $sort["type"] . "\">" . $this->lng->txt("question_type") . "</a>" . $table["images"]["type"]);
01283 $this->tpl->setVariable("QUESTION_AUTHOR", "<a href=\"" . $this->getCallingScript() . "$add_parameter&startrow=" . $table["startrow"] . "&sort[author]=" . $sort["author"] . "\">" . $this->lng->txt("author") . "</a>" . $table["images"]["author"]);
01284 $this->tpl->setVariable("QUESTION_CREATED", "<a href=\"" . $this->getCallingScript() . "$add_parameter&startrow=" . $table["startrow"] . "&sort[created]=" . $sort["created"] . "\">" . $this->lng->txt("create_date") . "</a>" . $table["images"]["created"]);
01285 $this->tpl->setVariable("QUESTION_UPDATED", "<a href=\"" . $this->getCallingScript() . "$add_parameter&startrow=" . $table["startrow"] . "&sort[updated]=" . $sort["updated"] . "\">" . $this->lng->txt("last_update") . "</a>" . $table["images"]["updated"]);
01286 $this->tpl->setVariable("QUESTION_POOL", "<a href=\"" . $this->getCallingScript() . "$add_parameter&startrow=" . $table["startrow"] . "&sort[qpl]=" . $sort["qpl"] . "\">" . $this->lng->txt("obj_spl") . "</a>" . $table["images"]["qpl"]);
01287 $this->tpl->parseCurrentBlock();
01288 }
01289 else
01290 {
01291 $this->tpl->setCurrentBlock("questionblocks_header");
01292 $this->tpl->setVariable("QUESTIONBLOCK_TITLE", "<a href=\"" . $this->getCallingScript() . "$add_parameter&startrow=" . $table["startrow"] . "&sort[title]=" . $sort["title"] . "\">" . $this->lng->txt("title") . "</a>" . $table["images"]["title"]);
01293 $this->tpl->setVariable("SURVEY_TITLE", "<a href=\"" . $this->getCallingScript() . "$add_parameter&startrow=" . $table["startrow"] . "&sort[svy]=" . $sort["svy"] . "\">" . $this->lng->txt("obj_svy") . "</a>" . $table["images"]["svy"]);
01294 $this->tpl->setVariable("QUESTIONS_TITLE", $this->lng->txt("contains"));
01295 $this->tpl->parseCurrentBlock();
01296 }
01297 $this->tpl->setCurrentBlock("adm_content");
01298
01299 $this->tpl->setVariable("BUTTON_BACK", $this->lng->txt("back"));
01300 $this->tpl->setVariable("FORM_ACTION", $this->getCallingScript() . $add_parameter);
01301 $this->tpl->parseCurrentBlock();
01302 }
01303
01311 function searchQuestionsForm()
01312 {
01313 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_search_questions.html", true);
01314
01315 if ($_POST["cmd"]["search"])
01316 {
01317 $search = new SurveySearch(ilUtil::stripSlashes($_POST["search_term"]), $_POST["concat"], $_POST["search_field"], $_POST["search_type"]);
01318 $search->search();
01319 if (count($search->search_results))
01320 {
01321 $classes = array("tblrow1", "tblrow2");
01322 $counter = 0;
01323 $titles = $this->object->getQuestionpoolTitles();
01324 $forbidden_pools =& $this->object->getForbiddenQuestionpools();
01325 $existing_questions =& $this->object->getExistingQuestions();
01326 foreach ($search->search_results as $data)
01327 {
01328 if ((!in_array($data["question_id"], $existing_questions)) && (!in_array($data["obj_fi"], $forbidden_pools)))
01329 {
01330 $this->tpl->setCurrentBlock("result_row");
01331 $this->tpl->setVariable("COLOR_CLASS", $classes[$counter % 2]);
01332 $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
01333 $this->tpl->setVariable("QUESTION_TITLE", $data["title"]);
01334 $this->tpl->setVariable("QUESTION_DESCRIPTION", $data["description"]);
01335 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($data["type_tag"]));
01336 $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]);
01337 $this->tpl->setVariable("QUESTION_POOL", $titles[$data["ref_id"]]);
01338 $this->tpl->parseCurrentBlock();
01339 $counter++;
01340 }
01341 }
01342 $this->tpl->setCurrentBlock("search_results");
01343 $this->tpl->setVariable("RESULT_IMAGE", ilUtil::getImagePath("icon_spl_b.gif"));
01344 $this->tpl->setVariable("ALT_IMAGE", $this->lng->txt("found_questions"));
01345 $this->tpl->setVariable("TEXT_QUESTION_TITLE", $this->lng->txt("title"));
01346 $this->tpl->setVariable("TEXT_QUESTION_DESCRIPTION", $this->lng->txt("description"));
01347 $this->tpl->setVariable("TEXT_QUESTION_TYPE", $this->lng->txt("question_type"));
01348 $this->tpl->setVariable("TEXT_QUESTION_AUTHOR", $this->lng->txt("author"));
01349 $this->tpl->setVariable("TEXT_QUESTION_POOL", $this->lng->txt("obj_spl"));
01350 $this->tpl->setVariable("BTN_INSERT", $this->lng->txt("insert"));
01351 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"\">");
01352 $this->tpl->setVariable("FOUND_QUESTIONS", $this->lng->txt("found_questions"));
01353 $this->tpl->parseCurrentBlock();
01354 }
01355 else
01356 {
01357 sendInfo($this->lng->txt("no_search_results"));
01358 }
01359 }
01360
01361 sendInfo();
01362 $add_parameter = $this->getAddParameter();
01363 $questiontypes = &$this->object->getQuestiontypes();
01364 foreach ($questiontypes as $questiontype)
01365 {
01366 $this->tpl->setCurrentBlock("questiontypes");
01367 $this->tpl->setVariable("VALUE_QUESTION_TYPE", $questiontype);
01368 $this->tpl->setVariable("TEXT_QUESTION_TYPE", $this->lng->txt($questiontype));
01369 if (strcmp($_POST["search_type"], $questiontype) == 0)
01370 {
01371 $this->tpl->setVariable("SELECTED_SEARCH_TYPE", " selected=\"selected\"");
01372 }
01373 $this->tpl->parseCurrentBlock();
01374 }
01375 $this->tpl->setCurrentBlock("adm_content");
01376 switch ($_POST["search_field"])
01377 {
01378 case "title":
01379 $this->tpl->setVariable("CHECKED_TITLE", " selected=\"selected\"");
01380 break;
01381 case "description":
01382 $this->tpl->setVariable("CHECKED_DESCRIPTION", " selected=\"selected\"");
01383 break;
01384 case "author":
01385 $this->tpl->setVariable("CHECKED_AUTHOR", " selected=\"selected\"");
01386 break;
01387 case "questiontext":
01388 $this->tpl->setVariable("CHECKED_QUESTIONTEXT", " selected=\"selected\"");
01389 break;
01390 case "default":
01391 $this->tpl->setVariable("CHECKED_ALL", " selected=\"selected\"");
01392 break;
01393 }
01394 $this->tpl->setVariable("TEXT_SEARCH_TERM", $this->lng->txt("search_term"));
01395 $this->tpl->setVariable("VALUE_SEARCH_TERM", $_POST["search_term"]);
01396 $this->tpl->setVariable("TEXT_CONCATENATION", $this->lng->txt("concatenation"));
01397 $this->tpl->setVariable("TEXT_AND", $this->lng->txt("and"));
01398 $this->tpl->setVariable("TEXT_OR", $this->lng->txt("or"));
01399 if ($_POST["concat"] == 1)
01400 {
01401 $this->tpl->setVariable("CHECKED_OR", " checked=\"checked\"");
01402 }
01403 else
01404 {
01405 $this->tpl->setVariable("CHECKED_AND", " checked=\"checked\"");
01406 }
01407 $this->tpl->setVariable("TEXT_SEARCH_FOR", $this->lng->txt("search_for"));
01408 $this->tpl->setVariable("SEARCH_FIELD_ALL", $this->lng->txt("search_field_all"));
01409 $this->tpl->setVariable("SEARCH_FIELD_TITLE", $this->lng->txt("title"));
01410 $this->tpl->setVariable("SEARCH_FIELD_DESCRIPTION", $this->lng->txt("description"));
01411 $this->tpl->setVariable("SEARCH_FIELD_AUTHOR", $this->lng->txt("author"));
01412 $this->tpl->setVariable("SEARCH_FIELD_QUESTIONTEXT", $this->lng->txt("question"));
01413 $this->tpl->setVariable("SEARCH_TYPE_ALL", $this->lng->txt("search_type_all"));
01414 $this->tpl->setVariable("BTN_SEARCH", $this->lng->txt("search"));
01415 $this->tpl->setVariable("FORM_ACTION", $this->getCallingScript() . $add_parameter . "&search_question=1&browsetype=1&insert_question=1");
01416 $this->tpl->parseCurrentBlock();
01417 }
01418
01428 function removeQuestionsForm($checked_questions, $checked_questionblocks)
01429 {
01430 sendInfo();
01431 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_remove_questions.html", true);
01432 $colors = array("tblrow1", "tblrow2");
01433 $counter = 0;
01434 $surveyquestions =& $this->object->getSurveyQuestions();
01435 foreach ($surveyquestions as $question_id => $data)
01436 {
01437 if (in_array($data["question_id"], $checked_questions) or (in_array($data["questionblock_id"], $checked_questionblocks)))
01438 {
01439 $this->tpl->setCurrentBlock("row");
01440 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
01441 $this->tpl->setVariable("TEXT_TITLE", $data["title"]);
01442 $this->tpl->setVariable("TEXT_DESCRIPTION", $data["description"]);
01443 $this->tpl->setVariable("TEXT_TYPE", $this->lng->txt($data["type_tag"]));
01444 $this->tpl->setVariable("TEXT_QUESTIONBLOCK", $data["questionblock_title"]);
01445 $this->tpl->parseCurrentBlock();
01446 $counter++;
01447 }
01448 }
01449 foreach ($checked_questions as $id)
01450 {
01451 $this->tpl->setCurrentBlock("hidden");
01452 $this->tpl->setVariable("HIDDEN_NAME", "id_$id");
01453 $this->tpl->setVariable("HIDDEN_VALUE", "$id");
01454 $this->tpl->parseCurrentBlock();
01455 }
01456 foreach ($checked_questionblocks as $id)
01457 {
01458 $this->tpl->setCurrentBlock("hidden");
01459 $this->tpl->setVariable("HIDDEN_NAME", "id_qb_$id");
01460 $this->tpl->setVariable("HIDDEN_VALUE", "$id");
01461 $this->tpl->parseCurrentBlock();
01462 }
01463 $this->tpl->setCurrentBlock("adm_content");
01464 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
01465 $this->tpl->setVariable("TEXT_DESCRIPTION", $this->lng->txt("description"));
01466 $this->tpl->setVariable("TEXT_TYPE", $this->lng->txt("question_type"));
01467 $this->tpl->setVariable("TEXT_QUESTIONBLOCK", $this->lng->txt("questionblock"));
01468 $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
01469 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
01470 $this->tpl->setVariable("FORM_ACTION", $this->getCallingScript() . $this->getAddParameter());
01471 $this->tpl->parseCurrentBlock();
01472 }
01473
01474
01483 function defineQuestionblock($questionblock_id = "")
01484 {
01485 sendInfo();
01486 if ($questionblock_id)
01487 {
01488 $questionblock = $this->object->getQuestionblock($questionblock_id);
01489 }
01490 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_define_questionblock.html", true);
01491 foreach ($_POST as $key => $value)
01492 {
01493 if (preg_match("/cb_(\d+)/", $key, $matches))
01494 {
01495 $this->tpl->setCurrentBlock("hidden");
01496 $this->tpl->setVariable("HIDDEN_NAME", "cb_$matches[1]");
01497 $this->tpl->setVariable("HIDDEN_VALUE", $matches[1]);
01498 $this->tpl->parseCurrentBlock();
01499 }
01500 }
01501 if ($questionblock_id)
01502 {
01503 $this->tpl->setCurrentBlock("hidden");
01504 $this->tpl->setVariable("HIDDEN_NAME", "questionblock_id");
01505 $this->tpl->setVariable("HIDDEN_VALUE", $questionblock_id);
01506 $this->tpl->parseCurrentBlock();
01507 }
01508 $this->tpl->setCurrentBlock("adm_content");
01509 $this->tpl->setVariable("DEFINE_QUESTIONBLOCK_HEADING", $this->lng->txt("define_questionblock"));
01510 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
01511 if ($questionblock_id)
01512 {
01513 $this->tpl->setVariable("VALUE_TITLE", $questionblock["title"]);
01514 }
01515 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
01516 $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
01517 $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
01518 $this->tpl->setVariable("FORM_ACTION", $this->getCallingScript() . $this->getAddParameter());
01519 $this->tpl->parseCurrentBlock();
01520 }
01521
01529 function questionpoolSelectForm()
01530 {
01531 global $ilUser;
01532 $add_parameter = $this->getAddParameter();
01533 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_qpl_select.html", true);
01534 $questionpools =& $this->object->getAvailableQuestionpools();
01535 foreach ($questionpools as $key => $value)
01536 {
01537 $this->tpl->setCurrentBlock("option");
01538 $this->tpl->setVariable("VALUE_OPTION", $key);
01539 $this->tpl->setVariable("TEXT_OPTION", $value);
01540 $this->tpl->parseCurrentBlock();
01541 }
01542 $this->tpl->setCurrentBlock("hidden");
01543 $this->tpl->setVariable("HIDDEN_NAME", "sel_question_types");
01544 $this->tpl->setVariable("HIDDEN_VALUE", $_POST["sel_question_types"]);
01545 $this->tpl->parseCurrentBlock();
01546 $this->tpl->setCurrentBlock("adm_content");
01547 $this->tpl->setVariable("FORM_ACTION", $this->getCallingScript() . $add_parameter);
01548 $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("select_questionpool"));
01549 if (count($questionpools))
01550 {
01551 $this->tpl->setVariable("BTN_SUBMIT", $this->lng->txt("submit"));
01552 }
01553 else
01554 {
01555 sendInfo($this->lng->txt("create_questionpool_before_add_question"));
01556 }
01557 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
01558 $this->tpl->parseCurrentBlock();
01559 }
01560
01570 function constraintsForm($checked_questions, $checked_questionblocks)
01571 {
01572 global $rbacsystem;
01573 sendInfo();
01574 $pages =& $this->object->getSurveyPages();
01575 $all_questions =& $this->object->getSurveyQuestions();
01576 $add_constraint = 0;
01577 $delete_constraint = 0;
01578 $constraint_question = -1;
01579 foreach ($_POST as $key => $value) {
01580 if (preg_match("/add_constraint_(\d+)/", $key, $matches)) {
01581 $add_constraint = 1;
01582 $constraint_question = $matches[1];
01583 }
01584 }
01585 if ($_POST["cmd"]["save_constraint"])
01586 {
01587 foreach ($checked_questions as $id)
01588 {
01589 foreach ($pages as $question_array)
01590 {
01591 foreach ($question_array as $question_data)
01592 {
01593 if ($question_data["question_id"] == $id)
01594 {
01595 $this->object->addConstraint($question_data["question_id"], $_POST["q"], $_POST["r"], $_POST["v"]);
01596 }
01597 }
01598 }
01599 }
01600 foreach ($checked_questionblocks as $id)
01601 {
01602 foreach ($pages as $question_array)
01603 {
01604 if ($question_array[0]["questionblock_id"] == $id)
01605 {
01606 foreach ($question_array as $question_data)
01607 {
01608 $this->object->addConstraint($question_data["question_id"], $_POST["q"], $_POST["r"], $_POST["v"]);
01609 }
01610 }
01611 }
01612 }
01613 $add_constraint = 0;
01614 }
01615 else if ($_POST["cmd"]["cancel_add_constraint"])
01616 {
01617
01618 $add_constraint = 0;
01619 }
01620 else
01621 {
01622 }
01623 if ($add_constraint)
01624 {
01625 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_add_constraint.html", true);
01626 $found = 0;
01627 if ($_POST["cmd"]["select_relation"] or $_POST["cmd"]["select_value"])
01628 {
01629 $this->tpl->setCurrentBlock("option_q");
01630 $this->tpl->setVariable("OPTION_VALUE", $_POST["q"]);
01631 $this->tpl->setVariable("OPTION_TEXT", $all_questions[$_POST["q"]]["title"] . " (" . $this->lng->txt($all_questions[$_POST["q"]]["type_tag"]) . ")");
01632 $this->tpl->parseCurrentBlock();
01633 }
01634 else
01635 {
01636 foreach ($pages as $question_array)
01637 {
01638 if (!$found)
01639 {
01640 foreach ($question_array as $question)
01641 {
01642 if ($question["question_id"] == $constraint_question)
01643 {
01644 $found = 1;
01645 }
01646 }
01647 if (!$found)
01648 {
01649 foreach ($question_array as $question)
01650 {
01651 $this->tpl->setCurrentBlock("option_q");
01652 $this->tpl->setVariable("OPTION_VALUE", $question["question_id"]);
01653 $this->tpl->setVariable("OPTION_TEXT", $question["title"] . " (" . $this->lng->txt($question["type_tag"]) . ")");
01654 if ($question["question_id"] == $_POST["q"])
01655 {
01656 $this->tpl->setVariable("OPTION_CHECKED", " selected=\"selected\"");
01657 }
01658 $this->tpl->parseCurrentBlock();
01659 }
01660 }
01661 }
01662 }
01663 }
01664 foreach ($_POST as $key => $value) {
01665 if (preg_match("/add_constraint_(\d+)/", $key, $matches)) {
01666 $this->tpl->setCurrentBlock("hidden");
01667 $this->tpl->setVariable("HIDDEN_NAME", $key);
01668 $this->tpl->setVariable("HIDDEN_VALUE", $value);
01669 $this->tpl->parseCurrentBlock();
01670 foreach ($checked_questions as $id)
01671 {
01672 $this->tpl->setCurrentBlock("hidden");
01673 $this->tpl->setVariable("HIDDEN_NAME", "cb_$id");
01674 $this->tpl->setVariable("HIDDEN_VALUE", "$id");
01675 $this->tpl->parseCurrentBlock();
01676 }
01677 foreach ($checked_questionblocks as $id)
01678 {
01679 $this->tpl->setCurrentBlock("hidden");
01680 $this->tpl->setVariable("HIDDEN_NAME", "cb_qb_$id");
01681 $this->tpl->setVariable("HIDDEN_VALUE", "$id");
01682 $this->tpl->parseCurrentBlock();
01683 }
01684 }
01685 }
01686 $continue_command = "select_relation";
01687 $back_command = "cancel_add_constraint";
01688 if ($_POST["cmd"]["select_relation"] or $_POST["cmd"]["select_value"])
01689 {
01690 $relations = $this->object->getAllRelations();
01691 switch ($all_questions[$_POST["q"]]["type_tag"])
01692 {
01693 case "qt_nominal":
01694 foreach ($relations as $rel_id => $relation)
01695 {
01696 if ((strcmp($relation["short"], "=") == 0) or (strcmp($relation["short"], "<>") == 0))
01697 {
01698 $this->tpl->setCurrentBlock("option_r");
01699 $this->tpl->setVariable("OPTION_VALUE", $rel_id);
01700 $this->tpl->setVariable("OPTION_TEXT", $relation["short"]);
01701 if ($rel_id == $_POST["r"])
01702 {
01703 $this->tpl->setVariable("OPTION_CHECKED", " selected=\"selected\"");
01704 }
01705 $this->tpl->parseCurrentBlock();
01706 }
01707 }
01708 break;
01709 case "qt_ordinal":
01710 case "qt_metric":
01711 foreach ($relations as $rel_id => $relation)
01712 {
01713 $this->tpl->setCurrentBlock("option_r");
01714 $this->tpl->setVariable("OPTION_VALUE", $rel_id);
01715 $this->tpl->setVariable("OPTION_TEXT", $relation["short"]);
01716 if ($rel_id == $_POST["r"])
01717 {
01718 $this->tpl->setVariable("OPTION_CHECKED", " selected=\"selected\"");
01719 }
01720 $this->tpl->parseCurrentBlock();
01721 }
01722 break;
01723 }
01724 $this->tpl->setCurrentBlock("select_relation");
01725 $this->tpl->setVariable("SELECT_RELATION", $this->lng->txt("select_relation"));
01726 $this->tpl->parseCurrentBlock();
01727 $continue_command = "select_value";
01728 $back_command = "begin_add_constraint";
01729 }
01730 if ($_POST["cmd"]["select_value"])
01731 {
01732 $variables =& $this->object->getVariables($_POST["q"]);
01733 switch ($all_questions[$_POST["q"]]["type_tag"])
01734 {
01735 case "qt_nominal":
01736 case "qt_ordinal":
01737 foreach ($variables as $sequence => $row)
01738 {
01739 $this->tpl->setCurrentBlock("option_v");
01740 $this->tpl->setVariable("OPTION_VALUE", $sequence);
01741 $this->tpl->setVariable("OPTION_TEXT", ($sequence+1) . " - " . $row->title);
01742 $this->tpl->parseCurrentBlock();
01743 }
01744 break;
01745 case "qt_metric":
01746 $this->tpl->setCurrentBlock("textfield");
01747 $this->tpl->setVariable("TEXTFIELD_VALUE", "");
01748 $this->tpl->parseCurrentBlock();
01749 break;
01750 }
01751 $this->tpl->setCurrentBlock("select_value");
01752 if (strcmp($all_questions[$_POST["q"]]["type_tag"], "qt_metric") == 0)
01753 {
01754 $this->tpl->setVariable("SELECT_VALUE", $this->lng->txt("enter_value"));
01755 }
01756 else
01757 {
01758 $this->tpl->setVariable("SELECT_VALUE", $this->lng->txt("select_value"));
01759 }
01760 $this->tpl->parseCurrentBlock();
01761 $continue_command = "save_constraint";
01762 $back_command = "select_relation";
01763 }
01764 $this->tpl->setCurrentBlock("buttons");
01765 $this->tpl->setVariable("BTN_CONTINUE", $this->lng->txt("continue"));
01766 $this->tpl->setVariable("COMMAND", "$continue_command");
01767 $this->tpl->setVariable("BTN_BACK", $this->lng->txt("back"));
01768 $this->tpl->setVariable("COMMAND_BACK", "$back_command");
01769 $this->tpl->parseCurrentBlock();
01770 $this->tpl->setCurrentBlock("adm_content");
01771 $textoutput = "";
01772 foreach ($checked_questions as $id)
01773 {
01774 foreach ($pages as $question_array)
01775 {
01776 foreach ($question_array as $question_data)
01777 {
01778 if ($question_data["question_id"] == $id)
01779 {
01780 if ($textoutput)
01781 {
01782 $textoutput .= "<br>";
01783 }
01784 $textoutput .= $question_data["title"] . ": " . $question_data["questiontext"];
01785 }
01786 }
01787 }
01788 }
01789 foreach ($checked_questionblocks as $id)
01790 {
01791 foreach ($pages as $question_array)
01792 {
01793 if ($question_array[0]["questionblock_id"] == $id)
01794 {
01795 if ($textoutput)
01796 {
01797 $textoutput .= "<br>";
01798 }
01799 $textoutput .= $this->lng->txt("questionblock") . ": " . $question_array[0]["questionblock_title"];
01800 }
01801 }
01802 }
01803 $this->tpl->setVariable("CONSTRAINT_QUESTION_TEXT", "$textoutput");
01804 $this->tpl->setVariable("SELECT_PRIOR_QUESTION", $this->lng->txt("select_prior_question"));
01805 $this->tpl->setVariable("FORM_ACTION", $this->getCallingScript() . $this->getAddParameter());
01806 $this->tpl->parseCurrentBlock();
01807 }
01808 else
01809 {
01810 foreach ($_POST as $key => $value)
01811 {
01812 if (preg_match("/delete_constraint_(\d+)_(\d+)/", $key, $matches)) {
01813 foreach ($pages as $question_array)
01814 {
01815 $found = 0;
01816 foreach ($question_array as $question_data)
01817 {
01818 if ($question_data["question_id"] == $matches[2])
01819 {
01820 $found = 1;
01821 }
01822 }
01823 if ($found)
01824 {
01825 foreach ($question_array as $question_id => $question_data)
01826 {
01827 $this->object->deleteConstraint($matches[1], $question_data["question_id"]);
01828 }
01829 }
01830 }
01831 }
01832 }
01833 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_constraints.html", true);
01834 $colors = array("tblrow1", "tblrow2");
01835 $counter = 0;
01836 foreach ($pages as $question_array)
01837 {
01838 if (count($question_array) > 1)
01839 {
01840
01841 $data = $question_array[0];
01842 }
01843 else
01844 {
01845
01846 $data = $question_array[0];
01847 }
01848 if (in_array($data["questionblock_id"], $checked_questionblocks) or (in_array($data["question_id"], $checked_questions)))
01849 {
01850 $counter = 0;
01851 $constraints = $this->object->getConstraints($data["question_id"]);
01852 if (count($constraints))
01853 {
01854 foreach ($constraints as $constraint)
01855 {
01856 $value = "";
01857 $variables =& $this->object->getVariables($constraint["question"]);
01858 switch ($all_questions[$constraint["question"]]["type_tag"])
01859 {
01860 case "qt_metric":
01861 $value = $constraint["value"];
01862 break;
01863 case "qt_nominal":
01864 case "qt_ordinal":
01865 $value = sprintf("%d", $constraint["value"]+1) . " - " . $variables[$constraint["value"]]->title;
01866 break;
01867 }
01868 $this->tpl->setCurrentBlock("constraint");
01869 $this->tpl->setVariable("CONSTRAINT_TEXT", $all_questions[$constraint["question"]]["title"] . " " . $constraint["short"] . " $value");
01870 if ($rbacsystem->checkAccess("write", $this->ref_id) and ($this->object->isOffline())) {
01871 $this->tpl->setVariable("CONSTRAINT_ID", $constraint["id"]);
01872 $this->tpl->setVariable("CONSTRAINT_QUESTION_ID", $constraint["question"]);
01873 $this->tpl->setVariable("BTN_DELETE", $this->lng->txt("delete"));
01874 }
01875 $this->tpl->parseCurrentBlock();
01876 }
01877 }
01878 else
01879 {
01880 $this->tpl->setCurrentBlock("empty_row");
01881 $this->tpl->setVariable("EMPTY_TEXT", $this->lng->txt("no_available_constraints"));
01882 $this->tpl->parseCurrentBlock();
01883 }
01884 $this->tpl->setCurrentBlock("question");
01885 if ($data["questionblock_id"])
01886 {
01887 $this->tpl->setVariable("QUESTION_IDENTIFIER", $this->lng->txt("questionblock") . ": " . $data["questionblock_title"]);
01888 }
01889 else
01890 {
01891 $this->tpl->setVariable("QUESTION_IDENTIFIER", $this->lng->txt($data["type_tag"]) . ": " . $data["title"]);
01892 }
01893 if ($rbacsystem->checkAccess("write", $this->ref_id) and ($this->object->isOffline())) {
01894 $this->tpl->setVariable("ADD_QUESTION_ID", $data["question_id"]);
01895 $this->tpl->setVariable("BTN_ADD", $this->lng->txt("add"));
01896 }
01897 $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
01898 $this->tpl->setVariable("BTN_BACK", $this->lng->txt("back"));
01899 $this->tpl->parseCurrentBlock();
01900 }
01901 }
01902 foreach ($checked_questions as $id)
01903 {
01904 $this->tpl->setCurrentBlock("hidden");
01905 $this->tpl->setVariable("HIDDEN_NAME", "cb_$id");
01906 $this->tpl->setVariable("HIDDEN_VALUE", "$id");
01907 $this->tpl->parseCurrentBlock();
01908 }
01909 foreach ($checked_questionblocks as $id)
01910 {
01911 $this->tpl->setCurrentBlock("hidden");
01912 $this->tpl->setVariable("HIDDEN_NAME", "cb_qb_$id");
01913 $this->tpl->setVariable("HIDDEN_VALUE", "$id");
01914 $this->tpl->parseCurrentBlock();
01915 }
01916
01917 $this->tpl->setCurrentBlock("adm_content");
01918 if ($rbacsystem->checkAccess("write", $this->ref_id) and ($this->object->isOffline())) {
01919 $this->tpl->setVariable("TEXT_EDIT_CONSTRAINTS", $this->lng->txt("edit_constraints_introduction"));
01920 }
01921 else
01922 {
01923 $this->tpl->setVariable("TEXT_EDIT_CONSTRAINTS", $this->lng->txt("view_constraints_introduction"));
01924 }
01925 $this->tpl->setVariable("FORM_ACTION", $this->getCallingScript() . $this->getAddParameter());
01926 $this->tpl->parseCurrentBlock();
01927 }
01928 }
01929
01938 function addHeadingObject($question_id = "")
01939 {
01940 $add_parameter = $this->getAddParameter();
01941 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_heading.html", true);
01942 $survey_questions =& $this->object->getSurveyQuestions();
01943 if ($question_id)
01944 {
01945 $_POST["insertbefore"] = $question_id;
01946 $_POST["heading"] = $survey_questions[$question_id]["heading"];
01947 }
01948 foreach ($survey_questions as $key => $value)
01949 {
01950 $this->tpl->setCurrentBlock("insertbefore_row");
01951 $this->tpl->setVariable("VALUE_OPTION", $key);
01952 $option = $this->lng->txt("before") . ": \"" . $value["title"] . "\"";
01953 if (strlen($option) > 80)
01954 {
01955 $option = preg_replace("/^(.{40}).*(.{40})$/", "\\1 [...] \\2", $option);
01956 }
01957 $this->tpl->setVariable("TEXT_OPTION", ilUtil::prepareFormOutput($option));
01958 if ($key == $_POST["insertbefore"])
01959 {
01960 $this->tpl->setVariable("SELECTED_OPTION", " selected=\"selected\"");
01961 }
01962 $this->tpl->parseCurrentBlock();
01963 }
01964 if ($question_id)
01965 {
01966 $this->tpl->setCurrentBlock("hidden");
01967 $this->tpl->setVariable("INSERTBEFORE_ORIGINAL", $question_id);
01968 $this->tpl->parseCurrentBlock();
01969 }
01970 $this->tpl->setCurrentBlock("adm_content");
01971 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
01972 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
01973 if ($question_id)
01974 {
01975 $this->tpl->setVariable("TEXT_ADD_HEADING", $this->lng->txt("edit_heading"));
01976 $this->tpl->setVariable("SELECT_DISABLED", " disabled=\"disabled\"");
01977 }
01978 else
01979 {
01980 $this->tpl->setVariable("TEXT_ADD_HEADING", $this->lng->txt("add_heading"));
01981 }
01982 $this->tpl->setVariable("TEXT_HEADING", $this->lng->txt("heading"));
01983 $this->tpl->setVariable("VALUE_HEADING", $_POST["heading"]);
01984 $this->tpl->setVariable("TEXT_INSERT", $this->lng->txt("insert"));
01985 $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
01986 $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
01987 $this->tpl->parseCurrentBlock();
01988 }
01989
01997 function confirmInsertQuestionObject()
01998 {
01999
02000 foreach ($_POST as $key => $value) {
02001 if (preg_match("/id_(\d+)/", $key, $matches)) {
02002 if ($_GET["browsetype"] == 1)
02003 {
02004 $this->object->insertQuestion($matches[1]);
02005 }
02006 else
02007 {
02008 $this->object->insertQuestionBlock($matches[1]);
02009 }
02010 }
02011 }
02012 $this->object->saveCompletionStatus();
02013 sendInfo($this->lng->txt("questions_inserted"), true);
02014 $this->ctrl->redirect($this, "questions");
02015 }
02016
02024 function cancelInsertQuestionObject()
02025 {
02026 $this->ctrl->redirect($this, "questions");
02027 }
02028
02036 function saveHeadingObject()
02037 {
02038 if ($_POST["heading"])
02039 {
02040 $insertbefore = $_POST["insertbefore"];
02041 if (!$insertbefore)
02042 {
02043 $insertbefore = $_POST["insertbefore_original"];
02044 }
02045 $this->object->saveHeading($_POST["heading"], $insertbefore);
02046 $this->ctrl->redirect($this, "questions");
02047 }
02048 else
02049 {
02050 sendInfo($this->lng->txt("error_add_heading"));
02051 $this->addHeadingObject();
02052 return;
02053 }
02054 }
02055
02063 function cancelHeadingObject()
02064 {
02065 $this->ctrl->redirect($this, "questions");
02066 }
02067
02075 function confirmRemoveHeadingObject()
02076 {
02077 $this->object->saveHeading("", $_POST["removeheading"]);
02078 $this->ctrl->redirect($this, "questions");
02079 }
02080
02088 function cancelRemoveHeadingObject()
02089 {
02090 $this->ctrl->redirect($this, "questions");
02091 }
02092
02100 function confirmRemoveHeadingForm()
02101 {
02102 sendInfo($this->lng->txt("confirm_remove_heading"));
02103 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_confirm_removeheading.html", true);
02104 $this->tpl->setCurrentBlock("adm_content");
02105 $this->tpl->setVariable("BTN_CONFIRM_REMOVE", $this->lng->txt("confirm"));
02106 $this->tpl->setVariable("BTN_CANCEL_REMOVE", $this->lng->txt("cancel"));
02107 $this->tpl->setVariable("REMOVE_HEADING", $_GET["removeheading"]);
02108 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
02109 $this->tpl->parseCurrentBlock();
02110 }
02111
02112
02120 function questionsObject() {
02121 global $rbacsystem;
02122
02123 if ((!$rbacsystem->checkAccess("read", $this->ref_id)) && (!$rbacsystem->checkAccess("write", $this->ref_id)))
02124 {
02125
02126 sendInfo($this->lng->txt("cannot_edit_survey"), true);
02127 $path = $this->tree->getPathFull($this->object->getRefID());
02128 ilUtil::redirect($this->getReturnLocation("cancel","../repository.php?cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
02129 return;
02130 }
02131 if ($_GET["new_id"] > 0)
02132 {
02133
02134 $this->object->insertQuestion($_GET["new_id"]);
02135 }
02136
02137 if ($_GET["eqid"] and $_GET["eqpl"])
02138 {
02139 ilUtil::redirect("questionpool.php?ref_id=" . $_GET["eqpl"] . "&cmd=editQuestionForSurvey&calling_survey=".$_GET["ref_id"]."&q_id=" . $_GET["eqid"]);
02140 }
02141
02142
02143 $_SESSION["calling_survey"] = $this->object->getRefId();
02144 unset($_SESSION["survey_id"]);
02145 $add_parameter = $this->getAddParameter();
02146
02147 if ($_GET["editheading"])
02148 {
02149 $this->addHeadingObject($_GET["editheading"]);
02150 return;
02151 }
02152
02153 if ($_GET["up"] > 0)
02154 {
02155 $this->object->moveUpQuestion($_GET["up"]);
02156 }
02157 if ($_GET["down"] > 0)
02158 {
02159 $this->object->moveDownQuestion($_GET["down"]);
02160 }
02161 if ($_GET["qbup"] > 0)
02162 {
02163 $this->object->moveUpQuestionblock($_GET["qbup"]);
02164 }
02165 if ($_GET["qbdown"] > 0)
02166 {
02167 $this->object->moveDownQuestionblock($_GET["qbdown"]);
02168 }
02169
02170 if ($_POST["cmd"]["addHeading"])
02171 {
02172 $this->addHeadingObject();
02173 return;
02174 }
02175
02176 if ($_POST["cmd"]["saveObligatory"])
02177 {
02178 $obligatory = array();
02179 foreach ($_POST as $key => $value)
02180 {
02181 if (preg_match("/obligatory_(\d+)/", $key, $matches))
02182 {
02183 $obligatory[$matches[1]] = 1;
02184 }
02185 }
02186 $this->object->setObligatoryStates($obligatory);
02187 }
02188
02189 if ($_POST["cmd"]["insert_before"] or $_POST["cmd"]["insert_after"])
02190 {
02191
02192 $move_questions = array();
02193 foreach ($_POST as $key => $value)
02194 {
02195 if (preg_match("/^move_(\d+)$/", $key, $matches))
02196 {
02197 array_push($move_questions, $value);
02198 }
02199 }
02200
02201 $insert_id = -1;
02202 foreach ($_POST as $key => $value)
02203 {
02204 if (preg_match("/^cb_(\d+)$/", $key, $matches))
02205 {
02206 if ($insert_id < 0)
02207 {
02208 $insert_id = $matches[1];
02209 }
02210 }
02211 if (preg_match("/^cb_qb_(\d+)$/", $key, $matches))
02212 {
02213 if ($insert_id < 0)
02214 {
02215 $ids =& $this->object->getQuestionblockQuestionIds($matches[1]);
02216 if (count($ids))
02217 {
02218 if ($_POST["cmd"]["insert_before"])
02219 {
02220 $insert_id = $ids[0];
02221 }
02222 else if ($_POST["cmd"]["insert_after"])
02223 {
02224 $insert_id = $ids[count($ids)-1];
02225 }
02226 }
02227 }
02228 }
02229 }
02230 if ($insert_id <= 0)
02231 {
02232 sendInfo($this->lng->txt("no_target_selected_for_move"));
02233 }
02234 else
02235 {
02236 $insert_mode = 1;
02237 if ($_POST["cmd"]["insert_before"])
02238 {
02239 $insert_mode = 0;
02240 }
02241 $this->object->moveQuestions($move_questions, $insert_id, $insert_mode);
02242 }
02243 }
02244
02245 if ($_GET["removeheading"])
02246 {
02247 $this->confirmRemoveHeadingForm();
02248 return;
02249 }
02250
02251 if ($_GET["editblock"])
02252 {
02253 $this->defineQuestionblock($_GET["editblock"]);
02254 return;
02255 }
02256
02257 if ($_POST["cmd"]["questionblock"])
02258 {
02259 $questionblock = array();
02260 foreach ($_POST as $key => $value)
02261 {
02262 if (preg_match("/cb_(\d+)/", $key, $matches))
02263 {
02264 array_push($questionblock, $value);
02265 }
02266 }
02267 if (count($questionblock) < 2)
02268 {
02269 sendInfo($this->lng->txt("qpl_define_questionblock_select_missing"));
02270 }
02271 else
02272 {
02273 $this->defineQuestionblock();
02274 return;
02275 }
02276 }
02277
02278 if ($_POST["cmd"]["unfold"])
02279 {
02280 $unfoldblocks = array();
02281 foreach ($_POST as $key => $value)
02282 {
02283 if (preg_match("/cb_qb_(\d+)/", $key, $matches))
02284 {
02285 array_push($unfoldblocks, $matches[1]);
02286 }
02287 }
02288 if (count($unfoldblocks))
02289 {
02290 $this->object->unfoldQuestionblocks($unfoldblocks);
02291 }
02292 else
02293 {
02294 sendInfo($this->lng->txt("qpl_unfold_select_none"));
02295 }
02296 }
02297
02298 if ($_POST["cmd"]["save_questionblock"])
02299 {
02300 if ($_POST["title"])
02301 {
02302 if ($_POST["questionblock_id"])
02303 {
02304 $this->object->modifyQuestionblock($_POST["questionblock_id"], ilUtil::stripSlashes($_POST["title"]));
02305 }
02306 else
02307 {
02308 $questionblock = array();
02309 foreach ($_POST as $key => $value)
02310 {
02311 if (preg_match("/cb_(\d+)/", $key, $matches))
02312 {
02313 array_push($questionblock, $value);
02314 }
02315 }
02316 $this->object->createQuestionblock(ilUtil::stripSlashes($_POST["title"]), $questionblock);
02317 }
02318 }
02319 else
02320 {
02321 sendInfo($this->lng->txt("enter_questionblock_title"));
02322 $this->defineQuestionblock();
02323 return;
02324 }
02325 }
02326
02327 $add_constraint = 0;
02328 $delete_constraint = 0;
02329 foreach ($_POST as $key => $value) {
02330 if (preg_match("/add_constraint_(\d+)/", $key, $matches)) {
02331 $add_constraint = 1;
02332 }
02333 }
02334 foreach ($_POST as $key => $value) {
02335 if (preg_match("/delete_constraint_(\d+)_(\d+)/", $key, $matches)) {
02336 $delete_constraint = 1;
02337 }
02338 }
02339 if ($_POST["cmd"]["constraints"] or $add_constraint or $delete_constraint or $_GET["constraints"])
02340 {
02341 $checked_questions = array();
02342 $checked_questionblocks = array();
02343 if ($_GET["constraints"])
02344 {
02345 $survey_questions =& $this->object->getSurveyQuestions();
02346 if (strcmp($survey_questions[$_GET["constraints"]]["questionblock_id"], "") == 0)
02347 {
02348 array_push($checked_questions, $_GET["constraints"]);
02349 }
02350 else
02351 {
02352 array_push($checked_questionblocks, $survey_questions[$_GET["constraints"]]["questionblock_id"]);
02353 }
02354 }
02355 foreach ($_POST as $key => $value) {
02356 if (preg_match("/cb_(\d+)/", $key, $matches)) {
02357 array_push($checked_questions, $matches[1]);
02358 }
02359 if (preg_match("/cb_qb_(\d+)/", $key, $matches)) {
02360 array_push($checked_questionblocks, $matches[1]);
02361 }
02362 }
02363 if ($_POST["cmd"]["constraints"] and (count($checked_questions)+count($checked_questionblocks) == 0))
02364 {
02365 sendInfo($this->lng->txt("no_constraints_checked"));
02366 }
02367 else
02368 {
02369 $this->constraintsForm($checked_questions, $checked_questionblocks);
02370 return;
02371 }
02372 }
02373
02374 if ($_POST["cmd"]["create_question"]) {
02375 $this->questionpoolSelectForm();
02376 return;
02377 }
02378
02379 if ($_POST["cmd"]["create_question_execute"])
02380 {
02381 ilUtil::redirect("questionpool.php?ref_id=" . $_POST["sel_spl"] . "&cmd=createQuestionForSurvey&new_for_survey=".$_GET["ref_id"]."&sel_question_types=".$_POST["sel_question_types"]);
02382 exit();
02383 }
02384
02385 if ($_GET["add"])
02386 {
02387
02388 $selected_array = array();
02389 array_push($selected_array, $_GET["add"]);
02390
02391
02392
02393
02394
02395 sendInfo($this->lng->txt("ask_insert_questions"));
02396
02397 $this->insertQuestionsForm($selected_array);
02398 return;
02399 }
02400
02401 if (($_POST["cmd"]["search_question"]) or ($_GET["search_question"]) and (!$_POST["cmd"]["insert"]))
02402 {
02403 $this->searchQuestionsForm();
02404 return;
02405 }
02406
02407 if (($_POST["cmd"]["insert_question"]) or ($_GET["insert_question"])) {
02408 $show_questionbrowser = true;
02409 if ($_POST["cmd"]["insert"])
02410 {
02411
02412 $inserted_objects = 0;
02413 foreach ($_POST as $key => $value)
02414 {
02415 if (preg_match("/cb_(\d+)/", $key, $matches))
02416 {
02417 if ($_GET["browsetype"] == 1)
02418 {
02419 $this->object->insertQuestion($matches[1]);
02420 }
02421 else
02422 {
02423 $this->object->insertQuestionBlock($matches[1]);
02424 }
02425 $inserted_objects++;
02426 }
02427 }
02428 if ($inserted_objects)
02429 {
02430 $this->object->saveCompletionStatus();
02431 sendInfo($this->lng->txt("questions_inserted"), true);
02432 $this->ctrl->redirect($this, "questions");
02433 }
02434 else
02435 {
02436 if ($_GET["browsetype"] == 1)
02437 {
02438 sendInfo($this->lng->txt("insert_missing_question"));
02439 }
02440 else
02441 {
02442 sendInfo($this->lng->txt("insert_missing_questionblock"));
02443 }
02444 }
02445 }
02446 if ($_POST["cmd"]["back"]) {
02447 $show_questionbrowser = false;
02448 }
02449 if ($show_questionbrowser) {
02450 $this->questionBrowser();
02451 return;
02452 }
02453 }
02454
02455 if (strlen($_POST["cmd"]["confirm_remove"]) > 0)
02456 {
02457
02458 sendInfo($this->lng->txt("questions_removed"));
02459 $checked_questions = array();
02460 $checked_questionblocks = array();
02461 foreach ($_POST as $key => $value) {
02462 if (preg_match("/id_(\d+)/", $key, $matches)) {
02463 array_push($checked_questions, $matches[1]);
02464 }
02465 if (preg_match("/id_qb_(\d+)/", $key, $matches)) {
02466 array_push($checked_questionblocks, $matches[1]);
02467 }
02468 }
02469 $this->object->removeQuestions($checked_questions, $checked_questionblocks);
02470 $this->object->saveCompletionStatus();
02471 }
02472
02473 if (strlen($_POST["cmd"]["remove"]) > 0) {
02474 $checked_questions = array();
02475 $checked_questionblocks = array();
02476 foreach ($_POST as $key => $value) {
02477 if (preg_match("/cb_(\d+)/", $key, $matches)) {
02478 array_push($checked_questions, $matches[1]);
02479 }
02480 if (preg_match("/cb_qb_(\d+)/", $key, $matches))
02481 {
02482 array_push($checked_questionblocks, $matches[1]);
02483 }
02484 }
02485 if (count($checked_questions) + count($checked_questionblocks) > 0) {
02486 sendInfo($this->lng->txt("remove_questions"));
02487 $this->removeQuestionsForm($checked_questions, $checked_questionblocks);
02488 return;
02489 } else {
02490 sendInfo($this->lng->txt("no_question_selected_for_removal"));
02491 }
02492 }
02493
02494 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_questions.html", true);
02495
02496 $survey_questions =& $this->object->getSurveyQuestions();
02497 $questionblock_titles =& $this->object->getQuestionblockTitles();
02498 $questionpools =& $this->object->getQuestionpoolTitles();
02499 $colors = array("tblrow1", "tblrow2");
02500 $counter = 0;
02501 $title_counter = 0;
02502 $obligatory = "<img src=\"" . ilUtil::getImagePath("obligatory.gif", true) . "\" alt=\"" . $this->lng->txt("question_obligatory") . "\" title=\"" . $this->lng->txt("question_obligatory") . "\" />";
02503 if (count($survey_questions) > 0)
02504 {
02505 foreach ($survey_questions as $question_id => $data)
02506 {
02507 $title_counter++;
02508 if (($data["questionblock_id"] > 0) and ($data["questionblock_id"] != $last_questionblock_id))
02509 {
02510 if (($data["questionblock_id"] != $last_questionblock_id) and (strcmp($last_questionblock_id, "") != 0))
02511 {
02512 $counter++;
02513 }
02514 $this->tpl->setCurrentBlock("block");
02515 $this->tpl->setVariable("TEXT_QUESTIONBLOCK", $this->lng->txt("questionblock") . ": " . $data["questionblock_title"]);
02516 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
02517 if ($rbacsystem->checkAccess("write", $this->ref_id) and ($this->object->isOffline())) {
02518 if ($data["question_id"] != $this->object->questions[0])
02519 {
02520 $this->tpl->setVariable("BUTTON_UP", "<a href=\"" . $this->getCallingScript() . "$add_parameter&qbup=" . $data["questionblock_id"] . "\"><img src=\"" . ilUtil::getImagePath("a_up.gif") . "\" alt=\"" . $this->lng->txt("up") . "\" title=\"" . $this->lng->txt("up") . "\" border=\"0\" /></a>");
02521 }
02522 $akeys = array_keys($survey_questions);
02523 if ($data["questionblock_id"] != $survey_questions[$akeys[count($akeys)-1]]["questionblock_id"])
02524 {
02525 $this->tpl->setVariable("BUTTON_DOWN", "<a href=\"" . $this->getCallingScript() . "$add_parameter&qbdown=" . $data["questionblock_id"] . "\"><img src=\"" . ilUtil::getImagePath("a_down.gif") . "\" alt=\"" . $this->lng->txt("down") . "\" title=\"" . $this->lng->txt("down") . "\" border=\"0\" /></a>");
02526 }
02527 $this->tpl->setVariable("TEXT_EDIT", "<img src=\"" . ilUtil::getImagePath("icon_pencil.gif") . "\" alt=\"" . $this->lng->txt("edit") . "\" title=\"" . $this->lng->txt("edit") . "\" border=\"0\" />");
02528 $this->tpl->setVariable("HREF_EDIT", $this->getCallingScript() . "$add_parameter&editblock=" . $data["questionblock_id"]);
02529 }
02530 if (count($data["constraints"]))
02531 {
02532 $this->tpl->setVariable("QUESTION_CONSTRAINTS", "<a href=\"" . $this->getCallingScript() . "$add_parameter&constraints=" . $data["question_id"] . "\">" . $this->lng->txt("questionblock_has_constraints") . "</a>");
02533 }
02534 $this->tpl->parseCurrentBlock();
02535 $this->tpl->setCurrentBlock("QTab");
02536 $this->tpl->setVariable("QUESTION_ID", "qb_" . $data["questionblock_id"]);
02537 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
02538 $this->tpl->parseCurrentBlock();
02539 $counter++;
02540 }
02541 if ($data["heading"])
02542 {
02543 $this->tpl->setCurrentBlock("heading");
02544 $this->tpl->setVariable("TEXT_HEADING", $data["heading"]);
02545 $this->tpl->setVariable("COLOR_CLASS", "std");
02546 if ($rbacsystem->checkAccess("write", $this->ref_id) and ($this->object->isOffline())) {
02547 $this->tpl->setVariable("TEXT_EDIT", "<img src=\"" . ilUtil::getImagePath("icon_pencil.gif") . "\" alt=\"" . $this->lng->txt("edit") . "\" title=\"" . $this->lng->txt("edit") . "\" border=\"0\" />");
02548 $this->tpl->setVariable("HREF_EDIT", $this->getCallingScript() . "$add_parameter&editheading=" . $data["question_id"]);
02549 $this->tpl->setVariable("TEXT_DELETE", "<img src=\"" . ilUtil::getImagePath("delete.gif") . "\" alt=\"" . $this->lng->txt("remove") . "\" title=\"" . $this->lng->txt("remove") . "\" border=\"0\" />");
02550 $this->tpl->setVariable("HREF_DELETE", $this->getCallingScript() . "$add_parameter&removeheading=" . $data["question_id"]);
02551 }
02552 $this->tpl->parseCurrentBlock();
02553 $this->tpl->setCurrentBlock("QTab");
02554
02555 $this->tpl->setVariable("COLOR_CLASS", "std");
02556 $this->tpl->parseCurrentBlock();
02557 }
02558 if (!$data["questionblock_id"])
02559 {
02560 $this->tpl->setCurrentBlock("checkable");
02561 $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
02562 $this->tpl->parseCurrentBlock();
02563 }
02564 $this->tpl->setCurrentBlock("QTab");
02565 $ref_id = SurveyQuestion::_getRefIdFromObjId($data["obj_fi"]);
02566 if ($rbacsystem->checkAccess("write", $this->ref_id) and ($this->object->isOffline()))
02567 {
02568 $q_id = $data["question_id"];
02569 $qpl_ref_id = $this->object->_getRefIdFromObjId($data["obj_fi"]);
02570 $this->tpl->setVariable("QUESTION_TITLE", "$title_counter. <a href=\"" . $this->getCallingScript() . $add_parameter . "&eqid=$q_id&eqpl=$qpl_ref_id" . "\">" . $data["title"] . "</a>");
02571
02572 }
02573 else
02574 {
02575 $this->tpl->setVariable("QUESTION_TITLE", "$title_counter. ". $data["title"]);
02576 }
02577
02578 if ($rbacsystem->checkAccess("write", $this->ref_id) and ($this->object->isOffline()))
02579 {
02580 $obligatory_checked = "";
02581 if ($data["obligatory"] == 1)
02582 {
02583 $obligatory_checked = " checked=\"checked\"";
02584 }
02585 $this->tpl->setVariable("QUESTION_OBLIGATORY", "<input type=\"checkbox\" name=\"obligatory_" . $data["question_id"] . "\" value=\"1\"$obligatory_checked />");
02586 }
02587 else
02588 {
02589 if ($data["obligatory"] == 1)
02590 {
02591 $this->tpl->setVariable("QUESTION_OBLIGATORY", $obligatory);
02592 }
02593 }
02594 $this->tpl->setVariable("QUESTION_COMMENT", $data["description"]);
02595 if ($rbacsystem->checkAccess("write", $this->ref_id) and ($this->object->isOffline())) {
02596 if (!$data["questionblock_id"])
02597 {
02598
02599 if ($data["question_id"] != $this->object->questions[0])
02600 {
02601 $this->tpl->setVariable("BUTTON_UP", "<a href=\"" . $this->getCallingScript() . "$add_parameter&up=" . $data["question_id"] . "\"><img src=\"" . ilUtil::getImagePath("a_up.gif") . "\" alt=\"Up\" border=\"0\" /></a>");
02602 }
02603 if ($data["question_id"] != $this->object->questions[count($this->object->questions)-1])
02604 {
02605 $this->tpl->setVariable("BUTTON_DOWN", "<a href=\"" . $this->getCallingScript() . "$add_parameter&down=" . $data["question_id"] . "\"><img src=\"" . ilUtil::getImagePath("a_down.gif") . "\" alt=\"Down\" border=\"0\" /></a>");
02606 }
02607 }
02608 else
02609 {
02610
02611 if ($data["questionblock_id"] == $last_questionblock_id)
02612 {
02613 $this->tpl->setVariable("BUTTON_UP", "<a href=\"" . $this->getCallingScript() . "$add_parameter&up=" . $data["question_id"] . "\"><img src=\"" . ilUtil::getImagePath("a_up.gif") . "\" alt=\"Up\" border=\"0\" /></a>");
02614 }
02615 $tmp_questions = array_keys($survey_questions);
02616 $blockkey = array_search($question_id, $tmp_questions);
02617 if (($blockkey !== FALSE) && ($blockkey < count($tmp_questions)-1))
02618 {
02619 if ($data["questionblock_id"] == $survey_questions[$tmp_questions[$blockkey+1]]["questionblock_id"])
02620 {
02621 $this->tpl->setVariable("BUTTON_DOWN", "<a href=\"" . $this->getCallingScript() . "$add_parameter&down=" . $data["question_id"] . "\"><img src=\"" . ilUtil::getImagePath("a_down.gif") . "\" alt=\"Down\" border=\"0\" /></a>");
02622 }
02623 }
02624 }
02625 }
02626 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($data["type_tag"]));
02627 $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]);
02628 if (count($data["constraints"]) and (strcmp($data["questionblock_id"], "") == 0))
02629 {
02630 $this->tpl->setVariable("QUESTION_CONSTRAINTS", "<a href=\"" . $this->getCallingScript() . "$add_parameter&constraints=" . $data["question_id"] . "\">" . $this->lng->txt("question_has_constraints") . "</a>");
02631 }
02632 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
02633 if (!$data["questionblock_id"])
02634 {
02635 $counter++;
02636 }
02637 $this->tpl->parseCurrentBlock();
02638 $last_questionblock_id = $data["questionblock_id"];
02639 }
02640 }
02641
02642 $checked_move = 0;
02643 if ($_POST["cmd"]["move"])
02644 {
02645 foreach ($_POST as $key => $value)
02646 {
02647 if (preg_match("/cb_(\d+)/", $key, $matches))
02648 {
02649 $checked_move++;
02650 $this->tpl->setCurrentBlock("move");
02651 $this->tpl->setVariable("MOVE_COUNTER", $matches[1]);
02652 $this->tpl->setVariable("MOVE_VALUE", $matches[1]);
02653 $this->tpl->parseCurrentBlock();
02654 }
02655 if (preg_match("/cb_qb_(\d+)/", $key, $matches))
02656 {
02657 $checked_move++;
02658 $ids = $this->object->getQuestionblockQuestionIds($matches[1]);
02659 foreach ($ids as $qkey => $qid)
02660 {
02661 $this->tpl->setCurrentBlock("move");
02662 $this->tpl->setVariable("MOVE_COUNTER", $qid);
02663 $this->tpl->setVariable("MOVE_VALUE", $qid);
02664 $this->tpl->parseCurrentBlock();
02665 }
02666 }
02667 }
02668 if ($checked_move)
02669 {
02670 sendInfo($this->lng->txt("select_target_position_for_move_question"));
02671 $this->tpl->setCurrentBlock("move_buttons");
02672 $this->tpl->setVariable("INSERT_BEFORE", $this->lng->txt("insert_before"));
02673 $this->tpl->setVariable("INSERT_AFTER", $this->lng->txt("insert_after"));
02674 $this->tpl->parseCurrentBlock();
02675 }
02676 else
02677 {
02678 sendInfo($this->lng->txt("no_question_selected_for_move"));
02679 }
02680 }
02681
02682
02683 if ($counter == 0) {
02684 $this->tpl->setCurrentBlock("Emptytable");
02685 $this->tpl->setVariable("TEXT_EMPTYTABLE", $this->lng->txt("no_questions_available"));
02686 $this->tpl->parseCurrentBlock();
02687 } else {
02688 if ($rbacsystem->checkAccess("write", $this->ref_id) and (!$this->object->getStatus() == STATUS_ONLINE)) {
02689 $this->tpl->setCurrentBlock("QFooter");
02690 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"\">");
02691 $this->tpl->setVariable("REMOVE", $this->lng->txt("remove_question"));
02692 $this->tpl->setVariable("MOVE", $this->lng->txt("move"));
02693 $this->tpl->setVariable("SAVE", $this->lng->txt("save_obligatory_state"));
02694 $this->tpl->setVariable("QUESTIONBLOCK", $this->lng->txt("define_questionblock"));
02695 $this->tpl->setVariable("UNFOLD", $this->lng->txt("unfold"));
02696 $this->tpl->setVariable("CONSTRAINTS", $this->lng->txt("constraints"));
02697 $this->tpl->setVariable("HEADING", $this->lng->txt("add_heading"));
02698 $this->tpl->parseCurrentBlock();
02699 }
02700 }
02701
02702 if ($rbacsystem->checkAccess("write", $this->ref_id) and (!$this->object->getStatus() == STATUS_ONLINE)) {
02703 $this->tpl->setCurrentBlock("QTypes");
02704 $query = "SELECT * FROM survey_questiontype";
02705 $query_result = $this->ilias->db->query($query);
02706 while ($data = $query_result->fetchRow(DB_FETCHMODE_OBJECT))
02707 {
02708 $this->tpl->setVariable("QUESTION_TYPE_ID", $data->type_tag);
02709 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($data->type_tag));
02710 $this->tpl->parseCurrentBlock();
02711 }
02712 $this->tpl->parseCurrentBlock();
02713 }
02714 $this->tpl->setCurrentBlock("adm_content");
02715 $this->tpl->setVariable("FORM_ACTION", $this->getCallingScript() . $add_parameter);
02716 $this->tpl->setVariable("QUESTION_TITLE", $this->lng->txt("title"));
02717 $this->tpl->setVariable("QUESTION_COMMENT", $this->lng->txt("description"));
02718 $this->tpl->setVariable("QUESTION_OBLIGATORY", $this->lng->txt("obligatory"));
02719 $this->tpl->setVariable("QUESTION_CONSTRAINTS", $this->lng->txt("constraints"));
02720 $this->tpl->setVariable("QUESTION_SEQUENCE", $this->lng->txt("sequence"));
02721 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("question_type"));
02722 $this->tpl->setVariable("QUESTION_AUTHOR", $this->lng->txt("author"));
02723 $this->tpl->setVariable("TEXT_EDIT", $this->lng->txt("edit"));
02724
02725 if ($rbacsystem->checkAccess("write", $this->ref_id) and (!$this->object->getStatus() == STATUS_ONLINE)) {
02726 $this->tpl->setVariable("BUTTON_INSERT_QUESTION", $this->lng->txt("browse_for_questions"));
02727 $this->tpl->setVariable("BUTTON_SEARCH_QUESTION", $this->lng->txt("search_questions"));
02728 $this->tpl->setVariable("TEXT_OR", " " . strtolower($this->lng->txt("or")));
02729 $this->tpl->setVariable("TEXT_CREATE_NEW", " " . strtolower($this->lng->txt("or")) . " " . $this->lng->txt("create_new"));
02730 $this->tpl->setVariable("BUTTON_CREATE_QUESTION", $this->lng->txt("create"));
02731 }
02732 if ($this->object->getStatus() == STATUS_ONLINE)
02733 {
02734 sendInfo($this->lng->txt("survey_online_warning"));
02735 }
02736
02737 $this->tpl->parseCurrentBlock();
02738 }
02739
02740 function evaluationuserObject()
02741 {
02742 if (!is_array($_POST))
02743 {
02744 $_POST = array();
02745 }
02746 $format_bold = "";
02747 $format_percent = "";
02748 $format_datetime = "";
02749 $format_title = "";
02750 $format_title_plain = "";
02751 $object_title = preg_replace("/[^a-zA-Z0-9\s]/", "", $this->object->getTitle());
02752 $surveyname = preg_replace("/\s/", "_", $object_title);
02753
02754 if (!$_POST["export_format"])
02755 {
02756 $_POST["export_format"] = TYPE_PRINT;
02757 }
02758
02759 $eval =& $this->object->getEvaluationForAllUsers();
02760 $this->setEvalTabs();
02761 sendInfo();
02762 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_evaluation_user.html", true);
02763 $counter = 0;
02764 $classes = array("tblrow1top", "tblrow2top");
02765 $csvrow = array();
02766 $questions =& $this->object->getSurveyQuestions(true);
02767 $this->tpl->setCurrentBlock("headercell");
02768 $this->tpl->setVariable("TEXT_HEADER_CELL", $this->lng->txt("username"));
02769 $this->tpl->parseCurrentBlock();
02770 if ($this->object->getAnonymize() == ANONYMIZE_OFF)
02771 {
02772 $this->tpl->setCurrentBlock("headercell");
02773 $this->tpl->setVariable("TEXT_HEADER_CELL", $this->lng->txt("gender"));
02774 $this->tpl->parseCurrentBlock();
02775 }
02776 if (array_key_exists("export_format", $_POST))
02777 {
02778 array_push($csvrow, $this->lng->txt("username"));
02779 if ($this->object->getAnonymize() == ANONYMIZE_OFF)
02780 {
02781 array_push($csvrow, $this->lng->txt("gender"));
02782 }
02783 }
02784 $char = "A";
02785 $cellcounter = 1;
02786 foreach ($questions as $question_id => $question_data)
02787 {
02788 $this->tpl->setCurrentBlock("headercell");
02789 $this->tpl->setVariable("TEXT_HEADER_CELL", $char);
02790 $this->tpl->parseCurrentBlock();
02791 $this->tpl->setCurrentBlock("legendrow");
02792 $this->tpl->setVariable("TEXT_KEY", $char++);
02793 $this->tpl->setVariable("TEXT_VALUE", $question_data["title"]);
02794 if (array_key_exists("export_format", $_POST))
02795 {
02796 array_push($csvrow, $question_data["title"]);
02797 switch ($question_data["questiontype_fi"])
02798 {
02799 case 1:
02800 if ($question_data["subtype"] == SUBTYPE_MCMR)
02801 {
02802 foreach ($question_data["answers"] as $cat => $cattext)
02803 {
02804 array_push($csvrow, ($cat+1) . " - $cattext");
02805 }
02806 }
02807 break;
02808 case 2:
02809 case 3:
02810 case 4:
02811 break;
02812 }
02813 }
02814 $this->tpl->parseCurrentBlock();
02815 }
02816 $csvfile = array();
02817 array_push($csvfile, $csvrow);
02818
02819 foreach ($eval as $user_id => $resultset)
02820 {
02821 $csvrow = array();
02822 $this->tpl->setCurrentBlock("bodycell");
02823 $this->tpl->setVariable("COLOR_CLASS", $classes[$counter % 2]);
02824 $this->tpl->setVariable("TEXT_BODY_CELL", $resultset["name"]);
02825 array_push($csvrow, $resultset["name"]);
02826 $this->tpl->parseCurrentBlock();
02827 if ($this->object->getAnonymize() == ANONYMIZE_OFF)
02828 {
02829 $this->tpl->setCurrentBlock("bodycell");
02830 $this->tpl->setVariable("COLOR_CLASS", $classes[$counter % 2]);
02831 $this->tpl->setVariable("TEXT_BODY_CELL", $resultset["gender"]);
02832 array_push($csvrow, $resultset["gender"]);
02833 $this->tpl->parseCurrentBlock();
02834 }
02835 foreach ($questions as $question_id => $question_data)
02836 {
02837
02838 if (array_key_exists("export_format", $_POST))
02839 {
02840 switch ($question_data["questiontype_fi"])
02841 {
02842 case 1:
02843
02844 if (count($resultset["answers"][$question_id]))
02845 {
02846 if ($question_data["subtype"] == SUBTYPE_MCMR)
02847 {
02848 array_push($csvrow, "");
02849 foreach ($question_data["answers"] as $cat => $cattext)
02850 {
02851 $found = 0;
02852 foreach ($resultset["answers"][$question_id] as $answerdata)
02853 {
02854 if (strcmp($cat, $answerdata["value"]) == 0)
02855 {
02856 $found = 1;
02857 }
02858 }
02859 if ($found)
02860 {
02861 array_push($csvrow, "1");
02862 }
02863 else
02864 {
02865 array_push($csvrow, "0");
02866 }
02867 }
02868 }
02869 else
02870 {
02871 array_push($csvrow, $resultset["answers"][$question_id][0]["value"]+1);
02872 }
02873 }
02874 else
02875 {
02876 array_push($csvrow, $this->lng->txt("skipped"));
02877 if ($question_data["subtype"] == SUBTYPE_MCMR)
02878 {
02879 foreach ($question_data["answers"] as $cat => $cattext)
02880 {
02881 array_push($csvrow, "");
02882 }
02883 }
02884 }
02885 break;
02886 case 2:
02887
02888 if (count($resultset["answers"][$question_id]))
02889 {
02890 foreach ($resultset["answers"][$question_id] as $key => $answer)
02891 {
02892 array_push($csvrow, $answer["value"]+1);
02893 }
02894 }
02895 else
02896 {
02897 array_push($csvrow, $this->lng->txt("skipped"));
02898 }
02899 break;
02900 case 3:
02901
02902 if (count($resultset["answers"][$question_id]))
02903 {
02904 foreach ($resultset["answers"][$question_id] as $key => $answer)
02905 {
02906 array_push($csvrow, $answer["value"]);
02907 }
02908 }
02909 else
02910 {
02911 array_push($csvrow, $this->lng->txt("skipped"));
02912 }
02913 break;
02914 case 4:
02915
02916 if (count($resultset["answers"][$question_id]))
02917 {
02918 foreach ($resultset["answers"][$question_id] as $key => $answer)
02919 {
02920 array_push($csvrow, $answer["textanswer"]);
02921 }
02922 }
02923 else
02924 {
02925 array_push($csvrow, $this->lng->txt("skipped"));
02926 }
02927 break;
02928 }
02929 }
02930
02931 if (count($resultset["answers"][$question_id]))
02932 {
02933 $answervalues = array();
02934 foreach ($resultset["answers"][$question_id] as $key => $answer)
02935 {
02936 switch ($question_data["questiontype_fi"])
02937 {
02938 case 1:
02939
02940 if (strcmp($answer["value"], "") != 0)
02941 {
02942 array_push($answervalues, ($answer["value"]+1) . " - " . ilUtil::prepareFormOutput($questions[$question_id]["answers"][$answer["value"]]));
02943 }
02944 break;
02945 case 2:
02946
02947 array_push($answervalues, ($answer["value"]+1) . " - " . ilUtil::prepareFormOutput($questions[$question_id]["answers"][$answer["value"]]));
02948 break;
02949 case 3:
02950
02951 array_push($answervalues, $answer["value"]);
02952 break;
02953 case 4:
02954
02955 array_push($answervalues, $answer["textanswer"]);
02956 break;
02957 }
02958 }
02959 $this->tpl->setCurrentBlock("bodycell");
02960 $this->tpl->setVariable("COLOR_CLASS", $classes[$counter % 2]);
02961 $this->tpl->setVariable("TEXT_BODY_CELL", join($answervalues, "<br />"));
02962 $this->tpl->parseCurrentBlock();
02963 }
02964 else
02965 {
02966 $this->tpl->setCurrentBlock("bodycell");
02967 $this->tpl->setVariable("COLOR_CLASS", $classes[$counter % 2]);
02968 $this->tpl->setVariable("TEXT_BODY_CELL", $this->lng->txt("skipped"));
02969 $this->tpl->parseCurrentBlock();
02970 }
02971 }
02972 $this->tpl->touchBlock("row");
02973 $counter++;
02974 array_push($csvfile, $csvrow);
02975 }
02976 $this->tpl->setCurrentBlock("generic_css");
02977 $this->tpl->setVariable("LOCATION_GENERIC_STYLESHEET", "./templates/default/evaluation_print.css");
02978 $this->tpl->setVariable("MEDIA_GENERIC_STYLESHEET", "print");
02979 $this->tpl->parseCurrentBlock();
02980 $this->tpl->setCurrentBlock("adm_content");
02981 $this->tpl->setVariable("EXPORT_DATA", $this->lng->txt("export_data_as"));
02982 $this->tpl->setVariable("TEXT_EXCEL", $this->lng->txt("exp_type_excel"));
02983 $this->tpl->setVariable("TEXT_EXCEL_MAC", $this->lng->txt("exp_type_excel_mac"));
02984 $this->tpl->setVariable("TEXT_CSV", $this->lng->txt("exp_type_csv"));
02985 $this->tpl->setVariable("BTN_EXPORT", $this->lng->txt("export"));
02986 $this->tpl->setVariable("BTN_PRINT", $this->lng->txt("print"));
02987 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
02988 $this->tpl->setVariable("PRINT_ACTION", $this->ctrl->getFormAction($this));
02989 $this->tpl->setVariable("TEXT_LEGEND", $this->lng->txt("legend"));
02990 $this->tpl->setVariable("TEXT_LEGEND_LINK", $this->lng->txt("eval_legend_link"));
02991 $this->tpl->setVariable("CMD_EXPORT", "evaluationuser");
02992 $this->tpl->parseCurrentBlock();
02993 switch ($_POST["export_format"])
02994 {
02995 case TYPE_XLS:
02996 case TYPE_XLS_MAC:
02997
02998
02999 include_once ("./classes/class.ilExcelUtils.php");
03000 $result = @include_once 'Spreadsheet/Excel/Writer.php';
03001 if (!$result)
03002 {
03003 include_once './classes/Spreadsheet/Excel/Writer.php';
03004 }
03005 $workbook = new Spreadsheet_Excel_Writer();
03006
03007
03008 $workbook->send("$surveyname.xls");
03009
03010
03011 $format_bold =& $workbook->addFormat();
03012 $format_bold->setBold();
03013 $format_percent =& $workbook->addFormat();
03014 $format_percent->setNumFormat("0.00%");
03015 $format_datetime =& $workbook->addFormat();
03016 $format_datetime->setNumFormat("DD/MM/YYYY hh:mm:ss");
03017 $format_title =& $workbook->addFormat();
03018 $format_title->setBold();
03019 $format_title->setColor('black');
03020 $format_title->setPattern(1);
03021 $format_title->setFgColor('silver');
03022 $format_title_plain =& $workbook->addFormat();
03023 $format_title_plain->setColor('black');
03024 $format_title_plain->setPattern(1);
03025 $format_title_plain->setFgColor('silver');
03026
03027 $mainworksheet =& $workbook->addWorksheet();
03028 $row = 0;
03029 foreach ($csvfile as $csvrow)
03030 {
03031 $col = 0;
03032 if ($row == 0)
03033 {
03034 foreach ($csvrow as $text)
03035 {
03036 $mainworksheet->writeString($row, $col++, ilExcelUtils::_convert_text($text, $_POST["export_format"]), $format_title);
03037 }
03038 }
03039 else
03040 {
03041 foreach ($csvrow as $text)
03042 {
03043 if (is_numeric($text))
03044 {
03045 $mainworksheet->writeNumber($row, $col++, $text);
03046 }
03047 else
03048 {
03049 $mainworksheet->writeString($row, $col++, ilExcelUtils::_convert_text($text, $_POST["export_format"]));
03050 }
03051 }
03052 }
03053 $row++;
03054 }
03055 $workbook->close();
03056 exit();
03057 break;
03058 case TYPE_SPSS:
03059 $csv = "";
03060 $separator = ";";
03061 foreach ($csvfile as $csvrow)
03062 {
03063 $csvrow =& $this->object->processCSVRow($csvrow, TRUE, $separator);
03064 $csv .= join($csvrow, $separator) . "\n";
03065 }
03066 ilUtil::deliverData($csv, "$surveyname.csv");
03067 exit();
03068 break;
03069 }
03070 }
03071
03072 function evaluationdetailsObject()
03073 {
03074 $this->evaluationObject(1);
03075 }
03076
03084 function evaluationObject($details = 0)
03085 {
03086 global $ilUser;
03087
03088 $format_bold = "";
03089 $format_percent = "";
03090 $format_datetime = "";
03091 $format_title = "";
03092 $object_title = preg_replace("/[^a-zA-Z0-9\s]/", "", $this->object->getTitle());
03093 $surveyname = preg_replace("/\s/", "_", $object_title);
03094
03095 if (!$_POST["export_format"])
03096 {
03097 $_POST["export_format"] = TYPE_PRINT;
03098 }
03099 switch ($_POST["export_format"])
03100 {
03101 case TYPE_XLS:
03102 case TYPE_XLS_MAC:
03103
03104 $result = @include_once 'Spreadsheet/Excel/Writer.php';
03105 if (!$result)
03106 {
03107 include_once './classes/Spreadsheet/Excel/Writer.php';
03108 }
03109 $workbook = new Spreadsheet_Excel_Writer();
03110
03111
03112 $workbook->send("$surveyname.xls");
03113
03114
03115 $format_bold =& $workbook->addFormat();
03116 $format_bold->setBold();
03117 $format_percent =& $workbook->addFormat();
03118 $format_percent->setNumFormat("0.00%");
03119 $format_datetime =& $workbook->addFormat();
03120 $format_datetime->setNumFormat("DD/MM/YYYY hh:mm:ss");
03121 $format_title =& $workbook->addFormat();
03122 $format_title->setBold();
03123 $format_title->setColor('black');
03124 $format_title->setPattern(1);
03125 $format_title->setFgColor('silver');
03126
03127 include_once ("./classes/class.ilExcelUtils.php");
03128 $mainworksheet =& $workbook->addWorksheet();
03129 $mainworksheet->writeString(0, 0, ilExcelUtils::_convert_text($this->lng->txt("title"), $_POST["export_format"]), $format_bold);
03130 $mainworksheet->writeString(0, 1, ilExcelUtils::_convert_text($this->lng->txt("question"), $_POST["export_format"]), $format_bold);
03131 $mainworksheet->writeString(0, 2, ilExcelUtils::_convert_text($this->lng->txt("question_type"), $_POST["export_format"]), $format_bold);
03132 $mainworksheet->writeString(0, 3, ilExcelUtils::_convert_text($this->lng->txt("users_answered"), $_POST["export_format"]), $format_bold);
03133 $mainworksheet->writeString(0, 4, ilExcelUtils::_convert_text($this->lng->txt("users_skipped"), $_POST["export_format"]), $format_bold);
03134 $mainworksheet->writeString(0, 5, ilExcelUtils::_convert_text($this->lng->txt("mode"), $_POST["export_format"]), $format_bold);
03135 $mainworksheet->writeString(0, 6, ilExcelUtils::_convert_text($this->lng->txt("mode_text"), $_POST["export_format"]), $format_bold);
03136 $mainworksheet->writeString(0, 7, ilExcelUtils::_convert_text($this->lng->txt("mode_nr_of_selections"), $_POST["export_format"]), $format_bold);
03137 $mainworksheet->writeString(0, 8, ilExcelUtils::_convert_text($this->lng->txt("median"), $_POST["export_format"]), $format_bold);
03138 $mainworksheet->writeString(0, 9, ilExcelUtils::_convert_text($this->lng->txt("arithmetic_mean"), $_POST["export_format"]), $format_bold);
03139 break;
03140 case (TYPE_SPSS || TYPE_PRINT):
03141 $csvfile = array();
03142 $csvrow = array();
03143 array_push($csvrow, $this->lng->txt("title"));
03144 array_push($csvrow, $this->lng->txt("question"));
03145 array_push($csvrow, $this->lng->txt("question_type"));
03146 array_push($csvrow, $this->lng->txt("users_answered"));
03147 array_push($csvrow, $this->lng->txt("users_skipped"));
03148 array_push($csvrow, $this->lng->txt("mode"));
03149
03150
03151
03152
03153 array_push($csvrow, $this->lng->txt("mode_nr_of_selections"));
03154 array_push($csvrow, $this->lng->txt("median"));
03155 array_push($csvrow, $this->lng->txt("arithmetic_mean"));
03156 array_push($csvfile, $csvrow);
03157 break;
03158 }
03159
03160 $this->setEvalTabs();
03161 sendInfo();
03162 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_evaluation.html", true);
03163 $counter = 0;
03164 $classes = array("tblrow1", "tblrow2");
03165 $questions =& $this->object->getSurveyQuestions();
03166 foreach ($questions as $data)
03167 {
03168 $eval = $this->object->getEvaluation($data["question_id"], $ilUser->id);
03169 $this->tpl->setCurrentBlock("row");
03170 $this->tpl->setVariable("QUESTION_TITLE", ($counter+1) . ". " . $data["title"]);
03171 $maxlen = 37;
03172 if (strlen($data["questiontext"]) > $maxlen + 3)
03173 {
03174 $questiontext = substr($data["questiontext"], 0, $maxlen) . "...";
03175 }
03176 else
03177 {
03178 $questiontext = $data["questiontext"];
03179 }
03180 $this->tpl->setVariable("QUESTION_TEXT", $questiontext);
03181 $this->tpl->setVariable("USERS_ANSWERED", $eval["USERS_ANSWERED"]);
03182 $this->tpl->setVariable("USERS_SKIPPED", $eval["USERS_SKIPPED"]);
03183 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($eval["QUESTION_TYPE"]));
03184 $this->tpl->setVariable("MODE", $eval["MODE"]);
03185 $this->tpl->setVariable("MODE_NR_OF_SELECTIONS", $eval["MODE_NR_OF_SELECTIONS"]);
03186 $this->tpl->setVariable("MEDIAN", $eval["MEDIAN"]);
03187 $this->tpl->setVariable("ARITHMETIC_MEAN", $eval["ARITHMETIC_MEAN"]);
03188 $this->tpl->setVariable("COLOR_CLASS", $classes[$counter % 2]);
03189 switch ($_POST["export_format"])
03190 {
03191 case TYPE_XLS:
03192 case TYPE_XLS_MAC:
03193 include_once ("./classes/class.ilExcelUtils.php");
03194 $mainworksheet->writeString($counter+1, 0, ilExcelUtils::_convert_text($data["title"], $_POST["export_format"]));
03195 $mainworksheet->writeString($counter+1, 1, ilExcelUtils::_convert_text($data["questiontext"], $_POST["export_format"]));
03196 $mainworksheet->writeString($counter+1, 2, ilExcelUtils::_convert_text($this->lng->txt($eval["QUESTION_TYPE"]), $_POST["export_format"]));
03197 $mainworksheet->write($counter+1, 3, $eval["USERS_ANSWERED"]);
03198 $mainworksheet->write($counter+1, 4, $eval["USERS_SKIPPED"]);
03199 preg_match("/(.*?)\s+-\s+(.*)/", $eval["MODE"], $matches);
03200 switch ($eval["QUESTION_TYPE"])
03201 {
03202 case "qt_metric":
03203 $mainworksheet->write($counter+1, 5, ilExcelUtils::_convert_text($eval["MODE"], $_POST["export_format"]));
03204 $mainworksheet->write($counter+1, 6, ilExcelUtils::_convert_text($eval["MODE"], $_POST["export_format"]));
03205 break;
03206 default:
03207 $mainworksheet->write($counter+1, 5, ilExcelUtils::_convert_text($matches[1], $_POST["export_format"]));
03208 $mainworksheet->write($counter+1, 6, ilExcelUtils::_convert_text($matches[2], $_POST["export_format"]));
03209 break;
03210 }
03211 $mainworksheet->write($counter+1, 7, $eval["MODE_NR_OF_SELECTIONS"]);
03212 $mainworksheet->write($counter+1, 8, ilExcelUtils::_convert_text(str_replace("<br />", " ", $eval["MEDIAN"]), $_POST["export_format"]));
03213 $mainworksheet->write($counter+1, 9, $eval["ARITHMETIC_MEAN"]);
03214 break;
03215 case (TYPE_SPSS || TYPE_PRINT):
03216 $csvrow = array();
03217 array_push($csvrow, $data["title"]);
03218 array_push($csvrow, $data["questiontext"]);
03219 array_push($csvrow, $this->lng->txt($eval["QUESTION_TYPE"]));
03220 array_push($csvrow, $eval["USERS_ANSWERED"]);
03221 array_push($csvrow, $eval["USERS_SKIPPED"]);
03222 array_push($csvrow, $eval["MODE"]);
03223 array_push($csvrow, $eval["MODE_NR_OF_SELECTIONS"]);
03224 array_push($csvrow, $eval["MEDIAN"]);
03225 array_push($csvrow, $eval["ARITHMETIC_MEAN"]);
03226 array_push($csvfile, $csvrow);
03227 break;
03228 }
03229 $this->tpl->parseCurrentBlock();
03230 if ($details)
03231 {
03232 $printDetail = array();
03233 switch ($_POST["export_format"])
03234 {
03235 case TYPE_XLS:
03236 case TYPE_XLS_MAC:
03237 include_once ("./classes/class.ilExcelUtils.php");
03238 $worksheet =& $workbook->addWorksheet();
03239 $worksheet->writeString(0, 0, ilExcelUtils::_convert_text($this->lng->txt("title"), $_POST["export_format"]), $format_bold);
03240 $worksheet->writeString(0, 1, ilExcelUtils::_convert_text($data["title"], $_POST["export_format"]));
03241 $worksheet->writeString(1, 0, ilExcelUtils::_convert_text($this->lng->txt("question"), $_POST["export_format"]), $format_bold);
03242 $worksheet->writeString(1, 1, ilExcelUtils::_convert_text($data["questiontext"], $_POST["export_format"]));
03243 $worksheet->writeString(2, 0, ilExcelUtils::_convert_text($this->lng->txt("question_type"), $_POST["export_format"]), $format_bold);
03244 $worksheet->writeString(2, 1, ilExcelUtils::_convert_text($this->lng->txt($eval["QUESTION_TYPE"]), $_POST["export_format"]));
03245 $worksheet->writeString(3, 0, ilExcelUtils::_convert_text($this->lng->txt("users_answered"), $_POST["export_format"]), $format_bold);
03246 $worksheet->write(3, 1, $eval["USERS_ANSWERED"]);
03247 $worksheet->writeString(4, 0, ilExcelUtils::_convert_text($this->lng->txt("users_skipped"), $_POST["export_format"]), $format_bold);
03248 $worksheet->write(4, 1, $eval["USERS_SKIPPED"]);
03249 $rowcounter = 5;
03250 break;
03251 case TYPE_PRINT:
03252 array_push($printDetail, $this->lng->txt("title"));
03253 array_push($printDetail, $data["title"]);
03254 array_push($printDetail, $this->lng->txt("question"));
03255 array_push($printDetail, $data["questiontext"]);
03256 array_push($printDetail, $this->lng->txt("question_type"));
03257 array_push($printDetail, $this->lng->txt($eval["QUESTION_TYPE"]));
03258 array_push($printDetail, $this->lng->txt("users_answered"));
03259 array_push($printDetail, $eval["USERS_ANSWERED"]);
03260 array_push($printDetail, $this->lng->txt("users_skipped"));
03261 array_push($printDetail, $eval["USERS_SKIPPED"]);
03262 break;
03263 }
03264 $this->tpl->setCurrentBlock("detail");
03265 $this->tpl->setVariable("QUESTION_TITLE", $data["title"]);
03266 $this->tpl->setVariable("TEXT_QUESTION_TEXT", $this->lng->txt("question"));
03267 $this->tpl->setVariable("QUESTION_TEXT", $data["questiontext"]);
03268 $this->tpl->setVariable("TEXT_QUESTION_TYPE", $this->lng->txt("question_type"));
03269 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($eval["QUESTION_TYPE"]));
03270 $this->tpl->setVariable("TEXT_USERS_ANSWERED", $this->lng->txt("users_answered"));
03271 $this->tpl->setVariable("USERS_ANSWERED", $eval["USERS_ANSWERED"]);
03272 $this->tpl->setVariable("TEXT_USERS_SKIPPED", $this->lng->txt("users_skipped"));
03273 $this->tpl->setVariable("USERS_SKIPPED", $eval["USERS_SKIPPED"]);
03274 switch ($eval["QUESTION_TYPE"])
03275 {
03276 case "qt_ordinal":
03277 switch ($_POST["export_format"])
03278 {
03279 case TYPE_XLS:
03280 case TYPE_XLS_MAC:
03281 preg_match("/(.*?)\s+-\s+(.*)/", $eval["MODE"], $matches);
03282 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode"), $_POST["export_format"]), $format_bold);
03283 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($matches[1], $_POST["export_format"]));
03284 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode_text"), $_POST["export_format"]), $format_bold);
03285 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($matches[2], $_POST["export_format"]));
03286 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode_nr_of_selections"), $_POST["export_format"]), $format_bold);
03287 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($eval["MODE_NR_OF_SELECTIONS"], $_POST["export_format"]));
03288 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("median"), $_POST["export_format"]), $format_bold);
03289 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text(str_replace("<br />", " ", $eval["MEDIAN"]), $_POST["export_format"]));
03290 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("categories"), $_POST["export_format"]), $format_bold);
03291 $worksheet->write($rowcounter, 1, ilExcelUtils::_convert_text($this->lng->txt("title"), $_POST["export_format"]), $format_title);
03292 $worksheet->write($rowcounter, 2, ilExcelUtils::_convert_text($this->lng->txt("value"), $_POST["export_format"]), $format_title);
03293 $worksheet->write($rowcounter, 3, ilExcelUtils::_convert_text($this->lng->txt("category_nr_selected"), $_POST["export_format"]), $format_title);
03294 $worksheet->write($rowcounter++, 4, ilExcelUtils::_convert_text($this->lng->txt("percentage_of_selections"), $_POST["export_format"]), $format_title);
03295 break;
03296 }
03297 $this->tpl->setVariable("TEXT_MODE", $this->lng->txt("mode"));
03298 $this->tpl->setVariable("MODE", $eval["MODE"]);
03299 $this->tpl->setVariable("TEXT_MODE_NR_OF_SELECTIONS", $this->lng->txt("mode_nr_of_selections"));
03300 $this->tpl->setVariable("MODE_NR_OF_SELECTIONS", $eval["MODE_NR_OF_SELECTIONS"]);
03301 $this->tpl->setVariable("TEXT_MEDIAN", $this->lng->txt("median"));
03302 $this->tpl->setVariable("MEDIAN", $eval["MEDIAN"]);
03303 $this->tpl->setVariable("TEXT_CATEGORIES", $this->lng->txt("categories"));
03304 $categories = "";
03305 foreach ($eval["variables"] as $key => $value)
03306 {
03307 $categories .= "<li>" . $this->lng->txt("title") . ":" . "<span class=\"bold\">" . $value["title"] . "</span><br />" .
03308 $this->lng->txt("category_nr_selected") . ": " . "<span class=\"bold\">" . $value["selected"] . "</span><br />" .
03309 $this->lng->txt("percentage_of_selections") . ": " . "<span class=\"bold\">" . sprintf("%.2f", 100*$value["percentage"]) . "</span></li>";
03310 switch ($_POST["export_format"])
03311 {
03312 case TYPE_XLS:
03313 case TYPE_XLS_MAC:
03314 $worksheet->write($rowcounter, 1, ilExcelUtils::_convert_text($value["title"], $_POST["export_format"]));
03315 $worksheet->write($rowcounter, 2, $key+1);
03316 $worksheet->write($rowcounter, 3, ilExcelUtils::_convert_text($value["selected"], $_POST["export_format"]));
03317 $worksheet->write($rowcounter++, 4, ilExcelUtils::_convert_text($value["percentage"], $_POST["export_format"]), $format_percent);
03318 break;
03319 }
03320 }
03321 $categories = "<ol>$categories</ol>";
03322 $this->tpl->setVariable("VALUE_CATEGORIES", $categories);
03323
03324
03325 $this->tpl->setVariable("TEXT_CHART", $this->lng->txt("chart"));
03326 $this->tpl->setVariable("ALT_CHART", $data["title"] . "( " . $this->lng->txt("chart") . ")");
03327 $this->tpl->setVariable("CHART","displaychart.php?grName=" . urlencode($data["title"]) .
03328 "&type=bars" .
03329 "&x=" . urlencode($this->lng->txt("answers")) .
03330 "&y=" . urlencode($this->lng->txt("users_answered")) .
03331 "&arr=".base64_encode(serialize($eval["variables"])));
03332 switch ($_POST["export_format"])
03333 {
03334 case TYPE_PRINT:
03335 array_push($printDetail, $this->lng->txt("mode"));
03336 array_push($printDetail, $eval["MODE"]);
03337 array_push($printDetail, $this->lng->txt("mode_nr_of_selections"));
03338 array_push($printDetail, $eval["MODE_NR_OF_SELECTIONS"]);
03339 array_push($printDetail, $this->lng->txt("median"));
03340 array_push($printDetail, $eval["MEDIAN"]);
03341 array_push($printDetail, $this->lng->txt("categories"));
03342 array_push($printDetail, $categories);
03343 break;
03344 }
03345 break;
03346 case "qt_nominal":
03347 switch ($_POST["export_format"])
03348 {
03349 case TYPE_XLS:
03350 case TYPE_XLS_MAC:
03351 preg_match("/(.*?)\s+-\s+(.*)/", $eval["MODE"], $matches);
03352 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode"), $_POST["export_format"]), $format_bold);
03353 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($matches[1], $_POST["export_format"]));
03354 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode_text"), $_POST["export_format"]), $format_bold);
03355 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($matches[2], $_POST["export_format"]));
03356 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode_nr_of_selections"), $_POST["export_format"]), $format_bold);
03357 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($eval["MODE_NR_OF_SELECTIONS"], $_POST["export_format"]));
03358 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("categories"), $_POST["export_format"]), $format_bold);
03359 $worksheet->write($rowcounter, 1, ilExcelUtils::_convert_text($this->lng->txt("title"), $_POST["export_format"]), $format_title);
03360 $worksheet->write($rowcounter, 2, ilExcelUtils::_convert_text($this->lng->txt("value"), $_POST["export_format"]), $format_title);
03361 $worksheet->write($rowcounter, 3, ilExcelUtils::_convert_text($this->lng->txt("category_nr_selected"), $_POST["export_format"]), $format_title);
03362 $worksheet->write($rowcounter++, 4, ilExcelUtils::_convert_text($this->lng->txt("percentage_of_selections"), $_POST["export_format"]), $format_title);
03363 break;
03364 }
03365 array_push($printDetail, $this->lng->txt("subtype"));
03366 $this->tpl->setVariable("TEXT_QUESTION_SUBTYPE", $this->lng->txt("subtype"));
03367 $charttype = "bars";
03368 switch ($data["subtype"])
03369 {
03370 case SUBTYPE_MCSR:
03371 $this->tpl->setVariable("QUESTION_SUBTYPE", $this->lng->txt("multiple_choice_single_response"));
03372 array_push($printDetail, $this->lng->txt("multiple_choice_single_response"));
03373 break;
03374 case SUBTYPE_MCMR:
03375 $charttype = "pie";
03376 $this->tpl->setVariable("QUESTION_SUBTYPE", $this->lng->txt("multiple_choice_multiple_response"));
03377 array_push($printDetail, $this->lng->txt("multiple_choice_multiple_response"));
03378 break;
03379 }
03380 $this->tpl->setVariable("TEXT_MODE", $this->lng->txt("mode"));
03381 $this->tpl->setVariable("MODE", $eval["MODE"]);
03382 $this->tpl->setVariable("TEXT_MODE_NR_OF_SELECTIONS", $this->lng->txt("mode_nr_of_selections"));
03383 $this->tpl->setVariable("MODE_NR_OF_SELECTIONS", $eval["MODE_NR_OF_SELECTIONS"]);
03384 $this->tpl->setVariable("TEXT_CATEGORIES", $this->lng->txt("categories"));
03385 $categories = "";
03386 foreach ($eval["variables"] as $key => $value)
03387 {
03388 $categories .= "<li>" . $this->lng->txt("title") . ":" . "<span class=\"bold\">" . $value["title"] . "</span><br />" .
03389 $this->lng->txt("category_nr_selected") . ": " . "<span class=\"bold\">" . $value["selected"] . "</span><br />" .
03390 $this->lng->txt("percentage_of_selections") . ": " . "<span class=\"bold\">" . sprintf("%.2f", 100*$value["percentage"]) . "</span></li>";
03391 switch ($_POST["export_format"])
03392 {
03393 case TYPE_XLS:
03394 case TYPE_XLS_MAC:
03395 $worksheet->write($rowcounter, 1, ilExcelUtils::_convert_text($value["title"], $_POST["export_format"]));
03396 $worksheet->write($rowcounter, 2, $key+1);
03397 $worksheet->write($rowcounter, 3, ilExcelUtils::_convert_text($value["selected"], $_POST["export_format"]));
03398 $worksheet->write($rowcounter++, 4, ilExcelUtils::_convert_text($value["percentage"], $_POST["export_format"]), $format_percent);
03399 break;
03400 }
03401 }
03402 $categories = "<ol>$categories</ol>";
03403 $this->tpl->setVariable("VALUE_CATEGORIES", $categories);
03404
03405
03406 $this->tpl->setVariable("TEXT_CHART", $this->lng->txt("chart"));
03407 $this->tpl->setVariable("ALT_CHART", $data["title"] . "( " . $this->lng->txt("chart") . ")");
03408 $this->tpl->setVariable("CHART","displaychart.php?grName=" . urlencode($data["title"]) .
03409 "&type=$charttype" .
03410 "&x=" . urlencode($this->lng->txt("answers")) .
03411 "&y=" . urlencode($this->lng->txt("users_answered")) .
03412 "&arr=".base64_encode(serialize($eval["variables"])));
03413
03414 switch ($_POST["export_format"])
03415 {
03416 case TYPE_PRINT:
03417 array_push($printDetail, $this->lng->txt("mode"));
03418 array_push($printDetail, $eval["MODE"]);
03419 array_push($printDetail, $this->lng->txt("mode_nr_of_selections"));
03420 array_push($printDetail, $eval["MODE_NR_OF_SELECTIONS"]);
03421 array_push($printDetail, $this->lng->txt("categories"));
03422 array_push($printDetail, $categories);
03423 break;
03424 }
03425 break;
03426 case "qt_metric":
03427 switch ($_POST["export_format"])
03428 {
03429 case TYPE_XLS:
03430 case TYPE_XLS_MAC:
03431 $worksheet->write($rowcounter, 0, $this->lng->txt("subtype"), $format_bold);
03432 switch ($data["subtype"])
03433 {
03434 case SUBTYPE_NON_RATIO:
03435 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($this->lng->txt("non_ratio"), $_POST["export_format"]), $format_bold);
03436 break;
03437 case SUBTYPE_RATIO_NON_ABSOLUTE:
03438 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($this->lng->txt("ratio_non_absolute"), $_POST["export_format"]), $format_bold);
03439 break;
03440 case SUBTYPE_RATIO_ABSOLUTE:
03441 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($this->lng->txt("ratio_absolute"), $_POST["export_format"]), $format_bold);
03442 break;
03443 }
03444 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode"), $_POST["export_format"]), $format_bold);
03445 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($eval["MODE"], $_POST["export_format"]));
03446 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode_text"), $_POST["export_format"]), $format_bold);
03447 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($eval["MODE"], $_POST["export_format"]));
03448 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode_nr_of_selections"), $_POST["export_format"]), $format_bold);
03449 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($eval["MODE_NR_OF_SELECTIONS"], $_POST["export_format"]));
03450 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("median"), $_POST["export_format"]), $format_bold);
03451 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($eval["MEDIAN"], $_POST["export_format"]));
03452 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("arithmetic_mean"), $_POST["export_format"]), $format_bold);
03453 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($eval["ARITHMETIC_MEAN"], $_POST["export_format"]));
03454 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("values"), $_POST["export_format"]), $format_bold);
03455 $worksheet->write($rowcounter, 1, ilExcelUtils::_convert_text($this->lng->txt("value"), $_POST["export_format"]), $format_title);
03456 $worksheet->write($rowcounter, 2, ilExcelUtils::_convert_text($this->lng->txt("category_nr_selected"), $_POST["export_format"]), $format_title);
03457 $worksheet->write($rowcounter++, 3, ilExcelUtils::_convert_text($this->lng->txt("percentage_of_selections"), $_POST["export_format"]), $format_title);
03458 break;
03459 }
03460 $this->tpl->setVariable("TEXT_QUESTION_SUBTYPE", $this->lng->txt("subtype"));
03461 array_push($printDetail, $this->lng->txt("subtype"));
03462 switch ($data["subtype"])
03463 {
03464 case SUBTYPE_NON_RATIO:
03465 $this->tpl->setVariable("QUESTION_SUBTYPE", $this->lng->txt("non_ratio"));
03466 array_push($printDetail, $this->lng->txt("non_ratio"));
03467 break;
03468 case SUBTYPE_RATIO_NON_ABSOLUTE:
03469 $this->tpl->setVariable("QUESTION_SUBTYPE", $this->lng->txt("ratio_non_absolute"));
03470 array_push($printDetail, $this->lng->txt("ratio_non_absolute"));
03471 break;
03472 case SUBTYPE_RATIO_ABSOLUTE:
03473 $this->tpl->setVariable("QUESTION_SUBTYPE", $this->lng->txt("ratio_absolute"));
03474 array_push($printDetail, $this->lng->txt("ratio_absolute"));
03475 break;
03476 }
03477 $this->tpl->setVariable("TEXT_MODE", $this->lng->txt("mode"));
03478 $this->tpl->setVariable("MODE", $eval["MODE"]);
03479 $this->tpl->setVariable("TEXT_MODE_NR_OF_SELECTIONS", $this->lng->txt("mode_nr_of_selections"));
03480 $this->tpl->setVariable("MODE_NR_OF_SELECTIONS", $eval["MODE_NR_OF_SELECTIONS"]);
03481 $this->tpl->setVariable("TEXT_MEDIAN", $this->lng->txt("median"));
03482 $this->tpl->setVariable("MEDIAN", $eval["MEDIAN"]);
03483 $this->tpl->setVariable("TEXT_ARITHMETIC_MEAN", $this->lng->txt("arithmetic_mean"));
03484 $this->tpl->setVariable("ARITHMETIC_MEAN", $eval["ARITHMETIC_MEAN"]);
03485 $this->tpl->setVariable("TEXT_VALUES", $this->lng->txt("values"));
03486 $values = "";
03487 if (is_array($eval["values"]))
03488 {
03489 foreach ($eval["values"] as $key => $value)
03490 {
03491 $values .= "<li>" . $this->lng->txt("value") . ": " . "<span class=\"bold\">" . $value["value"] . "</span><br />" .
03492 $this->lng->txt("value_nr_entered") . ": " . "<span class=\"bold\">" . $value["selected"] . "</span><br />" .
03493 $this->lng->txt("percentage_of_entered_values") . ": " . "<span class=\"bold\">" . sprintf("%.2f", 100*$value["percentage"]) . "</span></li>";
03494 switch ($_POST["export_format"])
03495 {
03496 case TYPE_XLS:
03497 case TYPE_XLS_MAC:
03498 $worksheet->write($rowcounter, 1, ilExcelUtils::_convert_text($value["value"], $_POST["export_format"]));
03499 $worksheet->write($rowcounter, 2, ilExcelUtils::_convert_text($value["selected"], $_POST["export_format"]));
03500 $worksheet->write($rowcounter++, 3, ilExcelUtils::_convert_text($value["percentage"], $_POST["export_format"]), $format_percent);
03501 break;
03502 }
03503 }
03504 }
03505 $values = "<ol>$values</ol>";
03506 $this->tpl->setVariable("VALUE_VALUES", $values);
03507
03508 $this->tpl->setVariable("TEXT_CHART", $this->lng->txt("chart"));
03509 $this->tpl->setVariable("ALT_CHART", $data["title"] . "( " . $this->lng->txt("chart") . ")");
03510 $this->tpl->setVariable("CHART","displaychart.php?grName=" . urlencode($data["title"]) .
03511 "&type=bars" .
03512 "&x=" . urlencode($this->lng->txt("answers")) .
03513 "&y=" . urlencode($this->lng->txt("users_answered")) .
03514 "&arr=".base64_encode(serialize($eval["values"])));
03515
03516 switch ($_POST["export_format"])
03517 {
03518 case TYPE_PRINT:
03519 array_push($printDetail, $this->lng->txt("mode"));
03520 array_push($printDetail, $eval["MODE"]);
03521 array_push($printDetail, $this->lng->txt("mode_nr_of_selections"));
03522 array_push($printDetail, $eval["MODE_NR_OF_SELECTIONS"]);
03523 array_push($printDetail, $this->lng->txt("median"));
03524 array_push($printDetail, $eval["MEDIAN"]);
03525 array_push($printDetail, $this->lng->txt("values"));
03526 array_push($printDetail, $values);
03527 break;
03528 }
03529 break;
03530 case "qt_text":
03531 switch ($_POST["export_format"])
03532 {
03533 case TYPE_XLS:
03534 case TYPE_XLS_MAC:
03535 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("given_answers"), $_POST["export_format"]), $format_bold);
03536 break;
03537 }
03538 $this->tpl->setVariable("TEXT_TEXTVALUES", $this->lng->txt("given_answers"));
03539 $textvalues = "";
03540 if (is_array($eval["textvalues"]))
03541 {
03542 foreach ($eval["textvalues"] as $textvalue)
03543 {
03544 $textvalues .= "<li>" . preg_replace("/\n/", "<br>", $textvalue) . "</li>";
03545 switch ($_POST["export_format"])
03546 {
03547 case TYPE_XLS:
03548 case TYPE_XLS_MAC:
03549 $worksheet->write($rowcounter++, 1, $textvalue);
03550 break;
03551 }
03552 }
03553 }
03554 $textvalues = "<ul>$textvalues</ul>";
03555 $this->tpl->setVariable("VALUE_TEXTVALUES", $textvalues);
03556 switch ($_POST["export_format"])
03557 {
03558 case TYPE_PRINT:
03559 array_push($printDetail, $this->lng->txt("given_answers"));
03560 array_push($printDetail, $textvalues);
03561 break;
03562 }
03563 break;
03564 }
03565
03566 if ($_POST["export_format"]==TYPE_PRINT)
03567 {
03568 $printdetail_file = array();
03569 array_push($printdetail_file, $printDetail);
03570 $s_question = $counter+1;
03571 $_SESSION[$this->lng->txt("question").$s_question] = $printdetail_file;
03572 $this->tpl->setVariable("PRINT_ACTION", $this->getCallingScript() . "?ref_id=" . $_GET["ref_id"] . "&cmd=printEvaluation&".$this->lng->txt("question")."=".$s_question);
03573 $this->tpl->setVariable("PRINT_TEXT", $this->lng->txt("print"));
03574 $this->tpl->setVariable("PRINT_IMAGE", ilUtil::getImagePath("icon_print.gif"));
03575 }
03576 $this->tpl->parseCurrentBlock();
03577 }
03578 $counter++;
03579 }
03580 if ($_POST["export_format"]==TYPE_PRINT)
03581 {
03582 $_SESSION["print_eval"] = $csvfile;
03583 }
03584
03585
03586 switch ($_POST["export_format"])
03587 {
03588 case TYPE_XLS:
03589 case TYPE_XLS_MAC:
03590
03591 $workbook->close();
03592 exit();
03593 break;
03594 case TYPE_SPSS:
03595 $csv = "";
03596 $separator = ";";
03597 foreach ($csvfile as $csvrow)
03598 {
03599 $csvrow =& $this->object->processCSVRow($csvrow, TRUE, $separator);
03600 $csv .= join($csvrow, $separator) . "\n";
03601 }
03602 ilUtil::deliverData($csv, "$surveyname.csv");
03603 exit();
03604 break;
03605 }
03606 $this->tpl->setCurrentBlock("generic_css");
03607 $this->tpl->setVariable("LOCATION_GENERIC_STYLESHEET", "./templates/default/evaluation_print.css");
03608 $this->tpl->setVariable("MEDIA_GENERIC_STYLESHEET", "print");
03609 $this->tpl->parseCurrentBlock();
03610 $this->tpl->setCurrentBlock("adm_content");
03611 $this->tpl->setVariable("QUESTION_TITLE", $this->lng->txt("title"));
03612 $this->tpl->setVariable("QUESTION_TEXT", $this->lng->txt("question"));
03613 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("question_type"));
03614 $this->tpl->setVariable("USERS_ANSWERED", $this->lng->txt("users_answered"));
03615 $this->tpl->setVariable("USERS_SKIPPED", $this->lng->txt("users_skipped"));
03616 $this->tpl->setVariable("MODE", $this->lng->txt("mode"));
03617 $this->tpl->setVariable("MODE_NR_OF_SELECTIONS", $this->lng->txt("mode_nr_of_selections"));
03618 $this->tpl->setVariable("MEDIAN", $this->lng->txt("median"));
03619 $this->tpl->setVariable("ARITHMETIC_MEAN", $this->lng->txt("arithmetic_mean"));
03620 $this->tpl->setVariable("EXPORT_DATA", $this->lng->txt("export_data_as"));
03621 $this->tpl->setVariable("TEXT_EXCEL", $this->lng->txt("exp_type_excel"));
03622 $this->tpl->setVariable("TEXT_EXCEL_MAC", $this->lng->txt("exp_type_excel_mac"));
03623 $this->tpl->setVariable("TEXT_CSV", $this->lng->txt("exp_type_csv"));
03624 $this->tpl->setVariable("VALUE_DETAIL", $details);
03625 $this->tpl->setVariable("BTN_EXPORT", $this->lng->txt("export"));
03626 $this->tpl->setVariable("BTN_PRINT", $this->lng->txt("print"));
03627 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
03628 $this->tpl->setVariable("PRINT_ACTION", $this->ctrl->getFormAction($this));
03629 if ($details)
03630 {
03631 $this->tpl->setVariable("CMD_EXPORT", "evaluationdetails");
03632 }
03633 else
03634 {
03635 $this->tpl->setVariable("CMD_EXPORT", "evaluation");
03636 }
03637 $this->tpl->parseCurrentBlock();
03638 }
03639
03647 function writeInviteFormData()
03648 {
03649 global $ilUser;
03650
03651 $message = "";
03652 $this->object->setInvitationAndMode($_POST["invitation"], $_POST["mode"]);
03653 if ($_POST["cmd"]["disinvite"])
03654 {
03655
03656 if (is_array($_POST["invited_users"]))
03657 {
03658 foreach ($_POST["invited_users"] as $user_id)
03659 {
03660 $this->object->disinviteUser($user_id);
03661 }
03662 }
03663 }
03664
03665 if ($_POST["cmd"]["add"])
03666 {
03667
03668 if (is_array($_POST["user_select"]))
03669 {
03670 foreach ($_POST["user_select"] as $user_id)
03671 {
03672 $this->object->inviteUser($user_id);
03673 }
03674 }
03675
03676 if (is_array($_POST["group_select"]))
03677 {
03678 foreach ($_POST["group_select"] as $group_id)
03679 {
03680 $this->object->inviteGroup($group_id);
03681 }
03682 }
03683
03684 if (is_array($_POST["role_select"]))
03685 {
03686 foreach ($_POST["role_select"] as $role_id)
03687 {
03688 $this->object->inviteRole($role_id);
03689 }
03690 }
03691 }
03692
03693 if ($_POST["cmd"]["search"])
03694 {
03695 if (is_array($_POST["search_for"]))
03696 {
03697 if (in_array("usr", $_POST["search_for"]) or in_array("grp", $_POST["search_for"]) or in_array("role", $_POST["search_for"]))
03698 {
03699 $search =& new ilSearch($ilUser->id);
03700 $search->setSearchString($_POST["search_term"]);
03701 $search->setCombination($_POST["concatenation"]);
03702 $search->setSearchFor($_POST["search_for"]);
03703 $search->setSearchType("new");
03704 if($search->validate($message))
03705 {
03706 $search->performSearch();
03707 }
03708 if ($message)
03709 {
03710 sendInfo($message);
03711 }
03712 if(!$search->getNumberOfResults() && $search->getSearchFor())
03713 {
03714 sendInfo($this->lng->txt("search_no_match"));
03715 return;
03716 }
03717 $buttons = array("add");
03718 $invited_users = $this->object->getInvitedUsers();
03719 if ($searchresult = $search->getResultByType("usr"))
03720 {
03721 $users = array();
03722 foreach ($searchresult as $result_array)
03723 {
03724 if (!in_array($result_array["id"], $invited_users))
03725 {
03726 array_push($users, $result_array["id"]);
03727 }
03728 }
03729 $this->outUserGroupTable("usr", $users, "user_result", "user_row", $this->lng->txt("search_user"), $buttons);
03730 }
03731 $searchresult = array();
03732 $invited_groups = array();
03733 if ($searchresult = $search->getResultByType("grp"))
03734 {
03735 $groups = array();
03736 foreach ($searchresult as $result_array)
03737 {
03738 array_push($groups, $result_array["id"]);
03739 }
03740 $this->outUserGroupTable("grp", $groups, "group_result", "group_row", $this->lng->txt("search_group"), $buttons);
03741 }
03742 $searchresult = array();
03743 $invited_roles = array();
03744 if ($searchresult = $search->getResultByType("role"))
03745 {
03746 $roles = array();
03747 foreach ($searchresult as $result_array)
03748 {
03749 array_push($roles, $result_array["id"]);
03750 }
03751 $this->outUserGroupTable("role", $roles, "role_result", "role_row", $this->lng->txt("search_roles"), $buttons);
03752 }
03753 }
03754 }
03755 else
03756 {
03757 sendInfo($this->lng->txt("no_user_or_group_selected"));
03758 }
03759 }
03760 }
03761
03769 function outUserGroupTable($a_type, $id_array, $block_result, $block_row, $title_text, $buttons)
03770 {
03771 global $rbacsystem;
03772
03773 $rowclass = array("tblrow1", "tblrow2");
03774 switch($a_type)
03775 {
03776 case "usr":
03777 foreach ($id_array as $user_id)
03778 {
03779 $counter = 0;
03780 $user = new ilObjUser($user_id);
03781 $this->tpl->setCurrentBlock($block_row);
03782 $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
03783 $this->tpl->setVariable("COUNTER", $user->getId());
03784 $this->tpl->setVariable("VALUE_LOGIN", $user->getLogin());
03785 $this->tpl->setVariable("VALUE_FIRSTNAME", $user->getFirstname());
03786 $this->tpl->setVariable("VALUE_LASTNAME", $user->getLastname());
03787 $counter++;
03788 $this->tpl->parseCurrentBlock();
03789 }
03790 $this->tpl->setCurrentBlock($block_result);
03791 $this->tpl->setVariable("TEXT_USER_TITLE", "<img src=\"" . ilUtil::getImagePath("icon_usr_b.gif") . "\" alt=\"\" /> " . $title_text);
03792 $this->tpl->setVariable("TEXT_LOGIN", $this->lng->txt("login"));
03793 $this->tpl->setVariable("TEXT_FIRSTNAME", $this->lng->txt("firstname"));
03794 $this->tpl->setVariable("TEXT_LASTNAME", $this->lng->txt("lastname"));
03795 if ($rbacsystem->checkAccess('invite', $this->object->getRefId()))
03796 {
03797 foreach ($buttons as $cat)
03798 {
03799 $this->tpl->setVariable("VALUE_" . strtoupper($cat), $this->lng->txt($cat));
03800 }
03801 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"\">");
03802 }
03803 $this->tpl->parseCurrentBlock();
03804 break;
03805 case "grp":
03806 foreach ($id_array as $group_id)
03807 {
03808 $counter = 0;
03809 $group = new ilObjGroup($group_id);
03810 $this->tpl->setCurrentBlock($block_row);
03811 $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
03812 $this->tpl->setVariable("COUNTER", $group->getRefId());
03813 $this->tpl->setVariable("VALUE_TITLE", $group->getTitle());
03814 $this->tpl->setVariable("VALUE_DESCRIPTION", $group->getDescription());
03815 $counter++;
03816 $this->tpl->parseCurrentBlock();
03817 }
03818 $this->tpl->setCurrentBlock($block_result);
03819 $this->tpl->setVariable("TEXT_GROUP_TITLE", "<img src=\"" . ilUtil::getImagePath("icon_grp_b.gif") . "\" alt=\"\" /> " . $title_text);
03820 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
03821 $this->tpl->setVariable("TEXT_DESCRIPTION", $this->lng->txt("description"));
03822 if ($rbacsystem->checkAccess('invite', $this->object->getRefId()))
03823 {
03824 foreach ($buttons as $cat)
03825 {
03826 $this->tpl->setVariable("VALUE_" . strtoupper($cat), $this->lng->txt($cat));
03827 }
03828 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"\">");
03829 }
03830 $this->tpl->parseCurrentBlock();
03831 break;
03832 case "role":
03833 foreach ($id_array as $role_id)
03834 {
03835 $counter = 0;
03836 $role = new ilObjRole($role_id);
03837 $this->tpl->setCurrentBlock($block_row);
03838 $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
03839 $this->tpl->setVariable("COUNTER", $role->getId());
03840 $this->tpl->setVariable("VALUE_TITLE", $role->getTitle());
03841 $this->tpl->setVariable("VALUE_DESCRIPTION", $role->getDescription());
03842 $counter++;
03843 $this->tpl->parseCurrentBlock();
03844 }
03845 $this->tpl->setCurrentBlock($block_result);
03846 $this->tpl->setVariable("TEXT_ROLE_TITLE", "<img src=\"" . ilUtil::getImagePath("icon_role_b.gif") . "\" alt=\"\" /> " . $title_text);
03847 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
03848 $this->tpl->setVariable("TEXT_DESCRIPTION", $this->lng->txt("description"));
03849 if ($rbacsystem->checkAccess('invite', $this->object->getRefId()))
03850 {
03851 foreach ($buttons as $cat)
03852 {
03853 $this->tpl->setVariable("VALUE_" . strtoupper($cat), $this->lng->txt($cat));
03854 }
03855 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"\">");
03856 }
03857 $this->tpl->parseCurrentBlock();
03858 break;
03859 }
03860 }
03861
03869 function inviteObject()
03870 {
03871 global $rbacsystem;
03872
03873 if ((!$rbacsystem->checkAccess("read", $this->ref_id)) && (!$rbacsystem->checkAccess("write", $this->ref_id)))
03874 {
03875
03876 sendInfo($this->lng->txt("cannot_edit_survey"), true);
03877 $path = $this->tree->getPathFull($this->object->getRefID());
03878 ilUtil::redirect($this->getReturnLocation("cancel","../repository.php?cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
03879 return;
03880 }
03881 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_invite.html", true);
03882
03883 if ($this->object->getStatus() == STATUS_OFFLINE)
03884 {
03885 $this->tpl->setCurrentBlock("survey_offline");
03886 $this->tpl->setVariable("SURVEY_OFFLINE_MESSAGE", $this->lng->txt("survey_offline_message"));
03887 $this->tpl->parseCurrentBlock();
03888 return;
03889 }
03890 if ($_POST["cmd"]["cancel"])
03891 {
03892 $path = $this->tree->getPathFull($this->object->getRefID());
03893 ilUtil::redirect($this->getReturnLocation("cancel",ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH)."/repository.php?cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
03894 exit();
03895 }
03896 if (count($_POST))
03897 {
03898 $this->writeInviteFormData();
03899 }
03900 if ($_POST["cmd"]["save"])
03901 {
03902 $this->object->saveToDb();
03903 }
03904 if (($this->object->getInvitationMode() == MODE_PREDEFINED_USERS) and ($this->object->getInvitation() == INVITATION_ON))
03905 {
03906 if ($rbacsystem->checkAccess('invite', $this->ref_id))
03907 {
03908 $this->tpl->setCurrentBlock("invitation");
03909 $this->tpl->setVariable("SEARCH_INVITATION", $this->lng->txt("search_invitation"));
03910 $this->tpl->setVariable("SEARCH_TERM", $this->lng->txt("search_term"));
03911 $this->tpl->setVariable("SEARCH_FOR", $this->lng->txt("search_for"));
03912 $this->tpl->setVariable("SEARCH_USERS", $this->lng->txt("search_users"));
03913 $this->tpl->setVariable("SEARCH_GROUPS", $this->lng->txt("search_groups"));
03914 $this->tpl->setVariable("SEARCH_ROLES", $this->lng->txt("search_roles"));
03915 $this->tpl->setVariable("TEXT_CONCATENATION", $this->lng->txt("concatenation"));
03916 $this->tpl->setVariable("TEXT_AND", $this->lng->txt("and"));
03917 $this->tpl->setVariable("TEXT_OR", $this->lng->txt("or"));
03918 $this->tpl->setVariable("VALUE_SEARCH_TERM", $_POST["search_term"]);
03919 if (is_array($_POST["search_for"]))
03920 {
03921 if (in_array("usr", $_POST["search_for"]))
03922 {
03923 $this->tpl->setVariable("CHECKED_USERS", " checked=\"checked\"");
03924 }
03925 if (in_array("grp", $_POST["search_for"]))
03926 {
03927 $this->tpl->setVariable("CHECKED_GROUPS", " checked=\"checked\"");
03928 }
03929 if (in_array("role", $_POST["search_for"]))
03930 {
03931 $this->tpl->setVariable("CHECKED_ROLES", " checked=\"checked\"");
03932 }
03933 }
03934 if (strcmp($_POST["concatenation"], "and") == 0)
03935 {
03936 $this->tpl->setVariable("CHECKED_AND", " checked=\"checked\"");
03937 }
03938 else if (strcmp($_POST["concatenation"], "or") == 0)
03939 {
03940 $this->tpl->setVariable("CHECKED_OR", " checked=\"checked\"");
03941 }
03942 $this->tpl->setVariable("SEARCH", $this->lng->txt("search"));
03943 $this->tpl->parseCurrentBlock();
03944 }
03945 }
03946 if ($this->object->getInvitationMode() == MODE_PREDEFINED_USERS)
03947 {
03948 $invited_users = $this->object->getInvitedUsers();
03949 $buttons = array("disinvite");
03950 if (count($invited_users))
03951 {
03952 $this->outUserGroupTable("usr", $invited_users, "invited_user_result", "invited_user_row", $this->lng->txt("invited_users"), $buttons);
03953 }
03954 }
03955 if ($this->object->getInvitation() == INVITATION_ON)
03956 {
03957 $this->tpl->setCurrentBlock("invitation_mode");
03958 $this->tpl->setVariable("TEXT_MODE", $this->lng->txt("invitation_mode"));
03959 $this->tpl->setVariable("VALUE_UNLIMITED", $this->lng->txt("unlimited_users"));
03960 $this->tpl->setVariable("VALUE_PREDEFINED", $this->lng->txt("predefined_users"));
03961 if ($this->object->getInvitationMode() == MODE_PREDEFINED_USERS)
03962 {
03963 $this->tpl->setVariable("SELECTED_PREDEFINED", " selected=\"selected\"");
03964 }
03965 else
03966 {
03967 $this->tpl->setVariable("SELECTED_UNLIMITED", " selected=\"selected\"");
03968 }
03969 $this->tpl->parseCurrentBlock();
03970 }
03971 $this->tpl->setCurrentBlock("adm_content");
03972 $this->tpl->setVariable("TEXT_INVITATION", $this->lng->txt("invitation"));
03973 $this->tpl->setVariable("VALUE_ON", $this->lng->txt("on"));
03974 $this->tpl->setVariable("VALUE_OFF", $this->lng->txt("off"));
03975 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
03976 if ($this->object->getInvitation() == INVITATION_ON)
03977 {
03978 $this->tpl->setVariable("SELECTED_ON", " selected=\"selected\"");
03979 }
03980 else
03981 {
03982 $this->tpl->setVariable("SELECTED_OFF", " selected=\"selected\"");
03983 }
03984 if ($rbacsystem->checkAccess("write", $this->ref_id) or $rbacsystem->checkAccess('invite', $this->ref_id)) {
03985 $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
03986 $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
03987 }
03988 $this->tpl->parseCurrentBlock();
03989 }
03990
03998 function deleteAllUserDataObject()
03999 {
04000 sendInfo($this->lng->txt("confirm_delete_all_user_data"));
04001 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_maintenance.html", true);
04002 $this->tpl->setCurrentBlock("confirm_delete");
04003 $this->tpl->setVariable("BTN_CONFIRM_DELETE_ALL", $this->lng->txt("confirm"));
04004 $this->tpl->setVariable("BTN_CANCEL_DELETE_ALL", $this->lng->txt("cancel"));
04005 $this->tpl->parseCurrentBlock();
04006 $this->tpl->setCurrentBlock("adm_content");
04007 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
04008 $this->tpl->parseCurrentBlock();
04009 }
04010
04018 function confirmDeleteAllUserDataObject()
04019 {
04020 $this->object->deleteAllUserData();
04021 sendInfo($this->lng->txt("svy_all_user_data_deleted"), true);
04022 $this->ctrl->redirect($this, "maintenance");
04023 }
04024
04032 function cancelDeleteAllUserDataObject()
04033 {
04034 $this->ctrl->redirect($this, "maintenance");
04035 }
04036
04044 function maintenanceObject()
04045 {
04046 global $rbacsystem;
04047
04048 if ((!$rbacsystem->checkAccess("read", $this->ref_id)) && (!$rbacsystem->checkAccess("write", $this->ref_id)))
04049 {
04050
04051 sendInfo($this->lng->txt("cannot_edit_survey"), true);
04052 $path = $this->tree->getPathFull($this->object->getRefID());
04053 ilUtil::redirect($this->getReturnLocation("cancel","../repository.php?cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
04054 return;
04055 }
04056
04057 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_maintenance.html", true);
04058
04059 if ($rbacsystem->checkAccess("write", $this->ref_id))
04060 {
04061 $this->tpl->setCurrentBlock("delete_button");
04062 $this->tpl->setVariable("BTN_DELETE_ALL", $this->lng->txt("svy_delete_all_user_data"));
04063 $this->tpl->parseCurrentBlock();
04064 $this->tpl->setCurrentBlock("adm_content");
04065 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
04066 $this->tpl->parseCurrentBlock();
04067 }
04068 else
04069 {
04070 sendInfo($this->lng->txt("cannot_maintain_survey"));
04071 }
04072 }
04073
04081 function statusObject()
04082 {
04083 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_status.html", true);
04084 if (!$this->object->isComplete())
04085 {
04086 if (count($this->object->questions) == 0)
04087 {
04088 $this->tpl->setCurrentBlock("list_element");
04089 $this->tpl->setVariable("TEXT_ELEMENT", $this->lng->txt("svy_missing_questions"));
04090 $this->tpl->parseCurrentBlock();
04091 }
04092 if (strcmp($this->object->author, "") == 0)
04093 {
04094 $this->tpl->setCurrentBlock("list_element");
04095 $this->tpl->setVariable("TEXT_ELEMENT", $this->lng->txt("svy_missing_author"));
04096 $this->tpl->parseCurrentBlock();
04097 }
04098 if (strcmp($this->object->title, "") == 0)
04099 {
04100 $this->tpl->setCurrentBlock("list_element");
04101 $this->tpl->setVariable("TEXT_ELEMENT", $this->lng->txt("svy_missing_author"));
04102 $this->tpl->parseCurrentBlock();
04103 }
04104 $this->tpl->setCurrentBlock("status_list");
04105 $this->tpl->setVariable("TEXT_MISSING_ELEMENTS", $this->lng->txt("svy_status_missing_elements"));
04106 $this->tpl->parseCurrentBlock();
04107 }
04108 $this->tpl->setCurrentBlock("adm_content");
04109 if ($this->object->isComplete())
04110 {
04111 $this->tpl->setVariable("TEXT_STATUS_MESSAGE", $this->lng->txt("svy_status_ok"));
04112 $this->tpl->setVariable("STATUS_CLASS", "bold");
04113 }
04114 else
04115 {
04116 $this->tpl->setVariable("TEXT_STATUS_MESSAGE", $this->lng->txt("svy_status_missing"));
04117 $this->tpl->setVariable("STATUS_CLASS", "warning");
04118 }
04119 $this->tpl->parseCurrentBlock();
04120 }
04121
04130 function setLocator($a_tree = "", $a_id = "", $scriptname="repository.php")
04131 {
04132
04133 $ilias_locator = new ilLocatorGUI(false);
04134 if (!is_object($a_tree))
04135 {
04136 $a_tree =& $this->tree;
04137 }
04138 if (!($a_id))
04139 {
04140 $a_id = $_GET["ref_id"];
04141 }
04142
04143
04144
04145 $path = $a_tree->getPathFull($a_id);
04146
04147
04148 if ($a_parent_parent)
04149 {
04150
04151 $subObj =& $this->ilias->obj_factory->getInstanceByRefId($a_ref_id);
04152
04153 $path[] = array(
04154 "id" => $a_ref_id,
04155 "title" => $this->lng->txt($subObj->getTitle())
04156 );
04157 }
04158
04159
04160 $modifier = 1;
04161
04162 if (isset($_GET["obj_id"]))
04163 {
04164 $modifier = 0;
04165 }
04166
04167
04168 $i = 1;
04169 if (!defined("ILIAS_MODULE")) {
04170 foreach ($path as $key => $row)
04171 {
04172 $ilias_locator->navigate($i++, $row["title"], ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/adm_object.php?ref_id=".$row["child"],"");
04173 }
04174 } else {
04175 foreach ($path as $key => $row)
04176 {
04177 if (strcmp($row["title"], "ILIAS") == 0) {
04178 $row["title"] = $this->lng->txt("repository");
04179 }
04180 if ($this->ref_id == $row["child"]) {
04181 if ($_GET["cmd"]) {
04182 $param = "&cmd=" . $_GET["cmd"];
04183 } else {
04184 $param = "";
04185 }
04186 $ilias_locator->navigate($i++, $row["title"], ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/survey/survey.php" . "?ref_id=".$row["child"] . $param,"target=\"bottom\"");
04187 } else {
04188 $ilias_locator->navigate($i++, $row["title"], ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/" . $scriptname."?cmd=frameset&ref_id=".$row["child"],"target=\"bottom\"");
04189 }
04190 }
04191
04192 if (isset($_GET["obj_id"]))
04193 {
04194 $obj_data =& $this->ilias->obj_factory->getInstanceByObjId($_GET["obj_id"]);
04195 $ilias_locator->navigate($i++,$obj_data->getTitle(),$scriptname."?cmd=frameset&ref_id=".$_GET["ref_id"]."&obj_id=".$_GET["obj_id"],"target=\"bottom\"");
04196 }
04197 }
04198 $ilias_locator->output();
04199 }
04200
04201
04202
04203
04204
04205
04206
04207
04208
04209
04210
04211
04212
04213
04214
04215
04216
04217
04218
04219
04220
04221
04222
04223
04224
04225
04226
04227
04228
04229
04230
04231
04232
04233
04234
04235
04236
04237
04238
04239
04240
04241
04242
04243
04244
04245
04246
04247
04248
04249
04250
04251
04252
04253
04254
04255
04256
04257
04258
04259
04260
04261
04262
04263
04264
04265
04266
04267
04268
04269
04270
04271
04272
04273
04274
04275
04276
04277
04278
04279
04280
04281
04282
04283
04284
04285
04286
04287
04288
04289
04290
04291
04292
04293
04294
04295
04296
04297 function prepareOutput()
04298 {
04299 $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
04300 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
04301 $title = $this->object->getTitle();
04302
04303 sendInfo();
04304
04305 if (!empty($title))
04306 {
04307 $this->tpl->setVariable("HEADER", $title);
04308 }
04309 if (!defined("ILIAS_MODULE"))
04310 {
04311 $this->setAdminTabs($_POST["new_type"]);
04312 }
04313 $this->setLocator();
04314
04315 }
04316
04317
04318
04319
04320 function exportObject()
04321 {
04322 global $tree;
04323 global $rbacsystem;
04324
04325 if ((!$rbacsystem->checkAccess("read", $this->ref_id)) && (!$rbacsystem->checkAccess("write", $this->ref_id)))
04326 {
04327
04328 sendInfo($this->lng->txt("cannot_edit_survey"), true);
04329 $path = $this->tree->getPathFull($this->object->getRefID());
04330 ilUtil::redirect($this->getReturnLocation("cancel","../repository.php?ref_id=" . $path[count($path) - 2]["child"]));
04331 return;
04332 }
04333
04334
04335
04336
04337 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
04338
04339
04340 $this->tpl->setCurrentBlock("btn_cell");
04341 $this->tpl->setVariable("BTN_LINK", "survey.php?ref_id=".$_GET["ref_id"]."&cmd=createExportFile");
04342 $this->tpl->setVariable("BTN_TXT", $this->lng->txt("svy_create_export_file"));
04343 $this->tpl->parseCurrentBlock();
04344
04345 $export_dir = $this->object->getExportDirectory();
04346 $export_files = $this->object->getExportFiles($export_dir);
04347
04348
04349 require_once("classes/class.ilTableGUI.php");
04350 $tbl = new ilTableGUI();
04351
04352
04353 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
04354
04355
04356 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.export_file_row.html", true);
04357
04358 $num = 0;
04359
04360 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
04361
04362 $tbl->setTitle($this->lng->txt("svy_export_files"));
04363
04364 $tbl->setHeaderNames(array("<input type=\"checkbox\" name=\"chb_check_all\" value=\"1\" onclick=\"setCheckboxes('ObjectItems', 'file', document.ObjectItems.chb_check_all.checked);\" />", $this->lng->txt("svy_file"),
04365 $this->lng->txt("svy_size"), $this->lng->txt("date") ));
04366
04367 $tbl->enabled["sort"] = false;
04368 $tbl->setColumnWidth(array("1%", "49%", "25%", "25%"));
04369
04370
04371 $tbl->setOrderColumn($_GET["sort_by"]);
04372 $tbl->setOrderDirection($_GET["sort_order"]);
04373 $tbl->setLimit($_GET["limit"]);
04374 $tbl->setOffset($_GET["offset"]);
04375 $tbl->setMaxCount($this->maxcount);
04376
04377 $this->tpl->setVariable("COLUMN_COUNTS", 4);
04378
04379
04380 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
04381 $this->tpl->setCurrentBlock("tbl_action_btn");
04382 $this->tpl->setVariable("BTN_NAME", "confirmDeleteExportFile");
04383 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
04384 $this->tpl->parseCurrentBlock();
04385
04386 $this->tpl->setCurrentBlock("tbl_action_btn");
04387 $this->tpl->setVariable("BTN_NAME", "downloadExportFile");
04388 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("download"));
04389 $this->tpl->parseCurrentBlock();
04390
04391
04392 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
04393
04394
04395 $tbl->setMaxCount(count($export_files));
04396 $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
04397
04398 $tbl->render();
04399 if(count($export_files) > 0)
04400 {
04401 $i=0;
04402 foreach($export_files as $exp_file)
04403 {
04404 $this->tpl->setCurrentBlock("tbl_content");
04405 $this->tpl->setVariable("TXT_FILENAME", $exp_file);
04406
04407 $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
04408 $this->tpl->setVariable("CSS_ROW", $css_row);
04409
04410 $this->tpl->setVariable("TXT_SIZE", filesize($export_dir."/".$exp_file));
04411 $this->tpl->setVariable("CHECKBOX_ID", $exp_file);
04412
04413 $file_arr = explode("__", $exp_file);
04414 $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s",$file_arr[0]));
04415
04416 $this->tpl->parseCurrentBlock();
04417 }
04418 }
04419 else
04420 {
04421 $this->tpl->setCurrentBlock("notfound");
04422 $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
04423 $this->tpl->setVariable("NUM_COLS", 3);
04424 $this->tpl->parseCurrentBlock();
04425 }
04426
04427 $this->tpl->parseCurrentBlock();
04428 }
04429
04433 function createExportFileObject()
04434 {
04435 global $rbacsystem;
04436
04437 if ($rbacsystem->checkAccess("write", $this->ref_id))
04438 {
04439 require_once("./survey/classes/class.ilSurveyExport.php");
04440 $survey_exp = new ilSurveyExport($this->object);
04441 $survey_exp->buildExportFile();
04442 ilUtil::redirect("survey.php?cmd=export&ref_id=".$_GET["ref_id"]);
04443 }
04444 else
04445 {
04446 sendInfo("cannot_export_survey");
04447 }
04448 }
04449
04455 function importObject()
04456 {
04457 $this->getTemplateFile("import", "svy");
04458 $this->tpl->setCurrentBlock("option_qpl");
04459 require_once("./survey/classes/class.ilObjSurvey.php");
04460 $svy = new ilObjSurvey();
04461 $questionpools =& $svy->getAvailableQuestionpools(true);
04462 if (count($questionpools) == 0)
04463 {
04464 }
04465 else
04466 {
04467 foreach ($questionpools as $key => $value)
04468 {
04469 $this->tpl->setCurrentBlock("option_spl");
04470 $this->tpl->setVariable("OPTION_VALUE", $key);
04471 $this->tpl->setVariable("TXT_OPTION", $value);
04472 $this->tpl->parseCurrentBlock();
04473 }
04474 }
04475 $this->tpl->setVariable("TXT_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool"));
04476 $this->tpl->setVariable("OPTION_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool_option"));
04477 $this->tpl->setVariable("FORMACTION", "adm_object.php?&ref_id=".$_GET["ref_id"]."&cmd=gateway&new_type=".$this->type);
04478 $this->tpl->setVariable("BTN_NAME", "upload");
04479 $this->tpl->setVariable("TXT_UPLOAD", $this->lng->txt("upload"));
04480 $this->tpl->setVariable("TXT_IMPORT_TST", $this->lng->txt("import_tst"));
04481 $this->tpl->setVariable("TXT_SELECT_MODE", $this->lng->txt("select_mode"));
04482 $this->tpl->setVariable("TXT_SELECT_FILE", $this->lng->txt("select_file"));
04483
04484 }
04485
04492 function uploadObject($redirect = true)
04493 {
04494 if ($_POST["spl"] < 1)
04495 {
04496 sendInfo($this->lng->txt("svy_select_questionpools"));
04497 $this->importObject();
04498 return;
04499 }
04500 if (strcmp($_FILES["xmldoc"]["tmp_name"], "") == 0)
04501 {
04502 sendInfo($this->lng->txt("svy_select_file_for_import"));
04503 $this->importObject();
04504 return;
04505 }
04506 include_once("./survey/classes/class.ilObjSurvey.php");
04507 $newObj = new ilObjSurvey();
04508 $newObj->setType($_GET["new_type"]);
04509 $newObj->setTitle("dummy");
04510 $newObj->setDescription("dummy");
04511 $newObj->create(true);
04512 $newObj->createReference();
04513 $newObj->putInTree($_GET["ref_id"]);
04514 $newObj->setPermissions($_GET["ref_id"]);
04515 $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
04516
04517
04518 $newObj->importObject($_FILES["xmldoc"], $_POST["spl"]);
04519
04520
04521
04522
04523
04524
04525
04526
04527
04528
04529
04530
04531
04532 $newObj->update();
04533 $newObj->saveToDb();
04534 if ($redirect)
04535 {
04536 ilUtil::redirect($this->getReturnLocation("upload",$this->ctrl->getTargetScript()."?".$this->link_params));
04537 }
04538 }
04539
04543 function createObject()
04544 {
04545 global $rbacsystem;
04546 $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
04547 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
04548 {
04549 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
04550 }
04551 else
04552 {
04553 $this->getTemplateFile("create", $new_type);
04554
04555 require_once("./survey/classes/class.ilObjSurvey.php");
04556 $svy = new ilObjSurvey();
04557
04558 $surveys =& ilObjSurvey::_getAvailableSurveys(true);
04559 if (count($surveys) > 0)
04560 {
04561 foreach ($surveys as $key => $value)
04562 {
04563 $this->tpl->setCurrentBlock("option_svy");
04564 $this->tpl->setVariable("OPTION_VALUE_SVY", $key);
04565 $this->tpl->setVariable("TXT_OPTION_SVY", $value);
04566 if ($_POST["svy"] == $key)
04567 {
04568 $this->tpl->setVariable("OPTION_SELECTED_SVY", " selected=\"selected\"");
04569 }
04570 $this->tpl->parseCurrentBlock();
04571 }
04572 }
04573
04574 $questionpools =& $svy->getAvailableQuestionpools(true);
04575 if (count($questionpools) > 0)
04576 {
04577 foreach ($questionpools as $key => $value)
04578 {
04579 $this->tpl->setCurrentBlock("option_spl");
04580 $this->tpl->setVariable("OPTION_VALUE", $key);
04581 $this->tpl->setVariable("TXT_OPTION", $value);
04582 if ($_POST["spl"] == $key)
04583 {
04584 $this->tpl->setVariable("OPTION_SELECTED", " selected=\"selected\"");
04585 }
04586 $this->tpl->parseCurrentBlock();
04587 }
04588 }
04589
04590 $data = array();
04591 $data["fields"] = array();
04592 $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
04593 $data["fields"]["desc"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["desc"]);
04594
04595 foreach ($data["fields"] as $key => $val)
04596 {
04597 $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
04598 $this->tpl->setVariable(strtoupper($key), $val);
04599
04600 if ($this->prepare_output)
04601 {
04602 $this->tpl->parseCurrentBlock();
04603 }
04604 }
04605
04606 $this->tpl->setVariable("FORMACTION", $this->getFormAction("save","adm_object.php?cmd=gateway&ref_id=".
04607 $_GET["ref_id"]."&new_type=".$new_type));
04608 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
04609 $this->tpl->setVariable("TXT_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool_short"));
04610 $this->tpl->setVariable("OPTION_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool_option"));
04611 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
04612 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
04613 $this->tpl->setVariable("CMD_SUBMIT", "save");
04614 $this->tpl->setVariable("TARGET", $this->getTargetFrame("save"));
04615 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
04616
04617 $this->tpl->setVariable("TXT_IMPORT_SVY", $this->lng->txt("import_svy"));
04618 $this->tpl->setVariable("TXT_SVY_FILE", $this->lng->txt("svy_upload_file"));
04619 $this->tpl->setVariable("TXT_IMPORT", $this->lng->txt("import"));
04620
04621 $this->tpl->setVariable("TXT_DUPLICATE_SVY", $this->lng->txt("duplicate_svy"));
04622 $this->tpl->setVariable("TXT_SELECT_SVY", $this->lng->txt("obj_svy"));
04623 $this->tpl->setVariable("OPTION_SELECT_SVY", $this->lng->txt("select_svy_option"));
04624 $this->tpl->setVariable("TXT_DUPLICATE", $this->lng->txt("duplicate"));
04625 }
04626 }
04627
04631 function cloneAllObject()
04632 {
04633 if ($_POST["svy"] < 1)
04634 {
04635 sendInfo($this->lng->txt("svy_select_surveys"));
04636 $this->createObject();
04637 return;
04638 }
04639 require_once "./survey/classes/class.ilObjSurvey.php";
04640 ilObjSurvey::_clone($_POST["svy"]);
04641 ilUtil::redirect($this->getReturnLocation("cloneAll",$this->ctrl->getTargetScript()."?".$this->link_params));
04642 }
04643
04647 function importFileObject()
04648 {
04649 if ($_POST["spl"] < 1)
04650 {
04651 sendInfo($this->lng->txt("svy_select_questionpools"));
04652 $this->createObject();
04653 return;
04654 }
04655 if (strcmp($_FILES["xmldoc"]["tmp_name"], "") == 0)
04656 {
04657 sendInfo($this->lng->txt("svy_select_file_for_import"));
04658 $this->createObject();
04659 return;
04660 }
04661 $this->uploadObject(false);
04662 ilUtil::redirect($this->getReturnLocation("importFile",$this->ctrl->getTargetScript()."?".$this->link_params));
04663 }
04664
04668 function downloadExportFileObject()
04669 {
04670 if(!isset($_POST["file"]))
04671 {
04672 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
04673 }
04674
04675 if (count($_POST["file"]) > 1)
04676 {
04677 $this->ilias->raiseError($this->lng->txt("select_max_one_item"),$this->ilias->error_obj->MESSAGE);
04678 }
04679
04680
04681 $export_dir = $this->object->getExportDirectory();
04682 ilUtil::deliverFile($export_dir."/".$_POST["file"][0],
04683 $_POST["file"][0]);
04684 }
04685
04689 function confirmDeleteExportFileObject()
04690 {
04691 if(!isset($_POST["file"]))
04692 {
04693 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
04694 }
04695
04696
04697
04698
04699 $_SESSION["ilExportFiles"] = $_POST["file"];
04700
04701 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html", true);
04702
04703 sendInfo($this->lng->txt("info_delete_sure"));
04704
04705 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
04706
04707
04708 $this->tpl->setCurrentBlock("table_header");
04709 $this->tpl->setVariable("TEXT",$this->lng->txt("objects"));
04710 $this->tpl->parseCurrentBlock();
04711
04712
04713 $counter = 0;
04714 foreach($_POST["file"] as $file)
04715 {
04716 $this->tpl->setCurrentBlock("table_row");
04717 $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
04718 $this->tpl->setVariable("TEXT_CONTENT", $file);
04719 $this->tpl->parseCurrentBlock();
04720 }
04721
04722
04723 $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
04724 $buttons = array( "cancelDeleteExportFile" => $this->lng->txt("cancel"),
04725 "deleteExportFile" => $this->lng->txt("confirm"));
04726 foreach ($buttons as $name => $value)
04727 {
04728 $this->tpl->setCurrentBlock("operation_btn");
04729 $this->tpl->setVariable("BTN_NAME",$name);
04730 $this->tpl->setVariable("BTN_VALUE",$value);
04731 $this->tpl->parseCurrentBlock();
04732 }
04733 }
04734
04735
04739 function cancelDeleteExportFileObject()
04740 {
04741 session_unregister("ilExportFiles");
04742 ilUtil::redirect("survey.php?cmd=export&ref_id=".$_GET["ref_id"]);
04743 }
04744
04745
04749 function deleteExportFileObject()
04750 {
04751 $export_dir = $this->object->getExportDirectory();
04752 foreach($_SESSION["ilExportFiles"] as $file)
04753 {
04754 $exp_file = $export_dir."/".$file;
04755 $exp_dir = $export_dir."/".substr($file, 0, strlen($file) - 4);
04756 if (@is_file($exp_file))
04757 {
04758 unlink($exp_file);
04759 }
04760 if (@is_dir($exp_dir))
04761 {
04762 ilUtil::delDir($exp_dir);
04763 }
04764 }
04765 ilUtil::redirect("survey.php?cmd=export&ref_id=".$_GET["ref_id"]);
04766 }
04767
04768 function setEvalTabs()
04769 {
04770 global $rbacsystem;
04771
04772 include_once "./classes/class.ilTabsGUI.php";
04773 $tabs_gui =& new ilTabsGUI();
04774
04775 $tabs_gui->addTarget("svy_eval_cumulated", $this->ctrl->getLinkTargetByClass(get_class($this), "evaluation"), "evaluation", "ilobjsurveygui");
04776 $tabs_gui->addTarget("svy_eval_detail", $this->ctrl->getLinkTargetByClass(get_class($this), "evaluationdetails"), "evaluationdetails", "ilobjsurveygui");
04777 $tabs_gui->addTarget("svy_eval_user", $this->ctrl->getLinkTargetByClass(get_class($this), "evaluationuser"), "evaluationuser", "ilobjsurveygui");
04778 $this->tpl->setVariable("TABS", $tabs_gui->getHTML());
04779 }
04780
04781 function codesObject()
04782 {
04783 global $rbacsystem;
04784
04785 if ((!$rbacsystem->checkAccess("read", $this->ref_id)) && (!$rbacsystem->checkAccess("write", $this->ref_id)))
04786 {
04787
04788 sendInfo($this->lng->txt("cannot_edit_survey"), true);
04789 $path = $this->tree->getPathFull($this->object->getRefID());
04790 ilUtil::redirect($this->getReturnLocation("cancel","../repository.php?ref_id=" . $path[count($path) - 2]["child"]));
04791 return;
04792 }
04793
04794 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_codes.html", true);
04795 if ($rbacsystem->checkAccess("write", $this->ref_id))
04796 {
04797 $color_class = array("tblrow1", "tblrow2");
04798 $survey_codes =& $this->object->getSurveyCodes();
04799 if (count($survey_codes) == 0)
04800 {
04801 $this->tpl->setCurrentBlock("emptyrow");
04802 $this->tpl->setVariable("COLOR_CLASS", "tblrow1");
04803 $this->tpl->setVariable("NO_CODES", $this->lng->txt("survey_code_no_codes"));
04804 $this->tpl->parseCurrentBlock();
04805 }
04806 else
04807 {
04808 foreach ($survey_codes as $key => $row)
04809 {
04810 $this->tpl->setCurrentBlock("coderow");
04811 $this->tpl->setVariable("COLOR_CLASS", $color_class[$key % 2]);
04812 $this->tpl->setVariable("SURVEY_CODE", $row["survey_key"]);
04813 $this->tpl->setVariable("CODE_CREATED", ilFormat::formatDate(ilFormat::ftimestamp2dateDB($row["TIMESTAMP14"]), "date"));
04814 $state = "<span class=\"smallred\">" . $this->lng->txt("not_used") . "</span>";
04815 if ($this->object->isSurveyCodeUsed($row["survey_key"]))
04816 {
04817 $state = "<span class=\"smallgreen\">" . $this->lng->txt("used") . "</span>";
04818 }
04819 else
04820 {
04821 $this->tpl->setVariable("CODE_URL_NAME", $this->lng->txt("survey_code_url_name"));
04822
04823 $this->tpl->setVariable("CODE_URL", ILIAS_HTTP_PATH."/goto.php?cmd=run&target=svy_".$this->object->getRefId() . "&client_id=" . CLIENT_ID . "&accesscode=".$row["survey_key"]);
04824 }
04825 $this->tpl->setVariable("CODE_USED", $state);
04826 $this->tpl->parseCurrentBlock();
04827 }
04828 }
04829 $this->tpl->setCurrentBlock("adm_content");
04830 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
04831 $this->tpl->setVariable("SURVEY_CODE", $this->lng->txt("survey_code"));
04832 $this->tpl->setVariable("CODE_CREATED", $this->lng->txt("create_date"));
04833 $this->tpl->setVariable("CODE_USED", $this->lng->txt("survey_code_used"));
04834 $this->tpl->setVariable("CODE_URL", $this->lng->txt("survey_code_url"));
04835 $this->tpl->setVariable("TEXT_CREATE", $this->lng->txt("create"));
04836 $this->tpl->setVariable("TEXT_SURVEY_CODES", $this->lng->txt("new_survey_codes"));
04837 $this->tpl->parseCurrentBlock();
04838 }
04839 else
04840 {
04841 sendInfo($this->lng->txt("cannot_create_survey_codes"));
04842 }
04843 }
04844
04845 function createSurveyCodesObject()
04846 {
04847 if (preg_match("/\d+/", $_POST["nrOfCodes"]))
04848 {
04849 $this->object->createSurveyCodes($_POST["nrOfCodes"]);
04850 }
04851 else
04852 {
04853 sendInfo($this->lng->txt("enter_valid_number_of_codes"), true);
04854 }
04855 $this->ctrl->redirect($this, "codes");
04856 }
04857
04863 function getTabs(&$tabs_gui)
04864 {
04865 $tabs_gui->getTargetsByObjectType($this, "svy");
04866
04867 $tabs_gui->addTarget("meta_data",
04868 $this->ctrl->getLinkTargetByClass('ilmdeditorgui',''),
04869 "meta_data", get_class($this));
04870 }
04871
04872 }
04873 ?>