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