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

assessment/classes/class.ilObjTestGUI.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 
00038 include_once "./assessment/classes/class.ilObjQuestionPool.php";
00039 include_once "./classes/class.ilObjectGUI.php";
00040 include_once "./classes/class.ilMetaDataGUI.php";
00041 include_once "./assessment/classes/class.assQuestionGUI.php";
00042 
00043 define ("TYPE_XLS_PC", "latin1");
00044 define ("TYPE_XLS_MAC", "macos");
00045 define ("TYPE_SPSS", "csv");
00046 
00047 class ilObjTestGUI extends ilObjectGUI
00048 {
00049         var $sequence;
00054         function ilObjTestGUI($a_data,$a_id,$a_call_by_reference = true, $a_prepare_output = true)
00055         {
00056                 global $lng, $ilCtrl;
00057                 $lng->loadLanguageModule("assessment");
00058                 $this->type = "tst";
00059                 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference, false);
00060                 if (!defined("ILIAS_MODULE"))
00061                 {
00062                         $this->setTabTargetScript("adm_object.php");
00063                 }
00064                 else
00065                 {
00066                         $this->setTabTargetScript("test.php");
00067                 }
00068                 if ($a_prepare_output) {
00069                         $this->prepareOutput();
00070                 }
00071 
00072                 $this->ctrl =& $ilCtrl;
00073                 $this->ctrl->saveParameter($this, "ref_id");
00074 
00075                 // Added parameter if called from crs_objectives
00076                 if((int) $_GET['crs_show_result'])
00077                 {
00078                         $this->ctrl->saveParameter($this,'crs_show_result',(int) $_GET['crs_show_result']);
00079                 }
00080         }
00081 
00085         function &executeCommand()
00086         {
00087                 $cmd = $this->ctrl->getCmd("properties");
00088                 $next_class = $this->ctrl->getNextClass($this);
00089                 $this->ctrl->setReturn($this, "properties");
00090 
00091                 #echo "<br>nextclass:$next_class:cmd:$cmd:qtype=$q_type";
00092                 switch($next_class)
00093                 {
00094                         default:
00095                                 switch ($cmd)
00096                                 {
00097                                         case "run":
00098                                         case "eval_a":
00099                                         case "eval_stat":
00100                                         case "evalStatSelected":
00101                                         case "searchForEvaluation":
00102                                         case "addFoundGroupsToEval":
00103                                         case "removeSelectedGroup":
00104                                         case "removeSelectedUser":
00105                                         case "addFoundUsersToEval":
00106                                         case "evalSelectedUsers":
00107                                         case "evalAllUsers":
00108                                                 break;
00109                                         default:
00110                                                 $this->setAdminTabs();
00111                                 }
00112                                 if ((strcmp($cmd, "properties") == 0) && ($_GET["browse"]))
00113                                 {
00114                                         $this->questionBrowser();
00115                                         return;
00116                                 }
00117                                 if ((strcmp($cmd, "properties") == 0) && ($_GET["up"] || $_GET["down"]))
00118                                 {
00119                                         $this->questionsObject();
00120                                         return;
00121                                 }
00122                                 $cmd.= "Object";
00123                                 $ret =& $this->$cmd();
00124                                 break;
00125                 }
00126         }
00127 
00133         function getCallingScript()
00134         {
00135                 return "test.php";
00136         }
00137         
00141         function importFileObject()
00142         {
00143                 if ($_POST["qpl"] < 1)
00144                 {
00145                         sendInfo($this->lng->txt("tst_select_questionpools"));
00146                         $this->createObject();
00147                         return;
00148                 }
00149                 if (strcmp($_FILES["xmldoc"]["tmp_name"], "") == 0)
00150                 {
00151                         sendInfo($this->lng->txt("tst_select_file_for_import"));
00152                         $this->createObject();
00153                         return;
00154                 }
00155                 $this->uploadObject(false);
00156                 ilUtil::redirect($this->getReturnLocation("post","$returnlocation?".$this->link_params));
00157 //              ilUtil::redirect($this->getCallingScript() . "?".$this->link_params);
00158         }
00159         
00163         function cloneAllObject()
00164         {
00165                 if ($_POST["tst"] < 1)
00166                 {
00167                         sendInfo($this->lng->txt("tst_select_tsts"));
00168                         $this->createObject();
00169                         return;
00170                 }
00171                 include_once "./assessment/classes/class.ilObjTest.php";
00172                 ilObjTest::_clone($_POST["tst"]);
00173                 ilUtil::redirect($this->getReturnLocation("post","$returnlocation?".$this->link_params));
00174 //              ilUtil::redirect($this->getCallingScript() . "?".$this->link_params);
00175         }
00176         
00181         function saveObject()
00182         {
00183                 global $rbacadmin;
00184 
00185                 // create and insert forum in objecttree
00186                 $newObj = parent::saveObject();
00187 
00188                 // setup rolefolder & default local roles
00189                 //$roles = $newObj->initDefaultRoles();
00190 
00191                 // ...finally assign role to creator of object
00192                 //$rbacadmin->assignUser($roles[0], $newObj->getOwner(), "y");
00193 
00194                 // put here object specific stuff
00195 
00196                 // always send a message
00197                 sendInfo($this->lng->txt("object_added"),true);
00198 
00199                 $returnlocation = "test.php";
00200                 if (!defined("ILIAS_MODULE"))
00201                 {
00202                         $returnlocation = "adm_object.php";
00203                 }
00204                 ilUtil::redirect($this->getReturnLocation("save","$returnlocation?".$this->link_params));
00205                 exit();
00206         }
00207 
00208         function getAddParameter()
00209         {
00210                 return "?ref_id=" . $_GET["ref_id"] . "&cmd=" . $_GET["cmd"] . '&crs_show_result='. (int) $_GET['crs_show_result'];
00211         }
00212 
00213         /*
00214         * list all export files
00215         */
00216         function exportObject()
00217         {
00218                 global $tree;
00219                 global $rbacsystem;
00220 
00221                 if ((!$rbacsystem->checkAccess("read", $this->ref_id)) && (!$rbacsystem->checkAccess("write", $this->ref_id))) 
00222                 {
00223                         // allow only read and write access
00224                         sendInfo($this->lng->txt("cannot_edit_test"), true);
00225                         $path = $this->tree->getPathFull($this->object->getRefID());
00226                         ilUtil::redirect($this->getReturnLocation("cancel","../repository.php?ref_id=" . $path[count($path) - 2]["child"]));
00227                         return;
00228                 }
00229 
00230                 //$this->setTabs();
00231 
00232                 //add template for view button
00233                 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00234 
00235                 // create export file button
00236                 $this->tpl->setCurrentBlock("btn_cell");
00237                 $this->tpl->setVariable("BTN_LINK", "test.php?ref_id=".$_GET["ref_id"]."&cmd=createExportFile");
00238                 $this->tpl->setVariable("BTN_TXT", $this->lng->txt("ass_create_export_file"));
00239                 $this->tpl->parseCurrentBlock();
00240 
00241                 // view last export log button
00242                 /*
00243                 if (is_file($this->object->getExportDirectory()."/export.log"))
00244                 {
00245                         $this->tpl->setCurrentBlock("btn_cell");
00246                         $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "viewExportLog"));
00247                         $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_view_last_export_log"));
00248                         $this->tpl->parseCurrentBlock();
00249                 }*/
00250 
00251                 $export_dir = $this->object->getExportDirectory();
00252 
00253                 $export_files = $this->object->getExportFiles($export_dir);
00254 
00255                 // create table
00256                 include_once("classes/class.ilTableGUI.php");
00257                 $tbl = new ilTableGUI();
00258 
00259                 // load files templates
00260                 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
00261 
00262                 // load template for table content data
00263                 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.export_file_row.html", true);
00264 
00265                 $num = 0;
00266 
00267                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00268 
00269                 $tbl->setTitle($this->lng->txt("ass_export_files"));
00270 
00271                 $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"),
00272                         $this->lng->txt("ass_size"), $this->lng->txt("date") ));
00273 
00274                 $tbl->enabled["sort"] = false;
00275                 $tbl->setColumnWidth(array("1%", "49%", "25%", "25%"));
00276 
00277                 // control
00278                 $tbl->setOrderColumn($_GET["sort_by"]);
00279                 $tbl->setOrderDirection($_GET["sort_order"]);
00280                 $tbl->setLimit($_GET["limit"]);
00281                 $tbl->setOffset($_GET["offset"]);
00282                 $tbl->setMaxCount($this->maxcount);             // ???
00283 
00284 
00285                 $this->tpl->setVariable("COLUMN_COUNTS", 4);
00286 
00287                 // delete button
00288                 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
00289                 $this->tpl->setCurrentBlock("tbl_action_btn");
00290                 $this->tpl->setVariable("BTN_NAME", "confirmDeleteExportFile");
00291                 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
00292                 $this->tpl->parseCurrentBlock();
00293 
00294                 $this->tpl->setCurrentBlock("tbl_action_btn");
00295                 $this->tpl->setVariable("BTN_NAME", "downloadExportFile");
00296                 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("download"));
00297                 $this->tpl->parseCurrentBlock();
00298 
00299                 // footer
00300                 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
00301                 //$tbl->disable("footer");
00302 
00303                 $tbl->setMaxCount(count($export_files));
00304                 $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
00305 
00306                 $tbl->render();
00307                 if(count($export_files) > 0)
00308                 {
00309                         $i=0;
00310                         foreach($export_files as $exp_file)
00311                         {
00312                                 $this->tpl->setCurrentBlock("tbl_content");
00313                                 $this->tpl->setVariable("TXT_FILENAME", $exp_file);
00314 
00315                                 $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
00316                                 $this->tpl->setVariable("CSS_ROW", $css_row);
00317 
00318                                 $this->tpl->setVariable("TXT_SIZE", filesize($export_dir."/".$exp_file));
00319                                 $this->tpl->setVariable("CHECKBOX_ID", $exp_file);
00320 
00321                                 $file_arr = explode("__", $exp_file);
00322                                 $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s",$file_arr[0]));
00323 
00324                                 $this->tpl->parseCurrentBlock();
00325                         }
00326                 } //if is_array
00327                 else
00328                 {
00329                         $this->tpl->setCurrentBlock("notfound");
00330                         $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
00331                         $this->tpl->setVariable("NUM_COLS", 3);
00332                         $this->tpl->parseCurrentBlock();
00333                 }
00334 
00335                 $this->tpl->parseCurrentBlock();
00336         }
00337 
00338         
00342         function createExportFileObject()
00343         {
00344                 global $rbacsystem;
00345                 
00346                 if ($rbacsystem->checkAccess("write", $this->ref_id))
00347                 {
00348                         include_once("assessment/classes/class.ilTestExport.php");
00349                         $test_exp = new ilTestExport($this->object);
00350                         $test_exp->buildExportFile();
00351                 }
00352                 else
00353                 {
00354                         sendInfo("cannot_export_test");
00355                 }
00356                 $this->exportObject();
00357         }
00358         
00362         function downloadExportFileObject()
00363         {
00364                 if(!isset($_POST["file"]))
00365                 {
00366                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00367                 }
00368 
00369                 if (count($_POST["file"]) > 1)
00370                 {
00371                         $this->ilias->raiseError($this->lng->txt("select_max_one_item"),$this->ilias->error_obj->MESSAGE);
00372                 }
00373 
00374 
00375                 $export_dir = $this->object->getExportDirectory();
00376                 ilUtil::deliverFile($export_dir."/".$_POST["file"][0],
00377                         $_POST["file"][0]);
00378         }
00379 
00383         function confirmDeleteExportFileObject()
00384         {
00385                 if(!isset($_POST["file"]))
00386                 {
00387                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00388                 }
00389 
00390                 //$this->setTabs();
00391 
00392                 // SAVE POST VALUES
00393                 $_SESSION["ilExportFiles"] = $_POST["file"];
00394 
00395                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html", true);
00396 
00397                 sendInfo($this->lng->txt("info_delete_sure"));
00398 
00399                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00400 
00401                 // BEGIN TABLE HEADER
00402                 $this->tpl->setCurrentBlock("table_header");
00403                 $this->tpl->setVariable("TEXT",$this->lng->txt("objects"));
00404                 $this->tpl->parseCurrentBlock();
00405 
00406                 // BEGIN TABLE DATA
00407                 $counter = 0;
00408                 foreach($_POST["file"] as $file)
00409                 {
00410                                 $this->tpl->setCurrentBlock("table_row");
00411                                 $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
00412                                 $this->tpl->setVariable("TEXT_CONTENT", $file);
00413                                 $this->tpl->parseCurrentBlock();
00414                 }
00415 
00416                 // cancel/confirm button
00417                 $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
00418                 $buttons = array( "cancelDeleteExportFile"  => $this->lng->txt("cancel"),
00419                         "deleteExportFile"  => $this->lng->txt("confirm"));
00420                 foreach ($buttons as $name => $value)
00421                 {
00422                         $this->tpl->setCurrentBlock("operation_btn");
00423                         $this->tpl->setVariable("BTN_NAME",$name);
00424                         $this->tpl->setVariable("BTN_VALUE",$value);
00425                         $this->tpl->parseCurrentBlock();
00426                 }
00427         }
00428 
00429 
00433         function cancelDeleteExportFileObject()
00434         {
00435                 session_unregister("ilExportFiles");
00436                 ilUtil::redirect("test.php?cmd=export&ref_id=".$_GET["ref_id"]);
00437         }
00438 
00439 
00443         function deleteExportFileObject()
00444         {
00445                 $export_dir = $this->object->getExportDirectory();
00446                 foreach($_SESSION["ilExportFiles"] as $file)
00447                 {
00448                         $exp_file = $export_dir."/".$file;
00449                         $exp_dir = $export_dir."/".substr($file, 0, strlen($file) - 4);
00450                         if (@is_file($exp_file))
00451                         {
00452                                 unlink($exp_file);
00453                         }
00454                         if (@is_dir($exp_dir))
00455                         {
00456                                 ilUtil::delDir($exp_dir);
00457                         }
00458                 }
00459                 ilUtil::redirect("test.php?cmd=export&ref_id=".$_GET["ref_id"]);
00460         }
00461 
00467         function importObject()
00468         {
00469                 $this->getTemplateFile("import", "tst");
00470                 $this->tpl->setCurrentBlock("option_qpl");
00471                 include_once("./assessment/classes/class.ilObjTest.php");
00472                 $tst = new ilObjTest();
00473                 $questionpools =& $tst->getAvailableQuestionpools(true);
00474                 if (count($questionpools) == 0)
00475                 {
00476                 }
00477                 else
00478                 {
00479                         foreach ($questionpools as $key => $value)
00480                         {
00481                                 $this->tpl->setCurrentBlock("option_qpl");
00482                                 $this->tpl->setVariable("OPTION_VALUE", $key);
00483                                 $this->tpl->setVariable("TXT_OPTION", $value);
00484                                 $this->tpl->parseCurrentBlock();
00485                         }
00486                 }
00487                 $this->tpl->setVariable("TXT_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool"));
00488                 $this->tpl->setVariable("OPTION_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool_option"));
00489                 $this->tpl->setVariable("FORMACTION", "adm_object.php?&ref_id=".$_GET["ref_id"]."&cmd=gateway&new_type=".$this->type);
00490                 $this->tpl->setVariable("BTN_NAME", "upload");
00491                 $this->tpl->setVariable("TXT_UPLOAD", $this->lng->txt("upload"));
00492                 $this->tpl->setVariable("TXT_IMPORT_TST", $this->lng->txt("import_tst"));
00493                 $this->tpl->setVariable("TXT_SELECT_MODE", $this->lng->txt("select_mode"));
00494                 $this->tpl->setVariable("TXT_SELECT_FILE", $this->lng->txt("select_file"));
00495 
00496         }
00497 
00504         function uploadObject($redirect = true)
00505         {
00506                 if ($_POST["qpl"] < 1)
00507                 {
00508                         sendInfo($this->lng->txt("tst_select_questionpools"));
00509                         $this->importObject();
00510                         return;
00511                 }
00512                 
00513                 if ($_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK)
00514                 {
00515                         sendInfo($this->lng->txt("tst_select_questionpools"));
00516                         $this->importObject();
00517                         return;
00518                 }
00519                 
00520                 include_once("./assessment/classes/class.ilObjTest.php");
00521                 $newObj = new ilObjTest();
00522                 $newObj->setType($_GET["new_type"]);
00523                 $newObj->setTitle("dummy");
00524                 $newObj->setDescription("dummy");
00525                 $newObj->create(true);
00526                 $newObj->createReference();
00527                 $newObj->putInTree($_GET["ref_id"]);
00528                 $newObj->setPermissions($_GET["ref_id"]);
00529                 $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
00530 
00531                 // create import directory
00532                 $newObj->createImportDirectory();
00533 
00534                 // copy uploaded file to import directory
00535                 $file = pathinfo($_FILES["xmldoc"]["name"]);
00536                 $full_path = $newObj->getImportDirectory()."/".$_FILES["xmldoc"]["name"];
00537                 ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"], $_FILES["xmldoc"]["name"], $full_path);
00538                 //move_uploaded_file($_FILES["xmldoc"]["tmp_name"], $full_path);
00539 
00540                 // unzip file
00541                 ilUtil::unzip($full_path);
00542 
00543                 // determine filename of xml file
00544                 $subdir = basename($file["basename"],".".$file["extension"]);
00545                 $xml_file = $newObj->getImportDirectory()."/".$subdir."/".$subdir.".xml";
00546                 $qti_file = $newObj->getImportDirectory()."/".$subdir."/".
00547                         str_replace("test", "qti", $subdir).".xml";
00548                 
00549                 // import qti data
00550                 $qtiresult = $newObj->importObject($qti_file, $_POST["qpl"]);
00551 //              $tmp_title = $newObj->getTitle();
00552 //              $tmp_descr = $newObj->getDescription();
00553                 // import page data
00554                 include_once ("content/classes/class.ilContObjParser.php");
00555                 $contParser = new ilContObjParser($newObj, $xml_file, $subdir);
00556                 $contParser->setQuestionMapping($newObj->getImportMapping());
00557                 $contParser->startParsing();
00558 
00559                 /* update title and description in object data */
00560                 if (is_object($newObj->meta_data))
00561                 {
00562                         // read the object metadata from the nested set tables
00563                         //$meta_data =& new ilMetaData($newObj->getType(), $newObj->getId());
00564                         //$newObj->meta_data = $meta_data;
00565                         //$newObj->setTitle($newObj->meta_data->getTitle());
00566                         //$newObj->setDescription($newObj->meta_data->getDescription());
00567                         ilObject::_writeTitle($newObj->getID(), $newObj->getTitle());
00568                         ilObject::_writeDescription($newObj->getID(), $newObj->getDescription());
00569                 }
00570 
00571                 $newObj->saveToDb();
00572 
00573                 // delete import directory
00574                 ilUtil::delDir($newObj->getImportDirectory());
00575                 
00576                 if ($redirect)
00577                 {
00578                         ilUtil::redirect("adm_object.php?".$this->link_params);
00579                 }
00580         }
00581 
00589         function savePropertiesObject()
00590         {
00591                 $total = $this->object->evalTotalPersons();
00592                 $deleteuserdata = false;
00593                 $randomtest_switch = false;
00594                 // Check the values the user entered in the form
00595                 if (!$total)
00596                 {
00597                         $data["sel_test_types"] = ilUtil::stripSlashes($_POST["sel_test_types"]);
00598                         if (!strlen($_POST["chb_random"]))
00599                         {
00600                                 $data["random_test"] = 0;
00601                         }
00602                         else
00603                         {
00604                                 $data["random_test"] = ilUtil::stripSlashes($_POST["chb_random"]);
00605                         }
00606                 }
00607                 else
00608                 {
00609                         $data["sel_test_types"] = $this->object->getTestType();
00610                         $data["random_test"] = $this->object->random_test;
00611                 }
00612                 if ($data["sel_test_types"] != $this->object->getTestType())
00613                 {
00614                         $deleteuserdata = true;
00615                 }
00616                 if ($data["random_test"] != $this->object->random_test)
00617                 {
00618                         $randomtest_switch = true;
00619                 }
00620                 $data["title"] = ilUtil::stripSlashes($_POST["title"]);
00621                 $data["description"] = ilUtil::stripSlashes($_POST["description"]);
00622                 $data["author"] = ilUtil::stripSlashes($_POST["author"]);
00623                 $data["introduction"] = ilUtil::stripSlashes($_POST["introduction"]);
00624                 $data["sequence_settings"] = ilUtil::stripSlashes($_POST["sequence_settings"]);
00625                 if ($this->object->getTestType() == TYPE_ASSESSMENT)
00626                 {
00627                         $data["score_reporting"] = REPORT_AFTER_TEST;
00628                 }
00629                 else
00630                 {
00631                         $data["score_reporting"] = ilUtil::stripSlashes($_POST["score_reporting"]);
00632                 }
00633                 $data["nr_of_tries"] = ilUtil::stripSlashes($_POST["nr_of_tries"]);
00634                 $data["processing_time"] = ilUtil::stripSlashes($_POST["processing_time"]);
00635                 if (!$_POST["chb_starting_time"])
00636                 {
00637                         $data["starting_time"] = "";
00638                 }
00639                 else
00640                 {
00641                         $data["starting_time"] = sprintf("%04d%02d%02d%02d%02d%02d",
00642                                 $_POST["starting_date"]["y"],
00643                                 $_POST["starting_date"]["m"],
00644                                 $_POST["starting_date"]["d"],
00645                                 $_POST["starting_time"]["h"],
00646                                 $_POST["starting_time"]["m"],
00647                                 0
00648                         );
00649                 }
00650                 if (!$_POST["chb_ending_time"])
00651                 {
00652                         $data["ending_time"] = "";
00653                 }
00654                 else
00655                 {
00656                         $data["ending_time"] = sprintf("%04d%02d%02d%02d%02d%02d",
00657                                 $_POST["ending_date"]["y"],
00658                                 $_POST["ending_date"]["m"],
00659                                 $_POST["ending_date"]["d"],
00660                                 $_POST["ending_time"]["h"],
00661                                 $_POST["ending_time"]["m"],
00662                                 0
00663                         );
00664                 }
00665 
00666                 if ($_POST["chb_processing_time"])
00667                 {
00668                         $data["enable_processing_time"] = "1";
00669                 }
00670                 else
00671                 {
00672                         $data["enable_processing_time"] = "0";
00673                 }
00674 
00675                 if ($data["enable_processing_time"])
00676                 {
00677                         $data["processing_time"] = sprintf("%02d:%02d:%02d",
00678                                 $_POST["processing_time"]["h"],
00679                                 $_POST["processing_time"]["m"],
00680                                 $_POST["processing_time"]["s"]
00681                         );
00682                 }
00683                 else
00684                 {
00685                         $proc_time = $this->object->getEstimatedWorkingTime();
00686                         $data["processing_time"] = sprintf("%02d:%02d:%02d",
00687                                 $proc_time["h"],
00688                                 $proc_time["m"],
00689                                 $proc_time["s"]
00690                         );
00691                 }
00692 
00693                 if (!$_POST["chb_reporting_date"])
00694                 {
00695                         $data["reporting_date"] = "";
00696                 }
00697                 else
00698                 {
00699                         $data["reporting_date"] = sprintf("%04d%02d%02d%02d%02d%02d",
00700                                 $_POST["reporting_date"]["y"],
00701                                 $_POST["reporting_date"]["m"],
00702                                 $_POST["reporting_date"]["d"],
00703                                 $_POST["reporting_time"]["h"],
00704                                 $_POST["reporting_time"]["m"],
00705                                 0
00706                         );
00707                 }
00708                 $this->object->setTestType($data["sel_test_types"]);
00709                 $this->object->setTitle($data["title"]);
00710                 $this->object->setDescription($data["description"]);
00711                 $this->object->setAuthor($data["author"]);
00712                 $this->object->setIntroduction($data["introduction"]);
00713                 $this->object->setSequenceSettings($data["sequence_settings"]);
00714                 if ($this->object->getTestType() == TYPE_ASSESSMENT)
00715                 {
00716                         $this->object->setScoreReporting(REPORT_AFTER_TEST);
00717                 }
00718                 else
00719                 {
00720                         $this->object->setScoreReporting($data["score_reporting"]);
00721                 }
00722                 $this->object->setReportingDate($data["reporting_date"]);
00723                 $this->object->setNrOfTries($data["nr_of_tries"]);
00724                 $this->object->setStartingTime($data["starting_time"]);
00725                 $this->object->setEndingTime($data["ending_time"]);
00726                 $this->object->setProcessingTime($data["processing_time"]);
00727                 $this->object->setRandomTest($data["random_test"]);
00728                 $this->object->setEnableProcessingTime($data["enable_processing_time"]);
00729 
00730                 $this->object->updateTitleAndDescription();
00731                 $this->update = $this->object->update();
00732                 $this->object->saveToDb(true);
00733 
00734                 if ($deleteuserdata)
00735                 {
00736                         $this->object->removeAllTestEditings();
00737                 }
00738                 sendInfo($this->lng->txt("msg_obj_modified"));
00739                 if ($randomtest_switch)
00740                 {
00741                         if ($this->object->isRandomTest())
00742                         {
00743                                 $this->object->removeNonRandomTestData();
00744                         }
00745                         else
00746                         {
00747                                 $this->object->removeRandomTestData();
00748                         }
00749                 }
00750                 $this->propertiesObject();
00751         }
00752         
00760         function cancelPropertiesObject()
00761         {
00762                 sendInfo($this->lng->txt("msg_cancel"), true);
00763                 $path = $this->tree->getPathFull($this->object->getRefID());
00764                 ilUtil::redirect($this->getReturnLocation("cancel","../repository.php?cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
00765         }
00766         
00774         function propertiesObject()
00775         {
00776                 global $rbacsystem;
00777                 $total = $this->object->evalTotalPersons();
00778                 if (($data["sel_test_types"] == TYPE_ASSESSMENT) || ($this->object->getTestType() == TYPE_ASSESSMENT && strlen($data["sel_test_types"]) == 0)) 
00779                 {
00780                         $this->lng->loadLanguageModule("jscalendar");
00781                         $this->tpl->addBlockFile("CALENDAR_LANG_JAVASCRIPT", "calendar_javascript", "tpl.calendar.html");
00782                         $this->tpl->setCurrentBlock("calendar_javascript");
00783                         $this->tpl->setVariable("FULL_SUNDAY", $this->lng->txt("l_su"));
00784                         $this->tpl->setVariable("FULL_MONDAY", $this->lng->txt("l_mo"));
00785                         $this->tpl->setVariable("FULL_TUESDAY", $this->lng->txt("l_tu"));
00786                         $this->tpl->setVariable("FULL_WEDNESDAY", $this->lng->txt("l_we"));
00787                         $this->tpl->setVariable("FULL_THURSDAY", $this->lng->txt("l_th"));
00788                         $this->tpl->setVariable("FULL_FRIDAY", $this->lng->txt("l_fr"));
00789                         $this->tpl->setVariable("FULL_SATURDAY", $this->lng->txt("l_sa"));
00790                         $this->tpl->setVariable("SHORT_SUNDAY", $this->lng->txt("s_su"));
00791                         $this->tpl->setVariable("SHORT_MONDAY", $this->lng->txt("s_mo"));
00792                         $this->tpl->setVariable("SHORT_TUESDAY", $this->lng->txt("s_tu"));
00793                         $this->tpl->setVariable("SHORT_WEDNESDAY", $this->lng->txt("s_we"));
00794                         $this->tpl->setVariable("SHORT_THURSDAY", $this->lng->txt("s_th"));
00795                         $this->tpl->setVariable("SHORT_FRIDAY", $this->lng->txt("s_fr"));
00796                         $this->tpl->setVariable("SHORT_SATURDAY", $this->lng->txt("s_sa"));
00797                         $this->tpl->setVariable("FULL_JANUARY", $this->lng->txt("l_01"));
00798                         $this->tpl->setVariable("FULL_FEBRUARY", $this->lng->txt("l_02"));
00799                         $this->tpl->setVariable("FULL_MARCH", $this->lng->txt("l_03"));
00800                         $this->tpl->setVariable("FULL_APRIL", $this->lng->txt("l_04"));
00801                         $this->tpl->setVariable("FULL_MAY", $this->lng->txt("l_05"));
00802                         $this->tpl->setVariable("FULL_JUNE", $this->lng->txt("l_06"));
00803                         $this->tpl->setVariable("FULL_JULY", $this->lng->txt("l_07"));
00804                         $this->tpl->setVariable("FULL_AUGUST", $this->lng->txt("l_08"));
00805                         $this->tpl->setVariable("FULL_SEPTEMBER", $this->lng->txt("l_09"));
00806                         $this->tpl->setVariable("FULL_OCTOBER", $this->lng->txt("l_10"));
00807                         $this->tpl->setVariable("FULL_NOVEMBER", $this->lng->txt("l_11"));
00808                         $this->tpl->setVariable("FULL_DECEMBER", $this->lng->txt("l_12"));
00809                         $this->tpl->setVariable("SHORT_JANUARY", $this->lng->txt("s_01"));
00810                         $this->tpl->setVariable("SHORT_FEBRUARY", $this->lng->txt("s_02"));
00811                         $this->tpl->setVariable("SHORT_MARCH", $this->lng->txt("s_03"));
00812                         $this->tpl->setVariable("SHORT_APRIL", $this->lng->txt("s_04"));
00813                         $this->tpl->setVariable("SHORT_MAY", $this->lng->txt("s_05"));
00814                         $this->tpl->setVariable("SHORT_JUNE", $this->lng->txt("s_06"));
00815                         $this->tpl->setVariable("SHORT_JULY", $this->lng->txt("s_07"));
00816                         $this->tpl->setVariable("SHORT_AUGUST", $this->lng->txt("s_08"));
00817                         $this->tpl->setVariable("SHORT_SEPTEMBER", $this->lng->txt("s_09"));
00818                         $this->tpl->setVariable("SHORT_OCTOBER", $this->lng->txt("s_10"));
00819                         $this->tpl->setVariable("SHORT_NOVEMBER", $this->lng->txt("s_11"));
00820                         $this->tpl->setVariable("SHORT_DECEMBER", $this->lng->txt("s_12"));
00821                         $this->tpl->setVariable("ABOUT_CALENDAR", $this->lng->txt("about_calendar"));
00822                         $this->tpl->setVariable("ABOUT_CALENDAR_LONG", $this->lng->txt("about_calendar_long"));
00823                         $this->tpl->setVariable("ABOUT_TIME_LONG", $this->lng->txt("about_time"));
00824                         $this->tpl->setVariable("PREV_YEAR", $this->lng->txt("prev_year"));
00825                         $this->tpl->setVariable("PREV_MONTH", $this->lng->txt("prev_month"));
00826                         $this->tpl->setVariable("GO_TODAY", $this->lng->txt("go_today"));
00827                         $this->tpl->setVariable("NEXT_MONTH", $this->lng->txt("next_month"));
00828                         $this->tpl->setVariable("NEXT_YEAR", $this->lng->txt("next_year"));
00829                         $this->tpl->setVariable("SEL_DATE", $this->lng->txt("select_date"));
00830                         $this->tpl->setVariable("DRAG_TO_MOVE", $this->lng->txt("drag_to_move"));
00831                         $this->tpl->setVariable("PART_TODAY", $this->lng->txt("part_today"));
00832                         $this->tpl->setVariable("DAY_FIRST", $this->lng->txt("day_first"));
00833                         $this->tpl->setVariable("CLOSE", $this->lng->txt("close"));
00834                         $this->tpl->setVariable("TODAY", $this->lng->txt("today"));
00835                         $this->tpl->setVariable("TIME_PART", $this->lng->txt("time_part"));
00836                         $this->tpl->setVariable("DEF_DATE_FORMAT", $this->lng->txt("def_date_format"));
00837                         $this->tpl->setVariable("TT_DATE_FORMAT", $this->lng->txt("tt_date_format"));
00838                         $this->tpl->setVariable("WK", $this->lng->txt("wk"));
00839                         $this->tpl->setVariable("TIME", $this->lng->txt("time"));
00840                         $this->tpl->parseCurrentBlock();
00841                         $this->tpl->setCurrentBlock("CalendarJS");
00842                         $this->tpl->setVariable("LOCATION_JAVASCRIPT_CALENDAR", ilUtil::getJSPath("calendar.js"));
00843                         $this->tpl->setVariable("LOCATION_JAVASCRIPT_CALENDAR_SETUP", ilUtil::getJSPath("calendar-setup.js"));
00844                         $this->tpl->setVariable("LOCATION_JAVASCRIPT_CALENDAR_STYLESHEET", ilUtil::getJSPath("calendar.css"));
00845                         $this->tpl->parseCurrentBlock();
00846                         $this->tpl->setCurrentBlock("javascript_call_calendar");
00847                         $this->tpl->setVariable("INPUT_FIELDS_STARTING_DATE", "starting_date");
00848                         $this->tpl->setVariable("INPUT_FIELDS_ENDING_DATE", "ending_date");
00849                         $this->tpl->setVariable("INPUT_FIELDS_REPORTING_DATE", "reporting_date");
00850                         $this->tpl->parseCurrentBlock();
00851                 }
00852                 if ((!$rbacsystem->checkAccess("read", $this->ref_id)) && (!$rbacsystem->checkAccess("write", $this->ref_id))) 
00853                 {
00854                         // allow only read and write access
00855                         sendInfo($this->lng->txt("cannot_edit_test"), true);
00856                         $path = $this->tree->getPathFull($this->object->getRefID());
00857                         ilUtil::redirect($this->getReturnLocation("cancel","../repository.php?cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
00858                         return;
00859                 }
00860                 
00861                 $data["sel_test_types"] = $this->object->getTestType();
00862                 $data["author"] = $this->object->getAuthor();
00863                 $data["introduction"] = $this->object->getIntroduction();
00864                 $data["sequence_settings"] = $this->object->getSequenceSettings();
00865                 $data["score_reporting"] = $this->object->getScoreReporting();
00866                 $data["reporting_date"] = $this->object->getReportingDate();
00867                 $data["nr_of_tries"] = $this->object->getNrOfTries();
00868                 $data["enable_processing_time"] = $this->object->getEnableProcessingTime();
00869                 $data["processing_time"] = $this->object->getProcessingTime();
00870                 $data["random_test"] = $this->object->isRandomTest();
00871                 if ((int)substr($data["processing_time"], 0, 2) + (int)substr($data["processing_time"], 3, 2) + (int)substr($data["processing_time"], 6, 2) == 0)
00872                 {
00873                         $proc_time = $this->object->getEstimatedWorkingTime();
00874                         $data["processing_time"] = sprintf("%02d:%02d:%02d",
00875                                 $proc_time["h"],
00876                                 $proc_time["m"],
00877                                 $proc_time["s"]
00878                         );
00879                 }
00880                 $data["starting_time"] = $this->object->getStartingTime();
00881                 $data["ending_time"] = $this->object->getEndingTime();
00882                 $data["title"] = $this->object->getTitle();
00883                 $data["description"] = $this->object->getDescription();
00884                 if ($data["sel_test_types"] == TYPE_ASSESSMENT)
00885                 {
00886                         $this->tpl->setCurrentBlock("starting_time");
00887                         $this->tpl->setVariable("TEXT_STARTING_TIME", $this->lng->txt("tst_starting_time"));
00888                         if (!$data["starting_time"])
00889                         {
00890                                 $date_input = ilUtil::makeDateSelect("starting_date");
00891                                 $time_input = ilUtil::makeTimeSelect("starting_time");
00892                         }
00893                         else
00894                         {
00895                                 preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $data["starting_time"], $matches);
00896                                 $date_input = ilUtil::makeDateSelect("starting_date", $matches[1], sprintf("%d", $matches[2]), sprintf("%d", $matches[3]));
00897                                 $time_input = ilUtil::makeTimeSelect("starting_time", true, sprintf("%d", $matches[4]), sprintf("%d", $matches[5]), sprintf("%d", $matches[6]));
00898                         }
00899                         $this->tpl->setVariable("IMG_STARTING_TIME_CALENDAR", ilUtil::getImagePath("calendar.png"));
00900                         $this->tpl->setVariable("TXT_STARTING_TIME_CALENDAR", $this->lng->txt("open_calendar"));
00901                         $this->tpl->setVariable("TXT_ENABLED", $this->lng->txt("enabled"));
00902                         if ($data["starting_time"])
00903                         {
00904                                 $this->tpl->setVariable("CHECKED_STARTING_TIME", " checked=\"checked\"");
00905                         }
00906                         $this->tpl->setVariable("INPUT_STARTING_TIME", $this->lng->txt("date") . ": " . $date_input . $this->lng->txt("time") . ": " . $time_input);
00907                         $this->tpl->parseCurrentBlock();
00908 
00909                         $this->tpl->setCurrentBlock("ending_time");
00910                         $this->tpl->setVariable("TEXT_ENDING_TIME", $this->lng->txt("tst_ending_time"));
00911                         if (!$data["ending_time"])
00912                         {
00913                                 $date_input = ilUtil::makeDateSelect("ending_date");
00914                                 $time_input = ilUtil::makeTimeSelect("ending_time");
00915                         }
00916                         else
00917                         {
00918                                 preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $data["ending_time"], $matches);
00919                                 $date_input = ilUtil::makeDateSelect("ending_date", $matches[1], sprintf("%d", $matches[2]), sprintf("%d", $matches[3]));
00920                                 $time_input = ilUtil::makeTimeSelect("ending_time", true, sprintf("%d", $matches[4]), sprintf("%d", $matches[5]), sprintf("%d", $matches[6]));
00921                         }
00922                         $this->tpl->setVariable("IMG_ENDING_TIME_CALENDAR", ilUtil::getImagePath("calendar.png"));
00923                         $this->tpl->setVariable("TXT_ENDING_TIME_CALENDAR", $this->lng->txt("open_calendar"));
00924                         $this->tpl->setVariable("TXT_ENABLED", $this->lng->txt("enabled"));
00925                         if ($data["ending_time"])
00926                         {
00927                                 $this->tpl->setVariable("CHECKED_ENDING_TIME", " checked=\"checked\"");
00928                         }
00929                         $this->tpl->setVariable("INPUT_ENDING_TIME", $this->lng->txt("date") . ": " . $date_input . $this->lng->txt("time") . ": " . $time_input);
00930                         $this->tpl->parseCurrentBlock();
00931 
00932                         $this->tpl->setCurrentBlock("reporting_date");
00933                         $this->tpl->setVariable("TEXT_SCORE_DATE", $this->lng->txt("tst_score_reporting_date"));
00934                         if (!$data["reporting_date"])
00935                         {
00936                                 $date_input = ilUtil::makeDateSelect("reporting_date");
00937                                 $time_input = ilUtil::makeTimeSelect("reporting_time");
00938                         } else {
00939                                 preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $data["reporting_date"], $matches);
00940                                 $date_input = ilUtil::makeDateSelect("reporting_date", $matches[1], sprintf("%d", $matches[2]), sprintf("%d", $matches[3]));
00941                                 $time_input = ilUtil::makeTimeSelect("reporting_time", true, sprintf("%d", $matches[4]), sprintf("%d", $matches[5]), sprintf("%d", $matches[6]));
00942                         }
00943                         $this->tpl->setVariable("IMG_REPORTING_DATE_CALENDAR", ilUtil::getImagePath("calendar.png"));
00944                         $this->tpl->setVariable("TXT_REPORTING_DATE_CALENDAR", $this->lng->txt("open_calendar"));
00945                         $this->tpl->setVariable("TXT_ENABLED", $this->lng->txt("enabled"));
00946                         if ($data["reporting_date"]) {
00947                                 $this->tpl->setVariable("CHECKED_REPORTING_DATE", " checked=\"checked\"");
00948                         }
00949                         $this->tpl->setVariable("INPUT_REPORTING_DATE", $this->lng->txt("date") . ": " . $date_input . $this->lng->txt("time") . ": " . $time_input);
00950                         $this->tpl->parseCurrentBlock();
00951                 }
00952 
00953                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_properties.html", true);
00954                 $this->tpl->setCurrentBlock("test_types");
00955                 foreach ($this->object->test_types as $key => $value) {
00956                         $this->tpl->setVariable("VALUE_TEST_TYPE", $key);
00957                         $this->tpl->setVariable("TEXT_TEST_TYPE", $this->lng->txt($value));
00958                         if ($data["sel_test_types"] == $key) {
00959                                 $this->tpl->setVariable("SELECTED_TEST_TYPE", " selected=\"selected\"");
00960                         }
00961                         $this->tpl->parseCurrentBlock();
00962                 }
00963                 $this->tpl->setCurrentBlock("adm_content");
00964                 $this->tpl->setVariable("ACTION_PROPERTIES", $this->ctrl->getFormAction($this));
00965                 if ($rbacsystem->checkAccess("write", $this->ref_id)) {
00966                         $this->tpl->setVariable("SUBMIT_TYPE", $this->lng->txt("change"));
00967                 }
00968                 $this->tpl->setVariable("HEADING_GENERAL", $this->lng->txt("tst_general_properties"));
00969                 $this->tpl->setVariable("TEXT_TEST_TYPES", $this->lng->txt("tst_types"));
00970                 $this->tpl->setVariable("TEST_TYPE_COMMENT", $this->lng->txt("tst_type_comment"));
00971                 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
00972                 $this->tpl->setVariable("VALUE_TITLE", ilUtil::prepareFormOutput($data["title"]));
00973                 $this->tpl->setVariable("TEXT_AUTHOR", $this->lng->txt("author"));
00974                 $this->tpl->setVariable("VALUE_AUTHOR", ilUtil::prepareFormOutput($data["author"]));
00975                 $this->tpl->setVariable("TEXT_DESCRIPTION", $this->lng->txt("description"));
00976                 $this->tpl->setVariable("VALUE_DESCRIPTION", ilUtil::prepareFormOutput($data["description"]));
00977                 $this->tpl->setVariable("TEXT_INTRODUCTION", $this->lng->txt("tst_introduction"));
00978                 $this->tpl->setVariable("VALUE_INTRODUCTION", $data["introduction"]);
00979                 $this->tpl->setVariable("HEADING_SEQUENCE", $this->lng->txt("tst_sequence_properties"));
00980                 $this->tpl->setVariable("TEXT_SEQUENCE", $this->lng->txt("tst_sequence"));
00981                 $this->tpl->setVariable("SEQUENCE_FIXED", $this->lng->txt("tst_sequence_fixed"));
00982                 $this->tpl->setVariable("SEQUENCE_POSTPONE", $this->lng->txt("tst_sequence_postpone"));
00983                 if ($data["sequence_settings"] == 0) {
00984                         $this->tpl->setVariable("SELECTED_FIXED", " selected=\"selected\"");
00985                 } elseif ($data["sequence_settings"] == 1) {
00986                         $this->tpl->setVariable("SELECTED_POSTPONE", " selected=\"selected\"");
00987                 }
00988                 $this->tpl->setVariable("HEADING_SCORE", $this->lng->txt("tst_score_reporting"));
00989                 $this->tpl->setVariable("TEXT_SCORE_TYPE", $this->lng->txt("tst_score_type"));
00990                 $this->tpl->setVariable("REPORT_AFTER_QUESTION", $this->lng->txt("tst_report_after_question"));
00991                 $this->tpl->setVariable("REPORT_AFTER_TEST", $this->lng->txt("tst_report_after_test"));
00992                 if ($data["sel_test_types"] == TYPE_ASSESSMENT) {
00993                         $this->tpl->setVariable("SELECTED_TEST", " selected=\"selected\"");
00994                         $this->tpl->setVariable("DISABLE_SCORE_REPORTING", " disabled=\"disabled\"");
00995                 } else {
00996                         if ($data["score_reporting"] == 0) {
00997                                 $this->tpl->setVariable("SELECTED_QUESTION", " selected=\"selected\"");
00998                         } elseif ($data["score_reporting"] == 1) {
00999                                 $this->tpl->setVariable("SELECTED_TEST", " selected=\"selected\"");
01000                         }
01001                 }
01002                 $this->tpl->setVariable("HEADING_SESSION", $this->lng->txt("tst_session_settings"));
01003                 $this->tpl->setVariable("TEXT_NR_OF_TRIES", $this->lng->txt("tst_nr_of_tries"));
01004                 $this->tpl->setVariable("VALUE_NR_OF_TRIES", $data["nr_of_tries"]);
01005                 $this->tpl->setVariable("COMMENT_NR_OF_TRIES", $this->lng->txt("0_unlimited"));
01006                 $this->tpl->setVariable("TEXT_PROCESSING_TIME", $this->lng->txt("tst_processing_time"));
01007                 $time_input = ilUtil::makeTimeSelect("processing_time", false, substr($data["processing_time"], 0, 2), substr($data["processing_time"], 3, 2), substr($data["processing_time"], 6, 2));
01008                 $this->tpl->setVariable("MAX_PROCESSING_TIME", $time_input . " (hh:mm:ss)");
01009                 if ($data["enable_processing_time"]) {
01010                         $this->tpl->setVariable("CHECKED_PROCESSING_TIME", " checked=\"checked\"");
01011                 }
01012                 $this->tpl->setVariable("TEXT_RANDOM_TEST", $this->lng->txt("tst_random_test"));
01013                 $this->tpl->setVariable("TEXT_RANDOM_TEST_DESCRIPTION", $this->lng->txt("tst_random_test_description"));
01014                 if ($data["random_test"]) {
01015                         $this->tpl->setVariable("CHECKED_RANDOM_TEST", " checked=\"checked\"");
01016                 }
01017 
01018 
01019                 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
01020                 if ($rbacsystem->checkAccess("write", $this->ref_id)) {
01021                         $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
01022                         $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
01023                 }
01024                 if ($total > 0)
01025                 {
01026                         $this->tpl->setVariable("ENABLED_TEST_TYPES", " disabled=\"disabled\"");
01027                         $this->tpl->setVariable("ENABLED_RANDOM_TEST", " disabled=\"disabled\"");
01028                 }
01029                 $this->tpl->parseCurrentBlock();
01030         }
01031 
01035         function downloadFileObject()
01036         {
01037                 $file = explode("_", $_GET["file_id"]);
01038                 include_once("classes/class.ilObjFile.php");
01039                 $fileObj =& new ilObjFile($file[count($file) - 1], false);
01040                 $fileObj->sendFile();
01041                 exit;
01042         }
01043         
01047         function fullscreenObject()
01048         {
01049                 include_once("content/classes/Pages/class.ilPageObjectGUI.php");
01050                 $page =& new ilPageObject("qpl", $_GET["pg_id"]);
01051                 $page_gui =& new ilPageObjectGUI($page);
01052                 $page_gui->showMediaFullscreen();
01053                 
01054         }
01055 
01059         function download_paragraphObject()
01060         {
01061                 include_once("content/classes/Pages/class.ilPageObject.php");
01062                 $pg_obj =& new ilPageObject("qpl", $_GET["pg_id"]);
01063                 $pg_obj->send_paragraph ($_GET["par_id"], $_GET["downloadtitle"]);
01064                 exit;
01065         }
01066 
01067         
01068         function filterObject()
01069         {
01070                 $filter_type = $_POST["sel_filter_type"];
01071                 if (!$filter_type)
01072                 {
01073                         $filter_type = $_GET["sel_filter_type"];
01074                 }
01075                 $filter_question_type = $_POST["sel_question_type"];
01076                 if (!$filter_question_type)
01077                 {
01078                         $filter_question_type = $_GET["sel_question_type"];
01079                 }
01080                 $filter_questionpool = $_POST["sel_questionpool"];
01081                 if (!$filter_questionpool)
01082                 {
01083                         $filter_questionpool = $_GET["sel_questionpool"];
01084                 }
01085                 $filter_text = $_POST["filter_text"];
01086                 if (!$filter_text)
01087                 {
01088                         $filter_text = $_GET["filter_text"];
01089                 }
01090                 $this->questionBrowser($filter_type, $filter_question_type, $filter_questionpool, $filter_text);
01091         }
01092 
01100         function resetFilterObject()
01101         {
01102                 $_GET["sel_filter_type"] = "";
01103                 $_GET["sel_question_type"] = "";
01104                 $_GET["sel_questionpool"] = "";
01105                 $_GET["filter_text"] = "";
01106                 $this->questionBrowser();
01107         }
01108 
01116         function confirmInsertQuestionsObject()
01117         {
01118                 foreach ($_POST as $key => $value) {
01119                         if (preg_match("/id_(\d+)/", $key, $matches)) {
01120                                 $this->object->insertQuestion($matches[1]);
01121                         }
01122                 }
01123                 $this->object->saveCompleteStatus();
01124                 sendInfo($this->lng->txt("tst_questions_inserted"), true);
01125                 $this->ctrl->redirect($this, "questions");
01126         }
01127         
01135         function cancelInsertQuestionsObject()
01136         {
01137                 $this->ctrl->redirect($this, "questions");
01138         }
01139 
01147         function backObject()
01148         {
01149                 $this->ctrl->redirect($this, "questions");
01150         }
01151         
01159         function confirmInsertQuestionsForm($checked_questions)
01160         {
01161                 sendInfo();
01162                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_insert_questions.html", true);
01163                 $where = "";
01164                 foreach ($checked_questions as $id)
01165                 {
01166                         $where .= sprintf(" OR qpl_questions.question_id = %s", $this->ilias->db->quote($id));
01167                 }
01168                 $where = preg_replace("/^ OR /", "", $where);
01169                 $where = "($where)";
01170                 $query = "SELECT qpl_questions.*, qpl_question_type.type_tag FROM qpl_questions, qpl_question_type WHERE ISNULL(qpl_questions.original_id) AND qpl_questions.question_type_fi = qpl_question_type.question_type_id AND $where";
01171                 $query_result = $this->ilias->db->query($query);
01172                 $colors = array("tblrow1", "tblrow2");
01173                 $counter = 0;
01174                 if ($query_result->numRows() > 0)
01175                 {
01176                         while ($data = $query_result->fetchRow(DB_FETCHMODE_OBJECT))
01177                         {
01178                                 if (in_array($data->question_id, $checked_questions))
01179                                 {
01180                                         $this->tpl->setCurrentBlock("row");
01181                                         $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
01182                                         $this->tpl->setVariable("TXT_TITLE", $data->title);
01183                                         $this->tpl->setVariable("TXT_DESCRIPTION", $data->comment);
01184                                         $this->tpl->setVariable("TXT_TYPE", $this->lng->txt($data->type_tag));
01185                                         $this->tpl->parseCurrentBlock();
01186                                         $counter++;
01187                                 }
01188                         }
01189                 }
01190                 foreach ($checked_questions as $id)
01191                 {
01192                         $this->tpl->setCurrentBlock("hidden");
01193                         $this->tpl->setVariable("HIDDEN_NAME", "id_$id");
01194                         $this->tpl->setVariable("HIDDEN_VALUE", "1");
01195                         $this->tpl->parseCurrentBlock();
01196                 }
01197 
01198                 $this->tpl->setCurrentBlock("adm_content");
01199                 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("tst_question_title"));
01200                 $this->tpl->setVariable("TXT_DESCRIPTION", $this->lng->txt("description"));
01201                 $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("tst_question_type"));
01202                 $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
01203                 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
01204                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
01205                 $this->tpl->parseCurrentBlock();
01206         }
01207 
01215         function insertQuestionsObject()
01216         {
01217                 // insert selected questions into test
01218                 $selected_array = array();
01219                 foreach ($_POST as $key => $value)
01220                 {
01221                         if (preg_match("/cb_(\d+)/", $key, $matches))
01222                         {
01223                                 array_push($selected_array, $matches[1]);
01224                         }
01225                 }
01226                 if (!count($selected_array))
01227                 {
01228                         sendInfo($this->lng->txt("tst_insert_missing_question"), true);
01229                         $this->ctrl->redirect($this, "browseForQuestions");
01230                 }
01231                 else
01232                 {
01233 
01234                         foreach ($selected_array as $key => $value) 
01235                         {
01236                                 $this->object->insertQuestion($value);
01237                         }
01238                         $this->object->saveCompleteStatus();
01239                         sendInfo($this->lng->txt("tst_questions_inserted"), true);
01240                         $this->ctrl->redirect($this, "questions");
01241                         return;
01242                 }
01243         }
01244 
01252         function questionBrowser($filter_type = "", $filter_question_type = "", $filter_questionpool = "", $filter_text = "")
01253         {
01254                 global $rbacsystem;
01255 
01256                 $this->ctrl->setParameterByClass(get_class($this), "browse", "1");
01257                 if (!$filter_type)
01258                 {
01259                         $filter_type = $_GET["sel_filter_type"];
01260                 }
01261                 $this->ctrl->setParameterByClass(get_class($this), "sel_filter_type", $filter_type);
01262                 if (!$filter_question_type)
01263                 {
01264                         $filter_question_type = $_GET["sel_question_type"];
01265                 }
01266                 $this->ctrl->setParameterByClass(get_class($this), "sel_question_type", $filter_question_type);
01267                 if (!$filter_questionpool)
01268                 {
01269                         $filter_questionpool = $_GET["sel_questionpool"];
01270                 }
01271                 $this->ctrl->setParameterByClass(get_class($this), "sel_questionpool", $filter_questionpool);
01272                 if (!$filter_text)
01273                 {
01274                         $filter_text = $_GET["filter_text"];
01275                 }
01276                 $this->ctrl->setParameterByClass(get_class($this), "filter_text", $filter_text);
01277                 
01278                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_questionbrowser.html", true);
01279                 $this->tpl->addBlockFile("A_BUTTONS", "a_buttons", "tpl.il_as_qpl_action_buttons.html", true);
01280                 $this->tpl->addBlockFile("FILTER_QUESTION_MANAGER", "filter_questions", "tpl.il_as_tst_filter_questions.html", true);
01281 
01282                 $questionpools =& $this->object->get_qpl_titles();
01283 
01284                 $filter_fields = array(
01285                         "title" => $this->lng->txt("title"),
01286                         "comment" => $this->lng->txt("description"),
01287                         "author" => $this->lng->txt("author"),
01288                 );
01289                 $this->tpl->setCurrentBlock("filterrow");
01290                 foreach ($filter_fields as $key => $value) {
01291                         $this->tpl->setVariable("VALUE_FILTER_TYPE", "$key");
01292                         $this->tpl->setVariable("NAME_FILTER_TYPE", "$value");
01293                         if (strcmp($_POST["cmd"]["resetFilter"], "") == 0) {
01294                                 if (strcmp($filter_type, $key) == 0) {
01295                                         $this->tpl->setVariable("VALUE_FILTER_SELECTED", " selected=\"selected\"");
01296                                 }
01297                         }
01298                         $this->tpl->parseCurrentBlock();
01299                 }
01300 
01301                 $questiontypes =& $this->object->_getQuestiontypes();
01302                 foreach ($questiontypes as $key => $value)
01303                 {
01304                         $this->tpl->setCurrentBlock("questiontype_row");
01305                         $this->tpl->setVariable("VALUE_QUESTION_TYPE", $value);
01306                         $this->tpl->setVariable("TEXT_QUESTION_TYPE", $this->lng->txt($value));
01307                         if (strcmp($filter_question_type, $value) == 0)
01308                         {
01309                                 $this->tpl->setVariable("SELECTED_QUESTION_TYPE", " selected=\"selected\"");
01310                         }
01311                         $this->tpl->parseCurrentBlock();
01312                 }
01313                 
01314                 foreach ($questionpools as $key => $value)
01315                 {
01316                         $this->tpl->setCurrentBlock("questionpool_row");
01317                         $this->tpl->setVariable("VALUE_QUESTIONPOOL", $key);
01318                         $this->tpl->setVariable("TEXT_QUESTIONPOOL", $value);
01319                         if (strcmp($filter_questionpool, $key) == 0)
01320                         {
01321                                 $this->tpl->setVariable("SELECTED_QUESTIONPOOL", " selected=\"selected\"");
01322                         }
01323                         $this->tpl->parseCurrentBlock();
01324                 }
01325 
01326                 $this->tpl->setCurrentBlock("filter_questions");
01327                 $this->tpl->setVariable("SHOW_QUESTION_TYPES", $this->lng->txt("filter_show_question_types"));
01328                 $this->tpl->setVariable("TEXT_ALL_QUESTION_TYPES", $this->lng->txt("filter_all_question_types"));
01329                 $this->tpl->setVariable("SHOW_QUESTIONPOOLS", $this->lng->txt("filter_show_questionpools"));
01330                 $this->tpl->setVariable("TEXT_ALL_QUESTIONPOOLS", $this->lng->txt("filter_all_questionpools"));
01331                 $this->tpl->setVariable("FILTER_TEXT", $this->lng->txt("filter"));
01332                 $this->tpl->setVariable("TEXT_FILTER_BY", $this->lng->txt("by"));
01333                 if (strcmp($_POST["cmd"]["resetFilter"], "") == 0) 
01334                 {
01335                         $this->tpl->setVariable("VALUE_FILTER_TEXT", $filter_text);
01336                 }
01337                 $this->tpl->setVariable("VALUE_SUBMIT_FILTER", $this->lng->txt("set_filter"));
01338                 $this->tpl->setVariable("VALUE_RESET_FILTER", $this->lng->txt("reset_filter"));
01339                 $this->tpl->parseCurrentBlock();
01340 
01341                 // create edit buttons & table footer
01342                 $this->tpl->setCurrentBlock("selection");
01343                 $this->tpl->setVariable("INSERT", $this->lng->txt("insert"));
01344                 $this->tpl->parseCurrentBlock();
01345 
01346                 $this->tpl->setCurrentBlock("Footer");
01347                 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"\">");
01348                 $this->tpl->parseCurrentBlock();
01349 
01350                 $this->tpl->setCurrentBlock("QTab");
01351 
01352                 $startrow = 0;
01353                 if ($_GET["prevrow"])
01354                 {
01355                         $startrow = $_GET["prevrow"];
01356                 }
01357                 if ($_GET["nextrow"])
01358                 {
01359                         $startrow = $_GET["nextrow"];
01360                 }
01361                 if ($_GET["startrow"])
01362                 {
01363                         $startrow = $_GET["startrow"];
01364                 }
01365                 if (!$_GET["sort"])
01366                 {
01367                         // default sort order
01368                         $_GET["sort"] = array("title" => "ASC");
01369                 }
01370                 $table = $this->object->getQuestionsTable($_GET["sort"], $filter_text, $filter_type, $startrow, 1, $filter_question_type, $filter_questionpool);
01371                 // display all questions in accessable question pools
01372                 $colors = array("tblrow1", "tblrow2");
01373                 $counter = 0;
01374                 $existing_questions =& $this->object->getExistingQuestions();
01375                 foreach ($table["rows"] as $data)
01376                 {
01377                         if (!in_array($data["question_id"], $existing_questions))
01378                         {
01379                                 if ($data["complete"])
01380                                 {
01381                                         // make only complete questions selectable
01382                                         $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
01383                                 }
01384                                 $this->tpl->setVariable("QUESTION_TITLE", "<strong>" . $data["title"] . "</strong>");
01385                                 $this->tpl->setVariable("PREVIEW", "[<a href=\"" . $this->getCallingScript() . "$add_parameter&preview=" . $data["question_id"] . "\">" . $this->lng->txt("preview") . "</a>]");
01386                                 $this->tpl->setVariable("QUESTION_COMMENT", $data["comment"]);
01387                                 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($data["type_tag"]));
01388                                 $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]);
01389                                 $this->tpl->setVariable("QUESTION_CREATED", ilFormat::formatDate(ilFormat::ftimestamp2dateDB($data["created"]), "date"));
01390                                 $this->tpl->setVariable("QUESTION_UPDATED", ilFormat::formatDate(ilFormat::ftimestamp2dateDB($data["TIMESTAMP14"]), "date"));
01391                                 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
01392                                 $this->tpl->setVariable("QUESTION_POOL", $questionpools[$data["obj_fi"]]);
01393                                 $this->tpl->parseCurrentBlock();
01394                                 $counter++;
01395                         }
01396                 }
01397 
01398                 if ($table["rowcount"] > count($table["rows"]))
01399                 {
01400                         $nextstep = $table["nextrow"] + $table["step"];
01401                         if ($nextstep > $table["rowcount"])
01402                         {
01403                                 $nextstep = $table["rowcount"];
01404                         }
01405                         $sort = "";
01406                         if (is_array($_GET["sort"]))
01407                         {
01408                                 $key = key($_GET["sort"]);
01409                                 $sort = "&sort[$key]=" . $_GET["sort"]["$key"];
01410                         }
01411                         $counter = 1;
01412                         for ($i = 0; $i < $table["rowcount"]; $i += $table["step"])
01413                         {
01414                                 $this->tpl->setCurrentBlock("pages");
01415                                 if ($table["startrow"] == $i)
01416                                 {
01417                                         $this->tpl->setVariable("PAGE_NUMBER", "<span class=\"inactivepage\">$counter</span>");
01418                                 }
01419                                 else
01420                                 {
01421                                         $this->tpl->setVariable("PAGE_NUMBER", "<a href=\"" . $this->ctrl->getFormAction($this) . "$sort&nextrow=$i" . "\">$counter</a>");
01422                                 }
01423                                 $this->tpl->parseCurrentBlock();
01424                                 $counter++;
01425                         }
01426                         $this->tpl->setCurrentBlock("navigation_bottom");
01427                         $this->tpl->setVariable("TEXT_ITEM", $this->lng->txt("item"));
01428                         $this->tpl->setVariable("TEXT_ITEM_START", $table["startrow"] + 1);
01429                         $end = $table["startrow"] + $table["step"];
01430                         if ($end > $table["rowcount"])
01431                         {
01432                                 $end = $table["rowcount"];
01433                         }
01434                         $this->tpl->setVariable("TEXT_ITEM_END", $end);
01435                         $this->tpl->setVariable("TEXT_OF", strtolower($this->lng->txt("of")));
01436                         $this->tpl->setVariable("TEXT_ITEM_COUNT", $table["rowcount"]);
01437                         $this->tpl->setVariable("TEXT_PREVIOUS", $this->lng->txt("previous"));
01438                         $this->tpl->setVariable("TEXT_NEXT", $this->lng->txt("next"));
01439                         $this->tpl->setVariable("HREF_PREV_ROWS", $this->ctrl->getFormAction($this) . "$sort&prevrow=" . $table["prevrow"]);
01440                         $this->tpl->setVariable("HREF_NEXT_ROWS", $this->ctrl->getFormAction($this) . "$sort&nextrow=" . $table["nextrow"]);
01441                         $this->tpl->parseCurrentBlock();
01442                 }
01443 
01444                 // if there are no questions, display a message
01445                 if ($counter == 0) {
01446                         $this->tpl->setCurrentBlock("Emptytable");
01447                         $this->tpl->setVariable("TEXT_EMPTYTABLE", $this->lng->txt("no_questions_available"));
01448                         $this->tpl->parseCurrentBlock();
01449                 }
01450 
01451                 // define the sort column parameters
01452                 $sort = array(
01453                         "title" => $_GET["sort"]["title"],
01454                         "comment" => $_GET["sort"]["comment"],
01455                         "type" => $_GET["sort"]["type"],
01456                         "author" => $_GET["sort"]["author"],
01457                         "created" => $_GET["sort"]["created"],
01458                         "updated" => $_GET["sort"]["updated"],
01459                         "qpl" => $_GET["sort"]["qpl"]
01460                 );
01461                 foreach ($sort as $key => $value) {
01462                         if (strcmp($value, "ASC") == 0) {
01463                                 $sort[$key] = "DESC";
01464                         } else {
01465                                 $sort[$key] = "ASC";
01466                         }
01467                 }
01468 
01469                 $this->tpl->setCurrentBlock("adm_content");
01470                 // create table header
01471                 $this->ctrl->setCmd("questionBrowser");
01472                 $this->ctrl->setParameterByClass(get_class($this), "startrow", $table["startrow"]);
01473                 $this->tpl->setVariable("QUESTION_TITLE", "<a href=\"" . $this->ctrl->getFormAction($this) . "&sort[title]=" . $sort["title"] . "\">" . $this->lng->txt("title") . "</a>" . $table["images"]["title"]);
01474                 $this->tpl->setVariable("QUESTION_COMMENT", "<a href=\"" . $this->ctrl->getFormAction($this) . "&sort[comment]=" . $sort["comment"] . "\">" . $this->lng->txt("description") . "</a>". $table["images"]["comment"]);
01475                 $this->tpl->setVariable("QUESTION_TYPE", "<a href=\"" . $this->ctrl->getFormAction($this) . "&sort[type]=" . $sort["type"] . "\">" . $this->lng->txt("question_type") . "</a>" . $table["images"]["type"]);
01476                 $this->tpl->setVariable("QUESTION_AUTHOR", "<a href=\"" . $this->ctrl->getFormAction($this) . "&sort[author]=" . $sort["author"] . "\">" . $this->lng->txt("author") . "</a>" . $table["images"]["author"]);
01477                 $this->tpl->setVariable("QUESTION_CREATED", "<a href=\"" . $this->ctrl->getFormAction($this) . "&sort[created]=" . $sort["created"] . "\">" . $this->lng->txt("create_date") . "</a>" . $table["images"]["created"]);
01478                 $this->tpl->setVariable("QUESTION_UPDATED", "<a href=\"" . $this->ctrl->getFormAction($this) . "&sort[updated]=" . $sort["updated"] . "\">" . $this->lng->txt("last_update") . "</a>" . $table["images"]["updated"]);
01479                 $this->tpl->setVariable("QUESTION_POOL", "<a href=\"" . $this->ctrl->getFormAction($this) . "&sort[qpl]=" . $sort["qpl"] . "\">" . $this->lng->txt("obj_qpl") . "</a>" . $table["images"]["qpl"]);
01480                 $this->tpl->setVariable("BUTTON_BACK", $this->lng->txt("back"));
01481                 $this->tpl->setVariable("ACTION_QUESTION_FORM", $this->ctrl->getFormAction($this));
01482                 $this->tpl->parseCurrentBlock();
01483         }
01484 
01493         function createQuestionPool($name = "dummy")
01494         {
01495                 global $tree;
01496                 $parent_ref = $tree->getParentId($this->object->getRefId());
01497                 $qpl = new ilObjQuestionPool();
01498                 $qpl->setType("qpl");
01499                 $qpl->setTitle($name);
01500                 $qpl->setDescription("");
01501                 $qpl->create();
01502                 $qpl->createReference();
01503                 $qpl->putInTree($parent_ref);
01504                 $qpl->setPermissions($parent_ref);
01505                 return $qpl->getRefId();
01506         }
01507 
01515         function randomselectObject()
01516         {
01517                 global $ilUser;
01518                 $add_parameter = $this->getAddParameter();
01519                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_random_select.html", true);
01520                 $questionpools =& $this->object->getAvailableQuestionpools();
01521                 $this->tpl->setCurrentBlock("option");
01522                 $this->tpl->setVariable("VALUE_OPTION", "0");
01523                 $this->tpl->setVariable("TEXT_OPTION", $this->lng->txt("all_available_question_pools"));
01524                 $this->tpl->parseCurrentBlock();
01525                 foreach ($questionpools as $key => $value)
01526                 {
01527                         $this->tpl->setCurrentBlock("option");
01528                         $this->tpl->setVariable("VALUE_OPTION", $key);
01529                         $this->tpl->setVariable("TEXT_OPTION", $value);
01530                         $this->tpl->parseCurrentBlock();
01531                 }
01532                 $this->tpl->setCurrentBlock("hidden");
01533                 $this->tpl->setVariable("HIDDEN_NAME", "sel_question_types");
01534                 $this->tpl->setVariable("HIDDEN_VALUE", $_POST["sel_question_types"]);
01535                 $this->tpl->parseCurrentBlock();
01536                 $this->tpl->setCurrentBlock("adm_content");
01537                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
01538                 $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_random_select_questionpool"));
01539                 $this->tpl->setVariable("TXT_NR_OF_QUESTIONS", $this->lng->txt("tst_random_nr_of_questions"));
01540                 $this->tpl->setVariable("BTN_SUBMIT", $this->lng->txt("submit"));
01541                 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
01542                 $this->tpl->parseCurrentBlock();
01543         }
01544         
01552         function cancelRandomSelectObject()
01553         {
01554                 $this->ctrl->redirect($this, "questions");
01555         }
01556         
01564         function createRandomSelectionObject()
01565         {
01566                 $question_array = $this->object->randomSelectQuestions($_POST["nr_of_questions"], $_POST["sel_qpl"]);
01567                 $add_parameter = $this->getAddParameter();
01568                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_random_question_offer.html", true);
01569                 $color_class = array("tblrow1", "tblrow2");
01570                 $counter = 0;
01571                 $questionpools =& $this->object->get_qpl_titles();
01572                 foreach ($question_array as $question_id)
01573                 {
01574                         $dataset = $this->object->getQuestionDataset($question_id);
01575                         $this->tpl->setCurrentBlock("QTab");
01576                         $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
01577                         $this->tpl->setVariable("QUESTION_TITLE", $dataset->title);
01578                         $this->tpl->setVariable("QUESTION_COMMENT", $dataset->comment);
01579                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($dataset->type_tag));
01580                         $this->tpl->setVariable("QUESTION_AUTHOR", $dataset->author);
01581                         $this->tpl->setVariable("QUESTION_POOL", $questionpools[$dataset->obj_fi]);
01582                         $this->tpl->parseCurrentBlock();
01583                         $counter++;
01584                 }
01585                 if (count($question_array) == 0)
01586                 {
01587                         $this->tpl->setCurrentBlock("Emptytable");
01588                         $this->tpl->setVariable("TEXT_NO_QUESTIONS_AVAILABLE", $this->lng->txt("no_questions_available"));
01589                         $this->tpl->parseCurrentBlock();
01590                 }
01591                         else
01592                 {
01593                         $this->tpl->setCurrentBlock("Selectionbuttons");
01594                         $this->tpl->setVariable("BTN_YES", $this->lng->txt("random_accept_sample"));
01595                         $this->tpl->setVariable("BTN_NO", $this->lng->txt("random_another_sample"));
01596                         $this->tpl->parseCurrentBlock();
01597                 }
01598                 $chosen_questions = join($question_array, ",");
01599                 $this->tpl->setCurrentBlock("adm_content");
01600                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
01601                 $this->tpl->setVariable("QUESTION_TITLE", $this->lng->txt("tst_question_title"));
01602                 $this->tpl->setVariable("QUESTION_COMMENT", $this->lng->txt("description"));
01603                 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("tst_question_type"));
01604                 $this->tpl->setVariable("QUESTION_AUTHOR", $this->lng->txt("author"));
01605                 $this->tpl->setVariable("QUESTION_POOL", $this->lng->txt("qpl"));
01606                 $this->tpl->setVariable("VALUE_CHOSEN_QUESTIONS", $chosen_questions);
01607                 $this->tpl->setVariable("VALUE_QUESTIONPOOL_SELECTION", $_POST["sel_qpl"]);
01608                 $this->tpl->setVariable("VALUE_NR_OF_QUESTIONS", $_POST["nr_of_questions"]);
01609                 $this->tpl->setVariable("TEXT_QUESTION_OFFER", $this->lng->txt("tst_question_offer"));
01610                 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
01611                 $this->tpl->parseCurrentBlock();
01612         }
01613         
01621         function insertRandomSelectionObject()
01622         {
01623                 $selected_array = split(",", $_POST["chosen_questions"]);
01624                 if (!count($selected_array))
01625                 {
01626                         sendInfo($this->lng->txt("tst_insert_missing_question"));
01627                 }
01628                 else
01629                 {
01630                         $total = $this->object->evalTotalPersons();
01631                         if ($total)
01632                         {
01633                                 // the test was executed previously
01634                                 sendInfo(sprintf($this->lng->txt("tst_insert_questions_and_results"), $total));
01635                         }
01636                         else
01637                         {
01638                                 sendInfo($this->lng->txt("tst_insert_questions"));
01639                         }
01640                         foreach ($selected_array as $key => $value) 
01641                         {
01642                                 $this->object->insertQuestion($value);
01643                         }
01644                         $this->object->saveCompleteStatus();
01645                         sendInfo($this->lng->txt("tst_questions_inserted"), true);
01646                         $this->ctrl->redirect($this, "questions");
01647                         return;
01648                 }
01649         }
01650 
01651         function randomQuestionsObject()
01652         {
01653                 $total = $this->object->evalTotalPersons();
01654                 $add_parameter = $this->getAddParameter();
01655                 $available_qpl =& $this->object->getAvailableQuestionpools(true);
01656                 $qpl_question_count = array();
01657                 foreach ($available_qpl as $key => $value)
01658                 {
01659                         $count = ilObjQuestionPool::_getQuestionCount($key);
01660                         $qpl_question_count[$key] = $count;
01661                         if ($count == 1)
01662                         {
01663                                 $available_qpl[$key] = $value . " ($count " . $this->lng->txt("ass_question") . ")";
01664                         }
01665                         else
01666                         {
01667                                 $available_qpl[$key] = $value . " ($count " . $this->lng->txt("ass_questions") . ")";
01668                         }
01669                 }
01670                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_random_questions.html", true);
01671                 $found_qpls = array();
01672                 if (count($_POST) == 0)
01673                 {
01674                         $found_qpls = $this->object->getRandomQuestionpools();
01675                 }
01676                 if (count($found_qpls) == 0)
01677                 {
01678                         if (!array_key_exists("countqpl_0", $_POST))
01679                         {
01680                                 // create first questionpool row automatically
01681                                 foreach ($available_qpl as $key => $value)
01682                                 {
01683                                         $this->tpl->setCurrentBlock("qpl_value");
01684                                         $this->tpl->setVariable("QPL_ID", $key);
01685                                         $this->tpl->setVariable("QPL_TEXT", $value);
01686                                         $this->tpl->parseCurrentBlock();
01687                                 }
01688                                 $this->tpl->setCurrentBlock("questionpool_row");
01689                                 $this->tpl->setVariable("COUNTQPL", "0");
01690                                 $this->tpl->setVariable("VALUE_COUNTQPL", $_POST["countqpl_0"]);
01691                                 $this->tpl->setVariable("TEXT_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool_option"));
01692                                 $this->tpl->setVariable("TEXT_QUESTIONS_FROM", $this->lng->txt("questions_from"));
01693                                 $this->tpl->parseCurrentBlock();
01694                         }
01695                 }
01696                 $qpl_unselected = 0;
01697                 foreach ($_POST as $key => $value)
01698                 {
01699                         if (preg_match("/countqpl_(\d+)/", $key, $matches))
01700                         {
01701                                 if ($value > $qpl_question_count[$_POST["qpl_" . $matches[1]]])
01702                                 {
01703                                         $value = $qpl_question_count[$_POST["qpl_" . $matches[1]]];
01704                                         sendInfo($this->lng->txt("tst_random_selection_question_count_too_high"));
01705                                 }
01706                                 $found_qpls[$matches[1]] = array(
01707                                         "index" => $matches[1],
01708                                         "count" => sprintf("%d", $value),
01709                                         "qpl"   => $_POST["qpl_" . $matches[1]]
01710                                 );
01711                                 if ($_POST["qpl_" . $matches[1]] == -1)
01712                                 {
01713                                         $qpl_unselected = 1;
01714                                 }
01715                         }
01716                 }
01717                 foreach ($_POST as $key => $value)
01718                 {
01719                         if (preg_match("/deleteqpl_(\d+)/", $key, $matches))
01720                         {
01721                                 unset($found_qpls[$matches[1]]);
01722                         }
01723                 }
01724                 sort($found_qpls);
01725                 $found_qpls = array_values($found_qpls);
01726                 $counter = 0;
01727                 foreach ($found_qpls as $key => $value)
01728                 {
01729                         $pools = $available_qpl;
01730                         foreach ($found_qpls as $pkey => $pvalue)
01731                         {
01732                                 if ($pvalue["qpl"] != $value["qpl"])
01733                                 {
01734                                         unset($pools[$pvalue["qpl"]]);
01735                                 }
01736                         }
01737                         // create first questionpool row automatically
01738                         foreach ($pools as $pkey => $pvalue)
01739                         {
01740                                 $this->tpl->setCurrentBlock("qpl_value");
01741                                 $this->tpl->setVariable("QPL_ID", $pkey);
01742                                 $this->tpl->setVariable("QPL_TEXT", $pvalue);
01743                                 if ($pkey == $value["qpl"])
01744                                 {
01745                                         $this->tpl->setVariable("SELECTED_QPL", " selected=\"selected\"");
01746                                 }
01747                                 $this->tpl->parseCurrentBlock();
01748                         }
01749                         $this->tpl->setCurrentBlock("questionpool_row");
01750                         $this->tpl->setVariable("COUNTQPL", $counter);
01751                         $this->tpl->setVariable("VALUE_COUNTQPL", $value["count"]);
01752                         $this->tpl->setVariable("TEXT_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool_option"));
01753                         $this->tpl->setVariable("TEXT_QUESTIONS_FROM", $this->lng->txt("questions_from"));
01754                         if (!$total)
01755                         {
01756                                 if ($counter > 0)
01757                                 {
01758                                         $this->tpl->setVariable("BTNCOUNTQPL", $counter);
01759                                         $this->tpl->setVariable("BTN_DELETE", $this->lng->txt("delete"));
01760                                 }
01761                         }
01762                         $this->tpl->parseCurrentBlock();
01763                         $counter++;
01764                 }
01765                 if ($_POST["cmd"]["addQuestionpool"])
01766                 {
01767                         if ($qpl_unselected)
01768                         {
01769                                 sendInfo($this->lng->txt("tst_random_qpl_unselected"));
01770                         }
01771                         else
01772                         {
01773                                 $pools = $available_qpl;
01774                                 foreach ($found_qpls as $pkey => $pvalue)
01775                                 {
01776                                         unset($pools[$pvalue["qpl"]]);
01777                                 }
01778                                 if (count($pools) == 0)
01779                                 {
01780                                         sendInfo($this->lng->txt("tst_no_more_available_questionpools"));
01781                                 }
01782                                 else
01783                                 {
01784                                         foreach ($pools as $key => $value)
01785                                         {
01786                                                 $this->tpl->setCurrentBlock("qpl_value");
01787                                                 $this->tpl->setVariable("QPL_ID", $key);
01788                                                 $this->tpl->setVariable("QPL_TEXT", $value);
01789                                                 $this->tpl->parseCurrentBlock();
01790                                         }
01791                                         $this->tpl->setCurrentBlock("questionpool_row");
01792                                         $this->tpl->setVariable("COUNTQPL", "$counter");
01793                                         $this->tpl->setVariable("TEXT_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool_option"));
01794                                         $this->tpl->setVariable("TEXT_QUESTIONS_FROM", $this->lng->txt("questions_from"));
01795                                         $this->tpl->parseCurrentBlock();
01796                                 }
01797                         }
01798                 }
01799                 if ($_POST["cmd"]["save"])
01800                 {
01801                         $this->object->saveRandomQuestionCount($_POST["total_questions"]);
01802                         $this->object->saveRandomQuestionpools($found_qpls);
01803                         $this->object->saveCompleteStatus();
01804                 }
01805                 $this->tpl->setCurrentBlock("adm_content");
01806                 $this->tpl->setVariable("TEXT_SELECT_RANDOM_QUESTIONS", $this->lng->txt("tst_select_random_questions"));
01807                 $this->tpl->setVariable("TEXT_TOTAL_QUESTIONS", $this->lng->txt("tst_total_questions"));
01808                 $this->tpl->setVariable("TEXT_TOTAL_QUESTIONS_DESCRIPTION", $this->lng->txt("tst_total_questions_description"));
01809                 $total_questions = $this->object->getRandomQuestionCount();
01810                 if (array_key_exists("total_questions", $_POST))
01811                 {
01812                         $total_questions = $_POST["total_questions"];
01813                 }
01814                 if ($total_questions > 0)
01815                 {
01816                         $sum = 0;
01817                         foreach ($found_qpls as $key => $value)
01818                         {
01819                                 $sum += $qpl_question_count[$value["qpl"]];
01820                         }
01821                         if ($total_questions > $sum)
01822                         {
01823                                 $total_questions = $sum;
01824                                 if ($_POST["cmd"]["saveRandomQuestions"])
01825                                 {
01826                                         $this->object->saveRandomQuestionCount($total_questions);
01827                                 }
01828                                 sendInfo($this->lng->txt("tst_random_selection_question_total_count_too_high"));
01829                         }
01830                 }
01831                 $this->tpl->setVariable("VALUE_TOTAL_QUESTIONS", $total_questions);
01832                 $this->tpl->setVariable("TEXT_QUESTIONPOOLS", $this->lng->txt("tst_random_questionpools"));
01833                 if (!$total)
01834                 {
01835                         $this->tpl->setVariable("BTN_SAVE", $this->lng->txt("save"));
01836                         $this->tpl->setVariable("BTN_ADD_QUESTIONPOOL", $this->lng->txt("add_questionpool"));
01837                 }
01838                 $this->tpl->setVariable("FORM_ACTION", $this->getCallingScript() . $add_parameter);
01839                 $this->tpl->parseCurrentBlock();
01840         }
01841 
01842         function browseForQuestionsObject()
01843         {
01844                 $this->questionBrowser();
01845         }
01846         
01854         function executeCreateQuestionObject()
01855         {
01856                 $qpl_ref_id = $_POST["sel_qpl"];
01857                 if ((strcmp($_POST["txt_qpl"], "") == 0) && (strcmp($qpl_ref_id, "") == 0))
01858                 {
01859                         sendInfo($this->lng->txt("questionpool_not_entered"));
01860                         $this->createQuestionObject();
01861                         return;
01862                 }
01863                 else
01864                 {
01865                         $_SESSION["test_id"] = $this->object->getRefId();
01866                         if (strcmp($_POST["txt_qpl"], "") != 0)
01867                         {
01868                                 // create a new question pool and return the reference id
01869                                 $qpl_ref_id = $this->createQuestionPool($_POST["txt_qpl"]);
01870                         }
01871                         ilUtil::redirect("questionpool.php?ref_id=" . $qpl_ref_id . "&cmd=createQuestionForTest&test_ref_id=".$_GET["ref_id"]."&sel_question_types=" . $_POST["sel_question_types"]);
01872                         exit();
01873                 }
01874         }
01875 
01883         function cancelCreateQuestionObject()
01884         {
01885                 $this->ctrl->redirect($this, "questions");
01886         }
01887 
01895         function createQuestionObject()
01896         {
01897                 global $ilUser;
01898                 $add_parameter = $this->getAddParameter();
01899                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_qpl_select.html", true);
01900                 $questionpools =& $this->object->getAvailableQuestionpools();
01901                 if (count($questionpools) == 0)
01902                 {
01903                         $this->tpl->setCurrentBlock("option");
01904                         $this->tpl->setVariable("VALUE_QPL", "");
01905                         $this->tpl->parseCurrentBlock();
01906                 }
01907                 else
01908                 {
01909                         foreach ($questionpools as $key => $value)
01910                         {
01911                                 $this->tpl->setCurrentBlock("option");
01912                                 $this->tpl->setVariable("VALUE_OPTION", $key);
01913                                 $this->tpl->setVariable("TEXT_OPTION", $value);
01914                                 $this->tpl->parseCurrentBlock();
01915                         }
01916                 }
01917                 $this->tpl->setCurrentBlock("hidden");
01918                 $this->tpl->setVariable("HIDDEN_NAME", "sel_question_types");
01919                 $this->tpl->setVariable("HIDDEN_VALUE", $_POST["sel_question_types"]);
01920                 $this->tpl->parseCurrentBlock();
01921                 $this->tpl->setCurrentBlock("adm_content");
01922                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
01923 
01924                 if (count($questionpools) == 0)
01925                 {
01926                         $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_enter_questionpool"));
01927                 }
01928                 else
01929                 {
01930                         $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_select_questionpool"));
01931                 }
01932                 $this->tpl->setVariable("BTN_SUBMIT", $this->lng->txt("submit"));
01933                 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
01934                 $this->tpl->parseCurrentBlock();
01935         }
01936 
01944         function confirmRemoveQuestionsObject()
01945         {
01946                 sendInfo($this->lng->txt("tst_questions_removed"));
01947                 $checked_questions = array();
01948                 foreach ($_POST as $key => $value) {
01949                         if (preg_match("/id_(\d+)/", $key, $matches)) {
01950                                 array_push($checked_questions, $matches[1]);
01951                         }
01952                 }
01953                 foreach ($checked_questions as $key => $value) {
01954                         $this->object->removeQuestion($value);
01955                 }
01956                 $this->object->saveCompleteStatus();
01957                 $this->ctrl->redirect($this, "questions");
01958         }
01959         
01967         function cancelRemoveQuestionsObject()
01968         {
01969                 $this->ctrl->redirect($this, "questions");
01970         }
01971         
01979         function removeQuestionsForm($checked_questions)
01980         {
01981                 sendInfo();
01982                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_remove_questions.html", true);
01983                 $query = sprintf("SELECT qpl_questions.*, qpl_question_type.type_tag FROM qpl_questions, qpl_question_type, tst_test_question WHERE qpl_questions.question_type_fi = qpl_question_type.question_type_id AND tst_test_question.test_fi = %s AND tst_test_question.question_fi = qpl_questions.question_id ORDER BY sequence",
01984                         $this->ilias->db->quote($this->object->getTestId())
01985                 );
01986                 $query_result = $this->ilias->db->query($query);
01987                 $colors = array("tblrow1", "tblrow2");
01988                 $counter = 0;
01989                 if ($query_result->numRows() > 0)
01990                 {
01991                         while ($data = $query_result->fetchRow(DB_FETCHMODE_OBJECT))
01992                         {
01993                                 if (in_array($data->question_id, $checked_questions))
01994                                 {
01995                                         $this->tpl->setCurrentBlock("row");
01996                                         $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
01997                                         $this->tpl->setVariable("TXT_TITLE", $data->title);
01998                                         $this->tpl->setVariable("TXT_DESCRIPTION", $data->comment);
01999                                         $this->tpl->setVariable("TXT_TYPE", $this->lng->txt($data->type_tag));
02000                                         $this->tpl->parseCurrentBlock();
02001                                         $counter++;
02002                                 }
02003                         }
02004                 }
02005                 foreach ($checked_questions as $id)
02006                 {
02007                         $this->tpl->setCurrentBlock("hidden");
02008                         $this->tpl->setVariable("HIDDEN_NAME", "id_$id");
02009                         $this->tpl->setVariable("HIDDEN_VALUE", "1");
02010                         $this->tpl->parseCurrentBlock();
02011                 }
02012 
02013                 $this->tpl->setCurrentBlock("adm_content");
02014                 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("tst_question_title"));
02015                 $this->tpl->setVariable("TXT_DESCRIPTION", $this->lng->txt("description"));
02016                 $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("tst_question_type"));
02017                 $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
02018                 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
02019                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
02020                 $this->tpl->parseCurrentBlock();
02021         }
02022 
02030         function removeQuestionsObject()
02031         {
02032                 $checked_questions = array();
02033                 foreach ($_POST as $key => $value) {
02034                         if (preg_match("/cb_(\d+)/", $key, $matches)) {
02035                                 array_push($checked_questions, $matches[1]);
02036                         }
02037                 }
02038                 if (count($checked_questions) > 0) {
02039                         $total = $this->object->evalTotalPersons();
02040                         if ($total) {
02041                                 // the test was executed previously
02042                                 sendInfo(sprintf($this->lng->txt("tst_remove_questions_and_results"), $total));
02043                         } else {
02044                                 sendInfo($this->lng->txt("tst_remove_questions"));
02045                         }
02046                         $this->removeQuestionsForm($checked_questions);
02047                         return;
02048                 } elseif (count($checked_questions) == 0) {
02049                         sendInfo($this->lng->txt("tst_no_question_selected_for_removal"), true);
02050                         $this->ctrl->redirect($this, "questions");
02051                 }
02052         }
02053         
02061         function moveQuestionsObject()
02062         {
02063                 $this->questionsObject();
02064         }
02065         
02073         function insertQuestionsBeforeObject()
02074         {
02075                 // get all questions to move
02076                 $move_questions = array();
02077                 foreach ($_POST as $key => $value)
02078                 {
02079                         if (preg_match("/^move_(\d+)$/", $key, $matches))
02080                         {
02081                                 array_push($move_questions, $value);
02082                         }
02083                 }
02084                 // get insert point
02085                 $insert_id = -1;
02086                 foreach ($_POST as $key => $value)
02087                 {
02088                         if (preg_match("/^cb_(\d+)$/", $key, $matches))
02089                         {
02090                                 if ($insert_id < 0)
02091                                 {
02092                                         $insert_id = $matches[1];
02093                                 }
02094                         }
02095                 }
02096                 if ($insert_id <= 0)
02097                 {
02098                         sendInfo($this->lng->txt("no_target_selected_for_move"), true);
02099                 }
02100                 else
02101                 {
02102                         $insert_mode = 0;
02103                         $this->object->moveQuestions($move_questions, $insert_id, $insert_mode);
02104                 }
02105                 $this->ctrl->redirect($this, "questions");
02106         }
02107         
02115         function insertQuestionsAfterObject()
02116         {
02117                 // get all questions to move
02118                 $move_questions = array();
02119                 foreach ($_POST as $key => $value)
02120                 {
02121                         if (preg_match("/^move_(\d+)$/", $key, $matches))
02122                         {
02123                                 array_push($move_questions, $value);
02124                         }
02125                 }
02126                 // get insert point
02127                 $insert_id = -1;
02128                 foreach ($_POST as $key => $value)
02129                 {
02130                         if (preg_match("/^cb_(\d+)$/", $key, $matches))
02131                         {
02132                                 if ($insert_id < 0)
02133                                 {
02134                                         $insert_id = $matches[1];
02135                                 }
02136                         }
02137                 }
02138                 if ($insert_id <= 0)
02139                 {
02140                         sendInfo($this->lng->txt("no_target_selected_for_move"), true);
02141                 }
02142                 else
02143                 {
02144                         $insert_mode = 1;
02145                         $this->object->moveQuestions($move_questions, $insert_id, $insert_mode);
02146                 }
02147                 $this->ctrl->redirect($this, "questions");
02148         }
02149         
02150         function questionsObject()
02151         {
02152                 global $rbacsystem;
02153 
02154                 if ((!$rbacsystem->checkAccess("read", $this->ref_id)) && (!$rbacsystem->checkAccess("write", $this->ref_id))) 
02155                 {
02156                         // allow only read and write access
02157                         sendInfo($this->lng->txt("cannot_edit_test"), true);
02158                         $path = $this->tree->getPathFull($this->object->getRefID());
02159                         ilUtil::redirect($this->getReturnLocation("cancel","../repository.php?cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
02160                         return;
02161                 }
02162 
02163                 if ($this->object->isRandomTest())
02164                 {
02165                         $this->randomQuestionsObject();
02166                         return;
02167                 }
02168                 
02169                 $add_parameter = $this->getAddParameter();
02170 
02171                 if ($_GET["eqid"] and $_GET["eqpl"])
02172                 {
02173                         ilUtil::redirect("questionpool.php?ref_id=" . $_GET["eqpl"] . "&cmd=editQuestionForTest&calling_test=".$_GET["ref_id"]."&q_id=" . $_GET["eqid"]);
02174                 }
02175                 
02176                 if ($_GET["up"] > 0)
02177                 {
02178                         $this->object->questionMoveUp($_GET["up"]);
02179                 }
02180                 if ($_GET["down"] > 0)
02181                 {
02182                         $this->object->questionMoveDown($_GET["down"]);
02183                 }
02184 
02185                 if ($_GET["add"])
02186                 {
02187                         $selected_array = array();
02188                         array_push($selected_array, $_GET["add"]);
02189                         $total = $this->object->evalTotalPersons();
02190                         if ($total)
02191                         {
02192                                 // the test was executed previously
02193                                 sendInfo(sprintf($this->lng->txt("tst_insert_questions_and_results"), $total));
02194                         }
02195                         else
02196                         {
02197                                 sendInfo($this->lng->txt("tst_insert_questions"));
02198                         }
02199                         $this->insertQuestions($selected_array);
02200                         return;
02201                 }
02202 
02203                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_questions.html", true);
02204                 $this->tpl->addBlockFile("A_BUTTONS", "question_buttons", "tpl.il_as_tst_question_buttons.html", true);
02205 
02206                 if (strcmp($this->ctrl->getCmd(), "moveQuestions") == 0)
02207                 {
02208                         $checked_move = 0;
02209                         foreach ($_POST as $key => $value)
02210                         {
02211                                 if (preg_match("/cb_(\d+)/", $key, $matches))
02212                                 {
02213                                         $checked_move++;
02214                                         $this->tpl->setCurrentBlock("move");
02215                                         $this->tpl->setVariable("MOVE_COUNTER", $matches[1]);
02216                                         $this->tpl->setVariable("MOVE_VALUE", $matches[1]);
02217                                         $this->tpl->parseCurrentBlock();
02218                                 }
02219                         }
02220                         if ($checked_move)
02221                         {
02222                                 sendInfo($this->lng->txt("select_target_position_for_move_question"));
02223                                 $this->tpl->setCurrentBlock("move_buttons");
02224                                 $this->tpl->setVariable("INSERT_BEFORE", $this->lng->txt("insert_before"));
02225                                 $this->tpl->setVariable("INSERT_AFTER", $this->lng->txt("insert_after"));
02226                                 $this->tpl->parseCurrentBlock();
02227                         }
02228                         else
02229                         {
02230                                 sendInfo($this->lng->txt("no_question_selected_for_move"));
02231                         }
02232                 }
02233                 
02234                 $query = sprintf("SELECT qpl_questions.*, qpl_question_type.type_tag FROM qpl_questions, qpl_question_type, tst_test_question WHERE qpl_questions.question_type_fi = qpl_question_type.question_type_id AND tst_test_question.test_fi = %s AND tst_test_question.question_fi = qpl_questions.question_id ORDER BY sequence",
02235                         $this->ilias->db->quote($this->object->getTestId())
02236                 );
02237                 $query_result = $this->ilias->db->query($query);
02238                 $colors = array("tblrow1", "tblrow2");
02239                 $counter = 0;
02240                 $questionpools =& $this->object->get_qpl_titles();
02241                 $total = $this->object->evalTotalPersons();
02242                 if ($query_result->numRows() > 0)
02243                 {
02244                         while ($data = $query_result->fetchRow(DB_FETCHMODE_OBJECT))
02245                         {
02246                                 $this->tpl->setCurrentBlock("QTab");
02247                                 $this->tpl->setVariable("QUESTION_ID", $data->question_id);
02248                                 if (($rbacsystem->checkAccess("write", $this->ref_id) and ($total == 0))) {
02249                                         $q_id = $data->question_id;
02250                                         $qpl_ref_id = $this->object->_getRefIdFromObjId($data->obj_fi);
02251                                         $this->tpl->setVariable("QUESTION_TITLE", "<a href=\"" . $this->getCallingScript() . $add_parameter . "&eqid=$q_id&eqpl=$qpl_ref_id" . "\">" . $data->title . "</a>");
02252                                 } else {
02253                                         $this->tpl->setVariable("QUESTION_TITLE", $data->title);
02254                                 }
02255                                 $this->tpl->setVariable("QUESTION_SEQUENCE", $this->lng->txt("tst_sequence"));
02256 
02257                                 if (($rbacsystem->checkAccess("write", $this->ref_id) and ($total == 0))) {
02258                                         if ($data->question_id != $this->object->questions[1])
02259                                         {
02260                                                 $this->tpl->setVariable("BUTTON_UP", "<a href=\"" . $this->ctrl->getFormAction($this) . "&up=$data->question_id\"><img src=\"" . ilUtil::getImagePath("a_up.gif") . "\" alt=\"" . $this->lng->txt("up") . "\" border=\"0\" /></a>");
02261                                         }
02262                                         if ($data->question_id != $this->object->questions[count($this->object->questions)])
02263                                         {
02264                                                 $this->tpl->setVariable("BUTTON_DOWN", "<a href=\"" . $this->ctrl->getFormAction($this) . "&down=$data->question_id\"><img src=\"" . ilUtil::getImagePath("a_down.gif") . "\" alt=\"" . $this->lng->txt("down") . "\" border=\"0\" /></a>");
02265                                         }
02266                                 }
02267                                 $this->tpl->setVariable("QUESTION_COMMENT", $data->comment);
02268                                 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($data->type_tag));
02269                                 $this->tpl->setVariable("QUESTION_AUTHOR", $data->author);
02270                                 $this->tpl->setVariable("QUESTION_POOL", $questionpools[$data->obj_fi]);
02271                                 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
02272                                 $this->tpl->parseCurrentBlock();
02273                                 $counter++;
02274                         }
02275                 }
02276                 if ($counter == 0) {
02277                         $this->tpl->setCurrentBlock("Emptytable");
02278                         $this->tpl->setVariable("TEXT_EMPTYTABLE", $this->lng->txt("tst_no_questions_available"));
02279                         $this->tpl->parseCurrentBlock();
02280                 } else {
02281                         if (($rbacsystem->checkAccess("write", $this->ref_id) and ($total == 0))) {
02282                                 $this->tpl->setCurrentBlock("QFooter");
02283                                 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"\">");
02284                                 $this->tpl->setVariable("REMOVE", $this->lng->txt("remove_question"));
02285                                 $this->tpl->setVariable("MOVE", $this->lng->txt("move"));
02286                                 $this->tpl->parseCurrentBlock();
02287                         }
02288                 }
02289 
02290                 if (($rbacsystem->checkAccess("write", $this->ref_id) and ($total == 0))) {
02291                         $this->tpl->setCurrentBlock("QTypes");
02292                         $query = "SELECT * FROM qpl_question_type";
02293                         $query_result = $this->ilias->db->query($query);
02294                         while ($data = $query_result->fetchRow(DB_FETCHMODE_OBJECT))
02295                         {
02296                                 $this->tpl->setVariable("QUESTION_TYPE_ID", $data->type_tag);
02297                                 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($data->type_tag));
02298                                 $this->tpl->parseCurrentBlock();
02299                         }
02300                         $this->tpl->parseCurrentBlock();
02301                 }
02302                 $this->tpl->setCurrentBlock("adm_content");
02303                 $this->tpl->setVariable("ACTION_QUESTION_FORM", $this->ctrl->getFormAction($this));
02304                 $this->tpl->setVariable("QUESTION_TITLE", $this->lng->txt("tst_question_title"));
02305                 $this->tpl->setVariable("QUESTION_COMMENT", $this->lng->txt("description"));
02306                 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("tst_question_type"));
02307                 $this->tpl->setVariable("QUESTION_AUTHOR", $this->lng->txt("author"));
02308                 $this->tpl->setVariable("QUESTION_POOL", $this->lng->txt("qpl"));
02309 
02310                 if (($rbacsystem->checkAccess("write", $this->ref_id) and ($total == 0))) {
02311                         $this->tpl->setVariable("BUTTON_INSERT_QUESTION", $this->lng->txt("tst_browse_for_questions"));
02312                         $this->tpl->setVariable("TEXT_CREATE_NEW", " " . strtolower($this->lng->txt("or")) . " " . $this->lng->txt("create_new"));
02313                         $this->tpl->setVariable("BUTTON_CREATE_QUESTION", $this->lng->txt("create"));
02314                         $this->tpl->setVariable("TXT_OR", $this->lng->txt("or"));
02315                         $this->tpl->setVariable("TEXT_RANDOM_SELECT", $this->lng->txt("random_selection"));
02316                 }
02317 
02318                 $this->tpl->parseCurrentBlock();
02319         }
02320 
02321         function takenObject() {
02322         }
02323         
02331         function addMarkStepObject()
02332         {
02333                 $this->saveMarkSchemaFormData();
02334                 $this->object->mark_schema->add_mark_step();
02335                 $this->marksObject();
02336         }
02337 
02345         function saveMarkSchemaFormData()
02346         {
02347                 $this->object->mark_schema->flush();
02348                 foreach ($_POST as $key => $value) {
02349                         if (preg_match("/mark_short_(\d+)/", $key, $matches)) {
02350                                 $this->object->mark_schema->add_mark_step($_POST["mark_short_$matches[1]"], $_POST["mark_official_$matches[1]"], $_POST["mark_percentage_$matches[1]"], $_POST["passed_$matches[1]"]);
02351                         }
02352                 }
02353                 $this->object->ects_grades["A"] = $_POST["ects_grade_a"];
02354                 $this->object->ects_grades["B"] = $_POST["ects_grade_b"];
02355                 $this->object->ects_grades["C"] = $_POST["ects_grade_c"];
02356                 $this->object->ects_grades["D"] = $_POST["ects_grade_d"];
02357                 $this->object->ects_grades["E"] = $_POST["ects_grade_e"];
02358                 if ($_POST["chbUseFX"])
02359                 {
02360                         $this->object->ects_fx = $_POST["percentFX"];
02361                 }
02362                 else
02363                 {
02364                         $this->object->ects_fx = "";
02365                 }
02366                 $this->object->ects_output = $_POST["chbECTS"];
02367         }
02368         
02376         function addSimpleMarkSchemaObject()
02377         {
02378                 $this->object->mark_schema->create_simple_schema($this->lng->txt("failed_short"), $this->lng->txt("failed_official"), 0, 0, $this->lng->txt("passed_short"), $this->lng->txt("passed_official"), 50, 1);
02379                 $this->marksObject();
02380         }
02381         
02389         function deleteMarkStepsObject()
02390         {
02391                 $this->saveMarkSchemaFormData();
02392                 $delete_mark_steps = array();
02393                 foreach ($_POST as $key => $value) {
02394                         if (preg_match("/cb_(\d+)/", $key, $matches)) {
02395                                 array_push($delete_mark_steps, $matches[1]);
02396                         }
02397                 }
02398                 if (count($delete_mark_steps)) {
02399                         $this->object->mark_schema->delete_mark_steps($delete_mark_steps);
02400                 } else {
02401                         sendInfo($this->lng->txt("tst_delete_missing_mark"));
02402                 }
02403                 $this->marksObject();
02404         }
02405 
02413         function cancelMarksObject()
02414         {
02415                 sendInfo($this->lng->txt("msg_cancel"), true);
02416                 $this->ctrl->redirect($this, "properties");
02417         }
02418         
02426         function saveMarksObject()
02427         {
02428                 $this->saveMarkSchemaFormData();
02429                 
02430                 $mark_check = $this->object->checkMarks();
02431                 if ($mark_check !== true)
02432                 {
02433                         sendInfo($this->lng->txt($mark_check));
02434                 }
02435                 elseif ($_POST["chbECTS"] && ((strcmp($_POST["ects_grade_a"], "") == 0) or (strcmp($_POST["ects_grade_b"], "") == 0) or (strcmp($_POST["ects_grade_c"], "") == 0) or (strcmp($_POST["ects_grade_d"], "") == 0) or (strcmp($_POST["ects_grade_e"], "") == 0)))
02436                 {
02437                         sendInfo($this->lng->txt("ects_fill_out_all_values"), true);
02438                 }
02439                 elseif (($_POST["ects_grade_a"] > 100) or ($_POST["ects_grade_a"] < 0))
02440                 {
02441                         sendInfo($this->lng->txt("ects_range_error_a"), true);
02442                 }
02443                 elseif (($_POST["ects_grade_b"] > 100) or ($_POST["ects_grade_b"] < 0))
02444                 {
02445                         sendInfo($this->lng->txt("ects_range_error_b"), true);
02446                 }
02447                 elseif (($_POST["ects_grade_c"] > 100) or ($_POST["ects_grade_c"] < 0))
02448                 {
02449                         sendInfo($this->lng->txt("ects_range_error_c"), true);
02450                 }
02451                 elseif (($_POST["ects_grade_d"] > 100) or ($_POST["ects_grade_d"] < 0))
02452                 {
02453                         sendInfo($this->lng->txt("ects_range_error_d"), true);
02454                 }
02455                 elseif (($_POST["ects_grade_e"] > 100) or ($_POST["ects_grade_e"] < 0))
02456                 {
02457                         sendInfo($this->lng->txt("ects_range_error_e"), true);
02458                 }
02459                 else 
02460                 {
02461                         $this->object->mark_schema->saveToDb($this->object->getTestId());
02462                         $this->object->saveCompleteStatus();
02463                         if ($this->object->getReportingDate())
02464                         {
02465                                 $fxpercent = "";
02466                                 if ($_POST["chbUseFX"])
02467                                 {
02468                                         $fxpercent = ilUtil::stripSlashes($_POST["percentFX"]);
02469                                 }
02470                                 $this->object->saveECTSStatus($_POST["chbECTS"], $fxpercent, $this->object->ects_grades["A"], $this->object->ects_grades["B"], $this->object->ects_grades["C"], $this->object->ects_grades["D"], $this->object->ects_grades["E"]);
02471                         }
02472                         sendInfo($this->lng->txt("msg_obj_modified"), true);
02473                 }
02474                 $this->marksObject();
02475         }
02476         
02477         function marksObject() {
02478                 global $rbacsystem;
02479 
02480                 if ((!$rbacsystem->checkAccess("read", $this->ref_id)) && (!$rbacsystem->checkAccess("write", $this->ref_id))) 
02481                 {
02482                         // allow only read and write access
02483                         sendInfo($this->lng->txt("cannot_edit_test"), true);
02484                         $path = $this->tree->getPathFull($this->object->getRefID());
02485                         ilUtil::redirect($this->getReturnLocation("cancel","../repository.php?cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
02486                         return;
02487                 }
02488 
02489                 $this->object->mark_schema->sort();
02490         
02491                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_marks.html", true);
02492                 $marks = $this->object->mark_schema->mark_steps;
02493                 $rows = array("tblrow1", "tblrow2");
02494                 $counter = 0;
02495                 foreach ($marks as $key => $value) {
02496                         $this->tpl->setCurrentBlock("markrow");
02497                         $this->tpl->setVariable("MARK_SHORT", $value->get_short_name());
02498                         $this->tpl->setVariable("MARK_OFFICIAL", $value->get_official_name());
02499                         $this->tpl->setVariable("MARK_PERCENTAGE", sprintf("%.2f", $value->get_minimum_level()));
02500                         $this->tpl->setVariable("MARK_PASSED", strtolower($this->lng->txt("tst_mark_passed")));
02501                         $this->tpl->setVariable("MARK_ID", "$key");
02502                         $this->tpl->setVariable("ROW_CLASS", $rows[$counter % 2]);
02503                         if ($value->get_passed()) {
02504                                 $this->tpl->setVariable("MARK_PASSED_CHECKED", " checked=\"checked\"");
02505                         }
02506                         $this->tpl->parseCurrentBlock();
02507                         $counter++;
02508                 }
02509                 if (count($marks) == 0) {
02510                         $this->tpl->setCurrentBlock("Emptyrow");
02511                         $this->tpl->setVariable("EMPTY_ROW", $this->lng->txt("tst_no_marks_defined"));
02512                         $this->tpl->setVariable("ROW_CLASS", $rows[$counter % 2]);
02513                         $this->tpl->parseCurrentBlock();
02514                 } else {
02515                         if ($rbacsystem->checkAccess("write", $this->ref_id)) {
02516                                 $this->tpl->setCurrentBlock("Footer");
02517                                 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"\">");
02518                                 $this->tpl->setVariable("BUTTON_EDIT", $this->lng->txt("edit"));
02519                                 $this->tpl->setVariable("BUTTON_DELETE", $this->lng->txt("delete"));
02520                                 $this->tpl->parseCurrentBlock();
02521                         }
02522                 }
02523                 
02524                 if ($this->object->getReportingDate())
02525                 {
02526                         $this->tpl->setCurrentBlock("ects");
02527                         if ($this->object->ects_output)
02528                         {
02529                                 $this->tpl->setVariable("CHECKED_ECTS", " checked=\"checked\"");
02530                         }
02531                         $this->tpl->setVariable("TEXT_OUTPUT_ECTS_GRADES", $this->lng->txt("ects_output_of_ects_grades"));
02532                         $this->tpl->setVariable("TEXT_ALLOW_ECTS_GRADES", $this->lng->txt("ects_allow_ects_grades"));
02533                         $this->tpl->setVariable("TEXT_USE_FX", $this->lng->txt("ects_use_fx_grade"));
02534                         if (preg_match("/\d+/", $this->object->ects_fx))
02535                         {
02536                                 $this->tpl->setVariable("CHECKED_FX", " checked=\"checked\"");
02537                                 $this->tpl->setVariable("VALUE_PERCENT_FX", sprintf("value=\"%s\" ", $this->object->ects_fx));
02538                         }
02539                         $this->tpl->setVariable("TEXT_PERCENT", $this->lng->txt("ects_use_fx_grade_part2"));
02540                         $this->tpl->setVariable("ECTS_GRADE", $this->lng->txt("ects_grade"));
02541                         $this->tpl->setVariable("PERCENTILE", $this->lng->txt("percentile"));
02542                         $this->tpl->setVariable("ECTS_GRADE_A", "A - " . $this->lng->txt("ects_grade_a_short"));
02543                         $this->tpl->setVariable("VALUE_GRADE_A", $this->object->ects_grades["A"]);
02544                         $this->tpl->setVariable("ECTS_GRADE_B", "B - " . $this->lng->txt("ects_grade_b_short"));
02545                         $this->tpl->setVariable("VALUE_GRADE_B", $this->object->ects_grades["B"]);
02546                         $this->tpl->setVariable("ECTS_GRADE_C", "C - " . $this->lng->txt("ects_grade_c_short"));
02547                         $this->tpl->setVariable("VALUE_GRADE_C", $this->object->ects_grades["C"]);
02548                         $this->tpl->setVariable("ECTS_GRADE_D", "D - " . $this->lng->txt("ects_grade_d_short"));
02549                         $this->tpl->setVariable("VALUE_GRADE_D", $this->object->ects_grades["D"]);
02550                         $this->tpl->setVariable("ECTS_GRADE_E", "E - " . $this->lng->txt("ects_grade_e_short"));
02551                         $this->tpl->setVariable("VALUE_GRADE_E", $this->object->ects_grades["E"]);
02552                         
02553                         $this->tpl->parseCurrentBlock();
02554                 }
02555 
02556                 $this->tpl->setCurrentBlock("adm_content");
02557                 $this->tpl->setVariable("ACTION_MARKS", $this->ctrl->getFormAction($this));
02558                 $this->tpl->setVariable("HEADER_SHORT", $this->lng->txt("tst_mark_short_form"));
02559                 $this->tpl->setVariable("HEADER_OFFICIAL", $this->lng->txt("tst_mark_official_form"));
02560                 $this->tpl->setVariable("HEADER_PERCENTAGE", $this->lng->txt("tst_mark_minimum_level"));
02561                 $this->tpl->setVariable("HEADER_PASSED", $this->lng->txt("tst_mark_passed"));
02562                 if ($rbacsystem->checkAccess("write", $this->ref_id)) {
02563                         $this->tpl->setVariable("BUTTON_NEW", $this->lng->txt("tst_mark_create_new_mark_step"));
02564                         $this->tpl->setVariable("BUTTON_NEW_SIMPLE", $this->lng->txt("tst_mark_create_simple_mark_schema"));
02565                         $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
02566                         $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
02567                 }
02568                 $this->tpl->parseCurrentBlock();
02569         }
02570 
02571         function runObject()
02572         {
02573                 global $ilUser;
02574                 global $rbacsystem;
02575 
02576                 if (!$rbacsystem->checkAccess("read", $this->ref_id)) 
02577                 {
02578                         // only with read access it is possible to run the test
02579                         $this->ilias->raiseError($this->lng->txt("cannot_execute_test"),$this->ilias->error_obj->MESSAGE);
02580                 }
02581 
02582                 if ($_POST["cmd"]["cancelTest"])
02583                 {
02584                         sendInfo($this->lng->txt("test_cancelled"), true);
02585                         $path = $this->tree->getPathFull($this->object->getRefID());
02586                         ilUtil::redirect($this->getReturnLocation("cancel","../repository.php?cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
02587                         exit();
02588                 }
02589                 
02590                 $add_parameter = $this->getAddParameter();
02591                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.il_as_tst_content.html", true);
02592                 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
02593                 $title = $this->object->getTitle();
02594                 $maxprocessingtimereached = 0;
02595                 if (($this->object->getEnableProcessingTime()) and ($this->object->getCompleteWorkingTime($ilUser->id) > $this->object->getProcessingTimeInSeconds()))
02596                 {
02597                         // maximum processing time reached
02598                         $maxprocessingtimereached = 1;
02599                 }
02600 
02601                 $directfeedback = 0;
02602                 // catch feedback message
02603                 sendInfo();
02604 
02605                 if ($_POST["cmd"]["next"] or $_POST["cmd"]["previous"] or $_POST["cmd"]["postpone"] or $_POST["cmd"]["directfeedback"] or isset($_GET["selImage"]))
02606                 {
02607                         // set new finish time for test
02608                         if ($_SESSION["active_time_id"])
02609                         {
02610                                 $this->object->updateWorkingTime($_SESSION["active_time_id"]);
02611                         }
02612                         if (($this->object->getEnableProcessingTime()) and ($this->object->getCompleteWorkingTime($ilUser->id) > $this->object->getProcessingTimeInSeconds()))
02613                         {
02614                                 // maximum processing time reached
02615                                 $maxprocessingtimereached = 1;
02616                         }
02617 
02618                         // save question solution
02619                         $saveResult = false;
02620                         if (!($this->object->endingTimeReached() and ($this->object->getTestType() == TYPE_ASSESSMENT)) and (!$maxprocessingtimereached))
02621                         {
02622                                 // but only if the ending time is not reached
02623                                 $question_gui = $this->object->createQuestionGUI("", $this->object->getQuestionIdFromActiveUserSequence($_GET["sequence"]));
02624                                 $saveResult = $question_gui->object->saveWorkingData($this->object->getTestId());
02625 
02626                                 if ($_POST["cmd"]["directfeedback"])
02627                                 {
02628                                         $directfeedback = 1;
02629                                 }
02630                         }
02631                 }
02632                 if ($_POST["cmd"]["start"] or $_POST["cmd"]["resume"])
02633                 {
02634                         if ($_POST["cmd"]["start"] && $this->object->isRandomTest())
02635                         {
02636                                 if ($this->object->getRandomQuestionCount() > 0)
02637                                 {
02638                                         $qpls =& $this->object->getRandomQuestionpools();
02639                                         $rndquestions = $this->object->randomSelectQuestions($this->object->getRandomQuestionCount(), 0, 1, $qpls);
02640                                         $allquestions = array();
02641                                         foreach ($rndquestions as $question_id)
02642                                         {
02643                                                 array_push($allquestions, $question_id);
02644                                         }
02645                                         srand ((float)microtime()*1000000);
02646                                         shuffle($allquestions);
02647                                         foreach ($allquestions as $question_id)
02648                                         {
02649                                                 $this->object->saveRandomQuestion($question_id);
02650                                         }
02651                                         $this->object->loadQuestions();
02652                                 }
02653                                 else
02654                                 {
02655                                         $qpls =& $this->object->getRandomQuestionpools();
02656                                         $allquestions = array();
02657                                         foreach ($qpls as $key => $value)
02658                                         {
02659                                                 if ($value["count"] > 0)
02660                                                 {
02661                                                         $rndquestions = $this->object->randomSelectQuestions($value["count"], $value["qpl"], 1);
02662                                                         foreach ($rndquestions as $question_id)
02663                                                         {
02664                                                                 array_push($allquestions, $question_id);
02665                                                         }
02666                                                 }
02667                                         }
02668                                         srand ((float)microtime()*1000000);
02669                                         shuffle($allquestions);
02670                                         foreach ($allquestions as $question_id)
02671                                         {
02672                                                 $this->object->saveRandomQuestion($question_id);
02673                                         }
02674                                         $this->object->loadQuestions();
02675                                 }
02676                         }
02677                         
02678                         // create new time dataset and set start time
02679                         $active_time_id = $this->object->startWorkingTime($ilUser->id);
02680                         $_SESSION["active_time_id"] = $active_time_id;
02681                         if ($_POST["chb_javascript"])
02682                         {
02683                                 $ilUser->setPref("tst_javascript", 1);
02684                                 $ilUser->writePref("tst_javascript", 1);
02685                         }
02686                         else
02687                         {
02688                                 $ilUser->setPref("tst_javascript", 0);
02689                                 $ilUser->writePref("tst_javascript", 0);
02690                         }
02691                 }
02692 
02693                 $this->sequence = $_GET["sequence"];
02694                 if ($_POST["cmd"]["deleteresults"] or $_POST["cmd"]["canceldeleteresults"] or $_POST["cmd"]["confirmdeleteresults"])
02695                 {
02696                         // reset sequence. it is not needed for test reset
02697                         $this->sequence = "";
02698                 }
02699                 if (($_POST["cmd"]["next"]) and $saveResult)
02700                 {
02701                         if($_GET['crs_show_result'])
02702                         {
02703                                 $this->sequence = $this->object->incrementSequenceByResult($this->sequence);
02704                         }
02705                         else
02706                         {
02707                                 $this->sequence++;
02708                         }
02709                 }
02710                 elseif (($_POST["cmd"]["previous"]) and ($this->sequence != 0) and ($saveResult))
02711                 {
02712                         if($_GET['crs_show_result'])
02713                         {
02714                                 $this->sequence = $this->object->decrementSequenceByResult($this->sequence);
02715                         }
02716                         else
02717                         {
02718                                 $this->sequence--;
02719                         }
02720                 }
02721                 $this->setLocator();
02722 
02723                 if (!empty($title))
02724                 {
02725                         $this->tpl->setVariable("HEADER", $title);
02726                 }
02727 
02728                 if ($_POST["cmd"]["confirmdeleteresults"])
02729                 {
02730                         $this->object->deleteResults($ilUser->id);
02731                         sendInfo($this->lng->txt("tst_confirm_delete_results_info"));
02732                 }
02733                 
02734                 if ($_POST["cmd"]["deleteresults"])
02735                 {
02736                         $this->confirmDeleteResults();
02737                         return;
02738                 }
02739                 
02740                 if ($_GET["evaluation"])
02741                 {
02742                         $this->outEvaluationForm();
02743                         return;
02744                 }
02745 
02746                 if (($_POST["cmd"]["showresults"]) or ($_GET["sortres"]))
02747                 {
02748                         $this->outTestResults();
02749                         return;
02750                 }
02751 
02752                 if (!$this->sequence)
02753                 {
02754                         // show introduction page
02755                         $this->outIntroductionPage($maxprocessingtimereached);
02756                 }
02757                 else
02758                 {
02759                         if ($this->object->endingTimeReached() and ($this->object->getTestType() == TYPE_ASSESSMENT))
02760                         {
02761                                 sendInfo(sprintf($this->lng->txt("detail_ending_time_reached"), ilFormat::ftimestamp2datetimeDB($this->object->getEndingTime())));
02762                                 $this->object->setActiveTestUser(1, "", true);
02763                                 if (!$this->object->canViewResults()) 
02764                                 {
02765                                         $this->outIntroductionPage($maxprocessingtimereached);
02766                                 }
02767                                 else
02768                                 {
02769                                         $this->outTestResults();
02770                                 }
02771                                 return;
02772                         }
02773                         if ($maxprocessingtimereached)
02774                         {
02775                                 sendInfo($this->lng->txt("detail_max_processing_time_reached"));
02776                                 $this->object->setActiveTestUser(1, "", true);
02777                                 if (!$this->object->canViewResults()) 
02778                                 {
02779                                         $this->outIntroductionPage($maxprocessingtimereached);
02780                                 }
02781                                 else
02782                                 {
02783                                         $this->outTestResults();
02784                                 }
02785                                 return;
02786                         }
02787                         $user_question_order =& $this->object->getAllQuestionsForActiveUser();
02788                         if ($this->sequence <= $this->object->getQuestionCount())
02789                         {
02790                                 if ($this->object->getScoreReporting() == REPORT_AFTER_QUESTION)
02791                                 {
02792                                         $this->tpl->setCurrentBlock("direct_feedback");
02793                                         $this->tpl->setVariable("TEXT_DIRECT_FEEDBACK", $this->lng->txt("direct_feedback"));
02794                                         $this->tpl->parseCurrentBlock();
02795                                 }
02796                                 
02797                                 // show next/previous question
02798                                 $postpone = "";
02799                                 if ($_POST["cmd"]["postpone"])
02800                                 {
02801                                         $postpone = $this->sequence;
02802                                 }
02803                                 $this->object->setActiveTestUser($this->sequence, $postpone);
02804                                 if ($this->sequence == $this->object->getQuestionCount())
02805                                 {
02806                                         $finish = true;
02807                                 }
02808                                 else
02809                                 {
02810                                         $finish = false;
02811                                 }
02812 
02813                                 $postpone = false;
02814 
02815                                 if ($this->object->getSequenceSettings() == TEST_POSTPONE)
02816                                 {
02817                                         $postpone = true;
02818                                 }
02819                                 $active = $this->object->getActiveTestUser();
02820 
02821                                 if(!$_GET['crs_show_result'])
02822                                 {
02823                                         $this->tpl->setCurrentBlock("percentage");
02824                                         $this->tpl->setVariable("PERCENTAGE", (int)(($this->sequence / count($user_question_order))*200));
02825                                         $this->tpl->setVariable("PERCENTAGE_VALUE", (int)(($this->sequence / count($user_question_order))*100));
02826                                         $this->tpl->setVariable("HUNDRED_PERCENT", "200");
02827                                         $this->tpl->setVariable("TEXT_COMPLETED", $this->lng->txt("completed") . ": ");
02828                                         $this->tpl->parseCurrentBlock();
02829                                         $this->tpl->setCurrentBlock("percentage_bottom");
02830                                         $this->tpl->setVariable("PERCENTAGE", (int)(($this->sequence / count($user_question_order))*200));
02831                                         $this->tpl->setVariable("PERCENTAGE_VALUE", (int)(($this->sequence / count($user_question_order))*100));
02832                                         $this->tpl->setVariable("HUNDRED_PERCENT", "200");
02833                                         $this->tpl->setVariable("TEXT_COMPLETED", $this->lng->txt("completed") . ": ");
02834                                         $this->tpl->parseCurrentBlock();
02835                                 }
02836                                 $this->tpl->setCurrentBlock("cancel_test");
02837                                 $this->tpl->setVariable("TEXT_CANCELTEST", $this->lng->txt("cancel_test"));
02838                                 $this->tpl->setVariable("TEXT_ALTCANCELTEXT", $this->lng->txt("cancel_test"));
02839                                 $this->tpl->setVariable("TEXT_TITLECANCELTEXT", $this->lng->txt("cancel_test"));
02840                                 $this->tpl->setVariable("HREF_IMGCANCELTEST", $this->ctrl->getLinkTargetByClass(get_class($this), "run") . "&cancelTest=true");
02841                                 $this->tpl->setVariable("HREF_CANCELTEXT", $this->ctrl->getLinkTargetByClass(get_class($this), "run") . "&cancelTest=true");
02842                                 $this->tpl->setVariable("IMAGE_CANCEL", ilUtil::getImagePath("cancel.png"));
02843                                 $this->tpl->parseCurrentBlock();
02844                                 $this->tpl->setCurrentBlock("cancel_test_bottom");
02845                                 $this->tpl->setVariable("TEXT_CANCELTEST", $this->lng->txt("cancel_test"));
02846                                 $this->tpl->setVariable("TEXT_ALTCANCELTEXT", $this->lng->txt("cancel_test"));
02847                                 $this->tpl->setVariable("TEXT_TITLECANCELTEXT", $this->lng->txt("cancel_test"));
02848                                 $this->tpl->setVariable("HREF_IMGCANCELTEST", $this->ctrl->getLinkTargetByClass(get_class($this), "run") . "&cancelTest=true");
02849                                 $this->tpl->setVariable("HREF_CANCELTEXT", $this->ctrl->getLinkTargetByClass(get_class($this), "run") . "&cancelTest=true");
02850                                 $this->tpl->setVariable("IMAGE_CANCEL", ilUtil::getImagePath("cancel.png"));
02851                                 $this->tpl->parseCurrentBlock();
02852 
02853                                 if ($this->object->getEnableProcessingTime())
02854                                 {
02855                                         $this->tpl->setCurrentBlock("enableprocessingtime");
02856                                         $working_time = $this->object->getCompleteWorkingTime($ilUser->id);
02857                                         $processing_time = $this->object->getProcessingTimeInSeconds();
02858                                         $time_seconds = $working_time;
02859                                         $time_hours    = floor($time_seconds/3600);
02860                                         $time_seconds -= $time_hours   * 3600;
02861                                         $time_minutes  = floor($time_seconds/60);
02862                                         $time_seconds -= $time_minutes * 60;
02863                                         $this->tpl->setVariable("USER_WORKING_TIME", $this->lng->txt("tst_time_already_spent") . ": " . sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds));
02864                                         $time_seconds = $processing_time;
02865                                         $time_hours    = floor($time_seconds/3600);
02866                                         $time_seconds -= $time_hours   * 3600;
02867                                         $time_minutes  = floor($time_seconds/60);
02868                                         $time_seconds -= $time_minutes * 60;
02869                                         $this->tpl->setVariable("MAXIMUM_PROCESSING_TIME", $this->lng->txt("tst_processing_time") . ": " . sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds));
02870                                         $this->tpl->parseCurrentBlock();
02871                                 }
02872 
02873 
02874                                 $this->outWorkingForm($this->sequence, $finish, $this->object->getTestId(), $active, $postpone, $user_question_order, $directfeedback);
02875 
02876                         }
02877                         else
02878                         {
02879                                 // finish test
02880                                 $this->object->setActiveTestUser(1, "", true);
02881                                 if (!$this->object->canViewResults()) 
02882                                 {
02883                                         $this->outIntroductionPage($maxprocessingtimereached);
02884                                 }
02885                                 else
02886                                 {
02887                                         $this->outTestResults();
02888                                 }
02889                                 // Update objectives
02890                                 include_once './course/classes/class.ilCourseObjectiveResult.php';
02891 
02892                                 $tmp_obj_res =& new ilCourseObjectiveResult($ilUser->getId());
02893                                 $tmp_obj_res->updateResults($this->object->getTestResult($ilUser->getId()));
02894                                 unset($tmp_obj_res);
02895 
02896                                 if($_GET['crs_show_result'])
02897                                 {
02898                                         ilUtil::redirect($this->getReturnLocation("cancel","../repository.php?ref_id=".(int) $_GET['crs_show_result']));
02899                                 }
02900                                 
02901                         }
02902                 }
02903         }
02904 
02912         function outIntroductionPage($maxprocessingtimereached = 0)
02913         {
02914                 global $ilUser;
02915 
02916                 $add_parameter = $this->getAddParameter();
02917                 $active = $this->object->getActiveTestUser();
02918                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_introduction.html", true);
02919                 $this->tpl->setCurrentBlock("info_row");
02920                 $this->tpl->setVariable("TEXT_INFO_COL1", $this->lng->txt("tst_type") . ":");
02921                 $this->tpl->setVariable("TEXT_INFO_COL2", $this->lng->txt($this->object->test_types[$this->object->getTestType()]));
02922                 $this->tpl->parseCurrentBlock();
02923                 $this->tpl->setVariable("TEXT_INFO_COL1", $this->lng->txt("description") . ":");
02924                 $this->tpl->setVariable("TEXT_INFO_COL2", $this->object->getDescription());
02925                 $this->tpl->parseCurrentBlock();
02926                 $this->tpl->setVariable("TEXT_INFO_COL1", $this->lng->txt("tst_sequence") . ":");
02927                 if ($this->object->getSequenceSettings() == TEST_FIXED_SEQUENCE)
02928                 {
02929                         $seq_setting = "tst_sequence_fixed";
02930                 }
02931                 else
02932                 {
02933                         $seq_setting = "tst_sequence_postpone";
02934                 }
02935                 $this->tpl->setVariable("TEXT_INFO_COL2", $this->lng->txt($seq_setting));
02936                 $this->tpl->parseCurrentBlock();
02937                 $this->tpl->setVariable("TEXT_INFO_COL1", $this->lng->txt("tst_score_reporting") . ":");
02938                 if ($this->object->getScoreReporting() == REPORT_AFTER_QUESTION) {
02939                         $score_reporting = "tst_report_after_question";
02940                 } else {
02941                         $score_reporting = "tst_report_after_test";
02942                 }
02943                 $this->tpl->setVariable("TEXT_INFO_COL2", $this->lng->txt($score_reporting));
02944                 $this->tpl->parseCurrentBlock();
02945                 $this->tpl->setVariable("TEXT_INFO_COL1", $this->lng->txt("tst_nr_of_tries") . ":");
02946                 $num_of = $this->object->getNrOfTries();
02947                 if (!$num_of) {
02948                         $num_of = $this->lng->txt("unlimited");
02949                 }
02950                 $this->tpl->setVariable("TEXT_INFO_COL2", $num_of);
02951                 $this->tpl->parseCurrentBlock();
02952                 if ($num_of != 1)
02953                 {
02954                         // display number of tries of the user
02955                         $this->tpl->setVariable("TEXT_INFO_COL1", $this->lng->txt("tst_nr_of_tries_of_user") . ":");
02956                         $tries = $active->tries;
02957                         if (!$tries)
02958                         {
02959                                 $tries = $this->lng->txt("tst_no_tries");
02960                         }
02961                         $this->tpl->setVariable("TEXT_INFO_COL2", $tries);
02962                         $this->tpl->parseCurrentBlock();
02963                 }
02964 
02965                 if ($this->object->getEnableProcessingTime())
02966                 {
02967                         $working_time = $this->object->getCompleteWorkingTime($ilUser->id);
02968                         $processing_time = $this->object->getProcessingTimeInSeconds();
02969                         $this->tpl->setVariable("TEXT_INFO_COL1", $this->lng->txt("tst_processing_time") . ":");
02970                         $time_seconds = $processing_time;
02971                         $time_hours    = floor($time_seconds/3600);
02972                         $time_seconds -= $time_hours   * 3600;
02973                         $time_minutes  = floor($time_seconds/60);
02974                         $time_seconds -= $time_minutes * 60;
02975                         $this->tpl->setVariable("TEXT_INFO_COL2", sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds));
02976                         $this->tpl->parseCurrentBlock();
02977                         $this->tpl->setVariable("TEXT_INFO_COL1", $this->lng->txt("tst_time_already_spent") . ":");
02978                         $time_seconds = $working_time;
02979                         $time_hours    = floor($time_seconds/3600);
02980                         $time_seconds -= $time_hours   * 3600;
02981                         $time_minutes  = floor($time_seconds/60);
02982                         $time_seconds -= $time_minutes * 60;
02983                         $this->tpl->setVariable("TEXT_INFO_COL2", sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds));
02984                         $this->tpl->parseCurrentBlock();
02985                 }
02986 
02987                 if ($this->object->getStartingTime())
02988                 {
02989                         $this->tpl->setVariable("TEXT_INFO_COL1", $this->lng->txt("tst_starting_time") . ":");
02990                         $this->tpl->setVariable("TEXT_INFO_COL2", ilFormat::formatDate(ilFormat::ftimestamp2datetimeDB($this->object->getStartingTime())));
02991                         $this->tpl->parseCurrentBlock();
02992                 }
02993                 if ($this->object->getEndingTime())
02994                 {
02995                         $this->tpl->setVariable("TEXT_INFO_COL1", $this->lng->txt("tst_ending_time") . ":");
02996                         $this->tpl->setVariable("TEXT_INFO_COL2", ilFormat::formatDate(ilFormat::ftimestamp2datetimeDB($this->object->getEndingTime())));
02997                         $this->tpl->parseCurrentBlock();
02998                 }
02999 
03000                 $this->tpl->setCurrentBlock("info");
03001                 $this->tpl->setVariable("TEXT_USE_JAVASCRIPT", $this->lng->txt("tst_use_javascript"));
03002                 if ($ilUser->prefs["tst_javascript"])
03003                 {
03004                         $this->tpl->setVariable("CHECKED_JAVASCRIPT", "checked=\"checked\" ");
03005                 }
03006                 $this->tpl->parseCurrentBlock();
03007                 $seq = 1;
03008                 if ($active) {
03009                         $seq = $active->lastindex;
03010                 }
03011                 $add_sequence = "&sequence=$seq";
03012 
03013                 if($_GET['crs_show_result'])
03014                 {
03015                         $first_seq = $this->object->getFirstSequence();
03016                         $add_sequence = "&sequence=".$first_seq;
03017 
03018                         if(!$first_seq)
03019                         {
03020                                 sendInfo($this->lng->txt('crs_all_questions_answered_successfully'));
03021                         }
03022                 }
03023                 $test_disabled = false;
03024                 if ($active) {
03025                         $this->tpl->setCurrentBlock("resume");
03026                         if ($seq == 1)
03027                         {
03028                                 if(!$_GET['crs_show_result'] or $first_seq)
03029                                 {
03030                                         $this->tpl->setVariable("BTN_RESUME", $this->lng->txt("tst_start_test"));
03031                                 }
03032                         }
03033                         else
03034                         {
03035                                 $this->tpl->setVariable("BTN_RESUME", $this->lng->txt("tst_resume_test"));
03036                         }
03037                         if ((($active->tries >= $this->object->getNrOfTries()) and ($this->object->getNrOfTries() != 0)) or $maxprocessingtimereached) {
03038                                 $this->tpl->setVariable("DISABLED", " disabled");
03039                                 $test_disabled = true;
03040                                 $add_sequence = "";
03041                         }
03042                         else
03043                         {
03044                                 // if resume is active it is possible to reset the test
03045                                 $this->tpl->setCurrentBlock("delete_results");
03046                                 $this->tpl->setVariable("BTN_DELETERESULTS", $this->lng->txt("tst_delete_results"));
03047                                 $this->tpl->parseCurrentBlock();
03048                         }
03049                         $this->tpl->parseCurrentBlock();
03050                         $this->tpl->setCurrentBlock("results");
03051                         if (($active->tries < 1) or (!$this->object->canViewResults())) {
03052                                 $this->tpl->setVariable("DISABLED", " disabled");
03053                         }
03054                         $this->tpl->setVariable("BTN_RESULTS", $this->lng->txt("tst_show_results"));
03055                         $this->tpl->parseCurrentBlock();
03056                         if (!$this->object->canViewResults()) {
03057                                 $this->tpl->setCurrentBlock("report_date_not_reached");
03058                                 preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->object->getReportingDate(), $matches);
03059                                 $reporting_date = date($this->lng->text["lang_dateformat"] . " " . $this->lng->text["lang_timeformat"], mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]));
03060                                 $this->tpl->setVariable("RESULT_DATE_NOT_REACHED", sprintf($this->lng->txt("report_date_not_reached"), $reporting_date));
03061                                 $this->tpl->parseCurrentBlock();
03062                         }
03063                 }
03064                 else
03065                 {
03066                         if (($this->object->startingTimeReached() and (!$this->object->endingTimeReached())) or ($this->object->getTestType() != TYPE_ASSESSMENT))
03067                         {
03068                                 $this->tpl->setCurrentBlock("start");
03069                                 $this->tpl->setVariable("BTN_START", $this->lng->txt("tst_start_test"));
03070                                 if (!$this->object->isComplete())
03071                                 {
03072                                         $this->tpl->setVariable("DISABLED", " disabled=\"disabled\"");
03073                                         $test_disabled = true;
03074                                 }
03075                                 $this->tpl->parseCurrentBlock();
03076                         }
03077                         else
03078                         {
03079                                 $this->tpl->setCurrentBlock("startingtime");
03080                                 $this->tpl->setVariable("IMAGE_STARTING_TIME", ilUtil::getImagePath("time.gif", true));
03081                                 if (!$this->object->startingTimeReached())
03082                                 {
03083                                         $this->tpl->setVariable("ALT_STARTING_TIME_NOT_REACHED", $this->lng->txt("starting_time_not_reached"));
03084                                         $this->tpl->setVariable("TEXT_STARTING_TIME_NOT_REACHED", sprintf($this->lng->txt("detail_starting_time_not_reached"), ilFormat::ftimestamp2datetimeDB($this->object->getStartingTime())));
03085                                 }
03086                                 else
03087                                 {
03088                                         $this->tpl->setVariable("ALT_STARTING_TIME_NOT_REACHED", $this->lng->txt("ending_time_reached"));
03089                                         $this->tpl->setVariable("TEXT_STARTING_TIME_NOT_REACHED", sprintf($this->lng->txt("detail_ending_time_reached"), ilFormat::ftimestamp2datetimeDB($this->object->getEndingTime())));
03090                                 }
03091                                 $this->tpl->parseCurrentBlock();
03092                         }
03093                 }
03094 
03095                 $this->tpl->setCurrentBlock("adm_content");
03096                 if ($test_disabled)
03097                 {
03098                         if ($maxprocessingtimereached)
03099                         {
03100                                 sendInfo($this->lng->txt("detail_max_processing_time_reached"));
03101                         }
03102                         else if (!$this->object->isComplete())
03103                         {
03104                                 sendInfo($this->lng->txt("warning_test_not_complete"));
03105                         }
03106                         else
03107                         {
03108                                 $this->tpl->setVariable("MAXIMUM_NUMBER_OF_TRIES_REACHED", $this->lng->txt("maximum_nr_of_tries_reached"));
03109                         }
03110                 }               
03111                 $introduction = $this->object->getIntroduction();
03112                 $introduction = preg_replace("/\n/i", "<br />", $introduction);
03113                 $this->tpl->setVariable("TEXT_INTRODUCTION", $introduction);
03114                 $this->tpl->setVariable("FORMACTION", $this->getCallingScript() . "$add_parameter$add_sequence");
03115                 $this->tpl->parseCurrentBlock();
03116         }
03117         
03125         function outWorkingForm($sequence = 1, $finish = false, $test_id, $active, $postpone_allowed, $user_question_order, $directfeedback = 0)
03126         {
03127                 global $ilUser;
03128                 
03129                 include_once("classes/class.ilObjStyleSheet.php");
03130                 $this->tpl->setCurrentBlock("ContentStyle");
03131                 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
03132                 ilObjStyleSheet::getContentStylePath(0));
03133                 $this->tpl->parseCurrentBlock();
03134 
03135                 // syntax style
03136                 $this->tpl->setCurrentBlock("SyntaxStyle");
03137                 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
03138                 ilObjStyleSheet::getSyntaxStylePath());
03139                 $this->tpl->parseCurrentBlock();
03140 
03141                 $question_gui = $this->object->createQuestionGUI("", $this->object->getQuestionIdFromActiveUserSequence($sequence));
03142                 if ($ilUser->prefs["tst_javascript"])
03143                 {
03144                         $question_gui->object->setOutputType(OUTPUT_JAVASCRIPT);
03145                 }
03146                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_preview.html", true);
03147 
03148                 $is_postponed = false;
03149                 if ($active)
03150                 {
03151                         if (!preg_match("/(^|\D)" . $question_gui->object->getId() . "($|\D)/", $active->postponed) and !($active->postponed == $question_gui->object->getId()))
03152                         {
03153                                 $is_postponed = false;
03154                         }
03155                         else
03156                         {
03157                                 $is_postponed = true;
03158                         }
03159                 }
03160 
03161 //              $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_question_output.html", true);
03162                 $formaction = $this->getCallingScript() . $this->getAddParameter() . "&sequence=$sequence";
03163                 // output question
03164                 switch ($question_gui->getQuestionType())
03165                 {
03166                         case "qt_imagemap":
03167                                 $question_gui->outWorkingForm($test_id, $is_postponed, $directfeedback, $formaction);
03168                                 $info =& $question_gui->object->getReachedInformation($ilUser->id, $test_id);
03169                                 if (strcmp($info[0]["value"], "") != 0)
03170                                 {
03171                                         $formaction .= "&selImage=" . $info[0]["value"];
03172                                 }
03173                                 break;
03174 
03175                         default:
03176                                 $question_gui->outWorkingForm($test_id, $is_postponed, $directfeedback);
03177                                 break;
03178                 }
03179 
03180                 if(!$_GET['crs_show_result'])
03181                 {
03182                         if ($sequence == 1)
03183                         {
03184                                 $this->tpl->setCurrentBlock("prev");
03185                                 $this->tpl->setVariable("BTN_PREV", "&lt;&lt; " . $this->lng->txt("save_introduction"));
03186                                 $this->tpl->parseCurrentBlock();
03187                                 $this->tpl->setCurrentBlock("prev_bottom");
03188                                 $this->tpl->setVariable("BTN_PREV", "&lt;&lt; " . $this->lng->txt("save_introduction"));
03189                                 $this->tpl->parseCurrentBlock();
03190                         }
03191                         else
03192                         {
03193                                 $this->tpl->setCurrentBlock("prev");
03194                                 $this->tpl->setVariable("BTN_PREV", "&lt;&lt; " . $this->lng->txt("save_previous"));
03195                                 $this->tpl->parseCurrentBlock();
03196                                 $this->tpl->setCurrentBlock("prev_bottom");
03197                                 $this->tpl->setVariable("BTN_PREV", "&lt;&lt; " . $this->lng->txt("save_previous"));
03198                                 $this->tpl->parseCurrentBlock();
03199                         }
03200                 }
03201 
03202                 if ($postpone_allowed)
03203                 {
03204                         if (!$is_postponed)
03205                         {
03206                                 $this->tpl->setCurrentBlock("postpone");
03207                                 $this->tpl->setVariable("BTN_POSTPONE", $this->lng->txt("postpone"));
03208                                 $this->tpl->parseCurrentBlock();
03209                                 $this->tpl->setCurrentBlock("postpone_bottom");
03210                                 $this->tpl->setVariable("BTN_POSTPONE", $this->lng->txt("postpone"));
03211                                 $this->tpl->parseCurrentBlock();
03212                         }
03213                 }
03214 
03215                 if ($finish)
03216                 {
03217                         $this->tpl->setCurrentBlock("next");
03218                         $this->tpl->setVariable("BTN_NEXT", $this->lng->txt("save_finish") . " &gt;&gt;");
03219                         $this->tpl->parseCurrentBlock();
03220                         $this->tpl->setCurrentBlock("next_bottom");
03221                         $this->tpl->setVariable("BTN_NEXT", $this->lng->txt("save_finish") . " &gt;&gt;");
03222                         $this->tpl->parseCurrentBlock();
03223                 }
03224                 else
03225                 {
03226                         $this->tpl->setCurrentBlock("next");
03227                         $this->tpl->setVariable("BTN_NEXT", $this->lng->txt("save_next") . " &gt;&gt;");
03228                         $this->tpl->parseCurrentBlock();
03229                         $this->tpl->setCurrentBlock("next_bottom");
03230                         $this->tpl->setVariable("BTN_NEXT", $this->lng->txt("save_next") . " &gt;&gt;");
03231                         $this->tpl->parseCurrentBlock();
03232                 }
03233 
03234                 $this->tpl->setCurrentBlock("adm_content");
03235                 $this->tpl->setVariable("FORMACTION", $formaction);
03236 
03237                 $this->tpl->parseCurrentBlock();
03238         }
03239 
03240         function outEvaluationForm()
03241         {
03242                 global $ilUser;
03243 
03244                 include_once("classes/class.ilObjStyleSheet.php");
03245                 $this->tpl->setCurrentBlock("ContentStyle");
03246                 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
03247                 $this->tpl->parseCurrentBlock();
03248 
03249                 // syntax style
03250                 $this->tpl->setCurrentBlock("SyntaxStyle");
03251                 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
03252                         ilObjStyleSheet::getSyntaxStylePath());
03253                 $this->tpl->parseCurrentBlock();
03254 
03255                 $test_id = $this->object->getTestId();
03256                 $question_gui = $this->object->createQuestionGUI("", $_GET["evaluation"]);
03257 //              $this->tpl->addBlockFile("RESULT_DESCRIPTION", "result_description", "tpl.il_as_tst_result_table.html", true);
03258                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_evaluation.html", true);
03259                 $formaction = $this->getCallingScript() . $this->getAddParameter() . "&sequence=$sequence";
03260                 switch ($question_gui->getQuestionType())
03261                 {
03262                         case "qt_imagemap":
03263                                 $question_gui->outWorkingForm($test_id, "", 1, $formaction);
03264                                 break;
03265                         case "qt_javaapplet":
03266                                 $question_gui->outWorkingForm("", "", 0);
03267                                 break;
03268                         default:
03269                                 $question_gui->outWorkingForm($test_id, "", 1);
03270                 }
03271 //              $this->tpl->setCurrentBlock("result_description");
03272 //              $question_gui->outUserSolution($ilUser->id, $this->object->getTestId());
03273                 $this->tpl->setCurrentBlock("adm_content");
03274                 $this->tpl->setVariable("FORMACTION", $this->getCallingScript() . $this->getAddParameter());
03275                 $this->tpl->setVariable("BACKLINK_TEXT", "&lt;&lt; " . $this->lng->txt("back"));
03276                 $this->tpl->parseCurrentBlock();
03277         }
03278 
03286         function outStatSelectedSearchResults()
03287         {
03288                 include_once ("./classes/class.ilSearch.php");
03289                 global $ilUser;
03290                 
03291                 if (is_array($_POST["search_for"]))
03292                 {
03293                         if (in_array("usr", $_POST["search_for"]) or in_array("grp", $_POST["search_for"]))
03294                         {
03295                                 $search =& new ilSearch($ilUser->id);
03296                                 $search->setSearchString($_POST["search_term"]);
03297                                 $search->setCombination($_POST["concatenation"]);
03298                                 $search->setSearchFor($_POST["search_for"]);
03299                                 $search->setSearchType("new");
03300                                 if($search->validate($message))
03301                                 {
03302                                         $search->performSearch();
03303                                 }
03304                                 if ($message)
03305                                 {
03306                                         //sendInfo($message);
03307                                 }
03308                                 if(!$search->getNumberOfResults() && $search->getSearchFor())
03309                                 {
03310                                         sendInfo($this->lng->txt("search_no_match"));
03311                                         return;
03312                                 }
03313                                 $buttons = array("add");
03314                                 $participants =& $this->object->evalTotalPersonsArray();
03315                                 $eval_users = $this->object->getEvaluationUsers($ilUser->id);
03316                                 if ($searchresult = $search->getResultByType("usr"))
03317                                 {
03318                                         $users = array();
03319                                         foreach ($searchresult as $result_array)
03320                                         {
03321                                                 if (!array_key_exists($result_array["id"], $eval_users))
03322                                                 {
03323                                                         if (array_key_exists($result_array["id"], $participants))
03324                                                         {
03325                                                                 $users[$result_array["id"]] = $eval_users[$result_array["id"]];
03326                                                         }
03327                                                 }
03328                                         }
03329                                         $this->outEvalSearchResultTable("usr", $users, "user_result", "user_row", $this->lng->txt("search_found_users"), $buttons);
03330                                 }
03331                                 $searchresult = array();
03332                                 $eval_groups = $this->object->getEvaluationGroups($ilUser->id);
03333                                 if ($searchresult = $search->getResultByType("grp"))
03334                                 {
03335                                         $groups = array();
03336                                         foreach ($searchresult as $result_array)
03337                                         {
03338                                                 if (!in_array($result_array["id"], $eval_groups))
03339                                                 {
03340                                                         include_once("./classes/class.ilObjGroup.php");
03341                                                         $grp = new ilObjGroup($result_array["id"], true);
03342                                                         $members = $grp->getGroupMemberIds();
03343                                                         $found_member = 0;
03344                                                         foreach ($members as $member_id)
03345                                                         {
03346                                                                 if (array_key_exists($member_id, $participants))
03347                                                                 {
03348                                                                         $found_member = 1;
03349                                                                 }
03350                                                         }
03351                                                         if ($found_member)
03352                                                         {
03353                                                                 array_push($groups, $result_array["id"]);
03354                                                         }
03355                                                 }
03356                                         }
03357                                         $this->outEvalSearchResultTable("grp", $groups, "group_result", "group_row", $this->lng->txt("search_found_groups"), $buttons);
03358                                 }
03359                         }
03360                 }
03361                 else
03362                 {
03363                         sendInfo($this->lng->txt("no_user_or_group_selected"));
03364                 }
03365         }
03366         
03374         function addFoundUsersToEvalObject()
03375         {
03376                 global $ilUser;
03377                 if (is_array($_POST["user_select"]))
03378                 {
03379                         foreach ($_POST["user_select"] as $user_id)
03380                         {
03381                                 $this->object->addSelectedUser($user_id, $ilUser->id);
03382                         }
03383                 }
03384                 $this->evalStatSelectedObject();
03385         }
03386         
03394         function removeSelectedUserObject()
03395         {
03396                 global $ilUser;
03397                 if (is_array($_POST["selected_users"]))
03398                 {
03399                         foreach ($_POST["selected_users"] as $user_id)
03400                         {
03401                                 $this->object->removeSelectedUser($user_id, $ilUser->id);
03402                         }
03403                 }
03404                 $this->evalStatSelectedObject();
03405         }
03406         
03414         function removeSelectedGroupObject()
03415         {
03416                 global $ilUser;
03417                 if (is_array($_POST["selected_groups"]))
03418                 {
03419                         foreach ($_POST["selected_groups"] as $group_id)
03420                         {
03421                                 $this->object->removeSelectedGroup($group_id, $ilUser->id);
03422                         }
03423                 }
03424                 $this->evalStatSelectedObject();
03425         }
03426         
03434         function addFoundGroupsToEvalObject()
03435         {
03436                 global $ilUser;
03437                 if (is_array($_POST["group_select"]))
03438                 {
03439                         foreach ($_POST["group_select"] as $group_id)
03440                         {
03441                                 $this->object->addSelectedGroup($group_id, $ilUser->id);
03442                         }
03443                 }
03444                 $this->evalStatSelectedObject();
03445         }
03446         
03454         function searchForEvaluationObject()
03455         {
03456                 $this->evalStatSelectedObject(1);
03457         }
03458         
03466         function evalStatSelectedObject($search = 0)
03467         {
03468                 global $ilUser;
03469                 
03470                 $this->ctrl->setCmd("evalStatSelected");
03471                 $this->setEvaluationSettingsTabs();
03472                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_eval_statistical_evaluation_selection.html", true);
03473                 if ($search)
03474                 {
03475                         $this->outStatSelectedSearchResults();
03476                 }
03477                 $this->tpl->setCurrentBlock("userselection");
03478                 $this->tpl->setVariable("SEARCH_USERSELECTION", $this->lng->txt("eval_search_userselection"));
03479                 $this->tpl->setVariable("SEARCH_TERM", $this->lng->txt("eval_search_term"));
03480                 $this->tpl->setVariable("SEARCH_FOR", $this->lng->txt("search_for"));
03481                 $this->tpl->setVariable("SEARCH_USERS", $this->lng->txt("eval_search_users"));
03482                 $this->tpl->setVariable("SEARCH_GROUPS", $this->lng->txt("eval_search_groups"));
03483                 $this->tpl->setVariable("TEXT_CONCATENATION", $this->lng->txt("eval_concatenation"));
03484                 $this->tpl->setVariable("TEXT_AND", $this->lng->txt("and"));
03485                 $this->tpl->setVariable("TEXT_OR", $this->lng->txt("or"));
03486                 $this->tpl->setVariable("VALUE_SEARCH_TERM", $_POST["search_term"]);
03487                 if (is_array($_POST["search_for"]))
03488                 {
03489                         if (in_array("usr", $_POST["search_for"]))
03490                         {
03491                                 $this->tpl->setVariable("CHECKED_USERS", " checked=\"checked\"");
03492                         }
03493                         if (in_array("grp", $_POST["search_for"]))
03494                         {
03495                                 $this->tpl->setVariable("CHECKED_GROUPS", " checked=\"checked\"");
03496                         }
03497                 }
03498                 if (strcmp($_POST["concatenation"], "and") == 0)
03499                 {
03500                         $this->tpl->setVariable("CHECKED_AND", " checked=\"checked\"");
03501                 }
03502                 else if (strcmp($_POST["concatenation"], "or") == 0)
03503                 {
03504                         $this->tpl->setVariable("CHECKED_OR", " checked=\"checked\"");
03505                 }
03506                 $this->tpl->setVariable("SEARCH", $this->lng->txt("search"));
03507                 $this->tpl->parseCurrentBlock();
03508 
03509                 // output of alread found users and groups
03510                 $eval_users = $this->object->getEvaluationUsers($ilUser->id);
03511                 $eval_groups = $this->object->getEvaluationGroups($ilUser->id);
03512                 $buttons = array("remove");
03513                 if (count($eval_users))
03514                 {
03515                         $this->outEvalSearchResultTable("usr", $eval_users, "selected_user_result", "selected_user_row", $this->lng->txt("eval_found_selected_users"), $buttons);
03516                 }
03517                 if (count($eval_groups))
03518                 {
03519                         $this->outEvalSearchResultTable("grp", $eval_groups, "selected_group_result", "selected_group_row", $this->lng->txt("eval_found_selected_groups"), $buttons);
03520                 }
03521 
03522                 $this->tpl->setCurrentBlock("adm_content");
03523                 $this->tpl->setVariable("CMD_EVAL", "evalSelectedUsers");
03524                 $this->tpl->setVariable("TXT_STAT_USERS_INTRO", $this->lng->txt("tst_stat_users_intro"));
03525                 $this->tpl->setVariable("TXT_STAT_ALL_USERS", $this->lng->txt("tst_stat_selected_users"));
03526                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
03527                 $this->tpl->setVariable("TXT_QWORKEDTHROUGH", $this->lng->txt("tst_stat_result_qworkedthrough"));
03528                 $this->tpl->setVariable("TXT_PWORKEDTHROUGH", $this->lng->txt("tst_stat_result_pworkedthrough"));
03529                 $this->tpl->setVariable("TXT_TIMEOFWORK", $this->lng->txt("tst_stat_result_timeofwork"));
03530                 $this->tpl->setVariable("TXT_ATIMEOFWORK", $this->lng->txt("tst_stat_result_atimeofwork"));
03531                 $this->tpl->setVariable("TXT_FIRSTVISIT", $this->lng->txt("tst_stat_result_firstvisit"));
03532                 $this->tpl->setVariable("TXT_LASTVISIT", $this->lng->txt("tst_stat_result_lastvisit"));
03533                 $this->tpl->setVariable("TXT_RESULTSPOINTS", $this->lng->txt("tst_stat_result_resultspoints"));
03534                 $this->tpl->setVariable("TXT_RESULTSMARKS", $this->lng->txt("tst_stat_result_resultsmarks"));
03535                 $this->tpl->setVariable("TXT_DISTANCEMEDIAN", $this->lng->txt("tst_stat_result_distancemedian"));
03536                 $this->tpl->setVariable("TXT_SPECIFICATION", $this->lng->txt("tst_stat_result_specification"));
03537                 $user_settings = $this->object->evalLoadStatisticalSettings($ilUser->id);
03538                 foreach ($user_settings as $key => $value) {
03539                         if ($value == 1) {
03540                                 $user_settings[$key] = " checked=\"checked\"";
03541                         } else {
03542                                 $user_settings[$key] = "";
03543                         }
03544                 }
03545                 $this->tpl->setVariable("CHECKED_QWORKEDTHROUGH", $user_settings["qworkedthrough"]);
03546                 $this->tpl->setVariable("CHECKED_PWORKEDTHROUGH", $user_settings["pworkedthrough"]);
03547                 $this->tpl->setVariable("CHECKED_TIMEOFWORK", $user_settings["timeofwork"]);
03548                 $this->tpl->setVariable("CHECKED_ATIMEOFWORK", $user_settings["atimeofwork"]);
03549                 $this->tpl->setVariable("CHECKED_FIRSTVISIT", $user_settings["firstvisit"]);
03550                 $this->tpl->setVariable("CHECKED_LASTVISIT", $user_settings["lastvisit"]);
03551                 $this->tpl->setVariable("CHECKED_RESULTSPOINTS", $user_settings["resultspoints"]);
03552                 $this->tpl->setVariable("CHECKED_RESULTSMARKS", $user_settings["resultsmarks"]);
03553                 $this->tpl->setVariable("CHECKED_DISTANCEMEDIAN", $user_settings["distancemedian"]);
03554                 $this->tpl->setVariable("TXT_STATISTICAL_EVALUATION", $this->lng->txt("tst_statistical_evaluation"));
03555                 $this->tpl->parseCurrentBlock();
03556         }
03557         
03565         function outEvalSearchResultTable($a_type, $id_array, $block_result, $block_row, $title_text, $buttons)
03566         {
03567                 include_once("./classes/class.ilObjGroup.php");
03568                 global $rbacsystem;
03569                 
03570                 $rowclass = array("tblrow1", "tblrow2");
03571                 switch($a_type)
03572                 {
03573                         case "usr":
03574                                 foreach ($id_array as $user_id => $username)
03575                                 {
03576                                         $counter = 0;
03577                                         $user = new ilObjUser($user_id);
03578                                         $this->tpl->setCurrentBlock($block_row);
03579                                         $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
03580                                         $this->tpl->setVariable("COUNTER", $user->getId());
03581                                         $this->tpl->setVariable("VALUE_LOGIN", $user->getLogin());
03582                                         $this->tpl->setVariable("VALUE_FIRSTNAME", $user->getFirstname());
03583                                         $this->tpl->setVariable("VALUE_LASTNAME", $user->getLastname());
03584                                         $counter++;
03585                                         $this->tpl->parseCurrentBlock();
03586                                 }
03587                                 $this->tpl->setCurrentBlock($block_result);
03588                                 $this->tpl->setVariable("TEXT_USER_TITLE", "<img src=\"" . ilUtil::getImagePath("icon_usr_b.gif") . "\" alt=\"\" /> " . $title_text);
03589                                 $this->tpl->setVariable("TEXT_LOGIN", $this->lng->txt("login"));
03590                                 $this->tpl->setVariable("TEXT_FIRSTNAME", $this->lng->txt("firstname"));
03591                                 $this->tpl->setVariable("TEXT_LASTNAME", $this->lng->txt("lastname"));
03592                                 if ($rbacsystem->checkAccess("write", $this->object->getRefId()))
03593                                 {
03594                                         foreach ($buttons as $cat)
03595                                         {
03596                                                 $this->tpl->setVariable("VALUE_" . strtoupper($cat), $this->lng->txt($cat));
03597                                         }
03598                                         $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"\">");
03599                                 }
03600                                 $this->tpl->parseCurrentBlock();
03601                                 break;
03602                         case "grp":
03603                                 foreach ($id_array as $group_id)
03604                                 {
03605                                         $counter = 0;
03606                                         $group = new ilObjGroup($group_id);
03607                                         $this->tpl->setCurrentBlock($block_row);
03608                                         $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
03609                                         $this->tpl->setVariable("COUNTER", $group->getRefId());
03610                                         $this->tpl->setVariable("VALUE_TITLE", $group->getTitle());
03611                                         $this->tpl->setVariable("VALUE_DESCRIPTION", $group->getDescription());
03612                                         $counter++;
03613                                         $this->tpl->parseCurrentBlock();
03614                                 }
03615                                 $this->tpl->setCurrentBlock($block_result);
03616                                 $this->tpl->setVariable("TEXT_GROUP_TITLE", "<img src=\"" . ilUtil::getImagePath("icon_grp_b.gif") . "\" alt=\"\" /> " . $title_text);
03617                                 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
03618                                 $this->tpl->setVariable("TEXT_DESCRIPTION", $this->lng->txt("description"));
03619                                 if ($rbacsystem->checkAccess("write", $this->object->getRefId()))
03620                                 {
03621                                         foreach ($buttons as $cat)
03622                                         {
03623                                                 $this->tpl->setVariable("VALUE_" . strtoupper($cat), $this->lng->txt($cat));
03624                                         }
03625                                         $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"\">");
03626                                 }
03627                                 $this->tpl->parseCurrentBlock();
03628                                 break;
03629                 }
03630         }
03631 
03639         function evaluationDetailObject()
03640         {
03641                 $answertext = $this->object->getTextAnswer($_GET["userdetail"], $_GET["answer"]);
03642                 $questiontext = $this->object->getQuestiontext($_GET["answer"]);
03643                 $this->tpl = new ilTemplate("./assessment/templates/default/tpl.il_as_tst_eval_user_answer.html", true, true);
03644                 $this->tpl->setVariable("TITLE_USER_ANSWER", $this->lng->txt("tst_eval_user_answer"));
03645                 $this->tpl->setVariable("TEXT_USER", $this->lng->txt("user"));
03646                 $user = new ilObjUser($_GET["userdetail"]);
03647                 $this->tpl->setVariable("TEXT_USERNAME", trim($user->getFirstname() . " " . $user->getLastname()));
03648                 $this->tpl->setVariable("TEXT_QUESTION", $this->lng->txt("question"));
03649                 $this->tpl->setVariable("TEXT_QUESTIONTEXT", ilUtil::prepareFormOutput($questiontext));
03650                 $this->tpl->setVariable("TEXT_ANSWER", $this->lng->txt("answer"));
03651                 $this->tpl->setVariable("TEXT_USER_ANSWER", str_replace("\n", "<br />", ilUtil::prepareFormOutput($answertext)));
03652         }
03653         
03654         function eval_statObject()
03655         {
03656                 $this->ctrl->setCmdClass(get_class($this));
03657                 $this->ctrl->setCmd("eval_stat");
03658                 $this->setEvaluationSettingsTabs();
03659                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_eval_statistical_evaluation_selection.html", true);
03660                 $this->tpl->setCurrentBlock("adm_content");
03661                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
03662                 $this->tpl->setVariable("CMD_EVAL", "evalAllUsers");
03663                 $this->tpl->setVariable("TXT_STAT_USERS_INTRO", $this->lng->txt("tst_stat_users_intro"));
03664                 $this->tpl->setVariable("TXT_STAT_ALL_USERS", $this->lng->txt("tst_stat_all_users"));
03665                 $this->tpl->setVariable("TXT_QWORKEDTHROUGH", $this->lng->txt("tst_stat_result_qworkedthrough"));
03666                 $this->tpl->setVariable("TXT_PWORKEDTHROUGH", $this->lng->txt("tst_stat_result_pworkedthrough"));
03667                 $this->tpl->setVariable("TXT_TIMEOFWORK", $this->lng->txt("tst_stat_result_timeofwork"));
03668                 $this->tpl->setVariable("TXT_ATIMEOFWORK", $this->lng->txt("tst_stat_result_atimeofwork"));
03669                 $this->tpl->setVariable("TXT_FIRSTVISIT", $this->lng->txt("tst_stat_result_firstvisit"));
03670                 $this->tpl->setVariable("TXT_LASTVISIT", $this->lng->txt("tst_stat_result_lastvisit"));
03671                 $this->tpl->setVariable("TXT_RESULTSPOINTS", $this->lng->txt("tst_stat_result_resultspoints"));
03672                 $this->tpl->setVariable("TXT_RESULTSMARKS", $this->lng->txt("tst_stat_result_resultsmarks"));
03673                 $this->tpl->setVariable("TXT_DISTANCEMEDIAN", $this->lng->txt("tst_stat_result_distancemedian"));
03674                 $this->tpl->setVariable("TXT_SPECIFICATION", $this->lng->txt("tst_stat_result_specification"));
03675                 $user_settings = $this->object->evalLoadStatisticalSettings($ilUser->id);
03676                 foreach ($user_settings as $key => $value) {
03677                         if ($value == 1) {
03678                                 $user_settings[$key] = " checked=\"checked\"";
03679                         } else {
03680                                 $user_settings[$key] = "";
03681                         }
03682                 }
03683                 $this->tpl->setVariable("CHECKED_QWORKEDTHROUGH", $user_settings["qworkedthrough"]);
03684                 $this->tpl->setVariable("CHECKED_PWORKEDTHROUGH", $user_settings["pworkedthrough"]);
03685                 $this->tpl->setVariable("CHECKED_TIMEOFWORK", $user_settings["timeofwork"]);
03686                 $this->tpl->setVariable("CHECKED_ATIMEOFWORK", $user_settings["atimeofwork"]);
03687                 $this->tpl->setVariable("CHECKED_FIRSTVISIT", $user_settings["firstvisit"]);
03688                 $this->tpl->setVariable("CHECKED_LASTVISIT", $user_settings["lastvisit"]);
03689                 $this->tpl->setVariable("CHECKED_RESULTSPOINTS", $user_settings["resultspoints"]);
03690                 $this->tpl->setVariable("CHECKED_RESULTSMARKS", $user_settings["resultsmarks"]);
03691                 $this->tpl->setVariable("CHECKED_DISTANCEMEDIAN", $user_settings["distancemedian"]);
03692                 $this->tpl->setVariable("TXT_STATISTICAL_EVALUATION", $this->lng->txt("tst_statistical_evaluation"));
03693                 $this->tpl->parseCurrentBlock();
03694         }
03695 
03696         function saveEvaluationSettings()
03697         {
03698                 $eval_statistical_settings = array(
03699                         "qworkedthrough" => $_POST["chb_result_qworkedthrough"],
03700                         "pworkedthrough" => $_POST["chb_result_pworkedthrough"],
03701                         "timeofwork" => $_POST["chb_result_timeofwork"],
03702                         "atimeofwork" => $_POST["chb_result_atimeofwork"],
03703                         "firstvisit" => $_POST["chb_result_firstvisit"],
03704                         "lastvisit" => $_POST["chb_result_lastvisit"],
03705                         "resultspoints" => $_POST["chb_result_resultspoints"],
03706                         "resultsmarks" => $_POST["chb_result_resultsmarks"],
03707                         "distancemedian" => $_POST["chb_result_distancemedian"]
03708                 );
03709                 $this->object->evalSaveStatisticalSettings($eval_statistical_settings, $ilUser->id);
03710                 return $eval_statistical_settings;
03711         }
03712         
03713         function evalSelectedUsersObject($all_users = 0)
03714         {
03715                 global $ilUser;
03716 
03717                 $savetextanswers = 0;
03718                 $textanswers = 0;
03719                 $print = 0;
03720                 $export = 0;
03721                 if (strcmp($_POST["cmd"][$this->ctrl->getCmd()], $this->lng->txt("print")) == 0)
03722                 {
03723                         $print = 1;
03724                 }
03725                 if (strcmp($_POST["cmd"][$this->ctrl->getCmd()], $this->lng->txt("export")) == 0)
03726                 {
03727                         $export = 1;
03728                 }
03729                 if (strcmp($_POST["cmd"][$this->ctrl->getCmd()], $this->lng->txt("save_text_answer_points")) == 0)
03730                 {
03731 
03732                         $savetextanswers = 1;
03733                         foreach ($_POST as $key => $value)
03734                         {
03735                                 if (preg_match("/(\d+)_(\d+)_(\d+)/", $key, $matches))
03736                                 {
03737                                         ASS_TextQuestion::_setReachedPoints($matches[1], $this->object->getTestId(), $matches[2], $value, $matches[3]);
03738                                 }
03739                         }
03740                         sendInfo($this->lng->txt("text_answers_saved"));
03741                 }
03742                 if ((count($_POST) == 0) || ($print) || ($export) || ($savetextanswers))
03743                 {
03744                         $user_settings = $this->object->evalLoadStatisticalSettings($ilUser->id);
03745                         $eval_statistical_settings = array(
03746                                 "qworkedthrough" => $user_settings["qworkedthrough"],
03747                                 "pworkedthrough" => $user_settings["pworkedthrough"],
03748                                 "timeofwork" => $user_settings["timeofwork"],
03749                                 "atimeofwork" => $user_settings["atimeofwork"],
03750                                 "firstvisit" => $user_settings["firstvisit"],
03751                                 "lastvisit" => $user_settings["lastvisit"],
03752                                 "resultspoints" => $user_settings["resultspoints"],
03753                                 "resultsmarks" => $user_settings["resultsmarks"],
03754                                 "distancemedian" => $user_settings["distancemedian"]
03755                         );
03756                 }
03757                 else
03758                 {
03759                         $eval_statistical_settings = $this->saveEvaluationSettings();
03760                 }
03761 //              $this->ctrl->setCmd("evalSelectedUsers");
03762                 $this->setEvaluationTabs($all_users);
03763                 $legend = array();
03764                 $legendquestions = array();
03765                 $titlerow = array();
03766                 // build title columns
03767                 $name_column = $this->lng->txt("name");
03768                 if ($this->object->getTestType() == TYPE_SELF_ASSESSMENT)
03769                 {
03770                         $name_column = $this->lng->txt("counter");
03771                 }
03772                 array_push($titlerow, $name_column);
03773                 
03774                 $char = "A";
03775                 if ($eval_statistical_settings["qworkedthrough"]) {
03776                         array_push($titlerow, $char);
03777                         $legend[$char] = $this->lng->txt("tst_stat_result_qworkedthrough");
03778                         $char++;
03779                 }
03780                 if ($eval_statistical_settings["pworkedthrough"]) {
03781                         array_push($titlerow, $char);
03782                         $legend[$char] = $this->lng->txt("tst_stat_result_pworkedthrough");
03783                         $char++;
03784                 }
03785                 if ($eval_statistical_settings["timeofwork"]) {
03786                         array_push($titlerow, $char);
03787                         $legend[$char] = $this->lng->txt("tst_stat_result_timeofwork");
03788                         $char++;
03789                 }
03790                 if ($eval_statistical_settings["atimeofwork"]) {
03791                         array_push($titlerow, $char);
03792                         $legend[$char] = $this->lng->txt("tst_stat_result_atimeofwork");
03793                         $char++;
03794                 }
03795                 if ($eval_statistical_settings["firstvisit"]) {
03796                         array_push($titlerow, $char);
03797                         $legend[$char] = $this->lng->txt("tst_stat_result_firstvisit");
03798                         $char++;
03799                 }
03800                 if ($eval_statistical_settings["lastvisit"]) {
03801                         array_push($titlerow, $char);
03802                         $legend[$char] = $this->lng->txt("tst_stat_result_lastvisit");
03803                         $char++;
03804                 }
03805                 if ($eval_statistical_settings["resultspoints"]) {
03806                         array_push($titlerow, $char);
03807                         $legend[$char] = $this->lng->txt("tst_stat_result_resultspoints");
03808                         $char++;
03809                 }
03810                 if ($eval_statistical_settings["resultsmarks"]) {
03811                         array_push($titlerow, $char);
03812                         $legend[$char] = $this->lng->txt("tst_stat_result_resultsmarks");
03813                         $char++;
03814                         
03815                         if ($this->object->ects_output)
03816                         {
03817                                 array_push($titlerow, $char);
03818                                 $legend[$char] = $this->lng->txt("ects_grade");
03819                                 $char++;
03820                         }
03821                 }
03822                 if ($eval_statistical_settings["distancemedian"]) {
03823                         array_push($titlerow, $char);
03824                         $legend[$char] = $this->lng->txt("tst_stat_result_mark_median");
03825                         $char++;
03826                         array_push($titlerow, $char);
03827                         $legend[$char] = $this->lng->txt("tst_stat_result_rank_participant");
03828                         $char++;
03829                         array_push($titlerow, $char);
03830                         $legend[$char] = $this->lng->txt("tst_stat_result_rank_median");
03831                         $char++;
03832                         array_push($titlerow, $char);
03833                         $legend[$char] = $this->lng->txt("tst_stat_result_total_participants");
03834                         $char++;
03835                         array_push($titlerow, $char);
03836                         $legend[$char] = $this->lng->txt("tst_stat_result_median");
03837                         $char++;
03838                 }
03839                 
03840                 $titlerow_without_questions = $titlerow;
03841                 if (!$this->object->isRandomTest())
03842                 {
03843                         $qtitles =& $this->object->getQuestionTitles();
03844                         $i = 1;
03845                         foreach ($qtitles as $title)
03846                         {
03847                                 array_push($titlerow, $this->lng->txt("question_short") . " " . $i);
03848                                 $legendquestions[$i] = $title;
03849                                 $legend[$this->lng->txt("question_short") . " " . $i] = $i;
03850                                 $i++;
03851                         }
03852                 }
03853                 else
03854                 {
03855                         for ($i = 1; $i <= $this->object->getQuestionCount(); $i++)
03856                         {
03857                                 array_push($titlerow, "&nbsp;");
03858                         }
03859                 }
03860                 $total_users =& $this->object->evalTotalPersonsArray();
03861                 $selected_users = array();
03862                 if ($all_users == 1) {
03863                         $selected_users = $total_users;
03864                 } else {
03865                         $selected_users =& $this->object->getEvaluationUsers($ilUser->id);
03866                         $selected_groups =& $this->object->getEvaluationGroups($ilUser->id);
03867                         include_once("./classes/class.ilObjGroup.php");
03868                         foreach ($selected_groups as $group_id)
03869                         {
03870                                 $grp = new ilObjGroup($group_id, true);
03871                                 $members = $grp->getGroupMemberIds();
03872                                 foreach ($members as $member_id)
03873                                 {
03874                                         if (array_key_exists($member_id, $total_users))
03875                                         {
03876                                                 $usr = new ilObjUser($member_id); 
03877                                                 $selected_users[$member_id] = trim($usr->firstname . " " . $usr->lastname);
03878                                         }
03879                                 }
03880                         }
03881                 }
03882 //                      $ilBench->stop("Test_Statistical_evaluation", "getAllParticipants");
03883                 $row = 0;
03884                 $question_legend = false;
03885                 $question_stat = array();
03886                 $evaluation_array = array();
03887                 foreach ($total_users as $key => $value) {
03888                         // receive array with statistical information on the test for a specific user
03889 //                              $ilBench->start("Test_Statistical_evaluation", "this->object->evalStatistical($key)");
03890                         $stat_eval =& $this->object->evalStatistical($key);
03891                         foreach ($stat_eval as $sindex => $sarray)
03892                         {
03893                                 if (preg_match("/\d+/", $sindex))
03894                                 {
03895                                         $qt = $sarray["title"];
03896                                         $qt = preg_replace("/<.*?>/", "", $qt);
03897                                         if (!array_key_exists($sarray["qid"], $question_stat))
03898                                         {
03899                                                 $question_stat[$sarray["qid"]] = array("max" => 0, "reached" => 0, "title" => $qt);
03900                                         }
03901                                         $question_stat[$sarray["qid"]]["single_max"] = $sarray["max"];
03902                                         $question_stat[$sarray["qid"]]["max"] += $sarray["max"];
03903                                         $question_stat[$sarray["qid"]]["reached"] += $sarray["reached"];
03904                                 }
03905                         }
03906 //                              $ilBench->stop("Test_Statistical_evaluation", "this->object->evalStatistical($key)");
03907                         $evaluation_array[$key] = $stat_eval;
03908                 }
03909 
03910                 include_once "./classes/class.ilStatistics.php";
03911                 // calculate the median
03912                 $median_array = array();
03913                 foreach ($evaluation_array as $key => $value)
03914                 {
03915                         array_push($median_array, $value["resultspoints"]);
03916                 }
03917                 //$median_array =& $this->object->getTotalPointsArray();
03918                 $statistics = new ilStatistics();
03919                 $statistics->setData($median_array);
03920                 $median = $statistics->median();
03921 //                      $ilBench->stop("Test_Statistical_evaluation", "calculate all statistical data");
03922 //                      $ilBench->save();
03923                 $evalcounter = 1;
03924                 $question_titles = array();
03925                 $question_title_counter = 1;
03926                 $eval_complete = array();
03927                 foreach ($selected_users as $key => $name)
03928                 {
03929                         $stat_eval = $evaluation_array[$key];
03930                         
03931                         $titlerow_user = array();
03932                         if ($this->object->isRandomTest())
03933                         {
03934                                 $this->object->loadQuestions($key);
03935                                 $titlerow_user = $titlerow_without_questions;
03936                                 $i = 1;
03937                                 foreach ($stat_eval as $key1 => $value1)
03938                                 {
03939                                         if (preg_match("/\d+/", $key1))
03940                                         {
03941                                                 $qt = $value1["title"];
03942                                                 $qt = preg_replace("/<.*?>/", "", $qt);
03943 /*                                              $arraykey = array_search($qt, $legend);
03944                                                 if (!$arraykey)
03945                                                 {
03946                                                         array_push($titlerow_user, $this->lng->txt("question_short") . " " . $question_title_counter);
03947                                                         $legend[$this->lng->txt("question_short") . " " . $question_title_counter] = $qt;
03948                                                         $question_title_counter++;
03949                                                 }
03950                                                 else
03951                                                 {
03952                                                         array_push($titlerow_user, $arraykey);
03953                                                 }*/
03954                                                 if (!array_key_exists($value1["qid"], $legendquestions))
03955                                                 {
03956                                                         array_push($titlerow_user, $this->lng->txt("question_short") . " " . $question_title_counter);
03957                                                         $legend[$this->lng->txt("question_short") . " " . $question_title_counter] = $value1["qid"];
03958                                                         $legendquestions[$value1["qid"]] = $qt;
03959                                                         $question_title_counter++;
03960                                                 }
03961                                                 else
03962                                                 {
03963                                                         $arraykey = array_search($value1["qid"], $legend);
03964                                                         array_push($titlerow_user, $arraykey);
03965                                                 }
03966                                         }
03967                                 }
03968                         }
03969 
03970                         $evalrow = array();
03971                         $username = $evalcounter++; 
03972                         if ($this->object->getTestType() != TYPE_SELF_ASSESSMENT)
03973                         {
03974                                 $username = $selected_users[$key];
03975                         }
03976                         array_push($evalrow, array(
03977                                 "html" => $username,
03978                                 "xls"  => $username,
03979                                 "csv"  => $username
03980                         ));
03981                         if ($eval_statistical_settings["qworkedthrough"]) {
03982                                 array_push($evalrow, array(
03983                                         "html" => $stat_eval["qworkedthrough"],
03984                                         "xls"  => $stat_eval["qworkedthrough"],
03985                                         "csv"  => $stat_eval["qworkedthrough"]
03986                                 ));
03987                         }
03988                         if ($eval_statistical_settings["pworkedthrough"]) {
03989                                 array_push($evalrow, array(
03990                                         "html" => sprintf("%2.2f", $stat_eval["pworkedthrough"] * 100.0) . " %",
03991                                         "xls"  => $stat_eval["pworkedthrough"],
03992                                         "csv"  => $stat_eval["pworkedthrough"],
03993                                         "format" => "%"
03994                                 ));
03995                         }
03996                         if ($eval_statistical_settings["timeofwork"]) {
03997                                 $time = $stat_eval["timeofwork"];
03998                                 $time_seconds = $time;
03999                                 $time_hours    = floor($time_seconds/3600);
04000                                 $time_seconds -= $time_hours   * 3600;
04001                                 $time_minutes  = floor($time_seconds/60);
04002                                 $time_seconds -= $time_minutes * 60;
04003                                 array_push($evalrow, array(
04004                                         "html" => sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds),
04005                                         "xls"  => sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds),
04006                                         "csv"  => sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds)
04007                                 ));
04008                         }
04009                         if ($eval_statistical_settings["atimeofwork"]) {
04010                                 $time = $stat_eval["atimeofwork"];
04011                                 $time_seconds = $time;
04012                                 $time_hours    = floor($time_seconds/3600);
04013                                 $time_seconds -= $time_hours   * 3600;
04014                                 $time_minutes  = floor($time_seconds/60);
04015                                 $time_seconds -= $time_minutes * 60;
04016                                 array_push($evalrow, array(
04017                                         "html" => sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds),
04018                                         "xls"  => sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds),
04019                                         "csv"  => sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds)
04020                                 ));
04021                         }
04022                         if ($eval_statistical_settings["firstvisit"]) {
04023                                 array_push($evalrow, array(
04024                                         "html" => date($this->lng->text["lang_dateformat"] . " " . $this->lng->text["lang_timeformat"], mktime($stat_eval["firstvisit"]["hours"], $stat_eval["firstvisit"]["minutes"], $stat_eval["firstvisit"]["seconds"], $stat_eval["firstvisit"]["mon"], $stat_eval["firstvisit"]["mday"], $stat_eval["firstvisit"]["year"])),
04025                                         "xls"  => ilUtil::excelTime($stat_eval["firstvisit"]["year"],$stat_eval["firstvisit"]["mon"],$stat_eval["firstvisit"]["mday"],$stat_eval["firstvisit"]["hours"],$stat_eval["firstvisit"]["minutes"],$stat_eval["firstvisit"]["seconds"]),
04026                                         "csv"  => date($this->lng->text["lang_dateformat"] . " " . $this->lng->text["lang_timeformat"], mktime($stat_eval["firstvisit"]["hours"], $stat_eval["firstvisit"]["minutes"], $stat_eval["firstvisit"]["seconds"], $stat_eval["firstvisit"]["mon"], $stat_eval["firstvisit"]["mday"], $stat_eval["firstvisit"]["year"])),
04027                                         "format" => "t"
04028                                 ));
04029                         }
04030                         if ($eval_statistical_settings["lastvisit"]) {
04031                                 array_push($evalrow, array(
04032                                         "html" => date($this->lng->text["lang_dateformat"] . " " . $this->lng->text["lang_timeformat"], mktime($stat_eval["lastvisit"]["hours"], $stat_eval["lastvisit"]["minutes"], $stat_eval["lastvisit"]["seconds"], $stat_eval["lastvisit"]["mon"], $stat_eval["lastvisit"]["mday"], $stat_eval["lastvisit"]["year"])),
04033                                         "xls"  => ilUtil::excelTime($stat_eval["lastvisit"]["year"],$stat_eval["lastvisit"]["mon"],$stat_eval["lastvisit"]["mday"],$stat_eval["lastvisit"]["hours"],$stat_eval["lastvisit"]["minutes"],$stat_eval["lastvisit"]["seconds"]),
04034                                         "csv"  => date($this->lng->text["lang_dateformat"] . " " . $this->lng->text["lang_timeformat"], mktime($stat_eval["lastvisit"]["hours"], $stat_eval["lastvisit"]["minutes"], $stat_eval["lastvisit"]["seconds"], $stat_eval["lastvisit"]["mon"], $stat_eval["lastvisit"]["mday"], $stat_eval["lastvisit"]["year"])),
04035                                         "format" => "t"
04036                                 ));
04037                         }
04038                         if ($eval_statistical_settings["resultspoints"]) {
04039                                 array_push($evalrow, array(
04040                                         "html" => $stat_eval["resultspoints"]." ".strtolower($this->lng->txt("of"))." ". $stat_eval["maxpoints"],
04041                                         "xls"  => $stat_eval["resultspoints"],
04042                                         "csv"  => $stat_eval["resultspoints"]
04043                                 ));
04044                         }
04045                         if ($eval_statistical_settings["resultsmarks"]) {
04046                                 array_push($evalrow, array(
04047                                         "html" => $stat_eval["resultsmarks"],
04048                                         "xls"  => $stat_eval["resultsmarks"],
04049                                         "csv"  => $stat_eval["resultsmarks"]
04050                                 ));
04051 
04052                                 if ($this->object->ects_output)
04053                                 {
04054                                         $mark_ects = $this->object->getECTSGrade($stat_eval["resultspoints"],$stat_eval["maxpoints"]);
04055                                         array_push($evalrow, array(
04056                                                 "html" => $mark_ects,
04057                                                 "xls"  => $mark_ects,
04058                                                 "csv"  => $mark_ects
04059                                         ));
04060                                 }
04061                         }
04062                         
04063                         if ($eval_statistical_settings["distancemedian"]) {
04064                                 if ($stat_eval["maxpoints"] == 0)
04065                                 {
04066                                         $pct = 0;
04067                                 }
04068                                 else
04069                                 {
04070                                         $pct = ($median / $stat_eval["maxpoints"]) * 100.0;
04071                                 }
04072                                 $mark = $this->object->mark_schema->get_matching_mark($pct);
04073                                 $mark_short_name = "";
04074                                 if ($mark)
04075                                 {
04076                                         $mark_short_name = $mark->get_short_name();
04077                                 }
04078                                 array_push($evalrow, array(
04079                                         "html" => $mark_short_name,
04080                                         "xls"  => $mark_short_name,
04081                                         "csv"  => $mark_short_name
04082                                 ));
04083                                 $rank_participant = $statistics->rank($stat_eval["resultspoints"]);
04084                                 array_push($evalrow, array(
04085                                         "html" => $rank_participant,
04086                                         "xls"  => $rank_participant,
04087                                         "csv"  => $rank_participant
04088                                 ));
04089                                 $rank_median = $statistics->rank_median();
04090                                 array_push($evalrow, array(
04091                                         "html" => $rank_median,
04092                                         "xls"  => $rank_median,
04093                                         "csv"  => $rank_median
04094                                 ));
04095                                 $total_participants = count($median_array);
04096                                 array_push($evalrow, array(
04097                                         "html" => $total_participants,
04098                                         "xls"  => $total_participants,
04099                                         "csv"  => $total_participants
04100                                 ));
04101                                 array_push($evalrow, array(
04102                                         "html" => $median,
04103                                         "xls"  => $median,
04104                                         "csv"  => $median
04105                                 ));
04106                         }
04107                         
04108                         for ($i = 1; $i <= $this->object->getQuestionCount(); $i++)
04109                         {
04110                                 $qshort = "";
04111                                 $qt = "";
04112                                 if ($this->object->isRandomTest())
04113                                 {
04114                                         $qt = $stat_eval[$i-1]["title"];
04115                                         $qt = preg_replace("/<.*?>/", "", $qt);
04116                                         $arrkey = array_search($stat_eval[$i-1]["qid"], $legend);
04117                                         if ($arrkey)
04118                                         {
04119                                                 $qshort = "<span title=\"" . ilUtil::prepareFormOutput($qt) . "\">" . $arrkey . "</span>: ";
04120                                         }
04121                                 }
04122 
04123                                 $htmloutput = "";
04124                                 if ($stat_eval[$i-1]["type"] == 8)
04125                                 {
04126                                         // Text question
04127                                         $name = $key."_".$stat_eval[$i-1]["qid"]."_".$stat_eval[$i-1]["max"];
04128                                         $htmloutput = $qshort . "<input type=\"text\" name=\"".$name."\" size=\"3\" value=\"".$stat_eval[$i-1]["reached"]."\" />".strtolower($this->lng->txt("of"))." ". $stat_eval[$i-1]["max"];
04129                                         // Solution
04130                                         $htmloutput .= " [<a href=\"".$this->ctrl->getLinkTargetByClass(get_class($this), "evaluationDetail") . "&userdetail=$key&answer=".$stat_eval[$i-1]["qid"]."\" target=\"popup\" onclick=\"";
04131                                         $htmloutput .= "window.open('', 'popup', 'width=600, height=200, scrollbars=no, toolbar=no, status=no, resizable=yes, menubar=no, location=no, directories=no')";
04132                                         $htmloutput .= "\">".$this->lng->txt("tst_eval_show_answer")."</a>]";
04133                                         $textanswers++;
04134                                 }
04135                                         else
04136                                 {
04137                                         $htmloutput = $qshort . $stat_eval[$i-1]["reached"] . " " . strtolower($this->lng->txt("of")) . " " .  $stat_eval[$i-1]["max"];
04138                                 }
04139 
04140                                 array_push($evalrow, array(
04141                                         "html" => $htmloutput,
04142                                         "xls"  => $stat_eval[$i-1]["reached"],
04143                                         "csv"  => $stat_eval[$i-1]["reached"]
04144                                 ));
04145                         }
04146                         array_push($eval_complete, array("title" => $titlerow_user, "data" => $evalrow));
04147                 }
04148 
04149                 $noqcount = count($titlerow_without_questions);
04150                 if ($export)
04151                 {
04152                         $testname = preg_replace("/\s/", "_", $this->object->getTitle());
04153                         switch ($_POST["export_type"])
04154                         {
04155                                 case TYPE_XLS_PC:
04156                                 case TYPE_XLS_MAC:
04157                                         // Creating a workbook
04158                                         $result = @include_once 'Spreadsheet/Excel/Writer.php';
04159                                         if (!$result)
04160                                         {
04161                                                 include_once './classes/Spreadsheet/Excel/Writer.php';
04162                                         }
04163                                         $workbook = new Spreadsheet_Excel_Writer();
04164         
04165                                         // sending HTTP headers
04166                                         $workbook->send("$testname.xls");
04167         
04168                                         // Creating a worksheet
04169                                         $format_bold =& $workbook->addFormat();
04170                                         $format_bold->setBold();
04171                                         $format_percent =& $workbook->addFormat();
04172                                         $format_percent->setNumFormat("0.00%");
04173                                         $format_datetime =& $workbook->addFormat();
04174                                         $format_datetime->setNumFormat("DD/MM/YYYY hh:mm:ss");
04175                                         $format_title =& $workbook->addFormat();
04176                                         $format_title->setBold();
04177                                         $format_title->setColor('black');
04178                                         $format_title->setPattern(1);
04179                                         $format_title->setFgColor('silver');
04180                                         $worksheet =& $workbook->addWorksheet();
04181                                         $row = 0;
04182                                         $col = 0;
04183                                         include_once ("./classes/class.ilExcelUtils.php");
04184                                         if (!$this->object->isRandomTest())
04185                                         {
04186                                                 foreach ($titlerow as $title)
04187                                                 {
04188                                                         if (preg_match("/\d+/", $title))
04189                                                         {
04190                                                                 $worksheet->write($row, $col, ilExcelUtils::_convert_text($legendquestions[$legend[$title]], $_POST["export_type"]), $format_title);
04191                                                         }
04192                                                         else
04193                                                         {
04194                                                                 $worksheet->write($row, $col, ilExcelUtils::_convert_text($legend[$title], $_POST["export_type"]), $format_title);
04195                                                         }
04196                                                         $col++;
04197                                                 }
04198                                                 $row++;
04199                                         }
04200                                         foreach ($eval_complete as $evalrow)
04201                                         {
04202                                                 $col = 0;
04203                                                 if ($this->object->isRandomTest())
04204                                                 {
04205                                                         foreach ($evalrow["title"] as $key => $value)
04206                                                         {
04207                                                                 if ($key == 0)
04208                                                                 {
04209                                                                         $worksheet->write($row, $col, ilExcelUtils::_convert_text($value, $_POST["export_type"]), $format_title);
04210                                                                 }
04211                                                                 else
04212                                                                 {
04213                                                                         if (preg_match("/\d+/", $value))
04214                                                                         {
04215                                                                                 $worksheet->write($row, $col, ilExcelUtils::_convert_text($legendquestions[$legend[$value]], $_POST["export_type"]), $format_title);
04216                                                                         }
04217                                                                         else
04218                                                                         {
04219                                                                                 $worksheet->write($row, $col, ilExcelUtils::_convert_text($legend[$value], $_POST["export_type"]), $format_title);
04220                                                                         }
04221                                                                 }
04222                                                                 $col++;
04223                                                         }
04224                                                         $row++;
04225                                                 }
04226                                                 $col = 0;
04227                                                 foreach ($evalrow["data"] as $key => $value)
04228                                                 {
04229                                                         switch ($value["format"])
04230                                                         {
04231                                                                 case "%":
04232                                                                         $worksheet->write($row, $col, $value["xls"], $format_percent);
04233                                                                         break;
04234                                                                 case "t":
04235                                                                         $worksheet->write($row, $col, $value["xls"], $format_datetime);
04236                                                                         break;
04237                                                                 default:
04238                                                                         $worksheet->write($row, $col, ilExcelUtils::_convert_text($value["xls"], $_POST["export_type"]));
04239                                                                         break;
04240                                                         }
04241                                                         $col++;
04242                                                 }
04243                                                 $row++;
04244                                         }
04245                                         $workbook->close();
04246                                         exit;
04247                                 case TYPE_SPSS:
04248                                         $csv = "";
04249                                         $separator = ";";
04250                                         if (!$this->object->isRandomTest())
04251                                         {
04252                                                 $titlerow =& $this->object->processCSVRow($titlerow, TRUE, $separator);
04253                                                 $csv .= join($titlerow, $separator) . "\n";
04254                                         }
04255                                         foreach ($eval_complete as $evalrow)
04256                                         {
04257                                                 $csvrow = array();
04258                                                 foreach ($evalrow["data"] as $dataarray)
04259                                                 {
04260                                                         array_push($csvrow, $dataarray["csv"]);
04261                                                 }
04262                                                 if ($this->object->isRandomTest())
04263                                                 {
04264                                                         $evalrow["title"] =& $this->object->processCSVRow($evalrow["title"], TRUE, $separator);
04265                                                         $csv .= join($evalrow["title"], $separator) . "\n";
04266                                                 }
04267                                                 $csvarr = array();
04268                                                 $evalrow["data"] =& $this->object->processCSVRow($csvrow, TRUE, $separator);
04269                                                 $csv .= join($evalrow["data"], $separator) . "\n";
04270                                         }
04271                                         ilUtil::deliverData($csv, "$testname.csv");
04272                                         break;
04273                         }
04274                         exit;
04275                 }
04276                 if ($print)
04277                 {
04278                         $this->tpl = new ilTemplate("./assessment/templates/default/tpl.il_as_tst_eval_statistical_evaluation_preview.html", true, true);
04279                 }
04280                 else
04281                 {
04282                         $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_eval_statistical_evaluation.html", true);
04283                 }
04284                 $color_class = array("tblrow1", "tblrow2");
04285                 foreach ($legend as $short => $long)
04286                 {
04287                         $this->tpl->setCurrentBlock("legendrow");
04288                         $this->tpl->setVariable("TXT_SYMBOL", $short);
04289                         if (preg_match("/\d+/", $short))
04290                         {
04291                                 $this->tpl->setVariable("TXT_MEANING", $legendquestions[$long]);
04292                         }
04293                         else
04294                         {
04295                                 $this->tpl->setVariable("TXT_MEANING", $long);
04296                         }
04297                         $this->tpl->parseCurrentBlock();
04298                 }
04299                 $this->tpl->setCurrentBlock("legend");
04300                 $this->tpl->setVariable("TXT_LEGEND", $this->lng->txt("legend"));
04301                 $this->tpl->setVariable("TXT_LEGEND_LINK", $this->lng->txt("eval_legend_link"));
04302                 $this->tpl->setVariable("TXT_SYMBOL", $this->lng->txt("symbol"));
04303                 $this->tpl->setVariable("TXT_MEANING", $this->lng->txt("meaning"));
04304                 $this->tpl->parseCurrentBlock();
04305 
04306                 $counter = 0;
04307                 foreach ($question_stat as $title => $values)
04308                 {
04309                         $this->tpl->setCurrentBlock("meanrow");
04310                         $this->tpl->setVariable("TXT_QUESTION", ilUtil::prepareFormOutput($values["title"]));
04311                         $percent = 0;
04312                         if ($values["max"] > 0)
04313                         {
04314                                 $percent = $values["reached"] / $values["max"];
04315                         }
04316                         $this->tpl->setVariable("TXT_MEAN", sprintf("%.2f", $values["single_max"]*$percent) . " " . strtolower($this->lng->txt("of")) . " " . sprintf("%.2f", $values["single_max"]) . " (" . sprintf("%.2f", $percent*100) . " %)");
04317                         $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
04318                         $counter++;
04319                         $this->tpl->parseCurrentBlock();
04320                 }
04321                 $this->tpl->setCurrentBlock("question_mean_points");
04322                 $this->tpl->setVariable("TXT_AVERAGE_POINTS", $this->lng->txt("average_reached_points"));
04323                 $this->tpl->setVariable("TXT_QUESTION", $this->lng->txt("question_title"));
04324                 $this->tpl->setVariable("TXT_MEAN", $this->lng->txt("average_reached_points"));
04325                 $this->tpl->parseCurrentBlock();
04326                 
04327                 $noq = $noqcount;               
04328                 foreach ($titlerow as $title)
04329                 {
04330                         if ($noq > 0)
04331                         {
04332                                 $this->tpl->setCurrentBlock("titlecol");
04333                                 $this->tpl->setVariable("TXT_TITLE", "<div title=\"" . ilUtil::prepareFormOutput($legendquestions[$legend[$title]]) . "\">" . $title . "</div>");
04334                                 $this->tpl->parseCurrentBlock();
04335                                 if ($noq == $noqcount)
04336                                 {
04337                                         $this->tpl->setCurrentBlock("questions_titlecol");
04338                                         $this->tpl->setVariable("TXT_TITLE", $title);
04339                                         $this->tpl->parseCurrentBlock();
04340                                 }
04341                                 $noq--;
04342                         }
04343                         else
04344                         {
04345                                 $this->tpl->setCurrentBlock("questions_titlecol");
04346                                 $this->tpl->setVariable("TXT_TITLE", "<div title=\"" . $legendquestions[$legend[$title]] . "\">" . $title . "</div>");
04347                                 $this->tpl->parseCurrentBlock();
04348                         }
04349                 }
04350                 $counter = 0;
04351                 foreach ($eval_complete as $row)
04352                 {
04353                         $noq = $noqcount;
04354                         foreach ($row["data"] as $key => $value)
04355                         {
04356                                 if ($noq > 0)
04357                                 {
04358                                         $this->tpl->setCurrentBlock("datacol");
04359                                         $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
04360                                         $this->tpl->setVariable("TXT_DATA", $value["html"]);
04361                                         $this->tpl->parseCurrentBlock();
04362                                         if ($noq == $noqcount)
04363                                         {
04364                                                 $this->tpl->setCurrentBlock("questions_datacol");
04365                                                 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
04366                                                 $this->tpl->setVariable("TXT_DATA", $value["html"]);
04367                                                 $this->tpl->parseCurrentBlock();
04368                                         }
04369                                         $noq--;
04370                                 }
04371                                 else
04372                                 {
04373                                         $this->tpl->setCurrentBlock("questions_datacol");
04374                                         $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
04375                                         $this->tpl->setVariable("TXT_DATA", $value["html"]);
04376                                         $this->tpl->parseCurrentBlock();
04377                                 }
04378                         }
04379                         $this->tpl->setCurrentBlock("row");
04380                         $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
04381                         $this->tpl->parseCurrentBlock();
04382                         $this->tpl->setCurrentBlock("questions_row");
04383                         $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
04384                         $this->tpl->parseCurrentBlock();
04385                         $counter++;
04386                 }
04387 
04388                 if ($textanswers)
04389                 {
04390                         $this->tpl->setCurrentBlock("questions_output_button");
04391                         $this->tpl->setVariable("BUTTON_SAVE", $this->lng->txt("save_text_answer_points"));
04392                         $this->tpl->setVariable("BTN_COMMAND", $this->ctrl->getCmd());
04393                         $this->tpl->parseCurrentBlock();
04394                 }
04395                 
04396                 $this->tpl->setCurrentBlock("questions_output");
04397                 $this->tpl->setVariable("TXT_QUESTIONS",  $this->lng->txt("ass_questions"));
04398                 $this->tpl->setVariable("FORM_ACTION_RESULTS", $this->ctrl->getFormAction($this));
04399                 $this->tpl->parseCurrentBlock();
04400 
04401                 $this->tpl->setCurrentBlock("export_btn");
04402                 $this->tpl->setVariable("EXPORT_DATA", $this->lng->txt("exp_eval_data"));
04403                 $this->tpl->setVariable("TEXT_EXCEL", $this->lng->txt("exp_type_excel"));
04404                 $this->tpl->setVariable("TEXT_EXCEL_MAC", $this->lng->txt("exp_type_excel_mac"));
04405                 $this->tpl->setVariable("TEXT_CSV", $this->lng->txt("exp_type_spss"));
04406                 $this->tpl->setVariable("BTN_EXPORT", $this->lng->txt("export"));
04407                 $this->tpl->setVariable("BTN_PRINT", $this->lng->txt("print"));
04408                 $this->tpl->setVariable("BTN_COMMAND", $this->ctrl->getCmd());
04409                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
04410                 $this->tpl->parseCurrentBlock();
04411                 
04412                 $this->tpl->setCurrentBlock("adm_content");
04413                 $this->tpl->setVariable("TXT_STATISTICAL_DATA", $this->lng->txt("statistical_data"));
04414                 $this->tpl->parseCurrentBlock();
04415                 if ($print)
04416                 {
04417                         $this->tpl->setCurrentBlock("__global__");
04418                         $this->tpl->setVariable("TXT_STATISTICAL_EVALUATION", $this->lng->txt("tst_statistical_evaluation") . " " . strtolower($this->lng->txt("of")) . " &quot;" . ilUtil::prepareFormOutput($this->object->getTitle()) . "&quot;");
04419                         $this->tpl->setVariable("PRINT_CSS", "./templates/default/print.css");
04420                         $this->tpl->setVariable("PRINT_TYPE", "summary");
04421                         $this->tpl->show();
04422                         exit;
04423                 }
04424         }
04425         
04426         function evalAllUsersObject()
04427         {
04428                 $this->evalSelectedUsersObject(1);
04429         }
04430         
04431         function eval_aObject()
04432         {
04433                 $this->setAggregatedResultsTabs();
04434                 $color_class = array("tblrow1", "tblrow2");
04435                 $counter = 0;
04436                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_eval_anonymous_aggregation.html", true);
04437                 $total_persons = $this->object->evalTotalPersons();
04438                 if ($total_persons) {
04439                         $this->tpl->setCurrentBlock("row");
04440                         $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("tst_eval_total_persons"));
04441                         $this->tpl->setVariable("TXT_VALUE", $total_persons);
04442                         $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
04443                         $counter++;
04444                         $this->tpl->parseCurrentBlock();
04445                         $this->tpl->setCurrentBlock("row");
04446                         $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("tst_eval_total_finished"));
04447                         $total_finished = $this->object->evalTotalFinished();
04448                         $this->tpl->setVariable("TXT_VALUE", $total_finished);
04449                         $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
04450                         $counter++;
04451                         $this->tpl->parseCurrentBlock();
04452                         $this->tpl->setCurrentBlock("row");
04453                         $average_time = $this->object->evalTotalFinishedAverageTime();
04454                         $diff_seconds = $average_time;
04455                         $diff_hours    = floor($diff_seconds/3600);
04456                         $diff_seconds -= $diff_hours   * 3600;
04457                         $diff_minutes  = floor($diff_seconds/60);
04458                         $diff_seconds -= $diff_minutes * 60;
04459                         $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("tst_eval_total_finished_average_time"));
04460                         $this->tpl->setVariable("TXT_VALUE", sprintf("%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds));
04461                         $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
04462                         $counter++;
04463                         $passed_tests = $this->object->evalTotalFinishedPassed();
04464                         $this->tpl->parseCurrentBlock();
04465                         $this->tpl->setCurrentBlock("row");
04466                         $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("tst_eval_total_passed"));
04467                         $this->tpl->setVariable("TXT_VALUE", $passed_tests["total_passed"]);
04468                         $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
04469                         $counter++;
04470                         $this->tpl->parseCurrentBlock();
04471                         $this->tpl->setCurrentBlock("row");
04472                         $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("tst_eval_total_passed_average_points"));
04473                         $this->tpl->setVariable("TXT_VALUE", sprintf("%2.2f", $passed_tests["average_points"]) . " " . strtolower($this->lng->txt("of")) . " " . sprintf("%2.2f", $passed_tests["maximum_points"]));
04474                         $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
04475                         $counter++;
04476                         $this->tpl->parseCurrentBlock();
04477                 } else {
04478                         $this->tpl->setCurrentBlock("emptyrow");
04479                         $this->tpl->setVariable("TXT_NO_ANONYMOUS_AGGREGATION", $this->lng->txt("tst_eval_no_anonymous_aggregation"));
04480                         $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
04481                         $this->tpl->parseCurrentBlock();
04482                 }
04483                 $this->tpl->setCurrentBlock("adm_content");
04484                 $this->tpl->setVariable("TXT_ANON_EVAL", $this->lng->txt("tst_anon_eval"));
04485                 $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("result"));
04486                 $this->tpl->setVariable("TXT_VALUE", $this->lng->txt("value"));
04487                 $this->tpl->parseCurrentBlock();
04488         }
04489 
04497         function confirmDeleteResults() 
04498         {
04499                 $add_parameter = $this->getAddParameter();
04500                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_delete_results_confirm.html", true);
04501                 $this->tpl->setCurrentBlock("adm_content");
04502                 $this->tpl->setVariable("TEXT_CONFIRM_DELETE_RESULTS", $this->lng->txt("tst_confirm_delete_results"));
04503                 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
04504                 $this->tpl->setVariable("BTN_OK", $this->lng->txt("tst_delete_results"));
04505                 $this->tpl->setVariable("FORM_ACTION", $this->getCallingScript() . $add_parameter);
04506                 $this->tpl->parseCurrentBlock();
04507         }
04508 
04516         function outTestResults() {
04517                 global $ilUser;
04518 
04519                 function sort_percent($a, $b) {
04520                         if (strcmp($_GET["order"], "ASC")) {
04521                                 $smaller = 1;
04522                                 $greater = -1;
04523                         } else {
04524                                 $smaller = -1;
04525                                 $greater = 1;
04526                         }
04527                         if ($a["percent"] == $b["percent"]) {
04528                                 if ($a["nr"] == $b["nr"]) return 0;
04529                                 return ($a["nr"] < $b["nr"]) ? -1 : 1;
04530                         }
04531                         return ($a["percent"] < $b["percent"]) ? $smaller : $greater;
04532                 }
04533 
04534                 function sort_nr($a, $b) {
04535                         if (strcmp($_GET["order"], "ASC")) {
04536                                 $smaller = 1;
04537                                 $greater = -1;
04538                         } else {
04539                                 $smaller = -1;
04540                                 $greater = 1;
04541                         }
04542                         if ($a["nr"] == $b["nr"]) return 0;
04543                         return ($a["nr"] < $b["nr"]) ? $smaller : $greater;
04544                 }
04545 
04546                 $add_parameter = $this->getAddParameter();
04547                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_finish.html", true);
04548                 $user_id = $ilUser->id;
04549                 $color_class = array("tblrow1", "tblrow2");
04550                 $counter = 0;
04551                 $this->tpl->addBlockFile("TEST_RESULTS", "results", "tpl.il_as_tst_results.html", true);
04552                 $result_array =& $this->object->getTestResult($user_id);
04553 
04554                 if (!$result_array["test"]["total_max_points"])
04555                 {
04556                         $percentage = 0;
04557                 }
04558                 else
04559                 {
04560                         $percentage = ($result_array["test"]["total_reached_points"]/$result_array["test"]["total_max_points"])*100;
04561                 }
04562                 $total_max = $result_array["test"]["total_max_points"];
04563                 $total_reached = $result_array["test"]["total_reached_points"];
04564                 $img_title_percent = "";
04565                 $img_title_nr = "";
04566                 switch ($_GET["sortres"]) {
04567                         case "percent":
04568                                 usort($result_array, "sort_percent");
04569                                 $img_title_percent = " <img src=\"" . ilUtil::getImagePath(strtolower($_GET["order"]) . "_order.png", true) . "\" alt=\"\" />";
04570                                 if (strcmp($_GET["order"], "ASC") == 0) {
04571                                         $sortpercent = "DESC";
04572                                 } else {
04573                                         $sortpercent = "ASC";
04574                                 }
04575                                 break;
04576                         case "nr":
04577                                 usort($result_array, "sort_nr");
04578                                 $img_title_nr = " <img src=\"" . ilUtil::getImagePath(strtolower($_GET["order"]) . "_order.png", true) . "\" alt=\"\" />";
04579                                 if (strcmp($_GET["order"], "ASC") == 0) {
04580                                         $sortnr = "DESC";
04581                                 } else {
04582                                         $sortnr = "ASC";
04583                                 }
04584                                 break;
04585                 }
04586                 if (!$sortpercent) {
04587                         $sortpercent = "ASC";
04588                 }
04589                 if (!$sortnr) {
04590                         $sortnr = "ASC";
04591                 }
04592 
04593                 foreach ($result_array as $key => $value) {
04594                         if (preg_match("/\d+/", $key)) {
04595                                 $this->tpl->setCurrentBlock("question");
04596                                 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
04597                                 $this->tpl->setVariable("VALUE_QUESTION_COUNTER", $value["nr"]);
04598                                 $this->tpl->setVariable("VALUE_QUESTION_TITLE", $value["title"]);
04599                                 $this->tpl->setVariable("VALUE_MAX_POINTS", $value["max"]);
04600                                 $this->tpl->setVariable("VALUE_REACHED_POINTS", $value["reached"]);
04601                                 if (preg_match("/http/", $value["solution"]))
04602                                 {
04603                                         $this->tpl->setVariable("SOLUTION_HINT", "<a href=\"".$value["solution"]."\" target=\"content\">" . $this->lng->txt("solution_hint"). "</a>");
04604                                 }
04605                                 else
04606                                 {
04607                                         if ($value["solution"])
04608                                         {
04609                                                 $this->tpl->setVariable("SOLUTION_HINT", $this->lng->txt($value["solution"]));
04610                                         }
04611                                         else
04612                                         {
04613                                                 $this->tpl->setVariable("SOLUTION_HINT", "");
04614                                         }
04615                                 }
04616                                 $this->tpl->setVariable("VALUE_PERCENT_SOLVED", $value["percent"]);
04617                                 $this->tpl->parseCurrentBlock();
04618                                 $counter++;
04619                         }
04620                 }
04621 
04622                 $this->tpl->setCurrentBlock("question");
04623                 $this->tpl->setVariable("COLOR_CLASS", "std");
04624                 $this->tpl->setVariable("VALUE_QUESTION_COUNTER", "<strong>" . $this->lng->txt("total") . "</strong>");
04625                 $this->tpl->setVariable("VALUE_QUESTION_TITLE", "");
04626                 $this->tpl->setVariable("SOLUTION_HINT", "");
04627                 $this->tpl->setVariable("VALUE_MAX_POINTS", "<strong>" . sprintf("%d", $total_max) . "</strong>");
04628                 $this->tpl->setVariable("VALUE_REACHED_POINTS", "<strong>" . sprintf("%d", $total_reached) . "</strong>");
04629                 $this->tpl->setVariable("VALUE_PERCENT_SOLVED", "<strong>" . sprintf("%2.2f", $percentage) . " %" . "</strong>");
04630                 $this->tpl->parseCurrentBlock();
04631 
04632                 $this->tpl->setCurrentBlock("results");
04633                 $this->tpl->setVariable("QUESTION_COUNTER", "<a href=\"" . $this->getCallingScript() . "$add_parameter&sortres=nr&order=$sortnr\">" . $this->lng->txt("tst_question_no") . "</a>$img_title_nr");
04634                 $this->tpl->setVariable("QUESTION_TITLE", $this->lng->txt("tst_question_title"));
04635                 $this->tpl->setVariable("SOLUTION_HINT_HEADER", $this->lng->txt("solution_hint"));
04636                 $this->tpl->setVariable("MAX_POINTS", $this->lng->txt("tst_maximum_points"));
04637                 $this->tpl->setVariable("REACHED_POINTS", $this->lng->txt("tst_reached_points"));
04638                 $this->tpl->setVariable("PERCENT_SOLVED", "<a href=\"" . $this->getCallingScript() . "$add_parameter&sortres=percent&order=$sortpercent\">" . $this->lng->txt("tst_percent_solved") . "</a>$img_title_percent");
04639                 $mark_obj = $this->object->mark_schema->get_matching_mark($percentage);
04640                 if ($mark_obj)
04641                 {
04642                         if ($mark_obj->get_passed()) {
04643                                 $mark = $this->lng->txt("tst_result_congratulations");
04644                         } else {
04645                                 $mark = $this->lng->txt("tst_result_sorry");
04646                         }
04647                         $mark .= "<br />" . $this->lng->txt("tst_your_mark_is") . ": &quot;" . $mark_obj->get_official_name() . "&quot;";
04648                 }
04649                 if ($this->object->ects_output)
04650                 {
04651                         $ects_mark = $this->object->getECTSGrade($total_reached, $total_max);
04652                         $mark .= "<br />" . $this->lng->txt("tst_your_ects_mark_is") . ": &quot;" . $ects_mark . "&quot; (" . $this->lng->txt("ects_grade_". strtolower($ects_mark) . "_short") . ": " . $this->lng->txt("ects_grade_". strtolower($ects_mark)) . ")";
04653                 }
04654                 $this->tpl->setVariable("USER_FEEDBACK", $mark);
04655                 $this->tpl->parseCurrentBlock();
04656                 $this->tpl->setCurrentBlock("adm_content");
04657                 $this->tpl->setVariable("TEXT_RESULTS", $this->lng->txt("tst_results"));
04658                 $this->tpl->parseCurrentBlock();
04659         }
04660 
04668         function deleteAllUserDataObject()
04669         {
04670                 sendInfo($this->lng->txt("confirm_delete_all_user_data"));
04671                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_maintenance.html", true);
04672 
04673                 $this->tpl->setCurrentBlock("confirm_delete");
04674                 $this->tpl->setVariable("BTN_CONFIRM_DELETE_ALL", $this->lng->txt("confirm"));
04675                 $this->tpl->setVariable("BTN_CANCEL_DELETE_ALL", $this->lng->txt("cancel"));
04676                 $this->tpl->parseCurrentBlock();
04677 
04678                 $this->tpl->setCurrentBlock("adm_content");
04679                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
04680                 $this->tpl->parseCurrentBlock();
04681         }
04682         
04690         function confirmDeleteAllUserDataObject()
04691         {
04692                 $this->object->removeAllTestEditings();
04693                 sendInfo($this->lng->txt("tst_all_user_data_deleted"), true);
04694                 $this->ctrl->redirect($this, "maintenance");
04695         }
04696         
04704         function cancelDeleteAllUserDataObject()
04705         {
04706                 $this->ctrl->redirect($this, "maintenance");
04707         }
04708         
04718         function createSolutionsObject()
04719         {
04720                 $this->object->createRandomSolutionsForAllUsers();
04721                 $this->ctrl->redirect($this, "maintenance");
04722         }
04723 
04731         function maintenanceObject()
04732         {
04733                 global $rbacsystem;
04734 
04735                 if ((!$rbacsystem->checkAccess("read", $this->ref_id)) && (!$rbacsystem->checkAccess("write", $this->ref_id))) 
04736                 {
04737                         // allow only read and write access
04738                         sendInfo($this->lng->txt("cannot_edit_test"), true);
04739                         $path = $this->tree->getPathFull($this->object->getRefID());
04740                         ilUtil::redirect($this->getReturnLocation("cancel","../repository.php?cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
04741                         return;
04742                 }
04743                 
04744                 if ($rbacsystem->checkAccess("write", $this->ref_id)) {
04745                         $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_maintenance.html", true);
04746                         $this->tpl->setCurrentBlock("adm_content");
04747                         $this->tpl->setVariable("BTN_DELETE_ALL", $this->lng->txt("tst_delete_all_user_data"));
04748 //                      $this->tpl->setVariable("BTN_CREATE_SOLUTIONS", $this->lng->txt("tst_create_solutions"));
04749                         $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
04750                         $this->tpl->parseCurrentBlock();
04751                 }
04752                 else
04753                 {
04754                         sendInfo($this->lng->txt("cannot_maintain_test"));
04755                 }
04756         }       
04757 
04765         function statusObject()
04766         {
04767                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_status.html", true);
04768                 if (!$this->object->isComplete())
04769                 {
04770                         if (!$this->object->isRandomTest())
04771                         {
04772                                 if (count($this->object->questions) == 0)
04773                                 {
04774                                         $this->tpl->setCurrentBlock("list_element");
04775                                         $this->tpl->setVariable("TEXT_ELEMENT", $this->lng->txt("tst_missing_questions"));
04776                                         $this->tpl->parseCurrentBlock();
04777                                 }
04778                         }
04779                         if (count($this->object->mark_schema->mark_steps) == 0)
04780                         {
04781                                 $this->tpl->setCurrentBlock("list_element");
04782                                 $this->tpl->setVariable("TEXT_ELEMENT", $this->lng->txt("tst_missing_marks"));
04783                                 $this->tpl->parseCurrentBlock();
04784                         }
04785                         if (strcmp($this->object->author, "") == 0)
04786                         {
04787                                 $this->tpl->setCurrentBlock("list_element");
04788                                 $this->tpl->setVariable("TEXT_ELEMENT", $this->lng->txt("tst_missing_author"));
04789                                 $this->tpl->parseCurrentBlock();
04790                         }
04791                         if (strcmp($this->object->title, "") == 0)
04792                         {
04793                                 $this->tpl->setCurrentBlock("list_element");
04794                                 $this->tpl->setVariable("TEXT_ELEMENT", $this->lng->txt("tst_missing_author"));
04795                                 $this->tpl->parseCurrentBlock();
04796                         }
04797                         
04798                         if ($this->object->isRandomTest())
04799                         {
04800                                 $arr = $this->object->getRandomQuestionpools();
04801                                 if (count($arr) == 0)
04802                                 {
04803                                         $this->tpl->setCurrentBlock("list_element");
04804                                         $this->tpl->setVariable("TEXT_ELEMENT", $this->lng->txt("tst_no_questionpools_for_random_test"));
04805                                         $this->tpl->parseCurrentBlock();
04806                                 }
04807                                 $count = 0;
04808                                 foreach ($arr as $array)
04809                                 {
04810                                         $count += $array["count"];
04811                                 }
04812                                 if (($count == 0) && ($this->object->getRandomQuestionCount() == 0))
04813                                 {
04814                                         $this->tpl->setCurrentBlock("list_element");
04815                                         $this->tpl->setVariable("TEXT_ELEMENT", $this->lng->txt("tst_no_questions_for_random_test"));
04816                                         $this->tpl->parseCurrentBlock();
04817                                 }
04818                         }
04819                         
04820                         $this->tpl->setCurrentBlock("status_list");
04821                         $this->tpl->setVariable("TEXT_MISSING_ELEMENTS", $this->lng->txt("tst_status_missing_elements"));
04822                         $this->tpl->parseCurrentBlock();
04823                 }
04824                 $total = $this->object->evalTotalPersons();
04825                 if ($total > 0)
04826                 {
04827                         $this->tpl->setCurrentBlock("list_element");
04828                         $this->tpl->setVariable("TEXT_ELEMENT", sprintf($this->lng->txt("tst_in_use_edit_questions_disabled"), $total));
04829                         $this->tpl->parseCurrentBlock();
04830                 }
04831                 $this->tpl->setCurrentBlock("adm_content");
04832                 if ($this->object->isComplete())
04833                 {
04834                         $this->tpl->setVariable("TEXT_STATUS_MESSAGE", $this->lng->txt("tst_status_ok"));
04835                         $this->tpl->setVariable("STATUS_CLASS", "bold");
04836                 }
04837                 else
04838                 {
04839                         $this->tpl->setVariable("TEXT_STATUS_MESSAGE", $this->lng->txt("tst_status_missing"));
04840                         $this->tpl->setVariable("STATUS_CLASS", "warning");
04841                 }
04842                 $this->tpl->parseCurrentBlock();
04843         }       
04844 
04853         function setLocator($a_tree = "", $a_id = "", $scriptname="repository.php")
04854         {
04855 //              global $ilias_locator;
04856                 $ilias_locator = new ilLocatorGUI(false);
04857                 if (!is_object($a_tree))
04858                 {
04859                         $a_tree =& $this->tree;
04860                 }
04861                 if (!($a_id))
04862                 {
04863                         $a_id = $_GET["ref_id"];
04864                 }
04865 
04866                 //$this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
04867 
04868                 $path = $a_tree->getPathFull($a_id);
04869                 //check if object isn't in tree, this is the case if parent_parent is set
04870                 // TODO: parent_parent no longer exist. need another marker
04871                 if ($a_parent_parent)
04872                 {
04873                         //$subObj = getObject($a_ref_id);
04874                         $subObj =& $this->ilias->obj_factory->getInstanceByRefId($a_ref_id);
04875 
04876                         $path[] = array(
04877                                 "id"     => $a_ref_id,
04878                                 "title"  => $this->lng->txt($subObj->getTitle())
04879                                 );
04880                 }
04881 
04882                 // this is a stupid workaround for a bug in PEAR:IT
04883                 $modifier = 1;
04884 
04885                 if (isset($_GET["obj_id"]))
04886                 {
04887                         $modifier = 0;
04888                 }
04889 
04890                 // ### AA 03.11.10 added new locator GUI class ###
04891                 $i = 1;
04892                 if (!defined("ILIAS_MODULE")) {
04893                         foreach ($path as $key => $row)
04894                         {
04895                                 $ilias_locator->navigate($i++, $row["title"], 
04896                                                                                  ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH).
04897                                                                                  "/adm_object.php?ref_id=".$row["child"],"");
04898                         }
04899                 } else {
04900 
04901                         // Workaround for crs_objectives
04902                         $frameset = $_GET['crs_show_result'] ? '' : 'cmd=frameset&';
04903 
04904                         foreach ($path as $key => $row)
04905                         {
04906                                 if (strcmp($row["title"], "ILIAS") == 0) {
04907                                         $row["title"] = $this->lng->txt("repository");
04908                                 }
04909                                 if ($this->ref_id == $row["child"]) {
04910                                         if ($_GET["cmd"]) {
04911                                                 $param = "&cmd=" . $_GET["cmd"];
04912                                         } else {
04913                                                 $param = "";
04914                                         }
04915                                         $ilias_locator->navigate($i++, $row["title"], 
04916                                                                                          ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . 
04917                                                                                          "/assessment/test.php" . "?crs_show_result=".$_GET['crs_show_result'].
04918                                                                                          "&ref_id=".$row["child"] . $param,"");
04919                                         if ($this->sequence) {
04920                                                 if (($this->sequence <= $this->object->getQuestionCount()) and (!$_POST["cmd"]["showresults"])) {
04921                                                         $ilias_locator->navigate($i++, $this->object->getQuestionTitle($this->sequence), 
04922                                                                                                          ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . 
04923                                                                                                          "/assessment/test.php" . "?crs_show_result=".$_GET['crs_show_result'].
04924                                                                                                          "&ref_id=".$row["child"] . $param . 
04925                                                                                                          "&sequence=" . $this->sequence,"");
04926                                                 } else {
04927                                                 }
04928                                         }
04929                                 } else {
04930                                         $ilias_locator->navigate($i++, $row["title"], 
04931                                                                                          ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/" . 
04932                                                                                          $scriptname."?".$frameset."ref_id=".$row["child"],"");
04933                                 }
04934                         }
04935 
04936                         if (isset($_GET["obj_id"]))
04937                         {
04938                                 $obj_data =& $this->ilias->obj_factory->getInstanceByObjId($_GET["obj_id"]);
04939                                 $ilias_locator->navigate($i++,$obj_data->getTitle(),
04940                                                                                  $scriptname."?".$frameset."ref_id=".$_GET["ref_id"]."&obj_id=".$_GET["obj_id"],"");
04941                         }
04942                 }
04943                 $ilias_locator->output();
04944         }
04945 
04946 
04947         function editMetaObject()
04948         {
04949                 $meta_gui =& new ilMetaDataGUI();
04950                 $meta_gui->setObject($this->object);
04951                 $meta_gui->edit("ADM_CONTENT", "adm_content",
04952                         $this->getTabTargetScript()."?ref_id=".$_GET["ref_id"]."&cmd=saveMeta");
04953         }
04954 
04955         function saveMetaObject()
04956         {
04957                 $meta_gui =& new ilMetaDataGUI();
04958                 $meta_gui->setObject($this->object);
04959                 $meta_gui->save($_POST["meta_section"]);
04960                 if (!strcmp($_POST["meta_section"], "General")) {
04961                         $meta = $_POST["meta"];
04962                         $this->object->setTitle(ilUtil::stripSlashes($meta["Title"]["Value"]));
04963                         $this->object->setDescription(ilUtil::stripSlashes($meta["Description"][0]["Value"]));
04964                         $this->object->update();
04965                 }
04966                 ilUtil::redirect($this->getTabTargetScript()."?ref_id=".$_GET["ref_id"]."&cmd=editMeta");
04967         }
04968 
04969         // called by administration
04970         function chooseMetaSectionObject($a_script = "",
04971                 $a_templ_var = "ADM_CONTENT", $a_templ_block = "adm_content")
04972         {
04973                 if ($a_script == "")
04974                 {
04975                         $a_script = $this->getTabTargetScript()."?ref_id=".$_GET["ref_id"];
04976                 }
04977                 $meta_gui =& new ilMetaDataGUI();
04978                 $meta_gui->setObject($this->object);
04979                 $meta_gui->edit($a_templ_var, $a_templ_block, $a_script, $_REQUEST["meta_section"]);
04980         }
04981 
04982         // called by editor
04983         function chooseMetaSection()
04984         {
04985                 $this->chooseMetaSectionObject($this->getTabTargetScript()."?ref_id=".
04986                         $this->object->getRefId());
04987         }
04988 
04989         function addMetaObject($a_script = "",
04990                 $a_templ_var = "ADM_CONTENT", $a_templ_block = "adm_content")
04991         {
04992                 if ($a_script == "")
04993                 {
04994                         $a_script = $this->getTabTargetScript()."?ref_id=".$_GET["ref_id"];
04995                 }
04996                 $meta_gui =& new ilMetaDataGUI();
04997                 $meta_gui->setObject($this->object);
04998                 $meta_name = $_POST["meta_name"] ? $_POST["meta_name"] : $_GET["meta_name"];
04999                 $meta_index = $_POST["meta_index"] ? $_POST["meta_index"] : $_GET["meta_index"];
05000                 if ($meta_index == "")
05001                         $meta_index = 0;
05002                 $meta_path = $_POST["meta_path"] ? $_POST["meta_path"] : $_GET["meta_path"];
05003                 $meta_section = $_POST["meta_section"] ? $_POST["meta_section"] : $_GET["meta_section"];
05004                 if ($meta_name != "")
05005                 {
05006                         $meta_gui->meta_obj->add($meta_name, $meta_path, $meta_index);
05007                 }
05008                 else
05009                 {
05010                         sendInfo($this->lng->txt("meta_choose_element"), true);
05011                 }
05012                 $meta_gui->edit($a_templ_var, $a_templ_block, $a_script, $meta_section);
05013         }
05014 
05015         function addMeta()
05016         {
05017                 $this->addMetaObject($this->getTabTargetScript()."?ref_id=".
05018                         $this->object->getRefId());
05019         }
05020 
05021         function deleteMetaObject($a_script = "",
05022                 $a_templ_var = "ADM_CONTENT", $a_templ_block = "adm_content")
05023         {
05024                 if ($a_script == "")
05025                 {
05026                         $a_script = $this->getTabTargetScript()."?ref_id=".$_GET["ref_id"];
05027                 }
05028                 $meta_gui =& new ilMetaDataGUI();
05029                 $meta_gui->setObject($this->object);
05030                 $meta_index = $_POST["meta_index"] ? $_POST["meta_index"] : $_GET["meta_index"];
05031                 $meta_gui->meta_obj->delete($_GET["meta_name"], $_GET["meta_path"], $meta_index);
05032                 $meta_gui->edit($a_templ_var, $a_templ_block, $a_script, $_GET["meta_section"]);
05033         }
05034 
05035         function deleteMeta()
05036         {
05037                 $this->deleteMetaObject($this->getTabTargetScript()."?ref_id=".
05038                         $this->object->getRefId());
05039         }
05040 
05044         function createObject()
05045         {
05046                 global $rbacsystem;
05047                 $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
05048                 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
05049                 {
05050                         $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
05051                 }
05052                 else
05053                 {
05054                         $this->getTemplateFile("create", $new_type);
05055 
05056                         include_once("./assessment/classes/class.ilObjTest.php");
05057                         $tst = new ilObjTest();
05058                         
05059                         $tests =& ilObjTest::_getAvailableTests(true);
05060                         if (count($tests) > 0)
05061                         {
05062                                 foreach ($tests as $key => $value)
05063                                 {
05064                                         $this->tpl->setCurrentBlock("option_tst");
05065                                         $this->tpl->setVariable("OPTION_VALUE_TST", $key);
05066                                         $this->tpl->setVariable("TXT_OPTION_TST", $value);
05067                                         if ($_POST["tst"] == $key)
05068                                         {
05069                                                 $this->tpl->setVariable("OPTION_SELECTED_TST", " selected=\"selected\"");                               
05070                                         }
05071                                         $this->tpl->parseCurrentBlock();
05072                                 }
05073                         }
05074                         
05075                         $questionpools =& $tst->getAvailableQuestionpools(true);
05076                         if (count($questionpools) == 0)
05077                         {
05078                         }
05079                         else
05080                         {
05081                                 foreach ($questionpools as $key => $value)
05082                                 {
05083                                         $this->tpl->setCurrentBlock("option_qpl");
05084                                         $this->tpl->setVariable("OPTION_VALUE", $key);
05085                                         $this->tpl->setVariable("TXT_OPTION", $value);
05086                                         if ($_POST["qpl"] == $key)
05087                                         {
05088                                                 $this->tpl->setVariable("OPTION_SELECTED", " selected=\"selected\"");                           
05089                                         }
05090                                         $this->tpl->parseCurrentBlock();
05091                                 }
05092                         }
05093                         // fill in saved values in case of error
05094                         $data = array();
05095                         $data["fields"] = array();
05096                         $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
05097                         $data["fields"]["desc"] = ilUtil::stripSlashes($_SESSION["error_post_vars"]["Fobject"]["desc"]);
05098 
05099                         foreach ($data["fields"] as $key => $val)
05100                         {
05101                                 $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
05102                                 $this->tpl->setVariable(strtoupper($key), $val);
05103 
05104                                 if ($this->prepare_output)
05105                                 {
05106                                         $this->tpl->parseCurrentBlock();
05107                                 }
05108                         }
05109 
05110                         $this->tpl->setVariable("FORMACTION", $this->getFormAction("save","adm_object.php?cmd=gateway&ref_id=".
05111                                                                                                                                            $_GET["ref_id"]."&new_type=".$new_type));
05112                         $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
05113                         $this->tpl->setVariable("TXT_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool"));
05114                         $this->tpl->setVariable("OPTION_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool_option"));
05115                         $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
05116                         $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
05117                         $this->tpl->setVariable("CMD_SUBMIT", "save");
05118                         $this->tpl->setVariable("TARGET", $this->getTargetFrame("save"));
05119                         $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
05120 
05121                         $this->tpl->setVariable("TXT_IMPORT_TST", $this->lng->txt("import_tst"));
05122                         $this->tpl->setVariable("TXT_TST_FILE", $this->lng->txt("tst_upload_file"));
05123                         $this->tpl->setVariable("TXT_IMPORT", $this->lng->txt("import"));
05124 
05125                         $this->tpl->setVariable("TXT_DUPLICATE_TST", $this->lng->txt("duplicate_tst"));
05126                         $this->tpl->setVariable("TXT_SELECT_TST", $this->lng->txt("obj_tst"));
05127                         $this->tpl->setVariable("OPTION_SELECT_TST", $this->lng->txt("select_tst_option"));
05128                         $this->tpl->setVariable("TXT_DUPLICATE", $this->lng->txt("duplicate"));
05129                 }
05130         }
05131 
05132         function prepareOutput()
05133         {
05134                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
05135                 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
05136                 $title = $this->object->getTitle();
05137                 // catch feedback message
05138                 sendInfo();
05139 
05140                 if (!empty($title))
05141                 {
05142                         $this->tpl->setVariable("HEADER", $title);
05143                 }
05144                 if (!defined("ILIAS_MODULE"))
05145                 {
05146                         $this->setAdminTabs($_POST["new_type"]);
05147                 }
05148                 $this->setLocator();
05149 
05150         }
05151         
05152         function setAggregatedResultsTabs()
05153         {
05154                 global $rbacsystem;
05155 
05156                 include_once "./classes/class.ilTabsGUI.php";
05157                 $tabs_gui =& new ilTabsGUI();
05158                 
05159                 $path = $this->tree->getPathFull($this->object->getRefID());
05160                 $addcmd = "";
05161                 if (strcmp($_SESSION["il_rep_mode"], "tree") == 0)
05162                 {
05163                         $addcmd = "&cmd=frameset";
05164                 }
05165                 $tabs_gui->addTarget("back", $this->getReturnLocation("cancel","../repository.php?ref_id=" . $path[count($path) - 2]["child"]) . $addcmd, "",   "");
05166                 $this->tpl->setVariable("TABS", $tabs_gui->getHTML());
05167         }
05168         
05169         function setEvaluationSettingsTabs()
05170         {
05171                 global $rbacsystem;
05172 
05173                 include_once "./classes/class.ilTabsGUI.php";
05174                 $tabs_gui =& new ilTabsGUI();
05175                 
05176                 $path = $this->tree->getPathFull($this->object->getRefID());
05177                 $tabs_gui->addTarget("eval_all_users", $this->ctrl->getLinkTargetByClass(get_class($this), "eval_stat"), "eval_stat",   "ilobjtestgui");
05178                 $tabs_gui->addTarget("eval_selected_users", $this->ctrl->getLinkTargetByClass(get_class($this), "evalStatSelected"), "evalStatSelected",        "ilobjtestgui");
05179                 $this->tpl->setVariable("TABS", $tabs_gui->getHTML());
05180         }
05181         
05182         function setEvaluationTabs($all_users = 0)
05183         {
05184                 global $rbacsystem;
05185 
05186                 include_once "./classes/class.ilTabsGUI.php";
05187                 $tabs_gui =& new ilTabsGUI();
05188                 
05189                 $cmd = "evalAllUsers";
05190                 if ($all_users == 0)
05191                 {
05192                         $cmd = "evalSelectedUsers";
05193                 }
05194                 $path = $this->tree->getPathFull($this->object->getRefID());
05195                 $tabs_gui->addTarget("tst_statistical_evaluation", $this->ctrl->getLinkTargetByClass(get_class($this), "$cmd"), "$cmd", "ilobjtestgui");
05196                 $this->tpl->setVariable("TABS", $tabs_gui->getHTML());
05197         }
05198         
05199 } // END class.ilObjTestGUI
05200 
05201 ?>

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