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

assessment/classes/class.ilObjQuestionPoolGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 
00041 require_once "./classes/class.ilObjectGUI.php";
00042 require_once "./assessment/classes/class.assQuestionGUI.php";
00043 require_once "./assessment/classes/class.ilObjQuestionPool.php";
00044 require_once "./classes/class.ilMetaDataGUI.php";
00045 
00046 class ilObjQuestionPoolGUI extends ilObjectGUI
00047 {
00052         function ilObjQuestionPoolGUI($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
00053         {
00054         global $lng, $ilCtrl;
00055 
00056                 $this->type = "qpl";
00057                 $lng->loadLanguageModule("assessment");
00058                 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference, false);
00059                 $this->ctrl =& $ilCtrl;
00060                 $this->ctrl->saveParameter($this, array("ref_id", "test_ref_id", "calling_test"));
00061 
00062                 if (!defined("ILIAS_MODULE"))
00063                 {
00064                         $this->setTabTargetScript("adm_object.php");
00065                 }
00066                 else
00067                 {
00068                         $this->setTabTargetScript("questionpool.php");
00069                 }
00070                 if ($a_prepare_output)
00071                 {
00072                         include_once("classes/class.ilObjStyleSheet.php");
00073                         $this->prepareOutput();
00074                         $this->tpl->setCurrentBlock("ContentStyle");
00075                         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00076                                 ilObjStyleSheet::getContentStylePath(0));
00077                         $this->tpl->parseCurrentBlock();
00078 
00079                         // syntax style
00080                         $this->tpl->setCurrentBlock("SyntaxStyle");
00081                         $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
00082                                 ilObjStyleSheet::getSyntaxStylePath());
00083                         $this->tpl->parseCurrentBlock();
00084 
00085                 }
00086 //echo "<br>ilObjQuestionPool_End of constructor.";
00087         }
00088 
00092         function &executeCommand()
00093         {
00094                 $cmd = $this->ctrl->getCmd("questions");
00095                 $next_class = $this->ctrl->getNextClass($this);
00096                 $this->ctrl->setReturn($this, "questions");
00097                 if ($_GET["q_id"] < 1)
00098                 {
00099                         $q_type = ($_POST["sel_question_types"] != "")
00100                                 ? $_POST["sel_question_types"]
00101                                 : $_GET["sel_question_types"];
00102                 }
00103 
00104                 if ($cmd != "createQuestion" && $cmd != "createQuestionForTest"
00105                         && $next_class != "ilpageobjectgui")
00106                 {
00107                         if (($_GET["test_ref_id"] != "") or ($_GET["calling_test"]))
00108                         {
00109                                 $ref_id = $_GET["test_ref_id"];
00110                                 if (!$ref_id)
00111                                 {
00112                                         $ref_id = $_GET["calling_test"];
00113                                 }
00114                                 include_once "./classes/class.ilTabsGUI.php";
00115                                 $tabs_gui =& new ilTabsGUI();
00116 
00117                                 $tabs_gui->addTarget("back",
00118                                         "test.php?ref_id=$ref_id&cmd=questions", "", "");
00119 
00120                                 // output tabs
00121                                 $this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00122                         }
00123                 }
00124 
00125 //echo "<br>nextclass:$next_class:cmd:$cmd:";
00126                 switch($next_class)
00127                 {
00128                         case "ilpageobjectgui":
00129 
00130                                 $q_gui =& ASS_QuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
00131                                 $q_gui->object->setObjId($this->object->getId());
00132                                 $question =& $q_gui->object;
00133                                 $this->tpl->setVariable("HEADER", $question->getTitle());
00134                                 $this->ctrl->saveParameter($this, "q_id");
00135                                 $count = $question->isInUse();
00136                                 if (($count) && strcmp($this->ctrl->getCmd(), "view") == 0)
00137                                 {
00138                                         global $rbacsystem;
00139                                         if ($rbacsystem->checkAccess("write", $this->ref_id))
00140                                         {
00141                                                 sendInfo(sprintf($this->lng->txt("qpl_question_is_in_use"), $count));
00142                                         }
00143                                 }
00144                                 include_once("content/classes/Pages/class.ilPageObjectGUI.php");
00145                                 $this->lng->loadLanguageModule("content");
00146                                 $this->setQuestionTabs();
00147                                 //$this->setPageEditorTabs();
00148                                 $this->ctrl->setReturnByClass("ilPageObjectGUI", "view");
00149                                 $this->ctrl->setReturn($this, "questions");
00150 
00151                                 $page =& new ilPageObject("qpl", $_GET["q_id"]);
00152                                 $page_gui =& new ilPageObjectGUI($page);
00153                                 $page_gui->setQuestionXML($question->to_xml(false, false, true));
00154                                 $page_gui->setTemplateTargetVar("ADM_CONTENT");
00155                                 $page_gui->setOutputMode("edit");
00156                                 $page_gui->setHeader($question->getTitle());
00157                                 $page_gui->setFileDownloadLink("questionpool.php?cmd=downloadFile".
00158                                         "&amp;ref_id=".$_GET["ref_id"]);
00159                                 $page_gui->setFullscreenLink("questionpool.php?cmd=fullscreen".
00160                                         "&amp;ref_id=".$_GET["ref_id"]);
00161                                 $page_gui->setSourcecodeDownloadScript("questionpool.php?ref_id=".$_GET["ref_id"]);
00162                                 /*
00163                                 $page_gui->setTabs(array(array("cont_all_definitions", "listDefinitions"),
00164                                                 array("edit", "view"),
00165                                                 array("cont_preview", "preview"),
00166                                                 array("meta_data", "editDefinitionMetaData")
00167                                                 ));*/
00168                                 $page_gui->setPresentationTitle($question->getTitle());
00169                                 //$page_gui->executeCommand();
00170 
00171                                 $ret =& $this->ctrl->forwardCommand($page_gui);
00172 
00173                                 break;
00174 
00175 
00176                         case "ass_multiplechoicegui":
00177                         case "ass_clozetestgui":
00178                         case "ass_orderingquestiongui":
00179                         case "ass_matchingquestiongui":
00180                         case "ass_imagemapquestiongui":
00181                         case "ass_javaappletgui":
00182                         case "ass_textquestiongui":
00183                                 $this->setQuestionTabs();
00184                                 $this->ctrl->setReturn($this, "questions");
00185                                 $q_gui =& ASS_QuestionGUI::_getQuestionGUI($q_type, $_GET["q_id"]);
00186                                 $q_gui->object->setObjId($this->object->getId());
00187                                 $count = $q_gui->object->isInUse();
00188                                 if (($count) && strcmp($this->ctrl->getCmd(), "assessment") != 0)
00189                                 {
00190                                         global $rbacsystem;
00191                                         if ($rbacsystem->checkAccess("write", $this->ref_id))
00192                                         {
00193                                                 sendInfo(sprintf($this->lng->txt("qpl_question_is_in_use"), $count));
00194                                         }
00195                                 }
00196                                 $ret =& $this->ctrl->forwardCommand($q_gui);
00197                                 break;
00198 
00199                         default:
00200 //                              echo "setAdminTabs<br>";
00201                                 if ($cmd != "createQuestion" && $cmd != "createQuestionForTest" && $cmd != "editQuestionForTest")
00202                                 {
00203                                         $this->setAdminTabs();
00204                                 }
00205                                 $cmd.= "Object";
00206                                 $ret =& $this->$cmd();
00207                                 break;
00208                 }
00209         }
00210 
00214         function downloadFileObject()
00215         {
00216                 $file = explode("_", $_GET["file_id"]);
00217                 require_once("classes/class.ilObjFile.php");
00218                 $fileObj =& new ilObjFile($file[count($file) - 1], false);
00219                 $fileObj->sendFile();
00220                 exit;
00221         }
00222         
00226         function fullscreenObject()
00227         {
00228                 $page =& new ilPageObject("qpl", $_GET["pg_id"]);
00229                 include_once("content/classes/Pages/class.ilPageObjectGUI.php");
00230                 $page_gui =& new ilPageObjectGUI($page);
00231                 $page_gui->showMediaFullscreen();
00232                 
00233         }
00234 
00235 
00239         function filterObject()
00240         {
00241                 $this->questionsObject();
00242         }
00243 
00247         function resetFilterObject()
00248         {
00249                 $_POST["filter_text"] = "";
00250                 $_POST["sel_filter_type"] = "";
00251                 $this->questionsObject();
00252         }
00253 
00257         function download_paragraphObject()
00258         {
00259                 require_once("content/classes/Pages/class.ilPageObject.php");
00260                 $pg_obj =& new ilPageObject("qpl", $_GET["pg_id"]);
00261                 $pg_obj->send_paragraph ($_GET["par_id"], $_GET["downloadtitle"]);
00262                 exit;
00263         }
00264 
00268         function uploadQplObject($redirect = true)
00269         {
00270                 if ($_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK)
00271                 {
00272                         sendInfo($this->lng->txt("error_upload"));
00273                         $this->importObject();
00274                         return;
00275                 }
00276                 // create new questionpool object
00277                 $newObj = new ilObjQuestionpool();
00278                 // set type of questionpool object
00279                 $newObj->setType($_GET["new_type"]);
00280                 // set title of questionpool object to "dummy"
00281                 $newObj->setTitle("dummy");
00282                 // create the questionpool class in the ILIAS database (object_data table)
00283                 $newObj->create(true);
00284                 // create a reference for the questionpool object in the ILIAS database (object_reference table)
00285                 $newObj->createReference();
00286                 // put the questionpool object in the administration tree
00287                 $newObj->putInTree($_GET["ref_id"]);
00288                 // get default permissions and set the permissions for the questionpool object
00289                 $newObj->setPermissions($_GET["ref_id"]);
00290                 // notify the questionpool object and all its parent objects that a "new" object was created
00291                 $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
00292 
00293                 // create import directory
00294                 $newObj->createImportDirectory();
00295 
00296                 // copy uploaded file to import directory
00297                 $file = pathinfo($_FILES["xmldoc"]["name"]);
00298                 $full_path = $newObj->getImportDirectory()."/".$_FILES["xmldoc"]["name"];
00299                 ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"], $_FILES["xmldoc"]["name"], $full_path);
00300                 //move_uploaded_file($_FILES["xmldoc"]["tmp_name"], $full_path);
00301 
00302                 // unzip file
00303                 ilUtil::unzip($full_path);
00304 
00305                 // determine filenames of xml files
00306                 $subdir = basename($file["basename"],".".$file["extension"]);
00307                 $xml_file = $newObj->getImportDirectory()."/".$subdir."/".$subdir.".xml";
00308                 $qti_file = $newObj->getImportDirectory()."/".$subdir."/". str_replace("qpl", "qti", $subdir).".xml";
00309                 
00310                 // import qti data
00311                 $qtiresult = $newObj->importObject($qti_file);
00312                 // import page data
00313                 include_once ("content/classes/class.ilContObjParser.php");
00314                 $contParser = new ilContObjParser($newObj, $xml_file, $subdir);
00315                 $contParser->setQuestionMapping($newObj->getImportMapping());
00316                 $contParser->startParsing();
00317 
00318                 /* update title and description in object data */
00319                 if (is_object($newObj->meta_data))
00320                 {
00321                         // read the object metadata from the nested set tables
00322                         //$meta_data =& new ilMetaData($newObj->getType(), $newObj->getId());
00323                         //$newObj->meta_data = $meta_data;
00324                         //$newObj->setTitle($newObj->meta_data->getTitle());
00325                         //$newObj->setDescription($newObj->meta_data->getDescription());
00326                         ilObject::_writeTitle($newObj->getID(), $newObj->getTitle());
00327                         ilObject::_writeDescription($newObj->getID(), $newObj->getDescription());
00328                 }
00329 
00330                 // delete import directory
00331                 ilUtil::delDir($newObj->getImportDirectory());
00332                 
00333                 if ($redirect)
00334                 {
00335                         ilUtil::redirect("adm_object.php?".$this->link_params);
00336                 }
00337         }
00338         
00342         function uploadObject()
00343         {
00344                 // check if file was uploaded
00345                 $source = $_FILES["xmldoc"]["tmp_name"];
00346                 $error = 0;
00347                 if (($source == 'none') || (!$source) || $_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK)
00348                 {
00349 //                      $this->ilias->raiseError("No file selected!",$this->ilias->error_obj->MESSAGE);
00350                         $error = 1;
00351                 }
00352                 // check correct file type
00353                 if (strcmp($_FILES["xmldoc"]["type"], "text/xml") == 0)
00354                 {
00355                         if (!$error)
00356                         {
00357                                 $this->object->importObject($source);
00358                         }
00359                 }
00360                 else
00361                 {
00362                         // create import directory
00363                         $this->object->createImportDirectory();
00364         
00365                         // copy uploaded file to import directory
00366                         $file = pathinfo($_FILES["xmldoc"]["name"]);
00367                         $full_path = $this->object->getImportDirectory()."/".$_FILES["xmldoc"]["name"];
00368                         ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"], $_FILES["xmldoc"]["name"], $full_path);
00369                         //move_uploaded_file($_FILES["xmldoc"]["tmp_name"], $full_path);
00370         
00371                         // unzip file
00372                         ilUtil::unzip($full_path);
00373         
00374                         // determine filename of xml file
00375                         $subdir = basename($file["basename"],".".$file["extension"]);
00376                         $xml_file = $this->object->getImportDirectory()."/".$subdir."/".$subdir.".xml";
00377                         $qti_file = $this->object->getImportDirectory()."/".$subdir."/". str_replace("qpl", "qti", $subdir).".xml";
00378                         // import qti data
00379                         $qtiresult = $this->object->importObject($qti_file);
00380                         // import page data
00381                         include_once ("content/classes/class.ilContObjParser.php");
00382                         $contParser = new ilContObjParser($this->object, $xml_file, $subdir);
00383                         $contParser->setQuestionMapping($this->object->getImportMapping());
00384                         $contParser->startParsing();
00385                 }
00386                 
00387                 $this->questionsObject();
00388         }
00389         
00393                 function importQuestionsObject()
00394         {
00395                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_import_question.html", true);
00396                 $this->tpl->setCurrentBlock("adm_content");
00397                 $this->tpl->setVariable("TEXT_IMPORT_QUESTION", $this->lng->txt("import_question"));
00398                 $this->tpl->setVariable("TEXT_SELECT_FILE", $this->lng->txt("select_file"));
00399                 $this->tpl->setVariable("TEXT_UPLOAD", $this->lng->txt("upload"));
00400                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00401                 $this->tpl->parseCurrentBlock();
00402         }
00403 
00409         function importObject()
00410         {
00411                 $this->getTemplateFile("import", "qpl");
00412                 $this->tpl->setVariable("FORMACTION", "adm_object.php?&ref_id=".$_GET["ref_id"]."&cmd=gateway&new_type=".$this->type);
00413                 $this->tpl->setVariable("BTN_NAME", "uploadQpl");
00414                 $this->tpl->setVariable("TXT_UPLOAD", $this->lng->txt("upload"));
00415                 $this->tpl->setVariable("TXT_IMPORT_QPL", $this->lng->txt("import_qpl"));
00416                 $this->tpl->setVariable("TXT_SELECT_MODE", $this->lng->txt("select_mode"));
00417                 $this->tpl->setVariable("TXT_SELECT_FILE", $this->lng->txt("select_file"));
00418         }
00419         
00423         function &createQuestionObject()
00424         {
00425 //echo "<br>create--".$_POST["sel_question_types"];
00426                 $q_gui =& ASS_QuestionGUI::_getQuestionGUI($_POST["sel_question_types"]);
00427                 $q_gui->object->setObjId($this->object->getId());
00428                 $this->ctrl->setCmdClass(get_class($q_gui));
00429                 $this->ctrl->setCmd("editQuestion");
00430 
00431                 $ret =& $this->executeCommand();
00432                 return $ret;
00433         }
00434 
00438         function &createQuestionForTestObject()
00439         {
00440 //echo "<br>create--".$_GET["new_type"];
00441                 $q_gui =& ASS_QuestionGUI::_getQuestionGUI($_GET["sel_question_types"]);
00442                 $q_gui->object->setObjId($this->object->getId());
00443                 $this->ctrl->setCmdClass(get_class($q_gui));
00444                 $this->ctrl->setCmd("editQuestion");
00445 
00446                 $ret =& $this->executeCommand();
00447                 return $ret;
00448         }
00449 
00454         function saveObject()
00455         {
00456                 global $rbacadmin;
00457 
00458                 // create and insert forum in objecttree
00459                 $newObj = parent::saveObject();
00460 
00461                 // setup rolefolder & default local roles
00462                 //$roles = $newObj->initDefaultRoles();
00463 
00464                 // ...finally assign role to creator of object
00465                 //$rbacadmin->assignUser($roles[0], $newObj->getOwner(), "y");
00466 
00467                 // put here object specific stuff
00468 
00469                 // always send a message
00470                 sendInfo($this->lng->txt("object_added"),true);
00471 
00472                 $returnlocation = "questionpool.php";
00473                 if (!defined("ILIAS_MODULE"))
00474                 {
00475                         $returnlocation = "adm_object.php";
00476                 }
00477                 ilUtil::redirect($this->getReturnLocation("save","$returnlocation?".$this->link_params));
00478                 exit();
00479         }
00480 
00484         function assessmentObject()
00485         {
00486                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.il_as_qpl_content.html", true);
00487                 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00488 
00489                 // catch feedback message
00490                 sendInfo();
00491 
00492                 $this->setLocator();
00493 
00494                 $title = $this->lng->txt("qpl_assessment_of_questions");
00495                 if (!empty($title))
00496                 {
00497                         $this->tpl->setVariable("HEADER", $title);
00498                 }
00499                 $question =& $this->object->createQuestion("", $_GET["q_id"]);
00500                 $total_of_answers = $question->getTotalAnswers();
00501                 $counter = 0;
00502                 $color_class = array("tblrow1", "tblrow2");
00503                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_qpl_assessment_of_questions.html", true);
00504                 if (!$total_of_answers)
00505                 {
00506                         $this->tpl->setCurrentBlock("emptyrow");
00507                         $this->tpl->setVariable("TXT_NO_ASSESSMENT", $this->lng->txt("qpl_assessment_no_assessment_of_questions"));
00508                         $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00509                         $this->tpl->parseCurrentBlock();
00510                 }
00511                 else
00512                 {
00513                         $this->tpl->setCurrentBlock("row");
00514                         $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("qpl_assessment_total_of_answers"));
00515                         $this->tpl->setVariable("TXT_VALUE", $total_of_answers);
00516                         $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00517                         $counter++;
00518                         $this->tpl->parseCurrentBlock();
00519                         $this->tpl->setCurrentBlock("row");
00520                         $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("qpl_assessment_total_of_right_answers"));
00521                         $this->tpl->setVariable("TXT_VALUE", sprintf("%2.2f", ASS_Question::_getTotalRightAnswers($_GET["edit"]) * 100.0) . " %");
00522                         $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00523                         $this->tpl->parseCurrentBlock();
00524                 }
00525                 $this->tpl->setCurrentBlock("adm_content");
00526                 $this->tpl->setVariable("TXT_QUESTION_TITLE", $question->object->getTitle());
00527                 $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("result"));
00528                 $this->tpl->setVariable("TXT_VALUE", $this->lng->txt("value"));
00529                 $this->tpl->parseCurrentBlock();
00530         }
00531 
00532         function getAddParameter()
00533         {
00534                 return "?ref_id=" . $_GET["ref_id"] . "&cmd=" . $_GET["cmd"];
00535         }
00536 
00537         function questionObject()
00538         {
00539 //echo "<br>ilObjQuestionPoolGUI->questionObject()";
00540                 $type = $_GET["sel_question_types"];
00541                 $this->editQuestionForm($type);
00542                 //$this->set_question_form($type, $_GET["edit"]);
00543         }
00544 
00548         function deleteQuestionsObject()
00549         {
00550 //echo "<br>ilObjQuestionPoolGUI->deleteQuestions()";
00551                 // duplicate button was pressed
00552                 if (count($_POST["q_id"]) < 1)
00553                 {
00554                         sendInfo($this->lng->txt("qpl_delete_select_none"), true);
00555                         $this->ctrl->redirect($this, "questions");
00556                 }
00557 
00558                 $checked_questions = $_POST["q_id"];
00559                 $_SESSION["ass_q_id"] = $_POST["q_id"];
00560                 sendInfo();
00561                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_qpl_confirm_delete_questions.html", true);
00562 
00563                 // buidling SQL statements is not allowed in GUI classes!
00564                 $whereclause = join($checked_questions, " OR qpl_questions.question_id = ");
00565                 $whereclause = " AND (qpl_questions.question_id = " . $whereclause . ")";
00566                 $query = "SELECT qpl_questions.*, qpl_question_type.type_tag FROM qpl_questions, qpl_question_type WHERE qpl_questions.question_type_fi = qpl_question_type.question_type_id$whereclause ORDER BY qpl_questions.title";
00567                 $query_result = $this->ilias->db->query($query);
00568                 $colors = array("tblrow1", "tblrow2");
00569                 $counter = 0;
00570                 $img_locked = "<img src=\"" . ilUtil::getImagePath("locked.gif", true) . "\" alt=\"" . $this->lng->txt("locked") . "\" title=\"" . $this->lng->txt("locked") . "\" border=\"0\" />";
00571                 if ($query_result->numRows() > 0)
00572                 {
00573                         while ($data = $query_result->fetchRow(DB_FETCHMODE_OBJECT))
00574                         {
00575                                 if (in_array($data->question_id, $checked_questions))
00576                                 {
00577                                         $this->tpl->setCurrentBlock("row");
00578                                         $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
00579                                         if ($this->object->isInUse($data->question_id))
00580                                         {
00581                                                 $this->tpl->setVariable("TXT_LOCKED", $img_locked);
00582                                         }
00583                                         $this->tpl->setVariable("TXT_TITLE", $data->title);
00584                                         $this->tpl->setVariable("TXT_DESCRIPTION", $data->comment);
00585                                         $this->tpl->setVariable("TXT_TYPE", $this->lng->txt($data->type_tag));
00586                                         $this->tpl->parseCurrentBlock();
00587                                         $counter++;
00588                                 }
00589                         }
00590                 }
00591                 foreach ($checked_questions as $id)
00592                 {
00593                         $this->tpl->setCurrentBlock("hidden");
00594                         $this->tpl->setVariable("HIDDEN_NAME", "id_$id");
00595                         $this->tpl->setVariable("HIDDEN_VALUE", "1");
00596                         $this->tpl->parseCurrentBlock();
00597                 }
00598 
00599                 $this->tpl->setCurrentBlock("adm_content");
00600                 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("tst_question_title"));
00601                 $this->tpl->setVariable("TXT_DESCRIPTION", $this->lng->txt("description"));
00602                 $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("tst_question_type"));
00603                 $this->tpl->setVariable("TXT_LOCKED", $this->lng->txt("locked"));
00604                 $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
00605                 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
00606                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00607                 $this->tpl->parseCurrentBlock();
00608         }
00609 
00610 
00614         function confirmDeleteQuestionsObject()
00615         {
00616                 // delete questions after confirmation
00617                 sendInfo($this->lng->txt("qpl_questions_deleted"), true);
00618                 foreach ($_SESSION["ass_q_id"] as $key => $value)
00619                 {
00620                         $this->object->deleteQuestion($value);
00621                 }
00622                 $this->ctrl->redirect($this, "questions");
00623         }
00624 
00628         function duplicateObject()
00629         {
00630                 // duplicate button was pressed
00631                 if (count($_POST["q_id"]) > 0)
00632                 {
00633                         foreach ($_POST["q_id"] as $key => $value)
00634                         {
00635                                 $this->object->duplicateQuestion($value);
00636                         }
00637                 }
00638                 else
00639                 {
00640                         sendInfo($this->lng->txt("qpl_duplicate_select_none"), true);
00641                 }
00642                 $this->ctrl->redirect($this, "questions");
00643         }
00644 
00648         function exportQuestionObject()
00649         {
00650                 // export button was pressed
00651                 if (count($_POST["q_id"]) > 0)
00652                 {
00653                         require_once("assessment/classes/class.ilQuestionpoolExport.php");
00654                         $qpl_exp = new ilQuestionpoolExport($this->object, "xml", $_POST["q_id"]);
00655                         $export_file = $qpl_exp->buildExportFile();
00656                         $filename = $export_file;
00657                         $filename = preg_replace("/.*\//", "", $filename);
00658                         ilUtil::deliverFile($export_file, $filename);
00659                         exit();
00660                 }
00661                 else
00662                 {
00663                         sendInfo($this->lng->txt("qpl_export_select_none"), true);
00664                 }
00665                 $this->ctrl->redirect($this, "questions");
00666         }
00667 
00671         function questionsObject()
00672         {
00673                 global $rbacsystem;
00674 
00675                 $type = $_GET["sel_question_types"];
00676 
00677                 // reset test_id SESSION variable
00678                 $_SESSION["test_id"] = "";
00679                 $add_parameter = $this->getAddParameter();
00680 
00681                 // create an array of all checked checkboxes
00682                 $checked_questions = array();
00683                 foreach ($_POST as $key => $value)
00684                 {
00685                         if (preg_match("/cb_(\d+)/", $key, $matches))
00686                         {
00687                                 array_push($checked_questions, $matches[1]);
00688                         }
00689                 }
00690 
00691                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.qpl_questions.html", true);
00692                 if ($rbacsystem->checkAccess('write', $this->ref_id))
00693                 {
00694                         $this->tpl->addBlockFile("CREATE_QUESTION", "create_question", "tpl.il_as_create_new_question.html", true);
00695                         $this->tpl->addBlockFile("A_BUTTONS", "a_buttons", "tpl.il_as_qpl_action_buttons.html", true);
00696                 }
00697                 $this->tpl->addBlockFile("FILTER_QUESTION_MANAGER", "filter_questions", "tpl.il_as_qpl_filter_questions.html", true);
00698 
00699                 // create filter form
00700                 $filter_fields = array(
00701                         "title" => $this->lng->txt("title"),
00702                         "comment" => $this->lng->txt("description"),
00703                         "author" => $this->lng->txt("author"),
00704                 );
00705                 $this->tpl->setCurrentBlock("filterrow");
00706                 foreach ($filter_fields as $key => $value)
00707                 {
00708                         $this->tpl->setVariable("VALUE_FILTER_TYPE", "$key");
00709                         $this->tpl->setVariable("NAME_FILTER_TYPE", "$value");
00710                         if (strcmp($_POST["sel_filter_type"], $key) == 0)
00711                         {
00712                                 $this->tpl->setVariable("VALUE_FILTER_SELECTED", " selected=\"selected\"");
00713                         }
00714                         $this->tpl->parseCurrentBlock();
00715                 }
00716 
00717                 $this->tpl->setCurrentBlock("filter_questions");
00718                 $this->tpl->setVariable("FILTER_TEXT", $this->lng->txt("filter"));
00719                 $this->tpl->setVariable("TEXT_FILTER_BY", $this->lng->txt("by"));
00720                 $this->tpl->setVariable("VALUE_FILTER_TEXT", $_POST["filter_text"]);
00721                 $this->tpl->setVariable("VALUE_SUBMIT_FILTER", $this->lng->txt("set_filter"));
00722                 $this->tpl->setVariable("VALUE_RESET_FILTER", $this->lng->txt("reset_filter"));
00723                 $this->tpl->parseCurrentBlock();
00724 
00725                 // create edit buttons & table footer
00726                 if ($rbacsystem->checkAccess('write', $this->ref_id))
00727                 {
00728                         $this->tpl->setCurrentBlock("standard");
00729                         $this->tpl->setVariable("DELETE", $this->lng->txt("delete"));
00730                         $this->tpl->setVariable("DUPLICATE", $this->lng->txt("duplicate"));
00731                         $this->tpl->setVariable("EXPORT", $this->lng->txt("export"));
00732                         $this->tpl->parseCurrentBlock();
00733                         $this->tpl->setCurrentBlock("Footer");
00734                         $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"\">");
00735                         $this->tpl->parseCurrentBlock();
00736                 }
00737 
00738                 $this->tpl->setCurrentBlock("QTab");
00739 
00740                 // reset the filter
00741                 $startrow = 0;
00742                 if ($_GET["prevrow"])
00743                 {
00744                         $startrow = $_GET["prevrow"];
00745                 }
00746                 if ($_GET["nextrow"])
00747                 {
00748                         $startrow = $_GET["nextrow"];
00749                 }
00750                 if ($_GET["startrow"])
00751                 {
00752                         $startrow = $_GET["startrow"];
00753                 }
00754                 if (!$_GET["sort"])
00755                 {
00756                         // default sort order
00757                         $_GET["sort"] = array("title" => "ASC");
00758                 }
00759                 $table = $this->object->getQuestionsTable($_GET["sort"], $_POST["filter_text"], $_POST["sel_filter_type"], $startrow);
00760                 $colors = array("tblrow1", "tblrow2");
00761                 $img_locked = "<img src=\"" . ilUtil::getImagePath("locked.gif", true) . "\" alt=\"" . $this->lng->txt("locked") . "\" title=\"" . $this->lng->txt("locked") . "\" border=\"0\" />";
00762                 $counter = 0;
00763                 $editable = $rbacsystem->checkAccess('write', $this->ref_id);
00764                 foreach ($table["rows"] as $data)
00765                 {
00766                         if ($data["complete"] == 0)
00767                         {
00768                                 $this->tpl->setCurrentBlock("qpl_warning");
00769                                 $this->tpl->setVariable("IMAGE_WARNING", ilUtil::getImagePath("warning.png"));
00770                                 $this->tpl->setVariable("ALT_WARNING", $this->lng->txt("warning_question_not_complete"));
00771                                 $this->tpl->setVariable("TITLE_WARNING", $this->lng->txt("warning_question_not_complete"));
00772                                 $this->tpl->parseCurrentBlock();
00773                                 $this->tpl->setCurrentBlock("QTab");
00774                         }
00775                         $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
00776                         $class = strtolower(ASS_QuestionGUI::_getGUIClassNameForId($data["question_id"]));
00777                         $this->ctrl->setParameterByClass("ilpageobjectgui", "q_id", $data["question_id"]);
00778                         $this->ctrl->setParameterByClass($class, "q_id", $data["question_id"]);
00779                         if ($editable)
00780                         {
00781                                 $this->tpl->setVariable("TXT_EDIT", $this->lng->txt("edit"));
00782                                 $this->tpl->setVariable("LINK_EDIT", $this->ctrl->getLinkTargetByClass("ilpageobjectgui", "view"));
00783                         }
00784                         $this->tpl->setVariable("QUESTION_TITLE", "<strong>" .$data["title"] . "</strong>");
00785 
00786                         $this->tpl->setVariable("TXT_PREVIEW", $this->lng->txt("preview"));
00787                         $this->tpl->setVariable("LINK_PREVIEW", $this->ctrl->getLinkTargetByClass("ilpageobjectgui", "preview"));
00788 
00789                         $this->tpl->setVariable("QUESTION_COMMENT", $data["comment"]);
00790                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($data["type_tag"]));
00791                         $this->tpl->setVariable("LINK_ASSESSMENT", $this->ctrl->getLinkTargetByClass($class, "assessment"));
00792                         $this->tpl->setVariable("TXT_ASSESSMENT", $this->lng->txt("qpl_assessment_of_questions"));
00793                         $this->tpl->setVariable("IMG_ASSESSMENT",
00794                                 ilUtil::getImagePath("assessment.gif", true));
00795                         $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]);
00796                         $this->tpl->setVariable("QUESTION_CREATED", ilFormat::formatDate(ilFormat::ftimestamp2dateDB($data["created"]), "date"));
00797                         $this->tpl->setVariable("QUESTION_UPDATED", ilFormat::formatDate(ilFormat::ftimestamp2dateDB($data["TIMESTAMP14"]), "date"));
00798                         $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
00799                         $this->tpl->parseCurrentBlock();
00800                         $counter++;
00801                 }
00802 
00803                 if ($table["rowcount"] > count($table["rows"]))
00804                 {
00805                         $nextstep = $table["nextrow"] + $table["step"];
00806                         if ($nextstep > $table["rowcount"])
00807                         {
00808                                 $nextstep = $table["rowcount"];
00809                         }
00810                         $sort = "";
00811                         if (is_array($_GET["sort"]))
00812                         {
00813                                 $key = key($_GET["sort"]);
00814                                 $sort = "&sort[$key]=" . $_GET["sort"]["$key"];
00815                         }
00816                         $counter = 1;
00817                         for ($i = 0; $i < $table["rowcount"]; $i += $table["step"])
00818                         {
00819                                 $this->tpl->setCurrentBlock("pages");
00820                                 if ($table["startrow"] == $i)
00821                                 {
00822                                         $this->tpl->setVariable("PAGE_NUMBER", "<span class=\"inactivepage\">$counter</span>");
00823                                 }
00824                                 else
00825                                 {
00826                                         $this->tpl->setVariable("PAGE_NUMBER", "<a href=\"" . $this->ctrl->getFormAction($this) . "$sort&nextrow=$i" . "\">$counter</a>");
00827                                 }
00828                                 $this->tpl->parseCurrentBlock();
00829                                 $counter++;
00830                         }
00831                         $this->tpl->setCurrentBlock("navigation_bottom");
00832                         $this->tpl->setVariable("TEXT_ITEM", $this->lng->txt("item"));
00833                         $this->tpl->setVariable("TEXT_ITEM_START", $table["startrow"] + 1);
00834                         $end = $table["startrow"] + $table["step"];
00835                         if ($end > $table["rowcount"])
00836                         {
00837                                 $end = $table["rowcount"];
00838                         }
00839                         $this->tpl->setVariable("TEXT_ITEM_END", $end);
00840                         $this->tpl->setVariable("TEXT_OF", strtolower($this->lng->txt("of")));
00841                         $this->tpl->setVariable("TEXT_ITEM_COUNT", $table["rowcount"]);
00842                         $this->tpl->setVariable("TEXT_PREVIOUS", $this->lng->txt("previous"));
00843                         $this->tpl->setVariable("TEXT_NEXT", $this->lng->txt("next"));
00844                         $this->tpl->setVariable("HREF_PREV_ROWS", $this->ctrl->getFormAction($this) . "$sort&prevrow=" . $table["prevrow"]);
00845                         $this->tpl->setVariable("HREF_NEXT_ROWS", $this->ctrl->getFormAction($this) . "$sort&nextrow=" . $table["nextrow"]);
00846                         $this->tpl->parseCurrentBlock();
00847                 }
00848 
00849                 // if there are no questions, display a message
00850                 if ($counter == 0)
00851                 {
00852                         $this->tpl->setCurrentBlock("Emptytable");
00853                         $this->tpl->setVariable("TEXT_EMPTYTABLE", $this->lng->txt("no_questions_available"));
00854                         $this->tpl->parseCurrentBlock();
00855                 }
00856 
00857                 if ($rbacsystem->checkAccess('write', $this->ref_id))
00858                 {
00859                         // "create question" form
00860                         $this->tpl->setCurrentBlock("QTypes");
00861                         $query = "SELECT * FROM qpl_question_type ORDER BY question_type_id";
00862                         $query_result = $this->ilias->db->query($query);
00863                         while ($data = $query_result->fetchRow(DB_FETCHMODE_OBJECT))
00864                         {
00865 // temporary disable java questions
00866 //                              if ($data->type_tag != "qt_javaapplet")
00867 //                              {
00868                                         $this->tpl->setVariable("QUESTION_TYPE_ID", $data->type_tag);
00869                                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($data->type_tag));
00870                                         $this->tpl->parseCurrentBlock();
00871 //                              }
00872                         }
00873                         $this->tpl->setCurrentBlock("CreateQuestion");
00874                         $this->tpl->setVariable("QUESTION_ADD", $this->lng->txt("create"));
00875                         $this->tpl->setVariable("ACTION_QUESTION_ADD", $this->ctrl->getFormAction($this));
00876                         $this->tpl->setVariable("QUESTION_IMPORT", $this->lng->txt("import"));
00877                         $this->tpl->parseCurrentBlock();
00878                 }
00879 
00880                 // define the sort column parameters
00881                 $sort = array(
00882                         "title" => $_GET["sort"]["title"],
00883                         "comment" => $_GET["sort"]["comment"],
00884                         "type" => $_GET["sort"]["type"],
00885                         "author" => $_GET["sort"]["author"],
00886                         "created" => $_GET["sort"]["created"],
00887                         "updated" => $_GET["sort"]["updated"]
00888                 );
00889                 foreach ($sort as $key => $value)
00890                 {
00891                         if (strcmp($value, "ASC") == 0)
00892                         {
00893                                 $sort[$key] = "DESC";
00894                         }
00895                         else
00896                         {
00897                                 $sort[$key] = "ASC";
00898                         }
00899                 }
00900 
00901                 $this->tpl->setCurrentBlock("adm_content");
00902                 // create table header
00903                 $this->ctrl->setParameterByClass(get_class($this), "startrow", $table["startrow"]);
00904                 $this->tpl->setVariable("QUESTION_TITLE", "<a href=\"" . $this->ctrl->getFormAction($this) . "&sort[title]=" . $sort["title"] . "\">" . $this->lng->txt("title") . "</a>" . $table["images"]["title"]);
00905                 $this->tpl->setVariable("QUESTION_COMMENT", "<a href=\"" . $this->ctrl->getFormAction($this) . "&sort[comment]=" . $sort["comment"] . "\">" . $this->lng->txt("description") . "</a>". $table["images"]["comment"]);
00906                 $this->tpl->setVariable("QUESTION_TYPE", "<a href=\"" . $this->ctrl->getFormAction($this) . "&sort[type]=" . $sort["type"] . "\">" . $this->lng->txt("question_type") . "</a>" . $table["images"]["type"]);
00907                 $this->tpl->setVariable("QUESTION_AUTHOR", "<a href=\"" . $this->ctrl->getFormAction($this) . "&sort[author]=" . $sort["author"] . "\">" . $this->lng->txt("author") . "</a>" . $table["images"]["author"]);
00908                 $this->tpl->setVariable("QUESTION_CREATED", "<a href=\"" . $this->ctrl->getFormAction($this) . "&sort[created]=" . $sort["created"] . "\">" . $this->lng->txt("create_date") . "</a>" . $table["images"]["created"]);
00909                 $this->tpl->setVariable("QUESTION_UPDATED", "<a href=\"" . $this->ctrl->getFormAction($this) . "&sort[updated]=" . $sort["updated"] . "\">" . $this->lng->txt("last_update") . "</a>" . $table["images"]["updated"]);
00910                 $this->tpl->setVariable("BUTTON_CANCEL", $this->lng->txt("cancel"));
00911                 $this->tpl->setVariable("ACTION_QUESTION_FORM", $this->ctrl->getFormAction($this));
00912                 $this->tpl->parseCurrentBlock();
00913         }
00914 
00915         function updateObject()
00916         {
00917                 $this->update = $this->object->updateMetaData();
00918                 sendInfo($this->lng->txt("msg_obj_modified"), true);
00919         }
00920 
00929         function setLocator($a_tree = "", $a_id = "", $scriptname="repository.php", $question_title = "")
00930         {
00931 //echo "<br>ilObjQuestionPoolGUI->setLocator()";
00932                 $ilias_locator = new ilLocatorGUI(false);
00933                 if (!is_object($a_tree))
00934                 {
00935                         $a_tree =& $this->tree;
00936                 }
00937                 if (!($a_id))
00938                 {
00939                         $a_id = $_GET["ref_id"];
00940                 }
00941                 if (!($scriptname))
00942                 {
00943                         $scriptname = "repository.php";
00944                 }
00945                 $path = $a_tree->getPathFull($a_id);
00946                 //check if object isn't in tree, this is the case if parent_parent is set
00947                 // TODO: parent_parent no longer exist. need another marker
00948                 if ($a_parent_parent)
00949                 {
00950                         //$subObj = getObject($a_ref_id);
00951                         $subObj =& $this->ilias->obj_factory->getInstanceByRefId($a_ref_id);
00952 
00953                         $path[] = array(
00954                                 "id"     => $a_ref_id,
00955                                 "title"  => $this->lng->txt($subObj->getTitle())
00956                         );
00957                 }
00958 
00959                 // this is a stupid workaround for a bug in PEAR:IT
00960                 $modifier = 1;
00961 
00962                 if (isset($_GET["obj_id"]))
00963                 {
00964                         $modifier = 0;
00965                 }
00966 
00967                 // ### AA 03.11.10 added new locator GUI class ###
00968                 $i = 1;
00969 
00970                 if (!defined("ILIAS_MODULE"))
00971                 {
00972                         foreach ($path as $key => $row)
00973                         {
00974                                 $ilias_locator->navigate($i++, $row["title"], ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/adm_object.php?ref_id=".$row["child"],"");
00975                         }
00976                 }
00977                 else
00978                 {
00979                         foreach ($path as $key => $row)
00980                         {
00981                                 if (strcmp($row["title"], "ILIAS") == 0)
00982                                 {
00983                                         $row["title"] = $this->lng->txt("repository");
00984                                 }
00985                                 if ($this->ref_id == $row["child"])
00986                                 {
00987                                         $param = "&cmd=questions";
00988                                         $ilias_locator->navigate($i++, $row["title"], ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/assessment/questionpool.php" . "?ref_id=".$row["child"] . $param,"");
00989                                         switch ($_GET["cmd"])
00990                                         {
00991                                                 case "question":
00992                                                         $id = $_GET["edit"];
00993                                                         if (!$id)
00994                                                         {
00995                                                                 $id = $_POST["id"];
00996                                                         }
00997                                                         if ($question_title)
00998                                                         {
00999                                                                 if ($id > 1)
01000                                                                 {
01001                                                                         $ilias_locator->navigate($i++, $question_title, ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/assessment/questionpool.php" . "?ref_id=".$row["child"] . "&cmd=question&edit=$id","");
01002                                                                 }
01003                                                         }
01004                                                         break;
01005                                         }
01006                                 }
01007                                 else
01008                                 {
01009                                         $ilias_locator->navigate($i++, $row["title"], ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/" . $scriptname."?cmd=frameset&ref_id=".$row["child"],"");
01010                                 }
01011                         }
01012 
01013                         if (isset($_GET["obj_id"]))
01014                         {
01015                                 $obj_data =& $this->ilias->obj_factory->getInstanceByObjId($_GET["obj_id"]);
01016                                 $ilias_locator->navigate($i++,$obj_data->getTitle(),$scriptname."?ref_id=".$_GET["ref_id"]."&obj_id=".$_GET["obj_id"],"");
01017                         }
01018                 }
01019                 $ilias_locator->output(true);
01020         }
01021 
01022         function prepareOutput()
01023         {
01024                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
01025                 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
01026                 $title = $this->object->getTitle();
01027 
01028                 // catch feedback message
01029                 sendInfo();
01030 
01031                 if (!empty($title))
01032                 {
01033                         $this->tpl->setVariable("HEADER", $title);
01034                 }
01035                 if (!defined("ILIAS_MODULE"))
01036                 {
01037                         $this->setAdminTabs($_POST["new_type"]);
01038                 }
01039                 $this->setLocator();
01040 
01041         }
01042 
01043 
01047         function setPageEditorTabs()
01048         {
01049 
01050                 // catch feedback message
01051                 include_once("classes/class.ilTabsGUI.php");
01052                 $tabs_gui =& new ilTabsGUI();
01053                 $this->getPageEditorTabs($tabs_gui);
01054 
01055                 $this->tpl->setVariable("TABS", $tabs_gui->getHTML());
01056 
01057         }
01058 
01062         function getPageEditorTabs(&$tabs_gui)
01063         {
01064                 global $rbacsystem;
01065                 
01066                 if ($rbacsystem->checkAccess('write', $this->ref_id))
01067                 {
01068                         // edit page
01069                         $tabs_gui->addTarget("edit_content",
01070                                 $this->ctrl->getLinkTargetByClass("ilPageObjectGUI", "view"), "view",
01071                                 "ilPageObjectGUI");
01072                 }
01073                 // preview page
01074                 $tabs_gui->addTarget("preview",
01075                         $this->ctrl->getLinkTargetByClass("ilPageObjectGUI", "preview"), "preview",
01076                         "ilPageObjectGUI");
01077 
01078                 // back to upper context
01079                 $tabs_gui->addTarget("back",
01080                         $this->ctrl->getLinkTarget($this, "questions"), "questions",
01081                         "ilObjQuestionPoolGUI");
01082 
01083         }
01084         
01085         function setQuestionTabs()
01086         {
01087 //              echo "<br>setQuestionTabs<br>";
01088                 global $rbacsystem;
01089                 
01090                 $this->ctrl->setParameterByClass("ilpageobjectgui", "q_id", $_GET["q_id"]);
01091                 $q_type = ASS_Question::getQuestionTypeFromDb($_GET["q_id"]);
01092                 include_once "./classes/class.ilTabsGUI.php";
01093                 $tabs_gui =& new ilTabsGUI();
01094                 
01095                 switch ($q_type)
01096                 {
01097                         case "qt_multiple_choice_sr":
01098                                 $classname = "ASS_MultipleChoiceGUI";
01099                                 $this->ctrl->setParameterByClass("ass_multiplechoicegui", "sel_question_types", $q_type);
01100                                 $this->ctrl->setParameterByClass("ass_multiplechoicegui", "q_id", $_GET["q_id"]);
01101                                 break;
01102 
01103                         case "qt_multiple_choice_mr":
01104                                 $classname = "ASS_MultipleChoiceGUI";
01105                                 $this->ctrl->setParameterByClass("ass_multiplechoicegui", "sel_question_types", $q_type);
01106                                 $this->ctrl->setParameterByClass("ass_multiplechoicegui", "q_id", $_GET["q_id"]);
01107                                 break;
01108 
01109                         case "qt_cloze":
01110                                 $classname = "ASS_ClozeTestGUI";
01111                                 $this->ctrl->setParameterByClass("ass_clozetestgui", "sel_question_types", $q_type);
01112                                 $this->ctrl->setParameterByClass("ass_clozetestgui", "q_id", $_GET["q_id"]);
01113                                 break;
01114 
01115                         case "qt_matching":
01116                                 $classname = "ASS_MatchingQuestionGUI";
01117                                 $this->ctrl->setParameterByClass("ass_matchingquestiongui", "sel_question_types", $q_type);
01118                                 $this->ctrl->setParameterByClass("ass_matchingquestiongui", "q_id", $_GET["q_id"]);
01119                                 break;
01120 
01121                         case "qt_ordering":
01122                                 $classname = "ASS_OrderingQuestionGUI";
01123                                 $this->ctrl->setParameterByClass("ass_orderingquestiongui", "sel_question_types", $q_type);
01124                                 $this->ctrl->setParameterByClass("ass_orderingquestiongui", "q_id", $_GET["q_id"]);
01125                                 break;
01126 
01127                         case "qt_imagemap":
01128                                 $classname = "ASS_ImagemapQuestionGUI";
01129                                 $this->ctrl->setParameterByClass("ass_imagemapquestiongui", "sel_question_types", $q_type);
01130                                 $this->ctrl->setParameterByClass("ass_imagemapquestiongui", "q_id", $_GET["q_id"]);
01131                                 break;
01132 
01133                         case "qt_javaapplet":
01134                                 $classname = "ASS_JavaAppletGUI";
01135                                 $this->ctrl->setParameterByClass("ass_javaappletgui", "sel_question_types", $q_type);
01136                                 $this->ctrl->setParameterByClass("ass_javaappletgui", "q_id", $_GET["q_id"]);
01137                                 break;
01138 
01139                         case "qt_text":
01140                                 $classname = "ASS_TextQuestionGUI";
01141                                 $this->ctrl->setParameterByClass("ass_textquestiongui", "sel_question_types", $q_type);
01142                                 $this->ctrl->setParameterByClass("ass_textquestiongui", "q_id", $_GET["q_id"]);
01143                                 break;
01144                 }
01145 
01146                 if (($_GET["q_id"]) && (strlen($_GET["calling_test"]) == 0))
01147                 {
01148                         if ($rbacsystem->checkAccess('write', $this->ref_id))
01149                         {
01150                                 // edit page
01151                                 $tabs_gui->addTarget("edit_content",
01152                                         $this->ctrl->getLinkTargetByClass("ilPageObjectGUI", "view"), "view",
01153                                         "ilPageObjectGUI");
01154                         }
01155         
01156                         $tabs_gui->addTarget("preview",
01157                                 $this->ctrl->getLinkTargetByClass("ilPageObjectGUI", "preview"), "preview",
01158                                 "ilPageObjectGUI");
01159                 }
01160 
01161                 if (($classname) && (strlen($_GET["calling_test"]) == 0))
01162                 {
01163                         if ($rbacsystem->checkAccess('write', $this->ref_id))
01164                         {
01165                                 $tabs_gui->addTarget("edit_properties",
01166                                         $this->ctrl->getLinkTargetByClass($classname, "editQuestion"), "editQuestion",
01167                                         $classname);
01168                         }
01169                 }
01170 
01171                 if (strlen($_GET["calling_test"]) == 0)
01172                 {
01173                         $tabs_gui->addTarget("back",
01174                                 $this->ctrl->getLinkTarget($this, "questions"), "questions",
01175                                 "ilObjQuestionPoolGUI");
01176                 }
01177                 else
01178                 {
01179                         $tabs_gui->addTarget("backtocallingtest",
01180                                 "test.php?cmd=questions&ref_id=".$_GET["calling_test"], "questions",
01181                                 "ilObjQuestionPoolGUI");
01182                 }
01183 
01184                 $this->tpl->setVariable("TABS", $tabs_gui->getHTML());
01185 //              echo "<br>end setQuestionTabs<br>";
01186         }
01187 
01188         function editMetaObject()
01189         {
01190                 $meta_gui =& new ilMetaDataGUI();
01191                 $meta_gui->setObject($this->object);
01192                 $meta_gui->edit("ADM_CONTENT", "adm_content",
01193                         $this->getTabTargetScript()."?ref_id=".$_GET["ref_id"]."&cmd=saveMeta");
01194         }
01195 
01196                 function saveMetaObject()
01197         {
01198                 $meta_gui =& new ilMetaDataGUI();
01199                 $meta_gui->setObject($this->object);
01200                 $meta_gui->save($_POST["meta_section"]);
01201                 if (!strcmp($_POST["meta_section"], "General")) {
01202                         //$this->updateObject();
01203                 }
01204                 ilUtil::redirect($this->getTabTargetScript()."?ref_id=".$_GET["ref_id"]);
01205         }
01206 
01207         // called by administration
01208         function chooseMetaSectionObject($a_script = "",
01209                 $a_templ_var = "ADM_CONTENT", $a_templ_block = "adm_content")
01210         {
01211                 if ($a_script == "")
01212                 {
01213                         $a_script = $this->getTabTargetScript()."?ref_id=".$_GET["ref_id"];
01214                 }
01215                 $meta_gui =& new ilMetaDataGUI();
01216                 $meta_gui->setObject($this->object);
01217                 $meta_gui->edit($a_templ_var, $a_templ_block, $a_script, $_REQUEST["meta_section"]);
01218         }
01219 
01220         // called by editor
01221         function chooseMetaSection()
01222         {
01223                 $this->chooseMetaSectionObject($this->getTabTargetScript()."?ref_id=".
01224                         $this->object->getRefId());
01225         }
01226 
01227         function addMetaObject($a_script = "",
01228                 $a_templ_var = "ADM_CONTENT", $a_templ_block = "adm_content")
01229         {
01230                 if ($a_script == "")
01231                 {
01232                         $a_script = $this->getTabTargetScript()."?ref_id=".$_GET["ref_id"];
01233                 }
01234                 $meta_gui =& new ilMetaDataGUI();
01235                 $meta_gui->setObject($this->object);
01236                 $meta_name = $_POST["meta_name"] ? $_POST["meta_name"] : $_GET["meta_name"];
01237                 $meta_index = $_POST["meta_index"] ? $_POST["meta_index"] : $_GET["meta_index"];
01238                 if ($meta_index == "")
01239                         $meta_index = 0;
01240                 $meta_path = $_POST["meta_path"] ? $_POST["meta_path"] : $_GET["meta_path"];
01241                 $meta_section = $_POST["meta_section"] ? $_POST["meta_section"] : $_GET["meta_section"];
01242                 if ($meta_name != "")
01243                 {
01244                         $meta_gui->meta_obj->add($meta_name, $meta_path, $meta_index);
01245                 }
01246                 else
01247                 {
01248                         sendInfo($this->lng->txt("meta_choose_element"), true);
01249                 }
01250                 $meta_gui->edit($a_templ_var, $a_templ_block, $a_script, $meta_section);
01251         }
01252 
01253         function addMeta()
01254         {
01255                 $this->addMetaObject($this->getTabTargetScript()."?ref_id=".
01256                         $this->object->getRefId());
01257         }
01258 
01259         function deleteMetaObject($a_script = "",
01260                 $a_templ_var = "ADM_CONTENT", $a_templ_block = "adm_content")
01261         {
01262                 if ($a_script == "")
01263                 {
01264                         $a_script = $this->getTabTargetScript()."?ref_id=".$_GET["ref_id"];
01265                 }
01266                 $meta_gui =& new ilMetaDataGUI();
01267                 $meta_gui->setObject($this->object);
01268                 $meta_index = $_POST["meta_index"] ? $_POST["meta_index"] : $_GET["meta_index"];
01269                 $meta_gui->meta_obj->delete($_GET["meta_name"], $_GET["meta_path"], $meta_index);
01270                 $meta_gui->edit($a_templ_var, $a_templ_block, $a_script, $_GET["meta_section"]);
01271         }
01272 
01273         function deleteMeta()
01274         {
01275                 $this->deleteMetaObject($this->getTabTargetScript()."?ref_id=".
01276                         $this->object->getRefId());
01277         }
01278 
01279         /*
01280         * list all export files
01281         */
01282         function exportObject()
01283         {
01284                 global $tree;
01285 
01286                 //$this->setTabs();
01287 
01288                 //add template for view button
01289                 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
01290 
01291                 // create export file button
01292                 $this->tpl->setCurrentBlock("btn_cell");
01293                 $this->tpl->setVariable("BTN_LINK", "questionpool.php?ref_id=".$_GET["ref_id"]."&cmd=createExportFile");
01294                 $this->tpl->setVariable("BTN_TXT", $this->lng->txt("ass_create_export_file"));
01295                 $this->tpl->parseCurrentBlock();
01296 
01297                 // view last export log button
01298                 /*
01299                 if (is_file($this->object->getExportDirectory()."/export.log"))
01300                 {
01301                         $this->tpl->setCurrentBlock("btn_cell");
01302                         $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "viewExportLog"));
01303                         $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_view_last_export_log"));
01304                         $this->tpl->parseCurrentBlock();
01305                 }*/
01306 
01307                 $export_dir = $this->object->getExportDirectory();
01308                 $export_files = $this->object->getExportFiles($export_dir);
01309 
01310                 // create table
01311                 require_once("classes/class.ilTableGUI.php");
01312                 $tbl = new ilTableGUI();
01313 
01314                 // load files templates
01315                 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
01316 
01317                 // load template for table content data
01318                 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.export_file_row.html", true);
01319 
01320                 $num = 0;
01321 
01322                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01323 
01324                 $tbl->setTitle($this->lng->txt("ass_export_files"));
01325 
01326                 $tbl->setHeaderNames(array("<input type=\"checkbox\" name=\"chb_check_all\" value=\"1\" onclick=\"setCheckboxes('ObjectItems', 'file', document.ObjectItems.chb_check_all.checked);\" />", $this->lng->txt("ass_file"),
01327                         $this->lng->txt("ass_size"), $this->lng->txt("date") ));
01328                 $tbl->enabled["sort"] = false;
01329                 $tbl->setColumnWidth(array("1%", "49%", "25%", "25%"));
01330 
01331                 // control
01332                 $tbl->setOrderColumn($_GET["sort_by"]);
01333                 $tbl->setOrderDirection($_GET["sort_order"]);
01334                 $tbl->setLimit($_GET["limit"]);
01335                 $tbl->setOffset($_GET["offset"]);
01336 
01337                 $this->tpl->setVariable("COLUMN_COUNTS", 4);
01338 
01339                 // delete button
01340                 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
01341                 $this->tpl->setCurrentBlock("tbl_action_btn");
01342                 $this->tpl->setVariable("BTN_NAME", "confirmDeleteExportFile");
01343                 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
01344                 $this->tpl->parseCurrentBlock();
01345 
01346                 $this->tpl->setCurrentBlock("tbl_action_btn");
01347                 $this->tpl->setVariable("BTN_NAME", "downloadExportFile");
01348                 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("download"));
01349                 $this->tpl->parseCurrentBlock();
01350 
01351                 // footer
01352                 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
01353                 //$tbl->disable("footer");
01354 
01355                 $tbl->setMaxCount(count($export_files));
01356                 $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
01357 
01358                 $tbl->render();
01359                 if(count($export_files) > 0)
01360                 {
01361                         $i=0;
01362                         foreach($export_files as $exp_file)
01363                         {
01364                                 $this->tpl->setCurrentBlock("tbl_content");
01365                                 $this->tpl->setVariable("TXT_FILENAME", $exp_file);
01366 
01367                                 $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
01368                                 $this->tpl->setVariable("CSS_ROW", $css_row);
01369 
01370                                 $this->tpl->setVariable("TXT_SIZE", filesize($export_dir."/".$exp_file));
01371                                 $this->tpl->setVariable("CHECKBOX_ID", $exp_file);
01372 
01373                                 $file_arr = explode("__", $exp_file);
01374                                 $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s",$file_arr[0]));
01375 
01376                                 $this->tpl->parseCurrentBlock();
01377                         }
01378                 } //if is_array
01379                 else
01380                 {
01381                         $this->tpl->setCurrentBlock("notfound");
01382                         $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
01383                         $this->tpl->setVariable("NUM_COLS", 3);
01384                         $this->tpl->parseCurrentBlock();
01385                 }
01386 
01387                 $this->tpl->parseCurrentBlock();
01388         }
01389 
01390         
01394         function createExportFileObject()
01395         {
01396                 global $rbacsystem;
01397                 if ($rbacsystem->checkAccess("write", $this->ref_id))
01398                 {
01399                         require_once("assessment/classes/class.ilQuestionpoolExport.php");
01400                         $question_ids =& $this->object->getAllQuestionIds();
01401                         $qpl_exp = new ilQuestionpoolExport($this->object, "xml", $question_ids);
01402                         $qpl_exp->buildExportFile();
01403                         $this->exportObject();
01404 
01405                         //ilUtil::deliverData($this->object->to_xml(), $this->object->getTitle() . ".xml");
01406                         
01407                         /*
01408                         $add_parameter = $this->getAddParameter();
01409                         if (!defined("ILIAS_MODULE"))
01410                         {
01411                                 define("ILIAS_MODULE", "assessment");
01412                         }
01413                         $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_export.html", true);
01414                         $this->tpl->setCurrentBlock("adm_content");
01415                         $this->tpl->setVariable("FORMACTION", $add_parameter);
01416                         $this->tpl->setVariable("BUTTON_EXPORT", $this->lng->txt("export"));
01417                         $this->tpl->parseCurrentBlock();*/
01418                 }
01419                 else
01420                 {
01421                         sendInfo("cannot_export_qpl");
01422                 }
01423         }
01424         
01428         function downloadExportFileObject()
01429         {
01430                 if(!isset($_POST["file"]))
01431                 {
01432                         sendInfo($this->lng->txt("no_checkbox"), true);
01433                         $this->ctrl->redirect($this, "export");
01434                 }
01435 
01436                 if (count($_POST["file"]) > 1)
01437                 {
01438                         sendInfo($this->lng->txt("cont_select_max_one_item"), true);
01439                         $this->ctrl->redirect($this, "export");
01440                 }
01441 
01442 
01443                 $export_dir = $this->object->getExportDirectory();
01444                 ilUtil::deliverFile($export_dir."/".$_POST["file"][0],
01445                         $_POST["file"][0]);
01446                 $this->ctrl->redirect($this, "export");
01447         }
01448 
01452         function confirmDeleteExportFileObject()
01453         {
01454                 if(!isset($_POST["file"]))
01455                 {
01456                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
01457                 }
01458 
01459                 //$this->setTabs();
01460 
01461                 // SAVE POST VALUES
01462                 $_SESSION["ilExportFiles"] = $_POST["file"];
01463 
01464                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html", true);
01465 
01466                 sendInfo($this->lng->txt("info_delete_sure"));
01467 
01468                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01469 
01470                 // BEGIN TABLE HEADER
01471                 $this->tpl->setCurrentBlock("table_header");
01472                 $this->tpl->setVariable("TEXT",$this->lng->txt("objects"));
01473                 $this->tpl->parseCurrentBlock();
01474 
01475                 // BEGIN TABLE DATA
01476                 $counter = 0;
01477                 foreach($_POST["file"] as $file)
01478                 {
01479                                 $this->tpl->setCurrentBlock("table_row");
01480                                 $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
01481                                 $this->tpl->setVariable("TEXT_CONTENT", $file);
01482                                 $this->tpl->parseCurrentBlock();
01483                 }
01484 
01485                 // cancel/confirm button
01486                 $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
01487                 $buttons = array( "cancelDeleteExportFile"  => $this->lng->txt("cancel"),
01488                         "deleteExportFile"  => $this->lng->txt("confirm"));
01489                 foreach ($buttons as $name => $value)
01490                 {
01491                         $this->tpl->setCurrentBlock("operation_btn");
01492                         $this->tpl->setVariable("BTN_NAME",$name);
01493                         $this->tpl->setVariable("BTN_VALUE",$value);
01494                         $this->tpl->parseCurrentBlock();
01495                 }
01496         }
01497 
01498 
01502         function cancelDeleteExportFileObject()
01503         {
01504                 session_unregister("ilExportFiles");
01505                 $this->ctrl->redirect($this, "export");
01506         }
01507 
01511         function deleteExportFileObject()
01512         {
01513                 $export_dir = $this->object->getExportDirectory();
01514                 foreach($_SESSION["ilExportFiles"] as $file)
01515                 {
01516                         $exp_file = $export_dir."/".$file;
01517                         $exp_dir = $export_dir."/".substr($file, 0, strlen($file) - 4);
01518                         if (@is_file($exp_file))
01519                         {
01520                                 unlink($exp_file);
01521                         }
01522                         if (@is_dir($exp_dir))
01523                         {
01524                                 ilUtil::delDir($exp_dir);
01525                         }
01526                 }
01527                 $this->ctrl->redirect($this, "export");
01528         }
01529 
01533         function &editQuestionForTestObject()
01534         {
01535 //echo "<br>create--".$_GET["new_type"];
01536                 $q_gui =& ASS_QuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
01537                 $this->ctrl->setCmdClass(get_class($q_gui));
01538                 $this->ctrl->setCmd("editQuestion");
01539 
01540                 $ret =& $this->executeCommand();
01541                 return $ret;
01542         }
01543 
01547         function createObject()
01548         {
01549                 global $rbacsystem;
01550                 $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
01551                 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
01552                 {
01553                         $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
01554                 }
01555                 else
01556                 {
01557                         $this->getTemplateFile("create", $new_type);
01558 
01559                         // fill in saved values in case of error
01560                         $data = array();
01561                         $data["fields"] = array();
01562                         $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
01563                         $data["fields"]["desc"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["desc"]);
01564 
01565                         foreach ($data["fields"] as $key => $val)
01566                         {
01567                                 $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
01568                                 $this->tpl->setVariable(strtoupper($key), $val);
01569 
01570                                 if ($this->prepare_output)
01571                                 {
01572                                         $this->tpl->parseCurrentBlock();
01573                                 }
01574                         }
01575 
01576                         $this->tpl->setVariable("FORMACTION", $this->getFormAction("save","adm_object.php?cmd=gateway&ref_id=".
01577                                                                                                                                            $_GET["ref_id"]."&new_type=".$new_type));
01578                         $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
01579                         $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
01580                         $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
01581                         $this->tpl->setVariable("CMD_SUBMIT", "save");
01582                         $this->tpl->setVariable("TARGET", $this->getTargetFrame("save"));
01583                         $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
01584 
01585                         $this->tpl->setVariable("TXT_IMPORT_QPL", $this->lng->txt("import_qpl"));
01586                         $this->tpl->setVariable("TXT_QPL_FILE", $this->lng->txt("qpl_upload_file"));
01587                         $this->tpl->setVariable("TXT_IMPORT", $this->lng->txt("import"));
01588                 }
01589         }
01590 
01594         function importFileObject()
01595         {
01596                 if (strcmp($_FILES["xmldoc"]["tmp_name"], "") == 0)
01597                 {
01598                         sendInfo($this->lng->txt("qpl_select_file_for_import"));
01599                         $this->createObject();
01600                         return;
01601                 }
01602                 $this->uploadQplObject(false);
01603                 ilUtil::redirect($this->getReturnLocation("importFile",$this->ctrl->getTargetScript()."?".$this->link_params));
01604         }
01605 
01606 } // END class.ilObjQuestionPoolGUI
01607 ?>

Generated on Fri Dec 13 2013 09:06:33 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1