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 include_once "./classes/class.ilObjectGUI.php";
00042 include_once "./assessment/classes/class.assQuestionGUI.php";
00043 include_once "./assessment/classes/class.ilObjQuestionPool.php";
00044 include_once "./assessment/classes/inc.AssessmentConstants.php";
00045
00046 class ilObjQuestionPoolGUI extends ilObjectGUI
00047 {
00052 function ilObjQuestionPoolGUI()
00053 {
00054 global $lng, $ilCtrl;
00055 $lng->loadLanguageModule("assessment");
00056 $this->type = "qpl";
00057 $this->ctrl =& $ilCtrl;
00058 $this->ctrl->saveParameter($this, array("ref_id", "test_ref_id", "calling_test"));
00059
00060 $this->ilObjectGUI("",$_GET["ref_id"], true, false);
00061 }
00062
00066 function &executeCommand()
00067 {
00068 global $ilLocator;
00069
00070 $this->prepareOutput();
00071 $cmd = $this->ctrl->getCmd("questions");
00072 $next_class = $this->ctrl->getNextClass($this);
00073 $this->ctrl->setReturn($this, "questions");
00074 if ($_GET["q_id"] < 1)
00075 {
00076 $q_type = ($_POST["sel_question_types"] != "")
00077 ? $_POST["sel_question_types"]
00078 : $_GET["sel_question_types"];
00079 }
00080
00081 if ($cmd != "createQuestion" && $cmd != "createQuestionForTest"
00082 && $next_class != "ilpageobjectgui")
00083 {
00084 if (($_GET["test_ref_id"] != "") or ($_GET["calling_test"]))
00085 {
00086 $ref_id = $_GET["test_ref_id"];
00087 if (!$ref_id)
00088 {
00089 $ref_id = $_GET["calling_test"];
00090 }
00091 }
00092 }
00093 switch($next_class)
00094 {
00095 case 'ilmdeditorgui':
00096 include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
00097
00098 $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
00099 $md_gui->addObserver($this->object,'MDUpdateListener','General');
00100 $this->ctrl->forwardCommand($md_gui);
00101 break;
00102 case "ilpageobjectgui":
00103 include_once("classes/class.ilObjStyleSheet.php");
00104 $this->tpl->setCurrentBlock("ContentStyle");
00105 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00106 ilObjStyleSheet::getContentStylePath(0));
00107 $this->tpl->parseCurrentBlock();
00108
00109
00110 $this->tpl->setCurrentBlock("SyntaxStyle");
00111 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
00112 ilObjStyleSheet::getSyntaxStylePath());
00113 $this->tpl->parseCurrentBlock();
00114 $this->setQuestionTabs();
00115 include_once "./assessment/classes/class.assQuestionGUI.php";
00116 $q_gui =& ASS_QuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
00117 $q_gui->outAdditionalOutput();
00118 $q_gui->object->setObjId($this->object->getId());
00119 $question =& $q_gui->object;
00120 $this->ctrl->saveParameter($this, "q_id");
00121 $count = $question->isInUse();
00122 if (($count) && strcmp($this->ctrl->getCmd(), "view") == 0)
00123 {
00124 global $rbacsystem;
00125 if ($rbacsystem->checkAccess("write", $this->ref_id))
00126 {
00127 sendInfo(sprintf($this->lng->txt("qpl_question_is_in_use"), $count));
00128 }
00129 }
00130 include_once("content/classes/Pages/class.ilPageObject.php");
00131 include_once("content/classes/Pages/class.ilPageObjectGUI.php");
00132 $this->lng->loadLanguageModule("content");
00133 $this->ctrl->setReturnByClass("ilPageObjectGUI", "view");
00134 $this->ctrl->setReturn($this, "questions");
00135 $page =& new ilPageObject("qpl", $_GET["q_id"]);
00136 $page_gui =& new ilPageObjectGUI($page);
00137 if (strlen($this->ctrl->getCmd()) == 0)
00138 {
00139 $this->ctrl->setCmdClass(get_class($page_gui));
00140 $this->ctrl->setCmd("preview");
00141 }
00142 $page_gui->setQuestionXML($question->to_xml(false, false, true));
00143 $page_gui->setTemplateTargetVar("ADM_CONTENT");
00144 $page_gui->setOutputMode("edit");
00145 $page_gui->setHeader($question->getTitle());
00146 $page_gui->setFileDownloadLink($this->ctrl->getLinkTarget($this, "downloadFile"));
00147 $page_gui->setFullscreenLink($this->ctrl->getLinkTarget($this, "fullscreen"));
00148 $page_gui->setSourcecodeDownloadScript($this->ctrl->getLinkTarget($this));
00149 $page_gui->setPresentationTitle($question->getTitle());
00150 $ret =& $this->ctrl->forwardCommand($page_gui);
00151 break;
00152 case "ass_multiplechoicegui":
00153 case "ass_clozetestgui":
00154 case "ass_orderingquestiongui":
00155 case "ass_matchingquestiongui":
00156 case "ass_imagemapquestiongui":
00157 case "ass_javaappletgui":
00158 case "ass_textquestiongui":
00159 $this->setQuestionTabs();
00160 $this->ctrl->setReturn($this, "questions");
00161 include_once "./assessment/classes/class.assQuestionGUI.php";
00162 $q_gui =& ASS_QuestionGUI::_getQuestionGUI($q_type, $_GET["q_id"]);
00163 $q_gui->object->setObjId($this->object->getId());
00164 $count = $q_gui->object->isInUse();
00165 if (($count) && strcmp($this->ctrl->getCmd(), "assessment") != 0)
00166 {
00167 global $rbacsystem;
00168 if ($rbacsystem->checkAccess("write", $this->ref_id))
00169 {
00170 sendInfo(sprintf($this->lng->txt("qpl_question_is_in_use"), $count));
00171 }
00172 }
00173 $ret =& $this->ctrl->forwardCommand($q_gui);
00174 break;
00175
00176 case 'ilpermissiongui':
00177 include_once("./classes/class.ilPermissionGUI.php");
00178 $perm_gui =& new ilPermissionGUI($this);
00179 $ret =& $this->ctrl->forwardCommand($perm_gui);
00180 break;
00181
00182 default:
00183 $cmd.= "Object";
00184 $ret =& $this->$cmd();
00185 break;
00186 }
00187
00188 if (strtolower($_GET["baseClass"]) != "iladministrationgui" &&
00189 $this->getCreationMode() != true)
00190 {
00191 $this->tpl->show();
00192 }
00193 }
00194
00198 function propertiesObject()
00199 {
00200 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_qpl_properties.html", true);
00201 $this->tpl->setCurrentBlock("adm_content");
00202 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00203 $this->tpl->setVariable("HEADING_GENERAL", $this->lng->txt("qpl_general_properties"));
00204 $this->tpl->setVariable("PROPERTY_ONLINE", $this->lng->txt("qpl_online_property"));
00205 $this->tpl->setVariable("PROPERTY_ONLINE_DESCRIPTION", $this->lng->txt("qpl_online_property_description"));
00206 if ($this->object->getOnline() == 1)
00207 {
00208 $this->tpl->setVariable("PROPERTY_ONLINE_CHECKED", " checked=\"checked\"");
00209 }
00210 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00211 $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
00212 $this->tpl->parseCurrentBlock();
00213 }
00214
00220 function cancelObject($in_rep = false)
00221 {
00222 sendInfo($this->lng->txt("msg_cancel"),true);
00223 ilUtil::redirect("repository.php?cmd=frameset&ref_id=".$_GET["ref_id"]);
00224 }
00225
00226
00230 function savePropertiesObject()
00231 {
00232 $qpl_online = $_POST["online"];
00233 if (strlen($qpl_online) == 0) $qpl_online = "0";
00234 $this->object->setOnline($qpl_online);
00235 $this->object->saveToDb();
00236 sendInfo($this->lng->txt("saved_successfully"), true);
00237 $this->ctrl->redirect($this, "properties");
00238 }
00239
00243 function downloadFileObject()
00244 {
00245 $file = explode("_", $_GET["file_id"]);
00246 include_once("classes/class.ilObjFile.php");
00247 $fileObj =& new ilObjFile($file[count($file) - 1], false);
00248 $fileObj->sendFile();
00249 exit;
00250 }
00251
00255 function fullscreenObject()
00256 {
00257 include_once("content/classes/Pages/class.ilPageObject.php");
00258 include_once("content/classes/Pages/class.ilPageObjectGUI.php");
00259 $page =& new ilPageObject("qpl", $_GET["pg_id"]);
00260 $page_gui =& new ilPageObjectGUI($page);
00261 $page_gui->showMediaFullscreen();
00262
00263 }
00264
00265
00269 function filterObject()
00270 {
00271 $this->questionsObject();
00272 }
00273
00277 function resetFilterObject()
00278 {
00279 $_POST["filter_text"] = "";
00280 $_POST["sel_filter_type"] = "";
00281 $this->questionsObject();
00282 }
00283
00287 function download_paragraphObject()
00288 {
00289 include_once("content/classes/Pages/class.ilPageObject.php");
00290 $pg_obj =& new ilPageObject("qpl", $_GET["pg_id"]);
00291 $pg_obj->send_paragraph ($_GET["par_id"], $_GET["downloadtitle"]);
00292 exit;
00293 }
00294
00298 function uploadQplObject($questions_only = false)
00299 {
00300 if ($_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK)
00301 {
00302 sendInfo($this->lng->txt("error_upload"));
00303 $this->importObject();
00304 return;
00305 }
00306
00307 include_once "./assessment/classes/class.ilObjQuestionPool.php";
00308 ilObjQuestionPool::_createImportDirectory();
00309
00310
00311 $file = pathinfo($_FILES["xmldoc"]["name"]);
00312 $full_path = ilObjQuestionPool::_getImportDirectory()."/".$_FILES["xmldoc"]["name"];
00313 include_once "./classes/class.ilUtil.php";
00314 ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"], $_FILES["xmldoc"]["name"], $full_path);
00315
00316
00317 ilUtil::unzip($full_path);
00318
00319
00320 $subdir = basename($file["basename"],".".$file["extension"]);
00321 $xml_file = ilObjQuestionPool::_getImportDirectory()."/".$subdir."/".$subdir.".xml";
00322 $qti_file = ilObjQuestionPool::_getImportDirectory()."/".$subdir."/". str_replace("qpl", "qti", $subdir).".xml";
00323
00324
00325 include_once "./assessment/classes/QTI/class.ilQTIParser.php";
00326 $qtiParser = new ilQTIParser($qti_file, IL_MO_VERIFY_QTI, 0, "");
00327 $result = $qtiParser->startParsing();
00328 $founditems =& $qtiParser->getFoundItems();
00329
00330 if (count($founditems) == 0)
00331 {
00332
00333
00334
00335 ilUtil::delDir(ilObjQuestionPool::_getImportDirectory());
00336
00337 sendInfo($this->lng->txt("qpl_import_no_items"));
00338 $this->importObject();
00339 return;
00340 }
00341
00342 $complete = 0;
00343 $incomplete = 0;
00344 foreach ($founditems as $item)
00345 {
00346 if (strlen($item["type"]))
00347 {
00348 $complete++;
00349 }
00350 else
00351 {
00352 $incomplete++;
00353 }
00354 }
00355
00356 if ($complete == 0)
00357 {
00358
00359 ilUtil::delDir(ilObjQuestionPool::_getImportDirectory());
00360
00361 sendInfo($this->lng->txt("qpl_import_non_ilias_files"));
00362 $this->importObject();
00363 return;
00364 }
00365
00366 $_SESSION["qpl_import_xml_file"] = $xml_file;
00367 $_SESSION["qpl_import_qti_file"] = $qti_file;
00368 $_SESSION["qpl_import_subdir"] = $subdir;
00369
00370 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.qpl_import_verification.html");
00371 $row_class = array("tblrow1", "tblrow2");
00372 $counter = 0;
00373 foreach ($founditems as $item)
00374 {
00375 $this->tpl->setCurrentBlock("verification_row");
00376 $this->tpl->setVariable("ROW_CLASS", $row_class[$counter++ % 2]);
00377 $this->tpl->setVariable("QUESTION_TITLE", $item["title"]);
00378 $this->tpl->setVariable("QUESTION_IDENT", $item["ident"]);
00379 switch ($item["type"])
00380 {
00381 case "MULTIPLE CHOICE QUESTION":
00382 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("qt_multiple_choice"));
00383 break;
00384 case "CLOZE QUESTION":
00385 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("qt_cloze"));
00386 break;
00387 case "IMAGE MAP QUESTION":
00388 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("qt_imagemap"));
00389 break;
00390 case "JAVA APPLET QUESTION":
00391 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("qt_javaapplet"));
00392 break;
00393 case "MATCHING QUESTION":
00394 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("qt_matching"));
00395 break;
00396 case "ORDERING QUESTION":
00397 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("qt_ordering"));
00398 break;
00399 case "TEXT QUESTION":
00400 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("qt_text"));
00401 break;
00402 }
00403 $this->tpl->parseCurrentBlock();
00404 }
00405
00406 $this->tpl->setCurrentBlock("import_qpl");
00407 if (is_file($xml_file))
00408 {
00409
00410 $fh = @fopen($xml_file, "r") or die("");
00411 $xml = @fread($fh, filesize($xml_file));
00412 @fclose($fh);
00413 if (preg_match("/<ContentObject.*?MetaData.*?General.*?Title[^>]*?>([^<]*?)</", $xml, $matches))
00414 {
00415 $this->tpl->setVariable("VALUE_NEW_QUESTIONPOOL", $matches[1]);
00416 }
00417 }
00418 $this->tpl->setVariable("TEXT_CREATE_NEW_QUESTIONPOOL", $this->lng->txt("qpl_import_create_new_qpl"));
00419 $this->tpl->parseCurrentBlock();
00420
00421 $this->tpl->setCurrentBlock("adm_content");
00422 $this->tpl->setVariable("TEXT_TYPE", $this->lng->txt("question_type"));
00423 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("question_title"));
00424 $this->tpl->setVariable("FOUND_QUESTIONS_INTRODUCTION", $this->lng->txt("qpl_import_verify_found_questions"));
00425 if ($questions_only)
00426 {
00427 $this->tpl->setVariable("VERIFICATION_HEADING", $this->lng->txt("import_questions_into_qpl"));
00428 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00429 }
00430 else
00431 {
00432 $this->tpl->setVariable("VERIFICATION_HEADING", $this->lng->txt("import_qpl"));
00433
00434 $this->ctrl->setParameter($this, "new_type", $this->type);
00435 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00436
00437
00438 }
00439 $this->tpl->setVariable("ARROW", ilUtil::getImagePath("arrow_downright.gif"));
00440 $this->tpl->setVariable("VALUE_IMPORT", $this->lng->txt("import"));
00441 $this->tpl->setVariable("VALUE_CANCEL", $this->lng->txt("cancel"));
00442 $value_questions_only = 0;
00443 if ($questions_only) $value_questions_only = 1;
00444 $this->tpl->setVariable("VALUE_QUESTIONS_ONLY", $value_questions_only);
00445
00446 $this->tpl->parseCurrentBlock();
00447 }
00448
00452 function importVerifiedFileObject()
00453 {
00454 if ($_POST["questions_only"] == 1)
00455 {
00456 $newObj =& $this->object;
00457 }
00458 else
00459 {
00460 include_once("./assessment/classes/class.ilObjQuestionPool.php");
00461
00462 $newObj = new ilObjQuestionPool(true);
00463
00464 $newObj->setType($_GET["new_type"]);
00465
00466 $newObj->setTitle("dummy");
00467
00468 $newObj->setDescription("questionpool import");
00469
00470 $newObj->create(true);
00471
00472 $newObj->createReference();
00473
00474 $newObj->putInTree($_GET["ref_id"]);
00475
00476 $newObj->setPermissions($_GET["ref_id"]);
00477
00478 $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
00479 }
00480
00481
00482 include_once "./assessment/classes/QTI/class.ilQTIParser.php";
00483 $qtiParser = new ilQTIParser($_SESSION["qpl_import_qti_file"], IL_MO_PARSE_QTI, $newObj->getId(), $_POST["ident"]);
00484 $result = $qtiParser->startParsing();
00485
00486
00487 include_once ("content/classes/class.ilContObjParser.php");
00488 $contParser = new ilContObjParser($newObj, $_SESSION["qpl_import_xml_file"], $_SESSION["qpl_import_subdir"]);
00489 $contParser->setQuestionMapping($qtiParser->getImportMapping());
00490 $contParser->startParsing();
00491
00492
00493 $qpl_name = $_POST["qpl_new"];
00494 if ((strcmp($qpl_name, $newObj->getTitle()) != 0) && (strlen($qpl_name) > 0))
00495 {
00496 $newObj->setTitle($qpl_name);
00497 $newObj->update();
00498 }
00499
00500
00501 include_once "./classes/class.ilUtil.php";
00502 ilUtil::delDir(ilObjQuestionPool::_getImportDirectory());
00503
00504 if ($_POST["questions_only"] == 1)
00505 {
00506 $this->ctrl->redirect($this, "questions");
00507 }
00508 else
00509 {
00510 sendInfo($this->lng->txt("object_imported"),true);
00511 ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
00512 "&baseClass=ilObjQuestionPoolGUI");
00513 }
00514 }
00515
00516 function cancelImportObject()
00517 {
00518 if ($_POST["questions_only"] == 1)
00519 {
00520 $this->ctrl->redirect($this, "questions");
00521 }
00522 else
00523 {
00524 $this->ctrl->redirect($this, "cancel");
00525 }
00526 }
00527
00531 function uploadObject()
00532 {
00533 $this->uploadQplObject(true);
00534 }
00535
00539 function importQuestionsObject()
00540 {
00541 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_import_question.html", true);
00542 $this->tpl->setCurrentBlock("adm_content");
00543 $this->tpl->setVariable("TEXT_IMPORT_QUESTION", $this->lng->txt("import_question"));
00544 $this->tpl->setVariable("TEXT_SELECT_FILE", $this->lng->txt("select_file"));
00545 $this->tpl->setVariable("TEXT_UPLOAD", $this->lng->txt("upload"));
00546 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00547 $this->tpl->parseCurrentBlock();
00548 }
00549
00555 function importObject()
00556 {
00557 global $rbacsystem;
00558 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"]))
00559 {
00560 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00561 }
00562 $this->getTemplateFile("import", "qpl");
00563 $this->ctrl->setParameter($this, "new_type", $this->type);
00564 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00565
00566 $this->tpl->setVariable("BTN_NAME", "uploadQpl");
00567 $this->tpl->setVariable("TXT_UPLOAD", $this->lng->txt("import"));
00568 $this->tpl->setVariable("NEW_TYPE", $this->type);
00569 $this->tpl->setVariable("TXT_IMPORT_QPL", $this->lng->txt("import_qpl"));
00570 $this->tpl->setVariable("TXT_SELECT_MODE", $this->lng->txt("select_mode"));
00571 $this->tpl->setVariable("TXT_SELECT_FILE", $this->lng->txt("select_file"));
00572 $this->tpl->parseCurrentBlock();
00573 }
00574
00578 function &createQuestionObject()
00579 {
00580 include_once "./assessment/classes/class.assQuestionGUI.php";
00581 $q_gui =& ASS_QuestionGUI::_getQuestionGUI($_POST["sel_question_types"]);
00582 $q_gui->object->setObjId($this->object->getId());
00583 $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $_POST["sel_question_types"]);
00584 $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
00585 }
00586
00590 function &createQuestionForTestObject()
00591 {
00592 include_once "./assessment/classes/class.assQuestionGUI.php";
00593 $q_gui =& ASS_QuestionGUI::_getQuestionGUI($_GET["sel_question_types"]);
00594 $q_gui->object->setObjId($this->object->getId());
00595 $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $_GET["sel_question_types"]);
00596 $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
00597 }
00598
00603 function saveObject()
00604 {
00605 global $rbacadmin;
00606
00607
00608 $newObj = parent::saveObject();
00609
00610
00611 sendInfo($this->lng->txt("object_added"),true);
00612
00613 ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
00614 "&baseClass=ilObjQuestionPoolGUI");
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625 }
00626
00630 function assessmentObject()
00631 {
00632 $this->tpl->addBlockFile("CONTENT", "content", "tpl.il_as_qpl_content.html", true);
00633 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00634
00635
00636 sendInfo();
00637
00638 include_once "./assessment/classes/class.assQuestion.php";
00639 $question_title = ASS_Question::_getTitle($_GET["q_id"]);
00640 $title = $this->lng->txt("statistics") . " - $question_title";
00641 if (!empty($title))
00642 {
00643 $this->tpl->setVariable("HEADER", $title);
00644 }
00645 include_once("./assessment/classes/class.assQuestion.php");
00646 $total_of_answers = ASS_Question::_getTotalAnswers($_GET["q_id"]);
00647 $counter = 0;
00648 $color_class = array("tblrow1", "tblrow2");
00649 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_qpl_assessment_of_questions.html", true);
00650 if (!$total_of_answers)
00651 {
00652 $this->tpl->setCurrentBlock("emptyrow");
00653 $this->tpl->setVariable("TXT_NO_ASSESSMENT", $this->lng->txt("qpl_assessment_no_assessment_of_questions"));
00654 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00655 $this->tpl->parseCurrentBlock();
00656 }
00657 else
00658 {
00659 $this->tpl->setCurrentBlock("row");
00660 $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("qpl_assessment_total_of_answers"));
00661 $this->tpl->setVariable("TXT_VALUE", $total_of_answers);
00662 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00663 $counter++;
00664 $this->tpl->parseCurrentBlock();
00665 $this->tpl->setCurrentBlock("row");
00666 $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("qpl_assessment_total_of_right_answers"));
00667 $this->tpl->setVariable("TXT_VALUE", sprintf("%2.2f", ASS_Question::_getTotalRightAnswers($_GET["edit"]) * 100.0) . " %");
00668 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00669 $this->tpl->parseCurrentBlock();
00670 }
00671 $this->tpl->setCurrentBlock("adm_content");
00672 $this->tpl->setVariable("TXT_QUESTION_TITLE", $question_title);
00673 $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("result"));
00674 $this->tpl->setVariable("TXT_VALUE", $this->lng->txt("value"));
00675 $this->tpl->parseCurrentBlock();
00676 }
00677
00678 function questionObject()
00679 {
00680
00681 $type = $_GET["sel_question_types"];
00682 $this->editQuestionForm($type);
00683
00684 }
00685
00689 function deleteQuestionsObject()
00690 {
00691
00692
00693 if (count($_POST["q_id"]) < 1)
00694 {
00695 sendInfo($this->lng->txt("qpl_delete_select_none"), true);
00696 $this->ctrl->redirect($this, "questions");
00697 }
00698
00699 $checked_questions =& $this->object->getQuestionDetails($_POST["q_id"]);
00700 $deleteable_questions =& $this->object->getDeleteableQuestionDetails($_POST["q_id"]);
00701 $used_questions =& $this->object->getUsedQuestionDetails($_POST["q_id"]);
00702 $_SESSION["ass_q_id"] = $deleteable_questions;
00703 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_qpl_confirm_delete_questions.html", true);
00704
00705 $colors = array("tblrow1", "tblrow2");
00706 $counter = 0;
00707 include_once "./classes/class.ilUtil.php";
00708 $img_locked = "<img src=\"" . ilUtil::getImagePath("locked.gif", true) . "\" alt=\"" . $this->lng->txt("locked") . "\" title=\"" . $this->lng->txt("locked") . "\" border=\"0\" />";
00709 if (count($deleteable_questions) > 0)
00710 {
00711 foreach ($deleteable_questions as $question)
00712 {
00713 $this->tpl->setCurrentBlock("row");
00714 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
00715 if ($this->object->isInUse($question["question_id"]))
00716 {
00717 $this->tpl->setVariable("TXT_LOCKED", $img_locked);
00718 }
00719 $this->tpl->setVariable("TXT_TITLE", $question["title"]);
00720 $this->tpl->setVariable("TXT_DESCRIPTION", $question["comment"]);
00721 $this->tpl->setVariable("TXT_TYPE", $this->lng->txt($question["type_tag"]));
00722 $this->tpl->parseCurrentBlock();
00723 $counter++;
00724
00725 $this->tpl->setCurrentBlock("hidden");
00726 $this->tpl->setVariable("HIDDEN_NAME", "id_" . $question["question_id"]);
00727 $this->tpl->setVariable("HIDDEN_VALUE", "1");
00728 $this->tpl->parseCurrentBlock();
00729 }
00730 }
00731 else
00732 {
00733 $this->tpl->setCurrentBlock("emptyrow");
00734 $this->tpl->setVariable("TEXT_EMPTY_ROW", $this->lng->txt("qpl_delete_no_deleteable_questions"));
00735 $this->tpl->parseCurrentBlock();
00736 }
00737
00738 if (count($used_questions))
00739 {
00740 foreach ($used_questions as $question)
00741 {
00742 $this->tpl->setCurrentBlock("undeleteable_row");
00743 $this->tpl->setVariable("QUESTION_TITLE", $question["title"]);
00744 $this->tpl->parseCurrentBlock();
00745 }
00746 $this->tpl->setCurrentBlock("undeleteable_questions");
00747 $this->tpl->setVariable("TEXT_UNDELETEABLE_QUESTIONS", $this->lng->txt("qpl_delete_describe_undeleteable_questions"));
00748 $this->tpl->parseCurrentBlock();
00749 }
00750
00751 $this->tpl->setCurrentBlock("adm_content");
00752 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("tst_question_title"));
00753 $this->tpl->setVariable("TXT_DESCRIPTION", $this->lng->txt("description"));
00754 $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("tst_question_type"));
00755 $this->tpl->setVariable("TXT_LOCKED", $this->lng->txt("locked"));
00756 $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
00757 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
00758 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00759 $this->tpl->setVariable("DELETE_QUESTION", $this->lng->txt("qpl_confirm_delete_questions"));
00760 $this->tpl->parseCurrentBlock();
00761 }
00762
00763
00767 function confirmDeleteQuestionsObject()
00768 {
00769
00770 if (count($_SESSION["ass_q_id"])) sendInfo($this->lng->txt("qpl_questions_deleted"), true);
00771 foreach ($_SESSION["ass_q_id"] as $key => $value)
00772 {
00773 $this->object->deleteQuestion($value["question_id"]);
00774 }
00775 $this->ctrl->redirect($this, "questions");
00776 }
00777
00781 function cancelDeleteQuestionsObject()
00782 {
00783 $this->ctrl->redirect($this, "questions");
00784 }
00785
00789 function duplicateObject()
00790 {
00791
00792 if (count($_POST["q_id"]) > 0)
00793 {
00794 foreach ($_POST["q_id"] as $key => $value)
00795 {
00796 $this->object->duplicateQuestion($value);
00797 }
00798 }
00799 else
00800 {
00801 sendInfo($this->lng->txt("qpl_duplicate_select_none"), true);
00802 }
00803 $this->ctrl->redirect($this, "questions");
00804 }
00805
00809 function exportQuestionObject()
00810 {
00811
00812 if (count($_POST["q_id"]) > 0)
00813 {
00814 include_once("assessment/classes/class.ilQuestionpoolExport.php");
00815 $qpl_exp = new ilQuestionpoolExport($this->object, "xml", $_POST["q_id"]);
00816 $export_file = $qpl_exp->buildExportFile();
00817 $filename = $export_file;
00818 $filename = preg_replace("/.*\//", "", $filename);
00819 include_once "./classes/class.ilUtil.php";
00820 ilUtil::deliverFile($export_file, $filename);
00821 exit();
00822 }
00823 else
00824 {
00825 sendInfo($this->lng->txt("qpl_export_select_none"), true);
00826 }
00827 $this->ctrl->redirect($this, "questions");
00828 }
00829
00833 function questionsObject()
00834 {
00835 global $rbacsystem;
00836 global $ilUser;
00837
00838 $lastquestiontype = $ilUser->getPref("tst_lastquestiontype");
00839 $type = $_GET["sel_question_types"];
00840
00841
00842 $_SESSION["test_id"] = "";
00843
00844
00845 $checked_questions = array();
00846 foreach ($_POST as $key => $value)
00847 {
00848 if (preg_match("/cb_(\d+)/", $key, $matches))
00849 {
00850 array_push($checked_questions, $matches[1]);
00851 }
00852 }
00853
00854 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.qpl_questions.html", true);
00855 if ($rbacsystem->checkAccess('write', $this->ref_id))
00856 {
00857 $this->tpl->addBlockFile("CREATE_QUESTION", "create_question", "tpl.il_as_create_new_question.html", true);
00858 $this->tpl->addBlockFile("A_BUTTONS", "a_buttons", "tpl.il_as_qpl_action_buttons.html", true);
00859 }
00860 $this->tpl->addBlockFile("FILTER_QUESTION_MANAGER", "filter_questions", "tpl.il_as_qpl_filter_questions.html", true);
00861
00862
00863 $filter_fields = array(
00864 "title" => $this->lng->txt("title"),
00865 "comment" => $this->lng->txt("description"),
00866 "author" => $this->lng->txt("author"),
00867 );
00868 $this->tpl->setCurrentBlock("filterrow");
00869 foreach ($filter_fields as $key => $value)
00870 {
00871 $this->tpl->setVariable("VALUE_FILTER_TYPE", "$key");
00872 $this->tpl->setVariable("NAME_FILTER_TYPE", "$value");
00873 if (strcmp($_POST["sel_filter_type"], $key) == 0)
00874 {
00875 $this->tpl->setVariable("VALUE_FILTER_SELECTED", " selected=\"selected\"");
00876 }
00877 $this->tpl->parseCurrentBlock();
00878 }
00879
00880 $this->tpl->setCurrentBlock("filter_questions");
00881 $this->tpl->setVariable("FILTER_TEXT", $this->lng->txt("filter"));
00882 $this->tpl->setVariable("TEXT_FILTER_BY", $this->lng->txt("by"));
00883 $this->tpl->setVariable("VALUE_FILTER_TEXT", $_POST["filter_text"]);
00884 $this->tpl->setVariable("VALUE_SUBMIT_FILTER", $this->lng->txt("set_filter"));
00885 $this->tpl->setVariable("VALUE_RESET_FILTER", $this->lng->txt("reset_filter"));
00886 $this->tpl->parseCurrentBlock();
00887
00888
00889 if ($rbacsystem->checkAccess('write', $this->ref_id))
00890 {
00891 $this->tpl->setCurrentBlock("standard");
00892 $this->tpl->setVariable("DELETE", $this->lng->txt("delete"));
00893 $this->tpl->setVariable("DUPLICATE", $this->lng->txt("duplicate"));
00894 $this->tpl->setVariable("EXPORT", $this->lng->txt("export"));
00895 $this->tpl->setVariable("COPY", $this->lng->txt("copy"));
00896 $this->tpl->setVariable("MOVE", $this->lng->txt("move"));
00897 $this->tpl->parseCurrentBlock();
00898 if (array_key_exists("qpl_clipboard", $_SESSION))
00899 {
00900 $this->tpl->setCurrentBlock("pastebutton");
00901 $this->tpl->setVariable("PASTE", $this->lng->txt("paste"));
00902 $this->tpl->parseCurrentBlock();
00903 }
00904 $this->tpl->setCurrentBlock("Footer");
00905 include_once "./classes/class.ilUtil.php";
00906 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\"/>");
00907 $this->tpl->parseCurrentBlock();
00908 }
00909
00910 $this->tpl->setCurrentBlock("QTab");
00911
00912
00913 $startrow = 0;
00914 if ($_GET["prevrow"])
00915 {
00916 $startrow = $_GET["prevrow"];
00917 }
00918 if ($_GET["nextrow"])
00919 {
00920 $startrow = $_GET["nextrow"];
00921 }
00922 if ($_GET["startrow"])
00923 {
00924 $startrow = $_GET["startrow"];
00925 }
00926 if (!$_GET["sort"])
00927 {
00928
00929 $_GET["sort"] = array("title" => "ASC");
00930 }
00931 $table = $this->object->getQuestionsTable($_GET["sort"], $_POST["filter_text"], $_POST["sel_filter_type"], $startrow);
00932 $colors = array("tblrow1", "tblrow2");
00933 include_once "./classes/class.ilUtil.php";
00934 $img_locked = "<img src=\"" . ilUtil::getImagePath("locked.gif", true) . "\" alt=\"" . $this->lng->txt("locked") . "\" title=\"" . $this->lng->txt("locked") . "\" border=\"0\" />";
00935 $counter = 0;
00936 $editable = $rbacsystem->checkAccess('write', $this->ref_id);
00937 foreach ($table["rows"] as $data)
00938 {
00939 if ($data["complete"] == 0)
00940 {
00941 $this->tpl->setCurrentBlock("qpl_warning");
00942 $this->tpl->setVariable("IMAGE_WARNING", ilUtil::getImagePath("warning.gif"));
00943 $this->tpl->setVariable("ALT_WARNING", $this->lng->txt("warning_question_not_complete"));
00944 $this->tpl->setVariable("TITLE_WARNING", $this->lng->txt("warning_question_not_complete"));
00945 $this->tpl->parseCurrentBlock();
00946 $this->tpl->setCurrentBlock("QTab");
00947 }
00948 $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
00949 include_once "./assessment/classes/class.assQuestionGUI.php";
00950 $class = strtolower(ASS_QuestionGUI::_getGUIClassNameForId($data["question_id"]));
00951 $this->ctrl->setParameterByClass("ilpageobjectgui", "q_id", $data["question_id"]);
00952 $this->ctrl->setParameterByClass($class, "q_id", $data["question_id"]);
00953 if ($editable)
00954 {
00955 $this->tpl->setVariable("TXT_EDIT", $this->lng->txt("edit"));
00956 $this->tpl->setVariable("LINK_EDIT", $this->ctrl->getLinkTargetByClass("ilpageobjectgui", "view"));
00957 }
00958 $this->tpl->setVariable("QUESTION_TITLE", "<strong>" .$data["title"] . "</strong>");
00959
00960 $this->tpl->setVariable("TXT_PREVIEW", $this->lng->txt("preview"));
00961 $this->tpl->setVariable("LINK_PREVIEW", $this->ctrl->getLinkTargetByClass("ilpageobjectgui", "preview"));
00962
00963 $this->tpl->setVariable("QUESTION_COMMENT", $data["comment"]);
00964 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($data["type_tag"]));
00965 $this->tpl->setVariable("LINK_ASSESSMENT", $this->ctrl->getLinkTargetByClass($class, "assessment"));
00966 $this->tpl->setVariable("TXT_ASSESSMENT", $this->lng->txt("statistics"));
00967 include_once "./classes/class.ilUtil.php";
00968 $this->tpl->setVariable("IMG_ASSESSMENT", ilUtil::getImagePath("assessment.gif", true));
00969 $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]);
00970 include_once "./classes/class.ilFormat.php";
00971 $this->tpl->setVariable("QUESTION_CREATED", ilFormat::formatDate(ilFormat::ftimestamp2dateDB($data["created"]), "date"));
00972 $this->tpl->setVariable("QUESTION_UPDATED", ilFormat::formatDate(ilFormat::ftimestamp2dateDB($data["TIMESTAMP14"]), "date"));
00973 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
00974 $this->tpl->parseCurrentBlock();
00975 $counter++;
00976 }
00977
00978 if ($table["rowcount"] > count($table["rows"]))
00979 {
00980 $nextstep = $table["nextrow"] + $table["step"];
00981 if ($nextstep > $table["rowcount"])
00982 {
00983 $nextstep = $table["rowcount"];
00984 }
00985 $sort = "";
00986 if (is_array($_GET["sort"]))
00987 {
00988 $key = key($_GET["sort"]);
00989 $sort = "&sort[$key]=" . $_GET["sort"]["$key"];
00990 }
00991 $counter = 1;
00992 for ($i = 0; $i < $table["rowcount"]; $i += $table["step"])
00993 {
00994 $this->tpl->setCurrentBlock("pages");
00995 if ($table["startrow"] == $i)
00996 {
00997 $this->tpl->setVariable("PAGE_NUMBER", "<span class=\"inactivepage\">$counter</span>");
00998 }
00999 else
01000 {
01001 $this->tpl->setVariable("PAGE_NUMBER", "<a href=\"" . $this->ctrl->getFormAction($this) . "$sort&nextrow=$i" . "\">$counter</a>");
01002 }
01003 $this->tpl->parseCurrentBlock();
01004 $counter++;
01005 }
01006 $this->tpl->setCurrentBlock("navigation_bottom");
01007 $this->tpl->setVariable("TEXT_ITEM", $this->lng->txt("item"));
01008 $this->tpl->setVariable("TEXT_ITEM_START", $table["startrow"] + 1);
01009 $end = $table["startrow"] + $table["step"];
01010 if ($end > $table["rowcount"])
01011 {
01012 $end = $table["rowcount"];
01013 }
01014 $this->tpl->setVariable("TEXT_ITEM_END", $end);
01015 $this->tpl->setVariable("TEXT_OF", strtolower($this->lng->txt("of")));
01016 $this->tpl->setVariable("TEXT_ITEM_COUNT", $table["rowcount"]);
01017 $this->tpl->setVariable("TEXT_PREVIOUS", $this->lng->txt("previous"));
01018 $this->tpl->setVariable("TEXT_NEXT", $this->lng->txt("next"));
01019 $this->tpl->setVariable("HREF_PREV_ROWS", $this->ctrl->getFormAction($this) . "$sort&prevrow=" . $table["prevrow"]);
01020 $this->tpl->setVariable("HREF_NEXT_ROWS", $this->ctrl->getFormAction($this) . "$sort&nextrow=" . $table["nextrow"]);
01021 $this->tpl->parseCurrentBlock();
01022 }
01023
01024
01025 if ($counter == 0)
01026 {
01027 $this->tpl->setCurrentBlock("Emptytable");
01028 $this->tpl->setVariable("TEXT_EMPTYTABLE", $this->lng->txt("no_questions_available"));
01029 $this->tpl->parseCurrentBlock();
01030 }
01031 else
01032 {
01033 if ($rbacsystem->checkAccess('write', $this->ref_id))
01034 {
01035 $counter++;
01036 $this->tpl->setCurrentBlock("selectall");
01037 $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
01038 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
01039 $this->tpl->parseCurrentBlock();
01040 }
01041 }
01042
01043 if ($rbacsystem->checkAccess('write', $this->ref_id))
01044 {
01045
01046 $this->tpl->setCurrentBlock("QTypes");
01047 $query = "SELECT * FROM qpl_question_type ORDER BY question_type_id";
01048 $query_result = $this->ilias->db->query($query);
01049 while ($data = $query_result->fetchRow(DB_FETCHMODE_OBJECT))
01050 {
01051 if ($data->question_type_id == $lastquestiontype)
01052 {
01053 $this->tpl->setVariable("QUESTION_TYPE_SELECTED", " selected=\"selected\"");
01054 }
01055 $this->tpl->setVariable("QUESTION_TYPE_ID", $data->type_tag);
01056 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($data->type_tag));
01057 $this->tpl->parseCurrentBlock();
01058
01059 }
01060 $this->tpl->setCurrentBlock("CreateQuestion");
01061 $this->tpl->setVariable("QUESTION_ADD", $this->lng->txt("create"));
01062 $this->tpl->setVariable("ACTION_QUESTION_ADD", $this->ctrl->getFormAction($this));
01063 $this->tpl->setVariable("QUESTION_IMPORT", $this->lng->txt("import"));
01064 $this->tpl->parseCurrentBlock();
01065 }
01066
01067
01068 $sort = array(
01069 "title" => $_GET["sort"]["title"],
01070 "comment" => $_GET["sort"]["comment"],
01071 "type" => $_GET["sort"]["type"],
01072 "author" => $_GET["sort"]["author"],
01073 "created" => $_GET["sort"]["created"],
01074 "updated" => $_GET["sort"]["updated"]
01075 );
01076 foreach ($sort as $key => $value)
01077 {
01078 if (strcmp($value, "ASC") == 0)
01079 {
01080 $sort[$key] = "DESC";
01081 }
01082 else
01083 {
01084 $sort[$key] = "ASC";
01085 }
01086 }
01087
01088 $this->tpl->setCurrentBlock("adm_content");
01089
01090 $this->ctrl->setParameterByClass(get_class($this), "startrow", $table["startrow"]);
01091 $this->tpl->setVariable("QUESTION_TITLE", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&sort[title]=" . $sort["title"] . "\">" . $this->lng->txt("title") . "</a>" . $table["images"]["title"]);
01092 $this->tpl->setVariable("QUESTION_COMMENT", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&sort[comment]=" . $sort["comment"] . "\">" . $this->lng->txt("description") . "</a>". $table["images"]["comment"]);
01093 $this->tpl->setVariable("QUESTION_TYPE", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&sort[type]=" . $sort["type"] . "\">" . $this->lng->txt("question_type") . "</a>" . $table["images"]["type"]);
01094 $this->tpl->setVariable("QUESTION_AUTHOR", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&sort[author]=" . $sort["author"] . "\">" . $this->lng->txt("author") . "</a>" . $table["images"]["author"]);
01095 $this->tpl->setVariable("QUESTION_CREATED", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&sort[created]=" . $sort["created"] . "\">" . $this->lng->txt("create_date") . "</a>" . $table["images"]["created"]);
01096 $this->tpl->setVariable("QUESTION_UPDATED", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&sort[updated]=" . $sort["updated"] . "\">" . $this->lng->txt("last_update") . "</a>" . $table["images"]["updated"]);
01097 $this->tpl->setVariable("ACTION_QUESTION_FORM", $this->ctrl->getFormAction($this));
01098 $this->tpl->parseCurrentBlock();
01099 }
01100
01101 function updateObject()
01102 {
01103
01104 $this->update = $this->object->update();
01105 sendInfo($this->lng->txt("msg_obj_modified"), true);
01106 }
01107
01111 function pasteObject()
01112 {
01113 if (array_key_exists("qpl_clipboard", $_SESSION))
01114 {
01115 $this->object->pasteFromClipboard();
01116 sendInfo($this->lng->txt("qpl_paste_success"), true);
01117 }
01118 else
01119 {
01120 sendInfo($this->lng->txt("qpl_paste_no_objects"), true);
01121 }
01122 $this->ctrl->redirect($this, "questions");
01123 }
01124
01128 function copyObject()
01129 {
01130 if (count($_POST["q_id"]) > 0)
01131 {
01132 foreach ($_POST["q_id"] as $key => $value)
01133 {
01134 $this->object->copyToClipboard($value);
01135 }
01136 sendInfo($this->lng->txt("qpl_copy_insert_clipboard"), true);
01137 }
01138 else
01139 {
01140 sendInfo($this->lng->txt("qpl_copy_select_none"), true);
01141 }
01142 $this->ctrl->redirect($this, "questions");
01143 }
01144
01148 function moveObject()
01149 {
01150 if (count($_POST["q_id"]) > 0)
01151 {
01152 foreach ($_POST["q_id"] as $key => $value)
01153 {
01154 $this->object->moveToClipboard($value);
01155 }
01156 sendInfo($this->lng->txt("qpl_move_insert_clipboard"), true);
01157 }
01158 else
01159 {
01160 sendInfo($this->lng->txt("qpl_move_select_none"), true);
01161 }
01162 $this->ctrl->redirect($this, "questions");
01163 }
01164
01165
01166
01167
01168 function exportObject()
01169 {
01170 global $tree;
01171
01172
01173 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
01174
01175
01176 $this->tpl->setCurrentBlock("btn_cell");
01177 $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "createExportFile"));
01178 $this->tpl->setVariable("BTN_TXT", $this->lng->txt("ass_create_export_file"));
01179 $this->tpl->parseCurrentBlock();
01180
01181 $export_dir = $this->object->getExportDirectory();
01182 $export_files = $this->object->getExportFiles($export_dir);
01183
01184
01185 include_once("classes/class.ilTableGUI.php");
01186 $tbl = new ilTableGUI();
01187
01188
01189 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
01190
01191
01192 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.export_file_row.html", true);
01193
01194 $num = 0;
01195
01196 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01197
01198 $tbl->setTitle($this->lng->txt("ass_export_files"));
01199
01200 $tbl->setHeaderNames(array("", $this->lng->txt("ass_file"),
01201 $this->lng->txt("ass_size"), $this->lng->txt("date") ));
01202 $tbl->enabled["sort"] = false;
01203 $tbl->setColumnWidth(array("1%", "49%", "25%", "25%"));
01204
01205
01206 $tbl->setOrderColumn($_GET["sort_by"]);
01207 $tbl->setOrderDirection($_GET["sort_order"]);
01208 $tbl->setLimit($_GET["limit"]);
01209 $tbl->setOffset($_GET["offset"]);
01210
01211
01212 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
01213
01214
01215 $tbl->setMaxCount(count($export_files));
01216 $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
01217
01218 $tbl->render();
01219 include_once "./classes/class.ilUtil.php";
01220 if(count($export_files) > 0)
01221 {
01222 $this->tpl->setVariable("COLUMN_COUNTS", 4);
01223
01224 $i=0;
01225 foreach($export_files as $exp_file)
01226 {
01227 $this->tpl->setCurrentBlock("tbl_content");
01228 $this->tpl->setVariable("TXT_FILENAME", $exp_file);
01229
01230 $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
01231 $this->tpl->setVariable("CSS_ROW", $css_row);
01232
01233 $this->tpl->setVariable("TXT_SIZE", filesize($export_dir."/".$exp_file));
01234 $this->tpl->setVariable("CHECKBOX_ID", $exp_file);
01235
01236 $file_arr = explode("__", $exp_file);
01237 $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s",$file_arr[0]));
01238
01239 $this->tpl->parseCurrentBlock();
01240 }
01241 $this->tpl->setCurrentBlock("selectall");
01242 $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
01243 $this->tpl->setVariable("CSS_ROW", $css_row);
01244 $this->tpl->parseCurrentBlock();
01245
01246
01247 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
01248 $this->tpl->setCurrentBlock("tbl_action_btn");
01249 $this->tpl->setVariable("BTN_NAME", "confirmDeleteExportFile");
01250 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
01251 $this->tpl->parseCurrentBlock();
01252
01253 $this->tpl->setCurrentBlock("tbl_action_btn");
01254 $this->tpl->setVariable("BTN_NAME", "downloadExportFile");
01255 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("download"));
01256 $this->tpl->parseCurrentBlock();
01257 }
01258 else
01259 {
01260 $this->tpl->setCurrentBlock("notfound");
01261 $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
01262 $this->tpl->setVariable("NUM_COLS", 3);
01263 $this->tpl->parseCurrentBlock();
01264 }
01265
01266 $this->tpl->parseCurrentBlock();
01267 }
01268
01269
01273 function createExportFileObject()
01274 {
01275 global $rbacsystem;
01276 if ($rbacsystem->checkAccess("write", $this->ref_id))
01277 {
01278 include_once("assessment/classes/class.ilQuestionpoolExport.php");
01279 $question_ids =& $this->object->getAllQuestionIds();
01280 $qpl_exp = new ilQuestionpoolExport($this->object, "xml", $question_ids);
01281 $qpl_exp->buildExportFile();
01282 $this->exportObject();
01283 }
01284 else
01285 {
01286 sendInfo("cannot_export_qpl");
01287 }
01288 }
01289
01293 function downloadExportFileObject()
01294 {
01295 if(!isset($_POST["file"]))
01296 {
01297 sendInfo($this->lng->txt("no_checkbox"), true);
01298 $this->ctrl->redirect($this, "export");
01299 }
01300
01301 if (count($_POST["file"]) > 1)
01302 {
01303 sendInfo($this->lng->txt("cont_select_max_one_item"), true);
01304 $this->ctrl->redirect($this, "export");
01305 }
01306
01307
01308 $export_dir = $this->object->getExportDirectory();
01309 include_once "./classes/class.ilUtil.php";
01310 ilUtil::deliverFile($export_dir."/".$_POST["file"][0],
01311 $_POST["file"][0]);
01312 $this->ctrl->redirect($this, "export");
01313 }
01314
01318 function confirmDeleteExportFileObject()
01319 {
01320 if(!isset($_POST["file"]))
01321 {
01322 sendInfo($this->lng->txt("no_checkbox"), true);
01323 $this->ctrl->redirect($this, "export");
01324 }
01325
01326
01327 $_SESSION["ilExportFiles"] = $_POST["file"];
01328
01329 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html", true);
01330
01331 sendInfo($this->lng->txt("info_delete_sure"));
01332
01333 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01334
01335
01336 $this->tpl->setCurrentBlock("table_header");
01337 $this->tpl->setVariable("TEXT",$this->lng->txt("objects"));
01338 $this->tpl->parseCurrentBlock();
01339
01340
01341 $counter = 0;
01342 include_once "./classes/class.ilUtil.php";
01343 foreach($_POST["file"] as $file)
01344 {
01345 $this->tpl->setCurrentBlock("table_row");
01346 $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
01347 $this->tpl->setVariable("TEXT_CONTENT", $file);
01348 $this->tpl->parseCurrentBlock();
01349 }
01350
01351
01352 $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
01353 $buttons = array(
01354 "deleteExportFile" => $this->lng->txt("confirm"),
01355 "cancelDeleteExportFile" => $this->lng->txt("cancel")
01356 );
01357 foreach ($buttons as $name => $value)
01358 {
01359 $this->tpl->setCurrentBlock("operation_btn");
01360 $this->tpl->setVariable("BTN_NAME",$name);
01361 $this->tpl->setVariable("BTN_VALUE",$value);
01362 $this->tpl->parseCurrentBlock();
01363 }
01364 }
01365
01366
01370 function cancelDeleteExportFileObject()
01371 {
01372 session_unregister("ilExportFiles");
01373 $this->ctrl->redirect($this, "export");
01374 }
01375
01379 function deleteExportFileObject()
01380 {
01381 include_once "./classes/class.ilUtil.php";
01382 $export_dir = $this->object->getExportDirectory();
01383 foreach($_SESSION["ilExportFiles"] as $file)
01384 {
01385 $exp_file = $export_dir."/".$file;
01386 $exp_dir = $export_dir."/".substr($file, 0, strlen($file) - 4);
01387 if (@is_file($exp_file))
01388 {
01389 unlink($exp_file);
01390 }
01391 if (@is_dir($exp_dir))
01392 {
01393 ilUtil::delDir($exp_dir);
01394 }
01395 }
01396 $this->ctrl->redirect($this, "export");
01397 }
01398
01402 function &editQuestionForTestObject()
01403 {
01404 include_once "./assessment/classes/class.assQuestionGUI.php";
01405 $q_gui =& ASS_QuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
01406 $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
01407 }
01408
01412 function createObject()
01413 {
01414 global $rbacsystem;
01415 $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
01416 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
01417 {
01418 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
01419 }
01420 else
01421 {
01422 $this->getTemplateFile("create", $new_type);
01423
01424 $qpls =& ilObjQuestionPool::_getAvailableQuestionpools(true);
01425 if (count($qpls) > 0)
01426 {
01427 foreach ($qpls as $key => $value)
01428 {
01429 $this->tpl->setCurrentBlock("option_qpl");
01430 $this->tpl->setVariable("OPTION_VALUE_QPL", $key);
01431 $this->tpl->setVariable("TXT_OPTION_QPL", $value);
01432 if ($_POST["qpl"] == $key)
01433 {
01434 $this->tpl->setVariable("OPTION_SELECTED_QPL", " selected=\"selected\"");
01435 }
01436 $this->tpl->parseCurrentBlock();
01437 }
01438 }
01439
01440
01441 $data = array();
01442 $data["fields"] = array();
01443 include_once "./classes/class.ilUtil.php";
01444 $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
01445 $data["fields"]["desc"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["desc"]);
01446
01447 foreach ($data["fields"] as $key => $val)
01448 {
01449 $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
01450 $this->tpl->setVariable(strtoupper($key), $val);
01451
01452 if ($this->prepare_output)
01453 {
01454 $this->tpl->parseCurrentBlock();
01455 }
01456 }
01457
01458 $this->ctrl->setParameter($this, "new_type", $this->type);
01459 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01460
01461
01462 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
01463 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
01464 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
01465 $this->tpl->setVariable("CMD_SUBMIT", "save");
01466 $this->tpl->setVariable("TARGET", ' target="'.
01467 ilFrameTargetInfo::_getFrame("MainContent").'" ');
01468 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
01469
01470 $this->tpl->setVariable("TXT_IMPORT_QPL", $this->lng->txt("import_qpl"));
01471 $this->tpl->setVariable("TXT_QPL_FILE", $this->lng->txt("qpl_upload_file"));
01472 $this->tpl->setVariable("NEW_TYPE", $this->type);
01473 $this->tpl->setVariable("TXT_IMPORT", $this->lng->txt("import"));
01474
01475 $this->tpl->setVariable("TXT_DUPLICATE_QPL", $this->lng->txt("duplicate_qpl"));
01476 $this->tpl->setVariable("TXT_SELECT_QPL", $this->lng->txt("obj_qpl"));
01477 $this->tpl->setVariable("OPTION_SELECT_QPL", $this->lng->txt("select_qpl_option"));
01478 $this->tpl->setVariable("TXT_DUPLICATE", $this->lng->txt("duplicate"));
01479
01480 $this->tpl->parseCurrentBlock();
01481 }
01482 }
01483
01487 function cloneAllObject()
01488 {
01489 if ($_POST["qpl"] < 1)
01490 {
01491 sendInfo($this->lng->txt("tst_select_qpls"));
01492 $this->createObject();
01493 return;
01494 }
01495 $ref_id = ilObjQuestionPool::_clone($_POST["qpl"]);
01496 sendInfo($this->lng->txt("object_duplicated"),true);
01497 ilUtil::redirect("ilias.php?ref_id=$ref_id&baseClass=ilObjQuestionPoolGUI");
01498 }
01499
01503 function importFileObject()
01504 {
01505 if (strcmp($_FILES["xmldoc"]["tmp_name"], "") == 0)
01506 {
01507 sendInfo($this->lng->txt("qpl_select_file_for_import"));
01508 $this->createObject();
01509 return;
01510 }
01511 $this->uploadQplObject();
01512 }
01513
01514 function addLocatorItems()
01515 {
01516 global $ilLocator;
01517 switch ($this->ctrl->getCmd())
01518 {
01519 case "create":
01520 case "importFile":
01521 case "cancel":
01522 break;
01523 default:
01524 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""));
01525 break;
01526 }
01527 if ($_GET["q_id"] > 0)
01528 {
01529 include_once "./assessment/classes/class.assQuestionGUI.php";
01530 $q_gui =& ASS_QuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
01531 $q_gui->object->setObjId($this->object->getId());
01532 if ($_GET["q_id"] > 0)
01533 {
01534 $ilLocator->addItem($q_gui->object->getTitle(), $this->ctrl->getLinkTargetByClass(get_class($q_gui), "editQuestion"));
01535 }
01536 }
01537 }
01538
01542 function setTitleAndDescription()
01543 {
01544 if ($_GET["q_id"] > 0)
01545 {
01546 include_once "./assessment/classes/class.assQuestionGUI.php";
01547 $q_gui =& ASS_QuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
01548 $q_gui->object->setObjId($this->object->getId());
01549 $title = $q_gui->object->getTitle();
01550 if (strcmp($this->ctrl->getCmd(), "assessment") == 0)
01551 {
01552 $title .= " - " . $this->lng->txt("statistics");
01553 }
01554 $this->tpl->setTitle($title);
01555 $this->tpl->setDescription($q_gui->object->getComment());
01556 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_".$this->object->getType()."_b.gif"), $this->lng->txt("obj_qpl"));
01557 }
01558 else
01559 {
01560 $this->tpl->setTitle($this->object->getTitle());
01561 $this->tpl->setDescription($this->object->getLongDescription());
01562 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_".$this->object->getType()."_b.gif"), $this->lng->txt("obj_qpl"));
01563 }
01564 }
01565
01566 function setQuestionTabs()
01567 {
01568 global $rbacsystem;
01569
01570 $this->ctrl->setParameterByClass("ilpageobjectgui", "q_id", $_GET["q_id"]);
01571 include_once "./assessment/classes/class.assQuestion.php";
01572 $q_type = ASS_Question::getQuestionTypeFromDb($_GET["q_id"]);
01573
01574 switch ($q_type)
01575 {
01576 case "qt_multiple_choice_sr":
01577 $classname = "ASS_MultipleChoiceGUI";
01578 $this->ctrl->setParameterByClass("ass_multiplechoicegui", "sel_question_types", $q_type);
01579 $this->ctrl->setParameterByClass("ass_multiplechoicegui", "q_id", $_GET["q_id"]);
01580 break;
01581
01582 case "qt_multiple_choice_mr":
01583 $classname = "ASS_MultipleChoiceGUI";
01584 $this->ctrl->setParameterByClass("ass_multiplechoicegui", "sel_question_types", $q_type);
01585 $this->ctrl->setParameterByClass("ass_multiplechoicegui", "q_id", $_GET["q_id"]);
01586 break;
01587
01588 case "qt_cloze":
01589 $classname = "ASS_ClozeTestGUI";
01590 $this->ctrl->setParameterByClass("ass_clozetestgui", "sel_question_types", $q_type);
01591 $this->ctrl->setParameterByClass("ass_clozetestgui", "q_id", $_GET["q_id"]);
01592 break;
01593
01594 case "qt_matching":
01595 $classname = "ASS_MatchingQuestionGUI";
01596 $this->ctrl->setParameterByClass("ass_matchingquestiongui", "sel_question_types", $q_type);
01597 $this->ctrl->setParameterByClass("ass_matchingquestiongui", "q_id", $_GET["q_id"]);
01598 break;
01599
01600 case "qt_ordering":
01601 $classname = "ASS_OrderingQuestionGUI";
01602 $this->ctrl->setParameterByClass("ass_orderingquestiongui", "sel_question_types", $q_type);
01603 $this->ctrl->setParameterByClass("ass_orderingquestiongui", "q_id", $_GET["q_id"]);
01604 break;
01605
01606 case "qt_imagemap":
01607 $classname = "ASS_ImagemapQuestionGUI";
01608 $this->ctrl->setParameterByClass("ass_imagemapquestiongui", "sel_question_types", $q_type);
01609 $this->ctrl->setParameterByClass("ass_imagemapquestiongui", "q_id", $_GET["q_id"]);
01610 break;
01611
01612 case "qt_javaapplet":
01613 $classname = "ASS_JavaAppletGUI";
01614 $this->ctrl->setParameterByClass("ass_javaappletgui", "sel_question_types", $q_type);
01615 $this->ctrl->setParameterByClass("ass_javaappletgui", "q_id", $_GET["q_id"]);
01616 break;
01617
01618 case "qt_text":
01619 $classname = "ASS_TextQuestionGUI";
01620 $this->ctrl->setParameterByClass("ass_textquestiongui", "sel_question_types", $q_type);
01621 $this->ctrl->setParameterByClass("ass_textquestiongui", "q_id", $_GET["q_id"]);
01622 break;
01623 }
01624
01625 if ($_GET["q_id"])
01626 {
01627 if ($rbacsystem->checkAccess('write', $this->ref_id))
01628 {
01629
01630 $this->tabs_gui->addSubTabTarget("edit_content",
01631 $this->ctrl->getLinkTargetByClass("ilPageObjectGUI", "view"),
01632 array("view", "insert", "exec_pg"),
01633 "", "", $force_active);
01634 }
01635
01636
01637 $this->tabs_gui->addSubTabTarget("preview",
01638 $this->ctrl->getLinkTargetByClass("ilPageObjectGUI", "preview"),
01639 array("preview"),
01640 "ilPageObjectGUI", "", $force_active);
01641 }
01642
01643 if ($classname)
01644 {
01645 $force_active = false;
01646 $commands = $_POST["cmd"];
01647 if (is_array($commands))
01648 {
01649 foreach ($commands as $key => $value)
01650 {
01651 if (preg_match("/^delete_.*/", $key, $matches) ||
01652 preg_match("/^addSelectGap_.*/", $key, $matches) ||
01653 preg_match("/^addTextGap_.*/", $key, $matches) ||
01654 preg_match("/^addSuggestedSolution_.*/", $key, $matches)
01655 )
01656 {
01657 $force_active = true;
01658 }
01659 }
01660 }
01661 if (array_key_exists("imagemap_x", $_POST))
01662 {
01663 $force_active = true;
01664 }
01665 if ($rbacsystem->checkAccess('write', $this->ref_id))
01666 {
01667
01668 $this->tabs_gui->addSubTabTarget("edit_properties",
01669 $this->ctrl->getLinkTargetByClass($classname, "editQuestion"),
01670 array("questions", "filter", "resetFilter", "createQuestion",
01671 "importQuestions", "deleteQuestions", "duplicate",
01672 "view", "preview", "editQuestion", "exec_pg",
01673 "addItem", "upload", "save", "cancel", "addSuggestedSolution",
01674 "cancelExplorer", "linkChilds", "removeSuggestedSolution",
01675 "add", "addYesNo", "addTrueFalse", "createGaps", "saveEdit",
01676 "setMediaMode", "uploadingImage", "uploadingImagemap", "addArea",
01677 "deletearea", "saveShape", "back", "addPair", "uploadingJavaapplet",
01678 "addParameter", "addGIT", "addST", "addPG", "delete"),
01679 $classname, "", $force_active);
01680 }
01681 }
01682
01683
01684 $this->tabs_gui->addSubTabTarget("statistics",
01685 $this->ctrl->getLinkTargetByClass($classname, "assessment"),
01686 array("assessment"),
01687 $classname, "");
01688
01689 }
01690
01696 function getTabs(&$tabs_gui)
01697 {
01698
01699 $tabs_gui->addTarget("properties",
01700 $this->ctrl->getLinkTarget($this,'properties'),
01701 "properties", "",
01702 "");
01703
01704
01705 $force_active = false;
01706 $commands = $_POST["cmd"];
01707 if (is_array($commands))
01708 {
01709 foreach ($commands as $key => $value)
01710 {
01711 if (preg_match("/^delete_.*/", $key, $matches) ||
01712 preg_match("/^addSelectGap_.*/", $key, $matches) ||
01713 preg_match("/^addTextGap_.*/", $key, $matches) ||
01714 preg_match("/^addSuggestedSolution_.*/", $key, $matches)
01715 )
01716 {
01717 $force_active = true;
01718 }
01719 }
01720 }
01721 if (array_key_exists("imagemap_x", $_POST))
01722 {
01723 $force_active = true;
01724 }
01725 if (!$force_active)
01726 {
01727 $force_active = ((strtolower($this->ctrl->getCmdClass()) == strtolower(get_class($this)) || strlen($this->ctrl->getCmdClass()) == 0) &&
01728 $this->ctrl->getCmd() == "")
01729 ? true
01730 : false;
01731 }
01732 $tabs_gui->addTarget("ass_questions",
01733 $this->ctrl->getLinkTarget($this, "questions"),
01734 array("questions", "filter", "resetFilter", "createQuestion",
01735 "importQuestions", "deleteQuestions", "duplicate",
01736 "view", "preview", "editQuestion", "exec_pg",
01737 "addItem", "upload", "save", "cancel", "addSuggestedSolution",
01738 "cancelExplorer", "linkChilds", "removeSuggestedSolution",
01739 "add", "addYesNo", "addTrueFalse", "createGaps", "saveEdit",
01740 "setMediaMode", "uploadingImage", "uploadingImagemap", "addArea",
01741 "deletearea", "saveShape", "back", "addPair", "uploadingJavaapplet",
01742 "addParameter", "assessment", "addGIT", "addST", "addPG", "delete"),
01743 "", "", $force_active);
01744
01745
01746 $tabs_gui->addTarget("export",
01747 $this->ctrl->getLinkTarget($this,'export'),
01748 array("export", "createExportFile", "confirmDeleteExportFile", "downloadExportFile"),
01749 "", "");
01750
01751
01752 $tabs_gui->addTarget("perm_settings",
01753 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
01754
01755
01756 $tabs_gui->addTarget("meta_data",
01757 $this->ctrl->getLinkTargetByClass('ilmdeditorgui','listSection'),
01758 "", "ilmdeditorgui");
01759 }
01760
01761 }
01762 ?>