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

assessment/classes/class.ilObjQuestionPoolGUI.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 
00041 require_once "./classes/class.ilObjectGUI.php";
00042 require_once "./assessment/classes/class.assQuestionGUI.php";
00043 require_once "./assessment/classes/class.ilObjQuestionPool.php";
00044 
00045 class ilObjQuestionPoolGUI extends ilObjectGUI
00046 {
00051         function ilObjQuestionPoolGUI($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
00052         {
00053         global $lng, $ilCtrl;
00054 
00055                 $this->type = "qpl";
00056                 $lng->loadLanguageModule("assessment");
00057                 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference, false);
00058                 $this->ctrl =& $ilCtrl;
00059                 $this->ctrl->saveParameter($this, array("ref_id", "test_ref_id", "calling_test"));
00060 
00061                 if (!defined("ILIAS_MODULE"))
00062                 {
00063                         $this->setTabTargetScript("adm_object.php");
00064                 }
00065                 else
00066                 {
00067                         $this->setTabTargetScript("questionpool.php");
00068                 }
00069                 if ($a_prepare_output)
00070                 {
00071                         include_once("classes/class.ilObjStyleSheet.php");
00072                         $this->prepareOutput();
00073                         $this->tpl->setCurrentBlock("ContentStyle");
00074                         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00075                                 ilObjStyleSheet::getContentStylePath(0));
00076                         $this->tpl->parseCurrentBlock();
00077 
00078                         // syntax style
00079                         $this->tpl->setCurrentBlock("SyntaxStyle");
00080                         $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
00081                                 ilObjStyleSheet::getSyntaxStylePath());
00082                         $this->tpl->parseCurrentBlock();
00083 
00084                 }
00085 //echo "<br>ilObjQuestionPool_End of constructor.";
00086         }
00087 
00091         function &executeCommand()
00092         {
00093                 $cmd = $this->ctrl->getCmd("questions");
00094                 $next_class = $this->ctrl->getNextClass($this);
00095                 $this->ctrl->setReturn($this, "questions");
00096                 if ($_GET["q_id"] < 1)
00097                 {
00098                         $q_type = ($_POST["sel_question_types"] != "")
00099                                 ? $_POST["sel_question_types"]
00100                                 : $_GET["sel_question_types"];
00101                 }
00102 
00103                 if ($cmd != "createQuestion" && $cmd != "createQuestionForTest"
00104                         && $next_class != "ilpageobjectgui")
00105                 {
00106                         if (($_GET["test_ref_id"] != "") or ($_GET["calling_test"]))
00107                         {
00108                                 $ref_id = $_GET["test_ref_id"];
00109                                 if (!$ref_id)
00110                                 {
00111                                         $ref_id = $_GET["calling_test"];
00112                                 }
00113                                 include_once "./classes/class.ilTabsGUI.php";
00114                                 $tabs_gui =& new ilTabsGUI();
00115 
00116                                 $tabs_gui->addTarget("back",
00117                                         "test.php?ref_id=$ref_id&cmd=questions", "", "");
00118 
00119                                 // output tabs
00120                                 $this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00121                         }
00122                 }
00123 
00124 //echo "<br>nextclass:$next_class:cmd:$cmd:";
00125                 switch($next_class)
00126                 {
00127                         case 'ilmdeditorgui':
00128                                 $this->setAdminTabs();
00129                                 include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
00130 
00131                                 $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
00132                                 $md_gui->addObserver($this->object,'MDUpdateListener','General');
00133 
00134                                 $this->ctrl->forwardCommand($md_gui);
00135                                 break;
00136 
00137                         case "ilpageobjectgui":
00138 
00139                                 $q_gui =& ASS_QuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
00140                                 $q_gui->object->setObjId($this->object->getId());
00141                                 $question =& $q_gui->object;
00142                                 $this->tpl->setVariable("HEADER", $question->getTitle());
00143                                 $this->ctrl->saveParameter($this, "q_id");
00144                                 $count = $question->isInUse();
00145                                 if (($count) && strcmp($this->ctrl->getCmd(), "view") == 0)
00146                                 {
00147                                         global $rbacsystem;
00148                                         if ($rbacsystem->checkAccess("write", $this->ref_id))
00149                                         {
00150                                                 sendInfo(sprintf($this->lng->txt("qpl_question_is_in_use"), $count));
00151                                         }
00152                                 }
00153                                 include_once("content/classes/Pages/class.ilPageObjectGUI.php");
00154                                 $this->lng->loadLanguageModule("content");
00155                                 $this->setQuestionTabs();
00156                                 //$this->setPageEditorTabs();
00157                                 $this->ctrl->setReturnByClass("ilPageObjectGUI", "view");
00158                                 $this->ctrl->setReturn($this, "questions");
00159                                 $page =& new ilPageObject("qpl", $_GET["q_id"]);
00160                                 $page_gui =& new ilPageObjectGUI($page);
00161                                 if (strlen($this->ctrl->getCmd()) == 0)
00162                                 {
00163                                         $this->ctrl->setCmdClass(get_class($page_gui));
00164                                         $this->ctrl->setCmd("preview");
00165                                 }
00166                                 $page_gui->setQuestionXML($question->to_xml(false, false, true));
00167                                 $page_gui->setTemplateTargetVar("ADM_CONTENT");
00168                                 $page_gui->setOutputMode("edit");
00169                                 $page_gui->setHeader($question->getTitle());
00170                                 $page_gui->setFileDownloadLink("questionpool.php?cmd=downloadFile".
00171                                         "&amp;ref_id=".$_GET["ref_id"]);
00172                                 $page_gui->setFullscreenLink("questionpool.php?cmd=fullscreen".
00173                                         "&amp;ref_id=".$_GET["ref_id"]);
00174                                 $page_gui->setSourcecodeDownloadScript("questionpool.php?ref_id=".$_GET["ref_id"]);
00175                                 $page_gui->setPresentationTitle($question->getTitle());
00176                                 $ret =& $this->ctrl->forwardCommand($page_gui);
00177 
00178                                 break;
00179 
00180 
00181                         case "ass_multiplechoicegui":
00182                         case "ass_clozetestgui":
00183                         case "ass_orderingquestiongui":
00184                         case "ass_matchingquestiongui":
00185                         case "ass_imagemapquestiongui":
00186                         case "ass_javaappletgui":
00187                         case "ass_textquestiongui":
00188                                 $this->setQuestionTabs();
00189                                 $this->ctrl->setReturn($this, "questions");
00190                                 $q_gui =& ASS_QuestionGUI::_getQuestionGUI($q_type, $_GET["q_id"]);
00191                                 $q_gui->object->setObjId($this->object->getId());
00192                                 $count = $q_gui->object->isInUse();
00193                                 if (($count) && strcmp($this->ctrl->getCmd(), "assessment") != 0)
00194                                 {
00195                                         global $rbacsystem;
00196                                         if ($rbacsystem->checkAccess("write", $this->ref_id))
00197                                         {
00198                                                 sendInfo(sprintf($this->lng->txt("qpl_question_is_in_use"), $count));
00199                                         }
00200                                 }
00201                                 $ret =& $this->ctrl->forwardCommand($q_gui);
00202                                 break;
00203 
00204                         default:
00205 //                              echo "setAdminTabs<br>";
00206                                 if ($cmd != "createQuestion" && $cmd != "createQuestionForTest" && $cmd != "editQuestionForTest")
00207                                 {
00208                                         $this->setAdminTabs();
00209                                 }
00210                                 $cmd.= "Object";
00211                                 $ret =& $this->$cmd();
00212                                 break;
00213                 }
00214         }
00215 
00219         function downloadFileObject()
00220         {
00221                 $file = explode("_", $_GET["file_id"]);
00222                 require_once("classes/class.ilObjFile.php");
00223                 $fileObj =& new ilObjFile($file[count($file) - 1], false);
00224                 $fileObj->sendFile();
00225                 exit;
00226         }
00227         
00231         function fullscreenObject()
00232         {
00233                 $page =& new ilPageObject("qpl", $_GET["pg_id"]);
00234                 include_once("content/classes/Pages/class.ilPageObjectGUI.php");
00235                 $page_gui =& new ilPageObjectGUI($page);
00236                 $page_gui->showMediaFullscreen();
00237                 
00238         }
00239 
00240 
00244         function filterObject()
00245         {
00246                 $this->questionsObject();
00247         }
00248 
00252         function resetFilterObject()
00253         {
00254                 $_POST["filter_text"] = "";
00255                 $_POST["sel_filter_type"] = "";
00256                 $this->questionsObject();
00257         }
00258 
00262         function download_paragraphObject()
00263         {
00264                 require_once("content/classes/Pages/class.ilPageObject.php");
00265                 $pg_obj =& new ilPageObject("qpl", $_GET["pg_id"]);
00266                 $pg_obj->send_paragraph ($_GET["par_id"], $_GET["downloadtitle"]);
00267                 exit;
00268         }
00269 
00273         function uploadQplObject($questions_only = false)
00274         {
00275                 if ($_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK)
00276                 {
00277                         sendInfo($this->lng->txt("error_upload"));
00278                         $this->importObject();
00279                         return;
00280                 }
00281                 // create import directory
00282                 ilObjQuestionPool::_createImportDirectory();
00283 
00284                 // copy uploaded file to import directory
00285                 $file = pathinfo($_FILES["xmldoc"]["name"]);
00286                 $full_path = ilObjQuestionPool::_getImportDirectory()."/".$_FILES["xmldoc"]["name"];
00287                 ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"], $_FILES["xmldoc"]["name"], $full_path);
00288 
00289                 // unzip file
00290                 ilUtil::unzip($full_path);
00291 
00292                 // determine filenames of xml files
00293                 $subdir = basename($file["basename"],".".$file["extension"]);
00294                 $xml_file = ilObjQuestionPool::_getImportDirectory()."/".$subdir."/".$subdir.".xml";
00295                 $qti_file = ilObjQuestionPool::_getImportDirectory()."/".$subdir."/". str_replace("qpl", "qti", $subdir).".xml";
00296 
00297                 // start verification of QTI files
00298                 include_once "./assessment/classes/class.ilQTIParser.php";
00299                 $qtiParser = new ilQTIParser($qti_file, IL_MO_VERIFY_QTI, 0, "");
00300                 $result = $qtiParser->startParsing();
00301                 $founditems =& $qtiParser->getFoundItems();
00302                 
00303                 if (count($founditems) == 0)
00304                 {
00305                         // nothing found
00306 
00307                         // delete import directory
00308                         ilUtil::delDir(ilObjQuestionPool::_getImportDirectory());
00309 
00310                         sendInfo($this->lng->txt("qpl_import_no_items"));
00311                         $this->importObject();
00312                         return;
00313                 }
00314                 
00315                 $complete = 0;
00316                 $incomplete = 0;
00317                 foreach ($founditems as $item)
00318                 {
00319                         if (strlen($item["type"]))
00320                         {
00321                                 $complete++;
00322                         }
00323                         else
00324                         {
00325                                 $incomplete++;
00326                         }
00327                 }
00328                 
00329                 if ($complete == 0)
00330                 {
00331                         // delete import directory
00332                         ilUtil::delDir(ilObjQuestionPool::_getImportDirectory());
00333 
00334                         sendInfo($this->lng->txt("qpl_import_non_ilias_files"));
00335                         $this->importObject();
00336                         return;
00337                 }
00338                 
00339                 $_SESSION["qpl_import_xml_file"] = $xml_file;
00340                 $_SESSION["qpl_import_qti_file"] = $qti_file;
00341                 $_SESSION["qpl_import_subdir"] = $subdir;
00342                 // display of found questions
00343                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.qpl_import_verification.html");
00344                 $row_class = array("tblrow1", "tblrow2");
00345                 $counter = 0;
00346                 foreach ($founditems as $item)
00347                 {
00348                         $this->tpl->setCurrentBlock("verification_row");
00349                         $this->tpl->setVariable("ROW_CLASS", $row_class[$counter++ % 2]);
00350                         $this->tpl->setVariable("QUESTION_TITLE", $item["title"]);
00351                         $this->tpl->setVariable("QUESTION_IDENT", $item["ident"]);
00352                         switch ($item["type"])
00353                         {
00354                                 case "MULTIPLE CHOICE QUESTION":
00355                                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("qt_multiple_choice"));
00356                                         break;
00357                                 case "CLOZE QUESTION":
00358                                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("qt_cloze"));
00359                                         break;
00360                                 case "IMAGE MAP QUESTION":
00361                                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("qt_imagemap"));
00362                                         break;
00363                                 case "JAVA APPLET QUESTION":
00364                                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("qt_javaapplet"));
00365                                         break;
00366                                 case "MATCHING QUESTION":
00367                                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("qt_matching"));
00368                                         break;
00369                                 case "ORDERING QUESTION":
00370                                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("qt_ordering"));
00371                                         break;
00372                                 case "TEXT QUESTION":
00373                                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("qt_text"));
00374                                         break;
00375                         }
00376                         $this->tpl->parseCurrentBlock();
00377                 }
00378                 
00379                 $this->tpl->setCurrentBlock("import_qpl");
00380                 if (is_file($xml_file))
00381                 {
00382                         // read file into a string
00383                         $fh = @fopen($xml_file, "r") or die("");
00384                         $xml = @fread($fh, filesize($xml_file));
00385                         @fclose($fh);
00386                         if (preg_match("/<ContentObject.*?MetaData.*?General.*?Title[^>]*?>([^<]*?)</", $xml, $matches))
00387                         {
00388                                 $this->tpl->setVariable("VALUE_NEW_QUESTIONPOOL", $matches[1]);
00389                         }
00390                 }
00391                 $this->tpl->setVariable("TEXT_CREATE_NEW_QUESTIONPOOL", $this->lng->txt("qpl_import_create_new_qpl"));
00392                 $this->tpl->parseCurrentBlock();
00393                 
00394                 $this->tpl->setCurrentBlock("adm_content");
00395                 $this->tpl->setVariable("TEXT_TYPE", $this->lng->txt("question_type"));
00396                 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("question_title"));
00397                 $this->tpl->setVariable("FOUND_QUESTIONS_INTRODUCTION", $this->lng->txt("qpl_import_verify_found_questions"));
00398                 if ($questions_only)
00399                 {
00400                         $this->tpl->setVariable("VERIFICATION_HEADING", $this->lng->txt("import_questions_into_qpl"));
00401                         $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00402                 }
00403                 else
00404                 {
00405                         $this->tpl->setVariable("VERIFICATION_HEADING", $this->lng->txt("import_qpl"));
00406                         $this->tpl->setVariable("FORMACTION", $this->getFormAction("save","adm_object.php?cmd=gateway&ref_id=".$_GET["ref_id"]."&new_type=".$this->type));
00407                 }
00408                 $this->tpl->setVariable("ARROW", ilUtil::getImagePath("arrow_downright.gif"));
00409                 $this->tpl->setVariable("VALUE_IMPORT", $this->lng->txt("import"));
00410                 $this->tpl->setVariable("VALUE_CANCEL", $this->lng->txt("cancel"));
00411                 $value_questions_only = 0;
00412                 if ($questions_only) $value_questions_only = 1;
00413                 $this->tpl->setVariable("VALUE_QUESTIONS_ONLY", $value_questions_only);
00414 
00415                 $this->tpl->parseCurrentBlock();
00416         }
00417         
00421         function importVerifiedFileObject()
00422         {
00423                 if ($_POST["questions_only"] == 1)
00424                 {
00425                         $newObj =& $this->object;
00426                 }
00427                 else
00428                 {
00429                         // create new questionpool object
00430                         $newObj = new ilObjQuestionpool(true);
00431                         // set type of questionpool object
00432                         $newObj->setType($_GET["new_type"]);
00433                         // set title of questionpool object to "dummy"
00434                         $newObj->setTitle("dummy");
00435                         // set description of questionpool object
00436                         $newObj->setDescription("questionpool import");
00437                         // create the questionpool class in the ILIAS database (object_data table)
00438                         $newObj->create(true);
00439                         // create a reference for the questionpool object in the ILIAS database (object_reference table)
00440                         $newObj->createReference();
00441                         // put the questionpool object in the administration tree
00442                         $newObj->putInTree($_GET["ref_id"]);
00443                         // get default permissions and set the permissions for the questionpool object
00444                         $newObj->setPermissions($_GET["ref_id"]);
00445                         // notify the questionpool object and all its parent objects that a "new" object was created
00446                         $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
00447                 }
00448 
00449                 // start parsing of QTI files
00450                 include_once "./assessment/classes/class.ilQTIParser.php";
00451                 $qtiParser = new ilQTIParser($_SESSION["qpl_import_qti_file"], IL_MO_PARSE_QTI, $newObj->getId(), $_POST["ident"]);
00452                 $result = $qtiParser->startParsing();
00453 
00454                 // import page data
00455                 include_once ("content/classes/class.ilContObjParser.php");
00456                 $contParser = new ilContObjParser($newObj, $_SESSION["qpl_import_xml_file"], $_SESSION["qpl_import_subdir"]);
00457                 $contParser->setQuestionMapping($qtiParser->getImportMapping());
00458                 $contParser->startParsing();
00459 
00460                 // set another question pool name (if possible)
00461                 $qpl_name = $_POST["qpl_new"];
00462                 if ((strcmp($qpl_name, $newObj->getTitle()) != 0) && (strlen($qpl_name) > 0))
00463                 {
00464                         $newObj->setTitle($qpl_name);
00465                         $newObj->update();
00466                 }
00467                 
00468                 // delete import directory
00469                 ilUtil::delDir(ilObjQuestionPool::_getImportDirectory());
00470 
00471                 if ($_POST["questions_only"] == 1)
00472                 {
00473                         $this->ctrl->redirect($this, "questions");
00474                 }
00475                 else
00476                 {
00477                         ilUtil::redirect($this->getReturnLocation("save", "adm_object.php?ref_id=" . $_GET["ref_id"]));
00478                 }
00479         }
00480         
00481         function cancelImportObject()
00482         {
00483                 if ($_POST["questions_only"] == 1)
00484                 {
00485                         $this->ctrl->redirect($this, "questions");
00486                 }
00487                 else
00488                 {
00489                         ilUtil::redirect($this->getReturnLocation("cancel", "adm_object.php?ref_id=" . $_GET["ref_id"]));
00490                 }
00491         }
00492         
00496         /*function uploadQplObject($redirect = true)
00497         {
00498                 if ($_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK)
00499                 {
00500                         sendInfo($this->lng->txt("error_upload"));
00501                         $this->importObject();
00502                         return;
00503                 }
00504 
00505                 // create import directory
00506                 ilObjQuestionPool::_createImportDirectory();
00507 
00508                 // copy uploaded file to import directory
00509                 $file = pathinfo($_FILES["xmldoc"]["name"]);
00510                 $full_path = ilObjQuestionPool::_getImportDirectory()."/".$_FILES["xmldoc"]["name"];
00511                 ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"], $_FILES["xmldoc"]["name"], $full_path);
00512                 //move_uploaded_file($_FILES["xmldoc"]["tmp_name"], $full_path);
00513 
00514                 // unzip file
00515                 ilUtil::unzip($full_path);
00516 
00517                 // determine filenames of xml files
00518                 $subdir = basename($file["basename"],".".$file["extension"]);
00519                 $xml_file = ilObjQuestionPool::_getImportDirectory()."/".$subdir."/".$subdir.".xml";
00520                 $qti_file = ilObjQuestionPool::_getImportDirectory()."/".$subdir."/". str_replace("qpl", "qti", $subdir).".xml";
00521 
00522                 // create new questionpool object
00523                 $newObj = new ilObjQuestionpool(true);
00524                 // set type of questionpool object
00525                 $newObj->setType($_GET["new_type"]);
00526                 // set title of questionpool object to "dummy"
00527                 $newObj->setTitle("dummy");
00528                 // create the questionpool class in the ILIAS database (object_data table)
00529                 $newObj->create(true);
00530                 // create a reference for the questionpool object in the ILIAS database (object_reference table)
00531                 $newObj->createReference();
00532                 // put the questionpool object in the administration tree
00533                 $newObj->putInTree($_GET["ref_id"]);
00534                 // get default permissions and set the permissions for the questionpool object
00535                 $newObj->setPermissions($_GET["ref_id"]);
00536                 // notify the questionpool object and all its parent objects that a "new" object was created
00537                 $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
00538 
00539                 // import qti data
00540                 $qtiresult = $newObj->importObject($qti_file);
00541 
00542                 // import page data
00543                 include_once ("content/classes/class.ilContObjParser.php");
00544                 $contParser = new ilContObjParser($newObj, $xml_file, $subdir);
00545                 $contParser->setQuestionMapping($newObj->getImportMapping());
00546                 $contParser->startParsing();
00547 
00548 
00549                 // delete import directory
00550                 ilUtil::delDir(ilObjQuestionPool::_getImportDirectory());
00551 
00552                 if ($redirect)
00553                 {
00554                         ilUtil::redirect("adm_object.php?".$this->link_params);
00555                 }
00556         }*/
00557 
00561         function uploadObject()
00562         {
00563                 $this->uploadQplObject(true);
00564 /*      // check if file was uploaded
00565                 $source = $_FILES["xmldoc"]["tmp_name"];
00566                 $error = 0;
00567                 if (($source == 'none') || (!$source) || $_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK)
00568                 {
00569 //                      $this->ilias->raiseError("No file selected!",$this->ilias->error_obj->MESSAGE);
00570                         $error = 1;
00571                 }
00572                 // check correct file type
00573                 if (strcmp($_FILES["xmldoc"]["type"], "text/xml") == 0)
00574                 {
00575                         if (!$error)
00576                         {
00577                                 $this->object->importObject($source);
00578                         }
00579                 }
00580                 else
00581                 {
00582                         // create import directory
00583                         ilObjQuestionPool::_createImportDirectory();
00584         
00585                         // copy uploaded file to import directory
00586                         $file = pathinfo($_FILES["xmldoc"]["name"]);
00587                         $full_path = ilObjQuestionPool::_getImportDirectory()."/".$_FILES["xmldoc"]["name"];
00588                         ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"], $_FILES["xmldoc"]["name"], $full_path);
00589                         //move_uploaded_file($_FILES["xmldoc"]["tmp_name"], $full_path);
00590         
00591                         // unzip file
00592                         ilUtil::unzip($full_path);
00593         
00594                         // determine filename of xml file
00595                         $subdir = basename($file["basename"],".".$file["extension"]);
00596                         $xml_file = ilObjQuestionPool::_getImportDirectory()."/".$subdir."/".$subdir.".xml";
00597                         $qti_file = ilObjQuestionPool::_getImportDirectory()."/".$subdir."/". str_replace("qpl", "qti", $subdir).".xml";
00598                         // import qti data
00599                         $qtiresult = $this->object->importObject($qti_file);
00600                         // import page data
00601                         include_once ("content/classes/class.ilContObjParser.php");
00602                         $contParser = new ilContObjParser($this->object, $xml_file, $subdir);
00603                         $contParser->setQuestionMapping($this->object->getImportMapping());
00604                         $contParser->startParsing();
00605 
00606                         // delete import directory
00607                         ilUtil::delDir(ilObjQuestionPool::_getImportDirectory());
00608                 }
00609                 
00610                 $this->questionsObject();*/
00611         }
00612         
00616                 function importQuestionsObject()
00617         {
00618                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_import_question.html", true);
00619                 $this->tpl->setCurrentBlock("adm_content");
00620                 $this->tpl->setVariable("TEXT_IMPORT_QUESTION", $this->lng->txt("import_question"));
00621                 $this->tpl->setVariable("TEXT_SELECT_FILE", $this->lng->txt("select_file"));
00622                 $this->tpl->setVariable("TEXT_UPLOAD", $this->lng->txt("upload"));
00623                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00624                 $this->tpl->parseCurrentBlock();
00625         }
00626 
00632         function importObject()
00633         {
00634                 global $rbacsystem;
00635                 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"]))
00636                 {
00637                         $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00638                 }
00639                 $this->getTemplateFile("import", "qpl");
00640                 $this->tpl->setVariable("FORMACTION", "adm_object.php?&ref_id=".$_GET["ref_id"]."&cmd=gateway&new_type=".$this->type);
00641                 $this->tpl->setVariable("BTN_NAME", "uploadQpl");
00642                 $this->tpl->setVariable("TXT_UPLOAD", $this->lng->txt("import"));
00643                 $this->tpl->setVariable("NEW_TYPE", $this->type);
00644                 $this->tpl->setVariable("TXT_IMPORT_QPL", $this->lng->txt("import_qpl"));
00645                 $this->tpl->setVariable("TXT_SELECT_MODE", $this->lng->txt("select_mode"));
00646                 $this->tpl->setVariable("TXT_SELECT_FILE", $this->lng->txt("select_file"));
00647                 $this->tpl->parseCurrentBlock();
00648         }
00649         
00653         function &createQuestionObject()
00654         {
00655 //echo "<br>create--".$_POST["sel_question_types"];
00656                 $q_gui =& ASS_QuestionGUI::_getQuestionGUI($_POST["sel_question_types"]);
00657                 $q_gui->object->setObjId($this->object->getId());
00658                 $this->ctrl->setCmdClass(get_class($q_gui));
00659                 $this->ctrl->setCmd("editQuestion");
00660 
00661                 $ret =& $this->executeCommand();
00662                 return $ret;
00663         }
00664 
00668         function &createQuestionForTestObject()
00669         {
00670 //echo "<br>create--".$_GET["new_type"];
00671                 $q_gui =& ASS_QuestionGUI::_getQuestionGUI($_GET["sel_question_types"]);
00672                 $q_gui->object->setObjId($this->object->getId());
00673                 $this->ctrl->setCmdClass(get_class($q_gui));
00674                 $this->ctrl->setCmd("editQuestion");
00675 
00676                 $ret =& $this->executeCommand();
00677                 return $ret;
00678         }
00679 
00684         function saveObject()
00685         {
00686                 global $rbacadmin;
00687 
00688                 // create and insert forum in objecttree
00689                 $newObj = parent::saveObject();
00690 
00691                 // setup rolefolder & default local roles
00692                 //$roles = $newObj->initDefaultRoles();
00693 
00694                 // ...finally assign role to creator of object
00695                 //$rbacadmin->assignUser($roles[0], $newObj->getOwner(), "y");
00696 
00697                 // put here object specific stuff
00698 
00699                 // always send a message
00700                 sendInfo($this->lng->txt("object_added"),true);
00701 
00702                 $returnlocation = "questionpool.php";
00703                 if (!defined("ILIAS_MODULE"))
00704                 {
00705                         $returnlocation = "adm_object.php";
00706                 }
00707                 ilUtil::redirect($this->getReturnLocation("save","$returnlocation?".$this->link_params));
00708                 exit();
00709         }
00710 
00714         function assessmentObject()
00715         {
00716                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.il_as_qpl_content.html", true);
00717                 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00718 
00719                 // catch feedback message
00720                 sendInfo();
00721 
00722                 $this->setLocator();
00723 
00724                 $title = $this->lng->txt("qpl_assessment_of_questions");
00725                 if (!empty($title))
00726                 {
00727                         $this->tpl->setVariable("HEADER", $title);
00728                 }
00729                 include_once("./assessment/classes/class.assQuestion.php");
00730                 $total_of_answers = ASS_Question::_getTotalAnswers($_GET["q_id"]);
00731                 $counter = 0;
00732                 $color_class = array("tblrow1", "tblrow2");
00733                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_qpl_assessment_of_questions.html", true);
00734                 if (!$total_of_answers)
00735                 {
00736                         $this->tpl->setCurrentBlock("emptyrow");
00737                         $this->tpl->setVariable("TXT_NO_ASSESSMENT", $this->lng->txt("qpl_assessment_no_assessment_of_questions"));
00738                         $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00739                         $this->tpl->parseCurrentBlock();
00740                 }
00741                 else
00742                 {
00743                         $this->tpl->setCurrentBlock("row");
00744                         $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("qpl_assessment_total_of_answers"));
00745                         $this->tpl->setVariable("TXT_VALUE", $total_of_answers);
00746                         $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00747                         $counter++;
00748                         $this->tpl->parseCurrentBlock();
00749                         $this->tpl->setCurrentBlock("row");
00750                         $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("qpl_assessment_total_of_right_answers"));
00751                         $this->tpl->setVariable("TXT_VALUE", sprintf("%2.2f", ASS_Question::_getTotalRightAnswers($_GET["edit"]) * 100.0) . " %");
00752                         $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00753                         $this->tpl->parseCurrentBlock();
00754                 }
00755                 $this->tpl->setCurrentBlock("adm_content");
00756                 $this->tpl->setVariable("TXT_QUESTION_TITLE", ASS_Question::_getTitle($_GET["q_id"]));
00757                 $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("result"));
00758                 $this->tpl->setVariable("TXT_VALUE", $this->lng->txt("value"));
00759                 $this->tpl->parseCurrentBlock();
00760         }
00761 
00762         function getAddParameter()
00763         {
00764                 return "?ref_id=" . $_GET["ref_id"] . "&cmd=" . $_GET["cmd"];
00765         }
00766 
00767         function questionObject()
00768         {
00769 //echo "<br>ilObjQuestionPoolGUI->questionObject()";
00770                 $type = $_GET["sel_question_types"];
00771                 $this->editQuestionForm($type);
00772                 //$this->set_question_form($type, $_GET["edit"]);
00773         }
00774 
00778         function deleteQuestionsObject()
00779         {
00780 //echo "<br>ilObjQuestionPoolGUI->deleteQuestions()";
00781                 // duplicate button was pressed
00782                 if (count($_POST["q_id"]) < 1)
00783                 {
00784                         sendInfo($this->lng->txt("qpl_delete_select_none"), true);
00785                         $this->ctrl->redirect($this, "questions");
00786                 }
00787                 
00788                 $checked_questions =& $this->object->getQuestionDetails($_POST["q_id"]);
00789                 $deleteable_questions =& $this->object->getDeleteableQuestionDetails($_POST["q_id"]);
00790                 $used_questions =& $this->object->getUsedQuestionDetails($_POST["q_id"]);
00791                 $_SESSION["ass_q_id"] = $deleteable_questions;
00792                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_qpl_confirm_delete_questions.html", true);
00793 
00794                 $colors = array("tblrow1", "tblrow2");
00795                 $counter = 0;
00796                 include_once "./classes/class.ilUtil.php";
00797                 $img_locked = "<img src=\"" . ilUtil::getImagePath("locked.gif", true) . "\" alt=\"" . $this->lng->txt("locked") . "\" title=\"" . $this->lng->txt("locked") . "\" border=\"0\" />";
00798                 if (count($deleteable_questions) > 0)
00799                 {
00800                         foreach ($deleteable_questions as $question)
00801                         {
00802                                 $this->tpl->setCurrentBlock("row");
00803                                 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
00804                                 if ($this->object->isInUse($question["question_id"]))
00805                                 {
00806                                         $this->tpl->setVariable("TXT_LOCKED", $img_locked);
00807                                 }
00808                                 $this->tpl->setVariable("TXT_TITLE", $question["title"]);
00809                                 $this->tpl->setVariable("TXT_DESCRIPTION", $question["comment"]);
00810                                 $this->tpl->setVariable("TXT_TYPE", $this->lng->txt($question["type_tag"]));
00811                                 $this->tpl->parseCurrentBlock();
00812                                 $counter++;
00813                                 
00814                                 $this->tpl->setCurrentBlock("hidden");
00815                                 $this->tpl->setVariable("HIDDEN_NAME", "id_" . $question["question_id"]);
00816                                 $this->tpl->setVariable("HIDDEN_VALUE", "1");
00817                                 $this->tpl->parseCurrentBlock();
00818                         }
00819                 }
00820                 else
00821                 {
00822                         $this->tpl->setCurrentBlock("emptyrow");
00823                         $this->tpl->setVariable("TEXT_EMPTY_ROW", $this->lng->txt("qpl_delete_no_deleteable_questions"));
00824                         $this->tpl->parseCurrentBlock();
00825                 }
00826                 
00827                 if (count($used_questions))
00828                 {
00829                         foreach ($used_questions as $question)
00830                         {
00831                                 $this->tpl->setCurrentBlock("undeleteable_row");
00832                                 $this->tpl->setVariable("QUESTION_TITLE", $question["title"]); 
00833                                 $this->tpl->parseCurrentBlock();
00834                         }
00835                         $this->tpl->setCurrentBlock("undeleteable_questions");
00836                         $this->tpl->setVariable("TEXT_UNDELETEABLE_QUESTIONS", $this->lng->txt("qpl_delete_describe_undeleteable_questions"));
00837                         $this->tpl->parseCurrentBlock();
00838                 }
00839 
00840                 $this->tpl->setCurrentBlock("adm_content");
00841                 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("tst_question_title"));
00842                 $this->tpl->setVariable("TXT_DESCRIPTION", $this->lng->txt("description"));
00843                 $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("tst_question_type"));
00844                 $this->tpl->setVariable("TXT_LOCKED", $this->lng->txt("locked"));
00845                 $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
00846                 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
00847                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00848                 $this->tpl->setVariable("DELETE_QUESTION", $this->lng->txt("qpl_confirm_delete_questions"));
00849                 $this->tpl->parseCurrentBlock();
00850         }
00854         function _deleteQuestionsObject()
00855         {
00856 //echo "<br>ilObjQuestionPoolGUI->deleteQuestions()";
00857                 // duplicate button was pressed
00858                 if (count($_POST["q_id"]) < 1)
00859                 {
00860                         sendInfo($this->lng->txt("qpl_delete_select_none"), true);
00861                         $this->ctrl->redirect($this, "questions");
00862                 }
00863 
00864                 $checked_questions = $_POST["q_id"];
00865                 $_SESSION["ass_q_id"] = $_POST["q_id"];
00866                 sendInfo();
00867                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_qpl_confirm_delete_questions.html", true);
00868 
00869                 // buidling SQL statements is not allowed in GUI classes!
00870                 $whereclause = join($checked_questions, " OR qpl_questions.question_id = ");
00871                 $whereclause = " AND (qpl_questions.question_id = " . $whereclause . ")";
00872                 $query = "SELECT qpl_questions.*, qpl_question_type.type_tag FROM qpl_questions, qpl_question_type WHERE qpl_questions.question_type_fi = qpl_question_type.question_type_id$whereclause ORDER BY qpl_questions.title";
00873                 $query_result = $this->ilias->db->query($query);
00874                 $colors = array("tblrow1", "tblrow2");
00875                 $counter = 0;
00876                 $img_locked = "<img src=\"" . ilUtil::getImagePath("locked.gif", true) . "\" alt=\"" . $this->lng->txt("locked") . "\" title=\"" . $this->lng->txt("locked") . "\" border=\"0\" />";
00877                 if ($query_result->numRows() > 0)
00878                 {
00879                         while ($data = $query_result->fetchRow(DB_FETCHMODE_OBJECT))
00880                         {
00881                                 if (in_array($data->question_id, $checked_questions))
00882                                 {
00883                                         $this->tpl->setCurrentBlock("row");
00884                                         $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
00885                                         if ($this->object->isInUse($data->question_id))
00886                                         {
00887                                                 $this->tpl->setVariable("TXT_LOCKED", $img_locked);
00888                                         }
00889                                         $this->tpl->setVariable("TXT_TITLE", $data->title);
00890                                         $this->tpl->setVariable("TXT_DESCRIPTION", $data->comment);
00891                                         $this->tpl->setVariable("TXT_TYPE", $this->lng->txt($data->type_tag));
00892                                         $this->tpl->parseCurrentBlock();
00893                                         $counter++;
00894                                 }
00895                         }
00896                 }
00897                 foreach ($checked_questions as $id)
00898                 {
00899                         $this->tpl->setCurrentBlock("hidden");
00900                         $this->tpl->setVariable("HIDDEN_NAME", "id_$id");
00901                         $this->tpl->setVariable("HIDDEN_VALUE", "1");
00902                         $this->tpl->parseCurrentBlock();
00903                 }
00904 
00905                 $this->tpl->setCurrentBlock("adm_content");
00906                 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("tst_question_title"));
00907                 $this->tpl->setVariable("TXT_DESCRIPTION", $this->lng->txt("description"));
00908                 $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("tst_question_type"));
00909                 $this->tpl->setVariable("TXT_LOCKED", $this->lng->txt("locked"));
00910                 $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
00911                 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
00912                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00913                 $this->tpl->parseCurrentBlock();
00914         }
00915 
00916 
00920         function confirmDeleteQuestionsObject()
00921         {
00922                 // delete questions after confirmation
00923                 sendInfo($this->lng->txt("qpl_questions_deleted"), true);
00924                 foreach ($_SESSION["ass_q_id"] as $key => $value)
00925                 {
00926                         $this->object->deleteQuestion($value["question_id"]);
00927                 }
00928                 $this->ctrl->redirect($this, "questions");
00929         }
00930 
00934         function cancelDeleteQuestionsObject()
00935         {
00936                 $this->ctrl->redirect($this, "questions");
00937         }
00938 
00942         function duplicateObject()
00943         {
00944                 // duplicate button was pressed
00945                 if (count($_POST["q_id"]) > 0)
00946                 {
00947                         foreach ($_POST["q_id"] as $key => $value)
00948                         {
00949                                 $this->object->duplicateQuestion($value);
00950                         }
00951                 }
00952                 else
00953                 {
00954                         sendInfo($this->lng->txt("qpl_duplicate_select_none"), true);
00955                 }
00956                 $this->ctrl->redirect($this, "questions");
00957         }
00958 
00962         function exportQuestionObject()
00963         {
00964                 // export button was pressed
00965                 if (count($_POST["q_id"]) > 0)
00966                 {
00967                         require_once("assessment/classes/class.ilQuestionpoolExport.php");
00968                         $qpl_exp = new ilQuestionpoolExport($this->object, "xml", $_POST["q_id"]);
00969                         $export_file = $qpl_exp->buildExportFile();
00970                         $filename = $export_file;
00971                         $filename = preg_replace("/.*\//", "", $filename);
00972                         ilUtil::deliverFile($export_file, $filename);
00973                         exit();
00974                 }
00975                 else
00976                 {
00977                         sendInfo($this->lng->txt("qpl_export_select_none"), true);
00978                 }
00979                 $this->ctrl->redirect($this, "questions");
00980         }
00981 
00985         function questionsObject()
00986         {
00987                 global $rbacsystem;
00988 
00989                 $type = $_GET["sel_question_types"];
00990 
00991                 // reset test_id SESSION variable
00992                 $_SESSION["test_id"] = "";
00993                 $add_parameter = $this->getAddParameter();
00994 
00995                 // create an array of all checked checkboxes
00996                 $checked_questions = array();
00997                 foreach ($_POST as $key => $value)
00998                 {
00999                         if (preg_match("/cb_(\d+)/", $key, $matches))
01000                         {
01001                                 array_push($checked_questions, $matches[1]);
01002                         }
01003                 }
01004 
01005                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.qpl_questions.html", true);
01006                 if ($rbacsystem->checkAccess('write', $this->ref_id))
01007                 {
01008                         $this->tpl->addBlockFile("CREATE_QUESTION", "create_question", "tpl.il_as_create_new_question.html", true);
01009                         $this->tpl->addBlockFile("A_BUTTONS", "a_buttons", "tpl.il_as_qpl_action_buttons.html", true);
01010                 }
01011                 $this->tpl->addBlockFile("FILTER_QUESTION_MANAGER", "filter_questions", "tpl.il_as_qpl_filter_questions.html", true);
01012 
01013                 // create filter form
01014                 $filter_fields = array(
01015                         "title" => $this->lng->txt("title"),
01016                         "comment" => $this->lng->txt("description"),
01017                         "author" => $this->lng->txt("author"),
01018                 );
01019                 $this->tpl->setCurrentBlock("filterrow");
01020                 foreach ($filter_fields as $key => $value)
01021                 {
01022                         $this->tpl->setVariable("VALUE_FILTER_TYPE", "$key");
01023                         $this->tpl->setVariable("NAME_FILTER_TYPE", "$value");
01024                         if (strcmp($_POST["sel_filter_type"], $key) == 0)
01025                         {
01026                                 $this->tpl->setVariable("VALUE_FILTER_SELECTED", " selected=\"selected\"");
01027                         }
01028                         $this->tpl->parseCurrentBlock();
01029                 }
01030 
01031                 $this->tpl->setCurrentBlock("filter_questions");
01032                 $this->tpl->setVariable("FILTER_TEXT", $this->lng->txt("filter"));
01033                 $this->tpl->setVariable("TEXT_FILTER_BY", $this->lng->txt("by"));
01034                 $this->tpl->setVariable("VALUE_FILTER_TEXT", $_POST["filter_text"]);
01035                 $this->tpl->setVariable("VALUE_SUBMIT_FILTER", $this->lng->txt("set_filter"));
01036                 $this->tpl->setVariable("VALUE_RESET_FILTER", $this->lng->txt("reset_filter"));
01037                 $this->tpl->parseCurrentBlock();
01038 
01039                 // create edit buttons & table footer
01040                 if ($rbacsystem->checkAccess('write', $this->ref_id))
01041                 {
01042                         $this->tpl->setCurrentBlock("standard");
01043                         $this->tpl->setVariable("DELETE", $this->lng->txt("delete"));
01044                         $this->tpl->setVariable("DUPLICATE", $this->lng->txt("duplicate"));
01045                         $this->tpl->setVariable("EXPORT", $this->lng->txt("export"));
01046                         $this->tpl->parseCurrentBlock();
01047                         $this->tpl->setCurrentBlock("Footer");
01048                         $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"\">");
01049                         $this->tpl->parseCurrentBlock();
01050                 }
01051 
01052                 $this->tpl->setCurrentBlock("QTab");
01053 
01054                 // reset the filter
01055                 $startrow = 0;
01056                 if ($_GET["prevrow"])
01057                 {
01058                         $startrow = $_GET["prevrow"];
01059                 }
01060                 if ($_GET["nextrow"])
01061                 {
01062                         $startrow = $_GET["nextrow"];
01063                 }
01064                 if ($_GET["startrow"])
01065                 {
01066                         $startrow = $_GET["startrow"];
01067                 }
01068                 if (!$_GET["sort"])
01069                 {
01070                         // default sort order
01071                         $_GET["sort"] = array("title" => "ASC");
01072                 }
01073                 $table = $this->object->getQuestionsTable($_GET["sort"], $_POST["filter_text"], $_POST["sel_filter_type"], $startrow);
01074                 $colors = array("tblrow1", "tblrow2");
01075                 $img_locked = "<img src=\"" . ilUtil::getImagePath("locked.gif", true) . "\" alt=\"" . $this->lng->txt("locked") . "\" title=\"" . $this->lng->txt("locked") . "\" border=\"0\" />";
01076                 $counter = 0;
01077                 $editable = $rbacsystem->checkAccess('write', $this->ref_id);
01078                 foreach ($table["rows"] as $data)
01079                 {
01080                         if ($data["complete"] == 0)
01081                         {
01082                                 $this->tpl->setCurrentBlock("qpl_warning");
01083                                 $this->tpl->setVariable("IMAGE_WARNING", ilUtil::getImagePath("warning.png"));
01084                                 $this->tpl->setVariable("ALT_WARNING", $this->lng->txt("warning_question_not_complete"));
01085                                 $this->tpl->setVariable("TITLE_WARNING", $this->lng->txt("warning_question_not_complete"));
01086                                 $this->tpl->parseCurrentBlock();
01087                                 $this->tpl->setCurrentBlock("QTab");
01088                         }
01089                         $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
01090                         $class = strtolower(ASS_QuestionGUI::_getGUIClassNameForId($data["question_id"]));
01091                         $this->ctrl->setParameterByClass("ilpageobjectgui", "q_id", $data["question_id"]);
01092                         $this->ctrl->setParameterByClass($class, "q_id", $data["question_id"]);
01093                         if ($editable)
01094                         {
01095                                 $this->tpl->setVariable("TXT_EDIT", $this->lng->txt("edit"));
01096                                 $this->tpl->setVariable("LINK_EDIT", $this->ctrl->getLinkTargetByClass("ilpageobjectgui", "view"));
01097                         }
01098                         $this->tpl->setVariable("QUESTION_TITLE", "<strong>" .$data["title"] . "</strong>");
01099 
01100                         $this->tpl->setVariable("TXT_PREVIEW", $this->lng->txt("preview"));
01101                         $this->tpl->setVariable("LINK_PREVIEW", $this->ctrl->getLinkTargetByClass("ilpageobjectgui", "preview"));
01102 
01103                         $this->tpl->setVariable("QUESTION_COMMENT", $data["comment"]);
01104                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($data["type_tag"]));
01105                         $this->tpl->setVariable("LINK_ASSESSMENT", $this->ctrl->getLinkTargetByClass($class, "assessment"));
01106                         $this->tpl->setVariable("TXT_ASSESSMENT", $this->lng->txt("qpl_assessment_of_questions"));
01107                         $this->tpl->setVariable("IMG_ASSESSMENT",
01108                                 ilUtil::getImagePath("assessment.gif", true));
01109                         $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]);
01110                         $this->tpl->setVariable("QUESTION_CREATED", ilFormat::formatDate(ilFormat::ftimestamp2dateDB($data["created"]), "date"));
01111                         $this->tpl->setVariable("QUESTION_UPDATED", ilFormat::formatDate(ilFormat::ftimestamp2dateDB($data["TIMESTAMP14"]), "date"));
01112                         $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
01113                         $this->tpl->parseCurrentBlock();
01114                         $counter++;
01115                 }
01116 
01117                 if ($table["rowcount"] > count($table["rows"]))
01118                 {
01119                         $nextstep = $table["nextrow"] + $table["step"];
01120                         if ($nextstep > $table["rowcount"])
01121                         {
01122                                 $nextstep = $table["rowcount"];
01123                         }
01124                         $sort = "";
01125                         if (is_array($_GET["sort"]))
01126                         {
01127                                 $key = key($_GET["sort"]);
01128                                 $sort = "&sort[$key]=" . $_GET["sort"]["$key"];
01129                         }
01130                         $counter = 1;
01131                         for ($i = 0; $i < $table["rowcount"]; $i += $table["step"])
01132                         {
01133                                 $this->tpl->setCurrentBlock("pages");
01134                                 if ($table["startrow"] == $i)
01135                                 {
01136                                         $this->tpl->setVariable("PAGE_NUMBER", "<span class=\"inactivepage\">$counter</span>");
01137                                 }
01138                                 else
01139                                 {
01140                                         $this->tpl->setVariable("PAGE_NUMBER", "<a href=\"" . $this->ctrl->getFormAction($this) . "$sort&nextrow=$i" . "\">$counter</a>");
01141                                 }
01142                                 $this->tpl->parseCurrentBlock();
01143                                 $counter++;
01144                         }
01145                         $this->tpl->setCurrentBlock("navigation_bottom");
01146                         $this->tpl->setVariable("TEXT_ITEM", $this->lng->txt("item"));
01147                         $this->tpl->setVariable("TEXT_ITEM_START", $table["startrow"] + 1);
01148                         $end = $table["startrow"] + $table["step"];
01149                         if ($end > $table["rowcount"])
01150                         {
01151                                 $end = $table["rowcount"];
01152                         }
01153                         $this->tpl->setVariable("TEXT_ITEM_END", $end);
01154                         $this->tpl->setVariable("TEXT_OF", strtolower($this->lng->txt("of")));
01155                         $this->tpl->setVariable("TEXT_ITEM_COUNT", $table["rowcount"]);
01156                         $this->tpl->setVariable("TEXT_PREVIOUS", $this->lng->txt("previous"));
01157                         $this->tpl->setVariable("TEXT_NEXT", $this->lng->txt("next"));
01158                         $this->tpl->setVariable("HREF_PREV_ROWS", $this->ctrl->getFormAction($this) . "$sort&prevrow=" . $table["prevrow"]);
01159                         $this->tpl->setVariable("HREF_NEXT_ROWS", $this->ctrl->getFormAction($this) . "$sort&nextrow=" . $table["nextrow"]);
01160                         $this->tpl->parseCurrentBlock();
01161                 }
01162 
01163                 // if there are no questions, display a message
01164                 if ($counter == 0)
01165                 {
01166                         $this->tpl->setCurrentBlock("Emptytable");
01167                         $this->tpl->setVariable("TEXT_EMPTYTABLE", $this->lng->txt("no_questions_available"));
01168                         $this->tpl->parseCurrentBlock();
01169                 }
01170 
01171                 if ($rbacsystem->checkAccess('write', $this->ref_id))
01172                 {
01173                         // "create question" form
01174                         $this->tpl->setCurrentBlock("QTypes");
01175                         $query = "SELECT * FROM qpl_question_type ORDER BY question_type_id";
01176                         $query_result = $this->ilias->db->query($query);
01177                         while ($data = $query_result->fetchRow(DB_FETCHMODE_OBJECT))
01178                         {
01179 // temporary disable java questions
01180 //                              if ($data->type_tag != "qt_javaapplet")
01181 //                              {
01182                                         $this->tpl->setVariable("QUESTION_TYPE_ID", $data->type_tag);
01183                                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($data->type_tag));
01184                                         $this->tpl->parseCurrentBlock();
01185 //                              }
01186                         }
01187                         $this->tpl->setCurrentBlock("CreateQuestion");
01188                         $this->tpl->setVariable("QUESTION_ADD", $this->lng->txt("create"));
01189                         $this->tpl->setVariable("ACTION_QUESTION_ADD", $this->ctrl->getFormAction($this));
01190                         $this->tpl->setVariable("QUESTION_IMPORT", $this->lng->txt("import"));
01191                         $this->tpl->parseCurrentBlock();
01192                 }
01193 
01194                 // define the sort column parameters
01195                 $sort = array(
01196                         "title" => $_GET["sort"]["title"],
01197                         "comment" => $_GET["sort"]["comment"],
01198                         "type" => $_GET["sort"]["type"],
01199                         "author" => $_GET["sort"]["author"],
01200                         "created" => $_GET["sort"]["created"],
01201                         "updated" => $_GET["sort"]["updated"]
01202                 );
01203                 foreach ($sort as $key => $value)
01204                 {
01205                         if (strcmp($value, "ASC") == 0)
01206                         {
01207                                 $sort[$key] = "DESC";
01208                         }
01209                         else
01210                         {
01211                                 $sort[$key] = "ASC";
01212                         }
01213                 }
01214 
01215                 $this->tpl->setCurrentBlock("adm_content");
01216                 // create table header
01217                 $this->ctrl->setParameterByClass(get_class($this), "startrow", $table["startrow"]);
01218                 $this->tpl->setVariable("QUESTION_TITLE", "<a href=\"" . $this->ctrl->getFormAction($this) . "&sort[title]=" . $sort["title"] . "\">" . $this->lng->txt("title") . "</a>" . $table["images"]["title"]);
01219                 $this->tpl->setVariable("QUESTION_COMMENT", "<a href=\"" . $this->ctrl->getFormAction($this) . "&sort[comment]=" . $sort["comment"] . "\">" . $this->lng->txt("description") . "</a>". $table["images"]["comment"]);
01220                 $this->tpl->setVariable("QUESTION_TYPE", "<a href=\"" . $this->ctrl->getFormAction($this) . "&sort[type]=" . $sort["type"] . "\">" . $this->lng->txt("question_type") . "</a>" . $table["images"]["type"]);
01221                 $this->tpl->setVariable("QUESTION_AUTHOR", "<a href=\"" . $this->ctrl->getFormAction($this) . "&sort[author]=" . $sort["author"] . "\">" . $this->lng->txt("author") . "</a>" . $table["images"]["author"]);
01222                 $this->tpl->setVariable("QUESTION_CREATED", "<a href=\"" . $this->ctrl->getFormAction($this) . "&sort[created]=" . $sort["created"] . "\">" . $this->lng->txt("create_date") . "</a>" . $table["images"]["created"]);
01223                 $this->tpl->setVariable("QUESTION_UPDATED", "<a href=\"" . $this->ctrl->getFormAction($this) . "&sort[updated]=" . $sort["updated"] . "\">" . $this->lng->txt("last_update") . "</a>" . $table["images"]["updated"]);
01224                 $this->tpl->setVariable("BUTTON_CANCEL", $this->lng->txt("cancel"));
01225                 $this->tpl->setVariable("ACTION_QUESTION_FORM", $this->ctrl->getFormAction($this));
01226                 $this->tpl->parseCurrentBlock();
01227         }
01228 
01229         function updateObject()
01230         {
01231 //              $this->update = $this->object->updateMetaData();
01232                 $this->update = $this->object->update();
01233                 sendInfo($this->lng->txt("msg_obj_modified"), true);
01234         }
01235 
01244         function setLocator($a_tree = "", $a_id = "", $scriptname="repository.php", $question_title = "")
01245         {
01246 //echo "<br>ilObjQuestionPoolGUI->setLocator()";
01247                 $ilias_locator = new ilLocatorGUI(false);
01248                 if (!is_object($a_tree))
01249                 {
01250                         $a_tree =& $this->tree;
01251                 }
01252                 if (!($a_id))
01253                 {
01254                         $a_id = $_GET["ref_id"];
01255                 }
01256                 if (!($scriptname))
01257                 {
01258                         $scriptname = "repository.php";
01259                 }
01260                 $path = $a_tree->getPathFull($a_id);
01261                 //check if object isn't in tree, this is the case if parent_parent is set
01262                 // TODO: parent_parent no longer exist. need another marker
01263                 if ($a_parent_parent)
01264                 {
01265                         //$subObj = getObject($a_ref_id);
01266                         $subObj =& $this->ilias->obj_factory->getInstanceByRefId($a_ref_id);
01267 
01268                         $path[] = array(
01269                                 "id"     => $a_ref_id,
01270                                 "title"  => $this->lng->txt($subObj->getTitle())
01271                         );
01272                 }
01273 
01274                 // this is a stupid workaround for a bug in PEAR:IT
01275                 $modifier = 1;
01276 
01277                 if (isset($_GET["obj_id"]))
01278                 {
01279                         $modifier = 0;
01280                 }
01281 
01282                 // ### AA 03.11.10 added new locator GUI class ###
01283                 $i = 1;
01284 
01285                 if (!defined("ILIAS_MODULE"))
01286                 {
01287                         foreach ($path as $key => $row)
01288                         {
01289                                 $ilias_locator->navigate($i++, $row["title"], ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/adm_object.php?ref_id=".$row["child"],"");
01290                         }
01291                 }
01292                 else
01293                 {
01294                         foreach ($path as $key => $row)
01295                         {
01296                                 if (strcmp($row["title"], "ILIAS") == 0)
01297                                 {
01298                                         $row["title"] = $this->lng->txt("repository");
01299                                 }
01300                                 if ($this->ref_id == $row["child"])
01301                                 {
01302                                         $param = "&cmd=questions";
01303                                         $ilias_locator->navigate($i++, $row["title"], ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/assessment/questionpool.php" . "?ref_id=".$row["child"] . $param,"");
01304                                         switch ($_GET["cmd"])
01305                                         {
01306                                                 case "question":
01307                                                         $id = $_GET["edit"];
01308                                                         if (!$id)
01309                                                         {
01310                                                                 $id = $_POST["id"];
01311                                                         }
01312                                                         if ($question_title)
01313                                                         {
01314                                                                 if ($id > 1)
01315                                                                 {
01316                                                                         $ilias_locator->navigate($i++, $question_title, ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/assessment/questionpool.php" . "?ref_id=".$row["child"] . "&cmd=question&edit=$id","");
01317                                                                 }
01318                                                         }
01319                                                         break;
01320                                         }
01321                                 }
01322                                 else
01323                                 {
01324                                         $ilias_locator->navigate($i++, $row["title"], ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/" . $scriptname."?cmd=frameset&ref_id=".$row["child"],"");
01325                                 }
01326                         }
01327 
01328                         if (isset($_GET["obj_id"]))
01329                         {
01330                                 $obj_data =& $this->ilias->obj_factory->getInstanceByObjId($_GET["obj_id"]);
01331                                 $ilias_locator->navigate($i++,$obj_data->getTitle(),$scriptname."?ref_id=".$_GET["ref_id"]."&obj_id=".$_GET["obj_id"],"");
01332                         }
01333                 }
01334                 $ilias_locator->output(true);
01335         }
01336 
01337         function prepareOutput()
01338         {
01339                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
01340                 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
01341                 $title = $this->object->getTitle();
01342 
01343                 // catch feedback message
01344                 sendInfo();
01345 
01346                 if (!empty($title))
01347                 {
01348                         $this->tpl->setVariable("HEADER", $title);
01349                 }
01350                 if (!defined("ILIAS_MODULE"))
01351                 {
01352                         $this->setAdminTabs($_POST["new_type"]);
01353                 }
01354                 $this->setLocator();
01355 
01356         }
01357 
01358 
01362         function setPageEditorTabs()
01363         {
01364 
01365                 // catch feedback message
01366                 include_once("classes/class.ilTabsGUI.php");
01367                 $tabs_gui =& new ilTabsGUI();
01368                 $this->getPageEditorTabs($tabs_gui);
01369 
01370                 $this->tpl->setVariable("TABS", $tabs_gui->getHTML());
01371 
01372         }
01373 
01377         function getPageEditorTabs(&$tabs_gui)
01378         {
01379                 global $rbacsystem;
01380                 
01381                 if ($rbacsystem->checkAccess('write', $this->ref_id))
01382                 {
01383                         // edit page
01384                         $tabs_gui->addTarget("edit_content",
01385                                 $this->ctrl->getLinkTargetByClass("ilPageObjectGUI", "view"), "view",
01386                                 "ilPageObjectGUI");
01387                 }
01388                 // preview page
01389                 $tabs_gui->addTarget("preview",
01390                         $this->ctrl->getLinkTargetByClass("ilPageObjectGUI", "preview"), "preview",
01391                         "ilPageObjectGUI");
01392 
01393                 // back to upper context
01394                 $tabs_gui->addTarget("back",
01395                         $this->ctrl->getLinkTarget($this, "questions"), "questions",
01396                         "ilObjQuestionPoolGUI");
01397 
01398         }
01399         
01400         function setQuestionTabs()
01401         {
01402 //              echo "<br>setQuestionTabs<br>";
01403                 global $rbacsystem;
01404                 
01405                 $this->ctrl->setParameterByClass("ilpageobjectgui", "q_id", $_GET["q_id"]);
01406                 $q_type = ASS_Question::getQuestionTypeFromDb($_GET["q_id"]);
01407                 include_once "./classes/class.ilTabsGUI.php";
01408                 $tabs_gui =& new ilTabsGUI();
01409                 
01410                 switch ($q_type)
01411                 {
01412                         case "qt_multiple_choice_sr":
01413                                 $classname = "ASS_MultipleChoiceGUI";
01414                                 $this->ctrl->setParameterByClass("ass_multiplechoicegui", "sel_question_types", $q_type);
01415                                 $this->ctrl->setParameterByClass("ass_multiplechoicegui", "q_id", $_GET["q_id"]);
01416                                 break;
01417 
01418                         case "qt_multiple_choice_mr":
01419                                 $classname = "ASS_MultipleChoiceGUI";
01420                                 $this->ctrl->setParameterByClass("ass_multiplechoicegui", "sel_question_types", $q_type);
01421                                 $this->ctrl->setParameterByClass("ass_multiplechoicegui", "q_id", $_GET["q_id"]);
01422                                 break;
01423 
01424                         case "qt_cloze":
01425                                 $classname = "ASS_ClozeTestGUI";
01426                                 $this->ctrl->setParameterByClass("ass_clozetestgui", "sel_question_types", $q_type);
01427                                 $this->ctrl->setParameterByClass("ass_clozetestgui", "q_id", $_GET["q_id"]);
01428                                 break;
01429 
01430                         case "qt_matching":
01431                                 $classname = "ASS_MatchingQuestionGUI";
01432                                 $this->ctrl->setParameterByClass("ass_matchingquestiongui", "sel_question_types", $q_type);
01433                                 $this->ctrl->setParameterByClass("ass_matchingquestiongui", "q_id", $_GET["q_id"]);
01434                                 break;
01435 
01436                         case "qt_ordering":
01437                                 $classname = "ASS_OrderingQuestionGUI";
01438                                 $this->ctrl->setParameterByClass("ass_orderingquestiongui", "sel_question_types", $q_type);
01439                                 $this->ctrl->setParameterByClass("ass_orderingquestiongui", "q_id", $_GET["q_id"]);
01440                                 break;
01441 
01442                         case "qt_imagemap":
01443                                 $classname = "ASS_ImagemapQuestionGUI";
01444                                 $this->ctrl->setParameterByClass("ass_imagemapquestiongui", "sel_question_types", $q_type);
01445                                 $this->ctrl->setParameterByClass("ass_imagemapquestiongui", "q_id", $_GET["q_id"]);
01446                                 break;
01447 
01448                         case "qt_javaapplet":
01449                                 $classname = "ASS_JavaAppletGUI";
01450                                 $this->ctrl->setParameterByClass("ass_javaappletgui", "sel_question_types", $q_type);
01451                                 $this->ctrl->setParameterByClass("ass_javaappletgui", "q_id", $_GET["q_id"]);
01452                                 break;
01453 
01454                         case "qt_text":
01455                                 $classname = "ASS_TextQuestionGUI";
01456                                 $this->ctrl->setParameterByClass("ass_textquestiongui", "sel_question_types", $q_type);
01457                                 $this->ctrl->setParameterByClass("ass_textquestiongui", "q_id", $_GET["q_id"]);
01458                                 break;
01459                 }
01460 
01461                 if (($_GET["q_id"]) && (strlen($_GET["calling_test"]) == 0))
01462                 {
01463                         if ($rbacsystem->checkAccess('write', $this->ref_id))
01464                         {
01465                                 // edit page
01466                                 $tabs_gui->addTarget("edit_content",
01467                                         $this->ctrl->getLinkTargetByClass("ilPageObjectGUI", "view"), "view",
01468                                         "ilPageObjectGUI");
01469                         }
01470         
01471                         $tabs_gui->addTarget("preview",
01472                                 $this->ctrl->getLinkTargetByClass("ilPageObjectGUI", "preview"), "preview",
01473                                 "ilPageObjectGUI");
01474                 }
01475 
01476                 if (($classname) && (strlen($_GET["calling_test"]) == 0))
01477                 {
01478                         if ($rbacsystem->checkAccess('write', $this->ref_id))
01479                         {
01480                                 $tabs_gui->addTarget("edit_properties",
01481                                         $this->ctrl->getLinkTargetByClass($classname, "editQuestion"), "editQuestion",
01482                                         $classname);
01483                         }
01484                 }
01485 
01486                 if (strlen($_GET["calling_test"]) == 0)
01487                 {
01488                         $tabs_gui->addTarget("back",
01489                                 $this->ctrl->getLinkTarget($this, "questions"), "questions",
01490                                 "ilObjQuestionPoolGUI");
01491                 }
01492                 else
01493                 {
01494                         $tabs_gui->addTarget("backtocallingtest",
01495                                 "test.php?cmd=questions&ref_id=".$_GET["calling_test"], "questions",
01496                                 "ilObjQuestionPoolGUI");
01497                 }
01498 
01499                 $this->tpl->setVariable("TABS", $tabs_gui->getHTML());
01500 //              echo "<br>end setQuestionTabs<br>";
01501         }
01502 
01503 /*
01504         function editMetaObject()
01505         {
01506                 $meta_gui =& new ilMetaDataGUI();
01507                 $meta_gui->setObject($this->object);
01508                 $meta_gui->edit("ADM_CONTENT", "adm_content",
01509                         $this->getTabTargetScript()."?ref_id=".$_GET["ref_id"]."&cmd=saveMeta");
01510         }
01511 
01512                 function saveMetaObject()
01513         {
01514                 $meta_gui =& new ilMetaDataGUI();
01515                 $meta_gui->setObject($this->object);
01516                 $meta_gui->save($_POST["meta_section"]);
01517                 if (!strcmp($_POST["meta_section"], "General")) {
01518                         //$this->updateObject();
01519                 }
01520                 ilUtil::redirect($this->getTabTargetScript()."?ref_id=".$_GET["ref_id"]);
01521         }
01522 
01523         // called by administration
01524         function chooseMetaSectionObject($a_script = "",
01525                 $a_templ_var = "ADM_CONTENT", $a_templ_block = "adm_content")
01526         {
01527                 if ($a_script == "")
01528                 {
01529                         $a_script = $this->getTabTargetScript()."?ref_id=".$_GET["ref_id"];
01530                 }
01531                 $meta_gui =& new ilMetaDataGUI();
01532                 $meta_gui->setObject($this->object);
01533                 $meta_gui->edit($a_templ_var, $a_templ_block, $a_script, $_REQUEST["meta_section"]);
01534         }
01535 
01536         // called by editor
01537         function chooseMetaSection()
01538         {
01539                 $this->chooseMetaSectionObject($this->getTabTargetScript()."?ref_id=".
01540                         $this->object->getRefId());
01541         }
01542 
01543         function addMetaObject($a_script = "",
01544                 $a_templ_var = "ADM_CONTENT", $a_templ_block = "adm_content")
01545         {
01546                 if ($a_script == "")
01547                 {
01548                         $a_script = $this->getTabTargetScript()."?ref_id=".$_GET["ref_id"];
01549                 }
01550                 $meta_gui =& new ilMetaDataGUI();
01551                 $meta_gui->setObject($this->object);
01552                 $meta_name = $_POST["meta_name"] ? $_POST["meta_name"] : $_GET["meta_name"];
01553                 $meta_index = $_POST["meta_index"] ? $_POST["meta_index"] : $_GET["meta_index"];
01554                 if ($meta_index == "")
01555                         $meta_index = 0;
01556                 $meta_path = $_POST["meta_path"] ? $_POST["meta_path"] : $_GET["meta_path"];
01557                 $meta_section = $_POST["meta_section"] ? $_POST["meta_section"] : $_GET["meta_section"];
01558                 if ($meta_name != "")
01559                 {
01560                         $meta_gui->meta_obj->add($meta_name, $meta_path, $meta_index);
01561                 }
01562                 else
01563                 {
01564                         sendInfo($this->lng->txt("meta_choose_element"), true);
01565                 }
01566                 $meta_gui->edit($a_templ_var, $a_templ_block, $a_script, $meta_section);
01567         }
01568 
01569         function addMeta()
01570         {
01571                 $this->addMetaObject($this->getTabTargetScript()."?ref_id=".
01572                         $this->object->getRefId());
01573         }
01574 
01575         function deleteMetaObject($a_script = "",
01576                 $a_templ_var = "ADM_CONTENT", $a_templ_block = "adm_content")
01577         {
01578                 if ($a_script == "")
01579                 {
01580                         $a_script = $this->getTabTargetScript()."?ref_id=".$_GET["ref_id"];
01581                 }
01582                 $meta_gui =& new ilMetaDataGUI();
01583                 $meta_gui->setObject($this->object);
01584                 $meta_index = $_POST["meta_index"] ? $_POST["meta_index"] : $_GET["meta_index"];
01585                 $meta_gui->meta_obj->delete($_GET["meta_name"], $_GET["meta_path"], $meta_index);
01586                 $meta_gui->edit($a_templ_var, $a_templ_block, $a_script, $_GET["meta_section"]);
01587         }
01588 
01589         function deleteMeta()
01590         {
01591                 $this->deleteMetaObject($this->getTabTargetScript()."?ref_id=".
01592                         $this->object->getRefId());
01593         }
01594 */
01595 
01596         /*
01597         * list all export files
01598         */
01599         function exportObject()
01600         {
01601                 global $tree;
01602 
01603                 //$this->setTabs();
01604 
01605                 //add template for view button
01606                 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
01607 
01608                 // create export file button
01609                 $this->tpl->setCurrentBlock("btn_cell");
01610                 $this->tpl->setVariable("BTN_LINK", "questionpool.php?ref_id=".$_GET["ref_id"]."&cmd=createExportFile");
01611                 $this->tpl->setVariable("BTN_TXT", $this->lng->txt("ass_create_export_file"));
01612                 $this->tpl->parseCurrentBlock();
01613 
01614                 // view last export log button
01615                 /*
01616                 if (is_file($this->object->getExportDirectory()."/export.log"))
01617                 {
01618                         $this->tpl->setCurrentBlock("btn_cell");
01619                         $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "viewExportLog"));
01620                         $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_view_last_export_log"));
01621                         $this->tpl->parseCurrentBlock();
01622                 }*/
01623 
01624                 $export_dir = $this->object->getExportDirectory();
01625                 $export_files = $this->object->getExportFiles($export_dir);
01626 
01627                 // create table
01628                 require_once("classes/class.ilTableGUI.php");
01629                 $tbl = new ilTableGUI();
01630 
01631                 // load files templates
01632                 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
01633 
01634                 // load template for table content data
01635                 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.export_file_row.html", true);
01636 
01637                 $num = 0;
01638 
01639                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01640 
01641                 $tbl->setTitle($this->lng->txt("ass_export_files"));
01642 
01643                 $tbl->setHeaderNames(array("<input type=\"checkbox\" name=\"chb_check_all\" value=\"1\" onclick=\"setCheckboxes('ObjectItems', 'file', document.ObjectItems.chb_check_all.checked);\" />", $this->lng->txt("ass_file"),
01644                         $this->lng->txt("ass_size"), $this->lng->txt("date") ));
01645                 $tbl->enabled["sort"] = false;
01646                 $tbl->setColumnWidth(array("1%", "49%", "25%", "25%"));
01647 
01648                 // control
01649                 $tbl->setOrderColumn($_GET["sort_by"]);
01650                 $tbl->setOrderDirection($_GET["sort_order"]);
01651                 $tbl->setLimit($_GET["limit"]);
01652                 $tbl->setOffset($_GET["offset"]);
01653 
01654                 $this->tpl->setVariable("COLUMN_COUNTS", 4);
01655 
01656                 // delete button
01657                 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
01658                 $this->tpl->setCurrentBlock("tbl_action_btn");
01659                 $this->tpl->setVariable("BTN_NAME", "confirmDeleteExportFile");
01660                 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
01661                 $this->tpl->parseCurrentBlock();
01662 
01663                 $this->tpl->setCurrentBlock("tbl_action_btn");
01664                 $this->tpl->setVariable("BTN_NAME", "downloadExportFile");
01665                 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("download"));
01666                 $this->tpl->parseCurrentBlock();
01667 
01668                 // footer
01669                 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
01670                 //$tbl->disable("footer");
01671 
01672                 $tbl->setMaxCount(count($export_files));
01673                 $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
01674 
01675                 $tbl->render();
01676                 if(count($export_files) > 0)
01677                 {
01678                         $i=0;
01679                         foreach($export_files as $exp_file)
01680                         {
01681                                 $this->tpl->setCurrentBlock("tbl_content");
01682                                 $this->tpl->setVariable("TXT_FILENAME", $exp_file);
01683 
01684                                 $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
01685                                 $this->tpl->setVariable("CSS_ROW", $css_row);
01686 
01687                                 $this->tpl->setVariable("TXT_SIZE", filesize($export_dir."/".$exp_file));
01688                                 $this->tpl->setVariable("CHECKBOX_ID", $exp_file);
01689 
01690                                 $file_arr = explode("__", $exp_file);
01691                                 $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s",$file_arr[0]));
01692 
01693                                 $this->tpl->parseCurrentBlock();
01694                         }
01695                 } //if is_array
01696                 else
01697                 {
01698                         $this->tpl->setCurrentBlock("notfound");
01699                         $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
01700                         $this->tpl->setVariable("NUM_COLS", 3);
01701                         $this->tpl->parseCurrentBlock();
01702                 }
01703 
01704                 $this->tpl->parseCurrentBlock();
01705         }
01706 
01707         
01711         function createExportFileObject()
01712         {
01713                 global $rbacsystem;
01714                 if ($rbacsystem->checkAccess("write", $this->ref_id))
01715                 {
01716                         require_once("assessment/classes/class.ilQuestionpoolExport.php");
01717                         $question_ids =& $this->object->getAllQuestionIds();
01718                         $qpl_exp = new ilQuestionpoolExport($this->object, "xml", $question_ids);
01719                         $qpl_exp->buildExportFile();
01720                         $this->exportObject();
01721 
01722                         //ilUtil::deliverData($this->object->to_xml(), $this->object->getTitle() . ".xml");
01723                         
01724                         /*
01725                         $add_parameter = $this->getAddParameter();
01726                         if (!defined("ILIAS_MODULE"))
01727                         {
01728                                 define("ILIAS_MODULE", "assessment");
01729                         }
01730                         $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_export.html", true);
01731                         $this->tpl->setCurrentBlock("adm_content");
01732                         $this->tpl->setVariable("FORMACTION", $add_parameter);
01733                         $this->tpl->setVariable("BUTTON_EXPORT", $this->lng->txt("export"));
01734                         $this->tpl->parseCurrentBlock();*/
01735                 }
01736                 else
01737                 {
01738                         sendInfo("cannot_export_qpl");
01739                 }
01740         }
01741         
01745         function downloadExportFileObject()
01746         {
01747                 if(!isset($_POST["file"]))
01748                 {
01749                         sendInfo($this->lng->txt("no_checkbox"), true);
01750                         $this->ctrl->redirect($this, "export");
01751                 }
01752 
01753                 if (count($_POST["file"]) > 1)
01754                 {
01755                         sendInfo($this->lng->txt("cont_select_max_one_item"), true);
01756                         $this->ctrl->redirect($this, "export");
01757                 }
01758 
01759 
01760                 $export_dir = $this->object->getExportDirectory();
01761                 ilUtil::deliverFile($export_dir."/".$_POST["file"][0],
01762                         $_POST["file"][0]);
01763                 $this->ctrl->redirect($this, "export");
01764         }
01765 
01769         function confirmDeleteExportFileObject()
01770         {
01771                 if(!isset($_POST["file"]))
01772                 {
01773                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
01774                 }
01775 
01776                 //$this->setTabs();
01777 
01778                 // SAVE POST VALUES
01779                 $_SESSION["ilExportFiles"] = $_POST["file"];
01780 
01781                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html", true);
01782 
01783                 sendInfo($this->lng->txt("info_delete_sure"));
01784 
01785                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01786 
01787                 // BEGIN TABLE HEADER
01788                 $this->tpl->setCurrentBlock("table_header");
01789                 $this->tpl->setVariable("TEXT",$this->lng->txt("objects"));
01790                 $this->tpl->parseCurrentBlock();
01791 
01792                 // BEGIN TABLE DATA
01793                 $counter = 0;
01794                 foreach($_POST["file"] as $file)
01795                 {
01796                                 $this->tpl->setCurrentBlock("table_row");
01797                                 $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
01798                                 $this->tpl->setVariable("TEXT_CONTENT", $file);
01799                                 $this->tpl->parseCurrentBlock();
01800                 }
01801 
01802                 // cancel/confirm button
01803                 $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
01804                 $buttons = array( "cancelDeleteExportFile"  => $this->lng->txt("cancel"),
01805                         "deleteExportFile"  => $this->lng->txt("confirm"));
01806                 foreach ($buttons as $name => $value)
01807                 {
01808                         $this->tpl->setCurrentBlock("operation_btn");
01809                         $this->tpl->setVariable("BTN_NAME",$name);
01810                         $this->tpl->setVariable("BTN_VALUE",$value);
01811                         $this->tpl->parseCurrentBlock();
01812                 }
01813         }
01814 
01815 
01819         function cancelDeleteExportFileObject()
01820         {
01821                 session_unregister("ilExportFiles");
01822                 $this->ctrl->redirect($this, "export");
01823         }
01824 
01828         function deleteExportFileObject()
01829         {
01830                 $export_dir = $this->object->getExportDirectory();
01831                 foreach($_SESSION["ilExportFiles"] as $file)
01832                 {
01833                         $exp_file = $export_dir."/".$file;
01834                         $exp_dir = $export_dir."/".substr($file, 0, strlen($file) - 4);
01835                         if (@is_file($exp_file))
01836                         {
01837                                 unlink($exp_file);
01838                         }
01839                         if (@is_dir($exp_dir))
01840                         {
01841                                 ilUtil::delDir($exp_dir);
01842                         }
01843                 }
01844                 $this->ctrl->redirect($this, "export");
01845         }
01846 
01850         function &editQuestionForTestObject()
01851         {
01852 //echo "<br>create--".$_GET["new_type"];
01853                 $q_gui =& ASS_QuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
01854                 $this->ctrl->setCmdClass(get_class($q_gui));
01855                 $this->ctrl->setCmd("editQuestion");
01856 
01857                 $ret =& $this->executeCommand();
01858                 return $ret;
01859         }
01860 
01864         function createObject()
01865         {
01866                 global $rbacsystem;
01867                 $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
01868                 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
01869                 {
01870                         $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
01871                 }
01872                 else
01873                 {
01874                         $this->getTemplateFile("create", $new_type);
01875 
01876                         // fill in saved values in case of error
01877                         $data = array();
01878                         $data["fields"] = array();
01879                         $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
01880                         $data["fields"]["desc"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["desc"]);
01881 
01882                         foreach ($data["fields"] as $key => $val)
01883                         {
01884                                 $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
01885                                 $this->tpl->setVariable(strtoupper($key), $val);
01886 
01887                                 if ($this->prepare_output)
01888                                 {
01889                                         $this->tpl->parseCurrentBlock();
01890                                 }
01891                         }
01892 
01893                         $this->tpl->setVariable("FORMACTION", $this->getFormAction("save","adm_object.php?cmd=gateway&ref_id=".
01894                                                                                                                                            $_GET["ref_id"]."&new_type=".$new_type));
01895                         $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
01896                         $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
01897                         $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
01898                         $this->tpl->setVariable("CMD_SUBMIT", "save");
01899                         $this->tpl->setVariable("TARGET", $this->getTargetFrame("save"));
01900                         $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
01901 
01902                         $this->tpl->setVariable("TXT_IMPORT_QPL", $this->lng->txt("import_qpl"));
01903                         $this->tpl->setVariable("TXT_QPL_FILE", $this->lng->txt("qpl_upload_file"));
01904                         $this->tpl->setVariable("NEW_TYPE", $this->type);
01905                         $this->tpl->setVariable("TXT_IMPORT", $this->lng->txt("import"));
01906                         $this->tpl->parseCurrentBlock();
01907                 }
01908         }
01909 
01913         function importFileObject()
01914         {
01915                 if (strcmp($_FILES["xmldoc"]["tmp_name"], "") == 0)
01916                 {
01917                         sendInfo($this->lng->txt("qpl_select_file_for_import"));
01918                         $this->createObject();
01919                         return;
01920                 }
01921                 $this->uploadQplObject();
01922         }
01923 
01929         function getTabs(&$tabs_gui)
01930         {
01931                 $tabs_gui->getTargetsByObjectType($this, "qpl");
01932 
01933                 $tabs_gui->addTarget("meta_data",
01934                          $this->ctrl->getLinkTargetByClass('ilmdeditorgui',''),
01935                          "meta_data", get_class($this));
01936         }
01937 
01938 
01939 } // END class.ilObjQuestionPoolGUI
01940 ?>

Generated on Fri Dec 13 2013 10:18:26 for ILIAS Release_3_5_x_branch .rev 46805 by  doxygen 1.7.1