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 require_once "./survey/classes/class.SurveyNominalQuestionGUI.php";
00025 require_once "./survey/classes/class.SurveyTextQuestionGUI.php";
00026 require_once "./survey/classes/class.SurveyMetricQuestionGUI.php";
00027 require_once "./survey/classes/class.SurveyOrdinalQuestionGUI.php";
00028 require_once "./classes/class.ilObjectGUI.php";
00029
00030
00045 class ilObjSurveyQuestionPoolGUI extends ilObjectGUI
00046 {
00047 var $defaultscript;
00048
00053 function ilObjSurveyQuestionPoolGUI($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
00054 {
00055 global $lng, $ilCtrl;
00056
00057 $this->type = "spl";
00058 $lng->loadLanguageModule("survey");
00059 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference, false);
00060 $this->ctrl =& $ilCtrl;
00061 $this->ctrl->saveParameter($this, array("ref_id", "calling_survey", "new_for_survey"));
00062 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference, false);
00063 if (!defined("ILIAS_MODULE"))
00064 {
00065 $this->setTabTargetScript("adm_object.php");
00066 $this->defaultscript = "adm_object.php";
00067 }
00068 else
00069 {
00070 $this->setTabTargetScript("questionpool.php");
00071 $this->defaultscript = "questionpool.php";
00072 }
00073 if ($a_prepare_output) {
00074 $this->prepareOutput();
00075 }
00076 }
00077
00082 function saveObject()
00083 {
00084 global $rbacadmin;
00085
00086
00087 $newObj = parent::saveObject();
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098 sendInfo($this->lng->txt("object_added"),true);
00099
00100 $returnlocation = "questionpool.php";
00101 if (!defined("ILIAS_MODULE"))
00102 {
00103 $returnlocation = "adm_object.php";
00104 }
00105 ilUtil::redirect($this->getReturnLocation("save","$returnlocation?".$this->link_params));
00106 exit();
00107 }
00108
00114 function getCallingScript()
00115 {
00116 return "questionpool.php";
00117 }
00118
00119 function getAddParameter()
00120 {
00121 return "?ref_id=" . $_GET["ref_id"] . "&cmd=" . $_GET["cmd"];
00122 }
00123
00132 function cancelAction($question_id = "")
00133 {
00134 $this->ctrl->redirect($this, "questions");
00135 }
00136
00144 function copyObject()
00145 {
00146
00147 $checked_questions = array();
00148 foreach ($_POST as $key => $value) {
00149 if (preg_match("/cb_(\d+)/", $key, $matches)) {
00150 array_push($checked_questions, $matches[1]);
00151 }
00152 }
00153
00154
00155 if (count($checked_questions) > 0) {
00156 $_SESSION["spl_copied_questions"] = join($checked_questions, ",");
00157 } elseif (count($checked_questions) == 0) {
00158 sendInfo($this->lng->txt("qpl_copy_select_none"), true);
00159 $_SESSION["spl_copied_questions"] = "";
00160 }
00161 $this->ctrl->redirect($this, "questions");
00162 }
00163
00171 function duplicateObject()
00172 {
00173
00174 $checked_questions = array();
00175 foreach ($_POST as $key => $value) {
00176 if (preg_match("/cb_(\d+)/", $key, $matches)) {
00177 array_push($checked_questions, $matches[1]);
00178 }
00179 }
00180
00181 if (count($checked_questions) > 0) {
00182 foreach ($checked_questions as $key => $value) {
00183 $this->object->duplicateQuestion($value);
00184 }
00185 } elseif (count($checked_questions) == 0) {
00186 sendInfo($this->lng->txt("qpl_duplicate_select_none"), true);
00187 }
00188 $this->ctrl->redirect($this, "questions");
00189 }
00190
00194 function exportQuestionsObject()
00195 {
00196
00197 $checked_questions = array();
00198 foreach ($_POST as $key => $value) {
00199 if (preg_match("/cb_(\d+)/", $key, $matches)) {
00200 array_push($checked_questions, $matches[1]);
00201 }
00202 }
00203
00204
00205 if (count($checked_questions) > 0)
00206 {
00207 $this->createExportFileObject($checked_questions);
00208 }
00209 else
00210 {
00211 sendInfo($this->lng->txt("qpl_export_select_none"), true);
00212 $this->ctrl->redirect($this, "questions");
00213 }
00214 }
00215
00223 function deleteQuestionsObject()
00224 {
00225 global $rbacsystem;
00226
00227 sendInfo();
00228
00229 $checked_questions = array();
00230 foreach ($_POST as $key => $value) {
00231 if (preg_match("/cb_(\d+)/", $key, $matches)) {
00232 array_push($checked_questions, $matches[1]);
00233 }
00234 }
00235
00236 if (count($checked_questions) > 0) {
00237 if ($rbacsystem->checkAccess('write', $this->ref_id)) {
00238 sendInfo($this->lng->txt("qpl_confirm_delete_questions"));
00239 } else {
00240 sendInfo($this->lng->txt("qpl_delete_rbac_error"), true);
00241 $this->ctrl->redirect($this, "questions");
00242 return;
00243 }
00244 } elseif (count($checked_questions) == 0) {
00245 sendInfo($this->lng->txt("qpl_delete_select_none"), true);
00246 $this->ctrl->redirect($this, "questions");
00247 return;
00248 }
00249 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_confirm_delete_questions.html", true);
00250 $whereclause = join($checked_questions, " OR survey_question.question_id = ");
00251 $whereclause = " AND (survey_question.question_id = " . $whereclause . ")";
00252 $query = "SELECT survey_question.*, survey_questiontype.type_tag FROM survey_question, survey_questiontype WHERE survey_question.questiontype_fi = survey_questiontype.questiontype_id$whereclause ORDER BY survey_question.title";
00253 $query_result = $this->ilias->db->query($query);
00254 $colors = array("tblrow1", "tblrow2");
00255 $counter = 0;
00256 if ($query_result->numRows() > 0)
00257 {
00258 while ($data = $query_result->fetchRow(DB_FETCHMODE_OBJECT))
00259 {
00260 if (in_array($data->question_id, $checked_questions))
00261 {
00262 $this->tpl->setCurrentBlock("row");
00263 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
00264 $this->tpl->setVariable("TXT_TITLE", $data->title);
00265 $this->tpl->setVariable("TXT_DESCRIPTION", $data->description);
00266 $this->tpl->setVariable("TXT_TYPE", $this->lng->txt($data->type_tag));
00267 $this->tpl->parseCurrentBlock();
00268 $counter++;
00269 }
00270 }
00271 }
00272 foreach ($checked_questions as $id)
00273 {
00274 $this->tpl->setCurrentBlock("hidden");
00275 $this->tpl->setVariable("HIDDEN_NAME", "id_$id");
00276 $this->tpl->setVariable("HIDDEN_VALUE", "1");
00277 $this->tpl->parseCurrentBlock();
00278 }
00279
00280 $this->tpl->setCurrentBlock("adm_content");
00281 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
00282 $this->tpl->setVariable("TXT_DESCRIPTION", $this->lng->txt("description"));
00283 $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("question_type"));
00284 $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
00285 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
00286 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00287 $this->tpl->parseCurrentBlock();
00288 }
00289
00293 function confirmDeleteQuestionsObject()
00294 {
00295
00296 sendInfo($this->lng->txt("qpl_questions_deleted"), true);
00297 $checked_questions = array();
00298 foreach ($_POST as $key => $value) {
00299 if (preg_match("/id_(\d+)/", $key, $matches)) {
00300 array_push($checked_questions, $matches[1]);
00301 }
00302 }
00303
00304 foreach ($checked_questions as $key => $value) {
00305 $this->object->removeQuestion($value);
00306 }
00307 $this->ctrl->redirect($this, "questions");
00308 }
00309
00313 function cancelDeleteQuestionsObject()
00314 {
00315
00316 $this->ctrl->redirect($this, "questions");
00317 }
00318
00326 function pasteObject()
00327 {
00328 sendInfo();
00329
00330
00331 $checked_questions = array();
00332 foreach ($_POST as $key => $value) {
00333 if (preg_match("/cb_(\d+)/", $key, $matches)) {
00334 array_push($checked_questions, $matches[1]);
00335 }
00336 }
00337
00338
00339 if (strcmp($_SESSION["spl_copied_questions"], "") != 0)
00340 {
00341 $copied_questions = split("/,/", $_SESSION["spl_copied_questions"]);
00342 sendInfo($this->lng->txt("qpl_past_questions_confirmation"));
00343 }
00344 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_confirm_paste_questions.html", true);
00345 $questions_info =& $this->object->getQuestionsInfo($copied_questions);
00346 $colors = array("tblrow1", "tblrow2");
00347 $counter = 0;
00348 foreach ($questions_info as $data)
00349 {
00350 $this->tpl->setCurrentBlock("row");
00351 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
00352 $this->tpl->setVariable("TXT_TITLE", $data->title);
00353 $this->tpl->setVariable("TXT_DESCRIPTION", $data->description);
00354 $this->tpl->setVariable("TXT_TYPE", $this->lng->txt($data->type_tag));
00355 $this->tpl->parseCurrentBlock();
00356 $counter++;
00357 }
00358 foreach ($questions_info as $data)
00359 {
00360 $this->tpl->setCurrentBlock("hidden");
00361 $this->tpl->setVariable("HIDDEN_NAME", "id_$data->question_id");
00362 $this->tpl->setVariable("HIDDEN_VALUE", $data->question_id);
00363 $this->tpl->parseCurrentBlock();
00364 }
00365
00366 $this->tpl->setCurrentBlock("adm_content");
00367 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
00368 $this->tpl->setVariable("TXT_DESCRIPTION", $this->lng->txt("description"));
00369 $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("question_type"));
00370 $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
00371 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
00372 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00373 $this->tpl->parseCurrentBlock();
00374 }
00375
00379 function confirmPasteQuestionsObject()
00380 {
00381
00382 sendInfo($this->lng->txt("qpl_questions_pasted"), true);
00383 $checked_questions = array();
00384 foreach ($_POST as $key => $value) {
00385 if (preg_match("/id_(\d+)/", $key, $matches)) {
00386 array_push($checked_questions, $matches[1]);
00387 }
00388 }
00389 foreach ($checked_questions as $key => $value) {
00390 $this->object->paste($value);
00391 }
00392
00393 $this->ctrl->redirect($this, "questions");
00394 }
00395
00399 function cancelPasteQuestionsObject()
00400 {
00401
00402 $this->ctrl->redirect($this, "questions");
00403 }
00404
00408 function cancelDeletePhraseObject()
00409 {
00410 $this->ctrl->redirect($this, "phrases");
00411 }
00412
00416 function confirmDeletePhraseObject()
00417 {
00418 $phrases = array();
00419 foreach ($_POST as $key => $value)
00420 {
00421 if (preg_match("/phrase_(\d+)/", $key, $matches))
00422 {
00423 array_push($phrases, $matches[1]);
00424 }
00425 }
00426 $this->object->deletePhrases($phrases);
00427 sendInfo($this->lng->txt("qpl_phrases_deleted"), true);
00428 $this->ctrl->redirect($this, "phrases");
00429 }
00430
00439 function deletePhrasesForm($checked_phrases)
00440 {
00441 sendInfo();
00442 $ordinal = new SurveyOrdinalQuestion();
00443 $phrases =& $ordinal->getAvailablePhrases(1);
00444 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_confirm_delete_phrases.html", true);
00445 $colors = array("tblrow1", "tblrow2");
00446 $counter = 0;
00447 foreach ($checked_phrases as $id)
00448 {
00449 $this->tpl->setCurrentBlock("row");
00450 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter++ % 2]);
00451 $this->tpl->setVariable("PHRASE_TITLE", $phrases[$id]["title"]);
00452 $categories =& $ordinal->getCategoriesForPhrase($id);
00453 $this->tpl->setVariable("PHRASE_CONTENT", join($categories, ", "));
00454 $this->tpl->parseCurrentBlock();
00455 $this->tpl->setCurrentBlock("hidden");
00456 $this->tpl->setVariable("HIDDEN_NAME", "phrase_$id");
00457 $this->tpl->setVariable("HIDDEN_VALUE", "1");
00458 $this->tpl->parseCurrentBlock();
00459 }
00460
00461 $this->tpl->setCurrentBlock("adm_content");
00462 $this->tpl->setVariable("TEXT_PHRASE_TITLE", $this->lng->txt("phrase"));
00463 $this->tpl->setVariable("TEXT_PHRASE_CONTENT", $this->lng->txt("categories"));
00464 $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
00465 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
00466 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00467 $this->tpl->parseCurrentBlock();
00468 }
00469
00477 function deletePhraseObject()
00478 {
00479 sendInfo();
00480
00481 $checked_phrases = array();
00482 foreach ($_POST as $key => $value)
00483 {
00484 if (preg_match("/phrase_(\d+)/", $key, $matches))
00485 {
00486 array_push($checked_phrases, $matches[1]);
00487 }
00488 }
00489 if (count($checked_phrases))
00490 {
00491 sendInfo($this->lng->txt("qpl_confirm_delete_phrases"));
00492 $this->deletePhrasesForm($checked_phrases);
00493 return;
00494 }
00495 else
00496 {
00497 sendInfo($this->lng->txt("qpl_delete_phrase_select_none"));
00498 $this->phrasesObject();
00499 return;
00500 }
00501
00502 $this->tpl->setCurrentBlock("obligatory");
00503 $this->tpl->setVariable("TEXT_OBLIGATORY", $this->lng->txt("obligatory"));
00504 $this->tpl->setVariable("CHECKED_OBLIGATORY", " checked=\"checked\"");
00505 $this->tpl->parseCurrentBlock();
00506 $this->tpl->setCurrentBlock("adm_content");
00507 $this->tpl->setVariable("DEFINE_QUESTIONBLOCK_HEADING", $this->lng->txt("define_questionblock"));
00508 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
00509 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00510 $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
00511 $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
00512 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00513 $this->tpl->parseCurrentBlock();
00514 }
00515
00521 function phrasesObject()
00522 {
00523 global $rbacsystem;
00524
00525 if ($rbacsystem->checkAccess("write", $this->object->getRefId()))
00526 {
00527 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_phrases.html", true);
00528 $ordinal = new SurveyOrdinalQuestion();
00529 $phrases =& $ordinal->getAvailablePhrases(1);
00530 if (count($phrases))
00531 {
00532 $colors = array("tblrow1", "tblrow2");
00533 $counter = 0;
00534 foreach ($phrases as $phrase_id => $phrase_array)
00535 {
00536 $this->tpl->setCurrentBlock("phraserow");
00537 $this->tpl->setVariable("PHRASE_ID", $phrase_id);
00538 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter++ % 2]);
00539 $this->tpl->setVariable("PHRASE_TITLE", $phrase_array["title"]);
00540 $categories =& $ordinal->getCategoriesForPhrase($phrase_id);
00541 $this->tpl->setVariable("PHRASE_CONTENT", join($categories, ", "));
00542 $this->tpl->parseCurrentBlock();
00543 }
00544 $this->tpl->setCurrentBlock("Footer");
00545 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"\">");
00546 $this->tpl->setVariable("TEXT_DELETE", $this->lng->txt("delete"));
00547 $this->tpl->parseCurrentBlock();
00548 }
00549 else
00550 {
00551 $this->tpl->setCurrentBlock("Emptytable");
00552 $this->tpl->setVariable("TEXT_EMPTYTABLE", $this->lng->txt("no_user_phrases_defined"));
00553 $this->tpl->parseCurrentBlock();
00554 }
00555 $this->tpl->setCurrentBlock("adm_content");
00556 $this->tpl->setVariable("INTRODUCTION_MANAGE_PHRASES", $this->lng->txt("introduction_manage_phrases"));
00557 $this->tpl->setVariable("TEXT_PHRASE_TITLE", $this->lng->txt("phrase"));
00558 $this->tpl->setVariable("TEXT_PHRASE_CONTENT", $this->lng->txt("categories"));
00559 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00560 $this->tpl->parseCurrentBlock();
00561 }
00562 else
00563 {
00564 sendInfo($this->lng->txt("cannot_manage_phrases"));
00565 }
00566 }
00567
00571 function importQuestionsObject()
00572 {
00573 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_import_question.html", true);
00574 $this->tpl->setCurrentBlock("adm_content");
00575 $this->tpl->setVariable("TEXT_IMPORT_QUESTION", $this->lng->txt("import_question"));
00576 $this->tpl->setVariable("TEXT_SELECT_FILE", $this->lng->txt("select_file"));
00577 $this->tpl->setVariable("TEXT_UPLOAD", $this->lng->txt("upload"));
00578 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00579 $this->tpl->parseCurrentBlock();
00580 }
00581
00585 function uploadQuestionsObject()
00586 {
00587
00588 $source = $_FILES["qtidoc"]["tmp_name"];
00589 $error = 0;
00590 if (($source == 'none') || (!$source) || $_FILES["qtidoc"]["error"] > UPLOAD_ERR_OK)
00591 {
00592
00593 $error = 1;
00594 }
00595
00596 if (strcmp($_FILES["qtidoc"]["type"], "text/xml") != 0)
00597 {
00598
00599 $error = 1;
00600 }
00601 if (!$error)
00602 {
00603
00604
00605 $this->object->createImportDirectory();
00606
00607
00608 $full_path = $this->object->getImportDirectory()."/".$_FILES["qtidoc"]["name"];
00609
00610 ilUtil::moveUploadedFile($_FILES["qtidoc"]["tmp_name"],
00611 $_FILES["qtidoc"]["name"], $full_path);
00612
00613 $source = $full_path;
00614
00615 $fh = fopen($source, "r") or die("");
00616 $xml = fread($fh, filesize($source));
00617 fclose($fh) or die("");
00618 unlink($source);
00619 if (preg_match_all("/(<item[^>]*>.*?<\/item>)/si", $xml, $matches))
00620 {
00621 foreach ($matches[1] as $index => $item)
00622 {
00623 $question = "";
00624 if (preg_match("/<qticomment>Questiontype\=(.*?)<\/qticomment>/is", $item, $questiontype))
00625 {
00626 switch ($questiontype[1])
00627 {
00628 case NOMINAL_QUESTION_IDENTIFIER:
00629 $question = new SurveyNominalQuestion();
00630 break;
00631 case ORDINAL_QUESTION_IDENTIFIER:
00632 $question = new SurveyOrdinalQuestion();
00633 break;
00634 case METRIC_QUESTION_IDENTIFIER:
00635 $question = new SurveyMetricQuestion();
00636 break;
00637 case TEXT_QUESTION_IDENTIFIER:
00638 $question = new SurveyTextQuestion();
00639 break;
00640 }
00641 if ($question)
00642 {
00643 $question->setObjId($this->object->getId());
00644 if ($question->from_xml("<questestinterop>$item</questestinterop>"))
00645 {
00646 $question->saveToDb();
00647 }
00648 else
00649 {
00650 $this->ilias->raiseError($this->lng->txt("error_importing_question"), $this->ilias->error_obj->MESSAGE);
00651 }
00652 }
00653 }
00654 }
00655 }
00656 }
00657 $this->ctrl->redirect($this, "questions");
00658 }
00659
00660 function filterObject()
00661 {
00662 $this->questionsObject();
00663 }
00664
00665 function resetObject()
00666 {
00667 $this->questionsObject();
00668 }
00669
00674 function questionsObject()
00675 {
00676 global $rbacsystem;
00677
00678 $add_parameter = $this->getAddParameter();
00679
00680 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_questions.html", true);
00681 if ($rbacsystem->checkAccess('write', $this->ref_id)) {
00682 $this->tpl->addBlockFile("CREATE_QUESTION", "create_question", "tpl.il_svy_qpl_create_new_question.html", true);
00683 $this->tpl->addBlockFile("A_BUTTONS", "a_buttons", "tpl.il_svy_qpl_action_buttons.html", true);
00684 }
00685 $this->tpl->addBlockFile("FILTER_QUESTION_MANAGER", "filter_questions", "tpl.il_svy_qpl_filter_questions.html", true);
00686
00687
00688 $filter_fields = array(
00689 "title" => $this->lng->txt("title"),
00690 "description" => $this->lng->txt("description"),
00691 "author" => $this->lng->txt("author"),
00692 );
00693 $this->tpl->setCurrentBlock("filterrow");
00694 foreach ($filter_fields as $key => $value) {
00695 $this->tpl->setVariable("VALUE_FILTER_TYPE", "$key");
00696 $this->tpl->setVariable("NAME_FILTER_TYPE", "$value");
00697 if (!$_POST["cmd"]["reset"]) {
00698 if (strcmp($_POST["sel_filter_type"], $key) == 0) {
00699 $this->tpl->setVariable("VALUE_FILTER_SELECTED", " selected=\"selected\"");
00700 }
00701 }
00702 $this->tpl->parseCurrentBlock();
00703 }
00704
00705 $this->tpl->setCurrentBlock("filter_questions");
00706 $this->tpl->setVariable("FILTER_TEXT", $this->lng->txt("filter"));
00707 $this->tpl->setVariable("TEXT_FILTER_BY", $this->lng->txt("by"));
00708 if (!$_POST["cmd"]["reset"]) {
00709 $this->tpl->setVariable("VALUE_FILTER_TEXT", $_POST["filter_text"]);
00710 }
00711 $this->tpl->setVariable("VALUE_SUBMIT_FILTER", $this->lng->txt("set_filter"));
00712 $this->tpl->setVariable("VALUE_RESET_FILTER", $this->lng->txt("reset_filter"));
00713 $this->tpl->parseCurrentBlock();
00714
00715
00716 if ($rbacsystem->checkAccess('write', $this->ref_id)) {
00717 $this->tpl->setCurrentBlock("standard");
00718 $this->tpl->setVariable("DELETE", $this->lng->txt("delete"));
00719 $this->tpl->setVariable("DUPLICATE", $this->lng->txt("duplicate"));
00720 $this->tpl->setVariable("COPY", $this->lng->txt("copy"));
00721 $this->tpl->setVariable("EXPORT", $this->lng->txt("export"));
00722 $this->tpl->setVariable("PASTE", $this->lng->txt("paste"));
00723 if (strcmp($_SESSION["spl_copied_questions"], "") == 0)
00724 {
00725 $this->tpl->setVariable("PASTE_DISABLED", " disabled=\"disabled\"");
00726 }
00727 $this->tpl->setVariable("QUESTIONBLOCK", $this->lng->txt("define_questionblock"));
00728 $this->tpl->setVariable("UNFOLD", $this->lng->txt("unfold"));
00729 $this->tpl->parseCurrentBlock();
00730 $this->tpl->setCurrentBlock("Footer");
00731 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"\">");
00732 $this->tpl->parseCurrentBlock();
00733 }
00734
00735 if ($_POST["cmd"]["reset"])
00736 {
00737 $_POST["filter_text"] = "";
00738 }
00739 $startrow = 0;
00740 if ($_GET["prevrow"])
00741 {
00742 $startrow = $_GET["prevrow"];
00743 }
00744 if ($_GET["nextrow"])
00745 {
00746 $startrow = $_GET["nextrow"];
00747 }
00748 if ($_GET["startrow"])
00749 {
00750 $startrow = $_GET["startrow"];
00751 }
00752 if (!$_GET["sort"])
00753 {
00754
00755 $_GET["sort"] = array("title" => "ASC");
00756 }
00757 $table = $this->object->getQuestionsTable($_GET["sort"], $_POST["filter_text"], $_POST["sel_filter_type"], $startrow);
00758 $colors = array("tblrow1", "tblrow2");
00759 $counter = 0;
00760 $last_questionblock_id = 0;
00761 $editable = $rbacsystem->checkAccess('write', $this->ref_id);
00762 foreach ($table["rows"] as $data)
00763 {
00764 $this->tpl->setCurrentBlock("checkable");
00765 $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
00766 $this->tpl->parseCurrentBlock();
00767 if ($data["complete"] == 0)
00768 {
00769 $this->tpl->setCurrentBlock("qpl_warning");
00770 $this->tpl->setVariable("IMAGE_WARNING", ilUtil::getImagePath("warning.png"));
00771 $this->tpl->setVariable("ALT_WARNING", $this->lng->txt("warning_question_not_complete"));
00772 $this->tpl->setVariable("TITLE_WARNING", $this->lng->txt("warning_question_not_complete"));
00773 $this->tpl->parseCurrentBlock();
00774 }
00775 $this->tpl->setCurrentBlock("QTab");
00776
00777 $class = strtolower(SurveyQuestionGUI::_getGUIClassNameForId($data["question_id"]));
00778 $this->ctrl->setParameterByClass($class, "q_id", $data["question_id"]);
00779 $sel_question_types = "";
00780 switch ($class)
00781 {
00782 case "surveynominalquestiongui":
00783 $sel_question_types = "qt_nominal";
00784 break;
00785 case "surveyordinalquestiongui":
00786 $sel_question_types = "qt_ordinal";
00787 break;
00788 case "surveymetricquestiongui":
00789 $sel_question_types = "qt_metric";
00790 break;
00791 case "surveytextquestiongui":
00792 $sel_question_types = "qt_text";
00793 break;
00794 }
00795 $this->ctrl->setParameterByClass($class, "sel_question_types", $sel_question_types);
00796 if ($editable)
00797 {
00798 $this->tpl->setVariable("EDIT", "[<a href=\"" . $this->ctrl->getLinkTargetByClass($class, "editQuestion") . "\">" . $this->lng->txt("edit") . "</a>]");
00799 }
00800 $this->tpl->setVariable("QUESTION_TITLE", "<strong>" . $data["title"] . "</strong>");
00801
00802 $this->tpl->setVariable("PREVIEW", "[<a href=\"" . $this->ctrl->getLinkTargetByClass($class, "preview") . "\">" . $this->lng->txt("preview") . "</a>]");
00803 $this->tpl->setVariable("QUESTION_DESCRIPTION", $data["description"]);
00804 $this->tpl->setVariable("QUESTION_PREVIEW", $this->lng->txt("preview"));
00805 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($data["type_tag"]));
00806 $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]);
00807 $this->tpl->setVariable("QUESTION_CREATED", ilFormat::formatDate(ilFormat::ftimestamp2dateDB($data["created"]), "date"));
00808 $this->tpl->setVariable("QUESTION_UPDATED", ilFormat::formatDate(ilFormat::ftimestamp2dateDB($data["TIMESTAMP14"]), "date"));
00809 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
00810 $this->tpl->parseCurrentBlock();
00811 $counter++;
00812 }
00813
00814 if ($table["rowcount"] > count($table["rows"]))
00815 {
00816 $nextstep = $table["nextrow"] + $table["step"];
00817 if ($nextstep > $table["rowcount"])
00818 {
00819 $nextstep = $table["rowcount"];
00820 }
00821 $sort = "";
00822 if (is_array($_GET["sort"]))
00823 {
00824 $key = key($_GET["sort"]);
00825 $sort = "&sort[$key]=" . $_GET["sort"]["$key"];
00826 }
00827 $counter = 1;
00828 for ($i = 0; $i < $table["rowcount"]; $i += $table["step"])
00829 {
00830 $this->tpl->setCurrentBlock("pages");
00831 if ($table["startrow"] == $i)
00832 {
00833 $this->tpl->setVariable("PAGE_NUMBER", "<span class=\"inactivepage\">$counter</span>");
00834 }
00835 else
00836 {
00837 $this->tpl->setVariable("PAGE_NUMBER", "<a href=\"" . $this->ctrl->getFormAction($this) . "$sort&nextrow=$i" . "\">$counter</a>");
00838 }
00839 $this->tpl->parseCurrentBlock();
00840 $counter++;
00841 }
00842 $this->tpl->setCurrentBlock("navigation_bottom");
00843 $this->tpl->setVariable("TEXT_ITEM", $this->lng->txt("item"));
00844 $this->tpl->setVariable("TEXT_ITEM_START", $table["startrow"] + 1);
00845 $end = $table["startrow"] + $table["step"];
00846 if ($end > $table["rowcount"])
00847 {
00848 $end = $table["rowcount"];
00849 }
00850 $this->tpl->setVariable("TEXT_ITEM_END", $end);
00851 $this->tpl->setVariable("TEXT_OF", strtolower($this->lng->txt("of")));
00852 $this->tpl->setVariable("TEXT_ITEM_COUNT", $table["rowcount"]);
00853 $this->tpl->setVariable("TEXT_PREVIOUS", $this->lng->txt("previous"));
00854 $this->tpl->setVariable("TEXT_NEXT", $this->lng->txt("next"));
00855 $this->tpl->setVariable("HREF_PREV_ROWS", $this->ctrl->getFormAction($this) . "$sort&prevrow=" . $table["prevrow"]);
00856 $this->tpl->setVariable("HREF_NEXT_ROWS", $this->ctrl->getFormAction($this) . "$sort&nextrow=" . $table["nextrow"]);
00857 $this->tpl->parseCurrentBlock();
00858 }
00859
00860
00861 if ($counter == 0) {
00862 $this->tpl->setCurrentBlock("Emptytable");
00863 $this->tpl->setVariable("TEXT_EMPTYTABLE", $this->lng->txt("no_questions_available"));
00864 $this->tpl->parseCurrentBlock();
00865 }
00866
00867 if ($rbacsystem->checkAccess('write', $this->ref_id)) {
00868
00869 $this->tpl->setCurrentBlock("QTypes");
00870 $query = "SELECT * FROM survey_questiontype ORDER BY questiontype_id";
00871 $query_result = $this->ilias->db->query($query);
00872 while ($data = $query_result->fetchRow(DB_FETCHMODE_OBJECT))
00873 {
00874 $this->tpl->setVariable("QUESTION_TYPE_ID", $data->type_tag);
00875 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($data->type_tag));
00876 $this->tpl->parseCurrentBlock();
00877 }
00878 $this->tpl->setCurrentBlock("CreateQuestion");
00879 $this->tpl->setVariable("QUESTION_ADD", $this->lng->txt("create"));
00880 $this->tpl->setVariable("QUESTION_IMPORT", $this->lng->txt("import"));
00881 $this->tpl->setVariable("ACTION_QUESTION_ADD", $this->ctrl->getFormAction($this));
00882 $this->tpl->parseCurrentBlock();
00883 }
00884
00885 $sortcolumns = array(
00886 "title" => $_GET["sort"]["title"],
00887 "description" => $_GET["sort"]["description"],
00888 "type" => $_GET["sort"]["type"],
00889 "author" => $_GET["sort"]["author"],
00890 "created" => $_GET["sort"]["created"],
00891 "updated" => $_GET["sort"]["updated"]
00892 );
00893 foreach ($sortcolumns as $key => $value) {
00894 if (strcmp($value, "ASC") == 0) {
00895 $sortcolumns[$key] = "DESC";
00896 } else {
00897 $sortcolumns[$key] = "ASC";
00898 }
00899 }
00900
00901 $this->tpl->setCurrentBlock("adm_content");
00902
00903 $this->ctrl->setParameterByClass(get_class($this), "startrow", $table["startrow"]);
00904 $this->tpl->setVariable("QUESTION_TITLE", "<a href=\"" . $this->ctrl->getFormAction($this) . "&sort[title]=" . $sortcolumns["title"] . "\">" . $this->lng->txt("title") . "</a>" . $table["images"]["title"]);
00905 $this->tpl->setVariable("QUESTION_DESCRIPTION", "<a href=\"" . $this->ctrl->getFormAction($this) . "&sort[description]=" . $sortcolumns["description"] . "\">" . $this->lng->txt("description") . "</a>". $table["images"]["description"]);
00906 $this->tpl->setVariable("QUESTION_TYPE", "<a href=\"" . $this->ctrl->getFormAction($this) . "&sort[type]=" . $sortcolumns["type"] . "\">" . $this->lng->txt("question_type") . "</a>" . $table["images"]["type"]);
00907 $this->tpl->setVariable("QUESTION_AUTHOR", "<a href=\"" . $this->ctrl->getFormAction($this) . "&sort[author]=" . $sortcolumns["author"] . "\">" . $this->lng->txt("author") . "</a>" . $table["images"]["author"]);
00908 $this->tpl->setVariable("QUESTION_CREATED", "<a href=\"" . $this->ctrl->getFormAction($this) . "&sort[created]=" . $sortcolumns["created"] . "\">" . $this->lng->txt("create_date") . "</a>" . $table["images"]["created"]);
00909 $this->tpl->setVariable("QUESTION_UPDATED", "<a href=\"" . $this->ctrl->getFormAction($this) . "&sort[updated]=" . $sortcolumns["updated"] . "\">" . $this->lng->txt("last_update") . "</a>" . $table["images"]["updated"]);
00910 $this->tpl->setVariable("BUTTON_CANCEL", $this->lng->txt("cancel"));
00911 $this->tpl->setVariable("ACTION_QUESTION_FORM", $this->ctrl->getFormAction($this));
00912 $this->tpl->parseCurrentBlock();
00913 unset($_SESSION["calling_survey"]);
00914 }
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973
00974
00975
00976
00977
00978
00979
00980
00981
00982
00983
00984
00985
00986
00987
00988
00989
00990
00991
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017 function updateObject() {
01018
01019 $this->update = $this->object->update();
01020 sendInfo($this->lng->txt("msg_obj_modified"), true);
01021 }
01022
01031 function setLocator($a_tree = "", $a_id = "", $scriptname="repository.php", $question_title = "")
01032 {
01033 $ilias_locator = new ilLocatorGUI(false);
01034 if (!is_object($a_tree))
01035 {
01036 $a_tree =& $this->tree;
01037 }
01038 if (!($a_id))
01039 {
01040 $a_id = $_GET["ref_id"];
01041 }
01042 if (!($scriptname))
01043 {
01044 $scriptname = "repository.php";
01045 }
01046 $path = $a_tree->getPathFull($a_id);
01047
01048
01049 if ($a_parent_parent)
01050 {
01051
01052 $subObj =& $this->ilias->obj_factory->getInstanceByRefId($a_ref_id);
01053
01054 $path[] = array(
01055 "id" => $a_ref_id,
01056 "title" => $this->lng->txt($subObj->getTitle())
01057 );
01058 }
01059
01060
01061 $modifier = 1;
01062
01063 if (isset($_GET["obj_id"]))
01064 {
01065 $modifier = 0;
01066 }
01067
01068
01069 $i = 1;
01070
01071 if (!defined("ILIAS_MODULE")) {
01072 foreach ($path as $key => $row)
01073 {
01074 $ilias_locator->navigate($i++, $row["title"], ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/adm_object.php?ref_id=".$row["child"], "");
01075 }
01076 } else {
01077 foreach ($path as $key => $row)
01078 {
01079 if (strcmp($row["title"], "ILIAS") == 0) {
01080 $row["title"] = $this->lng->txt("repository");
01081 }
01082 if ($this->ref_id == $row["child"]) {
01083 $param = "&cmd=questions";
01084 $ilias_locator->navigate($i++, $row["title"], ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/survey/questionpool.php" . "?ref_id=".$row["child"] . $param,"target=\"bottom\"");
01085 switch ($_GET["cmd"]) {
01086 case "questions":
01087 $id = $_GET["edit"];
01088 if (!$id) {
01089 $id = $_POST["id"];
01090 }
01091 if ($question_title) {
01092 if ($id > 0)
01093 {
01094 $ilias_locator->navigate($i++, $question_title, ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/survey/questionpool.php" . "?ref_id=".$row["child"] . "&cmd=questions&edit=$id","target=\"bottom\"");
01095 }
01096 }
01097 break;
01098 }
01099 } else {
01100 $ilias_locator->navigate($i++, $row["title"], ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/" . $scriptname."?cmd=frameset&ref_id=".$row["child"],"target=\"bottom\"");
01101 }
01102 }
01103
01104 if (isset($_GET["obj_id"]))
01105 {
01106 $obj_data =& $this->ilias->obj_factory->getInstanceByObjId($_GET["obj_id"]);
01107 $ilias_locator->navigate($i++,$obj_data->getTitle(),$scriptname."?cmd=frameset&ref_id=".$_GET["ref_id"]."&obj_id=".$_GET["obj_id"],"target=\"bottom\"");
01108 }
01109 }
01110 $ilias_locator->output(true);
01111 }
01112
01113
01114
01115
01116
01117 function exportObject()
01118 {
01119 global $tree;
01120
01121
01122
01123
01124 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
01125
01126
01127 $this->tpl->setCurrentBlock("btn_cell");
01128 $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "createExportFile"));
01129 $this->tpl->setVariable("BTN_TXT", $this->lng->txt("svy_create_export_file"));
01130 $this->tpl->parseCurrentBlock();
01131
01132 $export_dir = $this->object->getExportDirectory();
01133 $export_files = $this->object->getExportFiles($export_dir);
01134
01135
01136 include_once("./classes/class.ilTableGUI.php");
01137 $tbl = new ilTableGUI();
01138
01139
01140 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
01141
01142
01143 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.export_file_row.html", true);
01144
01145 $num = 0;
01146
01147 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01148
01149 $tbl->setTitle($this->lng->txt("svy_export_files"));
01150
01151 $tbl->setHeaderNames(array("", $this->lng->txt("svy_file"),
01152 $this->lng->txt("svy_size"), $this->lng->txt("date") ));
01153
01154 $tbl->enabled["sort"] = false;
01155 $tbl->setColumnWidth(array("1%", "49%", "25%", "25%"));
01156
01157
01158 $tbl->setOrderColumn($_GET["sort_by"]);
01159 $tbl->setOrderDirection($_GET["sort_order"]);
01160 $tbl->setLimit($_GET["limit"]);
01161 $tbl->setOffset($_GET["offset"]);
01162 $tbl->setMaxCount($this->maxcount);
01163
01164
01165 include_once "./classes/class.ilUtil.php";
01166
01167
01168 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
01169
01170
01171 $tbl->setMaxCount(count($export_files));
01172 $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
01173
01174 $tbl->render();
01175 if(count($export_files) > 0)
01176 {
01177 $this->tpl->setVariable("COLUMN_COUNTS", 4);
01178
01179 $i=0;
01180 foreach($export_files as $exp_file)
01181 {
01182 $this->tpl->setCurrentBlock("tbl_content");
01183 $this->tpl->setVariable("TXT_FILENAME", $exp_file);
01184
01185 $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
01186 $this->tpl->setVariable("CSS_ROW", $css_row);
01187
01188 $this->tpl->setVariable("TXT_SIZE", filesize($export_dir."/".$exp_file));
01189 $this->tpl->setVariable("CHECKBOX_ID", $exp_file);
01190
01191 $file_arr = explode("__", $exp_file);
01192 $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s",$file_arr[0]));
01193
01194 $this->tpl->parseCurrentBlock();
01195 }
01196 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
01197 $this->tpl->setCurrentBlock("tbl_action_btn");
01198 $this->tpl->setVariable("BTN_NAME", "confirmDeleteExportFile");
01199 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
01200 $this->tpl->parseCurrentBlock();
01201
01202 $this->tpl->setCurrentBlock("tbl_action_btn");
01203 $this->tpl->setVariable("BTN_NAME", "downloadExportFile");
01204 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("download"));
01205 $this->tpl->parseCurrentBlock();
01206 }
01207 else
01208 {
01209 $this->tpl->setCurrentBlock("notfound");
01210 $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
01211 $this->tpl->setVariable("NUM_COLS", 3);
01212 $this->tpl->parseCurrentBlock();
01213 }
01214
01215 $this->tpl->parseCurrentBlock();
01216 }
01217
01221 function createExportFileObject($questions = null)
01222 {
01223 global $rbacsystem;
01224
01225 if ($rbacsystem->checkAccess("write", $this->ref_id))
01226 {
01227 require_once("./survey/classes/class.ilSurveyQuestionpoolExport.php");
01228 $survey_exp = new ilSurveyQuestionpoolExport($this->object);
01229 $survey_exp->buildExportFile($questions);
01230 ilUtil::redirect("questionpool.php?cmd=export&ref_id=".$_GET["ref_id"]);
01231
01232 }
01233 else
01234 {
01235 sendInfo("cannot_export_questionpool");
01236 }
01237 }
01238
01242 function downloadExportFileObject()
01243 {
01244 if(!isset($_POST["file"]))
01245 {
01246 sendInfo($this->lng->txt("no_checkbox"), true);
01247 ilUtil::redirect("questionpool.php?cmd=export&ref_id=".$_GET["ref_id"]);
01248 }
01249
01250 if (count($_POST["file"]) > 1)
01251 {
01252 sendInfo($this->lng->txt("select_max_one_item"),true);
01253 ilUtil::redirect("questionpool.php?cmd=export&ref_id=".$_GET["ref_id"]);
01254 }
01255
01256
01257 $export_dir = $this->object->getExportDirectory();
01258 include_once "./classes/class.ilUtil.php";
01259 ilUtil::deliverFile($export_dir."/".$_POST["file"][0],
01260 $_POST["file"][0]);
01261 }
01262
01266 function confirmDeleteExportFileObject()
01267 {
01268 if(!isset($_POST["file"]))
01269 {
01270 sendInfo($this->lng->txt("no_checkbox"),true);
01271 ilUtil::redirect("questionpool.php?cmd=export&ref_id=".$_GET["ref_id"]);
01272 }
01273
01274
01275
01276
01277 $_SESSION["ilExportFiles"] = $_POST["file"];
01278
01279 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html", true);
01280
01281 sendInfo($this->lng->txt("info_delete_sure"));
01282
01283 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01284
01285
01286 $this->tpl->setCurrentBlock("table_header");
01287 $this->tpl->setVariable("TEXT",$this->lng->txt("objects"));
01288 $this->tpl->parseCurrentBlock();
01289
01290
01291 $counter = 0;
01292 foreach($_POST["file"] as $file)
01293 {
01294 $this->tpl->setCurrentBlock("table_row");
01295 $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
01296 $this->tpl->setVariable("TEXT_CONTENT", $file);
01297 $this->tpl->parseCurrentBlock();
01298 }
01299
01300
01301 $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
01302 $buttons = array( "cancelDeleteExportFile" => $this->lng->txt("cancel"),
01303 "deleteExportFile" => $this->lng->txt("confirm"));
01304 foreach ($buttons as $name => $value)
01305 {
01306 $this->tpl->setCurrentBlock("operation_btn");
01307 $this->tpl->setVariable("BTN_NAME",$name);
01308 $this->tpl->setVariable("BTN_VALUE",$value);
01309 $this->tpl->parseCurrentBlock();
01310 }
01311 }
01312
01313
01317 function cancelDeleteExportFileObject()
01318 {
01319 session_unregister("ilExportFiles");
01320 $this->ctrl->redirect($this, "export");
01321 }
01322
01323
01327 function deleteExportFileObject()
01328 {
01329 $export_dir = $this->object->getExportDirectory();
01330 foreach($_SESSION["ilExportFiles"] as $file)
01331 {
01332 $exp_file = $export_dir."/".$file;
01333 $exp_dir = $export_dir."/".substr($file, 0, strlen($file) - 4);
01334 if (@is_file($exp_file))
01335 {
01336 unlink($exp_file);
01337 }
01338 if (@is_dir($exp_dir))
01339 {
01340 ilUtil::delDir($exp_dir);
01341 }
01342 }
01343 $this->ctrl->redirect($this, "export");
01344 }
01345
01351 function importObject()
01352 {
01353 global $rbacsystem;
01354 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"]))
01355 {
01356 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
01357 }
01358 $this->getTemplateFile("import", "spl");
01359 $this->tpl->setVariable("FORMACTION", "adm_object.php?&ref_id=".$_GET["ref_id"]."&cmd=gateway&new_type=".$this->type);
01360 $this->tpl->setVariable("BTN_NAME", "uploadSpl");
01361 $this->tpl->setVariable("TXT_UPLOAD", $this->lng->txt("upload"));
01362 $this->tpl->setVariable("TXT_IMPORT_SPL", $this->lng->txt("import_spl"));
01363 $this->tpl->setVariable("TXT_SELECT_MODE", $this->lng->txt("select_mode"));
01364 $this->tpl->setVariable("TXT_SELECT_FILE", $this->lng->txt("select_file"));
01365 }
01366
01370 function uploadSplObject($redirect = true)
01371 {
01372 if ($_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK)
01373 {
01374 sendInfo($this->lng->txt("spl_select_file_for_import"));
01375 $this->importObject();
01376 return;
01377 }
01378 require_once "./survey/classes/class.ilObjSurveyQuestionPool.php";
01379
01380 $newObj = new ilObjSurveyQuestionPool();
01381
01382 $newObj->setType($_GET["new_type"]);
01383
01384 $newObj->setTitle("dummy");
01385
01386
01387
01388 $newObj->create(true);
01389
01390 $newObj->createReference();
01391
01392 $newObj->putInTree($_GET["ref_id"]);
01393
01394 $newObj->setPermissions($_GET["ref_id"]);
01395
01396 $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
01397
01398
01399 $newObj->createImportDirectory();
01400
01401
01402 $file = pathinfo($_FILES["xmldoc"]["name"]);
01403 $full_path = $newObj->getImportDirectory()."/".$_FILES["xmldoc"]["name"];
01404 ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"],
01405 $_FILES["xmldoc"]["name"], $full_path);
01406
01407
01408
01409 $qtiresult = $newObj->importObject($full_path);
01410
01411
01412
01413
01414
01415
01416
01417
01418
01419
01420
01421
01422
01423
01424
01425
01426 if ($redirect)
01427 {
01428 ilUtil::redirect("adm_object.php?".$this->link_params);
01429 }
01430 }
01431
01435 function createObject()
01436 {
01437 global $rbacsystem;
01438 $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
01439 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
01440 {
01441 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
01442 }
01443 else
01444 {
01445 $this->getTemplateFile("create", $new_type);
01446
01447 require_once("./survey/classes/class.ilObjSurvey.php");
01448
01449
01450 $data = array();
01451 $data["fields"] = array();
01452 $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
01453 $data["fields"]["desc"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["desc"]);
01454
01455 foreach ($data["fields"] as $key => $val)
01456 {
01457 $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
01458 $this->tpl->setVariable(strtoupper($key), $val);
01459
01460 if ($this->prepare_output)
01461 {
01462 $this->tpl->parseCurrentBlock();
01463 }
01464 }
01465
01466 $this->tpl->setVariable("FORMACTION", $this->getFormAction("save","adm_object.php?cmd=gateway&ref_id=".
01467 $_GET["ref_id"]."&new_type=".$new_type));
01468 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
01469 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
01470 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
01471 $this->tpl->setVariable("CMD_SUBMIT", "save");
01472 $this->tpl->setVariable("TARGET", $this->getTargetFrame("save"));
01473 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
01474
01475 $this->tpl->setVariable("TXT_IMPORT_SPL", $this->lng->txt("import_spl"));
01476 $this->tpl->setVariable("TXT_SPL_FILE", $this->lng->txt("spl_upload_file"));
01477 $this->tpl->setVariable("TXT_IMPORT", $this->lng->txt("import"));
01478 }
01479 }
01480
01484 function importFileObject()
01485 {
01486 if (strcmp($_FILES["xmldoc"]["tmp_name"], "") == 0)
01487 {
01488 sendInfo($this->lng->txt("spl_select_file_for_import"));
01489 $this->createObject();
01490 return;
01491 }
01492 $this->uploadSplObject(false);
01493 ilUtil::redirect($this->getReturnLocation("importFile",$this->ctrl->getTargetScript()."?".$this->link_params));
01494
01495 }
01496
01500 function &executeCommand()
01501 {
01502 $cmd = $this->ctrl->getCmd("questions");
01503 $next_class = $this->ctrl->getNextClass($this);
01504 $this->ctrl->setReturn($this, "questions");
01505 $q_type = ($_POST["sel_question_types"] != "")
01506 ? $_POST["sel_question_types"]
01507 : $_GET["sel_question_types"];
01508
01509
01510 switch($next_class)
01511 {
01512 case 'ilmdeditorgui':
01513 $this->setAdminTabs();
01514 include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
01515
01516 $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
01517 $md_gui->addObserver($this->object,'MDUpdateListener','General');
01518
01519 $this->ctrl->forwardCommand($md_gui);
01520 break;
01521
01522 case "surveynominalquestiongui":
01523 $this->ctrl->setParameterByClass("surveynominalquestiongui", "sel_question_types", $q_type);
01524 $q_gui =& SurveyQuestionGUI::_getQuestionGUI($q_type, $_GET["q_id"]);
01525 $q_gui->object->setObjId($this->object->getId());
01526 $q_gui->setQuestionTabs();
01527 $ret =& $this->ctrl->forwardCommand($q_gui);
01528 break;
01529
01530 case "surveyordinalquestiongui":
01531 $this->ctrl->setParameterByClass("surveyordinalquestiongui", "sel_question_types", $q_type);
01532 $q_gui =& SurveyQuestionGUI::_getQuestionGUI($q_type, $_GET["q_id"]);
01533 $q_gui->object->setObjId($this->object->getId());
01534 $q_gui->setQuestionTabs();
01535 $ret =& $this->ctrl->forwardCommand($q_gui);
01536 break;
01537
01538 case "surveymetricquestiongui":
01539 $this->ctrl->setParameterByClass("surveymetricquestiongui", "sel_question_types", $q_type);
01540 $q_gui =& SurveyQuestionGUI::_getQuestionGUI($q_type, $_GET["q_id"]);
01541 $q_gui->object->setObjId($this->object->getId());
01542 $q_gui->setQuestionTabs();
01543 $ret =& $this->ctrl->forwardCommand($q_gui);
01544 break;
01545
01546 case "surveytextquestiongui":
01547 $this->ctrl->setParameterByClass("surveytextquestiongui", "sel_question_types", $q_type);
01548 $q_gui =& SurveyQuestionGUI::_getQuestionGUI($q_type, $_GET["q_id"]);
01549 $q_gui->object->setObjId($this->object->getId());
01550 $q_gui->setQuestionTabs();
01551 $ret =& $this->ctrl->forwardCommand($q_gui);
01552 break;
01553
01554 default:
01555 if (($cmd != "createQuestion") and (!$_GET["calling_survey"]) and (!$_GET["new_for_survey"]))
01556 {
01557 $this->setAdminTabs();
01558 }
01559 $cmd.= "Object";
01560 $ret =& $this->$cmd();
01561 break;
01562 }
01563 }
01564
01568 function &createQuestionObject()
01569 {
01570 $q_gui =& SurveyQuestionGUI::_getQuestionGUI($_POST["sel_question_types"]);
01571 $q_gui->object->setObjId($this->object->getId());
01572 $this->ctrl->setCmdClass(get_class($q_gui));
01573 $this->ctrl->setCmd("editQuestion");
01574
01575 $ret =& $this->executeCommand();
01576 return $ret;
01577 }
01578
01579 function prepareOutput()
01580 {
01581 $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
01582 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
01583 $title = $this->object->getTitle();
01584
01585
01586 sendInfo();
01587
01588 if (!empty($title))
01589 {
01590 $this->tpl->setVariable("HEADER", $title);
01591 }
01592 if (!defined("ILIAS_MODULE"))
01593 {
01594 $this->setAdminTabs($_POST["new_type"]);
01595 }
01596 $this->setLocator();
01597
01598 }
01599
01603 function &editQuestionForSurveyObject()
01604 {
01605
01606 $q_gui =& SurveyQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
01607 $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $q_gui->getQuestionType());
01608 $this->ctrl->setParameterByClass(get_class($q_gui), "q_id", $_GET["q_id"]);
01609 $this->ctrl->setCmdClass(get_class($q_gui));
01610 $this->ctrl->setCmd("editQuestion");
01611 $ret =& $this->executeCommand();
01612 return $ret;
01613 }
01614
01618 function &createQuestionForSurveyObject()
01619 {
01620
01621 $q_gui =& SurveyQuestionGUI::_getQuestionGUI($_GET["sel_question_types"]);
01622 $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $q_gui->getQuestionType());
01623 $this->ctrl->setCmdClass(get_class($q_gui));
01624 $this->ctrl->setCmd("editQuestion");
01625 $ret =& $this->executeCommand();
01626 return $ret;
01627 }
01628
01632 function &previewObject()
01633 {
01634 $q_gui =& SurveyQuestionGUI::_getQuestionGUI("", $_GET["preview"]);
01635 $_GET["q_id"] = $_GET["preview"];
01636 $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $q_gui->getQuestionType());
01637 $this->ctrl->setParameterByClass(get_class($q_gui), "q_id", $_GET["preview"]);
01638 $this->ctrl->setCmdClass(get_class($q_gui));
01639 $this->ctrl->setCmd("preview");
01640 $ret =& $this->executeCommand();
01641 return $ret;
01642 }
01643
01649 function getTabs(&$tabs_gui)
01650 {
01651 $tabs_gui->getTargetsByObjectType($this, "spl");
01652
01653 $tabs_gui->addTarget("meta_data",
01654 $this->ctrl->getLinkTargetByClass('ilmdeditorgui',''),
01655 "meta_data", get_class($this));
01656 }
01657
01658
01659 }
01660 ?>