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