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