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 include_once "./classes/class.ilObjectGUI.php";
00025 include_once "./survey/classes/inc.SurveyConstants.php";
00026
00041 class ilObjSurveyQuestionPoolGUI extends ilObjectGUI
00042 {
00043 var $defaultscript;
00044
00049 function ilObjSurveyQuestionPoolGUI()
00050 {
00051 global $lng, $ilCtrl;
00052
00053 $this->type = "spl";
00054 $lng->loadLanguageModule("survey");
00055 $this->ctrl =& $ilCtrl;
00056 $this->ctrl->saveParameter($this, array("ref_id", "calling_survey", "new_for_survey"));
00057
00058 $this->ilObjectGUI("",$_GET["ref_id"], true, false);
00059 }
00060
00064 function &executeCommand()
00065 {
00066 $this->prepareOutput();
00067 $cmd = $this->ctrl->getCmd("questions");
00068 $next_class = $this->ctrl->getNextClass($this);
00069 $this->ctrl->setReturn($this, "questions");
00070 $q_type = ($_POST["sel_question_types"] != "")
00071 ? $_POST["sel_question_types"]
00072 : $_GET["sel_question_types"];
00073 switch($next_class)
00074 {
00075 case 'ilmdeditorgui':
00076 include_once "./Services/MetaData/classes/class.ilMDEditorGUI.php";
00077 $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
00078 $md_gui->addObserver($this->object,'MDUpdateListener','General');
00079
00080 $this->ctrl->forwardCommand($md_gui);
00081 break;
00082
00083 case "surveynominalquestiongui":
00084 $this->ctrl->setParameterByClass("surveynominalquestiongui", "sel_question_types", $q_type);
00085 include_once "./survey/classes/class.SurveyQuestionGUI.php";
00086 $q_gui =& SurveyQuestionGUI::_getQuestionGUI($q_type, $_GET["q_id"]);
00087 $q_gui->object->setObjId($this->object->getId());
00088 $q_gui->setQuestionTabs();
00089 $ret =& $this->ctrl->forwardCommand($q_gui);
00090 break;
00091
00092 case "surveyordinalquestiongui":
00093 $this->ctrl->setParameterByClass("surveyordinalquestiongui", "sel_question_types", $q_type);
00094 include_once "./survey/classes/class.SurveyQuestionGUI.php";
00095 $q_gui =& SurveyQuestionGUI::_getQuestionGUI($q_type, $_GET["q_id"]);
00096 $q_gui->object->setObjId($this->object->getId());
00097 $q_gui->setQuestionTabs();
00098 $ret =& $this->ctrl->forwardCommand($q_gui);
00099 break;
00100
00101 case "surveymetricquestiongui":
00102 $this->ctrl->setParameterByClass("surveymetricquestiongui", "sel_question_types", $q_type);
00103 include_once "./survey/classes/class.SurveyQuestionGUI.php";
00104 $q_gui =& SurveyQuestionGUI::_getQuestionGUI($q_type, $_GET["q_id"]);
00105 $q_gui->object->setObjId($this->object->getId());
00106 $q_gui->setQuestionTabs();
00107 $ret =& $this->ctrl->forwardCommand($q_gui);
00108 break;
00109
00110 case "surveytextquestiongui":
00111 $this->ctrl->setParameterByClass("surveytextquestiongui", "sel_question_types", $q_type);
00112 include_once "./survey/classes/class.SurveyQuestionGUI.php";
00113 $q_gui =& SurveyQuestionGUI::_getQuestionGUI($q_type, $_GET["q_id"]);
00114 $q_gui->object->setObjId($this->object->getId());
00115 $q_gui->setQuestionTabs();
00116 $ret =& $this->ctrl->forwardCommand($q_gui);
00117 break;
00118
00119 case 'ilpermissiongui':
00120 include_once("./classes/class.ilPermissionGUI.php");
00121 $perm_gui =& new ilPermissionGUI($this);
00122 $ret =& $this->ctrl->forwardCommand($perm_gui);
00123 break;
00124
00125 default:
00126 $cmd.= "Object";
00127 $ret =& $this->$cmd();
00128 break;
00129 }
00130 if (strtolower($_GET["baseClass"]) != "iladministrationgui" &&
00131 $this->getCreationMode() != true)
00132 {
00133 $this->tpl->show();
00134 }
00135 }
00136
00142 function cancelObject()
00143 {
00144 sendInfo($this->lng->txt("msg_cancel"),true);
00145 ilUtil::redirect("repository.php?cmd=frameset&ref_id=".$_GET["ref_id"]);
00146 }
00147
00148
00153 function saveObject()
00154 {
00155 global $rbacadmin;
00156
00157
00158 $newObj = parent::saveObject();
00159
00160
00161 sendInfo($this->lng->txt("object_added"),true);
00162
00163 ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
00164 "&baseClass=ilObjSurveyQuestionPoolGUI");
00165 }
00166
00175 function cancelAction($question_id = "")
00176 {
00177 $this->ctrl->redirect($this, "questions");
00178 }
00179
00183 function propertiesObject()
00184 {
00185 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_properties.html", true);
00186 $this->tpl->setCurrentBlock("adm_content");
00187 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00188 $this->tpl->setVariable("HEADING_GENERAL", $this->lng->txt("spl_general_properties"));
00189 $this->tpl->setVariable("PROPERTY_ONLINE", $this->lng->txt("spl_online_property"));
00190 $this->tpl->setVariable("PROPERTY_ONLINE_DESCRIPTION", $this->lng->txt("spl_online_property_description"));
00191 if ($this->object->getOnline() == 1)
00192 {
00193 $this->tpl->setVariable("PROPERTY_ONLINE_CHECKED", " checked=\"checked\"");
00194 }
00195 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00196 $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
00197 $this->tpl->parseCurrentBlock();
00198 }
00199
00203 function savePropertiesObject()
00204 {
00205 $qpl_online = $_POST["online"];
00206 if (strlen($qpl_online) == 0) $qpl_online = "0";
00207 $this->object->setOnline($qpl_online);
00208 $this->object->saveToDb();
00209 sendInfo($this->lng->txt("saved_successfully"), true);
00210 $this->ctrl->redirect($this, "properties");
00211 }
00212
00213
00221 function copyObject()
00222 {
00223
00224 $checked_questions = array();
00225 foreach ($_POST as $key => $value)
00226 {
00227 if (preg_match("/cb_(\d+)/", $key, $matches))
00228 {
00229 array_push($checked_questions, $matches[1]);
00230 }
00231 }
00232
00233
00234 if (count($checked_questions) > 0)
00235 {
00236 $_SESSION["spl_copied_questions"] = join($checked_questions, ",");
00237 }
00238 else if (count($checked_questions) == 0)
00239 {
00240 sendInfo($this->lng->txt("qpl_copy_select_none"));
00241 $_SESSION["spl_copied_questions"] = "";
00242 }
00243 $this->questionsObject();
00244 }
00245
00253 function duplicateObject()
00254 {
00255
00256 $checked_questions = array();
00257 foreach ($_POST as $key => $value) {
00258 if (preg_match("/cb_(\d+)/", $key, $matches)) {
00259 array_push($checked_questions, $matches[1]);
00260 }
00261 }
00262
00263 if (count($checked_questions) > 0) {
00264 foreach ($checked_questions as $key => $value) {
00265 $this->object->duplicateQuestion($value);
00266 }
00267 } elseif (count($checked_questions) == 0) {
00268 sendInfo($this->lng->txt("qpl_duplicate_select_none"));
00269 }
00270 $this->questionsObject();
00271 }
00272
00276 function exportQuestionsObject()
00277 {
00278
00279 $checked_questions = array();
00280 foreach ($_POST as $key => $value) {
00281 if (preg_match("/cb_(\d+)/", $key, $matches)) {
00282 array_push($checked_questions, $matches[1]);
00283 }
00284 }
00285
00286
00287 if (count($checked_questions) > 0)
00288 {
00289 $this->createExportFileObject($checked_questions);
00290 }
00291 else
00292 {
00293 sendInfo($this->lng->txt("qpl_export_select_none"));
00294 $this->questionsObject();
00295 }
00296 }
00297
00305 function deleteQuestionsObject()
00306 {
00307 global $rbacsystem;
00308
00309 sendInfo();
00310
00311 $checked_questions = array();
00312 foreach ($_POST as $key => $value) {
00313 if (preg_match("/cb_(\d+)/", $key, $matches)) {
00314 array_push($checked_questions, $matches[1]);
00315 }
00316 }
00317
00318 if (count($checked_questions) > 0) {
00319 if ($rbacsystem->checkAccess('write', $this->ref_id)) {
00320 sendInfo($this->lng->txt("qpl_confirm_delete_questions"));
00321 } else {
00322 sendInfo($this->lng->txt("qpl_delete_rbac_error"));
00323 $this->questionsObject();
00324 return;
00325 }
00326 } elseif (count($checked_questions) == 0) {
00327 sendInfo($this->lng->txt("qpl_delete_select_none"));
00328 $this->questionsObject();
00329 return;
00330 }
00331 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_confirm_delete_questions.html", true);
00332 $whereclause = join($checked_questions, " OR survey_question.question_id = ");
00333 $whereclause = " AND (survey_question.question_id = " . $whereclause . ")";
00334 $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";
00335 $query_result = $this->ilias->db->query($query);
00336 $colors = array("tblrow1", "tblrow2");
00337 $counter = 0;
00338 if ($query_result->numRows() > 0)
00339 {
00340 while ($data = $query_result->fetchRow(DB_FETCHMODE_OBJECT))
00341 {
00342 if (in_array($data->question_id, $checked_questions))
00343 {
00344 $this->tpl->setCurrentBlock("row");
00345 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
00346 $this->tpl->setVariable("TXT_TITLE", $data->title);
00347 $this->tpl->setVariable("TXT_DESCRIPTION", $data->description);
00348 $this->tpl->setVariable("TXT_TYPE", $this->lng->txt($data->type_tag));
00349 $this->tpl->parseCurrentBlock();
00350 $counter++;
00351 }
00352 }
00353 }
00354 foreach ($checked_questions as $id)
00355 {
00356 $this->tpl->setCurrentBlock("hidden");
00357 $this->tpl->setVariable("HIDDEN_NAME", "id_$id");
00358 $this->tpl->setVariable("HIDDEN_VALUE", "1");
00359 $this->tpl->parseCurrentBlock();
00360 }
00361
00362 $this->tpl->setCurrentBlock("adm_content");
00363 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
00364 $this->tpl->setVariable("TXT_DESCRIPTION", $this->lng->txt("description"));
00365 $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("question_type"));
00366 $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
00367 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
00368 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00369 $this->tpl->parseCurrentBlock();
00370 }
00371
00375 function confirmDeleteQuestionsObject()
00376 {
00377
00378 sendInfo($this->lng->txt("qpl_questions_deleted"), true);
00379 $checked_questions = array();
00380 foreach ($_POST as $key => $value) {
00381 if (preg_match("/id_(\d+)/", $key, $matches)) {
00382 array_push($checked_questions, $matches[1]);
00383 }
00384 }
00385
00386 foreach ($checked_questions as $key => $value) {
00387 $this->object->removeQuestion($value);
00388 }
00389 $this->ctrl->redirect($this, "questions");
00390 }
00391
00395 function cancelDeleteQuestionsObject()
00396 {
00397
00398 $this->ctrl->redirect($this, "questions");
00399 }
00400
00408 function pasteObject()
00409 {
00410 sendInfo();
00411
00412
00413 $checked_questions = array();
00414 foreach ($_POST as $key => $value) {
00415 if (preg_match("/cb_(\d+)/", $key, $matches)) {
00416 array_push($checked_questions, $matches[1]);
00417 }
00418 }
00419
00420
00421 if (strcmp($_SESSION["spl_copied_questions"], "") != 0)
00422 {
00423 $copied_questions = split("/,/", $_SESSION["spl_copied_questions"]);
00424 sendInfo($this->lng->txt("qpl_past_questions_confirmation"));
00425 }
00426 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_confirm_paste_questions.html", true);
00427 $questions_info =& $this->object->getQuestionsInfo($copied_questions);
00428 $colors = array("tblrow1", "tblrow2");
00429 $counter = 0;
00430 foreach ($questions_info as $data)
00431 {
00432 $this->tpl->setCurrentBlock("row");
00433 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
00434 $this->tpl->setVariable("TXT_TITLE", $data->title);
00435 $this->tpl->setVariable("TXT_DESCRIPTION", $data->description);
00436 $this->tpl->setVariable("TXT_TYPE", $this->lng->txt($data->type_tag));
00437 $this->tpl->parseCurrentBlock();
00438 $counter++;
00439 }
00440 foreach ($questions_info as $data)
00441 {
00442 $this->tpl->setCurrentBlock("hidden");
00443 $this->tpl->setVariable("HIDDEN_NAME", "id_$data->question_id");
00444 $this->tpl->setVariable("HIDDEN_VALUE", $data->question_id);
00445 $this->tpl->parseCurrentBlock();
00446 }
00447
00448 $this->tpl->setCurrentBlock("adm_content");
00449 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
00450 $this->tpl->setVariable("TXT_DESCRIPTION", $this->lng->txt("description"));
00451 $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("question_type"));
00452 $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
00453 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
00454 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00455 $this->tpl->parseCurrentBlock();
00456 }
00457
00461 function confirmPasteQuestionsObject()
00462 {
00463
00464 sendInfo($this->lng->txt("qpl_questions_pasted"), true);
00465 $checked_questions = array();
00466 foreach ($_POST as $key => $value) {
00467 if (preg_match("/id_(\d+)/", $key, $matches)) {
00468 array_push($checked_questions, $matches[1]);
00469 }
00470 }
00471 foreach ($checked_questions as $key => $value) {
00472 $this->object->paste($value);
00473 }
00474
00475 $this->ctrl->redirect($this, "questions");
00476 }
00477
00481 function cancelPasteQuestionsObject()
00482 {
00483
00484 $this->ctrl->redirect($this, "questions");
00485 }
00486
00490 function cancelDeletePhraseObject()
00491 {
00492 $this->ctrl->redirect($this, "phrases");
00493 }
00494
00498 function confirmDeletePhraseObject()
00499 {
00500 $phrases = array();
00501 foreach ($_POST as $key => $value)
00502 {
00503 if (preg_match("/phrase_(\d+)/", $key, $matches))
00504 {
00505 array_push($phrases, $matches[1]);
00506 }
00507 }
00508 $this->object->deletePhrases($phrases);
00509 sendInfo($this->lng->txt("qpl_phrases_deleted"), true);
00510 $this->ctrl->redirect($this, "phrases");
00511 }
00512
00521 function deletePhrasesForm($checked_phrases)
00522 {
00523 sendInfo();
00524 include_once "./survey/classes/class.SurveyOrdinalQuestion.php";
00525 $ordinal = new SurveyOrdinalQuestion();
00526 $phrases =& $ordinal->getAvailablePhrases(1);
00527 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_confirm_delete_phrases.html", true);
00528 $colors = array("tblrow1", "tblrow2");
00529 $counter = 0;
00530 foreach ($checked_phrases as $id)
00531 {
00532 $this->tpl->setCurrentBlock("row");
00533 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter++ % 2]);
00534 $this->tpl->setVariable("PHRASE_TITLE", $phrases[$id]["title"]);
00535 $categories =& $ordinal->getCategoriesForPhrase($id);
00536 $this->tpl->setVariable("PHRASE_CONTENT", join($categories, ", "));
00537 $this->tpl->parseCurrentBlock();
00538 $this->tpl->setCurrentBlock("hidden");
00539 $this->tpl->setVariable("HIDDEN_NAME", "phrase_$id");
00540 $this->tpl->setVariable("HIDDEN_VALUE", "1");
00541 $this->tpl->parseCurrentBlock();
00542 }
00543
00544 $this->tpl->setCurrentBlock("adm_content");
00545 $this->tpl->setVariable("TEXT_PHRASE_TITLE", $this->lng->txt("phrase"));
00546 $this->tpl->setVariable("TEXT_PHRASE_CONTENT", $this->lng->txt("categories"));
00547 $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
00548 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
00549 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00550 $this->tpl->parseCurrentBlock();
00551 }
00552
00560 function deletePhraseObject()
00561 {
00562 sendInfo();
00563
00564 $checked_phrases = array();
00565 foreach ($_POST as $key => $value)
00566 {
00567 if (preg_match("/phrase_(\d+)/", $key, $matches))
00568 {
00569 array_push($checked_phrases, $matches[1]);
00570 }
00571 }
00572 if (count($checked_phrases))
00573 {
00574 sendInfo($this->lng->txt("qpl_confirm_delete_phrases"));
00575 $this->deletePhrasesForm($checked_phrases);
00576 return;
00577 }
00578 else
00579 {
00580 sendInfo($this->lng->txt("qpl_delete_phrase_select_none"));
00581 $this->phrasesObject();
00582 return;
00583 }
00584
00585 $this->tpl->setCurrentBlock("obligatory");
00586 $this->tpl->setVariable("TEXT_OBLIGATORY", $this->lng->txt("obligatory"));
00587 $this->tpl->setVariable("CHECKED_OBLIGATORY", " checked=\"checked\"");
00588 $this->tpl->parseCurrentBlock();
00589 $this->tpl->setCurrentBlock("adm_content");
00590 $this->tpl->setVariable("DEFINE_QUESTIONBLOCK_HEADING", $this->lng->txt("define_questionblock"));
00591 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
00592 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00593 $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
00594 $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
00595 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00596 $this->tpl->parseCurrentBlock();
00597 }
00598
00604 function phrasesObject()
00605 {
00606 global $rbacsystem;
00607
00608 if ($rbacsystem->checkAccess("write", $this->object->getRefId()))
00609 {
00610 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_phrases.html", true);
00611 include_once "./survey/classes/class.SurveyOrdinalQuestion.php";
00612 $ordinal = new SurveyOrdinalQuestion();
00613 $phrases =& $ordinal->getAvailablePhrases(1);
00614 if (count($phrases))
00615 {
00616 include_once "./classes/class.ilUtil.php";
00617 $colors = array("tblrow1", "tblrow2");
00618 $counter = 0;
00619 foreach ($phrases as $phrase_id => $phrase_array)
00620 {
00621 $this->tpl->setCurrentBlock("phraserow");
00622 $this->tpl->setVariable("PHRASE_ID", $phrase_id);
00623 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter++ % 2]);
00624 $this->tpl->setVariable("PHRASE_TITLE", $phrase_array["title"]);
00625 $categories =& $ordinal->getCategoriesForPhrase($phrase_id);
00626 $this->tpl->setVariable("PHRASE_CONTENT", join($categories, ", "));
00627 $this->tpl->parseCurrentBlock();
00628 }
00629 $counter++;
00630 $this->tpl->setCurrentBlock("selectall");
00631 $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
00632 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter++ % 2]);
00633 $this->tpl->parseCurrentBlock();
00634 $this->tpl->setCurrentBlock("Footer");
00635 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\">");
00636 $this->tpl->setVariable("TEXT_DELETE", $this->lng->txt("delete"));
00637 $this->tpl->parseCurrentBlock();
00638 }
00639 else
00640 {
00641 $this->tpl->setCurrentBlock("Emptytable");
00642 $this->tpl->setVariable("TEXT_EMPTYTABLE", $this->lng->txt("no_user_phrases_defined"));
00643 $this->tpl->parseCurrentBlock();
00644 }
00645 $this->tpl->setCurrentBlock("adm_content");
00646 $this->tpl->setVariable("INTRODUCTION_MANAGE_PHRASES", $this->lng->txt("introduction_manage_phrases"));
00647 $this->tpl->setVariable("TEXT_PHRASE_TITLE", $this->lng->txt("phrase"));
00648 $this->tpl->setVariable("TEXT_PHRASE_CONTENT", $this->lng->txt("categories"));
00649 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00650 $this->tpl->parseCurrentBlock();
00651 }
00652 else
00653 {
00654 sendInfo($this->lng->txt("cannot_manage_phrases"));
00655 }
00656 }
00657
00661 function importQuestionsObject()
00662 {
00663 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_import_question.html", true);
00664 $this->tpl->setCurrentBlock("adm_content");
00665 $this->tpl->setVariable("TEXT_IMPORT_QUESTION", $this->lng->txt("import_question"));
00666 $this->tpl->setVariable("TEXT_SELECT_FILE", $this->lng->txt("select_file"));
00667 $this->tpl->setVariable("TEXT_UPLOAD", $this->lng->txt("upload"));
00668 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00669 $this->tpl->parseCurrentBlock();
00670 }
00671
00675 function uploadQuestionsObject()
00676 {
00677
00678 $source = $_FILES["qtidoc"]["tmp_name"];
00679 $error = 0;
00680 if (($source == 'none') || (!$source) || $_FILES["qtidoc"]["error"] > UPLOAD_ERR_OK)
00681 {
00682
00683 $error = 1;
00684 }
00685
00686 if (strcmp($_FILES["qtidoc"]["type"], "text/xml") != 0)
00687 {
00688
00689 $error = 1;
00690 }
00691 if (!$error)
00692 {
00693
00694
00695 $this->object->createImportDirectory();
00696
00697
00698 $full_path = $this->object->getImportDirectory()."/".$_FILES["qtidoc"]["name"];
00699
00700 include_once "./classes/class.ilUtil.php";
00701 ilUtil::moveUploadedFile($_FILES["qtidoc"]["tmp_name"],
00702 $_FILES["qtidoc"]["name"], $full_path);
00703
00704 $source = $full_path;
00705
00706 $fh = fopen($source, "r") or die("");
00707 $xml = fread($fh, filesize($source));
00708 fclose($fh) or die("");
00709 unlink($source);
00710 if (preg_match_all("/(<item[^>]*>.*?<\/item>)/si", $xml, $matches))
00711 {
00712 foreach ($matches[1] as $index => $item)
00713 {
00714 $question = "";
00715 if (preg_match("/<qticomment>Questiontype\=(.*?)<\/qticomment>/is", $item, $questiontype))
00716 {
00717 include_once "./survey/classes/class.SurveyNominalQuestion.php";
00718 include_once "./survey/classes/class.SurveyOrdinalQuestion.php";
00719 include_once "./survey/classes/class.SurveyMetricQuestion.php";
00720 include_once "./survey/classes/class.SurveyTextQuestion.php";
00721 switch ($questiontype[1])
00722 {
00723 case NOMINAL_QUESTION_IDENTIFIER:
00724 $question = new SurveyNominalQuestion();
00725 break;
00726 case ORDINAL_QUESTION_IDENTIFIER:
00727 $question = new SurveyOrdinalQuestion();
00728 break;
00729 case METRIC_QUESTION_IDENTIFIER:
00730 $question = new SurveyMetricQuestion();
00731 break;
00732 case TEXT_QUESTION_IDENTIFIER:
00733 $question = new SurveyTextQuestion();
00734 break;
00735 }
00736 if ($question)
00737 {
00738 $question->setObjId($this->object->getId());
00739 if ($question->from_xml("<questestinterop>$item</questestinterop>"))
00740 {
00741 $question->saveToDb();
00742 }
00743 else
00744 {
00745 $this->ilias->raiseError($this->lng->txt("error_importing_question"), $this->ilias->error_obj->MESSAGE);
00746 }
00747 }
00748 }
00749 }
00750 }
00751 }
00752 $this->ctrl->redirect($this, "questions");
00753 }
00754
00755 function filterObject()
00756 {
00757 $this->questionsObject();
00758 }
00759
00760 function resetObject()
00761 {
00762 $this->questionsObject();
00763 }
00764
00769 function questionsObject()
00770 {
00771 global $rbacsystem;
00772 global $ilUser;
00773
00774 $lastquestiontype = $ilUser->getPref("svy_lastquestiontype");
00775 $filter_text = "";
00776 $filter_type = "";
00777 if (count($_POST))
00778 {
00779 $filter_text = $_POST["filter_text"];
00780 $filter_type = $_POST["sel_filter_type"];
00781 }
00782 else
00783 {
00784 $filter_text = $_GET["filter_text"];
00785 $filter_type = $_GET["sel_filter_type"];
00786 }
00787
00788 if (strcmp($this->ctrl->getCmd(), "reset") == 0)
00789 {
00790 $filter_text = "";
00791 $filter_type = "";
00792 }
00793 else
00794 {
00795 $this->ctrl->setParameter($this, "filter_text", $filter_text);
00796 $this->ctrl->setParameter($this, "sel_filter_type", $filter_type);
00797 }
00798
00799 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_questions.html", true);
00800 if ($rbacsystem->checkAccess('write', $this->ref_id)) {
00801 $this->tpl->addBlockFile("CREATE_QUESTION", "create_question", "tpl.il_svy_qpl_create_new_question.html", true);
00802 $this->tpl->addBlockFile("A_BUTTONS", "a_buttons", "tpl.il_svy_qpl_action_buttons.html", true);
00803 }
00804 $this->tpl->addBlockFile("FILTER_QUESTION_MANAGER", "filter_questions", "tpl.il_svy_qpl_filter_questions.html", true);
00805
00806
00807 $filter_fields = array(
00808 "title" => $this->lng->txt("title"),
00809 "description" => $this->lng->txt("description"),
00810 "author" => $this->lng->txt("author"),
00811 );
00812 $this->tpl->setCurrentBlock("filterrow");
00813 foreach ($filter_fields as $key => $value)
00814 {
00815 $this->tpl->setVariable("VALUE_FILTER_TYPE", "$key");
00816 $this->tpl->setVariable("NAME_FILTER_TYPE", "$value");
00817 if (!$_POST["cmd"]["reset"])
00818 {
00819 if (strcmp($filter_type, $key) == 0)
00820 {
00821 $this->tpl->setVariable("VALUE_FILTER_SELECTED", " selected=\"selected\"");
00822 }
00823 }
00824 $this->tpl->parseCurrentBlock();
00825 }
00826
00827 $this->tpl->setCurrentBlock("filter_questions");
00828 $this->tpl->setVariable("FILTER_TEXT", $this->lng->txt("filter"));
00829 $this->tpl->setVariable("TEXT_FILTER_BY", $this->lng->txt("by"));
00830 if (strcmp($this->ctrl->getCmd(), "reset") != 0)
00831 {
00832 $this->tpl->setVariable("VALUE_FILTER_TEXT", $filter_text);
00833 }
00834 $this->tpl->setVariable("VALUE_SUBMIT_FILTER", $this->lng->txt("set_filter"));
00835 $this->tpl->setVariable("VALUE_RESET_FILTER", $this->lng->txt("reset_filter"));
00836 $this->tpl->parseCurrentBlock();
00837
00838 $startrow = 0;
00839 if ($_GET["prevrow"])
00840 {
00841 $startrow = $_GET["prevrow"];
00842 }
00843 if ($_GET["nextrow"])
00844 {
00845 $startrow = $_GET["nextrow"];
00846 }
00847 if ($_GET["startrow"])
00848 {
00849 $startrow = $_GET["startrow"];
00850 }
00851 if (!$_GET["sort"])
00852 {
00853
00854 $_GET["sort"] = array("title" => "ASC");
00855 }
00856 $table = $this->object->getQuestionsTable($_GET["sort"], $filter_text, $filter_type, $startrow);
00857 $colors = array("tblrow1", "tblrow2");
00858 $counter = 0;
00859 $last_questionblock_id = 0;
00860 $editable = $rbacsystem->checkAccess('write', $this->ref_id);
00861 foreach ($table["rows"] as $data)
00862 {
00863 $this->tpl->setCurrentBlock("checkable");
00864 $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
00865 $this->tpl->parseCurrentBlock();
00866 if ($data["complete"] == 0)
00867 {
00868 $this->tpl->setCurrentBlock("qpl_warning");
00869 include_once "./classes/class.ilUtil.php";
00870 $this->tpl->setVariable("IMAGE_WARNING", ilUtil::getImagePath("warning.gif"));
00871 $this->tpl->setVariable("ALT_WARNING", $this->lng->txt("warning_question_not_complete"));
00872 $this->tpl->setVariable("TITLE_WARNING", $this->lng->txt("warning_question_not_complete"));
00873 $this->tpl->parseCurrentBlock();
00874 }
00875 $this->tpl->setCurrentBlock("QTab");
00876 include_once "./survey/classes/class.SurveyQuestionGUI.php";
00877 $class = strtolower(SurveyQuestionGUI::_getGUIClassNameForId($data["question_id"]));
00878 $this->ctrl->setParameterByClass($class, "q_id", $data["question_id"]);
00879 $sel_question_types = "";
00880 switch ($class)
00881 {
00882 case "surveynominalquestiongui":
00883 $sel_question_types = "qt_nominal";
00884 break;
00885 case "surveyordinalquestiongui":
00886 $sel_question_types = "qt_ordinal";
00887 break;
00888 case "surveymetricquestiongui":
00889 $sel_question_types = "qt_metric";
00890 break;
00891 case "surveytextquestiongui":
00892 $sel_question_types = "qt_text";
00893 break;
00894 }
00895 $this->ctrl->setParameterByClass($class, "sel_question_types", $sel_question_types);
00896 if ($editable)
00897 {
00898 $this->tpl->setVariable("EDIT", "[<a href=\"" . $this->ctrl->getLinkTargetByClass($class, "editQuestion") . "\">" . $this->lng->txt("edit") . "</a>]");
00899 }
00900 $this->tpl->setVariable("QUESTION_TITLE", "<strong>" . $data["title"] . "</strong>");
00901
00902 $this->tpl->setVariable("PREVIEW", "[<a href=\"" . $this->ctrl->getLinkTargetByClass($class, "preview") . "\">" . $this->lng->txt("preview") . "</a>]");
00903 $this->tpl->setVariable("QUESTION_DESCRIPTION", $data["description"]);
00904 $this->tpl->setVariable("QUESTION_PREVIEW", $this->lng->txt("preview"));
00905 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($data["type_tag"]));
00906 $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]);
00907 include_once "./classes/class.ilFormat.php";
00908 $this->tpl->setVariable("QUESTION_CREATED", ilFormat::formatDate(ilFormat::ftimestamp2dateDB($data["created"]), "date"));
00909 $this->tpl->setVariable("QUESTION_UPDATED", ilFormat::formatDate(ilFormat::ftimestamp2dateDB($data["TIMESTAMP14"]), "date"));
00910 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
00911 $this->tpl->parseCurrentBlock();
00912 $counter++;
00913 }
00914
00915 if ($table["rowcount"] > count($table["rows"]))
00916 {
00917 $nextstep = $table["nextrow"] + $table["step"];
00918 if ($nextstep > $table["rowcount"])
00919 {
00920 $nextstep = $table["rowcount"];
00921 }
00922 $sort = "";
00923 if (is_array($_GET["sort"]))
00924 {
00925 $key = key($_GET["sort"]);
00926 $sort = "&sort[$key]=" . $_GET["sort"]["$key"];
00927 }
00928 $counter = 1;
00929 for ($i = 0; $i < $table["rowcount"]; $i += $table["step"])
00930 {
00931 $this->tpl->setCurrentBlock("pages");
00932 if ($table["startrow"] == $i)
00933 {
00934 $this->tpl->setVariable("PAGE_NUMBER", "<span class=\"inactivepage\">$counter</span>");
00935 }
00936 else
00937 {
00938 $this->tpl->setVariable("PAGE_NUMBER", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "$sort&nextrow=$i" . "\">$counter</a>");
00939 }
00940 $this->tpl->parseCurrentBlock();
00941 $counter++;
00942 }
00943 $this->tpl->setCurrentBlock("navigation_bottom");
00944 $this->tpl->setVariable("TEXT_ITEM", $this->lng->txt("item"));
00945 $this->tpl->setVariable("TEXT_ITEM_START", $table["startrow"] + 1);
00946 $end = $table["startrow"] + $table["step"];
00947 if ($end > $table["rowcount"])
00948 {
00949 $end = $table["rowcount"];
00950 }
00951 $this->tpl->setVariable("TEXT_ITEM_END", $end);
00952 $this->tpl->setVariable("TEXT_OF", strtolower($this->lng->txt("of")));
00953 $this->tpl->setVariable("TEXT_ITEM_COUNT", $table["rowcount"]);
00954 $this->tpl->setVariable("TEXT_PREVIOUS", $this->lng->txt("previous"));
00955 $this->tpl->setVariable("TEXT_NEXT", $this->lng->txt("next"));
00956 $this->tpl->setVariable("HREF_PREV_ROWS", $this->ctrl->getLinkTarget($this, "questions") . "$sort&prevrow=" . $table["prevrow"]);
00957 $this->tpl->setVariable("HREF_NEXT_ROWS", $this->ctrl->getLinkTarget($this, "questions") . "$sort&nextrow=" . $table["nextrow"]);
00958 $this->tpl->parseCurrentBlock();
00959 }
00960
00961
00962 if ($counter == 0)
00963 {
00964 $this->tpl->setCurrentBlock("Emptytable");
00965 $this->tpl->setVariable("TEXT_EMPTYTABLE", $this->lng->txt("no_questions_available"));
00966 $this->tpl->parseCurrentBlock();
00967 }
00968 else
00969 {
00970
00971 if ($rbacsystem->checkAccess('write', $this->ref_id))
00972 {
00973 $this->tpl->setCurrentBlock("selectall");
00974 $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
00975 $counter++;
00976 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
00977 $this->tpl->parseCurrentBlock();
00978 $this->tpl->setCurrentBlock("standard");
00979 $this->tpl->setVariable("DELETE", $this->lng->txt("delete"));
00980 $this->tpl->setVariable("DUPLICATE", $this->lng->txt("duplicate"));
00981 $this->tpl->setVariable("COPY", $this->lng->txt("copy"));
00982 $this->tpl->setVariable("EXPORT", $this->lng->txt("export"));
00983 $this->tpl->setVariable("PASTE", $this->lng->txt("paste"));
00984 if (strcmp($_SESSION["spl_copied_questions"], "") == 0)
00985 {
00986 $this->tpl->setVariable("PASTE_DISABLED", " disabled=\"disabled\"");
00987 }
00988 $this->tpl->setVariable("QUESTIONBLOCK", $this->lng->txt("define_questionblock"));
00989 $this->tpl->setVariable("UNFOLD", $this->lng->txt("unfold"));
00990 $this->tpl->parseCurrentBlock();
00991 $this->tpl->setCurrentBlock("Footer");
00992 include_once "./classes/class.ilUtil.php";
00993 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\">");
00994 $this->tpl->parseCurrentBlock();
00995 }
00996 }
00997
00998 if ($rbacsystem->checkAccess('write', $this->ref_id))
00999 {
01000
01001 $this->tpl->setCurrentBlock("QTypes");
01002 $query = "SELECT * FROM survey_questiontype ORDER BY questiontype_id";
01003 $query_result = $this->ilias->db->query($query);
01004 while ($data = $query_result->fetchRow(DB_FETCHMODE_OBJECT))
01005 {
01006 if ($lastquestiontype == $data->questiontype_id)
01007 {
01008 $this->tpl->setVariable("QUESTION_TYPE_SELECTED", " selected=\"selected\"");
01009 }
01010 $this->tpl->setVariable("QUESTION_TYPE_ID", $data->type_tag);
01011 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($data->type_tag));
01012 $this->tpl->parseCurrentBlock();
01013 }
01014 $this->tpl->setCurrentBlock("CreateQuestion");
01015 $this->tpl->setVariable("QUESTION_ADD", $this->lng->txt("create"));
01016 $this->tpl->setVariable("QUESTION_IMPORT", $this->lng->txt("import"));
01017 $this->tpl->setVariable("ACTION_QUESTION_ADD", $this->ctrl->getFormAction($this));
01018 $this->tpl->parseCurrentBlock();
01019 }
01020
01021 $sortcolumns = array(
01022 "title" => $_GET["sort"]["title"],
01023 "description" => $_GET["sort"]["description"],
01024 "type" => $_GET["sort"]["type"],
01025 "author" => $_GET["sort"]["author"],
01026 "created" => $_GET["sort"]["created"],
01027 "updated" => $_GET["sort"]["updated"]
01028 );
01029 foreach ($sortcolumns as $key => $value) {
01030 if (strcmp($value, "ASC") == 0) {
01031 $sortcolumns[$key] = "DESC";
01032 } else {
01033 $sortcolumns[$key] = "ASC";
01034 }
01035 }
01036
01037 $this->tpl->setCurrentBlock("adm_content");
01038
01039 $this->ctrl->setParameterByClass(get_class($this), "startrow", $table["startrow"]);
01040 $this->tpl->setVariable("QUESTION_TITLE", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&sort[title]=" . $sortcolumns["title"] . "\">" . $this->lng->txt("title") . "</a>" . $table["images"]["title"]);
01041 $this->tpl->setVariable("QUESTION_DESCRIPTION", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&sort[description]=" . $sortcolumns["description"] . "\">" . $this->lng->txt("description") . "</a>". $table["images"]["description"]);
01042 $this->tpl->setVariable("QUESTION_TYPE", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&sort[type]=" . $sortcolumns["type"] . "\">" . $this->lng->txt("question_type") . "</a>" . $table["images"]["type"]);
01043 $this->tpl->setVariable("QUESTION_AUTHOR", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&sort[author]=" . $sortcolumns["author"] . "\">" . $this->lng->txt("author") . "</a>" . $table["images"]["author"]);
01044 $this->tpl->setVariable("QUESTION_CREATED", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&sort[created]=" . $sortcolumns["created"] . "\">" . $this->lng->txt("create_date") . "</a>" . $table["images"]["created"]);
01045 $this->tpl->setVariable("QUESTION_UPDATED", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&sort[updated]=" . $sortcolumns["updated"] . "\">" . $this->lng->txt("last_update") . "</a>" . $table["images"]["updated"]);
01046 $this->tpl->setVariable("BUTTON_CANCEL", $this->lng->txt("cancel"));
01047 $this->tpl->setVariable("ACTION_QUESTION_FORM", $this->ctrl->getFormAction($this) . $sort);
01048 $this->tpl->parseCurrentBlock();
01049 unset($_SESSION["calling_survey"]);
01050 }
01051
01052
01053 function updateObject() {
01054 $this->update = $this->object->update();
01055 sendInfo($this->lng->txt("msg_obj_modified"), true);
01056 }
01057
01058
01059
01060
01061 function exportObject()
01062 {
01063 global $tree;
01064
01065
01066
01067
01068 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
01069
01070
01071 $this->tpl->setCurrentBlock("btn_cell");
01072 $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "createExportFile"));
01073 $this->tpl->setVariable("BTN_TXT", $this->lng->txt("svy_create_export_file"));
01074 $this->tpl->parseCurrentBlock();
01075
01076 $export_dir = $this->object->getExportDirectory();
01077 $export_files = $this->object->getExportFiles($export_dir);
01078
01079
01080 include_once("./classes/class.ilTableGUI.php");
01081 $tbl = new ilTableGUI();
01082
01083
01084 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
01085
01086
01087 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.export_file_row.html", true);
01088
01089 $num = 0;
01090
01091 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01092
01093 $tbl->setTitle($this->lng->txt("svy_export_files"));
01094
01095 $tbl->setHeaderNames(array("", $this->lng->txt("svy_file"),
01096 $this->lng->txt("svy_size"), $this->lng->txt("date") ));
01097
01098 $tbl->enabled["sort"] = false;
01099 $tbl->setColumnWidth(array("1%", "49%", "25%", "25%"));
01100
01101
01102 $tbl->setOrderColumn($_GET["sort_by"]);
01103 $tbl->setOrderDirection($_GET["sort_order"]);
01104 $tbl->setLimit($_GET["limit"]);
01105 $tbl->setOffset($_GET["offset"]);
01106 $tbl->setMaxCount($this->maxcount);
01107
01108
01109 include_once "./classes/class.ilUtil.php";
01110
01111
01112 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
01113
01114
01115 $tbl->setMaxCount(count($export_files));
01116 $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
01117
01118 $tbl->render();
01119 if(count($export_files) > 0)
01120 {
01121 $this->tpl->setVariable("COLUMN_COUNTS", 4);
01122
01123 $i=0;
01124 foreach($export_files as $exp_file)
01125 {
01126 $this->tpl->setCurrentBlock("tbl_content");
01127 $this->tpl->setVariable("TXT_FILENAME", $exp_file);
01128
01129 $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
01130 $this->tpl->setVariable("CSS_ROW", $css_row);
01131
01132 $this->tpl->setVariable("TXT_SIZE", filesize($export_dir."/".$exp_file));
01133 $this->tpl->setVariable("CHECKBOX_ID", $exp_file);
01134
01135 $file_arr = explode("__", $exp_file);
01136 $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s",$file_arr[0]));
01137
01138 $this->tpl->parseCurrentBlock();
01139 }
01140 $this->tpl->setCurrentBlock("selectall");
01141 $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
01142 $this->tpl->setVariable("CSS_ROW", $css_row);
01143 $this->tpl->parseCurrentBlock();
01144 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
01145 $this->tpl->setCurrentBlock("tbl_action_btn");
01146 $this->tpl->setVariable("BTN_NAME", "confirmDeleteExportFile");
01147 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
01148 $this->tpl->parseCurrentBlock();
01149
01150 $this->tpl->setCurrentBlock("tbl_action_btn");
01151 $this->tpl->setVariable("BTN_NAME", "downloadExportFile");
01152 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("download"));
01153 $this->tpl->parseCurrentBlock();
01154 }
01155 else
01156 {
01157 $this->tpl->setCurrentBlock("notfound");
01158 $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
01159 $this->tpl->setVariable("NUM_COLS", 3);
01160 $this->tpl->parseCurrentBlock();
01161 }
01162
01163 $this->tpl->parseCurrentBlock();
01164 }
01165
01169 function createExportFileObject($questions = null)
01170 {
01171 global $rbacsystem;
01172
01173 if ($rbacsystem->checkAccess("write", $this->ref_id))
01174 {
01175 include_once("./survey/classes/class.ilSurveyQuestionpoolExport.php");
01176 $survey_exp = new ilSurveyQuestionpoolExport($this->object);
01177 $survey_exp->buildExportFile($questions);
01178 $this->ctrl->redirect($this, "export");
01179 }
01180 else
01181 {
01182 sendInfo("cannot_export_questionpool");
01183 }
01184 }
01185
01189 function downloadExportFileObject()
01190 {
01191 if(!isset($_POST["file"]))
01192 {
01193 sendInfo($this->lng->txt("no_checkbox"), true);
01194 $this->ctrl->redirect($this, "export");
01195 }
01196
01197 if (count($_POST["file"]) > 1)
01198 {
01199 sendInfo($this->lng->txt("select_max_one_item"),true);
01200 $this->ctrl->redirect($this, "export");
01201 }
01202
01203
01204 $export_dir = $this->object->getExportDirectory();
01205 include_once "./classes/class.ilUtil.php";
01206 ilUtil::deliverFile($export_dir."/".$_POST["file"][0],
01207 $_POST["file"][0]);
01208 }
01209
01213 function confirmDeleteExportFileObject()
01214 {
01215 if(!isset($_POST["file"]))
01216 {
01217 sendInfo($this->lng->txt("no_checkbox"),true);
01218 $this->ctrl->redirect($this, "export");
01219 }
01220
01221
01222
01223
01224 $_SESSION["ilExportFiles"] = $_POST["file"];
01225
01226 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html", true);
01227
01228 sendInfo($this->lng->txt("info_delete_sure"));
01229
01230 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01231
01232
01233 $this->tpl->setCurrentBlock("table_header");
01234 $this->tpl->setVariable("TEXT",$this->lng->txt("objects"));
01235 $this->tpl->parseCurrentBlock();
01236
01237
01238 $counter = 0;
01239 include_once "./classes/class.ilUtil.php";
01240 foreach($_POST["file"] as $file)
01241 {
01242 $this->tpl->setCurrentBlock("table_row");
01243 $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_file.gif"));
01244 $this->tpl->setVariable("TEXT_IMG_OBJ", $this->lng->txt("file_icon"));
01245 $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
01246 $this->tpl->setVariable("TEXT_CONTENT", $file);
01247 $this->tpl->parseCurrentBlock();
01248 }
01249
01250
01251 $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
01252 $buttons = array(
01253 "deleteExportFile" => $this->lng->txt("confirm"),
01254 "cancelDeleteExportFile" => $this->lng->txt("cancel")
01255 );
01256 foreach ($buttons as $name => $value)
01257 {
01258 $this->tpl->setCurrentBlock("operation_btn");
01259 $this->tpl->setVariable("BTN_NAME",$name);
01260 $this->tpl->setVariable("BTN_VALUE",$value);
01261 $this->tpl->parseCurrentBlock();
01262 }
01263 }
01264
01265
01269 function cancelDeleteExportFileObject()
01270 {
01271 session_unregister("ilExportFiles");
01272 $this->ctrl->redirect($this, "export");
01273 }
01274
01275
01279 function deleteExportFileObject()
01280 {
01281 $export_dir = $this->object->getExportDirectory();
01282 foreach($_SESSION["ilExportFiles"] as $file)
01283 {
01284 $exp_file = $export_dir."/".$file;
01285 $exp_dir = $export_dir."/".substr($file, 0, strlen($file) - 4);
01286 if (@is_file($exp_file))
01287 {
01288 unlink($exp_file);
01289 }
01290 if (@is_dir($exp_dir))
01291 {
01292 include_once "./classes/class.ilUtil.php";
01293 ilUtil::delDir($exp_dir);
01294 }
01295 }
01296 $this->ctrl->redirect($this, "export");
01297 }
01298
01304 function importObject()
01305 {
01306 global $rbacsystem;
01307 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"]))
01308 {
01309 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
01310 }
01311 $this->getTemplateFile("import", "spl");
01312 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01313 $this->tpl->setVariable("BTN_NAME", "uploadSpl");
01314 $this->tpl->setVariable("TXT_UPLOAD", $this->lng->txt("upload"));
01315 $this->tpl->setVariable("TXT_IMPORT_SPL", $this->lng->txt("import_spl"));
01316 $this->tpl->setVariable("TXT_SELECT_MODE", $this->lng->txt("select_mode"));
01317 $this->tpl->setVariable("TXT_SELECT_FILE", $this->lng->txt("select_file"));
01318 }
01319
01323 function uploadSplObject($redirect = true)
01324 {
01325 if ($_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK)
01326 {
01327 sendInfo($this->lng->txt("spl_select_file_for_import"));
01328 $this->importObject();
01329 return;
01330 }
01331 include_once "./survey/classes/class.ilObjSurveyQuestionPool.php";
01332
01333 $newObj = new ilObjSurveyQuestionPool();
01334
01335 $newObj->setType($_GET["new_type"]);
01336
01337 $newObj->setTitle("dummy");
01338
01339
01340
01341 $newObj->create(true);
01342
01343 $newObj->createReference();
01344
01345 $newObj->putInTree($_GET["ref_id"]);
01346
01347 $newObj->setPermissions($_GET["ref_id"]);
01348
01349 $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
01350
01351
01352 $newObj->createImportDirectory();
01353
01354
01355 $file = pathinfo($_FILES["xmldoc"]["name"]);
01356 $full_path = $newObj->getImportDirectory()."/".$_FILES["xmldoc"]["name"];
01357 include_once "./classes/class.ilUtil.php";
01358 ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"],
01359 $_FILES["xmldoc"]["name"], $full_path);
01360
01361
01362
01363 $qtiresult = $newObj->importObject($full_path);
01364
01365 if ($redirect)
01366 {
01367 $this->ctrl->redirect($this, "cancel");
01368
01369 }
01370 return $newObj->getRefId();
01371 }
01372
01376 function createObject()
01377 {
01378 global $rbacsystem;
01379 $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
01380 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
01381 {
01382 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
01383 }
01384 else
01385 {
01386 $this->getTemplateFile("create", $new_type);
01387
01388 include_once("./survey/classes/class.ilObjSurvey.php");
01389
01390
01391 $data = array();
01392 $data["fields"] = array();
01393 include_once "./classes/class.ilUtil.php";
01394 $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
01395 $data["fields"]["desc"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["desc"]);
01396
01397 foreach ($data["fields"] as $key => $val)
01398 {
01399 $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
01400 $this->tpl->setVariable(strtoupper($key), $val);
01401
01402 if ($this->prepare_output)
01403 {
01404 $this->tpl->parseCurrentBlock();
01405 }
01406 }
01407
01408 $this->ctrl->setParameter($this, "new_type", $this->type);
01409 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01410 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
01411 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
01412 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
01413 $this->tpl->setVariable("CMD_SUBMIT", "save");
01414 $this->tpl->setVariable("TARGET", ' target="'.
01415 ilFrameTargetInfo::_getFrame("MainContent").'" ');
01416 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
01417
01418 $this->tpl->setVariable("TXT_IMPORT_SPL", $this->lng->txt("import_spl"));
01419 $this->tpl->setVariable("TXT_SPL_FILE", $this->lng->txt("spl_upload_file"));
01420 $this->tpl->setVariable("TXT_IMPORT", $this->lng->txt("import"));
01421 }
01422 }
01423
01427 function importFileObject()
01428 {
01429 if (strcmp($_FILES["xmldoc"]["tmp_name"], "") == 0)
01430 {
01431 sendInfo($this->lng->txt("spl_select_file_for_import"));
01432 $this->createObject();
01433 return;
01434 }
01435 $this->ctrl->setParameter($this, "new_type", $this->type);
01436 $ref_id = $this->uploadSplObject(false);
01437
01438 sendInfo($this->lng->txt("object_imported"),true);
01439
01440 ilUtil::redirect("ilias.php?ref_id=".$ref_id.
01441 "&baseClass=ilObjSurveyQuestionPoolGUI");
01442 }
01443
01447 function &createQuestionObject()
01448 {
01449 include_once "./survey/classes/class.SurveyQuestionGUI.php";
01450 $q_gui =& SurveyQuestionGUI::_getQuestionGUI($_POST["sel_question_types"]);
01451 $q_gui->object->setObjId($this->object->getId());
01452 $this->ctrl->setParameter($this, "sel_question_types", $_POST["sel_question_types"]);
01453 $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
01454 }
01455
01459 function &editQuestionForSurveyObject()
01460 {
01461 include_once "./survey/classes/class.SurveyQuestionGUI.php";
01462 $q_gui =& SurveyQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
01463 $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $q_gui->getQuestionType());
01464 $this->ctrl->setParameterByClass(get_class($q_gui), "q_id", $_GET["q_id"]);
01465 $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
01466 }
01467
01471 function &createQuestionForSurveyObject()
01472 {
01473 include_once "./survey/classes/class.SurveyQuestionGUI.php";
01474 $q_gui =& SurveyQuestionGUI::_getQuestionGUI($_GET["sel_question_types"]);
01475 $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $q_gui->getQuestionType());
01476 $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
01477 }
01478
01482 function &previewObject()
01483 {
01484 include_once "./survey/classes/class.SurveyQuestionGUI.php";
01485 $q_gui =& SurveyQuestionGUI::_getQuestionGUI("", $_GET["preview"]);
01486 $_GET["q_id"] = $_GET["preview"];
01487 $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $q_gui->getQuestionType());
01488 $this->ctrl->setParameterByClass(get_class($q_gui), "q_id", $_GET["preview"]);
01489 $this->ctrl->redirectByClass(get_class($q_gui), "preview");
01490 }
01491
01492 function addLocatorItems()
01493 {
01494 global $ilLocator;
01495 switch ($this->ctrl->getCmd())
01496 {
01497 case "create":
01498 case "importFile":
01499 case "cancel":
01500 break;
01501 default:
01502 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""));
01503 break;
01504 }
01505 if ($_GET["q_id"] > 0)
01506 {
01507 include_once "./survey/classes/class.SurveyQuestionGUI.php";
01508 $q_gui =& SurveyQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
01509 $q_gui->object->setObjId($this->object->getId());
01510 $ilLocator->addItem($q_gui->object->getTitle(), $this->ctrl->getLinkTargetByClass(get_class($q_gui), "editQuestion"));
01511 }
01512 }
01513
01519 function getTabs(&$tabs_gui)
01520 {
01521 if (($_GET["calling_survey"] > 0) || ($_GET["new_for_survey"] > 0)) return;
01522
01523 $tabs_gui->addTarget("properties",
01524 $this->ctrl->getLinkTarget($this,'properties'),
01525 "properties",
01526 "", "");
01527
01528 $force_active = ($this->ctrl->getCmdClass() == "" ||
01529 $this->ctrl->getCmd() == "")
01530 ? true
01531 : false;
01532 if (!$force_active)
01533 {
01534 if (is_array($_GET["sort"]))
01535 {
01536 $force_active = true;
01537 }
01538 }
01539 $tabs_gui->addTarget("survey_questions",
01540 $this->ctrl->getLinkTarget($this,'questions'),
01541 array("questions", "filter", "reset", "createQuestion",
01542 "importQuestions", "deleteQuestions", "duplicate", "copy", "paste",
01543 "exportQuestions", "confirmDeleteQuestions", "cancelDeleteQuestions",
01544 "confirmPasteQuestions", "cancelPasteQuestions", "uploadQuestions",
01545 "editQuestion", "addMaterial", "removeMaterial", "save", "cancel",
01546 "cancelExplorer", "linkChilds", "addGIT", "addST", "addPG", "preview",
01547 "moveCategory", "deleteCategory", "addPhrase", "addCategory", "savePhrase",
01548 "addSelectedPhrase", "cancelViewPhrase", "confirmSavePhrase", "cancelSavePhrase",
01549 "insertBeforeCategory", "insertAfterCategory", "confirmDeleteCategory",
01550 "cancelDeleteCategory", "categories", "saveCategories",
01551 "savePhrase", "addPhrase"
01552 ),
01553 "", "", $force_active);
01554
01555
01556 $tabs_gui->addTarget("manage_phrases",
01557 $this->ctrl->getLinkTarget($this,'phrases'),
01558 array("phrases", "deletePhrase", "confirmDeletePhrase", "cancelDeletePhrase"),
01559 "", "");
01560
01561
01562 $tabs_gui->addTarget("export",
01563 $this->ctrl->getLinkTarget($this,'export'),
01564 array("export", "createExportFile", "confirmDeleteExportFile",
01565 "downloadExportFile", "cancelDeleteExportFile", "deleteExportFile"),
01566 "", "");
01567
01568
01569 $tabs_gui->addTarget("perm_settings",
01570 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
01571
01572
01573 $tabs_gui->addTarget("meta_data",
01574 $this->ctrl->getLinkTargetByClass('ilmdeditorgui','listSection'),
01575 "", "ilmdeditorgui");
01576 }
01577
01578 }
01579 ?>