• Main Page
  • Related Pages
  • Modules
  • 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 
00045 include_once "./classes/class.ilObjectGUI.php";
00046 include_once "./assessment/classes/class.assQuestionGUI.php";
00047 include_once "./assessment/classes/class.ilObjQuestionPool.php";
00048 include_once "./assessment/classes/inc.AssessmentConstants.php";
00049 
00050 class ilObjQuestionPoolGUI extends ilObjectGUI
00051 {
00056         function ilObjQuestionPoolGUI()
00057         {
00058                 global $lng, $ilCtrl, $rbacsystem;
00059                 $lng->loadLanguageModule("assessment");
00060 
00061                 $this->type = "qpl";
00062                 $this->ctrl =& $ilCtrl;
00063                 $this->ctrl->saveParameter($this, array("ref_id", "test_ref_id", "calling_test"));
00064 
00065                 $this->ilObjectGUI("",$_GET["ref_id"], true, false);
00066                 if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
00067                 {
00068                         $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00069                 }
00070         }
00071 
00075         function &executeCommand()
00076         {
00077                 global $ilLocator;
00078                 $this->prepareOutput();
00079                 $cmd = $this->ctrl->getCmd("questions");
00080                 $next_class = $this->ctrl->getNextClass($this);
00081                 $this->ctrl->setReturn($this, "questions");
00082                 if ($_GET["q_id"] < 1)
00083                 {
00084                         $q_type = ($_POST["sel_question_types"] != "")
00085                                 ? $_POST["sel_question_types"]
00086                                 : $_GET["sel_question_types"];
00087                 }
00088                 if ($cmd != "createQuestion" && $cmd != "createQuestionForTest"
00089                         && $next_class != "ilpageobjectgui")
00090                 {
00091                         if (($_GET["test_ref_id"] != "") or ($_GET["calling_test"]))
00092                         {
00093                                 $ref_id = $_GET["test_ref_id"];
00094                                 if (!$ref_id)
00095                                 {
00096                                         $ref_id = $_GET["calling_test"];
00097                                 }
00098                         }
00099                 }
00100                 switch($next_class)
00101                 {
00102                         case 'ilmdeditorgui':
00103                                 include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
00104 
00105                                 $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
00106                                 $md_gui->addObserver($this->object,'MDUpdateListener','General');
00107                                 $this->ctrl->forwardCommand($md_gui);
00108                                 break;
00109                         case "ilpageobjectgui":
00110                                 include_once("classes/class.ilObjStyleSheet.php");
00111                                 $this->tpl->setCurrentBlock("ContentStyle");
00112                                 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00113                                         ilObjStyleSheet::getContentStylePath(0));
00114                                 $this->tpl->parseCurrentBlock();
00115 
00116                                 // syntax style
00117                                 $this->tpl->setCurrentBlock("SyntaxStyle");
00118                                 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
00119                                         ilObjStyleSheet::getSyntaxStylePath());
00120                                 $this->tpl->parseCurrentBlock();
00121                                 include_once "./assessment/classes/class.assQuestionGUI.php";
00122                                 $q_gui =& assQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
00123                                 $q_gui->outAdditionalOutput();
00124                                 $q_gui->object->setObjId($this->object->getId());
00125                                 $question =& $q_gui->object;
00126                                 $this->ctrl->saveParameter($this, "q_id");
00127                                 $count = $question->isInUse();
00128                                 if (($count) && strcmp($this->ctrl->getCmd(), "view") == 0)
00129                                 {
00130                                         global $rbacsystem;
00131                                         if ($rbacsystem->checkAccess("write", $this->ref_id))
00132                                         {
00133                                                 sendInfo(sprintf($this->lng->txt("qpl_question_is_in_use"), $count));
00134                                         }
00135                                 }
00136                                 include_once("content/classes/Pages/class.ilPageObject.php");
00137                                 include_once("content/classes/Pages/class.ilPageObjectGUI.php");
00138                                 $this->lng->loadLanguageModule("content");
00139                                 $this->ctrl->setReturnByClass("ilPageObjectGUI", "view");
00140                                 $this->ctrl->setReturn($this, "questions");
00141                                 $page =& new ilPageObject("qpl", $_GET["q_id"]);
00142                                 $page_gui =& new ilPageObjectGUI($page);
00143                                 if (strlen($this->ctrl->getCmd()) == 0)
00144                                 {
00145                                         $this->ctrl->setCmdClass(get_class($page_gui));
00146                                         $this->ctrl->setCmd("preview");
00147                                 }
00148                                 //$page_gui->setQuestionXML($question->to_xml(false, false, true));
00149                                 $page_gui->setQuestionHTML($q_gui->getPreview());
00150                                 $page_gui->setTemplateTargetVar("ADM_CONTENT");
00151                                 $page_gui->setOutputMode("edit");
00152                                 $page_gui->setHeader($question->getTitle());
00153                                 $page_gui->setFileDownloadLink($this->ctrl->getLinkTarget($this, "downloadFile"));
00154                                 $page_gui->setFullscreenLink($this->ctrl->getLinkTarget($this, "fullscreen"));
00155                                 $page_gui->setSourcecodeDownloadScript($this->ctrl->getLinkTarget($this));
00156                                 $page_gui->setPresentationTitle($question->getTitle());
00157                                 $ret =& $this->ctrl->forwardCommand($page_gui);
00158                                 break;
00159                         case 'ilpermissiongui':
00160                                 include_once("./classes/class.ilPermissionGUI.php");
00161                                 $perm_gui =& new ilPermissionGUI($this);
00162                                 $ret =& $this->ctrl->forwardCommand($perm_gui);
00163                                 break;
00164                         case "ilobjquestionpoolgui":
00165                         case "":
00166                                 $cmd.= "Object";
00167                                 $ret =& $this->$cmd();
00168                                 break;
00169                         default:
00170                                 $this->ctrl->setReturn($this, "questions");
00171                                 include_once "./assessment/classes/class.assQuestionGUI.php";
00172                                 $q_gui =& assQuestionGUI::_getQuestionGUI($q_type, $_GET["q_id"]);
00173                                 $q_gui->object->setObjId($this->object->getId());
00174                                 $count = $q_gui->object->isInUse();
00175                                 if (($count) && strcmp($this->ctrl->getCmd(), "assessment") != 0)
00176                                 {
00177                                         global $rbacsystem;
00178                                         if ($rbacsystem->checkAccess("write", $this->ref_id))
00179                                         {
00180                                                 sendInfo(sprintf($this->lng->txt("qpl_question_is_in_use"), $count));
00181                                         }
00182                                 }
00183                                 $ret =& $this->ctrl->forwardCommand($q_gui);
00184                                 break;
00185                 }
00186 
00187                 if (strtolower($_GET["baseClass"]) != "iladministrationgui" &&
00188                         $this->getCreationMode() != true)
00189                 {
00190                         $this->tpl->show();
00191                 }
00192         }
00193 
00197         function propertiesObject()
00198         {
00199                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_qpl_properties.html", true);
00200                 $this->tpl->setCurrentBlock("adm_content");
00201                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00202                 $this->tpl->setVariable("HEADING_GENERAL", $this->lng->txt("qpl_general_properties"));
00203                 $this->tpl->setVariable("PROPERTY_ONLINE", $this->lng->txt("qpl_online_property"));
00204                 $this->tpl->setVariable("PROPERTY_ONLINE_DESCRIPTION", $this->lng->txt("qpl_online_property_description"));
00205                 if ($this->object->getOnline() == 1)
00206                 {
00207                         $this->tpl->setVariable("PROPERTY_ONLINE_CHECKED", " checked=\"checked\"");
00208                 }
00209                 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00210                 $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
00211                 $this->tpl->parseCurrentBlock();
00212         }
00213 
00219         function cancelObject($in_rep = false)
00220         {
00221                 sendInfo($this->lng->txt("msg_cancel"),true);
00222                 ilUtil::redirect("repository.php?cmd=frameset&ref_id=".$_GET["ref_id"]);
00223         }
00224 
00225 
00229         function savePropertiesObject()
00230         {
00231                 $qpl_online = $_POST["online"];
00232                 if (strlen($qpl_online) == 0) $qpl_online = "0";
00233                 $this->object->setOnline($qpl_online);
00234                 $this->object->saveToDb();
00235                 sendInfo($this->lng->txt("saved_successfully"), true);
00236                 $this->ctrl->redirect($this, "properties");
00237         }
00238 
00242         function downloadFileObject()
00243         {
00244                 $file = explode("_", $_GET["file_id"]);
00245                 include_once("classes/class.ilObjFile.php");
00246                 $fileObj =& new ilObjFile($file[count($file) - 1], false);
00247                 $fileObj->sendFile();
00248                 exit;
00249         }
00250 
00254         function fullscreenObject()
00255         {
00256                 include_once("content/classes/Pages/class.ilPageObject.php");
00257                 include_once("content/classes/Pages/class.ilPageObjectGUI.php");
00258                 $page =& new ilPageObject("qpl", $_GET["pg_id"]);
00259                 $page_gui =& new ilPageObjectGUI($page);
00260                 $page_gui->showMediaFullscreen();
00261 
00262         }
00263 
00264 
00268         function filterObject()
00269         {
00270                 $this->questionsObject();
00271         }
00272 
00276         function resetFilterObject()
00277         {
00278                 $_POST["filter_text"] = "";
00279                 $_POST["sel_filter_type"] = "";
00280                 $this->questionsObject();
00281         }
00282 
00286         function download_paragraphObject()
00287         {
00288                 include_once("content/classes/Pages/class.ilPageObject.php");
00289                 $pg_obj =& new ilPageObject("qpl", $_GET["pg_id"]);
00290                 $pg_obj->send_paragraph ($_GET["par_id"], $_GET["downloadtitle"]);
00291                 exit;
00292         }
00293 
00297         function uploadQplObject($questions_only = false)
00298         {
00299                 if ($_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK)
00300                 {
00301                         sendInfo($this->lng->txt("error_upload"));
00302                         $this->importObject();
00303                         return;
00304                 }
00305                 // create import directory
00306                 include_once "./assessment/classes/class.ilObjQuestionPool.php";
00307                 ilObjQuestionPool::_createImportDirectory();
00308 
00309                 // copy uploaded file to import directory
00310                 $file = pathinfo($_FILES["xmldoc"]["name"]);
00311                 $full_path = ilObjQuestionPool::_getImportDirectory()."/".$_FILES["xmldoc"]["name"];
00312                 include_once "./classes/class.ilUtil.php";
00313                 ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"], $_FILES["xmldoc"]["name"], $full_path);
00314                 if (strcmp($_FILES["xmldoc"]["type"], "text/xml") == 0)
00315                 {
00316                         $qti_file = $full_path;
00317                 }
00318                 else
00319                 {
00320                         // unzip file
00321                         ilUtil::unzip($full_path);
00322 
00323                         // determine filenames of xml files
00324                         $subdir = basename($file["basename"],".".$file["extension"]);
00325                         $xml_file = ilObjQuestionPool::_getImportDirectory()."/".$subdir."/".$subdir.".xml";
00326                         $qti_file = ilObjQuestionPool::_getImportDirectory()."/".$subdir."/". str_replace("qpl", "qti", $subdir).".xml";
00327                 }
00328 
00329                 // start verification of QTI files
00330                 include_once "./assessment/classes/QTI/class.ilQTIParser.php";
00331                 $qtiParser = new ilQTIParser($qti_file, IL_MO_VERIFY_QTI, 0, "");
00332                 $result = $qtiParser->startParsing();
00333                 $founditems =& $qtiParser->getFoundItems();
00334                 if (count($founditems) == 0)
00335                 {
00336                         // nothing found
00337 
00338                         // delete import directory
00339                         ilUtil::delDir(ilObjQuestionPool::_getImportDirectory());
00340 
00341                         sendInfo($this->lng->txt("qpl_import_no_items"));
00342                         $this->importObject();
00343                         return;
00344                 }
00345 
00346                 $complete = 0;
00347                 $incomplete = 0;
00348                 foreach ($founditems as $item)
00349                 {
00350                         if (strlen($item["type"]))
00351                         {
00352                                 $complete++;
00353                         }
00354                         else
00355                         {
00356                                 $incomplete++;
00357                         }
00358                 }
00359 
00360                 if ($complete == 0)
00361                 {
00362                         // delete import directory
00363                         ilUtil::delDir(ilObjQuestionPool::_getImportDirectory());
00364 
00365                         sendInfo($this->lng->txt("qpl_import_non_ilias_files"));
00366                         $this->importObject();
00367                         return;
00368                 }
00369 
00370                 $_SESSION["qpl_import_xml_file"] = $xml_file;
00371                 $_SESSION["qpl_import_qti_file"] = $qti_file;
00372                 $_SESSION["qpl_import_subdir"] = $subdir;
00373                 // display of found questions
00374                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.qpl_import_verification.html");
00375                 $row_class = array("tblrow1", "tblrow2");
00376                 $counter = 0;
00377                 foreach ($founditems as $item)
00378                 {
00379                         $this->tpl->setCurrentBlock("verification_row");
00380                         $this->tpl->setVariable("ROW_CLASS", $row_class[$counter++ % 2]);
00381                         $this->tpl->setVariable("QUESTION_TITLE", $item["title"]);
00382                         $this->tpl->setVariable("QUESTION_IDENT", $item["ident"]);
00383                         include_once "./assessment/classes/QTI/class.ilQTIItem.php";
00384                         switch ($item["type"])
00385                         {
00386                                 case "MULTIPLE CHOICE QUESTION":
00387                                 case QT_MULTIPLE_CHOICE_MR:
00388                                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("qt_multiple_choice"));
00389                                         break;
00390                                 case "SINGLE CHOICE QUESTION":
00391                                 case QT_MULTIPLE_CHOICE_SR:
00392                                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assSingleChoice"));
00393                                         break;
00394                                 case "NUMERIC QUESTION":
00395                                 case QT_NUMERIC:
00396                                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assNumeric"));
00397                                         break;
00398                                 case "TEXTSUBSET QUESTION":
00399                                 case QT_TEXTSUBSET:
00400                                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assTextSubset"));
00401                                         break;
00402                                 case "CLOZE QUESTION":
00403                                 case QT_CLOZE:
00404                                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assClozeTest"));
00405                                         break;
00406                                 case "IMAGE MAP QUESTION":
00407                                 case QT_IMAGEMAP:
00408                                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assImagemapQuestion"));
00409                                         break;
00410                                 case "JAVA APPLET QUESTION":
00411                                 case QT_JAVAAPPLET:
00412                                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assJavaApplet"));
00413                                         break;
00414                                 case "MATCHING QUESTION":
00415                                 case QT_MATCHING:
00416                                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assMatchingQuestion"));
00417                                         break;
00418                                 case "ORDERING QUESTION":
00419                                 case QT_ORDERING:
00420                                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assOrderingQuestion"));
00421                                         break;
00422                                 case "TEXT QUESTION":
00423                                 case QT_TEXT:
00424                                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assTextQuestion"));
00425                                         break;
00426                         }
00427                         $this->tpl->parseCurrentBlock();
00428                 }
00429 
00430                 $this->tpl->setCurrentBlock("import_qpl");
00431                 if (is_file($xml_file))
00432                 {
00433                         // read file into a string
00434                         $fh = @fopen($xml_file, "r") or die("");
00435                         $xml = @fread($fh, filesize($xml_file));
00436                         @fclose($fh);
00437                         if (preg_match("/<ContentObject.*?MetaData.*?General.*?Title[^>]*?>([^<]*?)</", $xml, $matches))
00438                         {
00439                                 $this->tpl->setVariable("VALUE_NEW_QUESTIONPOOL", $matches[1]);
00440                         }
00441                 }
00442                 $this->tpl->setVariable("TEXT_CREATE_NEW_QUESTIONPOOL", $this->lng->txt("qpl_import_create_new_qpl"));
00443                 $this->tpl->parseCurrentBlock();
00444 
00445                 $this->tpl->setCurrentBlock("adm_content");
00446                 $this->tpl->setVariable("TEXT_TYPE", $this->lng->txt("question_type"));
00447                 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("question_title"));
00448                 $this->tpl->setVariable("FOUND_QUESTIONS_INTRODUCTION", $this->lng->txt("qpl_import_verify_found_questions"));
00449                 if ($questions_only)
00450                 {
00451                         $this->tpl->setVariable("VERIFICATION_HEADING", $this->lng->txt("import_questions_into_qpl"));
00452                         $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00453                 }
00454                 else
00455                 {
00456                         $this->tpl->setVariable("VERIFICATION_HEADING", $this->lng->txt("import_qpl"));
00457 
00458                         $this->ctrl->setParameter($this, "new_type", $this->type);
00459                         $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00460 
00461                         //$this->tpl->setVariable("FORMACTION", $this->getFormAction("save","adm_object.php?cmd=gateway&ref_id=".$_GET["ref_id"]."&new_type=".$this->type));
00462                 }
00463                 $this->tpl->setVariable("ARROW", ilUtil::getImagePath("arrow_downright.gif"));
00464                 $this->tpl->setVariable("VALUE_IMPORT", $this->lng->txt("import"));
00465                 $this->tpl->setVariable("VALUE_CANCEL", $this->lng->txt("cancel"));
00466                 $value_questions_only = 0;
00467                 if ($questions_only) $value_questions_only = 1;
00468                 $this->tpl->setVariable("VALUE_QUESTIONS_ONLY", $value_questions_only);
00469 
00470                 $this->tpl->parseCurrentBlock();
00471         }
00472 
00476         function importVerifiedFileObject()
00477         {
00478                 if ($_POST["questions_only"] == 1)
00479                 {
00480                         $newObj =& $this->object;
00481                 }
00482                 else
00483                 {
00484                         include_once("./assessment/classes/class.ilObjQuestionPool.php");
00485                         // create new questionpool object
00486                         $newObj = new ilObjQuestionPool(true);
00487                         // set type of questionpool object
00488                         $newObj->setType($_GET["new_type"]);
00489                         // set title of questionpool object to "dummy"
00490                         $newObj->setTitle("dummy");
00491                         // set description of questionpool object
00492                         $newObj->setDescription("questionpool import");
00493                         // create the questionpool class in the ILIAS database (object_data table)
00494                         $newObj->create(true);
00495                         // create a reference for the questionpool object in the ILIAS database (object_reference table)
00496                         $newObj->createReference();
00497                         // put the questionpool object in the administration tree
00498                         $newObj->putInTree($_GET["ref_id"]);
00499                         // get default permissions and set the permissions for the questionpool object
00500                         $newObj->setPermissions($_GET["ref_id"]);
00501                         // notify the questionpool object and all its parent objects that a "new" object was created
00502                         $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
00503                 }
00504 
00505                 // start parsing of QTI files
00506                 include_once "./assessment/classes/QTI/class.ilQTIParser.php";
00507                 $qtiParser = new ilQTIParser($_SESSION["qpl_import_qti_file"], IL_MO_PARSE_QTI, $newObj->getId(), $_POST["ident"]);
00508                 $result = $qtiParser->startParsing();
00509 
00510                 // import page data
00511                 if (strlen($_SESSION["qpl_import_xml_file"]))
00512                 {
00513                         include_once ("content/classes/class.ilContObjParser.php");
00514                         $contParser = new ilContObjParser($newObj, $_SESSION["qpl_import_xml_file"], $_SESSION["qpl_import_subdir"]);
00515                         $contParser->setQuestionMapping($qtiParser->getImportMapping());
00516                         $contParser->startParsing();
00517                 }
00518 
00519                 // set another question pool name (if possible)
00520                 $qpl_name = $_POST["qpl_new"];
00521                 if ((strcmp($qpl_name, $newObj->getTitle()) != 0) && (strlen($qpl_name) > 0))
00522                 {
00523                         $newObj->setTitle($qpl_name);
00524                         $newObj->update();
00525                 }
00526 
00527                 // delete import directory
00528                 include_once "./classes/class.ilUtil.php";
00529                 ilUtil::delDir(ilObjQuestionPool::_getImportDirectory());
00530 
00531                 if ($_POST["questions_only"] == 1)
00532                 {
00533                         $this->ctrl->redirect($this, "questions");
00534                 }
00535                 else
00536                 {
00537                         sendInfo($this->lng->txt("object_imported"),true);
00538                         ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
00539                                 "&baseClass=ilObjQuestionPoolGUI");
00540                 }
00541         }
00542 
00543         function cancelImportObject()
00544         {
00545                 if ($_POST["questions_only"] == 1)
00546                 {
00547                         $this->ctrl->redirect($this, "questions");
00548                 }
00549                 else
00550                 {
00551                         $this->ctrl->redirect($this, "cancel");
00552                 }
00553         }
00554 
00558         function uploadObject()
00559         {
00560                 $this->uploadQplObject(true);
00561         }
00562 
00566                 function importQuestionsObject()
00567         {
00568                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_import_question.html", true);
00569                 $this->tpl->setCurrentBlock("adm_content");
00570                 $this->tpl->setVariable("TEXT_IMPORT_QUESTION", $this->lng->txt("import_question"));
00571                 $this->tpl->setVariable("TEXT_SELECT_FILE", $this->lng->txt("select_file"));
00572                 $this->tpl->setVariable("TEXT_UPLOAD", $this->lng->txt("upload"));
00573                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00574                 $this->tpl->parseCurrentBlock();
00575         }
00576 
00582         function importObject()
00583         {
00584                 global $rbacsystem;
00585                 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"]))
00586                 {
00587                         $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00588                 }
00589                 $this->getTemplateFile("import", "qpl");
00590                 $this->ctrl->setParameter($this, "new_type", $this->type);
00591                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00592                 //$this->tpl->setVariable("FORMACTION", "adm_object.php?&ref_id=".$_GET["ref_id"]."&cmd=gateway&new_type=".$this->type);
00593                 $this->tpl->setVariable("BTN_NAME", "uploadQpl");
00594                 $this->tpl->setVariable("TXT_UPLOAD", $this->lng->txt("import"));
00595                 $this->tpl->setVariable("NEW_TYPE", $this->type);
00596                 $this->tpl->setVariable("TXT_IMPORT_QPL", $this->lng->txt("import_qpl"));
00597                 $this->tpl->setVariable("TXT_SELECT_MODE", $this->lng->txt("select_mode"));
00598                 $this->tpl->setVariable("TXT_SELECT_FILE", $this->lng->txt("select_file"));
00599                 $this->tpl->parseCurrentBlock();
00600         }
00601 
00605         function &createQuestionObject()
00606         {
00607                 include_once "./assessment/classes/class.assQuestionGUI.php";
00608                 $q_gui =& assQuestionGUI::_getQuestionGUI($_POST["sel_question_types"]);
00609                 $q_gui->object->setObjId($this->object->getId());
00610                 $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $_POST["sel_question_types"]);
00611                 $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
00612         }
00613 
00617         function &createQuestionForTestObject()
00618         {
00619                 include_once "./assessment/classes/class.assQuestionGUI.php";
00620                 $q_gui =& assQuestionGUI::_getQuestionGUI($_GET["sel_question_types"]);
00621                 $q_gui->object->setObjId($this->object->getId());
00622                 $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $_GET["sel_question_types"]);
00623                 $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
00624         }
00625 
00630         function saveObject()
00631         {
00632                 global $rbacadmin;
00633 
00634                 // create and insert forum in objecttree
00635                 $newObj = parent::saveObject();
00636 
00637                 // always send a message
00638                 sendInfo($this->lng->txt("object_added"),true);
00639 
00640                 ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
00641                         "&baseClass=ilObjQuestionPoolGUI");
00642 
00643 /*              if (strlen($this->ctrl->getModuleDir()) == 0)
00644                 {
00645                         include_once "./classes/class.ilUtil.php";
00646                         ilUtil::redirect($this->getReturnLocation("save","adm_object.php?ref_id=".$_GET["ref_id"]));
00647                 }
00648                 else
00649                 {
00650                         $this->ctrl->redirect($this, "questions");
00651                 }*/
00652         }
00653 
00657         function assessmentObject()
00658         {
00659                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.il_as_qpl_content.html", true);
00660                 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00661 
00662                 // catch feedback message
00663                 sendInfo();
00664 
00665                 include_once "./assessment/classes/class.assQuestion.php";
00666                 $question_title = assQuestion::_getTitle($_GET["q_id"]);
00667                 $title = $this->lng->txt("statistics") . " - $question_title";
00668                 if (!empty($title))
00669                 {
00670                         $this->tpl->setVariable("HEADER", $title);
00671                 }
00672                 include_once("./assessment/classes/class.assQuestion.php");
00673                 $total_of_answers = assQuestion::_getTotalAnswers($_GET["q_id"]);
00674                 $counter = 0;
00675                 $color_class = array("tblrow1", "tblrow2");
00676                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_qpl_assessment_of_questions.html", true);
00677                 if (!$total_of_answers)
00678                 {
00679                         $this->tpl->setCurrentBlock("emptyrow");
00680                         $this->tpl->setVariable("TXT_NO_ASSESSMENT", $this->lng->txt("qpl_assessment_no_assessment_of_questions"));
00681                         $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00682                         $this->tpl->parseCurrentBlock();
00683                 }
00684                 else
00685                 {
00686                         $this->tpl->setCurrentBlock("row");
00687                         $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("qpl_assessment_total_of_answers"));
00688                         $this->tpl->setVariable("TXT_VALUE", $total_of_answers);
00689                         $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00690                         $counter++;
00691                         $this->tpl->parseCurrentBlock();
00692                         $this->tpl->setCurrentBlock("row");
00693                         $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("qpl_assessment_total_of_right_answers"));
00694                         $this->tpl->setVariable("TXT_VALUE", sprintf("%2.2f", assQuestion::_getTotalRightAnswers($_GET["edit"]) * 100.0) . " %");
00695                         $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00696                         $this->tpl->parseCurrentBlock();
00697                 }
00698                 $this->tpl->setCurrentBlock("adm_content");
00699                 $this->tpl->setVariable("TXT_QUESTION_TITLE", $question_title);
00700                 $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("result"));
00701                 $this->tpl->setVariable("TXT_VALUE", $this->lng->txt("value"));
00702                 $this->tpl->parseCurrentBlock();
00703         }
00704 
00705         function questionObject()
00706         {
00707 //echo "<br>ilObjQuestionPoolGUI->questionObject()";
00708                 $type = $_GET["sel_question_types"];
00709                 $this->editQuestionForm($type);
00710         }
00711 
00715         function deleteQuestionsObject()
00716         {
00717 //echo "<br>ilObjQuestionPoolGUI->deleteQuestions()";
00718                 // duplicate button was pressed
00719                 if (count($_POST["q_id"]) < 1)
00720                 {
00721                         sendInfo($this->lng->txt("qpl_delete_select_none"), true);
00722                         $this->ctrl->redirect($this, "questions");
00723                 }
00724 
00725                 $checked_questions =& $this->object->getQuestionDetails($_POST["q_id"]);
00726                 $deleteable_questions =& $this->object->getDeleteableQuestionDetails($_POST["q_id"]);
00727                 $used_questions =& $this->object->getUsedQuestionDetails($_POST["q_id"]);
00728                 $_SESSION["ass_q_id"] = $deleteable_questions;
00729                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_qpl_confirm_delete_questions.html", true);
00730 
00731                 $colors = array("tblrow1", "tblrow2");
00732                 $counter = 0;
00733                 include_once "./classes/class.ilUtil.php";
00734                 if (count($deleteable_questions) > 0)
00735                 {
00736                         foreach ($deleteable_questions as $question)
00737                         {
00738                                 $this->tpl->setCurrentBlock("row");
00739                                 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
00740                                 $this->tpl->setVariable("TXT_TITLE", $question["title"]);
00741                                 $this->tpl->setVariable("TXT_DESCRIPTION", $question["comment"]);
00742                                 $this->tpl->setVariable("TXT_TYPE", $this->lng->txt($question["type_tag"]));
00743                                 $this->tpl->parseCurrentBlock();
00744                                 $counter++;
00745 
00746                                 $this->tpl->setCurrentBlock("hidden");
00747                                 $this->tpl->setVariable("HIDDEN_NAME", "id_" . $question["question_id"]);
00748                                 $this->tpl->setVariable("HIDDEN_VALUE", "1");
00749                                 $this->tpl->parseCurrentBlock();
00750                         }
00751                 }
00752                 else
00753                 {
00754                         $this->tpl->setCurrentBlock("emptyrow");
00755                         $this->tpl->setVariable("TEXT_EMPTY_ROW", $this->lng->txt("qpl_delete_no_deleteable_questions"));
00756                         $this->tpl->parseCurrentBlock();
00757                 }
00758 
00759                 if (count($used_questions))
00760                 {
00761                         foreach ($used_questions as $question)
00762                         {
00763                                 $this->tpl->setCurrentBlock("undeleteable_row");
00764                                 $this->tpl->setVariable("QUESTION_TITLE", $question["title"]);
00765                                 $this->tpl->parseCurrentBlock();
00766                         }
00767                         $this->tpl->setCurrentBlock("undeleteable_questions");
00768                         $this->tpl->setVariable("TEXT_UNDELETEABLE_QUESTIONS", $this->lng->txt("qpl_delete_describe_undeleteable_questions"));
00769                         $this->tpl->parseCurrentBlock();
00770                 }
00771 
00772                 $this->tpl->setCurrentBlock("adm_content");
00773                 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("tst_question_title"));
00774                 $this->tpl->setVariable("TXT_DESCRIPTION", $this->lng->txt("description"));
00775                 $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("tst_question_type"));
00776                 $this->tpl->setVariable("TXT_LOCKED", $this->lng->txt("locked"));
00777                 $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
00778                 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
00779                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00780                 $this->tpl->setVariable("DELETE_QUESTION", $this->lng->txt("qpl_confirm_delete_questions"));
00781                 $this->tpl->parseCurrentBlock();
00782         }
00783 
00784 
00788         function confirmDeleteQuestionsObject()
00789         {
00790                 // delete questions after confirmation
00791                 if (count($_SESSION["ass_q_id"])) sendInfo($this->lng->txt("qpl_questions_deleted"), true);
00792                 foreach ($_SESSION["ass_q_id"] as $key => $value)
00793                 {
00794                         $this->object->deleteQuestion($value["question_id"]);
00795                 }
00796                 $this->ctrl->redirect($this, "questions");
00797         }
00798 
00802         function cancelDeleteQuestionsObject()
00803         {
00804                 $this->ctrl->redirect($this, "questions");
00805         }
00806 
00810         function duplicateObject()
00811         {
00812                 // duplicate button was pressed
00813                 if (count($_POST["q_id"]) > 0)
00814                 {
00815                         foreach ($_POST["q_id"] as $key => $value)
00816                         {
00817                                 $this->object->duplicateQuestion($value);
00818                         }
00819                 }
00820                 else
00821                 {
00822                         sendInfo($this->lng->txt("qpl_duplicate_select_none"), true);
00823                 }
00824                 $this->ctrl->redirect($this, "questions");
00825         }
00826 
00830         function exportQuestionObject()
00831         {
00832                 // export button was pressed
00833                 if (count($_POST["q_id"]) > 0)
00834                 {
00835                         include_once("assessment/classes/class.ilQuestionpoolExport.php");
00836                         $qpl_exp = new ilQuestionpoolExport($this->object, "xml", $_POST["q_id"]);
00837                         $export_file = $qpl_exp->buildExportFile();
00838                         $filename = $export_file;
00839                         $filename = preg_replace("/.*\//", "", $filename);
00840                         include_once "./classes/class.ilUtil.php";
00841                         ilUtil::deliverFile($export_file, $filename);
00842                         exit();
00843                 }
00844                 else
00845                 {
00846                         sendInfo($this->lng->txt("qpl_export_select_none"), true);
00847                 }
00848                 $this->ctrl->redirect($this, "questions");
00849         }
00850 
00854         function questionsObject()
00855         {
00856                 global $rbacsystem;
00857                 global $ilUser;
00858 
00859                 $lastquestiontype = $ilUser->getPref("tst_lastquestiontype");
00860                 $type = $_GET["sel_question_types"];
00861 
00862                 // reset test_id SESSION variable
00863                 $_SESSION["test_id"] = "";
00864 
00865                 // create an array of all checked checkboxes
00866                 $checked_questions = array();
00867                 foreach ($_POST as $key => $value)
00868                 {
00869                         if (preg_match("/cb_(\d+)/", $key, $matches))
00870                         {
00871                                 array_push($checked_questions, $matches[1]);
00872                         }
00873                 }
00874 
00875                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.qpl_questions.html", true);
00876                 if ($rbacsystem->checkAccess('write', $this->ref_id))
00877                 {
00878                         $this->tpl->addBlockFile("CREATE_QUESTION", "create_question", "tpl.il_as_create_new_question.html", true);
00879                         $this->tpl->addBlockFile("A_BUTTONS", "a_buttons", "tpl.il_as_qpl_action_buttons.html", true);
00880                 }
00881                 $this->tpl->addBlockFile("FILTER_QUESTION_MANAGER", "filter_questions", "tpl.il_as_qpl_filter_questions.html", true);
00882 
00883                 // create filter form
00884                 $filter_fields = array(
00885                         "title" => $this->lng->txt("title"),
00886                         "comment" => $this->lng->txt("description"),
00887                         "author" => $this->lng->txt("author"),
00888                 );
00889                 $this->tpl->setCurrentBlock("filterrow");
00890                 foreach ($filter_fields as $key => $value)
00891                 {
00892                         $this->tpl->setVariable("VALUE_FILTER_TYPE", "$key");
00893                         $this->tpl->setVariable("NAME_FILTER_TYPE", "$value");
00894                         if (strcmp($_POST["sel_filter_type"], $key) == 0)
00895                         {
00896                                 $this->tpl->setVariable("VALUE_FILTER_SELECTED", " selected=\"selected\"");
00897                         }
00898                         $this->tpl->parseCurrentBlock();
00899                 }
00900 
00901                 $this->tpl->setCurrentBlock("filter_questions");
00902                 $this->tpl->setVariable("FILTER_TEXT", $this->lng->txt("filter"));
00903                 $this->tpl->setVariable("TEXT_FILTER_BY", $this->lng->txt("by"));
00904                 $this->tpl->setVariable("VALUE_FILTER_TEXT", $_POST["filter_text"]);
00905                 $this->tpl->setVariable("VALUE_SUBMIT_FILTER", $this->lng->txt("set_filter"));
00906                 $this->tpl->setVariable("VALUE_RESET_FILTER", $this->lng->txt("reset_filter"));
00907                 $this->tpl->parseCurrentBlock();
00908 
00909                 // create edit buttons & table footer
00910                 if ($rbacsystem->checkAccess('write', $this->ref_id))
00911                 {
00912                         $this->tpl->setCurrentBlock("standard");
00913                         $this->tpl->setVariable("DELETE", $this->lng->txt("delete"));
00914                         $this->tpl->setVariable("DUPLICATE", $this->lng->txt("duplicate"));
00915                         $this->tpl->setVariable("EXPORT", $this->lng->txt("export"));
00916                         $this->tpl->setVariable("COPY", $this->lng->txt("copy"));
00917                         $this->tpl->setVariable("MOVE", $this->lng->txt("move"));
00918                         $this->tpl->parseCurrentBlock();
00919                         if (array_key_exists("qpl_clipboard", $_SESSION))
00920                         {
00921                                 $this->tpl->setCurrentBlock("pastebutton");
00922                                 $this->tpl->setVariable("PASTE", $this->lng->txt("paste"));
00923                                 $this->tpl->parseCurrentBlock();
00924                         }
00925                         $this->tpl->setCurrentBlock("Footer");
00926                         include_once "./classes/class.ilUtil.php";
00927                         $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\"/>");
00928                         $this->tpl->parseCurrentBlock();
00929                 }
00930 
00931                 $this->tpl->setCurrentBlock("QTab");
00932 
00933                 // reset the filter
00934                 $startrow = 0;
00935                 if ($_GET["prevrow"])
00936                 {
00937                         $startrow = $_GET["prevrow"];
00938                 }
00939                 if ($_GET["nextrow"])
00940                 {
00941                         $startrow = $_GET["nextrow"];
00942                 }
00943                 if ($_GET["startrow"])
00944                 {
00945                         $startrow = $_GET["startrow"];
00946                 }
00947                 $sort = ($_GET["sort"]) ? $_GET["sort"] : "title";
00948                 $sortorder = ($_GET["sortorder"]) ? $_GET["sortorder"] : "ASC";
00949                 $this->ctrl->setParameter($this, "sort", $sort);
00950                 $this->ctrl->setParameter($this, "sortorder", $sortorder);
00951                 $table = $this->object->getQuestionsTable($sort, $sortorder, $_POST["filter_text"], $_POST["sel_filter_type"], $startrow);
00952                 $colors = array("tblrow1", "tblrow2");
00953                 include_once "./classes/class.ilUtil.php";
00954                 $counter = 0;
00955                 $sumPoints = 0;
00956                 $editable = $rbacsystem->checkAccess('write', $this->ref_id);
00957                 foreach ($table["rows"] as $data)
00958                 {
00959                         include_once "./assessment/classes/class.assQuestionGUI.php";
00960                         $class = strtolower(assQuestionGUI::_getGUIClassNameForId($data["question_id"]));
00961                         $this->ctrl->setParameterByClass("ilpageobjectgui", "q_id", $data["question_id"]);
00962                         $this->ctrl->setParameterByClass($class, "q_id", $data["question_id"]);
00963 
00964                         if ($data["complete"] == 0)
00965                         {
00966                                 $this->tpl->setCurrentBlock("qpl_warning");
00967                                 $this->tpl->setVariable("IMAGE_WARNING", ilUtil::getImagePath("warning.gif"));
00968                                 $this->tpl->setVariable("ALT_WARNING", $this->lng->txt("warning_question_not_complete"));
00969                                 $this->tpl->setVariable("TITLE_WARNING", $this->lng->txt("warning_question_not_complete"));
00970                                 $this->tpl->parseCurrentBlock();
00971                                 $points = 0;
00972                         } else
00973                         {
00974                             $points = assQuestion::_getMaximumPoints($data["question_id"]);
00975                         }
00976                         $sumPoints += $points;
00977 
00978                         if ($editable)
00979                         {
00980                                 $this->tpl->setCurrentBlock("checkable");
00981                                 $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
00982                                 $this->tpl->parseCurrentBlock();
00983                                 $this->tpl->setCurrentBlock("edit_link");
00984                                 $this->tpl->setVariable("TXT_EDIT", $this->lng->txt("edit"));
00985                                 $this->tpl->setVariable("LINK_EDIT", $this->ctrl->getLinkTargetByClass("ilpageobjectgui", "view"));
00986                                 $this->tpl->parseCurrentBlock();
00987                         }
00988                         $this->tpl->setCurrentBlock("QTab");
00989                         $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
00990                         $this->tpl->setVariable("QUESTION_TITLE", "<strong>" .$data["title"] . "</strong>");
00991 
00992                         $this->tpl->setVariable("TXT_PREVIEW", $this->lng->txt("preview"));
00993                         $this->tpl->setVariable("LINK_PREVIEW", $this->ctrl->getLinkTargetByClass("ilpageobjectgui", "preview"));
00994 
00995                         $this->tpl->setVariable("QUESTION_COMMENT", $data["comment"]);
00996                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($data["type_tag"]));
00997                         $this->tpl->setVariable("LINK_ASSESSMENT", $this->ctrl->getLinkTargetByClass($class, "assessment"));
00998                         $this->tpl->setVariable("TXT_ASSESSMENT", $this->lng->txt("statistics"));
00999                         include_once "./classes/class.ilUtil.php";
01000                         $this->tpl->setVariable("IMG_ASSESSMENT", ilUtil::getImagePath("assessment.gif", true));
01001                         $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]);
01002                         include_once "./classes/class.ilFormat.php";
01003                         $this->tpl->setVariable("QUESTION_CREATED", ilFormat::formatDate(ilFormat::ftimestamp2dateDB($data["created"]), "date"));
01004                         $this->tpl->setVariable("QUESTION_UPDATED", ilFormat::formatDate(ilFormat::ftimestamp2dateDB($data["TIMESTAMP14"]), "date"));
01005                         $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
01006                         $this->tpl->setVariable("QUESTION_POINTS", $points);
01007                         $this->tpl->parseCurrentBlock();
01008                         $counter++;
01009                 }
01010                 if ($table["rowcount"] > count($table["rows"]))
01011                 {
01012                         $nextstep = $table["nextrow"] + $table["step"];
01013                         if ($nextstep > $table["rowcount"])
01014                         {
01015                                 $nextstep = $table["rowcount"];
01016                         }
01017                         $counter = 1;
01018                         for ($i = 0; $i < $table["rowcount"]; $i += $table["step"])
01019                         {
01020                                 $this->tpl->setCurrentBlock("pages");
01021                                 if ($table["startrow"] == $i)
01022                                 {
01023                                         $this->tpl->setVariable("PAGE_NUMBER", "<span class=\"inactivepage\">$counter</span>");
01024                                 }
01025                                 else
01026                                 {
01027                                         $this->tpl->setVariable("PAGE_NUMBER", "<a href=\"" . $this->ctrl->getFormAction($this) . "&nextrow=$i" . "\">$counter</a>");
01028                                 }
01029                                 $this->tpl->parseCurrentBlock();
01030                                 $counter++;
01031                         }
01032                         $this->tpl->setCurrentBlock("navigation_bottom");
01033                         $this->tpl->setVariable("TEXT_ITEM", $this->lng->txt("item"));
01034                         $this->tpl->setVariable("TEXT_ITEM_START", $table["startrow"] + 1);
01035                         $end = $table["startrow"] + $table["step"];
01036                         if ($end > $table["rowcount"])
01037                         {
01038                                 $end = $table["rowcount"];
01039                         }
01040                         $this->tpl->setVariable("TEXT_ITEM_END", $end);
01041                         $this->tpl->setVariable("TEXT_OF", strtolower($this->lng->txt("of")));
01042                         $this->tpl->setVariable("TEXT_ITEM_COUNT", $table["rowcount"]);
01043                         $this->tpl->setVariable("TEXT_PREVIOUS", $this->lng->txt("previous"));
01044                         $this->tpl->setVariable("TEXT_NEXT", $this->lng->txt("next"));
01045                         $this->tpl->setVariable("HREF_PREV_ROWS", $this->ctrl->getFormAction($this) . "&prevrow=" . $table["prevrow"]);
01046                         $this->tpl->setVariable("HREF_NEXT_ROWS", $this->ctrl->getFormAction($this) . "&nextrow=" . $table["nextrow"]);
01047                         $this->tpl->parseCurrentBlock();
01048                 }
01049 
01050                 // if there are no questions, display a message
01051                 if ($counter == 0)
01052                 {
01053                         $this->tpl->setCurrentBlock("Emptytable");
01054                         $this->tpl->setVariable("TEXT_EMPTYTABLE", $this->lng->txt("no_questions_available"));
01055                         $this->tpl->parseCurrentBlock();
01056                 }
01057                 else
01058                 {
01059                         if ($rbacsystem->checkAccess('write', $this->ref_id))
01060                         {
01061                                 $counter++;
01062                                 $this->tpl->setCurrentBlock("selectall");
01063                                 $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
01064                                 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
01065                                 $this->tpl->setVariable("SUM_POINTS", $sumPoints);
01066                                 $this->tpl->parseCurrentBlock();
01067                         }
01068                 }
01069 
01070                 if ($rbacsystem->checkAccess('write', $this->ref_id))
01071                 {
01072                         // "create question" form
01073                         $this->tpl->setCurrentBlock("QTypes");
01074                         $types =& $this->object->getQuestionTypes();
01075                         foreach ($types as $data)
01076                         {
01077                                         if ($data["question_type_id"] == $lastquestiontype)
01078                                         {
01079                                                 $this->tpl->setVariable("QUESTION_TYPE_SELECTED", " selected=\"selected\"");
01080                                         }
01081                                         $this->tpl->setVariable("QUESTION_TYPE_ID", $data["type_tag"]);
01082                                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($data["type_tag"]));
01083                                         $this->tpl->parseCurrentBlock();
01084 //                              }
01085                         }
01086                         $this->tpl->setCurrentBlock("CreateQuestion");
01087                         $this->tpl->setVariable("QUESTION_ADD", $this->lng->txt("create"));
01088                         $this->tpl->setVariable("ACTION_QUESTION_ADD", $this->ctrl->getFormAction($this));
01089                         $this->tpl->setVariable("QUESTION_IMPORT", $this->lng->txt("import"));
01090                         $this->tpl->parseCurrentBlock();
01091                 }
01092 
01093                 // define the sort column parameters
01094                 $sortarray = array(
01095                         "title" => (strcmp($sort, "title") == 0) ? $sortorder : "",
01096                         "comment" => (strcmp($sort, "comment") == 0) ? $sortorder : "",
01097                         "type" => (strcmp($sort, "type") == 0) ? $sortorder : "",
01098                         "author" => (strcmp($sort, "author") == 0) ? $sortorder : "",
01099                         "created" => (strcmp($sort, "created") == 0) ? $sortorder : "",
01100                         "updated" => (strcmp($sort, "updated") == 0) ? $sortorder : ""
01101                 );
01102                 foreach ($sortarray as $key => $value) 
01103                 {
01104                         if (strcmp($value, "ASC") == 0) 
01105                         {
01106                                 $sortarray[$key] = "DESC";
01107                         } 
01108                         else 
01109                         {
01110                                 $sortarray[$key] = "ASC";
01111                         }
01112                 }
01113 
01114                 $this->tpl->setCurrentBlock("adm_content");
01115                 // create table header
01116                 $this->ctrl->setParameterByClass(get_class($this), "startrow", $table["startrow"]);
01117                 $this->ctrl->setParameter($this, "sort", "title");
01118                 $this->ctrl->setParameter($this, "sortorder", $sortarray["title"]);
01119                 $this->tpl->setVariable("QUESTION_TITLE", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "\">" . $this->lng->txt("title") . "</a>" . $table["images"]["title"]);
01120                 $this->ctrl->setParameter($this, "sort", "comment");
01121                 $this->ctrl->setParameter($this, "sortorder", $sortarray["comment"]);
01122                 $this->tpl->setVariable("QUESTION_COMMENT", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "\">" . $this->lng->txt("description") . "</a>". $table["images"]["comment"]);
01123                 $this->ctrl->setParameter($this, "sort", "type");
01124                 $this->ctrl->setParameter($this, "sortorder", $sortarray["type"]);
01125                 $this->tpl->setVariable("QUESTION_TYPE", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "\">" . $this->lng->txt("question_type") . "</a>" . $table["images"]["type"]);
01126                 $this->ctrl->setParameter($this, "sort", "author");
01127                 $this->ctrl->setParameter($this, "sortorder", $sortarray["author"]);
01128                 $this->tpl->setVariable("QUESTION_AUTHOR", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "\">" . $this->lng->txt("author") . "</a>" . $table["images"]["author"]);
01129                 $this->ctrl->setParameter($this, "sort", "created");
01130                 $this->ctrl->setParameter($this, "sortorder", $sortarray["created"]);
01131                 $this->tpl->setVariable("QUESTION_CREATED", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "\">" . $this->lng->txt("create_date") . "</a>" . $table["images"]["created"]);
01132                 $this->ctrl->setParameter($this, "sort", "updated");
01133                 $this->ctrl->setParameter($this, "sortorder", $sortarray["updated"]);
01134                 $this->tpl->setVariable("QUESTION_UPDATED", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "\">" . $this->lng->txt("last_update") . "</a>" . $table["images"]["updated"]);
01135                 $this->tpl->setVariable("QUESTION_POINTS", $this->lng->txt("points"));
01136                 $this->ctrl->setParameter($this, "sort", $sort);
01137                 $this->ctrl->setParameter($this, "sortorder", $sortorder);
01138                 $this->tpl->setVariable("ACTION_QUESTION_FORM", $this->ctrl->getFormAction($this));
01139                 $this->tpl->parseCurrentBlock();
01140         }
01141 
01149         function printObject()
01150         {
01151                 $sort = "title";
01152                 if (strlen($_POST["sortorder"]))
01153                 {
01154                         $sort = $_POST["sortorder"];
01155                 }
01156                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_qpl_printview.html", true);
01157                 $sortorder = array(
01158                         "title" => $this->lng->txt("title"),
01159                         "comment" => $this->lng->txt("description"),
01160                         "type" => $this->lng->txt("question_type"),
01161                         "author" => $this->lng->txt("author"),
01162                         "created" => $this->lng->txt("create_date"),
01163                         "updated" => $this->lng->txt("last_update")
01164                 );
01165                 foreach ($sortorder as $value => $text)
01166                 {
01167                         $this->tpl->setCurrentBlock("sortorder");
01168                         $this->tpl->setVariable("VALUE_SORTORDER", $value);
01169                         $this->tpl->setVariable("TEXT_SORTORDER", $text);
01170                         if (strcmp($sort, $value) == 0)
01171                         {
01172                                 $this->tpl->setVariable("SELECTED_SORTORDER", " selected=\"selected\"");
01173                         }
01174                         $this->tpl->parseCurrentBlock();
01175                 }
01176                 $table =& $this->object->getPrintviewQuestions($sort);
01177                 $colors = array("tblrow1top", "tblrow2top");
01178                 $counter = 1;
01179                 include_once "./classes/class.ilFormat.php";
01180                 foreach ($table as $row)
01181                 {
01182                         if ((strcmp($_POST["output"], "detailed") == 0) || (strcmp($_POST["output"], "detailed_printview") == 0))
01183                         {
01184                                 $this->tpl->setCurrentBlock("overview_row_detail");
01185                                 $this->tpl->setVariable("ROW_CLASS", $colors[$counter % 2]);
01186                                 include_once "./assessment/classes/class.assQuestion.php";
01187                                 $question_type_gui = assQuestion::_getQuestionType($row["question_id"]) . "GUI";
01188                                 include_once "./assessment/classes/class.".$question_type_gui.".php";
01189                                 $question_gui = new $question_type_gui();
01190                                 $question_gui->object->loadFromDb($row["question_id"]);
01191                                 if (strcmp($_POST["output"], "detailed") == 0)
01192                                 {
01193                                         $this->tpl->setVariable("PREVIEW", $question_gui->getSolutionOutput(""));
01194                                 }
01195                                 else
01196                                 {
01197                                         $this->tpl->setVariable("PREVIEW", $question_gui->getPreview());
01198                                 }
01199                                 $this->tpl->parseCurrentBlock();
01200                                 $this->tpl->setCurrentBlock("overview_row_detail");
01201                                 $this->tpl->setVariable("ROW_CLASS", $colors[$counter % 2]);
01202                                 $this->tpl->parseCurrentBlock();
01203                         }
01204                         $this->tpl->setCurrentBlock("overview_row");
01205                         $this->tpl->setVariable("ROW_CLASS", $colors[$counter % 2]);
01206                         $this->tpl->setVariable("TEXT_COUNTER", $counter);
01207                         $this->tpl->setVariable("TEXT_TITLE", ilUtil::prepareFormOutput($row["title"]));
01208                         $this->tpl->setVariable("TEXT_DESCRIPTION", ilUtil::prepareFormOutput($row["comment"]));
01209                         $this->tpl->setVariable("TEXT_QUESTIONTYPE", $this->lng->txt($row["type_tag"]));
01210                         $this->tpl->setVariable("TEXT_AUTHOR", $row["author"]);
01211                         $this->tpl->setVariable("TEXT_CREATED", ilFormat::formatDate(ilFormat::ftimestamp2dateDB($row["created"]), "date"));
01212                         $this->tpl->setVariable("TEXT_UPDATED", ilFormat::formatDate(ilFormat::ftimestamp2dateDB($row["TIMESTAMP14"]), "date"));
01213                         $this->tpl->parseCurrentBlock();
01214                         $counter++;
01215                 }
01216                 $this->tpl->setCurrentBlock("overview");
01217                 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
01218                 $this->tpl->setVariable("TEXT_DESCRIPTION", $this->lng->txt("description"));
01219                 $this->tpl->setVariable("TEXT_QUESTIONTYPE", $this->lng->txt("question_type"));
01220                 $this->tpl->setVariable("TEXT_AUTHOR", $this->lng->txt("author"));
01221                 $this->tpl->setVariable("TEXT_CREATED", $this->lng->txt("create_date"));
01222                 $this->tpl->setVariable("TEXT_UPDATED", $this->lng->txt("last_update"));
01223                 $this->tpl->parseCurrentBlock();
01224                 $this->tpl->setCurrentBlock("adm_content");
01225                 if (strcmp($_POST["output"], "detailed") == 0)
01226                 {
01227                         $this->tpl->setVariable("SELECTED_DETAILED", " selected=\"selected\"");
01228                 }
01229                 else if (strcmp($_POST["output"], "detailed_printview") == 0)
01230                 {
01231                         $this->tpl->setVariable("SELECTED_DETAILED_PRINTVIEW", " selected=\"selected\"");
01232                 }
01233                 $this->tpl->setVariable("TEXT_DETAILED", $this->lng->txt("detailed_output_solutions"));
01234                 $this->tpl->setVariable("TEXT_DETAILED_PRINTVIEW", $this->lng->txt("detailed_output_printview"));
01235                 $this->tpl->setVariable("TEXT_OVERVIEW", $this->lng->txt("overview"));
01236                 $this->tpl->setVariable("OUTPUT_MODE", $this->lng->txt("output_mode"));
01237                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01238                 $this->tpl->setVariable("SORT_TEXT", $this->lng->txt("sort_by_this_column"));
01239                 $this->tpl->setVariable("TEXT_SUBMIT", $this->lng->txt("submit"));
01240                 $this->tpl->setVariable("PRINT", $this->lng->txt("print"));
01241                 $this->tpl->parseCurrentBlock();
01242                 $this->tpl->setCurrentBlock("generic_css");
01243                 $this->tpl->setVariable("LOCATION_GENERIC_STYLESHEET", "./assessment/templates/default/test_print.css");
01244                 $this->tpl->setVariable("MEDIA_GENERIC_STYLESHEET", "print");
01245                 $this->tpl->parseCurrentBlock();
01246                 $this->tpl->setVariable("PAGETITLE", " - " . $this->object->getTitle());
01247         }
01248 
01249         function updateObject()
01250         {
01251 //              $this->update = $this->object->updateMetaData();
01252                 $this->update = $this->object->update();
01253                 sendInfo($this->lng->txt("msg_obj_modified"), true);
01254         }
01255 
01259         function pasteObject()
01260         {
01261                 if (array_key_exists("qpl_clipboard", $_SESSION))
01262                 {
01263                         $this->object->pasteFromClipboard();
01264                         sendInfo($this->lng->txt("qpl_paste_success"), true);
01265                 }
01266                 else
01267                 {
01268                         sendInfo($this->lng->txt("qpl_paste_no_objects"), true);
01269                 }
01270                 $this->ctrl->redirect($this, "questions");
01271         }
01272 
01276         function copyObject()
01277         {
01278                 if (count($_POST["q_id"]) > 0)
01279                 {
01280                         foreach ($_POST["q_id"] as $key => $value)
01281                         {
01282                                 $this->object->copyToClipboard($value);
01283                         }
01284                         sendInfo($this->lng->txt("qpl_copy_insert_clipboard"), true);
01285                 }
01286                 else
01287                 {
01288                         sendInfo($this->lng->txt("qpl_copy_select_none"), true);
01289                 }
01290                 $this->ctrl->redirect($this, "questions");
01291         }
01292 
01296         function moveObject()
01297         {
01298                 if (count($_POST["q_id"]) > 0)
01299                 {
01300                         foreach ($_POST["q_id"] as $key => $value)
01301                         {
01302                                 $this->object->moveToClipboard($value);
01303                         }
01304                         sendInfo($this->lng->txt("qpl_move_insert_clipboard"), true);
01305                 }
01306                 else
01307                 {
01308                         sendInfo($this->lng->txt("qpl_move_select_none"), true);
01309                 }
01310                 $this->ctrl->redirect($this, "questions");
01311         }
01312 
01313         /*
01314         * list all export files
01315         */
01316         function exportObject()
01317         {
01318                 global $tree;
01319 
01320                 //add template for view button
01321                 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.il_as_qpl_export.html", TRUE);
01322 
01323                 // create export file button
01324                 $this->tpl->setCurrentBlock("exporttype");
01325                 $this->tpl->setVariable("VALUE_EXPORTTYPE", "xml");
01326                 $this->tpl->setVariable("TEXT_EXPORTTYPE", $this->lng->txt("qpl_export_xml"));
01327                 $this->tpl->parseCurrentBlock();
01328                 $this->tpl->setCurrentBlock("exporttype");
01329                 $this->tpl->setVariable("VALUE_EXPORTTYPE", "xls");
01330                 $this->tpl->setVariable("TEXT_EXPORTTYPE", $this->lng->txt("qpl_export_excel"));
01331                 $this->tpl->parseCurrentBlock();
01332                 $this->tpl->setCurrentBlock("buttons");
01333                 $this->tpl->setVariable("FORMACTION_BUTTONS", $this->ctrl->getFormAction($this));
01334                 $this->tpl->setVariable("BTN_CREATE", $this->lng->txt("create"));
01335                 $this->tpl->parseCurrentBlock();
01336 
01337                 $export_dir = $this->object->getExportDirectory();
01338                 $export_files = $this->object->getExportFiles($export_dir);
01339 
01340                 // create table
01341                 include_once("classes/class.ilTableGUI.php");
01342                 $tbl = new ilTableGUI();
01343 
01344                 // load files templates
01345                 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
01346 
01347                 // load template for table content data
01348                 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.export_file_row.html", true);
01349 
01350                 $num = 0;
01351 
01352                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01353 
01354                 $tbl->setTitle($this->lng->txt("ass_export_files"));
01355 
01356                 $tbl->setHeaderNames(array("", $this->lng->txt("ass_file"),
01357                 $this->lng->txt("ass_size"), $this->lng->txt("date") ));
01358                 $tbl->enabled["sort"] = false;
01359                 $tbl->setColumnWidth(array("1%", "49%", "25%", "25%"));
01360 
01361                 // control
01362                 $tbl->setOrderColumn($_GET["sort_by"]);
01363                 $tbl->setOrderDirection($_GET["sort_order"]);
01364                 $tbl->setLimit($_GET["limit"]);
01365                 $tbl->setOffset($_GET["offset"]);
01366                 $header_params = $this->ctrl->getParameterArray($this, "export");
01367                 $tbl->setHeaderVars(array("", "file", "size", "date"), $header_params);
01368 
01369                 // footer
01370                 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
01371                 //$tbl->disable("footer");
01372 
01373                 $tbl->setMaxCount(count($export_files));
01374                 $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
01375 
01376                 $tbl->render();
01377                 include_once "./classes/class.ilUtil.php";
01378                 if(count($export_files) > 0)
01379                 {
01380                         $this->tpl->setVariable("COLUMN_COUNTS", 4);
01381 
01382                         $i=0;
01383                         foreach($export_files as $exp_file)
01384                         {
01385                                 $this->tpl->setCurrentBlock("tbl_content");
01386                                 $this->tpl->setVariable("TXT_FILENAME", $exp_file);
01387 
01388                                 $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
01389                                 $this->tpl->setVariable("CSS_ROW", $css_row);
01390 
01391                                 $this->tpl->setVariable("TXT_SIZE", filesize($export_dir."/".$exp_file));
01392                                 $this->tpl->setVariable("CHECKBOX_ID", $exp_file);
01393 
01394                                 $file_arr = explode("__", $exp_file);
01395                                 $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s",$file_arr[0]));
01396 
01397                                 $this->tpl->parseCurrentBlock();
01398                         }
01399                         $this->tpl->setCurrentBlock("selectall");
01400                         $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
01401                         $this->tpl->setVariable("CSS_ROW", $css_row);
01402                         $this->tpl->parseCurrentBlock();
01403 
01404                         // delete button
01405                         $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
01406                         $this->tpl->setCurrentBlock("tbl_action_btn");
01407                         $this->tpl->setVariable("BTN_NAME", "confirmDeleteExportFile");
01408                         $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
01409                         $this->tpl->parseCurrentBlock();
01410 
01411                         $this->tpl->setCurrentBlock("tbl_action_btn");
01412                         $this->tpl->setVariable("BTN_NAME", "downloadExportFile");
01413                         $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("download"));
01414                         $this->tpl->parseCurrentBlock();
01415                 } //if is_array
01416                 else
01417                 {
01418                         $this->tpl->setCurrentBlock("notfound");
01419                         $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
01420                         $this->tpl->setVariable("NUM_COLS", 3);
01421                         $this->tpl->parseCurrentBlock();
01422                 }
01423 
01424                 $this->tpl->parseCurrentBlock();
01425         }
01426 
01427 
01431         function createExportFileObject()
01432         {
01433                 global $rbacsystem;
01434                 if ($rbacsystem->checkAccess("write", $this->ref_id))
01435                 {
01436                         include_once("assessment/classes/class.ilQuestionpoolExport.php");
01437                         $question_ids =& $this->object->getAllQuestionIds();
01438                         $qpl_exp = new ilQuestionpoolExport($this->object, $_POST["exporttype"], $question_ids);
01439                         $qpl_exp->buildExportFile();
01440                         $this->ctrl->redirect($this, "export");
01441                 }
01442                 else
01443                 {
01444                         sendInfo("cannot_export_qpl", TRUE);
01445                         $this->ctrl->redirect($this, "export");
01446                 }
01447         }
01448 
01452         function downloadExportFileObject()
01453         {
01454                 if(!isset($_POST["file"]))
01455                 {
01456                         sendInfo($this->lng->txt("no_checkbox"), true);
01457                         $this->ctrl->redirect($this, "export");
01458                 }
01459 
01460                 if (count($_POST["file"]) > 1)
01461                 {
01462                         sendInfo($this->lng->txt("cont_select_max_one_item"), true);
01463                         $this->ctrl->redirect($this, "export");
01464                 }
01465 
01466 
01467                 $export_dir = $this->object->getExportDirectory();
01468                 include_once "./classes/class.ilUtil.php";
01469                 ilUtil::deliverFile($export_dir."/".$_POST["file"][0],
01470                         $_POST["file"][0]);
01471                 $this->ctrl->redirect($this, "export");
01472         }
01473 
01477         function confirmDeleteExportFileObject()
01478         {
01479                 if(!isset($_POST["file"]))
01480                 {
01481                         sendInfo($this->lng->txt("no_checkbox"), true);
01482                         $this->ctrl->redirect($this, "export");
01483                 }
01484 
01485                 // SAVE POST VALUES
01486                 $_SESSION["ilExportFiles"] = $_POST["file"];
01487 
01488                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html", true);
01489 
01490                 sendInfo($this->lng->txt("info_delete_sure"));
01491 
01492                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01493 
01494                 // BEGIN TABLE HEADER
01495                 $this->tpl->setCurrentBlock("table_header");
01496                 $this->tpl->setVariable("TEXT",$this->lng->txt("objects"));
01497                 $this->tpl->parseCurrentBlock();
01498 
01499                 // BEGIN TABLE DATA
01500                 $counter = 0;
01501                 include_once "./classes/class.ilUtil.php";
01502                 foreach($_POST["file"] as $file)
01503                 {
01504                                 $this->tpl->setCurrentBlock("table_row");
01505                                 $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
01506                                 $this->tpl->setVariable("TEXT_CONTENT", $file);
01507                                 $this->tpl->parseCurrentBlock();
01508                 }
01509 
01510                 // cancel/confirm button
01511                 $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
01512                 $buttons = array(
01513                         "deleteExportFile"  => $this->lng->txt("confirm"),
01514                         "cancelDeleteExportFile"  => $this->lng->txt("cancel")
01515                 );
01516                 foreach ($buttons as $name => $value)
01517                 {
01518                         $this->tpl->setCurrentBlock("operation_btn");
01519                         $this->tpl->setVariable("BTN_NAME",$name);
01520                         $this->tpl->setVariable("BTN_VALUE",$value);
01521                         $this->tpl->parseCurrentBlock();
01522                 }
01523         }
01524 
01525 
01529         function cancelDeleteExportFileObject()
01530         {
01531                 session_unregister("ilExportFiles");
01532                 $this->ctrl->redirect($this, "export");
01533         }
01534 
01538         function deleteExportFileObject()
01539         {
01540                 include_once "./classes/class.ilUtil.php";
01541                 $export_dir = $this->object->getExportDirectory();
01542                 foreach($_SESSION["ilExportFiles"] as $file)
01543                 {
01544                         $exp_file = $export_dir."/".$file;
01545                         include_once "./classes/class.ilStr.php";
01546                         $exp_dir = $export_dir."/".ilStr::subStr($file, 0, ilStr::strLen($file) - 4);
01547                         if (@is_file($exp_file))
01548                         {
01549                                 unlink($exp_file);
01550                         }
01551                         if (@is_dir($exp_dir))
01552                         {
01553                                 ilUtil::delDir($exp_dir);
01554                         }
01555                 }
01556                 $this->ctrl->redirect($this, "export");
01557         }
01558 
01562         function &editQuestionForTestObject()
01563         {
01564                 include_once "./assessment/classes/class.assQuestionGUI.php";
01565                 $q_gui =& assQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
01566                 $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
01567         }
01568 
01572         function createObject()
01573         {
01574                 global $rbacsystem;
01575                 $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
01576                 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
01577                 {
01578                         $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
01579                 }
01580                 else
01581                 {
01582                         $this->getTemplateFile("create", $new_type);
01583 
01584                         $qpls =& ilObjQuestionPool::_getAvailableQuestionpools(true);
01585                         if (count($qpls) > 0)
01586                         {
01587                                 foreach ($qpls as $key => $value)
01588                                 {
01589                                         $this->tpl->setCurrentBlock("option_qpl");
01590                                         $this->tpl->setVariable("OPTION_VALUE_QPL", $key);
01591                                         $this->tpl->setVariable("TXT_OPTION_QPL", $value);
01592                                         if ($_POST["qpl"] == $key)
01593                                         {
01594                                                 $this->tpl->setVariable("OPTION_SELECTED_QPL", " selected=\"selected\"");
01595                                         }
01596                                         $this->tpl->parseCurrentBlock();
01597                                 }
01598                         }
01599 
01600                         // fill in saved values in case of error
01601                         $data = array();
01602                         $data["fields"] = array();
01603                         include_once "./classes/class.ilUtil.php";
01604                         $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
01605                         $data["fields"]["desc"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["desc"]);
01606 
01607                         foreach ($data["fields"] as $key => $val)
01608                         {
01609                                 $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
01610                                 $this->tpl->setVariable(strtoupper($key), $val);
01611 
01612                                 if ($this->prepare_output)
01613                                 {
01614                                         $this->tpl->parseCurrentBlock();
01615                                 }
01616                         }
01617 
01618                         $this->ctrl->setParameter($this, "new_type", $this->type);
01619                         $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01620                         //$this->tpl->setVariable("FORMACTION", $this->getFormAction("save","adm_object.php?cmd=gateway&ref_id=".
01621                         //      $_GET["ref_id"]."&new_type=".$new_type));
01622                         $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
01623                         $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
01624                         $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
01625                         $this->tpl->setVariable("CMD_SUBMIT", "save");
01626                         $this->tpl->setVariable("TARGET", ' target="'.
01627                                 ilFrameTargetInfo::_getFrame("MainContent").'" ');
01628                         $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
01629 
01630                         $this->tpl->setVariable("TXT_IMPORT_QPL", $this->lng->txt("import_qpl"));
01631                         $this->tpl->setVariable("TXT_QPL_FILE", $this->lng->txt("qpl_upload_file"));
01632                         $this->tpl->setVariable("NEW_TYPE", $this->type);
01633                         $this->tpl->setVariable("TXT_IMPORT", $this->lng->txt("import"));
01634 
01635                         $this->tpl->setVariable("TXT_DUPLICATE_QPL", $this->lng->txt("duplicate_qpl"));
01636                         $this->tpl->setVariable("TXT_SELECT_QPL", $this->lng->txt("obj_qpl"));
01637                         $this->tpl->setVariable("OPTION_SELECT_QPL", $this->lng->txt("select_qpl_option"));
01638                         $this->tpl->setVariable("TXT_DUPLICATE", $this->lng->txt("duplicate"));
01639 
01640                         $this->tpl->setVariable("TYPE_IMG", ilUtil::getImagePath('icon_qpl.gif'));
01641                         $this->tpl->setVariable("ALT_IMG",$this->lng->txt("obj_qpl"));
01642                         $this->tpl->setVariable("TYPE_IMG2", ilUtil::getImagePath('icon_qpl.gif'));
01643                         $this->tpl->setVariable("ALT_IMG2",$this->lng->txt("obj_qpl"));
01644                         $this->tpl->setVariable("TYPE_IMG3", ilUtil::getImagePath('icon_qpl.gif'));
01645                         $this->tpl->setVariable("ALT_IMG3",$this->lng->txt("obj_qpl"));
01646 
01647                         $this->tpl->parseCurrentBlock();
01648                 }
01649         }
01650 
01654         function cloneAllObject()
01655         {
01656                 if ($_POST["qpl"] < 1)
01657                 {
01658                         sendInfo($this->lng->txt("tst_select_qpls"));
01659                         $this->createObject();
01660                         return;
01661                 }
01662                 $ref_id = ilObjQuestionPool::_clone($_POST["qpl"]);
01663                 sendInfo($this->lng->txt("object_duplicated"),true);
01664                 ilUtil::redirect("ilias.php?ref_id=$ref_id&baseClass=ilObjQuestionPoolGUI");
01665         }
01666 
01670         function importFileObject()
01671         {
01672                 if (strcmp($_FILES["xmldoc"]["tmp_name"], "") == 0)
01673                 {
01674                         sendInfo($this->lng->txt("qpl_select_file_for_import"));
01675                         $this->createObject();
01676                         return;
01677                 }
01678                 $this->uploadQplObject();
01679         }
01680 
01681         function addLocatorItems()
01682         {
01683                 global $ilLocator;
01684                 switch ($this->ctrl->getCmd())
01685                 {
01686                         case "create":
01687                         case "importFile":
01688                         case "cancel":
01689                                 break;
01690                         default:
01691                                 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""));
01692                                 break;
01693                 }
01694                 if ($_GET["q_id"] > 0)
01695                 {
01696                         include_once "./assessment/classes/class.assQuestionGUI.php";
01697                         $q_gui =& assQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
01698                         $q_gui->object->setObjId($this->object->getId());
01699                         if ($_GET["q_id"] > 0)
01700                         {
01701                                 $ilLocator->addItem($q_gui->object->getTitle(), $this->ctrl->getLinkTargetByClass(get_class($q_gui), "editQuestion"));
01702                         }
01703                 }
01704         }
01705 
01709         function setTitleAndDescription()
01710         {
01711                 if ($_GET["q_id"] > 0)
01712                 {
01713                         include_once "./assessment/classes/class.assQuestionGUI.php";
01714                         $q_gui =& assQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
01715                         $q_gui->object->setObjId($this->object->getId());
01716                         $title = $q_gui->object->getTitle();
01717                         if (strcmp($this->ctrl->getCmd(), "assessment") == 0)
01718                         {
01719                                 $title .= " - " . $this->lng->txt("statistics");
01720                         }
01721                         $this->tpl->setTitle($title);
01722                         $this->tpl->setDescription($q_gui->object->getComment());
01723                         $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_".$this->object->getType()."_b.gif"), $this->lng->txt("obj_qpl"));
01724                 }
01725                 else
01726                 {
01727                         $this->tpl->setTitle($this->object->getTitle());
01728                         $this->tpl->setDescription($this->object->getLongDescription());
01729                         $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_".$this->object->getType()."_b.gif"), $this->lng->txt("obj_qpl"));
01730                 }
01731         }
01732 
01733         function getEmbeddedTabs(&$tabs_gui)
01734         {
01735                 global $rbacsystem;
01736                 $this->ctrl->setParameterByClass("ilpageobjectgui", "q_id", $_GET["q_id"]);
01737                 include_once "./assessment/classes/class.assQuestion.php";
01738                 $q_type = assQuestion::getQuestionTypeFromDb($_GET["q_id"]);
01739 
01740                 if (strlen($q_type))
01741                 {
01742                         $classname = $q_type . "GUI";
01743                         $this->ctrl->setParameterByClass(strtolower($classname), "sel_question_types", $q_type);
01744                         $this->ctrl->setParameterByClass(strtolower($classname), "q_id", $_GET["q_id"]);
01745                 }
01746 
01747                 if ($_GET["q_id"])
01748                 {
01749                         if ($rbacsystem->checkAccess('write', $this->ref_id))
01750                         {
01751                                 // edit page
01752                                 $tabs_gui->addTarget("edit_content",
01753                                                                                                  $this->ctrl->getLinkTargetByClass("ilPageObjectGUI", "view"),
01754                                                                                                  array("view", "insert", "exec_pg"),
01755                                                                                                  "", "", $force_active);
01756                         }
01757 
01758                         // edit page
01759                         $tabs_gui->addTarget("preview",
01760                                                                                          $this->ctrl->getLinkTargetByClass("ilPageObjectGUI", "preview"),
01761                                                                                          array("preview"),
01762                                                                                          "ilPageObjectGUI", "", $force_active);
01763                 }
01764 
01765                 $force_active = false;
01766                 $commands = $_POST["cmd"];
01767                 if (is_array($commands))
01768                 {
01769                         foreach ($commands as $key => $value)
01770                         {
01771                                 if (preg_match("/^delete_.*/", $key, $matches) ||
01772                                         preg_match("/^addSelectGap_.*/", $key, $matches) ||
01773                                         preg_match("/^addTextGap_.*/", $key, $matches) ||
01774                                         preg_match("/^deleteImage_.*/", $key, $matches) ||
01775                                         preg_match("/^upload_.*/", $key, $matches) ||
01776                                         preg_match("/^addSuggestedSolution_.*/", $key, $matches)
01777                                         )
01778                                 {
01779                                         $force_active = true;
01780                                 }
01781                         }
01782                 }
01783                 if (array_key_exists("imagemap_x", $_POST))
01784                 {
01785                         $force_active = true;
01786                 }
01787                 if ($rbacsystem->checkAccess('write', $this->ref_id))
01788                 {
01789                         $url = "";
01790                         if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname, "editQuestion");
01791                         // edit question properties
01792                         $tabs_gui->addTarget("edit_properties",
01793                                                                                          $url,
01794                                                                                          array("questions", "filter", "resetFilter", "createQuestion",
01795                                                                                                          "importQuestions", "deleteQuestions", "duplicate",
01796                                                                                                          "view", "preview", "editQuestion", "exec_pg",
01797                                                                                                          "addItem", "upload", "save", "cancel", "addSuggestedSolution",
01798                                                                                                          "cancelExplorer", "linkChilds", "removeSuggestedSolution",
01799                                                                                                          "add", "addYesNo", "addTrueFalse", "createGaps", "saveEdit",
01800                                                                                                          "setMediaMode", "uploadingImage", "uploadingImagemap", "addArea",
01801                                                                                                          "deletearea", "saveShape", "back", "addPair", "uploadingJavaapplet",
01802                                                                                                          "addParameter", "addGIT", "addST", "addPG", "delete",
01803                                                                                                          "editMode", "deleteAnswer", "deleteImage"),
01804                                                                                          $classname, "", $force_active);
01805                 }
01806 
01807                 // Assessment of questions sub menu entry
01808                 if ($_GET["q_id"])
01809                 {
01810                         $tabs_gui->addTarget("statistics",
01811                                                                                          $this->ctrl->getLinkTargetByClass($classname, "assessment"),
01812                                                                                          array("assessment"),
01813                                                                                          $classname, "");
01814                 }
01815                 if (($_GET["calling_test"] > 0) || ($_GET["test_ref_id"] > 0))
01816                 {
01817                         $ref_id = $_GET["calling_test"];
01818                         if (strlen($ref_id) == 0) $ref_id = $_GET["test_ref_id"];
01819                         $tabs_gui->setBackTarget($this->lng->txt("backtocallingtest"), "ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
01820                 }
01821                 else
01822                 {
01823                         $tabs_gui->setBackTarget($this->lng->txt("qpl"), $this->ctrl->getLinkTarget($this, "questions"));
01824                 }
01825         }
01826 
01832         function getTabs(&$tabs_gui)
01833         {
01834                 $next_class = $this->ctrl->getNextClass($this);
01835                 switch ($next_class)
01836                 {
01837                         case "":
01838                         case "ilpermissiongui":
01839                         case "ilmdeditorgui":
01840                                 break;
01841                         default:
01842                                 return $this->getEmbeddedTabs($tabs_gui);
01843                                 break;
01844                 }
01845         // properties
01846                 $tabs_gui->addTarget("properties",
01847                          $this->ctrl->getLinkTarget($this,'properties'),
01848                          "properties", "",
01849                          "");
01850 
01851                 // questions
01852                 $force_active = false;
01853                 $commands = $_POST["cmd"];
01854                 if (is_array($commands))
01855                 {
01856                         foreach ($commands as $key => $value)
01857                         {
01858                                 if (preg_match("/^delete_.*/", $key, $matches) ||
01859                                         preg_match("/^addSelectGap_.*/", $key, $matches) ||
01860                                         preg_match("/^addTextGap_.*/", $key, $matches) ||
01861                                         preg_match("/^deleteImage_.*/", $key, $matches) ||
01862                                         preg_match("/^upload_.*/", $key, $matches) ||
01863                                         preg_match("/^addSuggestedSolution_.*/", $key, $matches)
01864                                         )
01865                                 {
01866                                         $force_active = true;
01867                                 }
01868                         }
01869                 }
01870                 if (array_key_exists("imagemap_x", $_POST))
01871                 {
01872                         $force_active = true;
01873                 }
01874                 if (!$force_active)
01875                 {
01876                         $force_active = ((strtolower($this->ctrl->getCmdClass()) == strtolower(get_class($this)) || strlen($this->ctrl->getCmdClass()) == 0) &&
01877                                 $this->ctrl->getCmd() == "")
01878                                 ? true
01879                                 : false;
01880                 }
01881                 $tabs_gui->addTarget("assQuestions",
01882                          $this->ctrl->getLinkTarget($this, "questions"),
01883                          array("questions", "filter", "resetFilter", "createQuestion",
01884                                 "importQuestions", "deleteQuestions", "duplicate",
01885                                 "view", "preview", "editQuestion", "exec_pg",
01886                                 "addItem", "upload", "save", "cancel", "addSuggestedSolution",
01887                                 "cancelExplorer", "linkChilds", "removeSuggestedSolution",
01888                                 "add", "addYesNo", "addTrueFalse", "createGaps", "saveEdit",
01889                                 "setMediaMode", "uploadingImage", "uploadingImagemap", "addArea",
01890                                 "deletearea", "saveShape", "back", "addPair", "uploadingJavaapplet",
01891                                 "addParameter", "assessment", "addGIT", "addST", "addPG", "delete",
01892                                 "toggleGraphicalAnswers", "deleteAnswer", "deleteImage", "removeJavaapplet"),
01893                          "", "", $force_active);
01894 
01895                 // meta data
01896                 $tabs_gui->addTarget("meta_data",
01897                          $this->ctrl->getLinkTargetByClass('ilmdeditorgui','listSection'),
01898                          "", "ilmdeditorgui");
01899 
01900                 // print view
01901                 $tabs_gui->addTarget("print_view",
01902                          $this->ctrl->getLinkTarget($this,'print'),
01903                          array("print"),
01904                          "", "");
01905 
01906                 // export
01907                 $tabs_gui->addTarget("export",
01908                          $this->ctrl->getLinkTarget($this,'export'),
01909                          array("export", "createExportFile", "confirmDeleteExportFile", "downloadExportFile"),
01910                          "", "");
01911 
01912                 // permissions
01913                 $tabs_gui->addTarget("perm_settings",
01914                         $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
01915         }
01916 
01917 } // END class.ilObjQuestionPoolGUI
01918 ?>

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