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 include_once "./assessment/classes/inc.AssessmentConstants.php";
00025
00037 class ASS_QuestionGUI
00038 {
00046 var $object;
00047
00048 var $tpl;
00049 var $lng;
00050 var $error;
00051
00056 var $sequence_no;
00064 function ASS_QuestionGUI()
00065 {
00066 global $lng, $tpl, $ilCtrl;
00067
00068
00069 $this->lng =& $lng;
00070 $this->tpl =& $tpl;
00071 $this->ctrl =& $ilCtrl;
00072 $this->ctrl->saveParameter($this, "q_id");
00073
00074 include_once "./assessment/classes/class.assQuestion.php";
00075 $this->object = new ASS_Question();
00076 }
00077
00081 function &executeCommand()
00082 {
00083 $cmd = $this->ctrl->getCmd("editQuestion");
00084 $next_class = $this->ctrl->getNextClass($this);
00085
00086 $cmd = $this->getCommand($cmd);
00087
00088 switch($next_class)
00089 {
00090 default:
00091 $ret =& $this->$cmd();
00092 break;
00093 }
00094 return $ret;
00095 }
00096
00097 function getCommand($cmd)
00098 {
00099 return $cmd;
00100 }
00101
00102
00111 function getQuestionType()
00112 {
00113 return "";
00114 }
00115
00119 function getType()
00120 {
00121 return $this->getQuestionType();
00122 }
00123
00131 function outOtherQuestionData()
00132 {
00133 }
00134
00143 function writePostData()
00144 {
00145 }
00146
00154 function outWorkingForm($test_id = "", $is_postponed = false)
00155 {
00156 }
00157
00161 function assessment()
00162 {
00163 $this->tpl->addBlockFile("CONTENT", "content", "tpl.il_as_qpl_content.html", true);
00164 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00165
00166
00167 sendInfo();
00168
00169 $total_of_answers = $this->object->getTotalAnswers();
00170 $counter = 0;
00171 $color_class = array("tblrow1", "tblrow2");
00172 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_qpl_assessment_of_questions.html", true);
00173 if (!$total_of_answers)
00174 {
00175 $this->tpl->setCurrentBlock("emptyrow");
00176 $this->tpl->setVariable("TXT_NO_ASSESSMENT", $this->lng->txt("qpl_assessment_no_assessment_of_questions"));
00177 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00178 $this->tpl->parseCurrentBlock();
00179 }
00180 else
00181 {
00182 $this->tpl->setCurrentBlock("row");
00183 $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("qpl_assessment_total_of_answers"));
00184 $this->tpl->setVariable("TXT_VALUE", $total_of_answers);
00185 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00186 $counter++;
00187 $this->tpl->parseCurrentBlock();
00188 $this->tpl->setCurrentBlock("row");
00189 $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("qpl_assessment_total_of_right_answers"));
00190 $this->tpl->setVariable("TXT_VALUE", sprintf("%2.2f", $this->object->_getTotalRightAnswers($_GET["q_id"]) * 100.0) . " %");
00191 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00192 $this->tpl->parseCurrentBlock();
00193 }
00194 $this->tpl->setCurrentBlock("adm_content");
00195 $this->tpl->setVariable("TXT_QUESTION_TITLE", $this->object->getTitle());
00196 $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("result"));
00197 $this->tpl->setVariable("TXT_VALUE", $this->lng->txt("value"));
00198 $this->tpl->parseCurrentBlock();
00199 }
00200
00201
00210 function writeOtherPostData($result = 0)
00211 {
00212 $this->object->setEstimatedWorkingTime(
00213 ilUtil::stripSlashes($_POST["Estimated"][h]),
00214 ilUtil::stripSlashes($_POST["Estimated"][m]),
00215 ilUtil::stripSlashes($_POST["Estimated"][s])
00216 );
00217
00218 $saved = false;
00219 return $saved;
00220 }
00221
00233 function &_getQuestionGUI($question_type, $question_id = -1)
00234 {
00235 include_once "./assessment/classes/class.assQuestion.php";
00236 if ((!$question_type) and ($question_id > 0))
00237 {
00238 $question_type = ASS_Question::getQuestionTypeFromDb($question_id);
00239
00240 }
00241 switch ($question_type)
00242 {
00243 case "qt_multiple_choice_sr":
00244 include_once "./assessment/classes/class.assMultipleChoiceGUI.php";
00245 $question =& new ASS_MultipleChoiceGUI();
00246 $question->object->set_response(RESPONSE_SINGLE);
00247 break;
00248
00249 case "qt_multiple_choice_mr":
00250 include_once "./assessment/classes/class.assMultipleChoiceGUI.php";
00251 $question =& new ASS_MultipleChoiceGUI();
00252 $question->object->set_response(RESPONSE_MULTIPLE);
00253 break;
00254
00255 case "qt_cloze":
00256 include_once "./assessment/classes/class.assClozeTestGUI.php";
00257 $question =& new ASS_ClozeTestGUI();
00258 break;
00259
00260 case "qt_matching":
00261 include_once "./assessment/classes/class.assMatchingQuestionGUI.php";
00262 $question =& new ASS_MatchingQuestionGUI();
00263 break;
00264
00265 case "qt_ordering":
00266 include_once "./assessment/classes/class.assOrderingQuestionGUI.php";
00267 $question =& new ASS_OrderingQuestionGUI();
00268 break;
00269
00270 case "qt_imagemap":
00271 include_once "./assessment/classes/class.assImagemapQuestionGUI.php";
00272 $question =& new ASS_ImagemapQuestionGUI();
00273 break;
00274
00275 case "qt_javaapplet":
00276 include_once "./assessment/classes/class.assJavaAppletGUI.php";
00277 $question =& new ASS_JavaAppletGUI();
00278 break;
00279 case "qt_text":
00280 include_once "./assessment/classes/class.assTextQuestionGUI.php";
00281 $question =& new ASS_TextQuestionGUI();
00282 break;
00283 }
00284 if ($question_id > 0)
00285 {
00286 $question->object->loadFromDb($question_id);
00287 }
00288
00289 return $question;
00290 }
00291
00292 function _getGUIClassNameForId($a_q_id)
00293 {
00294 include_once "./assessment/classes/class.assQuestion.php";
00295 include_once "./assessment/classes/class.assQuestionGUI.php";
00296 $q_type = ASS_Question::getQuestionTypeFromDb($a_q_id);
00297 $class_name = ASS_QuestionGUI::_getClassNameForQType($q_type);
00298 return $class_name;
00299 }
00300
00301 function _getClassNameForQType($q_type)
00302 {
00303 switch ($q_type)
00304 {
00305 case "qt_multiple_choice_sr":
00306 return "ASS_MultipleChoiceGUI";
00307 break;
00308
00309 case "qt_multiple_choice_mr":
00310 return "ASS_MultipleChoiceGUI";
00311 break;
00312
00313 case "qt_cloze":
00314 return "ASS_ClozeTestGUI";
00315 break;
00316
00317 case "qt_matching":
00318 return "ASS_MatchingQuestionGUI";
00319 break;
00320
00321 case "qt_ordering":
00322 return "ASS_OrderingQuestionGUI";
00323 break;
00324
00325 case "qt_imagemap":
00326 return "ASS_ImagemapQuestionGUI";
00327 break;
00328
00329 case "qt_javaapplet":
00330 return "ASS_JavaAppletGUI";
00331 break;
00332
00333 case "qt_text":
00334 return "ASS_TextQuestionGUI";
00335 break;
00336 }
00337
00338 }
00339
00350 function &createQuestionGUI($question_type, $question_id = -1)
00351 {
00352 include_once "./assessment/classes/class.assQuestionGUI.php";
00353 $this->question =& ASS_QuestionGUI::_getQuestionGUI($question_type, $question_id);
00354 }
00355
00359 function getQuestionTemplate($q_type)
00360 {
00361 $this->tpl->addBlockFile("CONTENT", "content", "tpl.il_as_qpl_content.html", true);
00362 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00363 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_question.html", true);
00364 }
00365
00369 function outQuestionPage($a_temp_var, $a_postponed = false, $test_id = "")
00370 {
00371 $postponed = "";
00372 if ($a_postponed)
00373 {
00374 $postponed = " (" . $this->lng->txt("postponed") . ")";
00375 }
00376
00377 include_once("content/classes/Pages/class.ilPageObject.php");
00378 include_once("content/classes/Pages/class.ilPageObjectGUI.php");
00379 $this->lng->loadLanguageModule("content");
00380 $page =& new ilPageObject("qpl", $this->object->getId());
00381 $page_gui =& new ilPageObjectGUI($page);
00382 $page_gui->setQuestionXML($this->object->to_xml(false, false, true, $test_id, $force_image_references = true));
00383 $page_gui->setTemplateTargetVar($a_temp_var);
00384 $page_gui->setFileDownloadLink("ilias.php?baseClass=ilObjTestGUI&cmd=downloadFile".
00385 "&ref_id=".$_GET["ref_id"]);
00386 $page_gui->setFullscreenLink("ilias.php?baseClass=ilObjTestGUI&cmd=fullscreen".
00387 "&ref_id=".$_GET["ref_id"]);
00388 $page_gui->setSourcecodeDownloadScript("ilias.php?baseClass=ilObjTestGUI&ref_id=".$_GET["ref_id"]);
00389 $page_gui->setOutputMode("presentation");
00390
00391 include_once "./assessment/classes/class.ilObjTest.php";
00392 $maxpoints = " (".$this->object->getMaximumPoints()." ".$this->lng->txt("points").")";
00393 if (ilObjTest::_getHideTitlePoints($test_id))
00394 {
00395 $maxpoints = "";
00396 }
00397 if (!$a_postponed && is_numeric($this->sequence_no))
00398 $page_gui->setPresentationTitle($this->lng->txt("question")." ".$this->sequence_no." - ".$this->object->getTitle().$postponed.$maxpoints);
00399 else
00400 $page_gui->setPresentationTitle($this->object->getTitle().$postponed.$maxpoints);
00401 return $page_gui->presentation();
00402 }
00403
00407 function cancel()
00408 {
00409 if ($_GET["calling_test"])
00410 {
00411 $_GET["ref_id"] = $_GET["calling_test"];
00412 ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=".$_GET["calling_test"]);
00413 }
00414 elseif ($_GET["test_ref_id"])
00415 {
00416 $_GET["ref_id"] = $_GET["test_ref_id"];
00417 ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=".$_GET["test_ref_id"]);
00418 }
00419 else
00420 {
00421 if ($_GET["q_id"] > 0)
00422 {
00423 $this->ctrl->setParameterByClass("ilpageobjectgui", "q_id", $_GET["q_id"]);
00424 $this->ctrl->redirectByClass("ilpageobjectgui", "view");
00425 }
00426 else
00427 {
00428 $this->ctrl->redirectByClass("ilobjquestionpoolgui", "questions");
00429 }
00430 }
00431 }
00432
00433 function originalSyncForm()
00434 {
00435 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_tst_sync_original.html", true);
00436 $this->tpl->setCurrentBlock("adm_content");
00437 $this->tpl->setVariable("BUTTON_YES", $this->lng->txt("yes"));
00438 $this->tpl->setVariable("BUTTON_NO", $this->lng->txt("no"));
00439 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00440 $this->tpl->setVariable("TEXT_SYNC", $this->lng->txt("confirm_sync_questions"));
00441 $this->tpl->parseCurrentBlock();
00442 }
00443
00444 function sync()
00445 {
00446 $original_id = $this->object->original_id;
00447 if ($original_id)
00448 {
00449 $this->object->syncWithOriginal();
00450 }
00451 $_GET["ref_id"] = $_GET["calling_test"];
00452 ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=".$_GET["calling_test"]);
00453 }
00454
00455 function cancelSync()
00456 {
00457 $_GET["ref_id"] = $_GET["calling_test"];
00458 ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=".$_GET["calling_test"]);
00459 }
00460
00464 function saveEdit()
00465 {
00466 global $ilUser;
00467
00468 $result = $this->writePostData();
00469 if ($result == 0)
00470 {
00471 $ilUser->setPref("tst_lastquestiontype", $this->object->getQuestionType());
00472 $ilUser->writePref("tst_lastquestiontype", $this->object->getQuestionType());
00473 $this->object->saveToDb();
00474 $originalexists = $this->object->_questionExists($this->object->original_id);
00475 include_once "./assessment/classes/class.assQuestion.php";
00476 if ($_GET["calling_test"] && $originalexists && ASS_Question::_isWriteable($this->object->original_id, $ilUser->getId()))
00477 {
00478 $this->originalSyncForm();
00479 }
00480 elseif ($_GET["calling_test"])
00481 {
00482 $_GET["ref_id"] = $_GET["calling_test"];
00483 ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=".$_GET["calling_test"]);
00484 return;
00485 }
00486 elseif ($_GET["test_ref_id"])
00487 {
00488 include_once ("./assessment/classes/class.ilObjTest.php");
00489 $_GET["ref_id"] = $_GET["test_ref_id"];
00490 $test =& new ilObjTest($_GET["test_ref_id"], true);
00491 $test->insertQuestion($this->object->getId());
00492 ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=".$_GET["test_ref_id"]);
00493 }
00494 else
00495 {
00496 $_GET["q_id"] = $this->object->getId();
00497 $this->editQuestion();
00498 if (strcmp($_SESSION["info"], "") != 0)
00499 {
00500 sendInfo($_SESSION["info"] . "<br />" . $this->lng->txt("msg_obj_modified"), false);
00501 }
00502 else
00503 {
00504 sendInfo($this->lng->txt("msg_obj_modified"), false);
00505 }
00506 $this->ctrl->setParameterByClass("ilpageobjectgui", "q_id", $this->object->getId());
00507 $this->ctrl->redirectByClass("ilpageobjectgui", "view");
00508 }
00509 }
00510 else
00511 {
00512 sendInfo($this->lng->txt("fill_out_all_required_fields"));
00513 $this->editQuestion();
00514 }
00515 }
00516
00520 function save()
00521 {
00522 global $ilUser;
00523
00524 $old_id = $_GET["q_id"];
00525 $result = $this->writePostData();
00526 if ($result == 0)
00527 {
00528 $ilUser->setPref("tst_lastquestiontype", $this->object->getQuestionType());
00529 $ilUser->writePref("tst_lastquestiontype", $this->object->getQuestionType());
00530 $this->object->saveToDb();
00531 $originalexists = $this->object->_questionExists($this->object->original_id);
00532 include_once "./assessment/classes/class.assQuestion.php";
00533 if ($_GET["calling_test"] && $originalexists && ASS_Question::_isWriteable($this->object->original_id, $ilUser->getId()))
00534 {
00535 $this->originalSyncForm();
00536 }
00537 elseif ($_GET["calling_test"])
00538 {
00539 $_GET["ref_id"] = $_GET["calling_test"];
00540 ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=".$_GET["calling_test"]);
00541 return;
00542 }
00543 elseif ($_GET["test_ref_id"])
00544 {
00545 include_once ("./assessment/classes/class.ilObjTest.php");
00546 $_GET["ref_id"] = $_GET["test_ref_id"];
00547 $test =& new ilObjTest($_GET["test_ref_id"], true);
00548 $test->insertQuestion($this->object->getId());
00549 ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=".$_GET["test_ref_id"]);
00550 }
00551 else
00552 {
00553 $_GET["q_id"] = $this->object->getId();
00554 if ($_GET["q_id"] != $old_id)
00555 {
00556
00557 $this->ctrl->setParameterByClass($_GET["cmdClass"], "q_id", $this->object->getId());
00558 $this->ctrl->setParameterByClass($_GET["cmdClass"], "sel_question_types", $_GET["sel_question_types"]);
00559 sendInfo($this->lng->txt("msg_obj_modified"), true);
00560 $this->ctrl->redirectByClass($_GET["cmdClass"], "editQuestion");
00561 }
00562 if (strcmp($_SESSION["info"], "") != 0)
00563 {
00564 sendInfo($_SESSION["info"] . "<br />" . $this->lng->txt("msg_obj_modified"), false);
00565 }
00566 else
00567 {
00568 sendInfo($this->lng->txt("msg_obj_modified"), false);
00569 }
00570 $this->editQuestion();
00571
00572
00573 }
00574 }
00575 else
00576 {
00577 sendInfo($this->lng->txt("fill_out_all_required_fields"));
00578 $this->editQuestion();
00579 }
00580 }
00581
00585 function apply()
00586 {
00587 $this->writePostData();
00588 $this->object->saveToDb();
00589 $_GET["q_id"] = $this->object->getId();
00590 $this->editQuestion();
00591 }
00592
00593 function cancelExplorer()
00594 {
00595 unset($_SESSION["subquestion_index"]);
00596 unset($_SESSION["link_new_type"]);
00597 $this->editQuestion();
00598 }
00599
00600 function addSuggestedSolution()
00601 {
00602 global $tree;
00603
00604 include_once("./assessment/classes/class.ilSolutionExplorer.php");
00605 switch ($_POST["internalLinkType"])
00606 {
00607 case "lm":
00608 $_SESSION["link_new_type"] = "lm";
00609 $_SESSION["search_link_type"] = "lm";
00610 break;
00611 case "glo":
00612 $_SESSION["link_new_type"] = "glo";
00613 $_SESSION["search_link_type"] = "glo";
00614 break;
00615 case "st":
00616 $_SESSION["link_new_type"] = "lm";
00617 $_SESSION["search_link_type"] = "st";
00618 break;
00619 case "pg":
00620 $_SESSION["link_new_type"] = "lm";
00621 $_SESSION["search_link_type"] = "pg";
00622 break;
00623 default:
00624 if (!$_SESSION["link_new_type"])
00625 {
00626 $_SESSION["link_new_type"] = "lm";
00627 }
00628 break;
00629 }
00630
00631 sendInfo($this->lng->txt("select_object_to_link"));
00632
00633 $exp = new ilSolutionExplorer($this->ctrl->getLinkTarget($this,'addSuggestedSolution'), get_class($this));
00634
00635 $exp->setExpand($_GET["expand"] ? $_GET["expand"] : $tree->readRootId());
00636 $exp->setExpandTarget($this->ctrl->getLinkTarget($this,'addSuggestedSolution'));
00637 $exp->setTargetGet("ref_id");
00638 $exp->setRefId($this->cur_ref_id);
00639 $exp->addFilter($_SESSION["link_new_type"]);
00640 $exp->setSelectableType($_SESSION["link_new_type"]);
00641
00642
00643 $exp->setOutput(0);
00644
00645 $this->tpl->addBlockFile("EXPLORER", "explorer", "tpl.il_as_qpl_explorer.html", true);
00646 $this->tpl->setVariable("EXPLORER_TREE",$exp->getOutput());
00647 $this->tpl->setVariable("BUTTON_CANCEL",$this->lng->txt("cancel"));
00648 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00649 $this->tpl->parseCurrentBlock();
00650 }
00651
00652 function removeSuggestedSolution()
00653 {
00654 $this->object->suggested_solutions = array();
00655 $this->object->saveToDb();
00656 $this->editQuestion();
00657 }
00658
00659 function addPG()
00660 {
00661 $subquestion_index = 0;
00662 if ($_SESSION["subquestion_index"] >= 0)
00663 {
00664 $subquestion_index = $_SESSION["subquestion_index"];
00665 }
00666 $this->object->setSuggestedSolution("il__pg_" . $_GET["pg"], $subquestion_index);
00667 unset($_SESSION["subquestion_index"]);
00668 unset($_SESSION["link_new_type"]);
00669 unset($_SESSION["search_link_type"]);
00670 sendInfo($this->lng->txt("suggested_solution_added_successfully"));
00671 $this->editQuestion();
00672 }
00673
00674 function addST()
00675 {
00676 $subquestion_index = 0;
00677 if ($_SESSION["subquestion_index"] >= 0)
00678 {
00679 $subquestion_index = $_SESSION["subquestion_index"];
00680 }
00681 $this->object->setSuggestedSolution("il__st_" . $_GET["st"], $subquestion_index);
00682 unset($_SESSION["subquestion_index"]);
00683 unset($_SESSION["link_new_type"]);
00684 unset($_SESSION["search_link_type"]);
00685 sendInfo($this->lng->txt("suggested_solution_added_successfully"));
00686 $this->editQuestion();
00687 }
00688
00689 function addGIT()
00690 {
00691 $subquestion_index = 0;
00692 if ($_SESSION["subquestion_index"] >= 0)
00693 {
00694 $subquestion_index = $_SESSION["subquestion_index"];
00695 }
00696 $this->object->setSuggestedSolution("il__git_" . $_GET["git"], $subquestion_index);
00697 unset($_SESSION["subquestion_index"]);
00698 unset($_SESSION["link_new_type"]);
00699 unset($_SESSION["search_link_type"]);
00700 sendInfo($this->lng->txt("suggested_solution_added_successfully"));
00701 $this->editQuestion();
00702 }
00703
00704 function linkChilds()
00705 {
00706 switch ($_SESSION["search_link_type"])
00707 {
00708 case "pg":
00709 include_once "./content/classes/class.ilLMPageObject.php";
00710 include_once("./content/classes/class.ilObjContentObject.php");
00711 $cont_obj =& new ilObjContentObject($_GET["source_id"], true);
00712 $pages = ilLMPageObject::getPageList($cont_obj->getId());
00713 $_GET["q_id"] = $this->object->getId();
00714 $this->tpl->setVariable("HEADER", $this->object->getTitle());
00715 $this->getQuestionTemplate($_GET["sel_question_types"]);
00716 $color_class = array("tblrow1", "tblrow2");
00717 $counter = 0;
00718 $this->tpl->addBlockFile("LINK_SELECTION", "link_selection", "tpl.il_as_qpl_internallink_selection.html", true);
00719 foreach($pages as $page)
00720 {
00721 if($page["type"] == $_SESSION["search_link_type"])
00722 {
00723 $this->tpl->setCurrentBlock("linktable_row");
00724 $this->tpl->setVariable("TEXT_LINK", $page["title"]);
00725 $this->tpl->setVariable("TEXT_ADD", $this->lng->txt("add"));
00726 $this->tpl->setVariable("LINK_HREF", $this->ctrl->getLinkTargetByClass(get_class($this), "add" . strtoupper($page["type"])) . "&" . $page["type"] . "=" . $page["obj_id"]);
00727 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00728 $this->tpl->parseCurrentBlock();
00729 $counter++;
00730 }
00731 }
00732 $this->tpl->setCurrentBlock("link_selection");
00733 $this->tpl->setVariable("BUTTON_CANCEL",$this->lng->txt("cancel"));
00734 $this->tpl->setVariable("TEXT_LINK_TYPE", $this->lng->txt("obj_" . $_SESSION["search_link_type"]));
00735 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00736 $this->tpl->parseCurrentBlock();
00737 break;
00738 case "st":
00739 $_GET["q_id"] = $this->object->getId();
00740 $this->tpl->setVariable("HEADER", $this->object->getTitle());
00741 $this->getQuestionTemplate($_GET["sel_question_types"]);
00742 $color_class = array("tblrow1", "tblrow2");
00743 $counter = 0;
00744 include_once("./content/classes/class.ilObjContentObject.php");
00745 $cont_obj =& new ilObjContentObject($_GET["source_id"], true);
00746
00747 $ctree =& $cont_obj->getLMTree();
00748 $nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId()));
00749 $this->tpl->addBlockFile("LINK_SELECTION", "link_selection", "tpl.il_as_qpl_internallink_selection.html", true);
00750 foreach($nodes as $node)
00751 {
00752 if($node["type"] == $_SESSION["search_link_type"])
00753 {
00754 $this->tpl->setCurrentBlock("linktable_row");
00755 $this->tpl->setVariable("TEXT_LINK", $node["title"]);
00756 $this->tpl->setVariable("TEXT_ADD", $this->lng->txt("add"));
00757 $this->tpl->setVariable("LINK_HREF", $this->ctrl->getLinkTargetByClass(get_class($this), "add" . strtoupper($node["type"])) . "&" . $node["type"] . "=" . $node["obj_id"]);
00758 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00759 $this->tpl->parseCurrentBlock();
00760 $counter++;
00761 }
00762 }
00763 $this->tpl->setCurrentBlock("link_selection");
00764 $this->tpl->setVariable("BUTTON_CANCEL",$this->lng->txt("cancel"));
00765 $this->tpl->setVariable("TEXT_LINK_TYPE", $this->lng->txt("obj_" . $_SESSION["search_link_type"]));
00766 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00767 $this->tpl->parseCurrentBlock();
00768 break;
00769 case "glo":
00770 $_GET["q_id"] = $this->object->getId();
00771 $this->tpl->setVariable("HEADER", $this->object->getTitle());
00772 $this->getQuestionTemplate($_GET["sel_question_types"]);
00773 $color_class = array("tblrow1", "tblrow2");
00774 $counter = 0;
00775 $this->tpl->addBlockFile("LINK_SELECTION", "link_selection", "tpl.il_as_qpl_internallink_selection.html", true);
00776 include_once "./content/classes/class.ilObjGlossary.php";
00777 $glossary =& new ilObjGlossary($_GET["source_id"], true);
00778
00779 $terms = $glossary->getTermList();
00780 foreach($terms as $term)
00781 {
00782 $this->tpl->setCurrentBlock("linktable_row");
00783 $this->tpl->setVariable("TEXT_LINK", $term["term"]);
00784 $this->tpl->setVariable("TEXT_ADD", $this->lng->txt("add"));
00785 $this->tpl->setVariable("LINK_HREF", $this->ctrl->getLinkTargetByClass(get_class($this), "addGIT") . "&git=" . $term["id"]);
00786 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00787 $this->tpl->parseCurrentBlock();
00788 $counter++;
00789 }
00790 $this->tpl->setCurrentBlock("link_selection");
00791 $this->tpl->setVariable("BUTTON_CANCEL",$this->lng->txt("cancel"));
00792 $this->tpl->setVariable("TEXT_LINK_TYPE", $this->lng->txt("glossary_term"));
00793 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00794 $this->tpl->parseCurrentBlock();
00795 break;
00796 case "lm":
00797 $subquestion_index = 0;
00798 if ($_SESSION["subquestion_index"] >= 0)
00799 {
00800 $subquestion_index = $_SESSION["subquestion_index"];
00801 }
00802 $this->object->setSuggestedSolution("il__lm_" . $_GET["source_id"], $subquestion_index);
00803 unset($_SESSION["subquestion_index"]);
00804 unset($_SESSION["link_new_type"]);
00805 unset($_SESSION["search_link_type"]);
00806 sendInfo($this->lng->txt("suggested_solution_added_successfully"));
00807 $this->editQuestion();
00808 break;
00809 }
00810 }
00811
00812 function replaceInputElements ($gap_idx, $solution, $output, $before="[", $after="]") {
00813 #echo htmlentities ($output)."<br>";
00814 #echo htmlentities ($gap_idx)."<br>";
00815 $before = "<span class=\"textanswer\">".$before;
00816 $after = $after . "</span>";
00817 $output = preg_replace ("/(<input[^>]*".$gap_idx."[^>]*>)/" , $before.$solution.$after, $output);
00818 #echo htmlentities ($output)."<br>";
00819 return $output;
00820 }
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832 function replaceSelectElements ($gap_idx, $repl_str, $output)
00833 {
00834 #echo htmlentities ($output)."<br>";
00835 #echo htmlentities ($gap_idx)."<br>";
00836 #echo htmlentities ($repl_str)."<br>";
00837 $before="<span class=\"textanswer\">[";
00838 $after="]</span>";
00839
00840 $select_pattern = "/<select[^>]*name=\"$gap_idx\".*?[^>]*>.*?<\/select>/";
00841 #echo htmlentities ($select_pattern)."<br>";
00842
00843 if (preg_match($select_pattern, $output, $matches)) {
00844
00845 #echo "<br><br>".htmlentities ($matches[0]);
00846 $value_pattern = "/<option[^>]*".$repl_str."[^>]*>(.*?)<\/option>/";
00847 if (preg_match($value_pattern, $matches[0], $matches))
00848 $output = preg_replace ($select_pattern, $before.$matches[1].$after, $output);
00849
00850
00851 }
00852 return $output;
00853 }
00854
00855 function removeFormElements ($output) {
00856 $output = preg_replace ("/(<input[^>]*>)/" ,"[]", $output);
00857 $output = preg_replace ("/<select[^>]*>.*?<\/select>/s" ,"[]", $output);
00858 return $output;
00859 }
00860
00861 function setSequenceNumber ($nr) {
00862 $this->sequence_no = $nr;
00863 }
00864
00865 function getSequenceNumber () {
00866 return $this->sequence_no;
00867 }
00868
00872 function outAdditionalOutput()
00873 {
00874 }
00875
00876 }
00877 ?>