• Main Page
  • Related Pages
  • Modules
  • 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 
00040 include_once "./classes/class.ilObjectGUI.php";
00041 include_once "./assessment/classes/inc.AssessmentConstants.php";
00042 
00043 class ilObjTestGUI extends ilObjectGUI
00044 {
00049         function ilObjTestGUI()
00050         {
00051                 global $lng, $ilCtrl, $rbacsystem;
00052                 $lng->loadLanguageModule("assessment");
00053                 $this->type = "tst";
00054                 $this->ctrl =& $ilCtrl;
00055                 $this->ctrl->saveParameter($this, "ref_id");
00056                 $this->ilObjectGUI("",$_GET["ref_id"], true, false);
00057                 // Added parameter if called from crs_objectives
00058                 if((int) $_GET['crs_show_result'])
00059                 {
00060                         $this->ctrl->saveParameter($this,'crs_show_result',(int) $_GET['crs_show_result']);
00061                 }
00062                 if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
00063                 {
00064                         $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00065                 }
00066         }
00067         
00071         function &executeCommand()
00072         {
00073                 $this->prepareOutput();
00074                 $cmd = $this->ctrl->getCmd("properties");
00075                 $next_class = $this->ctrl->getNextClass($this);
00076                 $this->ctrl->setReturn($this, "properties");
00077                 switch($next_class)
00078                 {
00079                         case "ilinfoscreengui":
00080                                 $this->infoScreen();    // forwards command
00081                                 break;
00082                         case 'ilmdeditorgui':
00083                                 include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
00084 
00085                                 $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
00086                                 $md_gui->addObserver($this->object,'MDUpdateListener','General');
00087 
00088                                 $this->ctrl->forwardCommand($md_gui);
00089                                 break;
00090                         case "iltestoutputgui":
00091                                 include_once "./assessment/classes/class.ilTestOutputGUI.php";
00092 
00093                                 $output_gui =& new ilTestOutputGUI($this->object);
00094                                 $this->ctrl->forwardCommand($output_gui);
00095                                 break;
00096                         case "iltestevaluationgui":
00097                                 include_once "./assessment/classes/class.ilTestEvaluationGUI.php";
00098 
00099                                 $evaluation_gui =& new ilTestEvaluationGUI($this->object);
00100                                 $this->ctrl->forwardCommand($evaluation_gui);
00101                                 break;
00102                                 
00103                         case 'ilpermissiongui':
00104                                 include_once("./classes/class.ilPermissionGUI.php");
00105                                 $perm_gui =& new ilPermissionGUI($this);
00106                                 $ret =& $this->ctrl->forwardCommand($perm_gui);
00107                                 break;
00108 
00109                         case "illearningprogressgui":
00110                                 include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
00111 
00112                                 $new_gui =& new ilLearningProgressGUI(LP_MODE_REPOSITORY,$this->object->getRefId());
00113                                 $this->ctrl->forwardCommand($new_gui);
00114 
00115                                 break;
00116 
00117                         default:
00118                                 if (preg_match("/deleteqpl_\d+/", $cmd))
00119                                 {
00120                                         $cmd = "randomQuestions";
00121                                 }
00122                                 if ((strcmp($cmd, "properties") == 0) && ($_GET["browse"]))
00123                                 {
00124                                         $this->questionBrowser();
00125                                         return;
00126                                 }
00127                                 if ((strcmp($cmd, "properties") == 0) && ($_GET["up"] || $_GET["down"]))
00128                                 {
00129                                         $this->questionsObject();
00130                                         return;
00131                                 }
00132                                 $cmd.= "Object";
00133                                 $ret =& $this->$cmd();
00134                                 break;
00135                 }
00136                 if (strtolower($_GET["baseClass"]) != "iladministrationgui" &&
00137                         $this->getCreationMode() != true)
00138                 {
00139                         $this->tpl->show();
00140                 }
00141         }
00142 
00143         function runObject()
00144         {
00145                 $this->ctrl->redirect($this, "infoScreen");
00146         }
00147         
00148         function eval_aObject()
00149         {
00150                 include_once "./assessment/classes/class.ilTestEvaluationGUI.php";
00151 
00152                 $evaluation_gui =& new ilTestEvaluationGUI($this->object);
00153                 $this->ctrl->redirect($evaluation_gui, "eval_a");
00154         }
00155 
00156         function eval_statObject()
00157         {
00158                 include_once "./assessment/classes/class.ilTestEvaluationGUI.php";
00159 
00160                 $evaluation_gui =& new ilTestEvaluationGUI($this->object);
00161                 $this->ctrl->redirect($evaluation_gui, "eval_stat");
00162         }
00163 
00167         function importFileObject()
00168         {
00169                 if ($_POST["qpl"] < 1)
00170                 {
00171                         sendInfo($this->lng->txt("tst_select_questionpools"));
00172                         $this->createObject();
00173                         return;
00174                 }
00175                 if (strcmp($_FILES["xmldoc"]["tmp_name"], "") == 0)
00176                 {
00177                         sendInfo($this->lng->txt("tst_select_file_for_import"));
00178                         $this->createObject();
00179                         return;
00180                 }
00181                 $this->ctrl->setParameter($this, "new_type", $this->type);
00182                 $this->uploadTstObject();
00183         }
00184         
00188         function cloneAllObject()
00189         {
00190                 if ($_POST["tst"] < 1)
00191                 {
00192                         sendInfo($this->lng->txt("tst_select_tsts"));
00193                         $this->createObject();
00194                         return;
00195                 }
00196                 include_once "./assessment/classes/class.ilObjTest.php";
00197                 $ref_id = ilObjTest::_clone($_POST["tst"]);
00198                 sendInfo($this->lng->txt("object_duplicated"),true);
00199                 ilUtil::redirect("ilias.php?ref_id=$ref_id&baseClass=ilObjTestGUI");
00200         }
00201         
00206         function saveObject()
00207         {
00208                 global $rbacadmin;
00209 
00210                 // create and insert forum in objecttree
00211                 $newObj = parent::saveObject();
00212 
00213                 // always send a message
00214                 sendInfo($this->lng->txt("object_added"),true);
00215 
00216                 ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
00217                         "&baseClass=ilObjTestGUI");
00218         }
00219 
00220         function backToRepositoryObject()
00221         {
00222                 include_once "./classes/class.ilUtil.php";
00223                 $path = $this->tree->getPathFull($this->object->getRefID());
00224                 ilUtil::redirect($this->getReturnLocation("cancel","./repository.php?cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
00225         }
00226         
00227         function backToCourseObject()
00228         {
00229                 include_once "./classes/class.ilUtil.php";
00230                 ilUtil::redirect($this->getReturnLocation("cancel","./repository.php?ref_id=".(int) $_GET['crs_show_result']));
00231         }
00232         
00233         /*
00234         * list all export files
00235         */
00236         function exportObject()
00237         {
00238                 global $tree;
00239                 global $ilAccess;
00240                 if (!$ilAccess->checkAccess("write", "", $this->ref_id)) 
00241                 {
00242                         // allow only write access
00243                         sendInfo($this->lng->txt("cannot_edit_test"), true);
00244                         $this->ctrl->redirect($this, "infoScreen");
00245                 }
00246 
00247 
00248                 //add template for view button
00249                 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00250 
00251                 // create export file button
00252                 $this->tpl->setCurrentBlock("btn_cell");
00253                 $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "createExportFile")."&mode=xml");
00254                 $this->tpl->setVariable("BTN_TXT", $this->lng->txt("ass_create_export_file"));
00255                 $this->tpl->parseCurrentBlock();
00256                 
00257                 // create export file button
00258                 if ($this->object->isOnlineTest()) 
00259                 {
00260                         $this->tpl->setCurrentBlock("btn_cell");
00261                         $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "createExportfile")."&mode=results");
00262                         $this->tpl->setVariable("BTN_TXT", $this->lng->txt("ass_create_export_test_results"));
00263                         $this->tpl->parseCurrentBlock();
00264                 }
00265                 
00266                 $export_dir = $this->object->getExportDirectory();
00267 
00268                 $export_files = $this->object->getExportFiles($export_dir);
00269 
00270                 // create table
00271                 include_once("classes/class.ilTableGUI.php");
00272                 $tbl = new ilTableGUI();
00273 
00274                 // load files templates
00275                 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
00276 
00277                 // load template for table content data
00278                 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.export_file_row.html", true);
00279 
00280                 $num = 0;
00281 
00282                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00283 
00284                 $tbl->setTitle($this->lng->txt("ass_export_files"));
00285 
00286                 $tbl->setHeaderNames(array("", $this->lng->txt("ass_file"),
00287                         $this->lng->txt("ass_size"), $this->lng->txt("date") ));
00288 
00289                 $tbl->enabled["sort"] = false;
00290                 $tbl->setColumnWidth(array("1%", "49%", "25%", "25%"));
00291 
00292                 // control
00293                 $tbl->setOrderColumn($_GET["sort_by"]);
00294                 $tbl->setOrderDirection($_GET["sort_order"]);
00295                 $tbl->setLimit($_GET["limit"]);
00296                 $tbl->setOffset($_GET["offset"]);
00297                 $tbl->setMaxCount($this->maxcount);             // ???
00298                 $header_params = $this->ctrl->getParameterArray($this, "export");
00299                 $tbl->setHeaderVars(array("", "file", "size", "date"), $header_params);
00300 
00301 
00302                 // footer
00303                 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
00304                 //$tbl->disable("footer");
00305 
00306                 $tbl->setMaxCount(count($export_files));
00307                 $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
00308 
00309                 $tbl->render();
00310                 if(count($export_files) > 0)
00311                 {
00312                         $this->tpl->setVariable("COLUMN_COUNTS", 4);
00313 
00314                         $i=0;
00315                         foreach($export_files as $exp_file)
00316                         {
00317                                 $this->tpl->setCurrentBlock("tbl_content");
00318                                 $this->tpl->setVariable("TXT_FILENAME", $exp_file);
00319 
00320                                 $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
00321                                 $this->tpl->setVariable("CSS_ROW", $css_row);
00322 
00323                                 $this->tpl->setVariable("TXT_SIZE", filesize($export_dir."/".$exp_file));
00324                                 $this->tpl->setVariable("CHECKBOX_ID", $exp_file);
00325 
00326                                 $file_arr = explode("__", $exp_file);
00327                                 $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s",$file_arr[0]));
00328 
00329                                 $this->tpl->parseCurrentBlock();
00330                         }
00331                         $this->tpl->setCurrentBlock("selectall");
00332                         $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
00333                         $this->tpl->setVariable("CSS_ROW", $css_row);
00334                         $this->tpl->parseCurrentBlock();
00335                         // delete button
00336                         $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
00337                         $this->tpl->setCurrentBlock("tbl_action_btn");
00338                         $this->tpl->setVariable("BTN_NAME", "confirmDeleteExportFile");
00339                         $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
00340                         $this->tpl->parseCurrentBlock();
00341         
00342                         $this->tpl->setCurrentBlock("tbl_action_btn");
00343                         $this->tpl->setVariable("BTN_NAME", "downloadExportFile");
00344                         $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("download"));
00345                         $this->tpl->parseCurrentBlock();        
00346                 } //if is_array
00347                 else
00348                 {
00349                         $this->tpl->setCurrentBlock("notfound");
00350                         $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
00351                         $this->tpl->setVariable("NUM_COLS", 3);
00352                         $this->tpl->parseCurrentBlock();
00353                 }
00354 
00355                 $this->tpl->parseCurrentBlock();
00356         }
00357 
00358         
00362         function createExportFileObject()
00363         {
00364                 global $ilAccess;
00365                 
00366                 if ($ilAccess->checkAccess("write", "", $this->ref_id))
00367                 {
00368                         include_once("assessment/classes/class.ilTestExport.php");
00369                         $test_exp = new ilTestExport($this->object, $_GET["mode"]);
00370                         $test_exp->buildExportFile();
00371                 }
00372                 else
00373                 {
00374                         sendInfo("cannot_export_test");
00375                 }
00376                 $this->exportObject();
00377         }
00378         
00379         
00383         function downloadExportFileObject()
00384         {
00385                 if(!isset($_POST["file"]))
00386                 {
00387                         sendInfo($this->lng->txt("no_checkbox"), true);
00388                         $this->ctrl->redirect($this, "export");
00389                 }
00390 
00391                 if (count($_POST["file"]) > 1)
00392                 {
00393                         sendInfo($this->lng->txt("select_max_one_item"), true);
00394                         $this->ctrl->redirect($this, "export");
00395                 }
00396 
00397 
00398                 $export_dir = $this->object->getExportDirectory();
00399                 ilUtil::deliverFile($export_dir."/".$_POST["file"][0],
00400                         $_POST["file"][0]);
00401         }
00402 
00406         function confirmDeleteExportFileObject()
00407         {
00408                 if(!isset($_POST["file"]))
00409                 {
00410                         sendInfo($this->lng->txt("no_checkbox"), true);
00411                         $this->ctrl->redirect($this, "export");
00412                 }
00413 
00414                 // SAVE POST VALUES
00415                 $_SESSION["ilExportFiles"] = $_POST["file"];
00416 
00417                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html", true);
00418 
00419                 sendInfo($this->lng->txt("info_delete_sure"));
00420 
00421                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00422 
00423                 // BEGIN TABLE HEADER
00424                 $this->tpl->setCurrentBlock("table_header");
00425                 $this->tpl->setVariable("TEXT",$this->lng->txt("objects"));
00426                 $this->tpl->parseCurrentBlock();
00427 
00428                 // BEGIN TABLE DATA
00429                 $counter = 0;
00430                 foreach($_POST["file"] as $file)
00431                 {
00432                                 $this->tpl->setCurrentBlock("table_row");
00433                                 $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
00434                                 $this->tpl->setVariable("TEXT_CONTENT", $file);
00435                                 $this->tpl->parseCurrentBlock();
00436                 }
00437 
00438                 // cancel/confirm button
00439                 $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
00440                 $buttons = array( "cancelDeleteExportFile"  => $this->lng->txt("cancel"),
00441                         "deleteExportFile"  => $this->lng->txt("confirm"));
00442                 foreach ($buttons as $name => $value)
00443                 {
00444                         $this->tpl->setCurrentBlock("operation_btn");
00445                         $this->tpl->setVariable("BTN_NAME",$name);
00446                         $this->tpl->setVariable("BTN_VALUE",$value);
00447                         $this->tpl->parseCurrentBlock();
00448                 }
00449         }
00450 
00456         function cancelObject($in_rep = false)
00457         {
00458                 sendInfo($this->lng->txt("msg_cancel"),true);
00459                 ilUtil::redirect("repository.php?cmd=frameset&ref_id=".$_GET["ref_id"]);
00460         }
00461 
00465         function cancelDeleteExportFileObject()
00466         {
00467                 session_unregister("ilExportFiles");
00468                 $this->ctrl->redirect($this, "export");
00469         }
00470 
00471 
00475         function deleteExportFileObject()
00476         {
00477                 $export_dir = $this->object->getExportDirectory();
00478                 foreach($_SESSION["ilExportFiles"] as $file)
00479                 {
00480                         $exp_file = $export_dir."/".$file;
00481                         $exp_dir = $export_dir."/".substr($file, 0, strlen($file) - 4);
00482                         if (@is_file($exp_file))
00483                         {
00484                                 unlink($exp_file);
00485                         }
00486                         if (@is_dir($exp_dir))
00487                         {
00488                                 ilUtil::delDir($exp_dir);
00489                         }
00490                 }
00491                 $this->ctrl->redirect($this, "export");
00492         }
00493 
00499         function importObject()
00500         {
00501                 $this->getTemplateFile("import", "tst");
00502                 $this->tpl->setCurrentBlock("option_qpl");
00503                 include_once("./assessment/classes/class.ilObjTest.php");
00504                 $tst = new ilObjTest();
00505                 $questionpools =& $tst->getAvailableQuestionpools(true);
00506                 if (count($questionpools) == 0)
00507                 {
00508                 }
00509                 else
00510                 {
00511                         foreach ($questionpools as $key => $value)
00512                         {
00513                                 $this->tpl->setCurrentBlock("option_qpl");
00514                                 $this->tpl->setVariable("OPTION_VALUE", $key);
00515                                 $this->tpl->setVariable("TXT_OPTION", $value["title"]);
00516                                 $this->tpl->parseCurrentBlock();
00517                         }
00518                 }
00519                 $this->tpl->setVariable("TXT_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool"));
00520                 $this->tpl->setVariable("OPTION_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool_option"));
00521                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00522                 $this->tpl->setVariable("BTN_NAME", "uploadTst");
00523                 $this->tpl->setVariable("TXT_UPLOAD", $this->lng->txt("upload"));
00524                 $this->tpl->setVariable("NEW_TYPE", $this->type);
00525                 $this->tpl->setVariable("TXT_IMPORT_TST", $this->lng->txt("import_tst"));
00526                 $this->tpl->setVariable("TXT_SELECT_MODE", $this->lng->txt("select_mode"));
00527                 $this->tpl->setVariable("TXT_SELECT_FILE", $this->lng->txt("select_file"));
00528 
00529         }
00530 
00534         function uploadTstObject()
00535         {
00536                 if ($_POST["qpl"] < 1)
00537                 {
00538                         sendInfo($this->lng->txt("tst_select_questionpools"));
00539                         $this->importObject();
00540                         return;
00541                 }
00542 
00543                 if ($_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK)
00544                 {
00545                         sendInfo($this->lng->txt("error_upload"));
00546                         $this->importObject();
00547                         return;
00548                 }
00549                 include_once("./assessment/classes/class.ilObjTest.php");
00550                 // create import directory
00551                 ilObjTest::_createImportDirectory();
00552 
00553                 // copy uploaded file to import directory
00554                 $file = pathinfo($_FILES["xmldoc"]["name"]);
00555                 $full_path = ilObjTest::_getImportDirectory()."/".$_FILES["xmldoc"]["name"];
00556                 ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"], $_FILES["xmldoc"]["name"], $full_path);
00557 
00558                 // unzip file
00559                 ilUtil::unzip($full_path);
00560 
00561                 // determine filenames of xml files
00562                 $subdir = basename($file["basename"],".".$file["extension"]);
00563                 $xml_file = ilObjTest::_getImportDirectory()."/".$subdir."/".$subdir.".xml";
00564                 $qti_file = ilObjTest::_getImportDirectory()."/".$subdir."/". str_replace("test", "qti", $subdir).".xml";
00565                 // start verification of QTI files
00566                 include_once "./assessment/classes/QTI/class.ilQTIParser.php";
00567                 $qtiParser = new ilQTIParser($qti_file, IL_MO_VERIFY_QTI, 0, "");
00568                 $result = $qtiParser->startParsing();
00569                 $founditems =& $qtiParser->getFoundItems();
00570                 
00571                 if (count($founditems) == 0)
00572                 {
00573                         // nothing found
00574 
00575                         // delete import directory
00576                         ilUtil::delDir(ilObjTest::_getImportDirectory());
00577 
00578                         sendInfo($this->lng->txt("tst_import_no_items"));
00579                         $this->importObject();
00580                         return;
00581                 }
00582                 
00583                 $complete = 0;
00584                 $incomplete = 0;
00585                 foreach ($founditems as $item)
00586                 {
00587                         if (strlen($item["type"]))
00588                         {
00589                                 $complete++;
00590                         }
00591                         else
00592                         {
00593                                 $incomplete++;
00594                         }
00595                 }
00596                 
00597                 if ($complete == 0)
00598                 {
00599                         // delete import directory
00600                         ilUtil::delDir(ilObjTest::_getImportDirectory());
00601 
00602                         sendInfo($this->lng->txt("qpl_import_non_ilias_files"));
00603                         $this->importObject();
00604                         return;
00605                 }
00606                 
00607                 $_SESSION["tst_import_xml_file"] = $xml_file;
00608                 $_SESSION["tst_import_qti_file"] = $qti_file;
00609                 $_SESSION["tst_import_subdir"] = $subdir;
00610                 // display of found questions
00611                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.tst_import_verification.html");
00612                 $row_class = array("tblrow1", "tblrow2");
00613                 $counter = 0;
00614                 foreach ($founditems as $item)
00615                 {
00616                         $this->tpl->setCurrentBlock("verification_row");
00617                         $this->tpl->setVariable("ROW_CLASS", $row_class[$counter++ % 2]);
00618                         $this->tpl->setVariable("QUESTION_TITLE", $item["title"]);
00619                         $this->tpl->setVariable("QUESTION_IDENT", $item["ident"]);
00620                         include_once "./assessment/classes/QTI/class.ilQTIItem.php";
00621                         switch ($item["type"])
00622                         {
00623                                 case "MULTIPLE CHOICE QUESTION":
00624                                 case QT_MULTIPLE_CHOICE_MR:
00625                                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("qt_multiple_choice"));
00626                                         break;
00627                                 case "SINGLE CHOICE QUESTION":
00628                                 case QT_MULTIPLE_CHOICE_SR:
00629                                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assSingleChoice"));
00630                                         break;
00631                                 case "NUMERIC QUESTION":
00632                                 case QT_NUMERIC:
00633                                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assNumeric"));
00634                                         break;
00635                                 case "TEXTSUBSET QUESTION":
00636                                 case QT_TEXTSUBSET:
00637                                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assTextSubset"));
00638                                         break;
00639                                 case "CLOZE QUESTION":
00640                                 case QT_CLOZE:
00641                                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assClozeTest"));
00642                                         break;
00643                                 case "IMAGE MAP QUESTION":
00644                                 case QT_IMAGEMAP:
00645                                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assImagemapQuestion"));
00646                                         break;
00647                                 case "JAVA APPLET QUESTION":
00648                                 case QT_JAVAAPPLET:
00649                                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assJavaApplet"));
00650                                         break;
00651                                 case "MATCHING QUESTION":
00652                                 case QT_MATCHING:
00653                                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assMatchingQuestion"));
00654                                         break;
00655                                 case "ORDERING QUESTION":
00656                                 case QT_ORDERING:
00657                                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assOrderingQuestion"));
00658                                         break;
00659                                 case "TEXT QUESTION":
00660                                 case QT_TEXT:
00661                                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assTextQuestion"));
00662                                         break;
00663                         }
00664                         $this->tpl->parseCurrentBlock();
00665                 }
00666                 $this->tpl->setCurrentBlock("adm_content");
00667                 $this->tpl->setVariable("TEXT_TYPE", $this->lng->txt("question_type"));
00668                 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("question_title"));
00669                 $this->tpl->setVariable("FOUND_QUESTIONS_INTRODUCTION", $this->lng->txt("tst_import_verify_found_questions"));
00670                 $this->tpl->setVariable("VERIFICATION_HEADING", $this->lng->txt("import_tst"));
00671                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00672                 $this->tpl->setVariable("ARROW", ilUtil::getImagePath("arrow_downright.gif"));
00673                 $this->tpl->setVariable("QUESTIONPOOL_ID", $_POST["qpl"]);
00674                 $this->tpl->setVariable("VALUE_IMPORT", $this->lng->txt("import"));
00675                 $this->tpl->setVariable("VALUE_CANCEL", $this->lng->txt("cancel"));
00676                 $this->tpl->parseCurrentBlock();
00677         }
00678         
00682         function importVerifiedFileObject()
00683         {
00684                 include_once "./assessment/classes/class.ilObjTest.php";
00685                 // create new questionpool object
00686                 $newObj = new ilObjTest(true);
00687                 // set type of questionpool object
00688                 $newObj->setType($_GET["new_type"]);
00689                 // set title of questionpool object to "dummy"
00690                 $newObj->setTitle("dummy");
00691                 // set description of questionpool object
00692                 $newObj->setDescription("test import");
00693                 // create the questionpool class in the ILIAS database (object_data table)
00694                 $newObj->create(true);
00695                 // create a reference for the questionpool object in the ILIAS database (object_reference table)
00696                 $newObj->createReference();
00697                 // put the questionpool object in the administration tree
00698                 $newObj->putInTree($_GET["ref_id"]);
00699                 // get default permissions and set the permissions for the questionpool object
00700                 $newObj->setPermissions($_GET["ref_id"]);
00701                 // notify the questionpool object and all its parent objects that a "new" object was created
00702                 $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
00703                 // empty mark schema
00704                 $newObj->mark_schema->flush();
00705 
00706                 // start parsing of QTI files
00707                 include_once "./assessment/classes/QTI/class.ilQTIParser.php";
00708                 $qtiParser = new ilQTIParser($_SESSION["tst_import_qti_file"], IL_MO_PARSE_QTI, $_POST["qpl_id"], $_POST["ident"]);
00709                 $qtiParser->setTestObject($newObj);
00710                 $result = $qtiParser->startParsing();
00711                 $newObj->saveToDb();
00712 
00713 
00714                 
00715                 // import page data
00716                 include_once ("content/classes/class.ilContObjParser.php");
00717                 $contParser = new ilContObjParser($newObj, $_SESSION["tst_import_xml_file"], $_SESSION["tst_import_subdir"]);
00718                 $contParser->setQuestionMapping($qtiParser->getImportMapping());
00719                 $contParser->startParsing();
00720 
00721                 // delete import directory
00722                 ilUtil::delDir(ilObjTest::_getImportDirectory());
00723                 sendInfo($this->lng->txt("object_imported"),true);
00724                 ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
00725                                 "&baseClass=ilObjTestGUI");
00726         }
00727         
00728         function cancelImportObject()
00729         {
00730                 $this->ctrl->redirect($this, "cancel");
00731 //              $this->backToRepositoryObject();
00732         }
00733         
00734         
00741         function uploadObject($redirect = true)
00742         {
00743                 $this->uploadTstObject();
00744         }
00745 
00755         function confirmChangeProperties($direction = 0)
00756         {
00757                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_properties_save_confirmation.html", true);
00758                 $information = "";
00759                 switch ($direction)
00760                 {
00761                         case 0:
00762                                 $information = $this->lng->txt("change_properties_from_random_to_standard");
00763                                 break;
00764                         default:
00765                                 $information = $this->lng->txt("change_properties_from_standard_to_random");
00766                                 break;
00767                 }
00768                 foreach ($_POST as $key => $value)
00769                 {
00770                         if (strcmp($key, "cmd") != 0)
00771                         {
00772                                 if (is_array($value))
00773                                 {
00774                                         foreach ($value as $k => $v)
00775                                         {
00776                                                 $this->tpl->setCurrentBlock("hidden_variable");
00777                                                 $this->tpl->setVariable("HIDDEN_KEY", $key . "[" . $k . "]");
00778                                                 $this->tpl->setVariable("HIDDEN_VALUE", $v);
00779                                                 $this->tpl->parseCurrentBlock();
00780                                         }
00781                                 }
00782                                 else
00783                                 {
00784                                         $this->tpl->setCurrentBlock("hidden_variable");
00785                                         $this->tpl->setVariable("HIDDEN_KEY", $key);
00786                                         $this->tpl->setVariable("HIDDEN_VALUE", $value);
00787                                         $this->tpl->parseCurrentBlock();
00788                                 }
00789                         }
00790                 }
00791                 $this->tpl->setCurrentBlock("hidden_variable");
00792                 $this->tpl->setVariable("HIDDEN_KEY", "tst_properties_confirmation");
00793                 $this->tpl->setVariable("HIDDEN_VALUE", "1");
00794                 $this->tpl->parseCurrentBlock();
00795                 $this->tpl->setCurrentBlock("adm_content");
00796                 $this->tpl->setVariable("TXT_CONFIRMATION", $this->lng->txt("confirmation"));
00797                 $this->tpl->setVariable("TXT_INFORMATION", $information);
00798                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00799                 $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
00800                 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
00801                 $this->tpl->parseCurrentBlock();
00802         }
00803         
00811         function savePropertiesObject()
00812         {
00813                 if (!array_key_exists("tst_properties_confirmation", $_POST))
00814                 {
00815                         if (($this->object->isRandomTest()) && (count($this->object->getRandomQuestionpools()) > 0))
00816                         {
00817                                 if (($_POST["chb_random"] != 1) && (($_POST["sel_test_types"] == TYPE_ONLINE_TEST) || ($_POST["sel_test_types"] == TYPE_ASSESSMENT) ||  ($_POST["sel_test_types"] == TYPE_SELF_ASSESSMENT)))
00818                                 {
00819                                         // user tries to change from a random test with existing random question pools to a non random test
00820                                         $this->confirmChangeProperties(0);
00821                                         return;
00822                                 }
00823                         }
00824                         if ((!$this->object->isRandomTest()) && (count($this->object->questions) > 0))
00825                         {
00826                                 if (($_POST["sel_test_types"] == TYPE_VARYING_RANDOMTEST) || (strlen($_POST["chb_random"]) > 0))
00827                                 {
00828                                         // user tries to change from a non random test with existing questions to a random test
00829                                         $this->confirmChangeProperties(1);
00830                                         return;
00831                                 }
00832                         }
00833                 }
00834                 
00835                 $total = $this->object->evalTotalPersons();
00836                 $deleteuserdata = false;
00837                 $randomtest_switch = false;
00838                 // Check the values the user entered in the form
00839                 if (!$total)
00840                 {
00841                         $data["count_system"] = $_POST["count_system"];
00842                         $data["mc_scoring"] = $_POST["mc_scoring"];
00843                         $data["score_cutting"] = $_POST["score_cutting"];
00844                         $data["pass_scoring"] = $_POST["pass_scoring"];
00845                         $data["sel_test_types"] = ilUtil::stripSlashes($_POST["sel_test_types"]);
00846                         if (!strlen($_POST["chb_random"]))
00847                         {
00848                                 $data["random_test"] = 0;
00849                         }
00850                         else
00851                         {
00852                                 $data["random_test"] = ilUtil::stripSlashes($_POST["chb_random"]);
00853                         }
00854                         if ($data["sel_test_types"] == TYPE_VARYING_RANDOMTEST)
00855                         {
00856                                 $data["random_test"] = "1";
00857                         }
00858                 }
00859                 else
00860                 {
00861                         $data["sel_test_types"] = $this->object->getTestType();
00862                         $data["random_test"] = $this->object->random_test;
00863                         $data["count_system"] = $this->object->getCountSystem();
00864                         $data["mc_scoring"] = $this->object->getMCScoring();
00865                         $data["score_cutting"] = $this->object->getScoreCutting();
00866                         $data["pass_scoring"] = $this->object->getPassScoring();
00867                 }
00868                 if ($data["sel_test_types"] != $this->object->getTestType())
00869                 {
00870                         $deleteuserdata = true;
00871                 }
00872                 if ($data["random_test"] != $this->object->random_test)
00873                 {
00874                         $randomtest_switch = true;
00875                 }
00876                 $data["title"] = ilUtil::stripSlashes($_POST["title"]);
00877                 $data["description"] = ilUtil::stripSlashes($_POST["description"]);
00878                 $data["author"] = ilUtil::stripSlashes($_POST["author"]);
00879                 $data["password"] = $_POST["password"];
00880                 $data["allowedUsers"] = $_POST["allowedUsers"];
00881                 $data["allowedUsersTimeGap"] = $_POST["allowedUsersTimeGap"];
00882                 include_once "./classes/class.ilObjAdvancedEditing.php";
00883                 $introduction = ilUtil::stripSlashes($_POST["introduction"], false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment"));
00884                 $data["introduction"] = $introduction;
00885                 $data["sequence_settings"] = ilUtil::stripSlashes($_POST["sequence_settings"]);
00886                 $data["shuffle_questions"] = 0;
00887                 if (!$this->object->isRandomTest())
00888                 {
00889                         if ($_POST["chb_shuffle_questions"])
00890                         {
00891                                 $data["shuffle_questions"] = $_POST["chb_shuffle_questions"];
00892                         }
00893                 }
00894                 else
00895                 {
00896                         $data["shuffle_questions"] = 1;
00897                 }
00898                 $data["show_solution_details"] = 1;
00899                 if (!$this->object->isOnlineTest())
00900                 {
00901                         if ($_POST["chb_show_solution_details"] != 1)
00902                         {
00903                                 $data["show_solution_details"] = 0;
00904                         }
00905                 }
00906                 else
00907                 {
00908                         $data["show_solution_details"] = 0;
00909                 }
00910                 $data["show_summary"] = 0;
00911                 if (!$this->object->isOnlineTest())
00912                 {
00913                         if ($_POST["chb_show_summary"] == 1)
00914                         {
00915                                 $data["show_summary"] = 1;
00916                         }
00917                 }
00918                 else
00919                 {
00920                         $data["show_summary"] = 1;
00921                 }
00922                 $data["show_solution_printview"] = 0;
00923                 if (!$this->object->isOnlineTest())
00924                 {
00925                         if ($_POST["chb_show_solution_printview"] == 1)
00926                         {
00927                                 $data["show_solution_printview"] = 1;
00928                         }
00929                 }
00930                 else
00931                 {
00932                         $data["show_solution_printview"] = 1;
00933                 }
00934                 if ($this->object->getTestType() == TYPE_ONLINE_TEST)
00935                 {
00936                         $data["score_reporting"] = REPORT_AFTER_TEST;
00937                 }
00938                 else
00939                 {
00940                         $data["score_reporting"] = ilUtil::stripSlashes($_POST["score_reporting"]);
00941                 }
00942                 if ($this->object->getTestType() != TYPE_SELF_ASSESSMENT)
00943                 {
00944                         $data["instant_verification"] = 0;
00945                 }
00946                 else
00947                 {
00948                         $data["instant_verification"] = ilUtil::stripSlashes($_POST["chb_instant_verification"]);
00949                 }
00950                 $data["nr_of_tries"] = ilUtil::stripSlashes($_POST["nr_of_tries"]);
00951                 $data["processing_time"] = ilUtil::stripSlashes($_POST["processing_time"]);
00952                 if (!$_POST["chb_starting_time"])
00953                 {
00954                         $data["starting_time"] = "";
00955                 }
00956                 else
00957                 {
00958                         $data["starting_time"] = sprintf("%04d%02d%02d%02d%02d%02d",
00959                                 $_POST["starting_date"]["y"],
00960                                 $_POST["starting_date"]["m"],
00961                                 $_POST["starting_date"]["d"],
00962                                 $_POST["starting_time"]["h"],
00963                                 $_POST["starting_time"]["m"],
00964                                 0
00965                         );
00966                 }
00967                 if (!$_POST["chb_ending_time"])
00968                 {
00969                         $data["ending_time"] = "";
00970                 }
00971                 else
00972                 {
00973                         $data["ending_time"] = sprintf("%04d%02d%02d%02d%02d%02d",
00974                                 $_POST["ending_date"]["y"],
00975                                 $_POST["ending_date"]["m"],
00976                                 $_POST["ending_date"]["d"],
00977                                 $_POST["ending_time"]["h"],
00978                                 $_POST["ending_time"]["m"],
00979                                 0
00980                         );
00981                 }
00982 
00983                 if ($_POST["chb_processing_time"])
00984                 {
00985                         $data["enable_processing_time"] = "1";
00986                 }
00987                 else
00988                 {
00989                         $data["enable_processing_time"] = "0";
00990                 }
00991                 if ($_POST["chb_hide_previous_results"])
00992                 {
00993                         $data["hide_previous_results"] = "1";
00994                 }
00995                 else
00996                 {
00997                         $data["hide_previous_results"] = "0";
00998                 }
00999                 if ($_POST["chb_hide_title_points"])
01000                 {
01001                         $data["hide_title_points"] = "1";
01002                 }
01003                 else
01004                 {
01005                         $data["hide_title_points"] = "0";
01006                 }
01007 
01008                 if ($data["enable_processing_time"])
01009                 {
01010                         $data["processing_time"] = sprintf("%02d:%02d:%02d",
01011                                 $_POST["processing_time"]["h"],
01012                                 $_POST["processing_time"]["m"],
01013                                 $_POST["processing_time"]["s"]
01014                         );
01015                 }
01016                 else
01017                 {
01018                         $proc_time = $this->object->getEstimatedWorkingTime();
01019                         $data["processing_time"] = sprintf("%02d:%02d:%02d",
01020                                 $proc_time["h"],
01021                                 $proc_time["m"],
01022                                 $proc_time["s"]
01023                         );
01024                 }
01025 
01026                 if (!$_POST["chb_reporting_date"] && !$this->object->isOnlineTest())
01027                 {
01028                         $data["reporting_date"] = "";
01029                 }
01030                 else
01031                 {
01032                         $data["reporting_date"] = sprintf("%04d%02d%02d%02d%02d%02d",
01033                                 $_POST["reporting_date"]["y"],
01034                                 $_POST["reporting_date"]["m"],
01035                                 $_POST["reporting_date"]["d"],
01036                                 $_POST["reporting_time"]["h"],
01037                                 $_POST["reporting_time"]["m"],
01038                                 0
01039                         );
01040                 }
01041                 if ($data["nr_of_tries"] == 1)
01042                 {
01043                         $data["pass_scoring"] = SCORE_LAST_PASS;
01044                 }
01045                 $this->object->setTestType($data["sel_test_types"]);
01046                 $this->object->setTitle($data["title"]);
01047                 $this->object->setDescription($data["description"]);
01048                 $this->object->setAuthor($data["author"]);
01049                 $this->object->setIntroduction($data["introduction"]);
01050                 $this->object->setSequenceSettings($data["sequence_settings"]);
01051                 $this->object->setCountSystem($data["count_system"]);
01052                 $this->object->setMCScoring($data["mc_scoring"]);
01053                 $this->object->setPassword($data["password"]);
01054                 $this->object->setAllowedUsers($data["allowedUsers"]);
01055                 $this->object->setAllowedUsersTimeGap($data["allowedUsersTimeGap"]);
01056                 $this->object->setScoreCutting($data["score_cutting"]);
01057                 $this->object->setPassScoring($data["pass_scoring"]);
01058                 if ($this->object->getTestType() == TYPE_ONLINE_TEST )
01059                 {
01060                         $this->object->setScoreReporting(REPORT_AFTER_TEST);
01061                 }
01062                 else
01063                 {
01064                         $this->object->setScoreReporting($data["score_reporting"]);
01065                 }
01066                 if ($this->object->getTestType() != TYPE_SELF_ASSESSMENT )
01067                 {
01068                         $this->object->setInstantVerification(0);
01069                 }
01070                 else
01071                 {
01072                         $this->object->setInstantVerification($data["instant_verification"]);
01073                 }
01074                 $this->object->setReportingDate($data["reporting_date"]);
01075                 $this->object->setNrOfTries($data["nr_of_tries"]);
01076                 $this->object->setStartingTime($data["starting_time"]);
01077                 $this->object->setEndingTime($data["ending_time"]);
01078                 $this->object->setProcessingTime($data["processing_time"]);
01079                 $this->object->setRandomTest($data["random_test"]);
01080                 $this->object->setEnableProcessingTime($data["enable_processing_time"]);
01081                 $this->object->setHidePreviousResults($data["hide_previous_results"]);
01082                 $this->object->setHideTitlePoints($data["hide_title_points"]);
01083                 if ($this->object->getTestType() == TYPE_ONLINE_TEST) 
01084                 {
01085                         $this->object->setScoreReporting(1);
01086                         $this->object->setSequenceSettings(0);
01087         $this->object->setNrOfTries(1);
01088         $this->object->setRandomTest(0);
01089                 }
01090                 
01091                 if ($this->object->getTestType() == TYPE_VARYING_RANDOMTEST)
01092                 {
01093                         $this->object->setHidePreviousResults(1);
01094                         $this->object->setRandomTest(1);
01095                 }
01096                 else
01097                 {
01098                         $this->object->setPassScoring(SCORE_LAST_PASS);
01099                 }
01100                 if ($data["shuffle_questions"])
01101                 {
01102                         $this->object->setShuffleQuestions(TRUE);
01103                 }
01104                 else
01105                 {
01106                         $this->object->setShuffleQuestions(FALSE);
01107                 }
01108                 if ($data["show_solution_details"])
01109                 {
01110                         $this->object->setShowSolutionDetails(TRUE);
01111                 }
01112                 else
01113                 {
01114                         $this->object->setShowSolutionDetails(FALSE);
01115                 }
01116                 if ($data["show_summary"])
01117                 {
01118                         $this->object->setShowSummary(TRUE);
01119                 }
01120                 else
01121                 {
01122                         $this->object->setShowSummary(FALSE);
01123                 }
01124                 if ($data["show_solution_printview"])
01125                 {
01126                         $this->object->setShowSolutionPrintview(TRUE);
01127                 }
01128                 else
01129                 {
01130                         $this->object->setShowSolutionPrintview(FALSE);
01131                 }
01132                 $this->update = $this->object->update();
01133                 $this->object->saveToDb(true);
01134 
01135                 if ($deleteuserdata)
01136                 {
01137                         $this->object->removeAllTestEditings();
01138                 }
01139                 sendInfo($this->lng->txt("msg_obj_modified"));
01140                 if ($randomtest_switch)
01141                 {
01142                         if ($this->object->isRandomTest())
01143                         {
01144                                 $this->object->removeNonRandomTestData();
01145                         }
01146                         else
01147                         {
01148                                 $this->object->removeRandomTestData();
01149                         }
01150                 }
01151                 $this->ctrl->redirect($this, "properties");
01152         }
01153         
01161         function cancelPropertiesObject()
01162         {
01163                 sendInfo($this->lng->txt("msg_cancel"), true);
01164                 $this->backToRepositoryObject();
01165         }
01166         
01174         function propertiesObject()
01175         {
01176                 global $ilAccess;
01177                 if (!$ilAccess->checkAccess("write", "", $this->ref_id)) 
01178                 {
01179                         // allow only write access
01180                         sendInfo($this->lng->txt("cannot_edit_test"), true);
01181                         $this->ctrl->redirect($this, "infoScreen");
01182                 }
01183 
01184                 include_once "./Services/RTE/classes/class.ilRTE.php";
01185                 $rtestring = ilRTE::_getRTEClassname();
01186                 include_once "./Services/RTE/classes/class.$rtestring.php";
01187                 $rte = new $rtestring();
01188                 include_once "./classes/class.ilObject.php";
01189                 $obj_id = ilObject::_lookupObjectId($_GET["ref_id"]);
01190                 $obj_type = ilObject::_lookupType($_GET["ref_id"], TRUE);
01191                 $rte->addRTESupport($obj_id, $obj_type, "assessment");
01192 
01193                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_properties.html", true);
01194                 $total = $this->object->evalTotalPersons();
01195                 if ($this->object->getTestType() == TYPE_ONLINE_TEST  || $data["sel_test_types"] == TYPE_ONLINE_TEST)
01196                 {
01197                 // fixed settings
01198                         $this->object->setScoreReporting(1);
01199                         $this->object->setSequenceSettings(0);
01200                         $this->object->setNrOfTries(1);
01201                         $this->object->setRandomTest(0);
01202     }
01203                 if ($total == 0)
01204                 {
01205                         $this->tpl->setCurrentBlock("change_button");
01206                         $this->tpl->setVariable("BTN_CHANGE", $this->lng->txt("change"));
01207                         $this->tpl->parseCurrentBlock();
01208                 }
01209                 if (
01210                         ($data["sel_test_types"] == TYPE_ONLINE_TEST) || 
01211                         ($data["sel_test_types"] == TYPE_ASSESSMENT) || 
01212                         ($data["sel_test_types"] == TYPE_VARYING_RANDOMTEST) || 
01213                         (($this->object->getTestType() == TYPE_ASSESSMENT || $this->object->getTestType() == TYPE_VARYING_RANDOMTEST || $this->object->getTestType() == TYPE_ONLINE_TEST) && strlen($data["sel_test_types"]) == 0)
01214                 ) 
01215                 {
01216                         $this->lng->loadLanguageModule("jscalendar");
01217                         $this->tpl->addBlockFile("CALENDAR_LANG_JAVASCRIPT", "calendar_javascript", "tpl.calendar.html");
01218                         $this->tpl->setCurrentBlock("calendar_javascript");
01219                         $this->tpl->setVariable("FULL_SUNDAY", $this->lng->txt("l_su"));
01220                         $this->tpl->setVariable("FULL_MONDAY", $this->lng->txt("l_mo"));
01221                         $this->tpl->setVariable("FULL_TUESDAY", $this->lng->txt("l_tu"));
01222                         $this->tpl->setVariable("FULL_WEDNESDAY", $this->lng->txt("l_we"));
01223                         $this->tpl->setVariable("FULL_THURSDAY", $this->lng->txt("l_th"));
01224                         $this->tpl->setVariable("FULL_FRIDAY", $this->lng->txt("l_fr"));
01225                         $this->tpl->setVariable("FULL_SATURDAY", $this->lng->txt("l_sa"));
01226                         $this->tpl->setVariable("SHORT_SUNDAY", $this->lng->txt("s_su"));
01227                         $this->tpl->setVariable("SHORT_MONDAY", $this->lng->txt("s_mo"));
01228                         $this->tpl->setVariable("SHORT_TUESDAY", $this->lng->txt("s_tu"));
01229                         $this->tpl->setVariable("SHORT_WEDNESDAY", $this->lng->txt("s_we"));
01230                         $this->tpl->setVariable("SHORT_THURSDAY", $this->lng->txt("s_th"));
01231                         $this->tpl->setVariable("SHORT_FRIDAY", $this->lng->txt("s_fr"));
01232                         $this->tpl->setVariable("SHORT_SATURDAY", $this->lng->txt("s_sa"));
01233                         $this->tpl->setVariable("FULL_JANUARY", $this->lng->txt("l_01"));
01234                         $this->tpl->setVariable("FULL_FEBRUARY", $this->lng->txt("l_02"));
01235                         $this->tpl->setVariable("FULL_MARCH", $this->lng->txt("l_03"));
01236                         $this->tpl->setVariable("FULL_APRIL", $this->lng->txt("l_04"));
01237                         $this->tpl->setVariable("FULL_MAY", $this->lng->txt("l_05"));
01238                         $this->tpl->setVariable("FULL_JUNE", $this->lng->txt("l_06"));
01239                         $this->tpl->setVariable("FULL_JULY", $this->lng->txt("l_07"));
01240                         $this->tpl->setVariable("FULL_AUGUST", $this->lng->txt("l_08"));
01241                         $this->tpl->setVariable("FULL_SEPTEMBER", $this->lng->txt("l_09"));
01242                         $this->tpl->setVariable("FULL_OCTOBER", $this->lng->txt("l_10"));
01243                         $this->tpl->setVariable("FULL_NOVEMBER", $this->lng->txt("l_11"));
01244                         $this->tpl->setVariable("FULL_DECEMBER", $this->lng->txt("l_12"));
01245                         $this->tpl->setVariable("SHORT_JANUARY", $this->lng->txt("s_01"));
01246                         $this->tpl->setVariable("SHORT_FEBRUARY", $this->lng->txt("s_02"));
01247                         $this->tpl->setVariable("SHORT_MARCH", $this->lng->txt("s_03"));
01248                         $this->tpl->setVariable("SHORT_APRIL", $this->lng->txt("s_04"));
01249                         $this->tpl->setVariable("SHORT_MAY", $this->lng->txt("s_05"));
01250                         $this->tpl->setVariable("SHORT_JUNE", $this->lng->txt("s_06"));
01251                         $this->tpl->setVariable("SHORT_JULY", $this->lng->txt("s_07"));
01252                         $this->tpl->setVariable("SHORT_AUGUST", $this->lng->txt("s_08"));
01253                         $this->tpl->setVariable("SHORT_SEPTEMBER", $this->lng->txt("s_09"));
01254                         $this->tpl->setVariable("SHORT_OCTOBER", $this->lng->txt("s_10"));
01255                         $this->tpl->setVariable("SHORT_NOVEMBER", $this->lng->txt("s_11"));
01256                         $this->tpl->setVariable("SHORT_DECEMBER", $this->lng->txt("s_12"));
01257                         $this->tpl->setVariable("ABOUT_CALENDAR", $this->lng->txt("about_calendar"));
01258                         $this->tpl->setVariable("ABOUT_CALENDAR_LONG", $this->lng->txt("about_calendar_long"));
01259                         $this->tpl->setVariable("ABOUT_TIME_LONG", $this->lng->txt("about_time"));
01260                         $this->tpl->setVariable("PREV_YEAR", $this->lng->txt("prev_year"));
01261                         $this->tpl->setVariable("PREV_MONTH", $this->lng->txt("prev_month"));
01262                         $this->tpl->setVariable("GO_TODAY", $this->lng->txt("go_today"));
01263                         $this->tpl->setVariable("NEXT_MONTH", $this->lng->txt("next_month"));
01264                         $this->tpl->setVariable("NEXT_YEAR", $this->lng->txt("next_year"));
01265                         $this->tpl->setVariable("SEL_DATE", $this->lng->txt("select_date"));
01266                         $this->tpl->setVariable("DRAG_TO_MOVE", $this->lng->txt("drag_to_move"));
01267                         $this->tpl->setVariable("PART_TODAY", $this->lng->txt("part_today"));
01268                         $this->tpl->setVariable("DAY_FIRST", $this->lng->txt("day_first"));
01269                         $this->tpl->setVariable("CLOSE", $this->lng->txt("close"));
01270                         $this->tpl->setVariable("TODAY", $this->lng->txt("today"));
01271                         $this->tpl->setVariable("TIME_PART", $this->lng->txt("time_part"));
01272                         $this->tpl->setVariable("DEF_DATE_FORMAT", $this->lng->txt("def_date_format"));
01273                         $this->tpl->setVariable("TT_DATE_FORMAT", $this->lng->txt("tt_date_format"));
01274                         $this->tpl->setVariable("WK", $this->lng->txt("wk"));
01275                         $this->tpl->setVariable("TIME", $this->lng->txt("time"));
01276                         $this->tpl->parseCurrentBlock();
01277                         $this->tpl->setCurrentBlock("CalendarJS");
01278                         $this->tpl->setVariable("LOCATION_JAVASCRIPT_CALENDAR", "./assessment/js/calendar/calendar.js");
01279                         $this->tpl->setVariable("LOCATION_JAVASCRIPT_CALENDAR_SETUP", "./assessment/js/calendar/calendar-setup.js");
01280                         $this->tpl->setVariable("LOCATION_JAVASCRIPT_CALENDAR_STYLESHEET", "./assessment/js/calendar/calendar.css");
01281                         $this->tpl->parseCurrentBlock();
01282                         $this->tpl->setCurrentBlock("javascript_call_calendar");
01283                         $this->tpl->setVariable("INPUT_FIELDS_STARTING_DATE", "starting_date");
01284                         $this->tpl->setVariable("INPUT_FIELDS_ENDING_DATE", "ending_date");
01285                         $this->tpl->setVariable("INPUT_FIELDS_REPORTING_DATE", "reporting_date");
01286                         $this->tpl->parseCurrentBlock();
01287                 }
01288 
01289                 $data["sel_test_types"] = $this->object->getTestType();
01290                 $data["author"] = $this->object->getAuthor();
01291                 $data["introduction"] = $this->object->getIntroduction();
01292                 $data["sequence_settings"] = $this->object->getSequenceSettings();
01293                 $data["score_reporting"] = $this->object->getScoreReporting();
01294                 $data["instant_verification"] = $this->object->getInstantVerification();
01295                 $data["reporting_date"] = $this->object->getReportingDate();
01296                 $data["nr_of_tries"] = $this->object->getNrOfTries();
01297                 $data["hide_previous_results"] = $this->object->getHidePreviousResults();
01298                 $data["hide_title_points"] = $this->object->getHideTitlePoints();
01299                 $data["enable_processing_time"] = $this->object->getEnableProcessingTime();
01300                 $data["processing_time"] = $this->object->getProcessingTime();
01301                 $data["random_test"] = $this->object->isRandomTest();
01302                 $data["count_system"] = $this->object->getCountSystem();
01303                 $data["mc_scoring"] = $this->object->getMCScoring();
01304                 $data["password"] = $this->object->getPassword();
01305                 $data["score_cutting"] = $this->object->getScoreCutting();
01306                 $data["allowedUsers"] = $this->object->getAllowedUsers();
01307                 $data["allowedUsersTimeGap"] = $this->object->getAllowedUsersTimeGap();
01308                 if ($this->object->getTestType() == TYPE_VARYING_RANDOMTEST)
01309                 {
01310                         $data["pass_scoring"] = $this->object->getPassScoring();
01311                 }
01312                 else
01313                 {
01314                         $data["pass_scoring"] = SCORE_LAST_PASS;
01315                 }
01316                 if ((int)substr($data["processing_time"], 0, 2) + (int)substr($data["processing_time"], 3, 2) + (int)substr($data["processing_time"], 6, 2) == 0)
01317                 {
01318                         $proc_time = $this->object->getEstimatedWorkingTime();
01319                         $data["processing_time"] = sprintf("%02d:%02d:%02d",
01320                                 $proc_time["h"],
01321                                 $proc_time["m"],
01322                                 $proc_time["s"]
01323                         );
01324                 }
01325                 $data["starting_time"] = $this->object->getStartingTime();
01326                 $data["ending_time"] = $this->object->getEndingTime();
01327                 $data["title"] = $this->object->getTitle();
01328                 $data["description"] = $this->object->getDescription();
01329                 
01330                 if ($data["sel_test_types"] == TYPE_ASSESSMENT || ($data["sel_test_types"] == TYPE_ONLINE_TEST) || ($data["sel_test_types"] == TYPE_VARYING_RANDOMTEST))
01331                 {
01332                         $this->tpl->setCurrentBlock("starting_time");
01333                         $this->tpl->setVariable("TEXT_STARTING_TIME", $this->lng->txt("tst_starting_time"));
01334                         if (!$data["starting_time"])
01335                         {
01336                                 $date_input = ilUtil::makeDateSelect("starting_date");
01337                                 $time_input = ilUtil::makeTimeSelect("starting_time");
01338                         }
01339                         else
01340                         {
01341                                 preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $data["starting_time"], $matches);
01342                                 $date_input = ilUtil::makeDateSelect("starting_date", $matches[1], sprintf("%d", $matches[2]), sprintf("%d", $matches[3]));
01343                                 $time_input = ilUtil::makeTimeSelect("starting_time", true, sprintf("%d", $matches[4]), sprintf("%d", $matches[5]), sprintf("%d", $matches[6]));
01344                         }
01345                         $this->tpl->setVariable("IMG_STARTING_TIME_CALENDAR", ilUtil::getImagePath("calendar.png"));
01346                         $this->tpl->setVariable("TXT_STARTING_TIME_CALENDAR", $this->lng->txt("open_calendar"));
01347                         $this->tpl->setVariable("TXT_ENABLED", $this->lng->txt("enabled"));
01348                         if ($data["starting_time"])
01349                         {
01350                                 $this->tpl->setVariable("CHECKED_STARTING_TIME", " checked=\"checked\"");
01351                         }
01352                         $this->tpl->setVariable("INPUT_STARTING_TIME", $this->lng->txt("date") . ": " . $date_input . $this->lng->txt("time") . ": " . $time_input);
01353                         $this->tpl->parseCurrentBlock();
01354 
01355                         $this->tpl->setCurrentBlock("ending_time");
01356                         $this->tpl->setVariable("TEXT_ENDING_TIME", $this->lng->txt("tst_ending_time"));
01357                         if (!$data["ending_time"])
01358                         {
01359                                 $date_input = ilUtil::makeDateSelect("ending_date");
01360                                 $time_input = ilUtil::makeTimeSelect("ending_time");
01361                         }
01362                         else
01363                         {
01364                                 preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $data["ending_time"], $matches);
01365                                 $date_input = ilUtil::makeDateSelect("ending_date", $matches[1], sprintf("%d", $matches[2]), sprintf("%d", $matches[3]));
01366                                 $time_input = ilUtil::makeTimeSelect("ending_time", true, sprintf("%d", $matches[4]), sprintf("%d", $matches[5]), sprintf("%d", $matches[6]));
01367                         }
01368                         $this->tpl->setVariable("IMG_ENDING_TIME_CALENDAR", ilUtil::getImagePath("calendar.png"));
01369                         $this->tpl->setVariable("TXT_ENDING_TIME_CALENDAR", $this->lng->txt("open_calendar"));
01370                         $this->tpl->setVariable("TXT_ENABLED", $this->lng->txt("enabled"));
01371                         if ($data["ending_time"])
01372                         {
01373                                 $this->tpl->setVariable("CHECKED_ENDING_TIME", " checked=\"checked\"");
01374                         }
01375                         $this->tpl->setVariable("INPUT_ENDING_TIME", $this->lng->txt("date") . ": " . $date_input . $this->lng->txt("time") . ": " . $time_input);
01376                         $this->tpl->parseCurrentBlock();
01377 
01378                         $this->tpl->setCurrentBlock("reporting_date");
01379                         $this->tpl->setVariable("TEXT_SCORE_DATE", $this->lng->txt("tst_score_reporting_date"));
01380                         if (!$data["reporting_date"])
01381                         {
01382                                 $date_input = ilUtil::makeDateSelect("reporting_date");
01383                                 $time_input = ilUtil::makeTimeSelect("reporting_time");
01384                         } else {
01385                                 preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $data["reporting_date"], $matches);
01386                                 $date_input = ilUtil::makeDateSelect("reporting_date", $matches[1], sprintf("%d", $matches[2]), sprintf("%d", $matches[3]));
01387                                 $time_input = ilUtil::makeTimeSelect("reporting_time", true, sprintf("%d", $matches[4]), sprintf("%d", $matches[5]), sprintf("%d", $matches[6]));
01388                         }
01389                         $this->tpl->setVariable("IMG_REPORTING_DATE_CALENDAR", ilUtil::getImagePath("calendar.png"));
01390                         $this->tpl->setVariable("TXT_REPORTING_DATE_CALENDAR", $this->lng->txt("open_calendar"));
01391                         $this->tpl->setVariable("TXT_ENABLED", $this->lng->txt("enabled"));
01392                         if ($data["reporting_date"] || ($data["sel_test_types"] == TYPE_ONLINE_TEST)) {
01393                                 $this->tpl->setVariable("CHECKED_REPORTING_DATE", " checked=\"checked\"");
01394                         }
01395                         $this->tpl->setVariable("INPUT_REPORTING_DATE", $this->lng->txt("date") . ": " . $date_input . $this->lng->txt("time") . ": " . $time_input);
01396                         if ($this->object->getTestType() == TYPE_ONLINE_TEST || $data["sel_test_types"] == TYPE_ONLINE_TEST) 
01397                         {
01398                                 $this->tpl->setVariable("DISABLE_SCORE_REPORTING_DATE_CHECKBOX", " disabled=\"disabled\"");
01399                         }
01400                         $this->tpl->parseCurrentBlock();
01401                 }
01402 
01403                 $this->tpl->setCurrentBlock("test_types");
01404                 foreach ($this->object->test_types as $key => $value) {
01405                         $this->tpl->setVariable("VALUE_TEST_TYPE", $key);
01406                         $this->tpl->setVariable("TEXT_TEST_TYPE", $this->lng->txt($value));
01407                         if ($data["sel_test_types"] == $key) {
01408                                 $this->tpl->setVariable("SELECTED_TEST_TYPE", " selected=\"selected\"");
01409                         }
01410                         $this->tpl->parseCurrentBlock();
01411                 }
01412                 $this->tpl->setCurrentBlock("adm_content");
01413                 $this->tpl->setVariable("ACTION_PROPERTIES", $this->ctrl->getFormAction($this));
01414                 if ($ilAccess->checkAccess("write", "", $this->ref_id)) 
01415                 {
01416                         $this->tpl->setVariable("SUBMIT_TYPE", $this->lng->txt("change"));
01417                 }
01418                 $this->tpl->setVariable("HEADING_GENERAL", $this->lng->txt("tst_general_properties"));
01419                 $this->tpl->setVariable("TEXT_TEST_TYPES", $this->lng->txt("tst_types"));
01420                 $this->tpl->setVariable("TEST_TYPE_COMMENT", $this->lng->txt("tst_type_comment"));
01421                 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
01422                 $this->tpl->setVariable("VALUE_TITLE", ilUtil::prepareFormOutput($data["title"]));
01423                 $this->tpl->setVariable("TEXT_AUTHOR", $this->lng->txt("author"));
01424                 $this->tpl->setVariable("VALUE_AUTHOR", ilUtil::prepareFormOutput($data["author"]));
01425                 $this->tpl->setVariable("TEXT_DESCRIPTION", $this->lng->txt("description"));
01426                 $this->tpl->setVariable("VALUE_DESCRIPTION", ilUtil::prepareFormOutput($data["description"]));
01427                 $this->tpl->setVariable("TEXT_INTRODUCTION", $this->lng->txt("tst_introduction"));
01428                 $this->tpl->setVariable("VALUE_INTRODUCTION", ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($data["introduction"])));
01429                 $this->tpl->setVariable("HEADING_SEQUENCE", $this->lng->txt("tst_sequence_properties"));
01430                 $this->tpl->setVariable("TEXT_SEQUENCE", $this->lng->txt("tst_sequence"));
01431                 $this->tpl->setVariable("SEQUENCE_FIXED", $this->lng->txt("tst_sequence_fixed"));
01432                 $this->tpl->setVariable("SEQUENCE_POSTPONE", $this->lng->txt("tst_sequence_postpone"));
01433                 if ($data["sequence_settings"] == 0) {
01434                         $this->tpl->setVariable("SELECTED_FIXED", " selected=\"selected\"");
01435                 } elseif ($data["sequence_settings"] == 1) {
01436                         $this->tpl->setVariable("SELECTED_POSTPONE", " selected=\"selected\"");
01437                 }
01438                 $this->tpl->setVariable("TEXT_SHUFFLE_QUESTIONS", $this->lng->txt("tst_shuffle_questions"));
01439                 $this->tpl->setVariable("TEXT_SHUFFLE_QUESTIONS_DESCRIPTION", $this->lng->txt("tst_shuffle_questions_description"));
01440                 if ($this->object->isRandomTest())
01441                 {
01442                         $this->tpl->setVariable("CHECKED_SHUFFLE_QUESTIONS", " checked=\"checked\"");
01443                         $this->tpl->setVariable("DISABLE_SHUFFLE_QUESTIONS", " disabled=\"disabled\"");
01444                 }
01445                 else 
01446                 {
01447                         if ($this->object->getShuffleQuestions())
01448                         {
01449                                 $this->tpl->setVariable("CHECKED_SHUFFLE_QUESTIONS", " checked=\"checked\"");
01450                         }
01451                 }
01452                 $this->tpl->setVariable("HEADING_SCORE", $this->lng->txt("tst_score_reporting"));
01453                 if ($this->object->getTestType() != TYPE_SELF_ASSESSMENT)
01454                 {
01455                         $this->tpl->setVariable("DISABLED_INSTANT_VERIFICATION", " disabled=\"disabled\"");
01456                 }
01457                 $this->tpl->setVariable("TEXT_VERIFICATION", $this->lng->txt("tst_instant_verification"));
01458                 $this->tpl->setVariable("TEXT_INSTANT_VERIFICATION", $this->lng->txt("tst_allow_instant_verification"));
01459                 if ($this->object->getInstantVerification() == 1)
01460                 {
01461                         $this->tpl->setVariable("CHECKED_INSTANT_VERIFICATION", " checked=\"checked\"");
01462                 }
01463                 $this->tpl->setVariable("TEXT_SCORE_TYPE", $this->lng->txt("tst_score_type"));
01464                 $this->tpl->setVariable("REPORT_AFTER_TEST", $this->lng->txt("tst_report_after_test"));
01465                 $this->tpl->setVariable("REPORT_AFTER_FIRST_QUESTION", $this->lng->txt("tst_report_after_first_question"));
01466                 if ($this->object->getTestType() == TYPE_ONLINE_TEST || $data["sel_test_types"] == TYPE_ONLINE_TEST) 
01467                 {
01468                         $this->tpl->setVariable("SELECTED_TEST", " selected=\"selected\"");
01469                         $this->tpl->setVariable("DISABLE_SCORE_REPORTING", " disabled=\"disabled\"");
01470                         $this->tpl->setVariable("DISABLE_SEQUENCE", " disabled=\"disabled\"");
01471                         $this->tpl->setVariable("DISABLE_NR_OF_TRIES", " disabled=\"disabled\"");
01472                         $this->tpl->setVariable("ENABLED_RANDOM_TEST", " disabled=\"disabled\"");
01473                 }
01474                 else 
01475                 {
01476                         if ($data["score_reporting"] == 1) 
01477                         {
01478                                 $this->tpl->setVariable("SELECTED_TEST", " selected=\"selected\"");
01479                         }
01480                         elseif ($data["score_reporting"] == 2)
01481                         {
01482                                 $this->tpl->setVariable("SELECTED_FIRST_QUESTION", " selected=\"selected\"");
01483                         }
01484                 }
01485 
01486                 $this->tpl->setVariable("TEXT_SHOW_SOLUTION_DETAILS", $this->lng->txt("tst_show_solution_details"));
01487                 $this->tpl->setVariable("TEXT_SHOW_SOLUTION_DETAILS_DESCRIPTION", $this->lng->txt("tst_show_solution_details_description"));
01488                 if ($this->object->isOnlineTest())
01489                 {
01490                         $this->tpl->setVariable("DISABLE_SHOW_SOLUTION_DETAILS", " disabled=\"disabled\"");
01491                 }
01492                 else
01493                 {
01494                         if ($this->object->getShowSolutionDetails())
01495                         {
01496                                 $this->tpl->setVariable("CHECKED_SHOW_SOLUTION_DETAILS", " checked=\"checked\"");
01497                         }
01498                 }
01499 
01500                 $this->tpl->setVariable("TEXT_SHOW_SUMMARY", $this->lng->txt("tst_show_summary"));
01501                 $this->tpl->setVariable("TEXT_SHOW_SUMMARY_DESCRIPTION", $this->lng->txt("tst_show_summary_description"));
01502                 if ($this->object->isOnlineTest())
01503                 {
01504                         $this->tpl->setVariable("CHECKED_SHOW_SUMMARY", " checked=\"checked\"");
01505                         $this->tpl->setVariable("DISABLE_SHOW_SUMMARY", " disabled=\"disabled\"");
01506                 }
01507                 else
01508                 {
01509                         if ($this->object->getShowSummary())
01510                         {
01511                                 $this->tpl->setVariable("CHECKED_SHOW_SUMMARY", " checked=\"checked\"");
01512                         }
01513                 }
01514 
01515                 $this->tpl->setVariable("TEXT_SHOW_SOLUTION_PRINTVIEW", $this->lng->txt("tst_show_solution_printview"));
01516                 $this->tpl->setVariable("TEXT_SHOW_SOLUTION_PRINTVIEW_DESCRIPTION", $this->lng->txt("tst_show_solution_printview_description"));
01517                 if ($this->object->isOnlineTest())
01518                 {
01519                         $this->tpl->setVariable("CHECKED_SHOW_SOLUTION_PRINTVIEW", " checked=\"checked\"");
01520                         $this->tpl->setVariable("DISABLE_SHOW_SOLUTION_PRINTVIEW", " disabled=\"disabled\"");
01521                 }
01522                 else
01523                 {
01524                         if ($this->object->getShowSolutionPrintview())
01525                         {
01526                                 $this->tpl->setVariable("CHECKED_SHOW_SOLUTION_PRINTVIEW", " checked=\"checked\"");
01527                         }
01528                 }
01529 
01530                 $this->tpl->setVariable("TEXT_HIDE_PREVIOUS_RESULTS", $this->lng->txt("tst_hide_previous_results"));
01531                 $this->tpl->setVariable("TEXT_HIDE_PREVIOUS_RESULTS_DESCRIPTION", $this->lng->txt("tst_hide_previous_results_description"));
01532                 $this->tpl->setVariable("TEXT_HIDE_TITLE_POINTS", $this->lng->txt("tst_hide_title_points"));
01533                 $this->tpl->setVariable("TEXT_HIDE_TITLE_POINTS_DESCRIPTION", $this->lng->txt("tst_hide_title_points_description"));
01534                 if ($data["hide_title_points"] == 1)
01535                 {
01536                         $this->tpl->setVariable("CHECKED_HIDE_TITLE_POINTS", " checked=\"checked\"");
01537                 }
01538                 if ($data["sel_test_types"] == TYPE_VARYING_RANDOMTEST)
01539                 {
01540                         $data["hide_previous_results"] = 1;
01541                 }
01542                 if ($data["sel_test_types"] == TYPE_ONLINE_TEST)
01543                 {
01544                         $data["hide_previous_results"] = 0;
01545                 }
01546                 if ($data["hide_previous_results"] == 1)
01547                 {
01548                         $this->tpl->setVariable("CHECKED_HIDE_PREVIOUS_RESULTS",  " checked=\"checked\"");
01549                 }
01550                 if (($data["sel_test_types"] == TYPE_VARYING_RANDOMTEST) || ($data["sel_test_types"] == TYPE_ONLINE_TEST))
01551                 {
01552                         $this->tpl->setVariable("DISABLE_HIDE_PREVIOUS_RESULTS", " disabled=\"disabled\"");
01553                 }
01554                 $this->tpl->setVariable("HEADING_SESSION", $this->lng->txt("tst_session_settings"));
01555                 $this->tpl->setVariable("TEXT_NR_OF_TRIES", $this->lng->txt("tst_nr_of_tries"));
01556                 $this->tpl->setVariable("VALUE_NR_OF_TRIES", $data["nr_of_tries"]);
01557                 $this->tpl->setVariable("COMMENT_NR_OF_TRIES", $this->lng->txt("0_unlimited"));
01558                 $this->tpl->setVariable("TEXT_PROCESSING_TIME", $this->lng->txt("tst_processing_time"));
01559                 $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));
01560                 $this->tpl->setVariable("MAX_PROCESSING_TIME", $time_input . " (hh:mm:ss)");
01561                 if ($data["enable_processing_time"]) {
01562                         $this->tpl->setVariable("CHECKED_PROCESSING_TIME", " checked=\"checked\"");
01563                 }
01564                 $this->tpl->setVariable("TEXT_RANDOM_TEST", $this->lng->txt("tst_random_test"));
01565                 $this->tpl->setVariable("TEXT_RANDOM_TEST_DESCRIPTION", $this->lng->txt("tst_random_test_description"));
01566                 if ($data["random_test"]) 
01567                 {
01568                         $this->tpl->setVariable("CHECKED_RANDOM_TEST", " checked=\"checked\"");
01569                 }
01570                 if ($data["sel_test_types"] == TYPE_VARYING_RANDOMTEST)
01571                 {
01572                         $this->tpl->setVariable("CHECKED_RANDOM_TEST", " checked=\"checked\"");
01573                         $this->tpl->setVariable("ENABLED_RANDOM_TEST", " disabled=\"disabled\"");
01574                 }
01575 
01576                 $this->tpl->setVariable("HEADING_SCORING", $this->lng->txt("tst_heading_scoring"));
01577                 $this->tpl->setVariable("TEXT_COUNT_SYSTEM", $this->lng->txt("tst_text_count_system"));
01578                 $this->tpl->setVariable("COUNT_PARTIAL_SOLUTIONS", $this->lng->txt("tst_count_partial_solutions"));
01579                 if ($data["count_system"] == COUNT_PARTIAL_SOLUTIONS)
01580                 {
01581                         $this->tpl->setVariable("SELECTED_PARTIAL", " selected=\"selected\"");
01582                 }
01583                 $this->tpl->setVariable("COUNT_CORRECT_SOLUTIONS", $this->lng->txt("tst_count_correct_solutions"));
01584                 if ($data["count_system"] == COUNT_CORRECT_SOLUTIONS)
01585                 {
01586                         $this->tpl->setVariable("SELECTED_CORRECT", " selected=\"selected\"");
01587                 }
01588                 $this->tpl->setVariable("TEXT_SCORE_MCMR", $this->lng->txt("tst_score_mcmr_questions"));
01589                 $this->tpl->setVariable("ZERO_POINTS_WHEN_UNANSWERED", $this->lng->txt("tst_score_mcmr_zero_points_when_unanswered"));
01590                 $this->tpl->setVariable("USE_SCORING_SYSTEM", $this->lng->txt("tst_score_mcmr_use_scoring_system"));
01591                 if ($data["mc_scoring"] == SCORE_ZERO_POINTS_WHEN_UNANSWERED)
01592                 {
01593                         $this->tpl->setVariable("SELECTED_ANTICHEAT", " selected=\"selected\"");
01594                 }
01595                 else
01596                 {
01597                         $this->tpl->setVariable("SELECTED_STANDARD", " selected=\"selected\"");
01598                 }
01599                 $this->tpl->setVariable("TEXT_SCORE_CUTTING", $this->lng->txt("tst_score_cutting"));
01600                 $this->tpl->setVariable("TEXT_CUT_QUESTION", $this->lng->txt("tst_score_cut_question"));
01601                 $this->tpl->setVariable("TEXT_CUT_TEST", $this->lng->txt("tst_score_cut_test"));
01602                 if ($data["score_cutting"] == SCORE_CUT_QUESTION)
01603                 {
01604                         $this->tpl->setVariable("SELECTED_CUT_QUESTION", " selected=\"selected\"");
01605                 }
01606                 else
01607                 {
01608                         $this->tpl->setVariable("SELECTED_CUT_TEST", " selected=\"selected\"");
01609                 }
01610 
01611                 $this->tpl->setVariable("TEXT_PASS_SCORING", $this->lng->txt("tst_pass_scoring"));
01612                 $this->tpl->setVariable("TEXT_LASTPASS", $this->lng->txt("tst_pass_last_pass"));
01613                 $this->tpl->setVariable("TEXT_BESTPASS", $this->lng->txt("tst_pass_best_pass"));
01614                 if ($data["pass_scoring"] == SCORE_BEST_PASS)
01615                 {
01616                         $this->tpl->setVariable("SELECTED_BESTPASS", " selected=\"selected\"");
01617                 }
01618                 else
01619                 {
01620                         $this->tpl->setVariable("SELECTED_LASTPASS", " selected=\"selected\"");
01621                 }
01622                 if ($this->object->getTestType() != TYPE_VARYING_RANDOMTEST)
01623                 {
01624                         $this->tpl->setVariable("DISABLE_PASS_SCORING", " disabled=\"disabled\"");
01625                 }
01626                 $this->tpl->setVariable("TEXT_MAX_ALLOWED_USERS", $this->lng->txt("tst_max_allowed_users"));
01627                 $this->tpl->setVariable("TEXT_ALLOWED_USERS", $this->lng->txt("tst_allowed_users"));
01628                 $this->tpl->setVariable("TEXT_ALLOWED_USERS_TIME_GAP", $this->lng->txt("tst_allowed_users_time_gap"));
01629                 if ($data["allowedUsers"] > 0)
01630                 {
01631                         $this->tpl->setVariable("VALUE_ALLOWED_USERS", " value=\"" . $data["allowedUsers"] . "\"");
01632                 }
01633                 $this->tpl->setVariable("TEXT_ALLOWED_USERS_TIME_GAP", $this->lng->txt("tst_allowed_users_time_gap"));
01634                 if ($data["allowedUsersTimeGap"] > 0)
01635                 {
01636                         $this->tpl->setVariable("VALUE_ALLOWED_USERS_TIME_GAP", " value=\"" . $data["allowedUsersTimeGap"] . "\"");
01637                 }
01638                 $this->tpl->setVariable("SECONDS", $this->lng->txt("seconds"));
01639                 $this->tpl->setVariable("TEXT_PASSWORD", $this->lng->txt("tst_password"));
01640                 $this->tpl->setVariable("TEXT_PASSWORD_DETAILS", $this->lng->txt("tst_password_details"));
01641                 if (strlen($data["password"]))
01642                 {
01643                         $this->tpl->setVariable("VALUE_PASSWORD", " value=\"". ilUtil::prepareFormOutput($data["password"])."\"");
01644                 }
01645                 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
01646                 if ($ilAccess->checkAccess("write", "", $this->ref_id)) 
01647                 {
01648                         $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
01649                         $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
01650                 }
01651                 if ($total > 0)
01652                 {
01653                         $this->tpl->setVariable("DISABLE_COUNT_SYSTEM", " disabled=\"disabled\"");
01654                         $this->tpl->setVariable("DISABLE_MC_SCORING", " disabled=\"disabled\"");
01655                         $this->tpl->setVariable("DISABLE_SCORE_CUTTING", " disabled=\"disabled\"");
01656                         $this->tpl->setVariable("DISABLE_PASS_SCORING", " disabled=\"disabled\"");
01657                         $this->tpl->setVariable("ENABLED_TEST_TYPES", " disabled=\"disabled\"");
01658                         $this->tpl->setVariable("ENABLED_RANDOM_TEST", " disabled=\"disabled\"");
01659                 }
01660                 $this->tpl->parseCurrentBlock();
01661         }
01662 
01666         function downloadFileObject()
01667         {
01668                 $file = explode("_", $_GET["file_id"]);
01669                 include_once("classes/class.ilObjFile.php");
01670                 $fileObj =& new ilObjFile($file[count($file) - 1], false);
01671                 $fileObj->sendFile();
01672                 exit;
01673         }
01674         
01678         function fullscreenObject()
01679         {
01680                 include_once("content/classes/Pages/class.ilPageObjectGUI.php");
01681                 $page =& new ilPageObject("qpl", $_GET["pg_id"]);
01682                 $page_gui =& new ilPageObjectGUI($page);
01683                 $page_gui->showMediaFullscreen();
01684                 
01685         }
01686 
01690         function download_paragraphObject()
01691         {
01692                 include_once("content/classes/Pages/class.ilPageObject.php");
01693                 $pg_obj =& new ilPageObject("qpl", $_GET["pg_id"]);
01694                 $pg_obj->send_paragraph ($_GET["par_id"], $_GET["downloadtitle"]);
01695                 exit;
01696         }
01697 
01705         function filterObject()
01706         {
01707                 $this->questionBrowser();
01708         }
01709 
01717         function resetFilterObject()
01718         {
01719                 $this->questionBrowser();
01720         }
01721 
01729         function backObject()
01730         {
01731                 $this->ctrl->redirect($this, "questions");
01732         }
01733         
01741         function insertQuestionsObject()
01742         {
01743                 // insert selected questions into test
01744                 $selected_array = array();
01745                 foreach ($_POST as $key => $value)
01746                 {
01747                         if (preg_match("/cb_(\d+)/", $key, $matches))
01748                         {
01749                                 array_push($selected_array, $matches[1]);
01750                         }
01751                 }
01752                 if (!count($selected_array))
01753                 {
01754                         sendInfo($this->lng->txt("tst_insert_missing_question"), true);
01755                         $this->ctrl->setParameterByClass(get_class($this), "sel_filter_type", $_POST["sel_filter_type"]);
01756                         $this->ctrl->setParameterByClass(get_class($this), "sel_question_type", $_POST["sel_question_type"]);
01757                         $this->ctrl->setParameterByClass(get_class($this), "sel_questionpool", $_POST["sel_questionpool"]);
01758                         $this->ctrl->setParameterByClass(get_class($this), "filter_text", $_POST["filter_text"]);
01759                         $this->ctrl->redirect($this, "browseForQuestions");
01760                 }
01761                 else
01762                 {
01763 
01764                         foreach ($selected_array as $key => $value) 
01765                         {
01766                                 $this->object->insertQuestion($value);
01767                         }
01768                         $this->object->saveCompleteStatus();
01769                         sendInfo($this->lng->txt("tst_questions_inserted"), true);
01770                         $this->ctrl->redirect($this, "questions");
01771                         return;
01772                 }
01773         }
01774 
01782         function questionBrowser()
01783         {
01784                 global $ilAccess;
01785 
01786                 $this->ctrl->setParameterByClass(get_class($this), "browse", "1");
01787 
01788                 if (strcmp($this->ctrl->getCmd(), "resetFilter") == 0)
01789                 {
01790                         $filter_type = "";
01791                         $filter_question_type = "";
01792                         $filter_questionpool = "";
01793                         $filter_text = "";
01794                 }
01795                 else
01796                 {
01797                         if (is_array($_POST) && (count($_POST) > 0))
01798                         {
01799                                 $filter_type = $_POST["sel_filter_type"];
01800                                 $filter_question_type = $_POST["sel_question_type"];
01801                                 $filter_questionpool = $_POST["sel_questionpool"];
01802                                 $filter_text = $_POST["filter_text"];
01803                         }
01804                         else
01805                         {
01806                                 $filter_type = $_GET["sel_filter_type"];
01807                                 $filter_question_type = $_GET["sel_question_type"];
01808                                 $filter_questionpool = $_GET["sel_questionpool"];
01809                                 $filter_text = $_GET["filter_text"];
01810                         }
01811                 }
01812 
01813                 $this->ctrl->setParameterByClass(get_class($this), "sel_filter_type", $filter_type);
01814                 $this->ctrl->setParameterByClass(get_class($this), "sel_question_type", $filter_question_type);
01815                 $this->ctrl->setParameterByClass(get_class($this), "sel_questionpool", $filter_questionpool);
01816                 $this->ctrl->setParameterByClass(get_class($this), "filter_text", $filter_text);
01817                 
01818                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_questionbrowser.html", true);
01819                 $this->tpl->addBlockFile("A_BUTTONS", "a_buttons", "tpl.il_as_qpl_action_buttons.html", true);
01820                 $this->tpl->addBlockFile("FILTER_QUESTION_MANAGER", "filter_questions", "tpl.il_as_tst_filter_questions.html", true);
01821 
01822                 $questionpools =& $this->object->get_qpl_titles();
01823 
01824                 $filter_fields = array(
01825                         "title" => $this->lng->txt("title"),
01826                         "comment" => $this->lng->txt("description"),
01827                         "author" => $this->lng->txt("author"),
01828                 );
01829                 $this->tpl->setCurrentBlock("filterrow");
01830                 foreach ($filter_fields as $key => $value) {
01831                         $this->tpl->setVariable("VALUE_FILTER_TYPE", "$key");
01832                         $this->tpl->setVariable("NAME_FILTER_TYPE", "$value");
01833                         if (strcmp($this->ctrl->getCmd(), "resetFilter") != 0) 
01834                         {
01835                                 if (strcmp($filter_type, $key) == 0) 
01836                                 {
01837                                         $this->tpl->setVariable("VALUE_FILTER_SELECTED", " selected=\"selected\"");
01838                                 }
01839                         }
01840                         $this->tpl->parseCurrentBlock();
01841                 }
01842 
01843                 $questiontypes =& $this->object->_getQuestiontypes();
01844                 foreach ($questiontypes as $key => $value)
01845                 {
01846                         $this->tpl->setCurrentBlock("questiontype_row");
01847                         $this->tpl->setVariable("VALUE_QUESTION_TYPE", $value["type_tag"]);
01848                         $this->tpl->setVariable("TEXT_QUESTION_TYPE", $this->lng->txt($value["type_tag"]));
01849                         if (strcmp($filter_question_type, $value["type_tag"]) == 0)
01850                         {
01851                                 $this->tpl->setVariable("SELECTED_QUESTION_TYPE", " selected=\"selected\"");
01852                         }
01853                         $this->tpl->parseCurrentBlock();
01854                 }
01855                 
01856                 foreach ($questionpools as $key => $value)
01857                 {
01858                         $this->tpl->setCurrentBlock("questionpool_row");
01859                         $this->tpl->setVariable("VALUE_QUESTIONPOOL", $key);
01860                         $this->tpl->setVariable("TEXT_QUESTIONPOOL", $value);
01861                         if (strcmp($filter_questionpool, $key) == 0)
01862                         {
01863                                 $this->tpl->setVariable("SELECTED_QUESTIONPOOL", " selected=\"selected\"");
01864                         }
01865                         $this->tpl->parseCurrentBlock();
01866                 }
01867 
01868                 $this->tpl->setCurrentBlock("filter_questions");
01869                 $this->tpl->setVariable("SHOW_QUESTION_TYPES", $this->lng->txt("filter_show_question_types"));
01870                 $this->tpl->setVariable("TEXT_ALL_QUESTION_TYPES", $this->lng->txt("filter_all_question_types"));
01871                 $this->tpl->setVariable("SHOW_QUESTIONPOOLS", $this->lng->txt("filter_show_questionpools"));
01872                 $this->tpl->setVariable("TEXT_ALL_QUESTIONPOOLS", $this->lng->txt("filter_all_questionpools"));
01873                 $this->tpl->setVariable("FILTER_TEXT", $this->lng->txt("filter"));
01874                 $this->tpl->setVariable("TEXT_FILTER_BY", $this->lng->txt("by"));
01875                 if (strcmp($this->ctrl->getCmd(), "resetFilter") != 0) 
01876                 {
01877                         $this->tpl->setVariable("VALUE_FILTER_TEXT", $filter_text);
01878                 }
01879                 $this->tpl->setVariable("VALUE_SUBMIT_FILTER", $this->lng->txt("set_filter"));
01880                 $this->tpl->setVariable("VALUE_RESET_FILTER", $this->lng->txt("reset_filter"));
01881                 $this->tpl->parseCurrentBlock();
01882 
01883                 $startrow = 0;
01884                 if ($_GET["prevrow"])
01885                 {
01886                         $startrow = $_GET["prevrow"];
01887                 }
01888                 if ($_GET["nextrow"])
01889                 {
01890                         $startrow = $_GET["nextrow"];
01891                 }
01892                 if ($_GET["startrow"])
01893                 {
01894                         $startrow = $_GET["startrow"];
01895                 }
01896                 $sort = ($_GET["sort"]) ? $_GET["sort"] : "title";
01897                 $sortorder = ($_GET["sortorder"]) ? $_GET["sortorder"] : "ASC";
01898                 $this->ctrl->setParameter($this, "sort", $sort);
01899                 $this->ctrl->setParameter($this, "sortorder", $sortorder);
01900                 $table = $this->object->getQuestionsTable($sort, $sortorder, $filter_text, $filter_type, $startrow, 1, $filter_question_type, $filter_questionpool);
01901                 // display all questions in accessable question pools
01902                 $colors = array("tblrow1", "tblrow2");
01903                 $counter = 0;
01904                 $existing_questions =& $this->object->getExistingQuestions();
01905                 if ((is_array($table["rows"])) && (count($table["rows"])))
01906                 {
01907                         foreach ($table["rows"] as $data)
01908                         {
01909                                 if (!in_array($data["question_id"], $existing_questions))
01910                                 {
01911                                         if ($data["complete"])
01912                                         {
01913                                                 // make only complete questions selectable
01914                                                 $this->tpl->setCurrentBlock("checkable");
01915                                                 $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
01916                                                 $this->tpl->parseCurrentBlock();
01917                                         }
01918                                         $this->tpl->setCurrentBlock("QTab");
01919                                         $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
01920                                         $this->tpl->setVariable("QUESTION_TITLE", "<strong>" . $data["title"] . "</strong>");
01921                                         $this->tpl->setVariable("PREVIEW", "[<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&preview=" . $data["question_id"] . "\">" . $this->lng->txt("preview") . "</a>]");
01922                                         $this->tpl->setVariable("QUESTION_COMMENT", $data["comment"]);
01923                                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($data["type_tag"]));
01924                                         $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]);
01925                                         $this->tpl->setVariable("QUESTION_CREATED", ilFormat::formatDate(ilFormat::ftimestamp2dateDB($data["created"]), "date"));
01926                                         $this->tpl->setVariable("QUESTION_UPDATED", ilFormat::formatDate(ilFormat::ftimestamp2dateDB($data["TIMESTAMP14"]), "date"));
01927                                         $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
01928                                         $this->tpl->setVariable("QUESTION_POOL", $questionpools[$data["obj_fi"]]);
01929                                         $this->tpl->parseCurrentBlock();
01930                                         $counter++;
01931                                 }
01932                         }
01933         
01934                         if ($table["rowcount"] > count($table["rows"]))
01935                         {
01936                                 $nextstep = $table["nextrow"] + $table["step"];
01937                                 if ($nextstep > $table["rowcount"])
01938                                 {
01939                                         $nextstep = $table["rowcount"];
01940                                 }
01941                                 $counter = 1;
01942                                 for ($i = 0; $i < $table["rowcount"]; $i += $table["step"])
01943                                 {
01944                                         $this->tpl->setCurrentBlock("pages");
01945                                         if ($table["startrow"] == $i)
01946                                         {
01947                                                 $this->tpl->setVariable("PAGE_NUMBER", "<span class=\"inactivepage\">$counter</span>");
01948                                         }
01949                                         else
01950                                         {
01951                                                 $this->tpl->setVariable("PAGE_NUMBER", "<a href=\"" . $this->ctrl->getLinkTarget($this, "browseForQuestions") . "&nextrow=$i" . "\">$counter</a>");
01952                                         }
01953                                         $this->tpl->parseCurrentBlock();
01954                                         $counter++;
01955                                 }
01956                                 $this->tpl->setCurrentBlock("navigation_bottom");
01957                                 $this->tpl->setVariable("TEXT_ITEM", $this->lng->txt("item"));
01958                                 $this->tpl->setVariable("TEXT_ITEM_START", $table["startrow"] + 1);
01959                                 $end = $table["startrow"] + $table["step"];
01960                                 if ($end > $table["rowcount"])
01961                                 {
01962                                         $end = $table["rowcount"];
01963                                 }
01964                                 $this->tpl->setVariable("TEXT_ITEM_END", $end);
01965                                 $this->tpl->setVariable("TEXT_OF", strtolower($this->lng->txt("of")));
01966                                 $this->tpl->setVariable("TEXT_ITEM_COUNT", $table["rowcount"]);
01967                                 $this->tpl->setVariable("TEXT_PREVIOUS", $this->lng->txt("previous"));
01968                                 $this->tpl->setVariable("TEXT_NEXT", $this->lng->txt("next"));
01969                                 $this->tpl->setVariable("HREF_PREV_ROWS", $this->ctrl->getLinkTarget($this, "browseForQuestions") . "&prevrow=" . $table["prevrow"]);
01970                                 $this->tpl->setVariable("HREF_NEXT_ROWS", $this->ctrl->getLinkTarget($this, "browseForQuestions") . "&nextrow=" . $table["nextrow"]);
01971                                 $this->tpl->parseCurrentBlock();
01972                         }
01973                 }
01974 
01975                 // if there are no questions, display a message
01976                 if (!((is_array($table["rows"])) && (count($table["rows"]))))
01977                 {
01978                         $this->tpl->setCurrentBlock("Emptytable");
01979                         $this->tpl->setVariable("TEXT_EMPTYTABLE", $this->lng->txt("no_questions_available"));
01980                         $this->tpl->parseCurrentBlock();
01981                 }
01982                 else
01983                 {
01984                         // create edit buttons & table footer
01985                         $this->tpl->setCurrentBlock("selection");
01986                         $this->tpl->setVariable("INSERT", $this->lng->txt("insert"));
01987                         $this->tpl->parseCurrentBlock();
01988         
01989                         $this->tpl->setCurrentBlock("selectall");
01990                         $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
01991                         $counter++;
01992                         $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
01993                         $this->tpl->parseCurrentBlock();
01994         
01995                         $this->tpl->setCurrentBlock("Footer");
01996                         $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\"/>");
01997                         $this->tpl->parseCurrentBlock();
01998                 }
01999                 // define the sort column parameters
02000                 $sortarray = array(
02001                         "title" => (strcmp($sort, "title") == 0) ? $sortorder : "",
02002                         "comment" => (strcmp($sort, "comment") == 0) ? $sortorder : "",
02003                         "type" => (strcmp($sort, "type") == 0) ? $sortorder : "",
02004                         "author" => (strcmp($sort, "author") == 0) ? $sortorder : "",
02005                         "created" => (strcmp($sort, "created") == 0) ? $sortorder : "",
02006                         "updated" => (strcmp($sort, "updated") == 0) ? $sortorder : "",
02007                         "qpl" => (strcmp($sort, "qpl") == 0) ? $sortorder : ""
02008                 );
02009                 foreach ($sortarray as $key => $value) 
02010                 {
02011                         if (strcmp($value, "ASC") == 0) 
02012                         {
02013                                 $sortarray[$key] = "DESC";
02014                         } 
02015                         else 
02016                         {
02017                                 $sortarray[$key] = "ASC";
02018                         }
02019                 }
02020 
02021                 $this->tpl->setCurrentBlock("adm_content");
02022                 // create table header
02023                 $this->ctrl->setCmd("questionBrowser");
02024                 $this->ctrl->setParameterByClass(get_class($this), "startrow", $table["startrow"]);
02025                 $this->ctrl->setParameter($this, "sort", "title");
02026                 $this->ctrl->setParameter($this, "sortorder", $sortarray["title"]);
02027                 $this->tpl->setVariable("QUESTION_TITLE", "<a href=\"" . $this->ctrl->getLinkTarget($this, "browseForQuestions") . "\">" . $this->lng->txt("title") . "</a>" . $table["images"]["title"]);
02028                 $this->ctrl->setParameter($this, "sort", "comment");
02029                 $this->ctrl->setParameter($this, "sortorder", $sortarray["comment"]);
02030                 $this->tpl->setVariable("QUESTION_COMMENT", "<a href=\"" . $this->ctrl->getLinkTarget($this, "browseForQuestions") . "\">" . $this->lng->txt("description") . "</a>". $table["images"]["comment"]);
02031                 $this->ctrl->setParameter($this, "sort", "type");
02032                 $this->ctrl->setParameter($this, "sortorder", $sortarray["type"]);
02033                 $this->tpl->setVariable("QUESTION_TYPE", "<a href=\"" . $this->ctrl->getLinkTarget($this, "browseForQuestions") . "\">" . $this->lng->txt("question_type") . "</a>" . $table["images"]["type"]);
02034                 $this->ctrl->setParameter($this, "sort", "author");
02035                 $this->ctrl->setParameter($this, "sortorder", $sortarray["author"]);
02036                 $this->tpl->setVariable("QUESTION_AUTHOR", "<a href=\"" . $this->ctrl->getLinkTarget($this, "browseForQuestions") . "\">" . $this->lng->txt("author") . "</a>" . $table["images"]["author"]);
02037                 $this->ctrl->setParameter($this, "sort", "created");
02038                 $this->ctrl->setParameter($this, "sortorder", $sortarray["created"]);
02039                 $this->tpl->setVariable("QUESTION_CREATED", "<a href=\"" . $this->ctrl->getLinkTarget($this, "browseForQuestions") . "\">" . $this->lng->txt("create_date") . "</a>" . $table["images"]["created"]);
02040                 $this->ctrl->setParameter($this, "sort", "updated");
02041                 $this->ctrl->setParameter($this, "sortorder", $sortarray["updated"]);
02042                 $this->tpl->setVariable("QUESTION_UPDATED", "<a href=\"" . $this->ctrl->getLinkTarget($this, "browseForQuestions") . "\">" . $this->lng->txt("last_update") . "</a>" . $table["images"]["updated"]);
02043                 $this->ctrl->setParameter($this, "sort", "qpl");
02044                 $this->ctrl->setParameter($this, "sortorder", $sortarray["qpl"]);
02045                 $this->tpl->setVariable("QUESTION_POOL", "<a href=\"" . $this->ctrl->getLinkTarget($this, "browseForQuestions") . "\">" . $this->lng->txt("obj_qpl") . "</a>" . $table["images"]["qpl"]);
02046                 $this->tpl->setVariable("BUTTON_BACK", $this->lng->txt("back"));
02047                 $this->ctrl->setParameter($this, "sort", $sort);
02048                 $this->ctrl->setParameter($this, "sortorder", $sortorder);
02049                 $this->tpl->setVariable("ACTION_QUESTION_FORM", $this->ctrl->getFormAction($this));
02050                 $this->tpl->parseCurrentBlock();
02051         }
02052 
02061         function createQuestionPool($name = "dummy")
02062         {
02063                 global $tree;
02064                 $parent_ref = $tree->getParentId($this->object->getRefId());
02065                 include_once "./assessment/classes/class.ilObjQuestionPool.php";
02066                 $qpl = new ilObjQuestionPool();
02067                 $qpl->setType("qpl");
02068                 $qpl->setTitle($name);
02069                 $qpl->setDescription("");
02070                 $qpl->create();
02071                 $qpl->createReference();
02072                 $qpl->putInTree($parent_ref);
02073                 $qpl->setPermissions($parent_ref);
02074                 $qpl->setOnline(1); // must be online to be available
02075                 $qpl->saveToDb();
02076                 return $qpl->getRefId();
02077         }
02078 
02086         function randomselectObject()
02087         {
02088                 global $ilUser;
02089                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_random_select.html", true);
02090                 $questionpools =& $this->object->getAvailableQuestionpools(false);
02091                 $this->tpl->setCurrentBlock("option");
02092                 $this->tpl->setVariable("VALUE_OPTION", "0");
02093                 $this->tpl->setVariable("TEXT_OPTION", $this->lng->txt("all_available_question_pools"));
02094                 $this->tpl->parseCurrentBlock();
02095                 foreach ($questionpools as $key => $value)
02096                 {
02097                         $this->tpl->setCurrentBlock("option");
02098                         $this->tpl->setVariable("VALUE_OPTION", $key);
02099                         $this->tpl->setVariable("TEXT_OPTION", $value["title"]);
02100                         $this->tpl->parseCurrentBlock();
02101                 }
02102                 $this->tpl->setCurrentBlock("hidden");
02103                 $this->tpl->setVariable("HIDDEN_NAME", "sel_question_types");
02104                 $this->tpl->setVariable("HIDDEN_VALUE", $_POST["sel_question_types"]);
02105                 $this->tpl->parseCurrentBlock();
02106                 $this->tpl->setCurrentBlock("adm_content");
02107                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
02108                 $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_random_select_questionpool"));
02109                 $this->tpl->setVariable("TXT_NR_OF_QUESTIONS", $this->lng->txt("tst_random_nr_of_questions"));
02110                 $this->tpl->setVariable("BTN_SUBMIT", $this->lng->txt("submit"));
02111                 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
02112                 $this->tpl->parseCurrentBlock();
02113         }
02114         
02122         function cancelRandomSelectObject()
02123         {
02124                 $this->ctrl->redirect($this, "questions");
02125         }
02126         
02134         function createRandomSelectionObject()
02135         {
02136                 $question_array = $this->object->randomSelectQuestions($_POST["nr_of_questions"], $_POST["sel_qpl"]);
02137                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_random_question_offer.html", true);
02138                 $color_class = array("tblrow1", "tblrow2");
02139                 $counter = 0;
02140                 $questionpools =& $this->object->get_qpl_titles();
02141                 foreach ($question_array as $question_id)
02142                 {
02143                         $dataset = $this->object->getQuestionDataset($question_id);
02144                         $this->tpl->setCurrentBlock("QTab");
02145                         $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
02146                         $this->tpl->setVariable("QUESTION_TITLE", $dataset->title);
02147                         $this->tpl->setVariable("QUESTION_COMMENT", $dataset->comment);
02148                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($dataset->type_tag));
02149                         $this->tpl->setVariable("QUESTION_AUTHOR", $dataset->author);
02150                         $this->tpl->setVariable("QUESTION_POOL", $questionpools[$dataset->obj_fi]);
02151                         $this->tpl->parseCurrentBlock();
02152                         $counter++;
02153                 }
02154                 if (count($question_array) == 0)
02155                 {
02156                         $this->tpl->setCurrentBlock("Emptytable");
02157                         $this->tpl->setVariable("TEXT_NO_QUESTIONS_AVAILABLE", $this->lng->txt("no_questions_available"));
02158                         $this->tpl->parseCurrentBlock();
02159                 }
02160                         else
02161                 {
02162                         $this->tpl->setCurrentBlock("Selectionbuttons");
02163                         $this->tpl->setVariable("BTN_YES", $this->lng->txt("random_accept_sample"));
02164                         $this->tpl->setVariable("BTN_NO", $this->lng->txt("random_another_sample"));
02165                         $this->tpl->parseCurrentBlock();
02166                 }
02167                 $chosen_questions = join($question_array, ",");
02168                 $this->tpl->setCurrentBlock("adm_content");
02169                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
02170                 $this->tpl->setVariable("QUESTION_TITLE", $this->lng->txt("tst_question_title"));
02171                 $this->tpl->setVariable("QUESTION_COMMENT", $this->lng->txt("description"));
02172                 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("tst_question_type"));
02173                 $this->tpl->setVariable("QUESTION_AUTHOR", $this->lng->txt("author"));
02174                 $this->tpl->setVariable("QUESTION_POOL", $this->lng->txt("qpl"));
02175                 $this->tpl->setVariable("VALUE_CHOSEN_QUESTIONS", $chosen_questions);
02176                 $this->tpl->setVariable("VALUE_QUESTIONPOOL_SELECTION", $_POST["sel_qpl"]);
02177                 $this->tpl->setVariable("VALUE_NR_OF_QUESTIONS", $_POST["nr_of_questions"]);
02178                 $this->tpl->setVariable("TEXT_QUESTION_OFFER", $this->lng->txt("tst_question_offer"));
02179                 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
02180                 $this->tpl->parseCurrentBlock();
02181         }
02182         
02190         function insertRandomSelectionObject()
02191         {
02192                 $selected_array = split(",", $_POST["chosen_questions"]);
02193                 if (!count($selected_array))
02194                 {
02195                         sendInfo($this->lng->txt("tst_insert_missing_question"));
02196                 }
02197                 else
02198                 {
02199                         $total = $this->object->evalTotalPersons();
02200                         if ($total)
02201                         {
02202                                 // the test was executed previously
02203                                 sendInfo(sprintf($this->lng->txt("tst_insert_questions_and_results"), $total));
02204                         }
02205                         else
02206                         {
02207                                 sendInfo($this->lng->txt("tst_insert_questions"));
02208                         }
02209                         foreach ($selected_array as $key => $value) 
02210                         {
02211                                 $this->object->insertQuestion($value);
02212                         }
02213                         $this->object->saveCompleteStatus();
02214                         sendInfo($this->lng->txt("tst_questions_inserted"), true);
02215                         $this->ctrl->redirect($this, "questions");
02216                         return;
02217                 }
02218         }
02219         
02220         function saveRandomQuestionsObject()
02221         {
02222                 $this->randomQuestionsObject();
02223         }
02224         
02225         function addQuestionpoolObject()
02226         {
02227                 $this->randomQuestionsObject();
02228         }
02229 
02230         function randomQuestionsObject()
02231         {
02232                 global $ilUser, $ilDB;
02233                 $selection_mode = $ilUser->getPref("tst_question_selection_mode_equal");
02234                 $total = $this->object->evalTotalPersons();
02235                 if ($ilDB->tableColumnExists("qpl_questionpool", "questioncount"))
02236                 {
02237                         $available_qpl =& $this->object->getAvailableQuestionpools(TRUE, $selection_mode, FALSE, TRUE);
02238                         $qpl_question_count = array();
02239                         foreach ($available_qpl as $key => $value)
02240                         {
02241                                 $qpl_question_count[$key] = $value["count"];
02242                         }
02243                 }
02244                 else
02245                 {
02246                         $available_qpl =& $this->object->getAvailableQuestionpools(TRUE, $selection_mode, FALSE);
02247                         include_once "./assessment/classes/class.ilObjQuestionPool.php";
02248                         $qpl_question_count = array();
02249                         foreach ($available_qpl as $key => $value)
02250                         {
02251                                 $count = ilObjQuestionPool::_getQuestionCount($key);
02252                                 $qpl_question_count[$key] = $count;
02253                                 if ($count == 1)
02254                                 {
02255                                         $available_qpl[$key]["title"] = $value["title"] . " ($count " . $this->lng->txt("ass_question") . ")";
02256                                 }
02257                                 else
02258                                 {
02259                                         $available_qpl[$key]["title"] = $value["title"] . " ($count " . $this->lng->txt("assQuestions") . ")";
02260                                 }
02261                         }
02262                 }
02263                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_random_questions.html", true);
02264                 $found_qpls = array();
02265                 if (count($_POST) == 0)
02266                 {
02267                         $found_qpls = $this->object->getRandomQuestionpools();
02268                 }
02269                 $qpl_unselected = 0;
02270                 foreach ($_POST as $key => $value)
02271                 {
02272                         if (preg_match("/countqpl_(\d+)/", $key, $matches))
02273                         {
02274                                 $questioncount = $qpl_question_count[$_POST["qpl_" . $matches[1]]];
02275                                 if ((strlen($questioncount) > 0) && ($value > $questioncount))
02276                                 {
02277                                         $value = $questioncount;
02278                                         sendInfo($this->lng->txt("tst_random_selection_question_count_too_high"));
02279                                 }
02280                                 $found_qpls[$matches[1]] = array(
02281                                         "index" => $matches[1],
02282                                         "count" => sprintf("%d", $value),
02283                                         "qpl"   => $_POST["qpl_" . $matches[1]],
02284                                         "title" => $available_qpl[$_POST["qpl_" . $matches[1]]]["title"]
02285                                 );
02286                                 if ($_POST["qpl_" . $matches[1]] == -1)
02287                                 {
02288                                         $qpl_unselected = 1;
02289                                 }
02290                         }
02291                 }
02292                 $commands = $_POST["cmd"];
02293                 if (is_array($commands))
02294                 {
02295                         foreach ($commands as $key => $value)
02296                         {
02297                                 if (preg_match("/deleteqpl_(\d+)/", $key, $matches))
02298                                 {
02299                                         unset($found_qpls[$matches[1]]);
02300                                 }
02301                         }
02302                 }
02303                 sort($found_qpls);
02304                 $found_qpls = array_values($found_qpls);
02305                 if (count($found_qpls) == 0)
02306                 {
02307 //                      if (!array_key_exists("countqpl_0", $_POST))
02308 //                      {
02309                                 // create first questionpool row automatically
02310                                 foreach ($available_qpl as $key => $value)
02311                                 {
02312                                         $this->tpl->setCurrentBlock("qpl_value");
02313                                         $this->tpl->setVariable("QPL_ID", $key);
02314                                         $this->tpl->setVariable("QPL_TEXT", $value["title"]);
02315                                         $this->tpl->parseCurrentBlock();
02316                                 }
02317                                 $this->tpl->setCurrentBlock("questionpool_row");
02318                                 $this->tpl->setVariable("COUNTQPL", "0");
02319                                 $this->tpl->setVariable("VALUE_COUNTQPL", $_POST["countqpl_0"]);
02320                                 $this->tpl->setVariable("TEXT_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool_option"));
02321                                 $this->tpl->setVariable("TEXT_QUESTIONS_FROM", $this->lng->txt("questions_from"));
02322                                 $this->tpl->setVariable("BTNCOUNTQPL", 0);
02323                                 $this->tpl->setVariable("BTN_DELETE", $this->lng->txt("delete"));
02324                                 $this->tpl->parseCurrentBlock();
02325 //                      }
02326                 }
02327 
02328                 $counter = 0;
02329                 foreach ($found_qpls as $key => $value)
02330                 {
02331                         $pools = $available_qpl;
02332                         foreach ($found_qpls as $pkey => $pvalue)
02333                         {
02334                                 if ($pvalue["qpl"] != $value["qpl"])
02335                                 {
02336                                         unset($pools[$pvalue["qpl"]]);
02337                                 }
02338                         }
02339                         // create first questionpool row automatically
02340                         foreach ($pools as $pkey => $pvalue)
02341                         {
02342                                 $this->tpl->setCurrentBlock("qpl_value");
02343                                 $this->tpl->setVariable("QPL_ID", $pkey);
02344                                 $this->tpl->setVariable("QPL_TEXT", $pvalue["title"]);
02345                                 if ($pkey == $value["qpl"])
02346                                 {
02347                                         $this->tpl->setVariable("SELECTED_QPL", " selected=\"selected\"");
02348                                 }
02349                                 $this->tpl->parseCurrentBlock();
02350                         }
02351                         $this->tpl->setCurrentBlock("questionpool_row");
02352                         $this->tpl->setVariable("COUNTQPL", $counter);
02353                         $this->tpl->setVariable("VALUE_COUNTQPL", $value["count"]);
02354                         $this->tpl->setVariable("TEXT_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool_option"));
02355                         $this->tpl->setVariable("TEXT_QUESTIONS_FROM", $this->lng->txt("questions_from"));
02356                         $this->tpl->setVariable("BTNCOUNTQPL", $counter);
02357                         $this->tpl->setVariable("BTN_DELETE", $this->lng->txt("delete"));
02358                         $this->tpl->parseCurrentBlock();
02359                         $counter++;
02360                 }
02361                 if ($_POST["cmd"]["addQuestionpool"])
02362                 {
02363                         if ($qpl_unselected)
02364                         {
02365                                 sendInfo($this->lng->txt("tst_random_qpl_unselected"));
02366                         }
02367                         else
02368                         {
02369                                 $pools = $available_qpl;
02370                                 foreach ($found_qpls as $pkey => $pvalue)
02371                                 {
02372                                         unset($pools[$pvalue["qpl"]]);
02373                                 }
02374                                 if (count($pools) == 0)
02375                                 {
02376                                         sendInfo($this->lng->txt("tst_no_more_available_questionpools"));
02377                                 }
02378                                 else
02379                                 {
02380                                         foreach ($pools as $key => $value)
02381                                         {
02382                                                 $this->tpl->setCurrentBlock("qpl_value");
02383                                                 $this->tpl->setVariable("QPL_ID", $key);
02384                                                 $this->tpl->setVariable("QPL_TEXT", $value["title"]);
02385                                                 $this->tpl->parseCurrentBlock();
02386                                         }
02387                                         $this->tpl->setCurrentBlock("questionpool_row");
02388                                         $this->tpl->setVariable("COUNTQPL", "$counter");
02389                                         $this->tpl->setVariable("TEXT_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool_option"));
02390                                         $this->tpl->setVariable("TEXT_QUESTIONS_FROM", $this->lng->txt("questions_from"));
02391                                         $this->tpl->setVariable("BTNCOUNTQPL", $counter);
02392                                         $this->tpl->setVariable("BTN_DELETE", $this->lng->txt("delete"));
02393                                         $this->tpl->parseCurrentBlock();
02394                                 }
02395                         }
02396                 }
02397                 if ($_POST["cmd"]["saveRandomQuestions"])
02398                 {
02399                         $this->object->saveRandomQuestionCount($_POST["total_questions"]);
02400                         $this->object->saveRandomQuestionpools($found_qpls);
02401                         $this->object->saveCompleteStatus();
02402                 }
02403                 $this->tpl->setCurrentBlock("adm_content");
02404                 $this->tpl->setVariable("TEXT_SELECT_RANDOM_QUESTIONS", $this->lng->txt("tst_select_random_questions"));
02405                 $this->tpl->setVariable("TEXT_TOTAL_QUESTIONS", $this->lng->txt("tst_total_questions"));
02406                 $this->tpl->setVariable("TEXT_TOTAL_QUESTIONS_DESCRIPTION", $this->lng->txt("tst_total_questions_description"));
02407                 $total_questions = $this->object->getRandomQuestionCount();
02408                 if (array_key_exists("total_questions", $_POST))
02409                 {
02410                         $total_questions = $_POST["total_questions"];
02411                 }
02412                 if ($total_questions > 0)
02413                 {
02414                         $sum = 0;
02415                         foreach ($found_qpls as $key => $value)
02416                         {
02417                                 $sum += $qpl_question_count[$value["qpl"]];
02418                         }
02419                         if ($total_questions > $sum)
02420                         {
02421                                 $total_questions = $sum;
02422                                 if ($_POST["cmd"]["saveRandomQuestions"])
02423                                 {
02424                                         $this->object->saveRandomQuestionCount($total_questions);
02425                                 }
02426                                 sendInfo($this->lng->txt("tst_random_selection_question_total_count_too_high"));
02427                         }
02428                 }
02429                 $this->tpl->setVariable("VALUE_TOTAL_QUESTIONS", $total_questions);
02430                 $this->tpl->setVariable("TEXT_QUESTIONPOOLS", $this->lng->txt("tst_random_questionpools"));
02431                 if (!$total)
02432                 {
02433                         $this->tpl->setVariable("BTN_SAVE", $this->lng->txt("save"));
02434                         $this->tpl->setVariable("BTN_ADD_QUESTIONPOOL", $this->lng->txt("add_questionpool"));
02435                 }
02436                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
02437 
02438                 $this->tpl->setVariable("TEXT_QUESTION_SELECTION", $this->lng->txt("tst_question_selection"));
02439                 $this->tpl->setVariable("VALUE_QUESTION_SELECTION", $this->lng->txt("tst_question_selection_equal"));
02440                 $this->tpl->setVariable("CMD_QUESTION_SELECTION", "setEqualQplSelection");
02441                 $this->tpl->setVariable("TEXT_QUESTION_SELECTION_DESCRIPTION", $this->lng->txt("tst_question_selection_description"));
02442                 $this->tpl->setVariable("BUTTON_SAVE", $this->lng->txt("change"));
02443                 if ($selection_mode == 1)
02444                 {
02445                         $this->tpl->setVariable("CHECKED_QUESTION_SELECTION_MODE", " checked=\"checked\"");
02446                 }
02447                 $this->tpl->parseCurrentBlock();
02448         }
02449         
02450         function saveQuestionSelectionModeObject()
02451         {
02452                 global $ilUser;
02453                 if ($_POST["chbQuestionSelectionMode"])
02454                 {
02455                         $ilUser->setPref("tst_question_selection_mode_equal", 1);
02456                         $ilUser->writePref("tst_question_selection_mode_equal", 1);
02457                 }
02458                 else
02459                 {
02460                         $ilUser->setPref("tst_question_selection_mode_equal", 0);
02461                         $ilUser->writePref("tst_question_selection_mode_equal", 0);
02462                 }
02463                 $this->randomQuestionsObject();
02464         }
02465 
02466         function browseForQuestionsObject()
02467         {
02468                 $this->questionBrowser();
02469         }
02470         
02478         function executeCreateQuestionObject()
02479         {
02480                 $qpl_ref_id = $_POST["sel_qpl"];
02481                 if ((strcmp($_POST["txt_qpl"], "") == 0) && (strcmp($qpl_ref_id, "") == 0))
02482                 {
02483                         sendInfo($this->lng->txt("questionpool_not_entered"));
02484                         $this->createQuestionObject();
02485                         return;
02486                 }
02487                 else
02488                 {
02489                         $_SESSION["test_id"] = $this->object->getRefId();
02490                         if (strcmp($_POST["txt_qpl"], "") != 0)
02491                         {
02492                                 // create a new question pool and return the reference id
02493                                 $qpl_ref_id = $this->createQuestionPool($_POST["txt_qpl"]);
02494                         }
02495                         include_once "./assessment/classes/class.ilObjQuestionPoolGUI.php";
02496                         ilUtil::redirect("ilias.php?baseClass=ilObjQuestionPoolGUI&ref_id=" . $qpl_ref_id . "&cmd=createQuestionForTest&test_ref_id=".$_GET["ref_id"]."&sel_question_types=" . $_POST["sel_question_types"]);
02497                         exit();
02498                 }
02499         }
02500 
02508         function cancelCreateQuestionObject()
02509         {
02510                 $this->ctrl->redirect($this, "questions");
02511         }
02512 
02520         function createQuestionObject()
02521         {
02522                 global $ilUser;
02523                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_qpl_select.html", true);
02524                 $questionpools =& $this->object->getAvailableQuestionpools();
02525                 if (count($questionpools) == 0)
02526                 {
02527                         $this->tpl->setCurrentBlock("option");
02528                         $this->tpl->setVariable("VALUE_QPL", "");
02529                         $this->tpl->parseCurrentBlock();
02530                 }
02531                 else
02532                 {
02533                         foreach ($questionpools as $key => $value)
02534                         {
02535                                 $this->tpl->setCurrentBlock("option");
02536                                 $this->tpl->setVariable("VALUE_OPTION", $key);
02537                                 $this->tpl->setVariable("TEXT_OPTION", $value["title"]);
02538                                 $this->tpl->parseCurrentBlock();
02539                         }
02540                 }
02541                 $this->tpl->setCurrentBlock("hidden");
02542                 $this->tpl->setVariable("HIDDEN_NAME", "sel_question_types");
02543                 $this->tpl->setVariable("HIDDEN_VALUE", $_POST["sel_question_types"]);
02544                 $this->tpl->parseCurrentBlock();
02545                 $this->tpl->setCurrentBlock("adm_content");
02546                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
02547 
02548                 if (count($questionpools) == 0)
02549                 {
02550                         $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_enter_questionpool"));
02551                 }
02552                 else
02553                 {
02554                         $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_select_questionpool"));
02555                 }
02556                 $this->tpl->setVariable("BTN_SUBMIT", $this->lng->txt("submit"));
02557                 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
02558                 $this->tpl->parseCurrentBlock();
02559         }
02560 
02568         function confirmRemoveQuestionsObject()
02569         {
02570                 sendInfo($this->lng->txt("tst_questions_removed"));
02571                 $checked_questions = array();
02572                 foreach ($_POST as $key => $value) {
02573                         if (preg_match("/id_(\d+)/", $key, $matches)) {
02574                                 array_push($checked_questions, $matches[1]);
02575                         }
02576                 }
02577                 foreach ($checked_questions as $key => $value) {
02578                         $this->object->removeQuestion($value);
02579                 }
02580                 $this->object->saveCompleteStatus();
02581                 $this->ctrl->redirect($this, "questions");
02582         }
02583         
02591         function cancelRemoveQuestionsObject()
02592         {
02593                 $this->ctrl->redirect($this, "questions");
02594         }
02595         
02603         function removeQuestionsForm($checked_questions)
02604         {
02605                 sendInfo();
02606                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_remove_questions.html", true);
02607                 $removablequestions =& $this->object->getTestQuestions();
02608                 $colors = array("tblrow1", "tblrow2");
02609                 $counter = 0;
02610                 if (count($removablequestions))
02611                 {
02612                         foreach ($removablequestions as $data)
02613                         {
02614                                 if (in_array($data["question_id"], $checked_questions))
02615                                 {
02616                                         $this->tpl->setCurrentBlock("row");
02617                                         $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
02618                                         $this->tpl->setVariable("TXT_TITLE", $data["title"]);
02619                                         $this->tpl->setVariable("TXT_DESCRIPTION", $data["comment"]);
02620                                         $this->tpl->setVariable("TXT_TYPE", $this->lng->txt($data["type_tag"]));
02621                                         $this->tpl->parseCurrentBlock();
02622                                         $counter++;
02623                                 }
02624                         }
02625                 }
02626                 foreach ($checked_questions as $id)
02627                 {
02628                         $this->tpl->setCurrentBlock("hidden");
02629                         $this->tpl->setVariable("HIDDEN_NAME", "id_$id");
02630                         $this->tpl->setVariable("HIDDEN_VALUE", "1");
02631                         $this->tpl->parseCurrentBlock();
02632                 }
02633 
02634                 $this->tpl->setCurrentBlock("adm_content");
02635                 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("tst_question_title"));
02636                 $this->tpl->setVariable("TXT_DESCRIPTION", $this->lng->txt("description"));
02637                 $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("tst_question_type"));
02638                 $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
02639                 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
02640                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
02641                 $this->tpl->parseCurrentBlock();
02642         }
02643 
02651         function removeQuestionsObject()
02652         {
02653                 $checked_questions = array();
02654                 foreach ($_POST as $key => $value) {
02655                         if (preg_match("/cb_(\d+)/", $key, $matches)) {
02656                                 array_push($checked_questions, $matches[1]);
02657                         }
02658                 }
02659                 if (count($checked_questions) > 0) {
02660                         $total = $this->object->evalTotalPersons();
02661                         if ($total) {
02662                                 // the test was executed previously
02663                                 sendInfo(sprintf($this->lng->txt("tst_remove_questions_and_results"), $total));
02664                         } else {
02665                                 sendInfo($this->lng->txt("tst_remove_questions"));
02666                         }
02667                         $this->removeQuestionsForm($checked_questions);
02668                         return;
02669                 } elseif (count($checked_questions) == 0) {
02670                         sendInfo($this->lng->txt("tst_no_question_selected_for_removal"), true);
02671                         $this->ctrl->redirect($this, "questions");
02672                 }
02673         }
02674         
02682         function moveQuestionsObject()
02683         {
02684                 $this->questionsObject();
02685         }
02686         
02694         function insertQuestionsBeforeObject()
02695         {
02696                 // get all questions to move
02697                 $move_questions = array();
02698                 foreach ($_POST as $key => $value)
02699                 {
02700                         if (preg_match("/^move_(\d+)$/", $key, $matches))
02701                         {
02702                                 array_push($move_questions, $value);
02703                         }
02704                 }
02705                 // get insert point
02706                 $insert_id = -1;
02707                 foreach ($_POST as $key => $value)
02708                 {
02709                         if (preg_match("/^cb_(\d+)$/", $key, $matches))
02710                         {
02711                                 if ($insert_id < 0)
02712                                 {
02713                                         $insert_id = $matches[1];
02714                                 }
02715                         }
02716                 }
02717                 if ($insert_id <= 0)
02718                 {
02719                         sendInfo($this->lng->txt("no_target_selected_for_move"), true);
02720                 }
02721                 else
02722                 {
02723                         $insert_mode = 0;
02724                         $this->object->moveQuestions($move_questions, $insert_id, $insert_mode);
02725                 }
02726                 $this->ctrl->redirect($this, "questions");
02727         }
02728         
02736         function insertQuestionsAfterObject()
02737         {
02738                 // get all questions to move
02739                 $move_questions = array();
02740                 foreach ($_POST as $key => $value)
02741                 {
02742                         if (preg_match("/^move_(\d+)$/", $key, $matches))
02743                         {
02744                                 array_push($move_questions, $value);
02745                         }
02746                 }
02747                 // get insert point
02748                 $insert_id = -1;
02749                 foreach ($_POST as $key => $value)
02750                 {
02751                         if (preg_match("/^cb_(\d+)$/", $key, $matches))
02752                         {
02753                                 if ($insert_id < 0)
02754                                 {
02755                                         $insert_id = $matches[1];
02756                                 }
02757                         }
02758                 }
02759                 if ($insert_id <= 0)
02760                 {
02761                         sendInfo($this->lng->txt("no_target_selected_for_move"), true);
02762                 }
02763                 else
02764                 {
02765                         $insert_mode = 1;
02766                         $this->object->moveQuestions($move_questions, $insert_id, $insert_mode);
02767                 }
02768                 $this->ctrl->redirect($this, "questions");
02769         }
02770         
02771         function questionsObject()
02772         {
02773                 global $ilAccess;
02774 
02775                 if (!$ilAccess->checkAccess("write", "", $this->ref_id)) 
02776                 {
02777                         // allow write access
02778                         sendInfo($this->lng->txt("cannot_edit_test"), true);
02779                         $this->ctrl->redirect($this, "infoScreen");
02780                 }
02781 
02782                 if ($this->object->isRandomTest())
02783                 {
02784                         $this->randomQuestionsObject();
02785                         return;
02786                 }
02787                 
02788                 if ($_GET["eqid"] and $_GET["eqpl"])
02789                 {
02790                         ilUtil::redirect("ilias.php?baseClass=ilObjQuestionPoolGUI&ref_id=" . $_GET["eqpl"] . "&cmd=editQuestionForTest&calling_test=".$_GET["ref_id"]."&q_id=" . $_GET["eqid"]);
02791                 }
02792                 
02793                 if ($_GET["up"] > 0)
02794                 {
02795                         $this->object->questionMoveUp($_GET["up"]);
02796                 }
02797                 if ($_GET["down"] > 0)
02798                 {
02799                         $this->object->questionMoveDown($_GET["down"]);
02800                 }
02801 
02802                 if ($_GET["add"])
02803                 {
02804                         $selected_array = array();
02805                         array_push($selected_array, $_GET["add"]);
02806                         $total = $this->object->evalTotalPersons();
02807                         if ($total)
02808                         {
02809                                 // the test was executed previously
02810                                 sendInfo(sprintf($this->lng->txt("tst_insert_questions_and_results"), $total));
02811                         }
02812                         else
02813                         {
02814                                 sendInfo($this->lng->txt("tst_insert_questions"));
02815                         }
02816                         $this->insertQuestions($selected_array);
02817                         return;
02818                 }
02819 
02820                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_questions.html", true);
02821                 $this->tpl->addBlockFile("A_BUTTONS", "question_buttons", "tpl.il_as_tst_question_buttons.html", true);
02822 
02823                 if (strcmp($this->ctrl->getCmd(), "moveQuestions") == 0)
02824                 {
02825                         $checked_move = 0;
02826                         foreach ($_POST as $key => $value)
02827                         {
02828                                 if (preg_match("/cb_(\d+)/", $key, $matches))
02829                                 {
02830                                         $checked_move++;
02831                                         $this->tpl->setCurrentBlock("move");
02832                                         $this->tpl->setVariable("MOVE_COUNTER", $matches[1]);
02833                                         $this->tpl->setVariable("MOVE_VALUE", $matches[1]);
02834                                         $this->tpl->parseCurrentBlock();
02835                                 }
02836                         }
02837                         if ($checked_move)
02838                         {
02839                                 sendInfo($this->lng->txt("select_target_position_for_move_question"));
02840                                 $this->tpl->setCurrentBlock("move_buttons");
02841                                 $this->tpl->setVariable("INSERT_BEFORE", $this->lng->txt("insert_before"));
02842                                 $this->tpl->setVariable("INSERT_AFTER", $this->lng->txt("insert_after"));
02843                                 $this->tpl->parseCurrentBlock();
02844                         }
02845                         else
02846                         {
02847                                 sendInfo($this->lng->txt("no_question_selected_for_move"));
02848                         }
02849                 }
02850                 
02851                 $testquestions =& $this->object->getTestQuestions();
02852                 $colors = array("tblrow1", "tblrow2");
02853                 $counter = 0;
02854                 //$questionpools =& $this->object->get_qpl_titles();
02855                 $questionpools = array();
02856                 $total = $this->object->evalTotalPersons();
02857                 if (count($testquestions) > 0)
02858                 {
02859                         foreach ($testquestions as $data)
02860                         {
02861                                 if (!array_key_exists($data->obj_fi, $questionpools))
02862                                 {
02863                                         $pooltitle = $this->object->_lookupTitle($data["obj_fi"]);
02864                                         $questionpools[$data["obj_fi"]] = $pooltitle;
02865                                 }
02866                                 $this->tpl->setCurrentBlock("QTab");
02867                                 $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
02868                                 if (($ilAccess->checkAccess("write", "", $this->ref_id) and ($total == 0))) 
02869                                 {
02870                                         $q_id = $data["question_id"];
02871                                         $qpl_ref_id = $this->object->_getRefIdFromObjId($data["obj_fi"]);
02872                                         $this->tpl->setVariable("QUESTION_TITLE", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&eqid=$q_id&eqpl=$qpl_ref_id" . "\">" . $data["title"] . "</a>");
02873                                 } else {
02874                                         $this->tpl->setVariable("QUESTION_TITLE", $data["title"]);
02875                                 }
02876                                 $this->tpl->setVariable("QUESTION_SEQUENCE", $this->lng->txt("tst_sequence"));
02877 
02878                                 if (($ilAccess->checkAccess("write", "", $this->ref_id) and ($total == 0))) 
02879                                 {
02880                                         if ($data["question_id"] != $this->object->questions[1])
02881                                         {
02882                                                 $this->tpl->setVariable("BUTTON_UP", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&up=".$data["question_id"]."\"><img src=\"" . ilUtil::getImagePath("a_up.gif") . "\" alt=\"" . $this->lng->txt("up") . "\" border=\"0\" /></a>");
02883                                         }
02884                                         if ($data["question_id"] != $this->object->questions[count($this->object->questions)])
02885                                         {
02886                                                 $this->tpl->setVariable("BUTTON_DOWN", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&down=".$data["question_id"]."\"><img src=\"" . ilUtil::getImagePath("a_down.gif") . "\" alt=\"" . $this->lng->txt("down") . "\" border=\"0\" /></a>");
02887                                         }
02888                                 }
02889                                 $this->tpl->setVariable("QUESTION_COMMENT", $data["comment"]);
02890                                 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($data["type_tag"]));
02891                                 $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]);
02892                                 $this->tpl->setVariable("QUESTION_POOL", $questionpools[$data["obj_fi"]]);
02893                                 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
02894                                 $this->tpl->parseCurrentBlock();
02895                                 $counter++;
02896                         }
02897                 }
02898                 if ($counter == 0) 
02899                 {
02900                         $this->tpl->setCurrentBlock("Emptytable");
02901                         $this->tpl->setVariable("TEXT_EMPTYTABLE", $this->lng->txt("tst_no_questions_available"));
02902                         $this->tpl->parseCurrentBlock();
02903                 } 
02904                 else 
02905                 {
02906                         if (($ilAccess->checkAccess("write", "", $this->ref_id) and ($total == 0))) 
02907                         {
02908                                 $this->tpl->setCurrentBlock("selectall");
02909                                 $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
02910                                 $counter++;
02911                                 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
02912                                 $this->tpl->parseCurrentBlock();
02913                                 $this->tpl->setCurrentBlock("QFooter");
02914                                 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\"/>");
02915                                 $this->tpl->setVariable("REMOVE", $this->lng->txt("remove_question"));
02916                                 $this->tpl->setVariable("MOVE", $this->lng->txt("move"));
02917                                 $this->tpl->parseCurrentBlock();
02918                         }
02919                 }
02920 
02921                 if (($ilAccess->checkAccess("write", "", $this->ref_id) and ($total == 0))) 
02922                 {
02923                         global $ilUser;
02924                         $lastquestiontype = $ilUser->getPref("tst_lastquestiontype");
02925                         $this->tpl->setCurrentBlock("QTypes");
02926                         $question_types =& $this->object->_getQuestiontypes();
02927                         foreach ($question_types as $data)
02928                         {
02929                                 if ($data["question_type_id"] == $lastquestiontype)
02930                                 {
02931                                         $this->tpl->setVariable("QUESTION_TYPE_SELECTED", " selected=\"selected\"");
02932                                 }
02933                                 $this->tpl->setVariable("QUESTION_TYPE_ID", $data["type_tag"]);
02934                                 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($data["type_tag"]));
02935                                 $this->tpl->parseCurrentBlock();
02936                         }
02937                         $this->tpl->parseCurrentBlock();
02938                 }
02939                 $this->tpl->setCurrentBlock("adm_content");
02940                 $this->tpl->setVariable("ACTION_QUESTION_FORM", $this->ctrl->getFormAction($this));
02941                 $this->tpl->setVariable("QUESTION_TITLE", $this->lng->txt("tst_question_title"));
02942                 $this->tpl->setVariable("QUESTION_COMMENT", $this->lng->txt("description"));
02943                 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("tst_question_type"));
02944                 $this->tpl->setVariable("QUESTION_AUTHOR", $this->lng->txt("author"));
02945                 $this->tpl->setVariable("QUESTION_POOL", $this->lng->txt("qpl"));
02946 
02947                 if (($ilAccess->checkAccess("write", "", $this->ref_id) and ($total == 0))) 
02948                 {
02949                         $this->tpl->setVariable("BUTTON_INSERT_QUESTION", $this->lng->txt("tst_browse_for_questions"));
02950                         $this->tpl->setVariable("TEXT_CREATE_NEW", " " . strtolower($this->lng->txt("or")) . " " . $this->lng->txt("create_new"));
02951                         $this->tpl->setVariable("BUTTON_CREATE_QUESTION", $this->lng->txt("create"));
02952                         $this->tpl->setVariable("TXT_OR", $this->lng->txt("or"));
02953                         $this->tpl->setVariable("TEXT_RANDOM_SELECT", $this->lng->txt("random_selection"));
02954                 }
02955 
02956                 $this->tpl->parseCurrentBlock();
02957         }
02958 
02959         function takenObject() {
02960         }
02961         
02969         function addMarkStepObject()
02970         {
02971                 $this->saveMarkSchemaFormData();
02972                 $this->object->mark_schema->addMarkStep();
02973                 $this->marksObject();
02974         }
02975 
02983         function saveMarkSchemaFormData()
02984         {
02985                 $this->object->mark_schema->flush();
02986                 foreach ($_POST as $key => $value) {
02987                         if (preg_match("/mark_short_(\d+)/", $key, $matches)) {
02988                                 $this->object->mark_schema->addMarkStep($_POST["mark_short_$matches[1]"], $_POST["mark_official_$matches[1]"], $_POST["mark_percentage_$matches[1]"], $_POST["passed_$matches[1]"]);
02989                         }
02990                 }
02991                 $this->object->ects_grades["A"] = $_POST["ects_grade_a"];
02992                 $this->object->ects_grades["B"] = $_POST["ects_grade_b"];
02993                 $this->object->ects_grades["C"] = $_POST["ects_grade_c"];
02994                 $this->object->ects_grades["D"] = $_POST["ects_grade_d"];
02995                 $this->object->ects_grades["E"] = $_POST["ects_grade_e"];
02996                 if ($_POST["chbUseFX"])
02997                 {
02998                         $this->object->ects_fx = $_POST["percentFX"];
02999                 }
03000                 else
03001                 {
03002                         $this->object->ects_fx = "";
03003                 }
03004                 $this->object->ects_output = $_POST["chbECTS"];
03005         }
03006         
03014         function addSimpleMarkSchemaObject()
03015         {
03016                 $this->object->mark_schema->createSimpleSchema($this->lng->txt("failed_short"), $this->lng->txt("failed_official"), 0, 0, $this->lng->txt("passed_short"), $this->lng->txt("passed_official"), 50, 1);
03017                 $this->marksObject();
03018         }
03019         
03027         function deleteMarkStepsObject()
03028         {
03029                 $this->saveMarkSchemaFormData();
03030                 $delete_mark_steps = array();
03031                 foreach ($_POST as $key => $value) {
03032                         if (preg_match("/cb_(\d+)/", $key, $matches)) {
03033                                 array_push($delete_mark_steps, $matches[1]);
03034                         }
03035                 }
03036                 if (count($delete_mark_steps)) {
03037                         $this->object->mark_schema->deleteMarkSteps($delete_mark_steps);
03038                 } else {
03039                         sendInfo($this->lng->txt("tst_delete_missing_mark"));
03040                 }
03041                 $this->marksObject();
03042         }
03043 
03051         function cancelMarksObject()
03052         {
03053                 sendInfo($this->lng->txt("msg_cancel"), true);
03054                 $this->ctrl->redirect($this, "properties");
03055         }
03056         
03064         function saveMarksObject()
03065         {
03066                 $this->saveMarkSchemaFormData();
03067                 
03068                 $mark_check = $this->object->checkMarks();
03069                 if ($mark_check !== true)
03070                 {
03071                         sendInfo($this->lng->txt($mark_check));
03072                 }
03073                 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)))
03074                 {
03075                         sendInfo($this->lng->txt("ects_fill_out_all_values"), true);
03076                 }
03077                 elseif (($_POST["ects_grade_a"] > 100) or ($_POST["ects_grade_a"] < 0))
03078                 {
03079                         sendInfo($this->lng->txt("ects_range_error_a"), true);
03080                 }
03081                 elseif (($_POST["ects_grade_b"] > 100) or ($_POST["ects_grade_b"] < 0))
03082                 {
03083                         sendInfo($this->lng->txt("ects_range_error_b"), true);
03084                 }
03085                 elseif (($_POST["ects_grade_c"] > 100) or ($_POST["ects_grade_c"] < 0))
03086                 {
03087                         sendInfo($this->lng->txt("ects_range_error_c"), true);
03088                 }
03089                 elseif (($_POST["ects_grade_d"] > 100) or ($_POST["ects_grade_d"] < 0))
03090                 {
03091                         sendInfo($this->lng->txt("ects_range_error_d"), true);
03092                 }
03093                 elseif (($_POST["ects_grade_e"] > 100) or ($_POST["ects_grade_e"] < 0))
03094                 {
03095                         sendInfo($this->lng->txt("ects_range_error_e"), true);
03096                 }
03097                 else 
03098                 {
03099                         $this->object->mark_schema->saveToDb($this->object->getTestId());
03100                         $this->object->saveCompleteStatus();
03101                         if ($this->object->getReportingDate())
03102                         {
03103                                 $fxpercent = "";
03104                                 if ($_POST["chbUseFX"])
03105                                 {
03106                                         $fxpercent = ilUtil::stripSlashes($_POST["percentFX"]);
03107                                 }
03108                                 $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"]);
03109                         }
03110                         sendInfo($this->lng->txt("msg_obj_modified"), true);
03111                 }
03112                 $this->marksObject();
03113         }
03114         
03115         function marksObject() 
03116         {
03117                 global $ilAccess;
03118                 if (!$ilAccess->checkAccess("write", "", $this->ref_id)) 
03119                 {
03120                         // allow only write access
03121                         sendInfo($this->lng->txt("cannot_edit_test"), true);
03122                         $this->ctrl->redirect($this, "infoScreen");
03123                 }
03124 
03125 
03126                 if (!$this->object->canEditMarks())
03127                 {
03128                         sendInfo($this->lng->txt("cannot_edit_marks"));
03129                 }
03130                 
03131                 $this->object->mark_schema->sort();
03132         
03133                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_marks.html", true);
03134                 $marks = $this->object->mark_schema->mark_steps;
03135                 $rows = array("tblrow1", "tblrow2");
03136                 $counter = 0;
03137                 foreach ($marks as $key => $value) {
03138                         $this->tpl->setCurrentBlock("markrow");
03139                         $this->tpl->setVariable("MARK_SHORT", $value->getShortName());
03140                         $this->tpl->setVariable("MARK_OFFICIAL", $value->getOfficialName());
03141                         $this->tpl->setVariable("MARK_PERCENTAGE", sprintf("%.2f", $value->getMinimumLevel()));
03142                         $this->tpl->setVariable("MARK_PASSED", strtolower($this->lng->txt("tst_mark_passed")));
03143                         $this->tpl->setVariable("MARK_ID", "$key");
03144                         $this->tpl->setVariable("ROW_CLASS", $rows[$counter % 2]);
03145                         if ($value->getPassed()) {
03146                                 $this->tpl->setVariable("MARK_PASSED_CHECKED", " checked=\"checked\"");
03147                         }
03148                         $this->tpl->parseCurrentBlock();
03149                         $counter++;
03150                 }
03151                 if (count($marks) == 0) 
03152                 {
03153                         $this->tpl->setCurrentBlock("Emptyrow");
03154                         $this->tpl->setVariable("EMPTY_ROW", $this->lng->txt("tst_no_marks_defined"));
03155                         $this->tpl->setVariable("ROW_CLASS", $rows[$counter % 2]);
03156                         $this->tpl->parseCurrentBlock();
03157                 } 
03158                 else 
03159                 {
03160                         if ($ilAccess->checkAccess("write", "", $this->ref_id) && $this->object->canEditMarks()) 
03161                         {
03162                                 $this->tpl->setCurrentBlock("selectall");
03163                                 $counter++;
03164                                 $this->tpl->setVariable("ROW_CLASS", $rows[$counter % 2]);
03165                                 $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
03166                                 $this->tpl->parseCurrentBlock();
03167                                 $this->tpl->setCurrentBlock("Footer");
03168                                 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\"/>");
03169                                 $this->tpl->setVariable("BUTTON_EDIT", $this->lng->txt("edit"));
03170                                 $this->tpl->setVariable("BUTTON_DELETE", $this->lng->txt("delete"));
03171                                 $this->tpl->parseCurrentBlock();
03172                         }
03173                 }
03174                 
03175                 if ($this->object->getReportingDate())
03176                 {
03177                         $this->tpl->setCurrentBlock("ects");
03178                         if ($this->object->ects_output)
03179                         {
03180                                 $this->tpl->setVariable("CHECKED_ECTS", " checked=\"checked\"");
03181                         }
03182                         $this->tpl->setVariable("TEXT_OUTPUT_ECTS_GRADES", $this->lng->txt("ects_output_of_ects_grades"));
03183                         $this->tpl->setVariable("TEXT_ALLOW_ECTS_GRADES", $this->lng->txt("ects_allow_ects_grades"));
03184                         $this->tpl->setVariable("TEXT_USE_FX", $this->lng->txt("ects_use_fx_grade"));
03185                         if (preg_match("/\d+/", $this->object->ects_fx))
03186                         {
03187                                 $this->tpl->setVariable("CHECKED_FX", " checked=\"checked\"");
03188                                 $this->tpl->setVariable("VALUE_PERCENT_FX", sprintf("value=\"%s\" ", $this->object->ects_fx));
03189                         }
03190                         $this->tpl->setVariable("TEXT_PERCENT", $this->lng->txt("ects_use_fx_grade_part2"));
03191                         $this->tpl->setVariable("ECTS_GRADE", $this->lng->txt("ects_grade"));
03192                         $this->tpl->setVariable("PERCENTILE", $this->lng->txt("percentile"));
03193                         $this->tpl->setVariable("ECTS_GRADE_A", "A - " . $this->lng->txt("ects_grade_a_short"));
03194                         $this->tpl->setVariable("VALUE_GRADE_A", $this->object->ects_grades["A"]);
03195                         $this->tpl->setVariable("ECTS_GRADE_B", "B - " . $this->lng->txt("ects_grade_b_short"));
03196                         $this->tpl->setVariable("VALUE_GRADE_B", $this->object->ects_grades["B"]);
03197                         $this->tpl->setVariable("ECTS_GRADE_C", "C - " . $this->lng->txt("ects_grade_c_short"));
03198                         $this->tpl->setVariable("VALUE_GRADE_C", $this->object->ects_grades["C"]);
03199                         $this->tpl->setVariable("ECTS_GRADE_D", "D - " . $this->lng->txt("ects_grade_d_short"));
03200                         $this->tpl->setVariable("VALUE_GRADE_D", $this->object->ects_grades["D"]);
03201                         $this->tpl->setVariable("ECTS_GRADE_E", "E - " . $this->lng->txt("ects_grade_e_short"));
03202                         $this->tpl->setVariable("VALUE_GRADE_E", $this->object->ects_grades["E"]);
03203                         
03204                         $this->tpl->parseCurrentBlock();
03205                 }
03206 
03207                 $this->tpl->setCurrentBlock("adm_content");
03208                 $this->tpl->setVariable("ACTION_MARKS", $this->ctrl->getFormAction($this));
03209                 $this->tpl->setVariable("HEADER_SHORT", $this->lng->txt("tst_mark_short_form"));
03210                 $this->tpl->setVariable("HEADER_OFFICIAL", $this->lng->txt("tst_mark_official_form"));
03211                 $this->tpl->setVariable("HEADER_PERCENTAGE", $this->lng->txt("tst_mark_minimum_level"));
03212                 $this->tpl->setVariable("HEADER_PASSED", $this->lng->txt("tst_mark_passed"));
03213                 if ($ilAccess->checkAccess("write", "", $this->ref_id) && $this->object->canEditMarks()) 
03214                 {
03215                         $this->tpl->setVariable("BUTTON_NEW", $this->lng->txt("tst_mark_create_new_mark_step"));
03216                         $this->tpl->setVariable("BUTTON_NEW_SIMPLE", $this->lng->txt("tst_mark_create_simple_mark_schema"));
03217                         $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
03218                         $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
03219                 }
03220                 $this->tpl->parseCurrentBlock();
03221         }
03222 
03230         function confirmDeleteAllUserDataObject()
03231         {
03232                 $this->object->removeAllTestEditings();
03233                 sendInfo($this->lng->txt("tst_all_user_data_deleted"), true);
03234                 $this->ctrl->redirect($this, "maintenance");
03235         }
03236         
03244         function cancelDeleteAllUserDataObject()
03245         {
03246                 $this->ctrl->redirect($this, "maintenance");
03247         }
03248 
03256         function confirmDeleteSelectedUserDataObject()
03257         {
03258                 $this->object->removeSelectedTestResults($_POST["chbUser"]);
03259                 sendInfo($this->lng->txt("tst_selected_user_data_deleted"), true);
03260                 $this->ctrl->redirect($this, "maintenance");
03261         }
03262         
03270         function cancelDeleteSelectedUserDataObject()
03271         {
03272                 $this->ctrl->redirect($this, "maintenance");
03273         }
03274         
03282         function deleteAllUserDataObject()
03283         {
03284                 sendInfo($this->lng->txt("confirm_delete_all_user_data"));
03285                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_maintenance.html", true);
03286 
03287                 $this->tpl->setCurrentBlock("confirm_delete");
03288                 $this->tpl->setVariable("BTN_CONFIRM_DELETE_ALL", $this->lng->txt("confirm"));
03289                 $this->tpl->setVariable("BTN_CANCEL_DELETE_ALL", $this->lng->txt("cancel"));
03290                 $this->tpl->parseCurrentBlock();
03291 
03292                 $this->tpl->setCurrentBlock("adm_content");
03293                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
03294                 $this->tpl->parseCurrentBlock();
03295         }
03296         
03304         function deleteSingleUserResultsObject()
03305         {
03306                 if (count($_POST["chbUser"]) == 0)
03307                 {
03308                         $this->ctrl->redirect($this, "maintenance");
03309                 }
03310                 sendInfo($this->lng->txt("confirm_delete_single_user_data"));
03311                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_maintenance.html", true);
03312 
03313                 foreach ($_POST["chbUser"] as $key => $value)
03314                 {
03315                         $this->tpl->setCurrentBlock("hidden");
03316                         $this->tpl->setVariable("USER_ID", $value);
03317                         $this->tpl->parseCurrentBlock();
03318                 }
03319                 
03320                 include_once "./classes/class.ilObjUser.php";
03321                 $color_class = array("tblrow1", "tblrow2");
03322                 $counter = 0;
03323                 foreach ($_POST["chbUser"] as $key => $value)
03324                 {
03325                         $user_id = $this->object->_getUserIdFromActiveId($value);
03326                         $user = ilObjUser::_lookupName($user_id);
03327                         $this->tpl->setCurrentBlock("row");
03328                         $this->tpl->setVariable("USER_ICON", ilUtil::getImagePath("icon_usr.gif"));
03329                         $this->tpl->setVariable("USER_ALT", $this->lng->txt("usr"));
03330                         $this->tpl->setVariable("USER_TITLE", $this->lng->txt("usr"));
03331                         if ($this->object->getTestType() == TYPE_SELF_ASSESSMENT)
03332                         {
03333                                 $this->tpl->setVariable("TXT_FIRSTNAME", "");
03334                                 $this->tpl->setVariable("TXT_LASTNAME", $this->lng->txt("anonymous"));
03335                                 $this->tpl->setVariable("TXT_LOGIN", "");
03336                         }
03337                         else
03338                         {
03339                                 $this->tpl->setVariable("TXT_FIRSTNAME", $user["firstname"]);
03340                                 if (strlen($user["lastname"]))
03341                                 {
03342                                         $this->tpl->setVariable("TXT_LASTNAME", $user["lastname"]);
03343                                 }
03344                                 else
03345                                 {
03346                                         $this->tpl->setVariable("TXT_LASTNAME", $this->lng->txt("deleted_user"));
03347                                 }
03348                                 $this->tpl->setVariable("TXT_LOGIN", ilObjUser::_lookupLogin($user_id));
03349                         }
03350                         $this->tpl->setVariable("ROW_CLASS", $color_class[$counter % 2]);
03351                         $this->tpl->parseCurrentBlock();
03352                         $counter++;
03353                 }
03354                 $this->tpl->setCurrentBlock("selectedusers");
03355                 $this->tpl->setVariable("HEADER_TXT_FIRSTNAME", $this->lng->txt("firstname"));
03356                 $this->tpl->setVariable("HEADER_TXT_LASTNAME", $this->lng->txt("lastname"));
03357                 $this->tpl->setVariable("HEADER_TXT_LOGIN", $this->lng->txt("login"));
03358                 $this->tpl->setVariable("BTN_CONFIRM_DELETE_SELECTED", $this->lng->txt("confirm"));
03359                 $this->tpl->setVariable("BTN_CANCEL_DELETE_SELECTED", $this->lng->txt("cancel"));
03360                 $this->tpl->parseCurrentBlock();
03361 
03362                 $this->tpl->setCurrentBlock("adm_content");
03363                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
03364                 $this->tpl->parseCurrentBlock();
03365         }
03366         
03374         function maintenanceObject()
03375         {
03376                 global $ilAccess;
03377                 if (!$ilAccess->checkAccess("write", "", $this->ref_id)) 
03378                 {
03379                         // allow only write access
03380                         sendInfo($this->lng->txt("cannot_edit_test"), true);
03381                         $this->ctrl->redirect($this, "infoScreen");
03382                 }
03383 
03384                 
03385                 if ($ilAccess->checkAccess("write", "", $this->ref_id)) 
03386                 {
03387                         $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_maintenance.html", true);
03388                         $total =& $this->object->evalTotalParticipantsArray();
03389                         if (count($total))
03390                         {
03391                                 $color_class = array("tblrow1", "tblrow2");
03392                                 $counter = 0;
03393                                 foreach ($total as $active_id => $user_data)
03394                                 {
03395                                         $user_name = $user_data["name"];
03396                                         $user_login = $user_data["login"];
03397                                         $this->tpl->setCurrentBlock("userrow");
03398                                         $this->tpl->setVariable("ROW_CLASS", $color_class[$counter % 2]);
03399                                         $this->tpl->setVariable("USER_ID", $active_id);
03400                                         $this->tpl->setVariable("VALUE_USER_NAME", $user_name);
03401                                         $this->tpl->setVariable("VALUE_USER_LOGIN", $user_login);
03402                                         $last_access = $this->object->_getLastAccess($active_id);
03403                                         $this->tpl->setVariable("LAST_ACCESS", ilFormat::formatDate($last_access));
03404                                         $this->tpl->parseCurrentBlock();
03405                                         $counter++;
03406                                 }
03407                                 $this->tpl->setCurrentBlock("selectall");
03408                                 $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
03409                                 $counter++;
03410                                 $this->tpl->setVariable("ROW_CLASS", $color_class[$counter % 2]);
03411                                 $this->tpl->parseCurrentBlock();
03412                                 $this->tpl->setCurrentBlock("participanttable");
03413                                 $this->tpl->setVariable("USER_NAME", $this->lng->txt("name"));
03414                                 $this->tpl->setVariable("USER_LOGIN", $this->lng->txt("login"));
03415                                 $this->tpl->setVariable("LAST_ACCESS", $this->lng->txt("last_access"));
03416                                 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
03417                                 $this->tpl->setVariable("DELETE", $this->lng->txt("delete_user_data"));
03418                                 $this->tpl->parseCurrentBlock();
03419 
03420                                 $this->tpl->setCurrentBlock("adm_content");
03421                                 $this->tpl->setVariable("BTN_DELETE_ALL", $this->lng->txt("tst_delete_all_user_data"));
03422         //                      $this->tpl->setVariable("BTN_CREATE_SOLUTIONS", $this->lng->txt("tst_create_solutions"));
03423                                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
03424                                 $this->tpl->parseCurrentBlock();
03425                         }
03426                         else
03427                         {
03428                                 $this->tpl->setCurrentBlock("maintenance_information");
03429                                 $this->tpl->setVariable("MAINTENANCE_INFORMATION", $this->lng->txt("tst_maintenance_information_no_results"));
03430                                 $this->tpl->parseCurrentBlock();
03431                         }
03432                 }
03433                 else
03434                 {
03435                         sendInfo($this->lng->txt("cannot_maintain_test"));
03436                 }
03437         }       
03438 
03446         function statusObject()
03447         {
03448                 global $ilAccess;
03449                 if (!$ilAccess->checkAccess("write", "", $this->ref_id)) 
03450                 {
03451                         // allow only write access
03452                         sendInfo($this->lng->txt("cannot_edit_test"), true);
03453                         $this->ctrl->redirect($this, "infoScreen");
03454                 }
03455 
03456                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_status.html", true);
03457                 if (!$this->object->isComplete())
03458                 {
03459                         if (!$this->object->isRandomTest())
03460                         {
03461                                 if (count($this->object->questions) == 0)
03462                                 {
03463                                         $this->tpl->setCurrentBlock("list_element");
03464                                         $this->tpl->setVariable("TEXT_ELEMENT", $this->lng->txt("tst_missing_questions"));
03465                                         $this->tpl->parseCurrentBlock();
03466                                 }
03467                         }
03468                         if (count($this->object->mark_schema->mark_steps) == 0)
03469                         {
03470                                 $this->tpl->setCurrentBlock("list_element");
03471                                 $this->tpl->setVariable("TEXT_ELEMENT", $this->lng->txt("tst_missing_marks"));
03472                                 $this->tpl->parseCurrentBlock();
03473                         }
03474                         if (strcmp($this->object->author, "") == 0)
03475                         {
03476                                 $this->tpl->setCurrentBlock("list_element");
03477                                 $this->tpl->setVariable("TEXT_ELEMENT", $this->lng->txt("tst_missing_author"));
03478                                 $this->tpl->parseCurrentBlock();
03479                         }
03480                         if (strcmp($this->object->title, "") == 0)
03481                         {
03482                                 $this->tpl->setCurrentBlock("list_element");
03483                                 $this->tpl->setVariable("TEXT_ELEMENT", $this->lng->txt("tst_missing_author"));
03484                                 $this->tpl->parseCurrentBlock();
03485                         }
03486                         
03487                         if ($this->object->isRandomTest())
03488                         {
03489                                 $arr = $this->object->getRandomQuestionpools();
03490                                 if (count($arr) == 0)
03491                                 {
03492                                         $this->tpl->setCurrentBlock("list_element");
03493                                         $this->tpl->setVariable("TEXT_ELEMENT", $this->lng->txt("tst_no_questionpools_for_random_test"));
03494                                         $this->tpl->parseCurrentBlock();
03495                                 }
03496                                 $count = 0;
03497                                 foreach ($arr as $array)
03498                                 {
03499                                         $count += $array["count"];
03500                                 }
03501                                 if (($count == 0) && ($this->object->getRandomQuestionCount() == 0))
03502                                 {
03503                                         $this->tpl->setCurrentBlock("list_element");
03504                                         $this->tpl->setVariable("TEXT_ELEMENT", $this->lng->txt("tst_no_questions_for_random_test"));
03505                                         $this->tpl->parseCurrentBlock();
03506                                 }
03507                         }
03508                         
03509                         $this->tpl->setCurrentBlock("status_list");
03510                         $this->tpl->setVariable("TEXT_MISSING_ELEMENTS", $this->lng->txt("tst_status_missing_elements"));
03511                         $this->tpl->parseCurrentBlock();
03512                 }
03513                 $total = $this->object->evalTotalPersons();
03514                 if ($total > 0)
03515                 {
03516                         $this->tpl->setCurrentBlock("list_element");
03517                         $this->tpl->setVariable("TEXT_ELEMENT", sprintf($this->lng->txt("tst_in_use_edit_questions_disabled"), $total));
03518                         $this->tpl->parseCurrentBlock();
03519                 }
03520                 
03521                 if ($ilAccess->checkAccess("write", "", $this->ref_id))
03522                 {
03523                         include_once "./classes/class.ilObjAssessmentFolder.php";
03524                         $log =& ilObjAssessmentFolder::_getLog("19700101000000", strftime("%Y%m%d%H%M%S"), $this->object->getId(), TRUE);
03525                         if (count($log))
03526                         {
03527                                 $tblrow = array("tblrow1", "tblrow2");
03528                                 $counter = 0;
03529                                 include_once "./classes/class.ilObjUser.php";
03530                                 foreach ($log as $entry)
03531                                 {
03532                                         $this->tpl->setCurrentBlock("changelog_row");
03533                                         $this->tpl->setVariable("ROW_CLASS", $tblrow[$counter % 2]);
03534                                         $user = ilObjUser::_lookupName($entry["user_fi"]);
03535                                         $this->tpl->setVariable("TXT_USER", trim($user["title"] . " " . $user["firstname"] . " " . $user["lastname"]));
03536                                         $this->tpl->setVariable("TXT_DATETIME", ilFormat::formatDate(ilFormat::ftimestamp2datetimeDB($entry["TIMESTAMP14"]), "datetime"));
03537                                         if (strlen($entry["ref_id"]) && strlen($entry["href"]))
03538                                         {
03539                                                 $this->tpl->setVariable("TXT_TEST_REFERENCE", $entry["ref_id"]);
03540                                                 $this->tpl->setVariable("HREF_REFERENCE", $entry["href"]);
03541                                         }
03542                                         $this->tpl->setVariable("TXT_LOGTEXT", trim(ilUtil::prepareFormOutput($entry["logtext"])));
03543                                         $this->tpl->parseCurrentBlock();
03544                                         $counter++;
03545                                 }
03546                                 $this->tpl->setCurrentBlock("changelog");
03547                                 $this->tpl->setVariable("HEADER_DATETIME", $this->lng->txt("assessment_log_datetime"));
03548                                 $this->tpl->setVariable("HEADER_USER", $this->lng->txt("user"));
03549                                 $this->tpl->setVariable("HEADER_LOGTEXT", $this->lng->txt("assessment_log_text"));
03550                                 $this->tpl->setVariable("HEADER_TEST_REFERENCE", $this->lng->txt("test_reference"));
03551                                 $this->tpl->setVariable("HEADING_CHANGELOG", $this->lng->txt("changelog_heading"));
03552                                 $this->tpl->setVariable("DESCRIPTION_CHANGELOG", $this->lng->txt("changelog_description"));
03553                                 $this->tpl->parseCurrentBlock();
03554                         }
03555                 }
03556                 
03557                 $this->tpl->setCurrentBlock("adm_content");
03558                 if ($this->object->isComplete())
03559                 {
03560                         $this->tpl->setVariable("TEXT_STATUS_MESSAGE", $this->lng->txt("tst_status_ok"));
03561                         $this->tpl->setVariable("STATUS_CLASS", "bold");
03562                 }
03563                 else
03564                 {
03565                         $this->tpl->setVariable("TEXT_STATUS_MESSAGE", $this->lng->txt("tst_status_missing"));
03566                         $this->tpl->setVariable("STATUS_CLASS", "warning");
03567                 }
03568                 $this->tpl->parseCurrentBlock();
03569         }       
03570 
03574         function createObject()
03575         {
03576                 global $rbacsystem;
03577                 $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
03578                 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
03579                 {
03580                         $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
03581                 }
03582                 else
03583                 {
03584                         $this->getTemplateFile("create", $new_type);
03585 
03586                         include_once("./assessment/classes/class.ilObjTest.php");
03587                         $tst = new ilObjTest();
03588                         
03589                         $tests =& ilObjTest::_getAvailableTests(true);
03590                         if (count($tests) > 0)
03591                         {
03592                                 foreach ($tests as $key => $value)
03593                                 {
03594                                         $this->tpl->setCurrentBlock("option_tst");
03595                                         $this->tpl->setVariable("OPTION_VALUE_TST", $key);
03596                                         $this->tpl->setVariable("TXT_OPTION_TST", $value);
03597                                         if ($_POST["tst"] == $key)
03598                                         {
03599                                                 $this->tpl->setVariable("OPTION_SELECTED_TST", " selected=\"selected\"");                               
03600                                         }
03601                                         $this->tpl->parseCurrentBlock();
03602                                 }
03603                         }
03604                         
03605                         $questionpools =& $tst->getAvailableQuestionpools($use_object_id = true, $equal_points = false, $could_be_offline = true);
03606                         if (count($questionpools) == 0)
03607                         {
03608                         }
03609                         else
03610                         {
03611                                 foreach ($questionpools as $key => $value)
03612                                 {
03613                                         $this->tpl->setCurrentBlock("option_qpl");
03614                                         $this->tpl->setVariable("OPTION_VALUE", $key);
03615                                         $this->tpl->setVariable("TXT_OPTION", $value["title"]);
03616                                         if ($_POST["qpl"] == $key)
03617                                         {
03618                                                 $this->tpl->setVariable("OPTION_SELECTED", " selected=\"selected\"");                           
03619                                         }
03620                                         $this->tpl->parseCurrentBlock();
03621                                 }
03622                         }
03623                         // fill in saved values in case of error
03624                         $data = array();
03625                         $data["fields"] = array();
03626                         $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
03627                         $data["fields"]["desc"] = ilUtil::stripSlashes($_SESSION["error_post_vars"]["Fobject"]["desc"]);
03628 
03629                         foreach ($data["fields"] as $key => $val)
03630                         {
03631                                 $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
03632                                 $this->tpl->setVariable(strtoupper($key), $val);
03633 
03634                                 if ($this->prepare_output)
03635                                 {
03636                                         $this->tpl->parseCurrentBlock();
03637                                 }
03638                         }
03639 
03640                         $this->ctrl->setParameter($this, "new_type", $this->type);
03641                         $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
03642 //                      $this->tpl->setVariable("FORMACTION", $this->getFormAction("save","adm_object.php?cmd=gateway&ref_id=".
03643 //                                                                                                                                         $_GET["ref_id"]."&new_type=".$new_type));
03644                         $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
03645                         $this->tpl->setVariable("TXT_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool"));
03646                         $this->tpl->setVariable("OPTION_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool_option"));
03647                         $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
03648                         $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
03649                         $this->tpl->setVariable("CMD_SUBMIT", "save");
03650                         $this->tpl->setVariable("TARGET", ' target="'.
03651                                 ilFrameTargetInfo::_getFrame("MainContent").'" ');
03652                         $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
03653 
03654                         $this->tpl->setVariable("TXT_IMPORT_TST", $this->lng->txt("import_tst"));
03655                         $this->tpl->setVariable("TXT_TST_FILE", $this->lng->txt("tst_upload_file"));
03656                         $this->tpl->setVariable("TXT_IMPORT", $this->lng->txt("import"));
03657 
03658                         $this->tpl->setVariable("TXT_DUPLICATE_TST", $this->lng->txt("duplicate_tst"));
03659                         $this->tpl->setVariable("TXT_SELECT_TST", $this->lng->txt("obj_tst"));
03660                         $this->tpl->setVariable("OPTION_SELECT_TST", $this->lng->txt("select_tst_option"));
03661                         $this->tpl->setVariable("TXT_DUPLICATE", $this->lng->txt("duplicate"));
03662                         $this->tpl->setVariable("TYPE_IMG", ilUtil::getImagePath('icon_tst.gif'));
03663                         $this->tpl->setVariable("ALT_IMG",$this->lng->txt("obj_tst"));
03664                         $this->tpl->setVariable("TYPE_IMG2", ilUtil::getImagePath('icon_tst.gif'));
03665                         $this->tpl->setVariable("ALT_IMG2",$this->lng->txt("obj_tst"));
03666                         $this->tpl->setVariable("TYPE_IMG3", ilUtil::getImagePath('icon_tst.gif'));
03667                         $this->tpl->setVariable("ALT_IMG3",$this->lng->txt("obj_tst"));
03668                         $this->tpl->setVariable("NEW_TYPE", $this->type);
03669                         $this->tpl->parseCurrentBlock();
03670                 }
03671         }
03672 
03680         function participantsObject()
03681         {
03682                 global $ilAccess;
03683                 if (!$ilAccess->checkAccess("write", "", $this->ref_id)) 
03684                 {
03685                         // allow only write access
03686                         sendInfo($this->lng->txt("cannot_edit_test"), true);
03687                         $this->ctrl->redirect($this, "infoScreen");
03688                 }
03689 
03690                 
03691                 if ($this->object->getTestType() != TYPE_ONLINE_TEST) 
03692                 {
03693                         // allow only read and write access
03694                         sendInfo($this->lng->txt("tst_must_be_online_exam"), false);
03695                         return;
03696                 }
03697                 
03698                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_invite.html", true);
03699 
03700                 if ($_POST["cmd"]["cancel"])
03701                 {
03702                         $this->backToRepositoryObject();
03703                 }
03704 
03705                 if (strcmp($this->ctrl->getCmd(), "searchParticipants") == 0)
03706                 {
03707                         if (is_array($_POST["search_for"]))
03708                         {
03709                                 if (in_array("usr", $_POST["search_for"]) or in_array("grp", $_POST["search_for"]) or in_array("role", $_POST["search_for"]))
03710                                 {                                       
03711                                         
03712                                         include_once './classes/class.ilSearch.php';
03713                                         $search =& new ilSearch($ilUser->id);
03714                                         $search->setSearchString($_POST["search_term"]);
03715                                         $search->setCombination($_POST["concatenation"]);
03716                                         $search->setSearchFor($_POST["search_for"]);
03717                                         $search->setSearchType("new");
03718                                         if($search->validate($message))
03719                                         {
03720                                                 $search->performSearch();
03721                                         }
03722                                         if ($message)
03723                                         {
03724                                                 sendInfo($message);
03725                                         }
03726                                         
03727                                         if(!$search->getNumberOfResults() && $search->getSearchFor())
03728                                         {
03729                                                 sendInfo($this->lng->txt("search_no_match"));
03730                                                 return;
03731                                         }
03732                                         $buttons = array("add");
03733         
03734                                         $invited_users = $this->object->getInvitedUsers();
03735                                 
03736                                         if ($searchresult = $search->getResultByType("usr"))
03737                                         {                                                                                               
03738                                                 $users = array();
03739                                                 foreach ($searchresult as $result_array)
03740                                                 {
03741                                                         if (!array_key_exists($result_array["id"], $invited_users))
03742                                                         {                                                               
03743                                                                 array_push($users, $result_array["id"]);
03744                                                         }
03745                                                 }
03746                                                 
03747                                                 $users = $this->object->getUserData($users);
03748                                                 
03749                                                 if (count ($users))
03750                                                         $this->outUserGroupTable("usr", $users, "user_result", "user_row", $this->lng->txt("search_user"),"TEXT_USER_TITLE", $buttons);
03751                                         }
03752         
03753                                         $searchresult = array();
03754                                         
03755                                         if ($searchresult = $search->getResultByType("grp"))
03756                                         {
03757                                                 $groups = array();
03758                                                 
03759                                                 foreach ($searchresult as $result_array)
03760                                                 {                                                       
03761                                                         array_push($groups, $result_array["id"]);
03762                                                 }
03763                                                 $groups = $this->object->getGroupData ($groups);
03764                                                 
03765                                                 if (count ($groups))
03766                                                         $this->outUserGroupTable("grp", $groups, "group_result", "group_row", $this->lng->txt("search_group"), "TEXT_GROUP_TITLE", $buttons);
03767                                         }
03768                                         
03769                                         $searchresult = array();
03770                                         
03771                                         if ($searchresult = $search->getResultByType("role"))
03772                                         {
03773                                                 $roles = array();
03774                                                 
03775                                                 foreach ($searchresult as $result_array)
03776                                                 {                                                       
03777                                                         array_push($roles, $result_array["id"]);
03778                                                 }
03779                                                 
03780                                                 $roles = $this->object->getRoleData ($roles);                   
03781                                                                 
03782                                                 if (count ($roles))
03783                                                         $this->outUserGroupTable("role", $roles, "role_result", "role_row", $this->lng->txt("role"), "TEXT_ROLE_TITLE", $buttons);
03784                                         }
03785                                         
03786                                 }
03787                                 
03788                         }
03789                         else
03790                         {
03791                                 sendInfo($this->lng->txt("no_user_or_group_selected"));
03792                         }
03793                 }
03794                 
03795                 if ($_POST["cmd"]["save"])
03796                 {
03797                         $this->object->saveToDb();
03798                 }
03799                 
03800                 {
03801                         if ($ilAccess->checkAccess("write", "", $this->ref_id))
03802                         {
03803                                 $this->tpl->setCurrentBlock("invitation");
03804                                 $this->tpl->setVariable("SEARCH_INVITATION", $this->lng->txt("search"));
03805                                 $this->tpl->setVariable("SEARCH_TERM", $this->lng->txt("search_term"));
03806                                 $this->tpl->setVariable("SEARCH_FOR", $this->lng->txt("search_for"));
03807                                 $this->tpl->setVariable("SEARCH_USERS", $this->lng->txt("search_users"));
03808                                 $this->tpl->setVariable("SEARCH_GROUPS", $this->lng->txt("search_groups"));
03809                                 $this->tpl->setVariable("SEARCH_ROLES", $this->lng->txt("search_roles"));
03810                                 $this->tpl->setVariable("TEXT_CONCATENATION", $this->lng->txt("concatenation"));
03811                                 $this->tpl->setVariable("TEXT_AND", $this->lng->txt("and"));
03812                                 $this->tpl->setVariable("TEXT_OR", $this->lng->txt("or"));
03813                                 $this->tpl->setVariable("VALUE_SEARCH_TERM", $_POST["search_term"]);
03814                                 if (is_array($_POST["search_for"]))
03815                                 {
03816                                         if (in_array("usr", $_POST["search_for"]))
03817                                         {
03818                                                 $this->tpl->setVariable("CHECKED_USERS", " checked=\"checked\"");
03819                                         }
03820                                         if (in_array("grp", $_POST["search_for"]))
03821                                         {
03822                                                 $this->tpl->setVariable("CHECKED_GROUPS", " checked=\"checked\"");
03823                                         }
03824                                         if (in_array("role", $_POST["search_for"]))
03825                                         {
03826                                                 $this->tpl->setVariable("CHECKED_ROLES", " checked=\"checked\"");
03827                                         }
03828                                         
03829                                 }
03830                                 if (strcmp($_POST["concatenation"], "and") == 0)
03831                                 {
03832                                         $this->tpl->setVariable("CHECKED_AND", " checked=\"checked\"");
03833                                 }
03834                                 else if (strcmp($_POST["concatenation"], "or") == 0)
03835                                 {
03836                                         $this->tpl->setVariable("CHECKED_OR", " checked=\"checked\"");
03837                                 }
03838                                 $this->tpl->setVariable("SEARCH", $this->lng->txt("search"));
03839                                 $this->tpl->parseCurrentBlock();
03840                         }
03841                 }
03842                 $invited_users = $this->object->getInvitedUsers();
03843 
03844                 $buttons = array("save","remove","tst_show_answer_sheet","tst_show_results");
03845                 
03846                 if (count($invited_users))
03847                 {
03848                         $this->outUserGroupTable("iv_usr", $invited_users, "invited_user_result", "invited_user_row", $this->lng->txt("tst_participating_users"), "TEXT_INVITED_USER_TITLE",$buttons);
03849                 }
03850 
03851                 $this->tpl->setCurrentBlock("adm_content");
03852                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
03853                 $this->tpl->setVariable("TEXT_INVITATION", $this->lng->txt("invitation"));
03854                 $this->tpl->setVariable("VALUE_ON", $this->lng->txt("on"));
03855                 $this->tpl->setVariable("VALUE_OFF", $this->lng->txt("off"));
03856                 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
03857 
03858         if ($ilAccess->checkAccess("write", "", $this->ref_id)) 
03859                 {
03860                         $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
03861                         $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
03862                 }
03863                 $this->tpl->parseCurrentBlock();
03864         }
03865 
03866         function removeParticipantObject()
03867         {
03868                 if (is_array($_POST["invited_users"])) 
03869                 {
03870                         foreach ($_POST["invited_users"] as $user_id)
03871                         {
03872                                 $this->object->disinviteUser($user_id);                         
03873                         }
03874                 }
03875                 else
03876                 {
03877                         sendInfo($this->lng->txt("select_one_user"), true);
03878                 }
03879                 $this->ctrl->redirect($this, "participants");
03880         }
03881         
03882         function saveClientIPObject()
03883         {
03884                 if (is_array($_POST["invited_users"])) 
03885                 {
03886                         foreach ($_POST["invited_users"] as $user_id)
03887                         {
03888                                 $this->object->setClientIP($user_id, $_POST["clientip_".$user_id]);
03889                         }
03890                 }
03891                 else
03892                 {
03893                         sendInfo($this->lng->txt("select_one_user"), true);
03894                 }
03895                 $this->ctrl->redirect($this, "participants");
03896         }
03897         
03905         function printobject() 
03906         {
03907                 global $ilAccess;
03908                 if (!$ilAccess->checkAccess("write", "", $this->ref_id)) 
03909                 {
03910                         // allow only write access
03911                         sendInfo($this->lng->txt("cannot_edit_test"), true);
03912                         $this->ctrl->redirect($this, "infoScreen");
03913                 }
03914 
03915                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_print_test_confirm.html", true);
03916                 $this->tpl->setCurrentBlock("generic_css");
03917                 $this->tpl->setVariable("LOCATION_GENERIC_STYLESHEET", "./assessment/templates/default/test_print.css");
03918                 $this->tpl->setVariable("MEDIA_GENERIC_STYLESHEET", "print");
03919                 $this->tpl->parseCurrentBlock();
03920                 
03921                 global $ilUser;         
03922                 $print_date = mktime(date("H"), date("i"), date("s"), date("m")  , date("d"), date("Y"));
03923                 $max_points= 0;
03924                 $counter = 1;
03925                                         
03926                 foreach ($this->object->questions as $question) 
03927                 {               
03928                         $this->tpl->setCurrentBlock("question");                        
03929                         $question_gui = $this->object->createQuestionGUI("", $question);
03930                         $this->tpl->setVariable("COUNTER_QUESTION", $counter.".");
03931                         $this->tpl->setVariable("QUESTION_TITLE", $question_gui->object->getTitle());
03932                         if ($question_gui->object->getMaximumPoints() == 1)
03933                         {
03934                                 $this->tpl->setVariable("QUESTION_POINTS", $question_gui->object->getMaximumPoints() . " " . $this->lng->txt("point"));
03935                         }
03936                         else
03937                         {
03938                                 $this->tpl->setVariable("QUESTION_POINTS", $question_gui->object->getMaximumPoints() . " " . $this->lng->txt("points"));
03939                         }
03940                         $result_output = $question_gui->getSolutionOutput("", NULL, FALSE, TRUE, FALSE);
03941                         $this->tpl->setVariable("SOLUTION_OUTPUT", $result_output);
03942                         $this->tpl->parseCurrentBlock("question");
03943                         $counter ++;                                    
03944                         $max_points += $question_gui->object->getMaximumPoints();                       
03945                 }
03946 
03947                 $this->tpl->setCurrentBlock("navigation_buttons");
03948                 $this->tpl->setVariable("BUTTON_PRINT", $this->lng->txt("print"));
03949                 $this->tpl->parseCurrentBlock();
03950                 
03951                 $this->tpl->setCurrentBlock("adm_content");
03952                 $this->tpl->setVariable("TITLE", $this->object->getTitle());            
03953                 $this->tpl->setVariable("PRINT_TEST", $this->lng->txt("tst_print"));
03954                 $this->tpl->setVariable("TXT_PRINT_DATE", $this->lng->txt("date"));
03955                 $this->tpl->setVariable("VALUE_PRINT_DATE", strftime("%c",$print_date));
03956                 $this->tpl->setVariable("TXT_MAXIMUM_POINTS", $this->lng->txt("tst_maximum_points"));
03957                 $this->tpl->setVariable("VALUE_MAXIMUM_POINTS", $max_points);
03958                 $this->tpl->parseCurrentBlock();
03959         }
03960         
03969         function outUserGroupTable($a_type, $data_array, $block_result, $block_row, $title_text, $title_label, $buttons)
03970         {
03971                 global $ilAccess;
03972                 $rowclass = array("tblrow1", "tblrow2");
03973                 
03974                 switch($a_type)
03975                 {
03976                         case "iv_usr":
03977                                 $finished = "<img border=\"0\" align=\"middle\" src=\"".ilUtil::getImagePath("right.png", true) . "\" alt=\"".$this->lng->txt("checkbox_checked")."\" />";
03978                                 $started  = "<img border=\"0\" align=\"middle\" src=\"".ilUtil::getImagePath("right.png", true) . "\" alt=\"".$this->lng->txt("checkbox_checked")."\" />" ;
03979                                 $counter = 0;
03980                                 foreach ($data_array as $data)
03981                                 {
03982                                         $finished_line = str_replace ("&user_id=","&user_id=".$data->usr_id,$finished);
03983                                         $started_line = str_replace ("&user_id=","&user_id=".$data->usr_id,$started); 
03984                                         $this->tpl->setCurrentBlock($block_row);
03985                                         $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
03986                                         $this->tpl->setVariable("COUNTER", $data->usr_id);
03987                                         $this->tpl->setVariable("VALUE_IV_USR_ID", $data->usr_id);
03988                                         $this->tpl->setVariable("VALUE_IV_LOGIN", $data->login);
03989                                         $this->tpl->setVariable("VALUE_IV_FIRSTNAME", $data->firstname);
03990                                         $this->tpl->setVariable("VALUE_IV_LASTNAME", $data->lastname);
03991                                         $this->tpl->setVariable("VALUE_IV_CLIENT_IP", $data->clientip);
03992                                         $this->tpl->setVariable("VALUE_IV_TEST_FINISHED", ($data->test_finished==1)?$finished_line:"&nbsp;");
03993                                         $this->tpl->setVariable("VALUE_IV_TEST_STARTED", ($data->test_started==1)?$started_line:"&nbsp;");
03994                                         $counter++;
03995                                         $this->tpl->parseCurrentBlock();
03996                                 }
03997                                 if (count($data_array))
03998                                 {
03999                                         $this->tpl->setCurrentBlock("selectall");
04000                                         $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
04001                                         $counter++;
04002                                         $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
04003                                         $this->tpl->parseCurrentBlock();
04004                                 }
04005                                 $this->tpl->setCurrentBlock($block_result);
04006                                 $this->tpl->setVariable("$title_label", "<img src=\"" . ilUtil::getImagePath("icon_usr_b.gif") . "\" alt=\"".$this->lng->txt("objs_usr")."\" align=\"middle\" /> " . $title_text);
04007                                 $this->tpl->setVariable("TEXT_IV_LOGIN", $this->lng->txt("login"));
04008                                 $this->tpl->setVariable("TEXT_IV_FIRSTNAME", $this->lng->txt("firstname"));
04009                                 $this->tpl->setVariable("TEXT_IV_LASTNAME", $this->lng->txt("lastname"));
04010                                 $this->tpl->setVariable("TEXT_IV_CLIENT_IP", $this->lng->txt("clientip"));
04011                                 $this->tpl->setVariable("TEXT_IV_TEST_FINISHED", $this->lng->txt("tst_finished"));
04012                                 $this->tpl->setVariable("TEXT_IV_TEST_STARTED", $this->lng->txt("tst_started"));
04013                                         
04014                                 if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
04015                                 {
04016                                         foreach ($buttons as $cat)
04017                                         {
04018                                                 $this->tpl->setVariable("VALUE_" . strtoupper($cat), $this->lng->txt($cat));
04019                                         }
04020                                         $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\"/>");
04021                                 }
04022                                 $this->tpl->parseCurrentBlock();
04023                                 break;
04024                         case "usr":
04025                                 $finished = "<a target=\"_BLANK\" href=\"".$this->ctrl->getLinkTarget($this, "participants")."\"><img border=\"0\" align=\"middle\" src=\"".ilUtil::getImagePath("right.png", true) . "\" alt=\"".$this->lng->txt("objs_usr")."\" />&nbsp;".$this->lng->txt("tst_qst_result_sheet")."</a>" ;
04026                                 $counter = 0;
04027                                 foreach ($data_array as $data)
04028                                 {
04029                                         $this->tpl->setCurrentBlock($block_row);
04030                                         $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
04031                                         $this->tpl->setVariable("COUNTER", $data->usr_id);
04032                                         $this->tpl->setVariable("VALUE_LOGIN", $data->login);
04033                                         $this->tpl->setVariable("VALUE_FIRSTNAME", $data->firstname);
04034                                         $this->tpl->setVariable("VALUE_LASTNAME", $data->lastname);
04035                                         $this->tpl->setVariable("VALUE_CLIENT_IP", $data->clientip);
04036                                         $counter++;
04037                                         $this->tpl->parseCurrentBlock();
04038                                 }
04039                                 if (count($data_array))
04040                                 {
04041                                         $this->tpl->setCurrentBlock("selectall_user_row");
04042                                         $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
04043                                         $counter++;
04044                                         $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
04045                                         $this->tpl->parseCurrentBlock();
04046                                 }
04047                                 $this->tpl->setCurrentBlock($block_result);
04048                                 $this->tpl->setVariable("$title_label", "<img src=\"" . ilUtil::getImagePath("icon_usr_b.gif") . "\" alt=\"".$this->lng->txt("objs_usr")."\" align=\"middle\" /> " . $title_text);
04049                                 $this->tpl->setVariable("TEXT_LOGIN", $this->lng->txt("login"));
04050                                 $this->tpl->setVariable("TEXT_FIRSTNAME", $this->lng->txt("firstname"));
04051                                 $this->tpl->setVariable("TEXT_LASTNAME", $this->lng->txt("lastname"));
04052                                 $this->tpl->setVariable("TEXT_CLIENT_IP", $this->lng->txt("clientip"));
04053                                         
04054                                 if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
04055                                 {
04056                                         foreach ($buttons as $cat)
04057                                         {
04058                                                 $this->tpl->setVariable("VALUE_" . strtoupper($cat), $this->lng->txt($cat));
04059                                         }
04060                                         $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\"/>");
04061                                 }
04062                                 $this->tpl->parseCurrentBlock();
04063                                 break;
04064                                 
04065                         case "role":
04066                         case "grp":
04067                                 $counter = 0;
04068                                 foreach ($data_array as $key => $data)
04069                                 {
04070                                         $this->tpl->setCurrentBlock($block_row);
04071                                         $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
04072                                         $this->tpl->setVariable("COUNTER", $key);
04073                                         $this->tpl->setVariable("VALUE_TITLE", $data->title);
04074                                         $this->tpl->setVariable("VALUE_DESCRIPTION", $data->description);
04075                                         $counter++;
04076                                         $this->tpl->parseCurrentBlock();
04077                                 }
04078                                 if (count($data_array))
04079                                 {
04080                                         $this->tpl->setCurrentBlock("selectall_" . $a_type . "_row");
04081                                         $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
04082                                         $counter++;
04083                                         $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
04084                                         $this->tpl->parseCurrentBlock();
04085                                 }
04086                                 $this->tpl->setCurrentBlock($block_result);
04087                                 $this->tpl->setVariable("$title_label", "<img src=\"" . ilUtil::getImagePath("icon_".$a_type."_b.gif") . "\" align=\"middle\" alt=\"".$this->lng->txt("objs_".$a_type)."\" /> " . $title_text);
04088                                 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
04089                                 $this->tpl->setVariable("TEXT_DESCRIPTION", $this->lng->txt("description"));
04090                                 if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
04091                                 {
04092                                         foreach ($buttons as $cat)
04093                                         {
04094                                                 $this->tpl->setVariable("VALUE_" . strtoupper($cat), $this->lng->txt($cat));
04095                                         }
04096                                         $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\"/>");
04097                                 }
04098                                 $this->tpl->parseCurrentBlock();
04099                                 break;
04100                 }
04101         }
04102 
04103         function addParticipantsObject()
04104         {
04105                 // add users 
04106                 if (is_array($_POST["user_select"]))
04107                 {
04108                         $i = 0;
04109                         foreach ($_POST["user_select"] as $user_id)
04110                         {                                       
04111                                 $client_ip = $_POST["client_ip"][$i];
04112                                 $this->object->inviteUser($user_id, $client_ip);
04113                                 $i++;                           
04114                         }
04115                 }
04116                 // add groups members
04117                 if (is_array($_POST["group_select"]))
04118                 {
04119                         foreach ($_POST["group_select"] as $group_id)
04120                         {
04121                                 $this->object->inviteGroup($group_id);
04122                         }
04123                 }
04124                 // add role members
04125                 if (is_array($_POST["role_select"]))
04126                 {
04127                         foreach ($_POST["role_select"] as $role_id)
04128                         {                                       
04129                                 $this->object->inviteRole($role_id);
04130                         }
04131                 }
04132                 $this->ctrl->redirect($this, "participants");
04133         }
04134         
04135         function searchParticipantsObject()
04136         {
04137                 $this->participantsObject();
04138         }
04139         
04147         function showResultsObject()
04148         {
04149                 $user_ids = array();
04150                 if (array_key_exists("invited_users", $_POST))
04151                 {
04152                         foreach ($_POST["invited_users"] as $user_id) 
04153                         {
04154                                 if ($this->object->isActiveTestSubmitted($user_id)) 
04155                                 {
04156                                         array_push($user_ids, $user_id);
04157                                 }
04158                         }
04159                 }
04160                 if (count($user_ids) == 0)
04161                 {
04162                         sendInfo($this->lng->txt("select_one_submitted_test"), true);
04163                         $this->ctrl->redirect($this, "participants");
04164                 }
04165                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_print_result_details.html", true);                        
04166                 $this->tpl->setCurrentBlock("generic_css");
04167                 $this->tpl->setVariable("LOCATION_GENERIC_STYLESHEET", "./assessment/templates/default/test_print.css");
04168                 $this->tpl->setVariable("MEDIA_GENERIC_STYLESHEET", "print");
04169                 $this->tpl->parseCurrentBlock();
04170                 $this->tpl->setCurrentBlock("navigation_buttons");
04171                 $this->tpl->setVariable("BUTTON_PRINT", $this->lng->txt("print"));
04172                 $this->tpl->setVariable("BUTTON_BACK", $this->lng->txt("back"));
04173                 $this->tpl->setVariable("URL_BACK", $this->ctrl->getLinkTarget($this, "participants"));
04174                 $this->tpl->parseCurrentBlock();
04175                 $counter = 0;
04176                 foreach ($user_ids as $user_id)
04177                 {
04178                         $counter++;
04179                         if ($counter < count($user_ids)) $this->tpl->touchBlock("ruler");
04180                         $this->outPrintUserResults($user_id);
04181                 }
04182         }
04183 
04191         function outPrintUserResults($user_id) 
04192         {
04193                 include_once "./classes/class.ilObjUser.php";
04194                 $user = new ilObjUser($user_id);
04195                 $active = $this->object->getActiveTestUser($user_id);
04196                 $t = $active->submittimestamp;
04197                 
04198                 $print_date = mktime(date("H"), date("i"), date("s"), date("m")  , date("d"), date("Y"));
04199 
04200                 if (strlen($user->getMatriculation()))
04201                 {
04202                         $this->tpl->setCurrentBlock("user_matric");
04203                         $this->tpl->setVariable("TXT_USR_MATRIC", $this->lng->txt("matriculation"));
04204                         $this->tpl->parseCurrentBlock();
04205                         $this->tpl->setCurrentBlock("user_matric_value");
04206                         $this->tpl->setVariable("VALUE_USR_MATRIC", $user->getMatriculation());
04207                         $this->tpl->parseCurrentBlock();
04208                         $this->tpl->touchBlock("user_matric_separator");
04209                 }
04210                 $pagetitle = $this->object->getTitle() . " - " . $this->lng->txt("matriculation") . ": " . $user->getMatriculation();
04211                 
04212                 $color_class = array("tblrow1", "tblrow2");
04213                 $counter = 0;
04214 
04215                 $result_array =& $this->object->getTestResult($active->active_id);
04216 
04217                 if (!$result_array["test"]["total_max_points"])
04218                 {
04219                         $percentage = 0;
04220                 }
04221                 else
04222                 {
04223                         $percentage = ($result_array["test"]["total_reached_points"]/$result_array["test"]["total_max_points"])*100;
04224                 }
04225                 
04226                 $total_max = $result_array["test"]["total_max_points"];
04227                 $total_reached = $result_array["test"]["total_reached_points"];
04228 
04229                 foreach ($result_array as $key => $value) {
04230                         if (preg_match("/\d+/", $key)) {
04231                                 $title = $value["title"];
04232                                 $this->tpl->setCurrentBlock("question");
04233                                 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
04234                                 $this->tpl->setVariable("VALUE_QUESTION_COUNTER", $value["nr"]);
04235                                 $this->tpl->setVariable("VALUE_QUESTION_TITLE", $title);
04236                                 $this->tpl->setVariable("VALUE_MAX_POINTS", $value["max"]);
04237                                 $this->tpl->setVariable("VALUE_REACHED_POINTS", $value["reached"]);
04238                                 $this->tpl->setVariable("VALUE_PERCENT_SOLVED", $value["percent"]);
04239                                 $this->tpl->parseCurrentBlock("question");
04240                                 $counter++;
04241                         }
04242                 }
04243                 
04244                 $this->tpl->setCurrentBlock("user_results");
04245                 $this->tpl->setVariable("TXT_TEST_TITLE", $this->lng->txt("title"));
04246                 $this->tpl->setVariable("VALUE_TEST_TITLE", $this->object->getTitle());
04247                 $this->tpl->setVariable("TXT_USR_NAME", $this->lng->txt("name"));
04248                 $this->tpl->setVariable("VALUE_USR_NAME", $user->getLastname().", ".$user->getFirstname());
04249                 $this->tpl->setVariable("TXT_TEST_DATE", $this->lng->txt("tst_tst_date"));
04250                 $this->tpl->setVariable("VALUE_TEST_DATE", strftime("%Y-%m-%d %H:%M:%S",ilUtil::date_mysql2time($t)));
04251                 $this->tpl->setVariable("TXT_PRINT_DATE", $this->lng->txt("tst_print_date"));
04252                 $this->tpl->setVariable("VALUE_PRINT_DATE", strftime("%Y-%m-%d %H:%M:%S",$print_date));
04253 
04254                 $this->tpl->setVariable("QUESTION_COUNTER", $this->lng->txt("tst_question_no"));
04255                 $this->tpl->setVariable("QUESTION_TITLE", $this->lng->txt("tst_question_title"));
04256                 $this->tpl->setVariable("SOLUTION_HINT_HEADER", $this->lng->txt("solution_hint"));
04257                 $this->tpl->setVariable("MAX_POINTS", $this->lng->txt("tst_maximum_points"));
04258                 $this->tpl->setVariable("REACHED_POINTS", $this->lng->txt("tst_reached_points"));
04259                 $this->tpl->setVariable("PERCENT_SOLVED", $this->lng->txt("tst_percent_solved"));
04260 
04261                 // SUM
04262                 $this->tpl->setVariable("TOTAL", $this->lng->txt("total"));
04263                 $this->tpl->setVariable("TOTAL_MAX_POINTS", $total_max);
04264                 $this->tpl->setVariable("TOTAL_REACHED_POINTS",  $total_reached);
04265                 $this->tpl->setVariable("TOTAL_PERCENT_SOLVED", sprintf("%01.2f",$percentage)." %");
04266 
04267                 $mark_obj = $this->object->mark_schema->getMatchingMark($percentage);
04268                 if ($mark_obj)
04269                 {
04270                         $mark .= "<br /><strong>" . $this->lng->txt("tst_mark") . ": &quot;" . $mark_obj->getOfficialName() . "&quot;</strong>";
04271                 }
04272                 if ($this->object->ects_output)
04273                 {
04274                         $ects_mark = $this->object->getECTSGrade($total_reached, $total_max);
04275                         $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)) . ")";
04276                 }       
04277  
04278                 $this->tpl->setVariable("GRADE", $mark);
04279                 $this->tpl->setVariable("TITLE", $this->object->getTitle());
04280                 $this->tpl->setVariable("TEXT_RESULTS", sprintf($this->lng->txt("tst_result_user_name"), $user->getFullName()));
04281                 $this->tpl->parseCurrentBlock();
04282                 $this->tpl->setVariable("PAGETITLE", $pagetitle);
04283         }
04284 
04292         function showAnswersObject()
04293         {
04294                 $user_ids = array();
04295                 if (array_key_exists("invited_users", $_POST))
04296                 {
04297                         foreach ($_POST["invited_users"] as $user_id) 
04298                         {
04299                                 if ($this->object->isActiveTestSubmitted($user_id)) 
04300                                 {
04301                                         array_push($user_ids, $user_id);
04302                                 }
04303                         }
04304                 }
04305                 if (count($user_ids) == 0)
04306                 {
04307                         sendInfo($this->lng->txt("select_one_submitted_test"), true);
04308                         $this->ctrl->redirect($this, "participants");
04309                 }
04310                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_print_answers_sheet_details.html", true);                 
04311                 $this->tpl->setCurrentBlock("generic_css");
04312                 $this->tpl->setVariable("LOCATION_GENERIC_STYLESHEET", "./assessment/templates/default/test_print.css");
04313                 $this->tpl->setVariable("MEDIA_GENERIC_STYLESHEET", "print");
04314                 $this->tpl->parseCurrentBlock();
04315                 $this->tpl->setCurrentBlock("navigation_buttons");
04316                 $this->tpl->setVariable("BUTTON_PRINT", $this->lng->txt("print"));
04317                 $this->tpl->setVariable("BUTTON_BACK", $this->lng->txt("back"));
04318                 $this->tpl->setVariable("URL_BACK", $this->ctrl->getLinkTarget($this, "participants"));
04319                 $this->tpl->parseCurrentBlock();
04320                 $counter = 0;
04321                 foreach ($user_ids as $user_id)
04322                 {
04323                         $counter++;
04324                         if ($counter < count($user_ids)) $this->tpl->touchBlock("ruler");
04325                         $this->outShowAnswersDetails($user_id);
04326                 }
04327         }
04328 
04336         function outShowAnswersDetails($user_id) 
04337         {
04338                 $active = $this->object->getActiveTestUser($user_id);
04339                 $t = $active->submittimestamp;
04340                 include_once "./classes/class.ilObjUser.php";
04341                 $ilUser = new ilObjUser($user_id);
04342                 
04343                 if (strlen($ilUser->getMatriculation()))
04344                 {
04345                         $this->tpl->setCurrentBlock("user_matric");
04346                         $this->tpl->setVariable("TXT_USR_MATRIC", $this->lng->txt("matriculation"));
04347                         $this->tpl->parseCurrentBlock();
04348                         $this->tpl->setCurrentBlock("user_matric_value");
04349                         $this->tpl->setVariable("VALUE_USR_MATRIC", $ilUser->getMatriculation());
04350                         $this->tpl->parseCurrentBlock();
04351                         $this->tpl->touchBlock("user_matric_separator");
04352                 }
04353 
04354                 $invited_users = array_pop($this->object->getInvitedUsers($ilUser->getId()));
04355                 if (strlen($invited_users->clientip))
04356                 {
04357                         $this->tpl->setCurrentBlock("user_clientip");
04358                         $this->tpl->setVariable("TXT_CLIENT_IP", $this->lng->txt("clientip"));
04359                         $this->tpl->parseCurrentBlock();
04360                         $this->tpl->setCurrentBlock("user_clientip_value");
04361                         $this->tpl->setVariable("VALUE_CLIENT_IP", $invited_users->clientip);
04362                         $this->tpl->parseCurrentBlock();
04363                         $this->tpl->touchBlock("user_clientip_separator");
04364                 }
04365                 $pagetitle = $this->object->getTitle() . " - IP: " . $invited_users->clientip . " - " . $this->lng->txt("matriculation") . ": " . $ilUser->getMatriculation();
04366                 
04367                 include_once "./classes/class.ilUtil.php";
04368 
04369                 // output of submit date and signature
04370                 if ($active->submitted)
04371                 {
04372                         // only display submit date when it exists (not in the summary but in the print form)
04373                         $this->tpl->setCurrentBlock("freefield_bottom");
04374                         $this->tpl->setVariable("TXT_DATE", $this->lng->txt("date"));
04375                         $this->tpl->setVariable("VALUE_DATE", strftime("%Y-%m-%d %H:%M:%S", ilUtil::date_mysql2time($t)));
04376 
04377                         $freefieldtypes = array(
04378                                 "freefield_bottom" => array(
04379                                         array(
04380                                                 "title" => $this->lng->txt("tst_signature"), 
04381                                                 "length" => 300
04382                                         )
04383                                 )
04384                         );
04385 
04386                         foreach ($freefieldtypes as $type => $freefields) 
04387                         {
04388                                 $counter = 0;
04389                                 while ($counter < count($freefields)) 
04390                                 {
04391                                         $freefield = $freefields[$counter];
04392                                         $this->tpl->setVariable("TXT_FREE_FIELD", $freefield["title"]);
04393                                         $this->tpl->setVariable("IMG_SPACER", ilUtil::getImagePath("spacer.gif"));
04394                                         $counter ++;
04395                                 }
04396                         }
04397                         $this->tpl->parseCurrentBlock();
04398                 }
04399 
04400                 $counter = 1;
04401                 $questions = $this->object->getQuestions($active->active_id, NULL, TRUE);
04402                 // output of questions with solutions
04403                 foreach ($questions as $question) 
04404                 {
04405                         $this->tpl->setCurrentBlock("question");
04406                         $question_gui = $this->object->createQuestionGUI("", $question);
04407 
04408                         $this->tpl->setVariable("COUNTER_QUESTION", $counter.". ");
04409                         $this->tpl->setVariable("QUESTION_TITLE", $question_gui->object->getTitle());
04410                         
04411                         $active = $this->object->getActiveTestUser($ilUser->getId());
04412                         $result_output = $question_gui->getSolutionOutput($active->active_id, $pass, FALSE, FALSE, FALSE);
04413                         $this->tpl->setVariable("SOLUTION_OUTPUT", $result_output);
04414                         $this->tpl->parseCurrentBlock();
04415                         $counter ++;
04416                 }
04417 
04418                 $this->tpl->setCurrentBlock("answer_sheet");
04419                 $this->tpl->setVariable("TXT_TEST_TITLE", $this->lng->txt("title"));
04420                 $this->tpl->setVariable("VALUE_TEST_TITLE", $this->object->getTitle());
04421                 $this->tpl->setVariable("TXT_TEST_PROLOG", $this->lng->txt("tst_your_answers"));
04422                 $this->tpl->setVariable("TITLE", $this->object->getTitle());
04423                 $this->tpl->setVariable("TXT_ANSWER_SHEET", $this->lng->txt("tst_answer_sheet"));
04424                 
04425                 $this->tpl->setVariable("TXT_USR_NAME", $this->lng->txt("name"));
04426                 $this->tpl->setVariable("VALUE_USR_NAME", $ilUser->getLastname().", ".$ilUser->getFirstname());
04427                 $this->tpl->parseCurrentBlock();
04428                 $this->tpl->setVariable("PAGETITLE", $pagetitle);
04429         }
04430         
04436         function infoScreenObject()
04437         {
04438                 $this->ctrl->setCmd("showSummary");
04439                 $this->ctrl->setCmdClass("ilinfoscreengui");
04440                 $this->infoScreen();
04441         }
04442         
04443         function redirectToInfoScreenObject()
04444         {
04445                 $this->ctrl->setCmd("showSummary");
04446                 $this->ctrl->setCmdClass("ilinfoscreengui");
04447                 $this->infoScreen($_SESSION["lock"]);
04448         }
04449         
04453         function infoScreen($session_lock = "")
04454         {
04455                 global $ilAccess;
04456                 global $ilUser;
04457                 global $ilLog;
04458                 
04459                 if (!$ilAccess->checkAccess("visible", "", $this->ref_id))
04460                 {
04461                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
04462                 }
04463 
04464                 include_once("classes/class.ilInfoScreenGUI.php");
04465                 $info = new ilInfoScreenGUI($this);
04466 
04467                 $active = $this->object->getActiveTestUser();
04468                 $seq = 1;
04469                 if (is_object($active)) 
04470                 {
04471                         $seq = $active->lastindex;
04472                 }
04473                 include_once "./assessment/classes/class.ilTestOutputGUI.php";
04474                 $output_gui =& new ilTestOutputGUI($this->object);
04475                 $this->ctrl->setParameter($output_gui, "sequence", $seq);
04476                 $info->setFormAction($this->ctrl->getFormAction($output_gui));
04477                 if (strlen($session_lock))
04478                 {
04479                         $info->addHiddenElement("lock", $session_lock);
04480                         //$ilLog->write("Test lock: $session_lock");
04481                 }
04482                 else
04483                 {
04484                         $info->addHiddenElement("lock", md5($_COOKIE['PHPSESSID'] . time()));
04485                         //$ilLog->write("Test lock: " . md5($_COOKIE['PHPSESSID'] . time()));
04486                 }
04487                 $online_access = false;
04488                 if ($this->object->isOnlineTest())
04489                 {
04490                         include_once "./assessment/classes/class.ilObjTestAccess.php";
04491                         $online_access_result =         ilObjTestAccess::_lookupOnlineTestAccess($this->object->getId(), $ilUser->getId());
04492                         if ($online_access_result === true)
04493                         {
04494                                 $online_access = true;
04495                         }
04496                 }
04497                 if ($this->object->isComplete())
04498                 {
04499                         if ((!$this->object->isOnlineTest() && $ilAccess->checkAccess("read", "", $this->ref_id)) || ($this->object->isOnlineTest() && $ilAccess->checkAccess("read", "", $this->ref_id) && $online_access))
04500                         {
04501                                 $executable = $this->object->isExecutable($ilUser->getId());
04502                                 if ($executable["executable"])
04503                                 {
04504                                         if (is_object($active))
04505                                         {
04506                                                 // resume test
04507                                                 $resume_text = $this->lng->txt("tst_resume_test");
04508                                                 if ($seq < 2)
04509                                                 {
04510                                                         $resume_text = $this->lng->txt("tst_start_test");
04511                                                 }
04512                                                 // Commented out because this leads to problems in "normal" tests
04513                                                 if(!$_GET['crs_show_result'] or $this->object->getFirstSequence())
04514                                                 {
04515                                                         $info->addFormButton("resume", $resume_text);
04516                                                 }
04517                                         }
04518                                         else
04519                                         {
04520                                                 // start new test
04521                                                 $info->addFormButton("start", $this->lng->txt("tst_start_test"));
04522                                         }
04523                                 }
04524                                 else
04525                                 {
04526                                         sendInfo($executable["errormessage"]);
04527                                         if ($this->object->isOnlineTest()) 
04528                                         {
04529                                                 if ($this->object->canShowSolutionPrintview($ilUser->getId()))
04530                                                 {
04531                                                         sendInfo($this->lng->txt("online_exam_show_answer_print_sheet"));
04532                                                 }                       
04533                                                 if (!$this->object->isActiveTestSubmitted($ilUser->getId())) 
04534                                                 {
04535                                                         if ($this->object->startingTimeReached() && (!$this->object->endingTimeReached()))
04536                                                         {
04537                                                                 $info->addFormButton("show_answers", $this->lng->txt("save_finish"));
04538                                                                 sendInfo($this->lng->txt("online_exam_show_finish_test"));
04539                                                         }
04540                                                 } 
04541                                         }                       
04542                                 }
04543                                 if (is_object($active))
04544                                 {
04545                                         // test results button
04546                                         if ($this->object->canShowTestResults($ilUser->getId())) 
04547                                         {
04548                                                 $info->addFormButton("outResults", $this->lng->txt("tst_show_results"));
04549                                         }
04550                                 }
04551                         }
04552                         if (is_object($active))
04553                         {
04554                                 if ($this->object->canShowSolutionPrintview($ilUser->getId()))
04555                                 {
04556                                         if ($this->object->getTestType() != TYPE_VARYING_RANDOMTEST)
04557                                         {
04558                                                 // it does not make sense to show always the last pass of a varying randomtest only in the print answers sheet
04559                                                 $info->addFormButton("showAnswersOfUser", $this->lng->txt("tst_show_answer_print_sheet"));
04560                                         }
04561                                 }
04562                         }
04563                 }
04564                 
04565                 $info->enablePrivateNotes();
04566                 
04567                 if (strlen($this->object->getIntroduction()))
04568                 {
04569                         $info->addSection($this->lng->txt("tst_introduction"));
04570                         $info->addProperty("", $this->object->prepareTextareaOutput($this->object->getIntroduction()));
04571                 }
04572 
04573                 $info->addSection($this->lng->txt("tst_general_properties"));
04574                 $info->addProperty($this->lng->txt("tst_type"), $this->lng->txt($this->object->test_types[$this->object->getTestType()]));
04575                 $info->addProperty($this->lng->txt("author"), $this->object->getAuthor());
04576                 $info->addProperty($this->lng->txt("title"), $this->object->getTitle());
04577                 if ($this->object->isComplete())
04578                 {
04579                         if ((!$this->object->isOnlineTest() && $ilAccess->checkAccess("read", "", $this->ref_id)) || ($this->object->isOnlineTest() && $ilAccess->checkAccess("read", "", $this->ref_id) && $online_access))
04580                         {
04581                                 // use javascript
04582                                 $checked_javascript = false;
04583                                 if ($ilUser->prefs["tst_javascript"])
04584                                 {
04585                                         $checked_javascript = true;
04586                                 }
04587                                 $info->addPropertyCheckbox($this->lng->txt("tst_test_output"), "chb_javascript", 1, $this->lng->txt("tst_use_javascript"), $checked_javascript);
04588         
04589                                 // hide previous results
04590                                 if (!($this->object->getTestType() == TYPE_VARYING_RANDOMTEST))
04591                                 {
04592                                         if ($this->object->getNrOfTries() != 1)
04593                                         {
04594                                                 if ($this->object->getHidePreviousResults() == 1)
04595                                                 {
04596                                                         $info->addProperty($this->lng->txt("tst_hide_previous_results"), $this->lng->txt("tst_hide_previous_results_introduction"));
04597                                                 }
04598                                                 else
04599                                                 {
04600                                                         $checked_hide_results = false;
04601                                                         if ($ilUser->prefs["tst_hide_previous_results"])
04602                                                         {
04603                                                                 $checked_hide_results = true;
04604                                                         }
04605                                                         $info->addPropertyCheckbox($this->lng->txt("tst_hide_previous_results"), "chb_hide_previous_results", 1, $this->lng->txt("tst_hide_previous_results_hide"), $checked_hide_results);
04606                                                 }
04607                                         }
04608                                 }
04609                                 if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
04610                                 {
04611                                         $info->addPropertyTextinput($this->lng->txt("enter_anonymous_code"), "anonymous_id", "", 8, "setAnonymousId", $this->lng->txt("submit"));
04612                                 }
04613                         }
04614                 }
04615                                                  
04616                 $info->addSection($this->lng->txt("tst_sequence_properties"));
04617                 $info->addProperty($this->lng->txt("tst_sequence"), $this->lng->txt(($this->object->getSequenceSettings() == TEST_FIXED_SEQUENCE)? "tst_sequence_fixed":"tst_sequence_postpone"));
04618                 
04619                 $info->addSection($this->lng->txt("tst_heading_scoring"));
04620                 $info->addProperty($this->lng->txt("tst_text_count_system"), $this->lng->txt(($this->object->getCountSystem() == COUNT_PARTIAL_SOLUTIONS)? "tst_count_partial_solutions":"tst_count_correct_solutions"));
04621                 $info->addProperty($this->lng->txt("tst_score_mcmr_questions"), $this->lng->txt(($this->object->getMCScoring() == SCORE_ZERO_POINTS_WHEN_UNANSWERED)? "tst_score_mcmr_zero_points_when_unanswered":"tst_score_mcmr_use_scoring_system"));
04622                 if ($this->object->getTestType() == TYPE_VARYING_RANDOMTEST)
04623                 {
04624                         $info->addProperty($this->lng->txt("tst_pass_scoring"), $this->lng->txt(($this->object->getPassScoring() == SCORE_BEST_PASS)? "tst_pass_best_pass":"tst_pass_last_pass"));
04625                 }
04626 
04627                 if ($this->object->getInstantVerification() == 1)
04628                 {
04629                         $info->addSection($this->lng->txt("tst_instant_verification"));
04630                         $info->addProperty($this->lng->txt("tst_instant_verification"), $this->lng->txt("tst_allow_instant_verification"));
04631                 }
04632                 $info->addSection($this->lng->txt("tst_score_reporting"));
04633                 $score_reporting_text = "";
04634                 switch ($this->object->getScoreReporting())
04635                 {
04636                         case REPORT_AFTER_TEST:
04637                                 $score_reporting_text = $this->lng->txt("tst_report_after_test");
04638                                 break;
04639                         case REPORT_AFTER_FIRST_QUESTION:
04640                                 $score_reporting_text = $this->lng->txt("tst_report_after_first_question");
04641                                 break;
04642                 }
04643                 $info->addProperty($this->lng->txt("tst_score_reporting"), $score_reporting_text); 
04644                 $reporting_date = $this->object->getReportingDate();
04645                 if ($reporting_date)
04646                 {
04647                         preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $reporting_date, $matches);
04648                         $txt_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]));
04649                         $info->addProperty($this->lng->txt("tst_score_reporting_date"), $txt_reporting_date);
04650                 }
04651         
04652                 $info->addSection($this->lng->txt("tst_session_settings"));
04653                 $info->addProperty($this->lng->txt("tst_nr_of_tries"), ($this->object->getNrOfTries() == 0)?$this->lng->txt("unlimited"):$this->object->getNrOfTries());
04654                 if ($this->object->getNrOfTries() != 1)
04655                 {
04656                         $info->addProperty($this->lng->txt("tst_nr_of_tries_of_user"), ($active->tries == false)?$this->lng->txt("tst_no_tries"):$active->tries);
04657                 }
04658 
04659                 if ($this->object->getEnableProcessingTime())
04660                 {
04661                         $info->addProperty($this->lng->txt("tst_processing_time"), $this->object->getProcessingTime());
04662                 }
04663                 if (strlen($this->object->getAllowedUsers()) && ($this->object->getAllowedUsersTimeGap()))
04664                 {
04665                         $info->addProperty($this->lng->txt("tst_allowed_users"), $this->object->getAllowedUsers());
04666                 }
04667                 
04668                 $starting_time = $this->object->getStartingTime();
04669                 if ($starting_time)
04670                 {
04671                         preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $starting_time, $matches);
04672                         $txt_starting_time = date($this->lng->text["lang_dateformat"] . " " . $this->lng->text["lang_timeformat"], mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]));
04673                         $info->addProperty($this->lng->txt("tst_starting_time"), $txt_starting_time);
04674                 }
04675                 $ending_time = $this->object->getEndingTime();
04676                 if ($ending_time)
04677                 {
04678                         preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $ending_time, $matches);
04679                         $txt_ending_time = date($this->lng->text["lang_dateformat"] . " " . $this->lng->text["lang_timeformat"], mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]));
04680                         $info->addProperty($this->lng->txt("tst_ending_time"), $txt_ending_time);
04681                 }
04682                 $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
04683                 // forward the command
04684 
04685                 if($_GET['crs_show_result'] and !$this->object->getFirstSequence())
04686                 {
04687                         sendInfo($this->lng->txt('crs_all_questions_answered_successfully'));
04688                 }                       
04689 
04690                 $this->ctrl->forwardCommand($info);
04691         }
04692 
04693         function addLocatorItems()
04694         {
04695                 global $ilLocator;
04696                 switch ($this->ctrl->getCmd())
04697                 {
04698                         case "run":
04699                         case "redirectToInfoScreen":
04700                         case "infoScreen":
04701                         case "start":
04702                         case "resume":
04703                         case "previous":
04704                         case "next":
04705                         case "summary":
04706                         case "finishTest":
04707                         case "outEvaluationForm":
04708                         case "passDetails":
04709                         case "showAnswersOfUser":
04710                         case "outResults":
04711                         case "backFromSummary":
04712                         case "show_answers":
04713                         case "setsolved":
04714                         case "resetsolved":
04715                         case "outTestSummary":
04716                         case "outQuestionSummary":
04717                         case "gotoQuestion":
04718                         case "selectImagemapRegion":
04719                         case "confirmSubmitAnswers":
04720                         case "finalSubmission":
04721                         case "postpone":
04722                         case "redirectQuestion":
04723                         case "outResultsOverview":
04724                         case "checkPassword":
04725                                 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "infoScreen"));
04726                                 break;
04727                         case "eval_stat":
04728                         case "evalAllUsers":
04729                         case "evalUserDetail":
04730                                 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "eval_stat"));
04731                                 break;
04732                         case "create":
04733                         case "save":
04734                         case "cancel":
04735                         case "importFile":
04736                         case "cloneAll":
04737                         case "importVerifiedFile":
04738                         case "cancelImport":
04739                                 break;
04740                 default:
04741                                 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""));
04742                                 break;
04743                 }
04744         }
04745         
04746         function getBrowseForQuestionsTab(&$tabs_gui)
04747         {
04748                 global $ilAccess;
04749                 if ($ilAccess->checkAccess("write", "", $this->ref_id))
04750                 {
04751                         // edit page
04752                         $tabs_gui->setBackTarget($this->lng->txt("backtocallingtest"), $this->ctrl->getLinkTarget($this, "questions"));
04753                         $tabs_gui->addTarget("tst_browse_for_questions",
04754                                 $this->ctrl->getLinkTarget($this, "browseForQuestions"),
04755                                 array("browseForQuestions", "filter", "resetFilter", "insertQuestions"),
04756                                 "", ""
04757                         );
04758                 }
04759         }
04760         
04761         function getRandomQuestionsTab(&$tabs_gui)
04762         {
04763                 global $ilAccess;
04764                 if ($ilAccess->checkAccess("write", "", $this->ref_id))
04765                 {
04766                         // edit page
04767                         $tabs_gui->setBackTarget($this->lng->txt("backtocallingtest"), $this->ctrl->getLinkTarget($this, "questions"));
04768                         $tabs_gui->addTarget("random_selection",
04769                                 $this->ctrl->getLinkTarget($this, "randomQuestions"),
04770                                 array("randomQuestions"),
04771                                 "", ""
04772                         );
04773                 }
04774         }
04775 
04781         function getTabs(&$tabs_gui)
04782         {
04783                 global $ilAccess;
04784 
04785                 switch ($this->ctrl->getCmd())
04786                 {
04787                         case "start":
04788                         case "resume":
04789                         case "previous":
04790                         case "next":
04791                         case "summary":
04792                         case "directfeedback":
04793                         case "finishTest":
04794                         case "outEvaluationForm":
04795                         case "passDetails":
04796                         case "showAnswersOfUser":
04797                         case "outResults":
04798                         case "backFromSummary":
04799                         case "show_answers":
04800                         case "setsolved":
04801                         case "resetsolved":
04802                         case "confirmFinish":
04803                         case "outTestSummary":
04804                         case "outQuestionSummary":
04805                         case "gotoQuestion":
04806                         case "selectImagemapRegion":
04807                         case "confirmSubmitAnswers":
04808                         case "finalSubmission":
04809                         case "postpone":
04810                         case "redirectQuestion":
04811                         case "outResultsOverview":
04812                         case "checkPassword":
04813                                 return;
04814                                 break;
04815                         case "browseForQuestions":
04816                         case "filter":
04817                         case "resetFilter":
04818                         case "insertQuestions":
04819                                 return $this->getBrowseForQuestionsTab($tabs_gui);
04820                                 break;
04821                 }
04822                 if (strcmp(strtolower(get_class($this->object)), "ilobjtest") == 0)
04823                 {
04824                         global $ilAccess;
04825                         if ($ilAccess->checkAccess("write", "", $this->ref_id))
04826                         {
04827                                 // properties
04828                                 $force_active = ($this->ctrl->getCmdClass() == "" &&
04829                                         $this->ctrl->getCmd() == "")
04830                                         ? true
04831                                         : false;
04832                                 $tabs_gui->addTarget("properties",
04833                                          $this->ctrl->getLinkTarget($this,'properties'),
04834                                          array("properties", "saveProperties", "cancelProperties"),
04835                                          "",
04836                                          "", $force_active);
04837                         }
04838         
04839                         if ($ilAccess->checkAccess("visible", "", $this->ref_id))
04840                         {
04841                                 $tabs_gui->addTarget("info",
04842                                          $this->ctrl->getLinkTarget($this,'infoScreen'),
04843                                          array("infoScreen", "outIntroductionPage", "showSummary", "setAnonymousId", "redirectToInfoScreen"));
04844                         }
04845         
04846                         if ($ilAccess->checkAccess("write", "", $this->ref_id))
04847                         {
04848                                 // questions
04849                                 $force_active = ($_GET["up"] != "" || $_GET["down"] != "")
04850                                         ? true
04851                                         : false;
04852                                 if (!$force_active)
04853                                 {
04854                                         if ($_GET["browse"] == 1) $force_active = true;
04855                                         if (preg_match("/deleteqpl_\d+/", $this->ctrl->getCmd()))
04856                                         {
04857                                                 $force_active = true;
04858                                         }
04859                                 }
04860                                 $tabs_gui->addTarget("assQuestions",
04861                                          $this->ctrl->getLinkTarget($this,'questions'),
04862                                          array("questions", "browseForQuestions", "questionBrowser", "createQuestion", 
04863                                          "randomselect", "filter", "resetFilter", "insertQuestions",
04864                                          "back", "createRandomSelection", "cancelRandomSelect",
04865                                          "insertRandomSelection", "removeQuestions", "moveQuestions",
04866                                          "insertQuestionsBefore", "insertQuestionsAfter", "confirmRemoveQuestions",
04867                                          "cancelRemoveQuestions", "executeCreateQuestion", "cancelCreateQuestion",
04868                                          "addQuestionpool", "saveRandomQuestions", "saveQuestionSelectionMode"), 
04869                                          "", "", $force_active);
04870                                          
04871                                 // meta data
04872                                 $tabs_gui->addTarget("meta_data",
04873                                          $this->ctrl->getLinkTargetByClass('ilmdeditorgui','listSection'),
04874                                          "", "ilmdeditorgui");
04875 
04876                                 // mark schema
04877                                 $tabs_gui->addTarget("mark_schema",
04878                                          $this->ctrl->getLinkTarget($this,'marks'),
04879                                          array("marks", "addMarkStep", "deleteMarkSteps", "addSimpleMarkSchema",
04880                                                 "saveMarks", "cancelMarks"),
04881                                          "");
04882                 
04883                                 if ($this->object->isOnlineTest())
04884                                 {
04885                                         // participants
04886                                         $tabs_gui->addTarget("participants",
04887                                                  $this->ctrl->getLinkTarget($this,'participants'),
04888                                                  array("participants", "searchParticipants", "addParticipants", "saveClientIP",
04889                                                  "removeParticipant", "showAnswers", "showResults"), 
04890                                                  "");
04891                                 }
04892                 
04893                                 // print
04894                                 if (!$this->object->isRandomTest())
04895                                 {
04896                                         $tabs_gui->addTarget("print",
04897                                                  $this->ctrl->getLinkTarget($this,'print'),
04898                                                  "print", "");
04899                                 }
04900                 
04901                                 // export
04902                                 $tabs_gui->addTarget("export",
04903                                          $this->ctrl->getLinkTarget($this,'export'),
04904                                          array("export", "createExportFile", "confirmDeleteExportFile",
04905                                          "downloadExportFile", "deleteExportFile", "cancelDeleteExportFile"),
04906                                          "");
04907                                         
04908                                 // maintenance
04909                                 $tabs_gui->addTarget("maintenance",
04910                                          $this->ctrl->getLinkTarget($this,'maintenance'),
04911                                          array("maintenance", "deleteAllUserData", "confirmDeleteAllUserData",
04912                                          "cancelDeleteAllUserData", "deleteSingleUserResults"), 
04913                                          "");
04914                 
04915                                 // status
04916                                 $tabs_gui->addTarget("status",
04917                                          $this->ctrl->getLinkTarget($this,'status'),
04918                                          "status", "");
04919 
04920                                 // learning progress
04921                                 include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
04922                                 if(ilObjUserTracking::_enabledLearningProgress() and $ilAccess->checkAccess("edit_learning_progress", "", $this->ref_id))
04923                                 {
04924                                         $tabs_gui->addTarget('learning_progress',
04925                                                                                  $this->ctrl->getLinkTargetByClass(array('illearningprogressgui'),''),
04926                                                                                  '',
04927                                                                                  array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui',
04928                                                                                            'illplistofprogressgui'));
04929                                 }
04930 
04931                                 // permissions
04932                                 $tabs_gui->addTarget("perm_settings",
04933                                         $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
04934                         }
04935                 }
04936         }
04937         
04946         function _goto($a_target)
04947         {
04948                 global $ilAccess, $ilErr, $lng;
04949 
04950                 if ($ilAccess->checkAccess("visible", "", $a_target))
04951                 {
04952                         //include_once "./classes/class.ilUtil.php";
04953                         $_GET["baseClass"] = "ilObjTestGUI";
04954                         $_GET["cmd"] = "infoScreen";
04955                         $_GET["ref_id"] = $a_target;
04956                         include_once("ilias.php");
04957                         exit;
04958                         //ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=infoScreen&ref_id=$a_target");
04959                 }
04960                 else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
04961                 {
04962                         $_GET["cmd"] = "frameset";
04963                         $_GET["target"] = "";
04964                         $_GET["ref_id"] = ROOT_FOLDER_ID;
04965                         sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
04966                                 ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
04967                         include("repository.php");
04968                         exit;
04969                 }
04970 
04971                 $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
04972         }       
04973 
04974 } // END class.ilObjTestGUI
04975 ?>

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