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