• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

survey/classes/class.ilObjSurveyQuestionPoolGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
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, $rbacsystem;
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                 if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
00060                 {
00061                         $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00062                 }
00063         }
00064 
00068         function &executeCommand()
00069         {
00070                 $this->prepareOutput();
00071                 $cmd = $this->ctrl->getCmd("questions");
00072                 $next_class = $this->ctrl->getNextClass($this);
00073                 $this->ctrl->setReturn($this, "questions");
00074                 $q_type = ($_POST["sel_question_types"] != "")
00075                         ? $_POST["sel_question_types"]
00076                         : $_GET["sel_question_types"];
00077                 switch($next_class)
00078                 {
00079                         case 'ilmdeditorgui':
00080                                 include_once "./Services/MetaData/classes/class.ilMDEditorGUI.php";
00081                                 $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
00082                                 $md_gui->addObserver($this->object,'MDUpdateListener','General');
00083 
00084                                 $this->ctrl->forwardCommand($md_gui);
00085                                 break;
00086 
00087                         case "surveynominalquestiongui":
00088                                 $this->ctrl->setParameterByClass("surveynominalquestiongui", "sel_question_types", $q_type);
00089                                 include_once "./survey/classes/class.SurveyQuestionGUI.php";
00090                                 $q_gui =& SurveyQuestionGUI::_getQuestionGUI($q_type, $_GET["q_id"]);
00091                                 $q_gui->object->setObjId($this->object->getId());
00092                                 $q_gui->setQuestionTabs();
00093                                 $ret =& $this->ctrl->forwardCommand($q_gui);
00094                                 break;
00095 
00096                         case "surveyordinalquestiongui":
00097                                 $this->ctrl->setParameterByClass("surveyordinalquestiongui", "sel_question_types", $q_type);
00098                                 include_once "./survey/classes/class.SurveyQuestionGUI.php";
00099                                 $q_gui =& SurveyQuestionGUI::_getQuestionGUI($q_type, $_GET["q_id"]);
00100                                 $q_gui->object->setObjId($this->object->getId());
00101                                 $q_gui->setQuestionTabs();
00102                                 $ret =& $this->ctrl->forwardCommand($q_gui);
00103                                 break;
00104 
00105                         case "surveymetricquestiongui":
00106                                 $this->ctrl->setParameterByClass("surveymetricquestiongui", "sel_question_types", $q_type);
00107                                 include_once "./survey/classes/class.SurveyQuestionGUI.php";
00108                                 $q_gui =& SurveyQuestionGUI::_getQuestionGUI($q_type, $_GET["q_id"]);
00109                                 $q_gui->object->setObjId($this->object->getId());
00110                                 $q_gui->setQuestionTabs();
00111                                 $ret =& $this->ctrl->forwardCommand($q_gui);
00112                                 break;
00113 
00114                         case "surveytextquestiongui":
00115                                 $this->ctrl->setParameterByClass("surveytextquestiongui", "sel_question_types", $q_type);
00116                                 include_once "./survey/classes/class.SurveyQuestionGUI.php";
00117                                 $q_gui =& SurveyQuestionGUI::_getQuestionGUI($q_type, $_GET["q_id"]);
00118                                 $q_gui->object->setObjId($this->object->getId());
00119                                 $q_gui->setQuestionTabs();
00120                                 $ret =& $this->ctrl->forwardCommand($q_gui);
00121                                 break;
00122                                 
00123                         case 'ilpermissiongui':
00124                                 include_once("./classes/class.ilPermissionGUI.php");
00125                                 $perm_gui =& new ilPermissionGUI($this);
00126                                 $ret =& $this->ctrl->forwardCommand($perm_gui);
00127                                 break;
00128 
00129                         default:
00130                                 $cmd.= "Object";
00131                                 $ret =& $this->$cmd();
00132                                 break;
00133                 }
00134                 if (strtolower($_GET["baseClass"]) != "iladministrationgui" &&
00135                         $this->getCreationMode() != true)
00136                 {
00137                         $this->tpl->show();
00138                 }
00139         }
00140 
00146         function cancelObject()
00147         {
00148                 sendInfo($this->lng->txt("msg_cancel"),true);
00149                 ilUtil::redirect("repository.php?cmd=frameset&ref_id=".$_GET["ref_id"]);
00150         }
00151 
00152 
00157         function saveObject()
00158         {
00159                 global $rbacadmin;
00160 
00161                 // create and insert forum in objecttree
00162                 $newObj = parent::saveObject();
00163 
00164                 // always send a message
00165                 sendInfo($this->lng->txt("object_added"),true);
00166 
00167                 ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
00168                         "&baseClass=ilObjSurveyQuestionPoolGUI");
00169         }
00170         
00179         function cancelAction($question_id = "") 
00180         {
00181                 $this->ctrl->redirect($this, "questions");
00182         }
00183 
00187         function propertiesObject()
00188         {
00189                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_properties.html", true);
00190                 $this->tpl->setCurrentBlock("adm_content");
00191                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00192                 $this->tpl->setVariable("HEADING_GENERAL", $this->lng->txt("spl_general_properties"));
00193                 $this->tpl->setVariable("PROPERTY_ONLINE", $this->lng->txt("spl_online_property"));
00194                 $this->tpl->setVariable("PROPERTY_ONLINE_DESCRIPTION", $this->lng->txt("spl_online_property_description"));
00195                 if ($this->object->getOnline() == 1)
00196                 {
00197                         $this->tpl->setVariable("PROPERTY_ONLINE_CHECKED", " checked=\"checked\"");
00198                 }
00199                 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00200                 $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
00201                 $this->tpl->parseCurrentBlock();
00202         }
00203         
00207         function savePropertiesObject()
00208         {
00209                 $qpl_online = $_POST["online"];
00210                 if (strlen($qpl_online) == 0) $qpl_online = "0";
00211                 $this->object->setOnline($qpl_online);
00212                 $this->object->saveToDb();
00213                 sendInfo($this->lng->txt("saved_successfully"), true);
00214                 $this->ctrl->redirect($this, "properties");
00215         }
00216         
00217 
00225         function copyObject()
00226         {
00227     // create an array of all checked checkboxes
00228     $checked_questions = array();
00229     foreach ($_POST as $key => $value) 
00230                 {
00231       if (preg_match("/cb_(\d+)/", $key, $matches)) 
00232                         {
00233         array_push($checked_questions, $matches[1]);
00234       }
00235     }
00236                 
00237                 // copy button was pressed
00238                 if (count($checked_questions) > 0) 
00239                 {
00240                         $_SESSION["spl_copied_questions"] = join($checked_questions, ",");
00241                 } 
00242                 else if (count($checked_questions) == 0) 
00243                 {
00244                         sendInfo($this->lng->txt("qpl_copy_select_none"));
00245                         $_SESSION["spl_copied_questions"] = "";
00246                 }
00247                 $this->questionsObject();
00248         }       
00249         
00257         function duplicateObject()
00258         {
00259     // create an array of all checked checkboxes
00260     $checked_questions = array();
00261     foreach ($_POST as $key => $value) {
00262       if (preg_match("/cb_(\d+)/", $key, $matches)) {
00263         array_push($checked_questions, $matches[1]);
00264       }
00265     }
00266                 
00267                 if (count($checked_questions) > 0) {
00268                         foreach ($checked_questions as $key => $value) {
00269                                 $this->object->duplicateQuestion($value);
00270                         }
00271                 } elseif (count($checked_questions) == 0) {
00272                         sendInfo($this->lng->txt("qpl_duplicate_select_none"));
00273                 }
00274                 $this->questionsObject();
00275         }
00276 
00280         function exportQuestionsObject()
00281         {
00282                 // create an array of all checked checkboxes
00283                 $checked_questions = array();
00284                 foreach ($_POST as $key => $value) {
00285                         if (preg_match("/cb_(\d+)/", $key, $matches)) {
00286                                 array_push($checked_questions, $matches[1]);
00287                         }
00288                 }
00289                 
00290                 // export button was pressed
00291                 if (count($checked_questions) > 0)
00292                 {
00293                         $this->createExportFileObject($checked_questions);
00294                 }
00295                 else
00296                 {
00297                         sendInfo($this->lng->txt("qpl_export_select_none"));
00298                         $this->questionsObject();
00299                 }
00300         }
00301         
00309         function deleteQuestionsObject()
00310         {
00311                 global $rbacsystem;
00312                 
00313                 sendInfo();
00314     // create an array of all checked checkboxes
00315     $checked_questions = array();
00316     foreach ($_POST as $key => $value) {
00317       if (preg_match("/cb_(\d+)/", $key, $matches)) {
00318         array_push($checked_questions, $matches[1]);
00319       }
00320     }
00321                 
00322                 if (count($checked_questions) > 0) {
00323                         if ($rbacsystem->checkAccess('write', $this->ref_id)) {
00324                                 sendInfo($this->lng->txt("qpl_confirm_delete_questions"));
00325                         } else {
00326                                 sendInfo($this->lng->txt("qpl_delete_rbac_error"));
00327                                 $this->questionsObject();
00328                                 return;
00329                         }
00330                 } elseif (count($checked_questions) == 0) {
00331                         sendInfo($this->lng->txt("qpl_delete_select_none"));
00332                         $this->questionsObject();
00333                         return;
00334                 }
00335                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_confirm_delete_questions.html", true);
00336                 $whereclause = join($checked_questions, " OR survey_question.question_id = ");
00337                 $whereclause = " AND (survey_question.question_id = " . $whereclause . ")";
00338                 $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";
00339                 $query_result = $this->ilias->db->query($query);
00340                 $colors = array("tblrow1", "tblrow2");
00341                 $counter = 0;
00342                 if ($query_result->numRows() > 0)
00343                 {
00344                         while ($data = $query_result->fetchRow(DB_FETCHMODE_OBJECT))
00345                         {
00346                                 if (in_array($data->question_id, $checked_questions))
00347                                 {
00348                                         $this->tpl->setCurrentBlock("row");
00349                                         $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
00350                                         $this->tpl->setVariable("TXT_TITLE", $data->title);
00351                                         $this->tpl->setVariable("TXT_DESCRIPTION", $data->description);
00352                                         $this->tpl->setVariable("TXT_TYPE", $this->lng->txt($data->type_tag));
00353                                         $this->tpl->parseCurrentBlock();
00354                                         $counter++;
00355                                 }
00356                         }
00357                 }
00358                 foreach ($checked_questions as $id)
00359                 {
00360                         $this->tpl->setCurrentBlock("hidden");
00361                         $this->tpl->setVariable("HIDDEN_NAME", "id_$id");
00362                         $this->tpl->setVariable("HIDDEN_VALUE", "1");
00363                         $this->tpl->parseCurrentBlock();
00364                 }
00365 
00366                 $this->tpl->setCurrentBlock("adm_content");
00367                 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
00368                 $this->tpl->setVariable("TXT_DESCRIPTION", $this->lng->txt("description"));
00369                 $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("question_type"));
00370                 $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
00371                 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
00372                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00373                 $this->tpl->parseCurrentBlock();
00374         }
00375 
00379         function confirmDeleteQuestionsObject()
00380         {
00381                 // delete questions after confirmation
00382                 sendInfo($this->lng->txt("qpl_questions_deleted"), true);
00383                 $checked_questions = array();
00384                 foreach ($_POST as $key => $value) {
00385                         if (preg_match("/id_(\d+)/", $key, $matches)) {
00386                                 array_push($checked_questions, $matches[1]);
00387                         }
00388                 }
00389 
00390                 foreach ($checked_questions as $key => $value) {
00391                         $this->object->removeQuestion($value);
00392                 }
00393                 $this->ctrl->redirect($this, "questions");
00394         }
00395         
00399         function cancelDeleteQuestionsObject()
00400         {
00401                 // delete questions after confirmation
00402                 $this->ctrl->redirect($this, "questions");
00403         }
00404         
00412         function pasteObject()
00413         {
00414                 sendInfo();
00415 
00416     // create an array of all checked checkboxes
00417     $checked_questions = array();
00418     foreach ($_POST as $key => $value) {
00419       if (preg_match("/cb_(\d+)/", $key, $matches)) {
00420         array_push($checked_questions, $matches[1]);
00421       }
00422     }
00423                 
00424                 // paste button was pressed
00425                 if (strcmp($_SESSION["spl_copied_questions"], "") != 0)
00426                 {
00427                         $copied_questions = split("/,/", $_SESSION["spl_copied_questions"]);
00428                         sendInfo($this->lng->txt("qpl_past_questions_confirmation"));
00429                 }
00430                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_confirm_paste_questions.html", true);
00431                 $questions_info =& $this->object->getQuestionsInfo($copied_questions);
00432                 $colors = array("tblrow1", "tblrow2");
00433                 $counter = 0;
00434                 foreach ($questions_info as $data)
00435                 {
00436                         $this->tpl->setCurrentBlock("row");
00437                         $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
00438                         $this->tpl->setVariable("TXT_TITLE", $data->title);
00439                         $this->tpl->setVariable("TXT_DESCRIPTION", $data->description);
00440                         $this->tpl->setVariable("TXT_TYPE", $this->lng->txt($data->type_tag));
00441                         $this->tpl->parseCurrentBlock();
00442                         $counter++;
00443                 }
00444                 foreach ($questions_info as $data)
00445                 {
00446                         $this->tpl->setCurrentBlock("hidden");
00447                         $this->tpl->setVariable("HIDDEN_NAME", "id_$data->question_id");
00448                         $this->tpl->setVariable("HIDDEN_VALUE", $data->question_id);
00449                         $this->tpl->parseCurrentBlock();
00450                 }
00451 
00452                 $this->tpl->setCurrentBlock("adm_content");
00453                 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
00454                 $this->tpl->setVariable("TXT_DESCRIPTION", $this->lng->txt("description"));
00455                 $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("question_type"));
00456                 $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
00457                 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
00458                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00459                 $this->tpl->parseCurrentBlock();
00460         }
00461 
00465         function confirmPasteQuestionsObject()
00466         {
00467                 // paste questions after confirmation
00468                 sendInfo($this->lng->txt("qpl_questions_pasted"), true);
00469                 $checked_questions = array();
00470                 foreach ($_POST as $key => $value) {
00471                         if (preg_match("/id_(\d+)/", $key, $matches)) {
00472                                 array_push($checked_questions, $matches[1]);
00473                         }
00474                 }
00475                 foreach ($checked_questions as $key => $value) {
00476                         $this->object->paste($value);
00477                 }
00478                 
00479                 $this->ctrl->redirect($this, "questions");
00480         }
00481         
00485         function cancelPasteQuestionsObject()
00486         {
00487                 // delete questions after confirmation
00488                 $this->ctrl->redirect($this, "questions");
00489         }
00490         
00494         function cancelDeletePhraseObject()
00495         {
00496                 $this->ctrl->redirect($this, "phrases");
00497         }
00498         
00502         function confirmDeletePhraseObject()
00503         {
00504                 $phrases = array();
00505                 foreach ($_POST as $key => $value)
00506                 {
00507                         if (preg_match("/phrase_(\d+)/", $key, $matches))
00508                         {
00509                                 array_push($phrases, $matches[1]);
00510                         }
00511                 }
00512                 $this->object->deletePhrases($phrases);
00513                 sendInfo($this->lng->txt("qpl_phrases_deleted"), true);
00514                 $this->ctrl->redirect($this, "phrases");
00515         }
00516         
00525         function deletePhrasesForm($checked_phrases)
00526         {
00527                 sendInfo();
00528                 include_once "./survey/classes/class.SurveyOrdinalQuestion.php";
00529                 $ordinal = new SurveyOrdinalQuestion();
00530                 $phrases =& $ordinal->getAvailablePhrases(1);
00531                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_confirm_delete_phrases.html", true);
00532                 $colors = array("tblrow1", "tblrow2");
00533                 $counter = 0;
00534                 foreach ($checked_phrases as $id)
00535                 {
00536                         $this->tpl->setCurrentBlock("row");
00537                         $this->tpl->setVariable("COLOR_CLASS", $colors[$counter++ % 2]);
00538                         $this->tpl->setVariable("PHRASE_TITLE", $phrases[$id]["title"]);
00539                         $categories =& $ordinal->getCategoriesForPhrase($id);
00540                         $this->tpl->setVariable("PHRASE_CONTENT", join($categories, ", "));
00541                         $this->tpl->parseCurrentBlock();
00542                         $this->tpl->setCurrentBlock("hidden");
00543                         $this->tpl->setVariable("HIDDEN_NAME", "phrase_$id");
00544                         $this->tpl->setVariable("HIDDEN_VALUE", "1");
00545                         $this->tpl->parseCurrentBlock();
00546                 }
00547 
00548                 $this->tpl->setCurrentBlock("adm_content");
00549                 $this->tpl->setVariable("TEXT_PHRASE_TITLE", $this->lng->txt("phrase"));
00550                 $this->tpl->setVariable("TEXT_PHRASE_CONTENT", $this->lng->txt("categories"));
00551                 $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
00552                 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
00553                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00554                 $this->tpl->parseCurrentBlock();
00555         }
00556         
00564         function deletePhraseObject()
00565         {
00566                 sendInfo();
00567 
00568                 $checked_phrases = array();
00569                 foreach ($_POST as $key => $value)
00570                 {
00571                         if (preg_match("/phrase_(\d+)/", $key, $matches))
00572                         {
00573                                 array_push($checked_phrases, $matches[1]);
00574                         }
00575                 }
00576                 if (count($checked_phrases))
00577                 {
00578                         sendInfo($this->lng->txt("qpl_confirm_delete_phrases"));
00579                         $this->deletePhrasesForm($checked_phrases);
00580                         return;
00581                 }
00582                 else
00583                 {
00584                         sendInfo($this->lng->txt("qpl_delete_phrase_select_none"));
00585                         $this->phrasesObject();
00586                         return;
00587                 }
00588                 
00589                 $this->tpl->setCurrentBlock("obligatory");
00590                 $this->tpl->setVariable("TEXT_OBLIGATORY", $this->lng->txt("obligatory"));
00591                 $this->tpl->setVariable("CHECKED_OBLIGATORY", " checked=\"checked\"");
00592                 $this->tpl->parseCurrentBlock();
00593                 $this->tpl->setCurrentBlock("adm_content");
00594                 $this->tpl->setVariable("DEFINE_QUESTIONBLOCK_HEADING", $this->lng->txt("define_questionblock"));
00595                 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
00596                 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00597                 $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
00598                 $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
00599                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00600                 $this->tpl->parseCurrentBlock();
00601         }
00602 
00608   function phrasesObject()
00609         {
00610                 global $rbacsystem;
00611                 
00612                 if ($rbacsystem->checkAccess("write", $this->object->getRefId()))
00613                 {
00614                         $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_phrases.html", true);
00615                         include_once "./survey/classes/class.SurveyOrdinalQuestion.php";
00616                         $ordinal = new SurveyOrdinalQuestion();
00617                         $phrases =& $ordinal->getAvailablePhrases(1);
00618                         if (count($phrases))
00619                         {
00620                                 include_once "./classes/class.ilUtil.php";
00621                                 $colors = array("tblrow1", "tblrow2");
00622                                 $counter = 0;
00623                                 foreach ($phrases as $phrase_id => $phrase_array)
00624                                 {
00625                                         $this->tpl->setCurrentBlock("phraserow");
00626                                         $this->tpl->setVariable("PHRASE_ID", $phrase_id);
00627                                         $this->tpl->setVariable("COLOR_CLASS", $colors[$counter++ % 2]);
00628                                         $this->tpl->setVariable("PHRASE_TITLE", $phrase_array["title"]);
00629                                         $categories =& $ordinal->getCategoriesForPhrase($phrase_id);
00630                                         $this->tpl->setVariable("PHRASE_CONTENT", join($categories, ", "));
00631                                         $this->tpl->parseCurrentBlock();
00632                                 }
00633                                 $counter++;
00634                                 $this->tpl->setCurrentBlock("selectall");
00635                                 $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
00636                                 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter++ % 2]);
00637                                 $this->tpl->parseCurrentBlock();
00638                                 $this->tpl->setCurrentBlock("Footer");
00639                                 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\">");
00640                                 $this->tpl->setVariable("TEXT_DELETE", $this->lng->txt("delete"));
00641                                 $this->tpl->parseCurrentBlock();
00642                         }
00643                         else
00644                         {
00645                                 $this->tpl->setCurrentBlock("Emptytable");
00646                                 $this->tpl->setVariable("TEXT_EMPTYTABLE", $this->lng->txt("no_user_phrases_defined"));
00647                                 $this->tpl->parseCurrentBlock();
00648                         }
00649                         $this->tpl->setCurrentBlock("adm_content");
00650                         $this->tpl->setVariable("INTRODUCTION_MANAGE_PHRASES", $this->lng->txt("introduction_manage_phrases"));
00651                         $this->tpl->setVariable("TEXT_PHRASE_TITLE", $this->lng->txt("phrase"));
00652                         $this->tpl->setVariable("TEXT_PHRASE_CONTENT", $this->lng->txt("categories"));
00653                         $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00654                         $this->tpl->parseCurrentBlock();
00655                 }
00656                 else
00657                 {
00658                         sendInfo($this->lng->txt("cannot_manage_phrases"));
00659                 }
00660         }
00661         
00665         function importQuestionsObject()
00666         {
00667                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_import_question.html", true);
00668                 $this->tpl->setCurrentBlock("adm_content");
00669                 $this->tpl->setVariable("TEXT_IMPORT_QUESTION", $this->lng->txt("import_question"));
00670                 $this->tpl->setVariable("TEXT_SELECT_FILE", $this->lng->txt("select_file"));
00671                 $this->tpl->setVariable("TEXT_UPLOAD", $this->lng->txt("upload"));
00672                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00673                 $this->tpl->parseCurrentBlock();
00674         }
00675 
00679         function uploadQuestionsObject()
00680         {
00681                 // check if file was uploaded
00682                 $source = $_FILES["qtidoc"]["tmp_name"];
00683                 $error = 0;
00684                 if (($source == 'none') || (!$source) || $_FILES["qtidoc"]["error"] > UPLOAD_ERR_OK)
00685                 {
00686 //                      $this->ilias->raiseError("No file selected!",$this->ilias->error_obj->MESSAGE);
00687                         $error = 1;
00688                 }
00689                 // check correct file type
00690                 if (strpos("xml", $_FILES["qtidoc"]["type"]) !== FALSE)
00691                 {
00692 //                      $this->ilias->raiseError("Wrong file type!",$this->ilias->error_obj->MESSAGE);
00693                         $error = 1;
00694                 }
00695                 if (!$error)
00696                 {
00697                         // import file into questionpool
00698                         // create import directory
00699                         $this->object->createImportDirectory();
00700 
00701                         // copy uploaded file to import directory
00702                         $full_path = $this->object->getImportDirectory()."/".$_FILES["qtidoc"]["name"];
00703 
00704                         include_once "./classes/class.ilUtil.php";
00705                         ilUtil::moveUploadedFile($_FILES["qtidoc"]["tmp_name"], 
00706                                 $_FILES["qtidoc"]["name"], $full_path);
00707                         //move_uploaded_file($_FILES["qtidoc"]["tmp_name"], $full_path);
00708                         $source = $full_path;
00709 
00710                         $fh = fopen($source, "r") or die("");
00711                         $xml = fread($fh, filesize($source));
00712                         fclose($fh) or die("");
00713                         unlink($source);
00714                         if (preg_match_all("/(<item[^>]*>.*?<\/item>)/si", $xml, $matches))
00715                         {
00716                                 foreach ($matches[1] as $index => $item)
00717                                 {
00718                                         $question = "";
00719                                         if (preg_match("/<qticomment>Questiontype\=(.*?)<\/qticomment>/is", $item, $questiontype))
00720                                         {
00721                                                 include_once "./survey/classes/class.SurveyNominalQuestion.php";
00722                                                 include_once "./survey/classes/class.SurveyOrdinalQuestion.php";
00723                                                 include_once "./survey/classes/class.SurveyMetricQuestion.php";
00724                                                 include_once "./survey/classes/class.SurveyTextQuestion.php";
00725                                                 switch ($questiontype[1])
00726                                                 {
00727                                                         case NOMINAL_QUESTION_IDENTIFIER:
00728                                                                 $question = new SurveyNominalQuestion();
00729                                                                 break;
00730                                                         case ORDINAL_QUESTION_IDENTIFIER:
00731                                                                 $question = new SurveyOrdinalQuestion();
00732                                                                 break;
00733                                                         case METRIC_QUESTION_IDENTIFIER:
00734                                                                 $question = new SurveyMetricQuestion();
00735                                                                 break;
00736                                                         case TEXT_QUESTION_IDENTIFIER:
00737                                                                 $question = new SurveyTextQuestion();
00738                                                                 break;
00739                                                 }
00740                                                 if ($question)
00741                                                 {
00742                                                         $question->setObjId($this->object->getId());
00743                                                         if ($question->from_xml("<questestinterop>$item</questestinterop>"))
00744                                                         {
00745                                                                 $question->saveToDb();
00746                                                         }
00747                                                         else
00748                                                         {
00749                                                                 $this->ilias->raiseError($this->lng->txt("error_importing_question"), $this->ilias->error_obj->MESSAGE);
00750                                                         }
00751                                                 }
00752                                         }
00753                                 }
00754                         }
00755                 }
00756                 $this->ctrl->redirect($this, "questions");
00757         }
00758         
00759         function filterObject()
00760         {
00761                 $this->questionsObject();
00762         }
00763         
00764         function resetObject()
00765         {
00766                 $this->questionsObject();
00767         }
00768         
00773   function questionsObject()
00774   {
00775     global $rbacsystem;
00776                 global $ilUser;
00777 
00778                 $lastquestiontype = $ilUser->getPref("svy_lastquestiontype");
00779                 $filter_text = "";
00780                 $filter_type = "";
00781                 if (count($_POST))
00782                 {
00783                         $filter_text = $_POST["filter_text"];
00784                         $filter_type = $_POST["sel_filter_type"];
00785                 }
00786                 else
00787                 {
00788                         $filter_text = $_GET["filter_text"];
00789                         $filter_type = $_GET["sel_filter_type"];
00790                 }
00791                 
00792                 if (strcmp($this->ctrl->getCmd(), "reset") == 0)
00793                 {
00794                         $filter_text = "";
00795                         $filter_type = "";
00796                 }
00797                 else
00798                 {
00799                         $this->ctrl->setParameter($this, "filter_text", $filter_text);
00800                         $this->ctrl->setParameter($this, "sel_filter_type", $filter_type);
00801                 }
00802 
00803                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_questions.html", true);
00804           if ($rbacsystem->checkAccess('write', $this->ref_id)) {
00805           $this->tpl->addBlockFile("CREATE_QUESTION", "create_question", "tpl.il_svy_qpl_create_new_question.html", true);
00806             $this->tpl->addBlockFile("A_BUTTONS", "a_buttons", "tpl.il_svy_qpl_action_buttons.html", true);
00807                 }
00808     $this->tpl->addBlockFile("FILTER_QUESTION_MANAGER", "filter_questions", "tpl.il_svy_qpl_filter_questions.html", true);
00809 
00810     // create filter form
00811     $filter_fields = array(
00812       "title" => $this->lng->txt("title"),
00813       "description" => $this->lng->txt("description"),
00814       "author" => $this->lng->txt("author"),
00815     );
00816     $this->tpl->setCurrentBlock("filterrow");
00817     foreach ($filter_fields as $key => $value) 
00818                 {
00819       $this->tpl->setVariable("VALUE_FILTER_TYPE", "$key");
00820       $this->tpl->setVariable("NAME_FILTER_TYPE", "$value");
00821       if (!$_POST["cmd"]["reset"]) 
00822                         {
00823         if (strcmp($filter_type, $key) == 0) 
00824                                 {
00825           $this->tpl->setVariable("VALUE_FILTER_SELECTED", " selected=\"selected\"");
00826         }
00827       }
00828       $this->tpl->parseCurrentBlock();
00829     }
00830 
00831     $this->tpl->setCurrentBlock("filter_questions");
00832     $this->tpl->setVariable("FILTER_TEXT", $this->lng->txt("filter"));
00833     $this->tpl->setVariable("TEXT_FILTER_BY", $this->lng->txt("by"));
00834                 if (strcmp($this->ctrl->getCmd(), "reset") != 0)
00835                 {
00836                         $this->tpl->setVariable("VALUE_FILTER_TEXT", $filter_text);
00837                 }
00838     $this->tpl->setVariable("VALUE_SUBMIT_FILTER", $this->lng->txt("set_filter"));
00839     $this->tpl->setVariable("VALUE_RESET_FILTER", $this->lng->txt("reset_filter"));
00840     $this->tpl->parseCurrentBlock();
00841     
00842                 $startrow = 0;
00843                 if ($_GET["prevrow"])
00844                 {
00845                         $startrow = $_GET["prevrow"];
00846                 }               
00847                 if ($_GET["nextrow"])
00848                 {
00849                         $startrow = $_GET["nextrow"];
00850                 }
00851                 if ($_GET["startrow"])
00852                 {
00853                         $startrow = $_GET["startrow"];
00854                 }
00855                 if (!$_GET["sort"])
00856                 {
00857                         // default sort order
00858                         $_GET["sort"] = array("title" => "ASC");
00859                 }
00860                 $table = $this->object->getQuestionsTable($_GET["sort"], $filter_text, $filter_type, $startrow);
00861     $colors = array("tblrow1", "tblrow2");
00862     $counter = 0;
00863                 $last_questionblock_id = 0;
00864                 $editable = $rbacsystem->checkAccess('write', $this->ref_id);
00865                 foreach ($table["rows"] as $data)
00866                 {
00867                         $this->tpl->setCurrentBlock("checkable");
00868                         $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
00869                         $this->tpl->parseCurrentBlock();
00870                         if ($data["complete"] == 0)
00871                         {
00872                                 $this->tpl->setCurrentBlock("qpl_warning");
00873                                 include_once "./classes/class.ilUtil.php";
00874                                 $this->tpl->setVariable("IMAGE_WARNING", ilUtil::getImagePath("warning.gif"));
00875                                 $this->tpl->setVariable("ALT_WARNING", $this->lng->txt("warning_question_not_complete"));
00876                                 $this->tpl->setVariable("TITLE_WARNING", $this->lng->txt("warning_question_not_complete"));
00877                                 $this->tpl->parseCurrentBlock();
00878                         }
00879                         include_once "./survey/classes/class.SurveyQuestion.php";
00880                         $classname = SurveyQuestion::_getQuestionType($data["question_id"]);
00881                         $classnamegui = $classname . "GUI";
00882                         $sel_question_types = $classname; 
00883                         $this->ctrl->setParameterByClass(strtolower($classnamegui), "q_id", $data["question_id"]);
00884                         $this->ctrl->setParameterByClass(strtolower($classnamegui), "sel_question_types", $sel_question_types);
00885                         if ($editable)
00886                         {
00887                                 $this->tpl->setCurrentBlock("url_edit");
00888                                 $this->tpl->setVariable("URL_EDIT", $this->ctrl->getLinkTargetByClass(strtolower($classnamegui), "editQuestion"));
00889                                 $this->tpl->setVariable("TEXT_EDIT", $this->lng->txt("edit"));
00890                                 $this->tpl->parseCurrentBlock();
00891                         }
00892                         $this->tpl->setCurrentBlock("QTab");
00893                         $this->tpl->setVariable("QUESTION_TITLE", "<strong>" . $data["title"] . "</strong>");
00894                         $this->tpl->setVariable("URL_PREVIEW", $this->ctrl->getLinkTargetByClass(strtolower($classnamegui), "preview"));
00895                         $this->tpl->setVariable("TEXT_PREVIEW", $this->lng->txt("preview"));
00896                         $this->tpl->setVariable("QUESTION_DESCRIPTION", $data["description"]);
00897                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($data["type_tag"]));
00898                         $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]);
00899                         include_once "./classes/class.ilFormat.php";
00900                         $this->tpl->setVariable("QUESTION_CREATED", ilFormat::formatDate(ilFormat::ftimestamp2dateDB($data["created"]), "date"));
00901                         $this->tpl->setVariable("QUESTION_UPDATED", ilFormat::formatDate(ilFormat::ftimestamp2dateDB($data["TIMESTAMP14"]), "date"));
00902                         $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
00903                         $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
00904                         $this->tpl->parseCurrentBlock();
00905                         $counter++;
00906     }
00907 
00908                 if ($table["rowcount"] > count($table["rows"]))
00909                 {
00910                         $nextstep = $table["nextrow"] + $table["step"];
00911                         if ($nextstep > $table["rowcount"])
00912                         {
00913                                 $nextstep = $table["rowcount"];
00914                         }
00915                         $sort = "";
00916                         if (is_array($_GET["sort"]))
00917                         {
00918                                 $key = key($_GET["sort"]);
00919                                 $sort = "&sort[$key]=" . $_GET["sort"]["$key"];
00920                         }
00921                         $counter = 1;
00922                         for ($i = 0; $i < $table["rowcount"]; $i += $table["step"])
00923                         {
00924                                 $this->tpl->setCurrentBlock("pages");
00925                                 if ($table["startrow"] == $i)
00926                                 {
00927                                         $this->tpl->setVariable("PAGE_NUMBER", "<span class=\"inactivepage\">$counter</span>");
00928                                 }
00929                                 else
00930                                 {
00931                                         $this->tpl->setVariable("PAGE_NUMBER", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "$sort&nextrow=$i" . "\">$counter</a>");
00932                                 }
00933                                 $this->tpl->parseCurrentBlock();
00934                                 $counter++;
00935                         }
00936                         $this->tpl->setCurrentBlock("navigation_bottom");
00937                         $this->tpl->setVariable("TEXT_ITEM", $this->lng->txt("item"));
00938                         $this->tpl->setVariable("TEXT_ITEM_START", $table["startrow"] + 1);
00939                         $end = $table["startrow"] + $table["step"];
00940                         if ($end > $table["rowcount"])
00941                         {
00942                                 $end = $table["rowcount"];
00943                         }
00944                         $this->tpl->setVariable("TEXT_ITEM_END", $end);
00945                         $this->tpl->setVariable("TEXT_OF", strtolower($this->lng->txt("of")));
00946                         $this->tpl->setVariable("TEXT_ITEM_COUNT", $table["rowcount"]);
00947                         $this->tpl->setVariable("TEXT_PREVIOUS", $this->lng->txt("previous"));
00948                         $this->tpl->setVariable("TEXT_NEXT", $this->lng->txt("next"));
00949                         $this->tpl->setVariable("HREF_PREV_ROWS", $this->ctrl->getLinkTarget($this, "questions") . "$sort&prevrow=" . $table["prevrow"]);
00950                         $this->tpl->setVariable("HREF_NEXT_ROWS", $this->ctrl->getLinkTarget($this, "questions") . "$sort&nextrow=" . $table["nextrow"]);
00951                         $this->tpl->parseCurrentBlock();
00952                 }
00953 
00954     // if there are no questions, display a message
00955     if ($counter == 0) 
00956                 {
00957       $this->tpl->setCurrentBlock("Emptytable");
00958       $this->tpl->setVariable("TEXT_EMPTYTABLE", $this->lng->txt("no_questions_available"));
00959       $this->tpl->parseCurrentBlock();
00960     }
00961                 else
00962                 {
00963                         // create edit buttons & table footer
00964                         if ($rbacsystem->checkAccess('write', $this->ref_id)) 
00965                         {
00966                                         $this->tpl->setCurrentBlock("selectall");
00967                                         $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
00968                                         $counter++;
00969                                         $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
00970                                         $this->tpl->parseCurrentBlock();
00971                                         $this->tpl->setCurrentBlock("standard");
00972                                         $this->tpl->setVariable("DELETE", $this->lng->txt("delete"));
00973                                         $this->tpl->setVariable("DUPLICATE", $this->lng->txt("duplicate"));
00974                                         $this->tpl->setVariable("COPY", $this->lng->txt("copy"));
00975                                         $this->tpl->setVariable("EXPORT", $this->lng->txt("export"));
00976                                         $this->tpl->setVariable("PASTE", $this->lng->txt("paste"));
00977                                         if (strcmp($_SESSION["spl_copied_questions"], "") == 0)
00978                                         {
00979                                                 $this->tpl->setVariable("PASTE_DISABLED", " disabled=\"disabled\"");
00980                                         }
00981                                         $this->tpl->setVariable("QUESTIONBLOCK", $this->lng->txt("define_questionblock"));
00982                                         $this->tpl->setVariable("UNFOLD", $this->lng->txt("unfold"));
00983                                         $this->tpl->parseCurrentBlock();
00984                                         $this->tpl->setCurrentBlock("Footer");
00985                                         include_once "./classes/class.ilUtil.php";
00986                                         $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\">");
00987                                         $this->tpl->parseCurrentBlock();
00988                         }    
00989                 }
00990     
00991           if ($rbacsystem->checkAccess('write', $this->ref_id)) 
00992                 {
00993                         // "create question" form
00994                         $this->tpl->setCurrentBlock("QTypes");
00995                         $query = "SELECT * FROM survey_questiontype ORDER BY questiontype_id";
00996                         $query_result = $this->ilias->db->query($query);
00997                         while ($data = $query_result->fetchRow(DB_FETCHMODE_OBJECT))
00998                         {
00999                                 if ($lastquestiontype == $data->questiontype_id)
01000                                 {
01001                                         $this->tpl->setVariable("QUESTION_TYPE_SELECTED", " selected=\"selected\"");
01002                                 }
01003                                 $this->tpl->setVariable("QUESTION_TYPE_ID", $data->type_tag);
01004                                 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($data->type_tag));
01005                                 $this->tpl->parseCurrentBlock();
01006                         }
01007                         $this->tpl->setCurrentBlock("CreateQuestion");
01008                         $this->tpl->setVariable("QUESTION_ADD", $this->lng->txt("create"));
01009                         $this->tpl->setVariable("QUESTION_IMPORT", $this->lng->txt("import"));
01010                         $this->tpl->setVariable("ACTION_QUESTION_ADD", $this->ctrl->getFormAction($this));
01011                         $this->tpl->parseCurrentBlock();
01012                 }
01013     // define the sort column parameters
01014     $sortcolumns = array(
01015       "title" => $_GET["sort"]["title"],
01016       "description" => $_GET["sort"]["description"],
01017       "type" => $_GET["sort"]["type"],
01018       "author" => $_GET["sort"]["author"],
01019       "created" => $_GET["sort"]["created"],
01020       "updated" => $_GET["sort"]["updated"]
01021     );
01022     foreach ($sortcolumns as $key => $value) {
01023       if (strcmp($value, "ASC") == 0) {
01024         $sortcolumns[$key] = "DESC";
01025       } else {
01026         $sortcolumns[$key] = "ASC";
01027       }
01028     }
01029     
01030     $this->tpl->setCurrentBlock("adm_content");
01031     // create table header
01032                 $this->ctrl->setParameterByClass(get_class($this), "startrow", $table["startrow"]);
01033     $this->tpl->setVariable("QUESTION_TITLE", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&sort[title]=" . $sortcolumns["title"] . "\">" . $this->lng->txt("title") . "</a>" . $table["images"]["title"]);
01034     $this->tpl->setVariable("QUESTION_DESCRIPTION", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&sort[description]=" . $sortcolumns["description"] . "\">" . $this->lng->txt("description") . "</a>". $table["images"]["description"]);
01035     $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"]);
01036     $this->tpl->setVariable("QUESTION_AUTHOR", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&sort[author]=" . $sortcolumns["author"] . "\">" . $this->lng->txt("author") . "</a>" . $table["images"]["author"]);
01037     $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"]);
01038     $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"]);
01039     $this->tpl->setVariable("BUTTON_CANCEL", $this->lng->txt("cancel"));
01040     $this->tpl->setVariable("ACTION_QUESTION_FORM", $this->ctrl->getFormAction($this) . $sort);
01041     $this->tpl->parseCurrentBlock();
01042                 unset($_SESSION["calling_survey"]);
01043   }
01044 
01045 
01046         function updateObject() {
01047                 $this->update = $this->object->update();
01048                 sendInfo($this->lng->txt("msg_obj_modified"), true);
01049         }
01050 
01051         /*
01052         * list all export files
01053         */
01054         function exportObject()
01055         {
01056                 global $tree;
01057 
01058                 //$this->setTabs();
01059 
01060                 //add template for view button
01061                 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
01062 
01063                 // create export file button
01064                 $this->tpl->setCurrentBlock("btn_cell");
01065                 $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "createExportFile"));
01066                 $this->tpl->setVariable("BTN_TXT", $this->lng->txt("svy_create_export_file"));
01067                 $this->tpl->parseCurrentBlock();
01068 
01069                 $export_dir = $this->object->getExportDirectory();
01070                 $export_files = $this->object->getExportFiles($export_dir);
01071 
01072                 // create table
01073                 include_once("./classes/class.ilTableGUI.php");
01074                 $tbl = new ilTableGUI();
01075 
01076                 // load files templates
01077                 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
01078 
01079                 // load template for table content data
01080                 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.export_file_row.html", true);
01081 
01082                 $num = 0;
01083 
01084                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01085 
01086                 $tbl->setTitle($this->lng->txt("svy_export_files"));
01087 
01088                 $tbl->setHeaderNames(array("", $this->lng->txt("svy_file"),
01089                         $this->lng->txt("svy_size"), $this->lng->txt("date") ));
01090 
01091                 $tbl->enabled["sort"] = false;
01092                 $tbl->setColumnWidth(array("1%", "49%", "25%", "25%"));
01093 
01094                 // control
01095                 $tbl->setOrderColumn($_GET["sort_by"]);
01096                 $tbl->setOrderDirection($_GET["sort_order"]);
01097                 $tbl->setLimit($_GET["limit"]);
01098                 $tbl->setOffset($_GET["offset"]);
01099                 $tbl->setMaxCount($this->maxcount);             // ???
01100                 $header_params = $this->ctrl->getParameterArray($this, "export");
01101                 $tbl->setHeaderVars(array("", "file", "size", "date"), $header_params);
01102 
01103                 // delete button
01104                 include_once "./classes/class.ilUtil.php";
01105 
01106                 // footer
01107                 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
01108                 //$tbl->disable("footer");
01109 
01110                 $tbl->setMaxCount(count($export_files));
01111                 $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
01112 
01113                 $tbl->render();
01114                 if(count($export_files) > 0)
01115                 {
01116                         $this->tpl->setVariable("COLUMN_COUNTS", 4);
01117 
01118                         $i=0;
01119                         foreach($export_files as $exp_file)
01120                         {
01121                                 $this->tpl->setCurrentBlock("tbl_content");
01122                                 $this->tpl->setVariable("TXT_FILENAME", $exp_file);
01123 
01124                                 $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
01125                                 $this->tpl->setVariable("CSS_ROW", $css_row);
01126 
01127                                 $this->tpl->setVariable("TXT_SIZE", filesize($export_dir."/".$exp_file));
01128                                 $this->tpl->setVariable("CHECKBOX_ID", $exp_file);
01129 
01130                                 $file_arr = explode("__", $exp_file);
01131                                 $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s",$file_arr[0]));
01132 
01133                                 $this->tpl->parseCurrentBlock();
01134                         }
01135                         $this->tpl->setCurrentBlock("selectall");
01136                         $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
01137                         $this->tpl->setVariable("CSS_ROW", $css_row);
01138                         $this->tpl->parseCurrentBlock();
01139                         $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
01140                         $this->tpl->setCurrentBlock("tbl_action_btn");
01141                         $this->tpl->setVariable("BTN_NAME", "confirmDeleteExportFile");
01142                         $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
01143                         $this->tpl->parseCurrentBlock();
01144         
01145                         $this->tpl->setCurrentBlock("tbl_action_btn");
01146                         $this->tpl->setVariable("BTN_NAME", "downloadExportFile");
01147                         $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("download"));
01148                         $this->tpl->parseCurrentBlock();
01149                 } //if is_array
01150                 else
01151                 {
01152                         $this->tpl->setCurrentBlock("notfound");
01153                         $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
01154                         $this->tpl->setVariable("NUM_COLS", 3);
01155                         $this->tpl->parseCurrentBlock();
01156                 }
01157 
01158                 $this->tpl->parseCurrentBlock();
01159         }
01160 
01164         function createExportFileObject($questions = null)
01165         {
01166                 global $rbacsystem;
01167                 
01168                 if ($rbacsystem->checkAccess("write", $this->ref_id))
01169                 {
01170                         include_once("./survey/classes/class.ilSurveyQuestionpoolExport.php");
01171                         $survey_exp = new ilSurveyQuestionpoolExport($this->object);
01172                         $survey_exp->buildExportFile($questions);
01173                         $this->ctrl->redirect($this, "export");
01174                 }
01175                 else
01176                 {
01177                         sendInfo("cannot_export_questionpool");
01178                 }
01179         }
01180         
01184         function downloadExportFileObject()
01185         {
01186                 if(!isset($_POST["file"]))
01187                 {
01188                         sendInfo($this->lng->txt("no_checkbox"), true);
01189                         $this->ctrl->redirect($this, "export");
01190                 }
01191 
01192                 if (count($_POST["file"]) > 1)
01193                 {
01194                         sendInfo($this->lng->txt("select_max_one_item"),true);
01195                         $this->ctrl->redirect($this, "export");
01196                 }
01197 
01198 
01199                 $export_dir = $this->object->getExportDirectory();
01200                 include_once "./classes/class.ilUtil.php";
01201                 ilUtil::deliverFile($export_dir."/".$_POST["file"][0],
01202                         $_POST["file"][0]);
01203         }
01204 
01208         function confirmDeleteExportFileObject()
01209         {
01210                 if(!isset($_POST["file"]))
01211                 {
01212                         sendInfo($this->lng->txt("no_checkbox"),true);
01213                         $this->ctrl->redirect($this, "export");
01214                 }
01215 
01216                 //$this->setTabs();
01217 
01218                 // SAVE POST VALUES
01219                 $_SESSION["ilExportFiles"] = $_POST["file"];
01220 
01221                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html", true);
01222 
01223                 sendInfo($this->lng->txt("info_delete_sure"));
01224 
01225                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01226 
01227                 // BEGIN TABLE HEADER
01228                 $this->tpl->setCurrentBlock("table_header");
01229                 $this->tpl->setVariable("TEXT",$this->lng->txt("objects"));
01230                 $this->tpl->parseCurrentBlock();
01231 
01232                 // BEGIN TABLE DATA
01233                 $counter = 0;
01234                 include_once "./classes/class.ilUtil.php";
01235                 foreach($_POST["file"] as $file)
01236                 {
01237                                 $this->tpl->setCurrentBlock("table_row");
01238                                 $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_file.gif"));
01239                                 $this->tpl->setVariable("TEXT_IMG_OBJ", $this->lng->txt("file_icon"));
01240                                 $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
01241                                 $this->tpl->setVariable("TEXT_CONTENT", $file);
01242                                 $this->tpl->parseCurrentBlock();
01243                 }
01244 
01245                 // cancel/confirm button
01246                 $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
01247                 $buttons = array( 
01248                         "deleteExportFile"  => $this->lng->txt("confirm"),
01249                         "cancelDeleteExportFile"  => $this->lng->txt("cancel")
01250                         );
01251                 foreach ($buttons as $name => $value)
01252                 {
01253                         $this->tpl->setCurrentBlock("operation_btn");
01254                         $this->tpl->setVariable("BTN_NAME",$name);
01255                         $this->tpl->setVariable("BTN_VALUE",$value);
01256                         $this->tpl->parseCurrentBlock();
01257                 }
01258         }
01259 
01260 
01264         function cancelDeleteExportFileObject()
01265         {
01266                 session_unregister("ilExportFiles");
01267                 $this->ctrl->redirect($this, "export");
01268         }
01269 
01270 
01274         function deleteExportFileObject()
01275         {
01276                 $export_dir = $this->object->getExportDirectory();
01277                 foreach($_SESSION["ilExportFiles"] as $file)
01278                 {
01279                         $exp_file = $export_dir."/".$file;
01280                         $exp_dir = $export_dir."/".substr($file, 0, strlen($file) - 4);
01281                         if (@is_file($exp_file))
01282                         {
01283                                 unlink($exp_file);
01284                         }
01285                         if (@is_dir($exp_dir))
01286                         {
01287                                 include_once "./classes/class.ilUtil.php";
01288                                 ilUtil::delDir($exp_dir);
01289                         }
01290                 }
01291                 $this->ctrl->redirect($this, "export");
01292         }
01293 
01299         function importObject()
01300         {
01301                 global $rbacsystem;
01302                 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"]))
01303                 {
01304                         $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
01305                 }
01306                 $this->getTemplateFile("import", "spl");
01307                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01308                 $this->tpl->setVariable("BTN_NAME", "uploadSpl");
01309                 $this->tpl->setVariable("TXT_UPLOAD", $this->lng->txt("upload"));
01310                 $this->tpl->setVariable("TXT_IMPORT_SPL", $this->lng->txt("import_spl"));
01311                 $this->tpl->setVariable("TXT_SELECT_MODE", $this->lng->txt("select_mode"));
01312                 $this->tpl->setVariable("TXT_SELECT_FILE", $this->lng->txt("select_file"));
01313         }
01314 
01318         function uploadSplObject($redirect = true)
01319         {
01320                 if ($_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK)
01321                 {
01322                         sendInfo($this->lng->txt("spl_select_file_for_import"));
01323                         $this->importObject();
01324                         return;
01325                 }
01326                 include_once "./survey/classes/class.ilObjSurveyQuestionPool.php";
01327                 // create new questionpool object
01328                 $newObj = new ilObjSurveyQuestionPool();
01329                 // set type of questionpool object
01330                 $newObj->setType($_GET["new_type"]);
01331                 // set title of questionpool object to "dummy"
01332                 $newObj->setTitle("dummy");
01333                 // set description of questionpool object to "dummy"
01334                 //$newObj->setDescription("dummy");
01335                 // create the questionpool class in the ILIAS database (object_data table)
01336                 $newObj->create(true);
01337                 // create a reference for the questionpool object in the ILIAS database (object_reference table)
01338                 $newObj->createReference();
01339                 // put the questionpool object in the administration tree
01340                 $newObj->putInTree($_GET["ref_id"]);
01341                 // get default permissions and set the permissions for the questionpool object
01342                 $newObj->setPermissions($_GET["ref_id"]);
01343                 // notify the questionpool object and all its parent objects that a "new" object was created
01344                 $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
01345 
01346                 // create import directory
01347                 $newObj->createImportDirectory();
01348 
01349                 // copy uploaded file to import directory
01350                 $file = pathinfo($_FILES["xmldoc"]["name"]);
01351                 $full_path = $newObj->getImportDirectory()."/".$_FILES["xmldoc"]["name"];
01352                 include_once "./classes/class.ilUtil.php";
01353                 ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"], 
01354                         $_FILES["xmldoc"]["name"], $full_path);
01355                 //move_uploaded_file($_FILES["xmldoc"]["tmp_name"], $full_path);
01356 
01357                 // import qti data
01358                 $qtiresult = $newObj->importObject($full_path);
01359 
01360                 if ($redirect)
01361                 {
01362                         $this->ctrl->redirect($this, "cancel");
01363 //                      ilUtil::redirect("adm_object.php?".$this->link_params);
01364                 }
01365                 return $newObj->getRefId();
01366         }
01367 
01371         function createObject()
01372         {
01373                 global $rbacsystem;
01374                 $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
01375                 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
01376                 {
01377                         $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
01378                 }
01379                 else
01380                 {
01381                         $this->getTemplateFile("create", $new_type);
01382 
01383                         include_once("./survey/classes/class.ilObjSurvey.php");
01384                         
01385                         // fill in saved values in case of error
01386                         $data = array();
01387                         $data["fields"] = array();
01388                         include_once "./classes/class.ilUtil.php";
01389                         $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
01390                         $data["fields"]["desc"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["desc"]);
01391 
01392                         foreach ($data["fields"] as $key => $val)
01393                         {
01394                                 $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
01395                                 $this->tpl->setVariable(strtoupper($key), $val);
01396 
01397                                 if ($this->prepare_output)
01398                                 {
01399                                         $this->tpl->parseCurrentBlock();
01400                                 }
01401                         }
01402 
01403                         $this->ctrl->setParameter($this, "new_type", $this->type);
01404                         $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01405                         $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
01406                         $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
01407                         $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
01408                         $this->tpl->setVariable("CMD_SUBMIT", "save");
01409                         $this->tpl->setVariable("TARGET", ' target="'.
01410                                 ilFrameTargetInfo::_getFrame("MainContent").'" ');
01411                         $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
01412 
01413                         $this->tpl->setVariable("TXT_IMPORT_SPL", $this->lng->txt("import_spl"));
01414                         $this->tpl->setVariable("TXT_SPL_FILE", $this->lng->txt("spl_upload_file"));
01415                         $this->tpl->setVariable("TXT_IMPORT", $this->lng->txt("import"));
01416 
01417                         $this->tpl->setVariable("TYPE_IMG", ilUtil::getImagePath('icon_spl.gif'));
01418                         $this->tpl->setVariable("ALT_IMG",$this->lng->txt("obj_spl"));
01419                         $this->tpl->setVariable("TYPE_IMG2", ilUtil::getImagePath('icon_spl.gif'));
01420                         $this->tpl->setVariable("ALT_IMG2",$this->lng->txt("obj_spl"));
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                 // always send a message
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                 $next_class = $this->ctrl->getNextClass($this);
01522                 switch ($next_class)
01523                 {
01524                         case "":
01525                         case "ilpermissiongui":
01526                         case "ilmdeditorgui":
01527                                 break;
01528                         default:
01529                                 return;
01530                                 break;
01531                 }
01532                 if (($_GET["calling_survey"] > 0) || ($_GET["new_for_survey"] > 0)) return;
01533                 // properties
01534                 $tabs_gui->addTarget("properties",
01535                          $this->ctrl->getLinkTarget($this,'properties'),
01536                          "properties", 
01537                          "", "");
01538                 // questions
01539                 $force_active = ($this->ctrl->getCmdClass() == "" ||
01540                         $this->ctrl->getCmd() == "")
01541                         ? true
01542                         : false;
01543                 if (!$force_active)
01544                 {
01545                         if (is_array($_GET["sort"]))
01546                         {
01547                                 $force_active = true;
01548                         }
01549                 }
01550                 $tabs_gui->addTarget("survey_questions",
01551                          $this->ctrl->getLinkTarget($this,'questions'),
01552                          array("questions", "filter", "reset", "createQuestion", 
01553                          "importQuestions", "deleteQuestions", "duplicate", "copy", "paste", 
01554                          "exportQuestions", "confirmDeleteQuestions", "cancelDeleteQuestions",
01555                          "confirmPasteQuestions", "cancelPasteQuestions", "uploadQuestions",
01556                          "editQuestion", "addMaterial", "removeMaterial", "save", "cancel",
01557                          "cancelExplorer", "linkChilds", "addGIT", "addST", "addPG", "preview",
01558                          "moveCategory", "deleteCategory", "addPhrase", "addCategory", "savePhrase",
01559                          "addSelectedPhrase", "cancelViewPhrase", "confirmSavePhrase", "cancelSavePhrase",
01560                          "insertBeforeCategory", "insertAfterCategory", "confirmDeleteCategory",
01561                          "cancelDeleteCategory", "categories", "saveCategories", 
01562                          "savePhrase", "addPhrase"
01563                          ),
01564                          "", "", $force_active);
01565 
01566                 // meta data
01567                 $tabs_gui->addTarget("meta_data",
01568                          $this->ctrl->getLinkTargetByClass('ilmdeditorgui','listSection'),
01569                          "", "ilmdeditorgui");
01570 
01571                 // manage phrases
01572                 $tabs_gui->addTarget("manage_phrases",
01573                          $this->ctrl->getLinkTarget($this,'phrases'),
01574                          array("phrases", "deletePhrase", "confirmDeletePhrase", "cancelDeletePhrase"),
01575                          "", "");
01576                         
01577                 // export
01578                 $tabs_gui->addTarget("export",
01579                          $this->ctrl->getLinkTarget($this,'export'),
01580                          array("export", "createExportFile", "confirmDeleteExportFile", 
01581                          "downloadExportFile", "cancelDeleteExportFile", "deleteExportFile"),
01582                          "", "");
01583 
01584                 // permissions
01585                 $tabs_gui->addTarget("perm_settings",
01586                         $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
01587         }
01588 
01589 } // END class.ilObjSurveyQuestionPoolGUI
01590 ?>

Generated on Fri Dec 13 2013 13:52:15 for ILIAS Release_3_7_x_branch .rev 46817 by  doxygen 1.7.1