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