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