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 "./Modules/Test/classes/inc.AssessmentConstants.php";
00025
00036 class assQuestionGUI
00037 {
00045 var $object;
00046
00047 var $tpl;
00048 var $lng;
00049 var $error;
00050 var $errormessage;
00051
00055 var $sequence_no;
00059 var $question_count;
00060
00068 function assQuestionGUI()
00069 {
00070 global $lng, $tpl, $ilCtrl;
00071
00072
00073 $this->lng =& $lng;
00074 $this->tpl =& $tpl;
00075 $this->ctrl =& $ilCtrl;
00076 $this->ctrl->saveParameter($this, "q_id");
00077
00078 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
00079 $this->errormessage = $this->lng->txt("fill_out_all_required_fields");
00080 $this->object = new assQuestion();
00081 }
00082
00086 function &executeCommand()
00087 {
00088 $cmd = $this->ctrl->getCmd("editQuestion");
00089 $next_class = $this->ctrl->getNextClass($this);
00090
00091 $cmd = $this->getCommand($cmd);
00092
00093 switch($next_class)
00094 {
00095 default:
00096 $ret =& $this->$cmd();
00097 break;
00098 }
00099 return $ret;
00100 }
00101
00102 function getCommand($cmd)
00103 {
00104 return $cmd;
00105 }
00106
00110 function getType()
00111 {
00112 return $this->getQuestionType();
00113 }
00114
00122 function outOtherQuestionData()
00123 {
00124 $est_working_time = $this->object->getEstimatedWorkingTime();
00125 $this->tpl->setVariable("TEXT_WORKING_TIME", $this->lng->txt("working_time"));
00126 $this->tpl->setVariable("TIME_FORMAT", $this->lng->txt("time_format"));
00127 $this->tpl->setVariable("VALUE_WORKING_TIME", ilUtil::makeTimeSelect("Estimated", false, $est_working_time[h], $est_working_time[m], $est_working_time[s]));
00128 }
00129
00138 function writePostData()
00139 {
00140 }
00141
00145 function assessment()
00146 {
00147 $this->tpl->addBlockFile("CONTENT", "content", "tpl.il_as_qpl_content.html", "Modules/TestQuestionPool");
00148 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00149
00150
00151 ilUtil::sendInfo();
00152
00153 $total_of_answers = $this->object->getTotalAnswers();
00154 $counter = 0;
00155 $color_class = array("tblrow1", "tblrow2");
00156 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_qpl_assessment_of_questions.html", "Modules/TestQuestionPool");
00157 if (!$total_of_answers)
00158 {
00159 $this->tpl->setCurrentBlock("emptyrow");
00160 $this->tpl->setVariable("TXT_NO_ASSESSMENT", $this->lng->txt("qpl_assessment_no_assessment_of_questions"));
00161 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00162 $this->tpl->parseCurrentBlock();
00163 }
00164 else
00165 {
00166 $this->tpl->setCurrentBlock("row");
00167 $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("qpl_assessment_total_of_answers"));
00168 $this->tpl->setVariable("TXT_VALUE", $total_of_answers);
00169 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00170 $counter++;
00171 $this->tpl->parseCurrentBlock();
00172 $this->tpl->setCurrentBlock("row");
00173 $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("qpl_assessment_total_of_right_answers"));
00174 $this->tpl->setVariable("TXT_VALUE", sprintf("%2.2f", $this->object->_getTotalRightAnswers($_GET["q_id"]) * 100.0) . " %");
00175 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00176 $this->tpl->parseCurrentBlock();
00177 }
00178
00179 $instances =& $this->object->getInstances();
00180 $counter = 0;
00181 foreach ($instances as $instance)
00182 {
00183 if (is_array($instance["refs"]))
00184 {
00185 foreach ($instance["refs"] as $ref_id)
00186 {
00187 $this->tpl->setCurrentBlock("references");
00188 $this->tpl->setVariable("GOTO", "./goto.php?target=tst_" . $ref_id);
00189 $this->tpl->setVariable("TEXT_GOTO", $this->lng->txt("perma_link"));
00190 $this->tpl->parseCurrentBlock();
00191 }
00192 }
00193 $this->tpl->setCurrentBlock("instance_row");
00194 $this->tpl->setVariable("TEST_TITLE", $instance["title"]);
00195 $this->tpl->setVariable("TEST_AUTHOR", $instance["author"]);
00196 $this->tpl->setVariable("QUESTION_ID", $instance["question_id"]);
00197 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00198 $counter++;
00199 $this->tpl->parseCurrentBlock();
00200 }
00201 $this->tpl->setCurrentBlock("instances");
00202 $this->tpl->setVariable("TEXT_TEST_TITLE", $this->lng->txt("title"));
00203 $this->tpl->setVariable("TEXT_TEST_AUTHOR", $this->lng->txt("author"));
00204 $this->tpl->setVariable("TEXT_TEST_LOCATION", $this->lng->txt("location"));
00205 $this->tpl->setVariable("INSTANCES_TITLE", $this->lng->txt("question_instances_title"));
00206 $this->tpl->parseCurrentBlock();
00207
00208 $this->tpl->setCurrentBlock("adm_content");
00209 $this->tpl->setVariable("TXT_QUESTION_TITLE", $this->lng->txt("question_cumulated_statistics"));
00210 $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("result"));
00211 $this->tpl->setVariable("TXT_VALUE", $this->lng->txt("value"));
00212 $this->tpl->parseCurrentBlock();
00213 }
00214
00215
00224 function writeOtherPostData($result = 0)
00225 {
00226 $this->object->setEstimatedWorkingTime(
00227 ilUtil::stripSlashes($_POST["Estimated"][h]),
00228 ilUtil::stripSlashes($_POST["Estimated"][m]),
00229 ilUtil::stripSlashes($_POST["Estimated"][s])
00230 );
00231
00232 $saved = false;
00233 return $saved;
00234 }
00235
00247 function &_getQuestionGUI($question_type, $question_id = -1)
00248 {
00249 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
00250 if ((!$question_type) and ($question_id > 0))
00251 {
00252 $question_type = assQuestion::getQuestionTypeFromDb($question_id);
00253 }
00254 if (strlen($question_type) == 0) return NULL;
00255 include_once "./Modules/TestQuestionPool/classes/class.".$question_type."GUI.php";
00256 $question_type_gui = $question_type . "GUI";
00257 $question =& new $question_type_gui();
00258 if ($question_id > 0)
00259 {
00260 $question->object->loadFromDb($question_id);
00261 }
00262 return $question;
00263 }
00264
00265 function _getGUIClassNameForId($a_q_id)
00266 {
00267 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
00268 include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
00269 $q_type = assQuestion::getQuestionTypeFromDb($a_q_id);
00270 $class_name = assQuestionGUI::_getClassNameForQType($q_type);
00271 return $class_name;
00272 }
00273
00274 function _getClassNameForQType($q_type)
00275 {
00276 return $q_type . "GUI";
00277 }
00278
00289 function &createQuestionGUI($question_type, $question_id = -1)
00290 {
00291 include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
00292 $this->question =& assQuestionGUI::_getQuestionGUI($question_type, $question_id);
00293 }
00294
00298 function getQuestionTemplate()
00299 {
00300 $this->tpl->addBlockFile("CONTENT", "content", "tpl.il_as_qpl_content.html", "Modules/TestQuestionPool");
00301 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00302 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_question.html", "Modules/TestQuestionPool");
00303 }
00304
00313 function getILIASPage()
00314 {
00315 include_once("./Services/COPage/classes/class.ilPageObject.php");
00316 include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
00317 $page =& new ilPageObject("qpl", $this->object->getId());
00318 $page_gui =& new ilPageObjectGUI($page);
00319 $page_gui->setTemplateTargetVar($a_temp_var);
00320 $page_gui->setEnabledInternalLinks(false);
00321 $page_gui->setFileDownloadLink("ilias.php?baseClass=ilObjTestGUI&cmd=downloadFile".
00322 "&ref_id=".$_GET["ref_id"]);
00323 $page_gui->setFullscreenLink("ilias.php?baseClass=ilObjTestGUI&cmd=fullscreen".
00324 "&ref_id=".$_GET["ref_id"]);
00325 $page_gui->setSourcecodeDownloadScript("ilias.php?baseClass=ilObjTestGUI&ref_id=".$_GET["ref_id"]);
00326 $page_gui->setOutputMode("presentation");
00327 $page_gui->setPresentationTitle("");
00328 $presentation = $page_gui->presentation();
00329
00330 $presentation = preg_replace("/((<img[^>]*?[^\\/])>)/ims", "\\2 />", $presentation);
00331 $presentation = preg_replace("/src=\".\\//ims", "src=\"" . ILIAS_HTTP_PATH . "/", $presentation);
00332 return $presentation;
00333 }
00334
00338 function outQuestionPage($a_temp_var, $a_postponed = false, $active_id = "")
00339 {
00340 $postponed = "";
00341 if ($a_postponed)
00342 {
00343 $postponed = " (" . $this->lng->txt("postponed") . ")";
00344 }
00345
00346 include_once("./Services/COPage/classes/class.ilPageObject.php");
00347 include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
00348 $this->lng->loadLanguageModule("content");
00349 $page =& new ilPageObject("qpl", $this->object->getId());
00350 $page_gui =& new ilPageObjectGUI($page);
00351 $page_gui->setTemplateTargetVar($a_temp_var);
00352 $page_gui->setFileDownloadLink("ilias.php?baseClass=ilObjTestGUI&cmd=downloadFile".
00353 "&ref_id=".$_GET["ref_id"]);
00354 $page_gui->setFullscreenLink("ilias.php?baseClass=ilObjTestGUI&cmd=fullscreen".
00355 "&ref_id=".$_GET["ref_id"]);
00356 $page_gui->setSourcecodeDownloadScript("ilias.php?baseClass=ilObjTestGUI&ref_id=".$_GET["ref_id"]);
00357 $page_gui->setOutputMode("presentation");
00358
00359 include_once "./Modules/Test/classes/class.ilObjTest.php";
00360 $title_output = ilObjTest::_getTitleOutput($active_id);
00361 switch ($title_output)
00362 {
00363 case 1:
00364 $page_gui->setPresentationTitle(sprintf($this->lng->txt("tst_position"), $this->getSequenceNumber(), $this->getQuestionCount())." - ".$this->object->getTitle().$postponed);
00365 break;
00366 case 2:
00367 $page_gui->setPresentationTitle(sprintf($this->lng->txt("tst_position"), $this->getSequenceNumber(), $this->getQuestionCount()).$postponed);
00368 break;
00369 case 0:
00370 default:
00371 $maxpoints = $this->object->getMaximumPoints();
00372 if ($maxpoints == 1)
00373 {
00374 $maxpoints = " (".$maxpoints." ".$this->lng->txt("point").")";
00375 }
00376 else
00377 {
00378 $maxpoints = " (".$maxpoints." ".$this->lng->txt("points").")";
00379 }
00380 $page_gui->setPresentationTitle(sprintf($this->lng->txt("tst_position"), $this->getSequenceNumber(), $this->getQuestionCount())." - ".$this->object->getTitle().$postponed.$maxpoints);
00381 break;
00382 }
00383 $presentation = $page_gui->presentation();
00384 if (strlen($maxpoints)) $presentation = str_replace($maxpoints, "<em>$maxpoints</em>", $presentation);
00385
00386 $presentation = preg_replace("/((<img[^>]*?[^\\/])>)/ims", "\\2 />", $presentation);
00387 $presentation = preg_replace("/src=\".\\//ims", "src=\"" . ILIAS_HTTP_PATH . "/", $presentation);
00388 return $presentation;
00389 }
00390
00394 function cancel()
00395 {
00396 if ($_GET["calling_test"])
00397 {
00398 $_GET["ref_id"] = $_GET["calling_test"];
00399 ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=".$_GET["calling_test"]);
00400 }
00401 elseif ($_GET["test_ref_id"])
00402 {
00403 $_GET["ref_id"] = $_GET["test_ref_id"];
00404 ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=".$_GET["test_ref_id"]);
00405 }
00406 else
00407 {
00408 if ($_GET["q_id"] > 0)
00409 {
00410 $this->ctrl->setParameterByClass("ilpageobjectgui", "q_id", $_GET["q_id"]);
00411 $this->ctrl->redirectByClass("ilpageobjectgui", "view");
00412 }
00413 else
00414 {
00415 $this->ctrl->redirectByClass("ilobjquestionpoolgui", "questions");
00416 }
00417 }
00418 }
00419
00420 function originalSyncForm($return_to = "")
00421 {
00422 if (strlen($return_to))
00423 {
00424 $this->ctrl->setParameter($this, "return_to", $return_to);
00425 }
00426 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_qpl_sync_original.html", "Modules/TestQuestionPool");
00427 $this->tpl->setCurrentBlock("adm_content");
00428 $this->tpl->setVariable("BUTTON_YES", $this->lng->txt("yes"));
00429 $this->tpl->setVariable("BUTTON_NO", $this->lng->txt("no"));
00430 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00431 $this->tpl->setVariable("TEXT_SYNC", $this->lng->txt("confirm_sync_questions"));
00432 $this->tpl->parseCurrentBlock();
00433 }
00434
00435 function sync()
00436 {
00437 $original_id = $this->object->original_id;
00438 if ($original_id)
00439 {
00440 $this->object->syncWithOriginal();
00441 }
00442 if (strlen($_GET["return_to"]))
00443 {
00444 $this->ctrl->redirect($this, $_GET["return_to"]);
00445 }
00446 else
00447 {
00448 $_GET["ref_id"] = $_GET["calling_test"];
00449 ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=".$_GET["calling_test"]);
00450 }
00451 }
00452
00453 function cancelSync()
00454 {
00455 if (strlen($_GET["return_to"]))
00456 {
00457 $this->ctrl->redirect($this, $_GET["return_to"]);
00458 }
00459 else
00460 {
00461 $_GET["ref_id"] = $_GET["calling_test"];
00462 ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=".$_GET["calling_test"]);
00463 }
00464 }
00465
00473 function saveFeedback()
00474 {
00475 global $ilUser;
00476
00477 $originalexists = $this->object->_questionExists($this->object->original_id);
00478 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
00479 if ($_GET["calling_test"] && $originalexists && assQuestion::_isWriteable($this->object->original_id, $ilUser->getId()))
00480 {
00481 $this->originalSyncForm("feedback");
00482 }
00483 else
00484 {
00485 $this->feedback();
00486 }
00487 }
00488
00492 function saveEdit()
00493 {
00494 global $ilUser;
00495
00496 $result = $this->writePostData();
00497 if ($result == 0)
00498 {
00499 $ilUser->setPref("tst_lastquestiontype", $this->object->getQuestionType());
00500 $ilUser->writePref("tst_lastquestiontype", $this->object->getQuestionType());
00501 $this->object->saveToDb();
00502 $originalexists = $this->object->_questionExists($this->object->original_id);
00503 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
00504 if ($_GET["calling_test"] && $originalexists && assQuestion::_isWriteable($this->object->original_id, $ilUser->getId()))
00505 {
00506 $this->originalSyncForm();
00507 }
00508 elseif ($_GET["calling_test"])
00509 {
00510 $_GET["ref_id"] = $_GET["calling_test"];
00511 ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=".$_GET["calling_test"]);
00512 return;
00513 }
00514 elseif ($_GET["test_ref_id"])
00515 {
00516 include_once ("./Modules/Test/classes/class.ilObjTest.php");
00517 $_GET["ref_id"] = $_GET["test_ref_id"];
00518 $test =& new ilObjTest($_GET["test_ref_id"], true);
00519 $test->insertQuestion($this->object->getId());
00520 ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=".$_GET["test_ref_id"]);
00521 }
00522 else
00523 {
00524 $this->ctrl->setParameter($this, "q_id", $this->object->getId());
00525 $this->editQuestion();
00526 if (strcmp($_SESSION["info"], "") != 0)
00527 {
00528 ilUtil::sendInfo($_SESSION["info"] . "<br />" . $this->lng->txt("msg_obj_modified"), false);
00529 }
00530 else
00531 {
00532 ilUtil::sendInfo($this->lng->txt("msg_obj_modified"), false);
00533 }
00534 $this->ctrl->setParameterByClass("ilpageobjectgui", "q_id", $this->object->getId());
00535 $this->ctrl->redirectByClass("ilpageobjectgui", "view");
00536 }
00537 }
00538 else
00539 {
00540 ilUtil::sendInfo($this->lng->txt("fill_out_all_required_fields"));
00541 $this->editQuestion();
00542 }
00543 }
00544
00548 function save()
00549 {
00550 global $ilUser;
00551 $old_id = $_GET["q_id"];
00552 $result = $this->writePostData();
00553 if ($result == 0)
00554 {
00555 $ilUser->setPref("tst_lastquestiontype", $this->object->getQuestionType());
00556 $ilUser->writePref("tst_lastquestiontype", $this->object->getQuestionType());
00557 $this->object->saveToDb();
00558 $originalexists = $this->object->_questionExists($this->object->original_id);
00559 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
00560 if ($_GET["calling_test"] && $originalexists && assQuestion::_isWriteable($this->object->original_id, $ilUser->getId()))
00561 {
00562 $this->originalSyncForm();
00563 }
00564 elseif ($_GET["calling_test"])
00565 {
00566 $_GET["ref_id"] = $_GET["calling_test"];
00567 ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=".$_GET["calling_test"]);
00568 return;
00569 }
00570 elseif ($_GET["test_ref_id"])
00571 {
00572 include_once ("./Modules/Test/classes/class.ilObjTest.php");
00573 $_GET["ref_id"] = $_GET["test_ref_id"];
00574 $test =& new ilObjTest($_GET["test_ref_id"], true);
00575 $test->insertQuestion($this->object->getId());
00576 ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=".$_GET["test_ref_id"]);
00577 }
00578 else
00579 {
00580 if ($this->object->getId() != $old_id)
00581 {
00582
00583 $this->ctrl->setParameterByClass($_GET["cmdClass"], "q_id", $this->object->getId());
00584 $this->ctrl->setParameterByClass($_GET["cmdClass"], "sel_question_types", $_GET["sel_question_types"]);
00585 ilUtil::sendInfo($this->lng->txt("msg_obj_modified"), true);
00586 $this->ctrl->redirectByClass($_GET["cmdClass"], "editQuestion");
00587 }
00588 if (strcmp($_SESSION["info"], "") != 0)
00589 {
00590 ilUtil::sendInfo($_SESSION["info"] . "<br />" . $this->lng->txt("msg_obj_modified"), false);
00591 }
00592 else
00593 {
00594 ilUtil::sendInfo($this->lng->txt("msg_obj_modified"), false);
00595 }
00596 $this->editQuestion();
00597
00598
00599 }
00600 }
00601 else
00602 {
00603 ilUtil::sendInfo($this->getErrorMessage());
00604 $this->editQuestion();
00605 }
00606 }
00607
00611 function apply()
00612 {
00613 $this->writePostData();
00614 $this->object->saveToDb();
00615 $this->ctrl->setParameter($this, "q_id", $this->object->getId());
00616 $this->editQuestion();
00617 }
00618
00619 function cancelExplorer()
00620 {
00621 unset($_SESSION["subquestion_index"]);
00622 unset($_SESSION["link_new_type"]);
00623 $this->editQuestion();
00624 }
00625
00633 function addSuggestedSolution()
00634 {
00635 global $tree;
00636
00637 include_once("./Modules/TestQuestionPool/classes/class.ilSolutionExplorer.php");
00638 switch ($_POST["internalLinkType"])
00639 {
00640 case "lm":
00641 $_SESSION["link_new_type"] = "lm";
00642 $_SESSION["search_link_type"] = "lm";
00643 break;
00644 case "glo":
00645 $_SESSION["link_new_type"] = "glo";
00646 $_SESSION["search_link_type"] = "glo";
00647 break;
00648 case "st":
00649 $_SESSION["link_new_type"] = "lm";
00650 $_SESSION["search_link_type"] = "st";
00651 break;
00652 case "pg":
00653 $_SESSION["link_new_type"] = "lm";
00654 $_SESSION["search_link_type"] = "pg";
00655 break;
00656 default:
00657 if (!$_SESSION["link_new_type"])
00658 {
00659 $_SESSION["link_new_type"] = "lm";
00660 }
00661 break;
00662 }
00663
00664 ilUtil::sendInfo($this->lng->txt("select_object_to_link"));
00665
00666 $exp = new ilSolutionExplorer($this->ctrl->getLinkTarget($this,'addSuggestedSolution'), get_class($this));
00667
00668 $exp->setExpand($_GET["expand"] ? $_GET["expand"] : $tree->readRootId());
00669 $exp->setExpandTarget($this->ctrl->getLinkTarget($this,'addSuggestedSolution'));
00670 $exp->setTargetGet("ref_id");
00671 $exp->setRefId($this->cur_ref_id);
00672 $exp->addFilter($_SESSION["link_new_type"]);
00673 $exp->setSelectableType($_SESSION["link_new_type"]);
00674
00675
00676 $exp->setOutput(0);
00677
00678 $this->tpl->addBlockFile("EXPLORER", "explorer", "tpl.il_as_qpl_explorer.html", "Modules/TestQuestionPool");
00679 $this->tpl->setVariable("EXPLORER_TREE",$exp->getOutput());
00680 $this->tpl->setVariable("BUTTON_CANCEL",$this->lng->txt("cancel"));
00681 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00682 $this->tpl->parseCurrentBlock();
00683 }
00684
00685 function removeSuggestedSolution()
00686 {
00687 $this->object->suggested_solutions = array();
00688 $this->object->saveToDb();
00689 $this->editQuestion();
00690 }
00691
00692 function addPG()
00693 {
00694 $subquestion_index = 0;
00695 if ($_SESSION["subquestion_index"] >= 0)
00696 {
00697 $subquestion_index = $_SESSION["subquestion_index"];
00698 }
00699 $this->object->setSuggestedSolution("il__pg_" . $_GET["pg"], $subquestion_index);
00700 unset($_SESSION["subquestion_index"]);
00701 unset($_SESSION["link_new_type"]);
00702 unset($_SESSION["search_link_type"]);
00703 ilUtil::sendInfo($this->lng->txt("suggested_solution_added_successfully"));
00704 $this->editQuestion();
00705 }
00706
00707 function addST()
00708 {
00709 $subquestion_index = 0;
00710 if ($_SESSION["subquestion_index"] >= 0)
00711 {
00712 $subquestion_index = $_SESSION["subquestion_index"];
00713 }
00714 $this->object->setSuggestedSolution("il__st_" . $_GET["st"], $subquestion_index);
00715 unset($_SESSION["subquestion_index"]);
00716 unset($_SESSION["link_new_type"]);
00717 unset($_SESSION["search_link_type"]);
00718 ilUtil::sendInfo($this->lng->txt("suggested_solution_added_successfully"));
00719 $this->editQuestion();
00720 }
00721
00722 function addGIT()
00723 {
00724 $subquestion_index = 0;
00725 if ($_SESSION["subquestion_index"] >= 0)
00726 {
00727 $subquestion_index = $_SESSION["subquestion_index"];
00728 }
00729 $this->object->setSuggestedSolution("il__git_" . $_GET["git"], $subquestion_index);
00730 unset($_SESSION["subquestion_index"]);
00731 unset($_SESSION["link_new_type"]);
00732 unset($_SESSION["search_link_type"]);
00733 ilUtil::sendInfo($this->lng->txt("suggested_solution_added_successfully"));
00734 $this->editQuestion();
00735 }
00736
00743 function getContextPath($cont_obj, $a_endnode_id, $a_startnode_id = 1)
00744 {
00745 $path = "";
00746
00747 $tmpPath = $cont_obj->getLMTree()->getPathFull($a_endnode_id, $a_startnode_id);
00748
00749
00750 for ($i = 1; $i < (count($tmpPath) - 1); $i++)
00751 {
00752 if ($path != "")
00753 {
00754 $path .= " > ";
00755 }
00756
00757 $path .= $tmpPath[$i]["title"];
00758 }
00759
00760 return $path;
00761 }
00762
00763 function linkChilds()
00764 {
00765 switch ($_SESSION["search_link_type"])
00766 {
00767 case "pg":
00768 include_once "./Modules/LearningModule/classes/class.ilLMPageObject.php";
00769 include_once("./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
00770 $cont_obj_gui =& new ilObjContentObjectGUI("", $_GET["source_id"], true);
00771 $cont_obj = $cont_obj_gui->object;
00772 $pages = ilLMPageObject::getPageList($cont_obj->getId());
00773 $shownpages = array();
00774 $tree = $cont_obj->getLMTree();
00775 $chapters = $tree->getSubtree($tree->getNodeData($tree->getRootId()));
00776 $this->ctrl->setParameter($this, "q_id", $this->object->getId());
00777 $this->tpl->setVariable("HEADER", $this->object->getTitle());
00778 $this->getQuestionTemplate();
00779 $color_class = array("tblrow1", "tblrow2");
00780 $counter = 0;
00781 $this->tpl->addBlockFile("LINK_SELECTION", "link_selection", "tpl.il_as_qpl_internallink_selection.html", "Modules/TestQuestionPool");
00782 foreach ($chapters as $chapter)
00783 {
00784 $chapterpages = $tree->getChildsByType($chapter["obj_id"], "pg");
00785 foreach ($chapterpages as $page)
00786 {
00787 if($page["type"] == $_SESSION["search_link_type"])
00788 {
00789 array_push($shownpages, $page["obj_id"]);
00790 $this->tpl->setCurrentBlock("linktable_row");
00791 $this->tpl->setVariable("TEXT_LINK", $page["title"]);
00792 $this->tpl->setVariable("TEXT_ADD", $this->lng->txt("add"));
00793 $this->tpl->setVariable("LINK_HREF", $this->ctrl->getLinkTargetByClass(get_class($this), "add" . strtoupper($page["type"])) . "&" . $page["type"] . "=" . $page["obj_id"]);
00794 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00795 if ($tree->isInTree($page["obj_id"]))
00796 {
00797 $path_str = $this->getContextPath($cont_obj, $page["obj_id"]);
00798 }
00799 else
00800 {
00801 $path_str = "---";
00802 }
00803 $this->tpl->setVariable("TEXT_DESCRIPTION", ilUtil::prepareFormOutput($path_str));
00804 $this->tpl->parseCurrentBlock();
00805 $counter++;
00806 }
00807 }
00808 }
00809 foreach ($pages as $page)
00810 {
00811 if (!in_array($page["obj_id"], $shownpages))
00812 {
00813 $this->tpl->setCurrentBlock("linktable_row");
00814 $this->tpl->setVariable("TEXT_LINK", $page["title"]);
00815 $this->tpl->setVariable("TEXT_ADD", $this->lng->txt("add"));
00816 $this->tpl->setVariable("LINK_HREF", $this->ctrl->getLinkTargetByClass(get_class($this), "add" . strtoupper($page["type"])) . "&" . $page["type"] . "=" . $page["obj_id"]);
00817 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00818 $path_str = "---";
00819 $this->tpl->setVariable("TEXT_DESCRIPTION", ilUtil::prepareFormOutput($path_str));
00820 $this->tpl->parseCurrentBlock();
00821 $counter++;
00822 }
00823 }
00824 $this->tpl->setCurrentBlock("link_selection");
00825 $this->tpl->setVariable("BUTTON_CANCEL",$this->lng->txt("cancel"));
00826 $this->tpl->setVariable("TEXT_LINK_TYPE", $this->lng->txt("obj_" . $_SESSION["search_link_type"]));
00827 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00828 $this->tpl->parseCurrentBlock();
00829 break;
00830 case "st":
00831 $this->ctrl->setParameter($this, "q_id", $this->object->getId());
00832 $this->tpl->setVariable("HEADER", $this->object->getTitle());
00833 $this->getQuestionTemplate();
00834 $color_class = array("tblrow1", "tblrow2");
00835 $counter = 0;
00836 include_once("./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
00837 $cont_obj_gui =& new ilObjContentObjectGUI("", $_GET["source_id"], true);
00838 $cont_obj = $cont_obj_gui->object;
00839
00840 $ctree =& $cont_obj->getLMTree();
00841 $nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId()));
00842 $this->tpl->addBlockFile("LINK_SELECTION", "link_selection", "tpl.il_as_qpl_internallink_selection.html", "Modules/TestQuestionPool");
00843 foreach($nodes as $node)
00844 {
00845 if($node["type"] == $_SESSION["search_link_type"])
00846 {
00847 $this->tpl->setCurrentBlock("linktable_row");
00848 $this->tpl->setVariable("TEXT_LINK", $node["title"]);
00849 $this->tpl->setVariable("TEXT_ADD", $this->lng->txt("add"));
00850 $this->tpl->setVariable("LINK_HREF", $this->ctrl->getLinkTargetByClass(get_class($this), "add" . strtoupper($node["type"])) . "&" . $node["type"] . "=" . $node["obj_id"]);
00851 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00852 $this->tpl->parseCurrentBlock();
00853 $counter++;
00854 }
00855 }
00856 $this->tpl->setCurrentBlock("link_selection");
00857 $this->tpl->setVariable("BUTTON_CANCEL",$this->lng->txt("cancel"));
00858 $this->tpl->setVariable("TEXT_LINK_TYPE", $this->lng->txt("obj_" . $_SESSION["search_link_type"]));
00859 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00860 $this->tpl->parseCurrentBlock();
00861 break;
00862 case "glo":
00863 $this->ctrl->setParameter($this, "q_id", $this->object->getId());
00864 $this->tpl->setVariable("HEADER", $this->object->getTitle());
00865 $this->getQuestionTemplate();
00866 $color_class = array("tblrow1", "tblrow2");
00867 $counter = 0;
00868 $this->tpl->addBlockFile("LINK_SELECTION", "link_selection", "tpl.il_as_qpl_internallink_selection.html", "Modules/TestQuestionPool");
00869 include_once "./Modules/Glossary/classes/class.ilObjGlossary.php";
00870 $glossary =& new ilObjGlossary($_GET["source_id"], true);
00871
00872 $terms = $glossary->getTermList();
00873 foreach($terms as $term)
00874 {
00875 $this->tpl->setCurrentBlock("linktable_row");
00876 $this->tpl->setVariable("TEXT_LINK", $term["term"]);
00877 $this->tpl->setVariable("TEXT_ADD", $this->lng->txt("add"));
00878 $this->tpl->setVariable("LINK_HREF", $this->ctrl->getLinkTargetByClass(get_class($this), "addGIT") . "&git=" . $term["id"]);
00879 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00880 $this->tpl->parseCurrentBlock();
00881 $counter++;
00882 }
00883 $this->tpl->setCurrentBlock("link_selection");
00884 $this->tpl->setVariable("BUTTON_CANCEL",$this->lng->txt("cancel"));
00885 $this->tpl->setVariable("TEXT_LINK_TYPE", $this->lng->txt("glossary_term"));
00886 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00887 $this->tpl->parseCurrentBlock();
00888 break;
00889 case "lm":
00890 $subquestion_index = 0;
00891 if ($_SESSION["subquestion_index"] >= 0)
00892 {
00893 $subquestion_index = $_SESSION["subquestion_index"];
00894 }
00895 $this->object->setSuggestedSolution("il__lm_" . $_GET["source_id"], $subquestion_index);
00896 unset($_SESSION["subquestion_index"]);
00897 unset($_SESSION["link_new_type"]);
00898 unset($_SESSION["search_link_type"]);
00899 ilUtil::sendInfo($this->lng->txt("suggested_solution_added_successfully"));
00900 $this->editQuestion();
00901 break;
00902 }
00903 }
00904
00905 function setSequenceNumber($nr)
00906 {
00907 $this->sequence_no = $nr;
00908 }
00909
00910 function getSequenceNumber()
00911 {
00912 return $this->sequence_no;
00913 }
00914
00915 function setQuestionCount($a_question_count)
00916 {
00917 $this->question_count = $a_question_count;
00918 }
00919
00920 function getQuestionCount()
00921 {
00922 return $this->question_count;
00923 }
00924
00925 function getErrorMessage()
00926 {
00927 return $this->errormessage;
00928 }
00929
00930 function setErrorMessage($errormessage)
00931 {
00932 $this->errormessage = $errormessage;
00933 }
00934
00935 function outAdditionalOutput()
00936 {
00937 }
00938
00947 function getQuestionType()
00948 {
00949 return $this->object->getQuestionType();
00950 }
00951
00962 function getAnswerFeedbackOutput($active_id, $pass)
00963 {
00964 $output = "";
00965 include_once "./Modules/Test/classes/class.ilObjTest.php";
00966 $manual_feedback = ilObjTest::getManualFeedback($active_id, $this->object->getId(), $pass);
00967 if (strlen($manual_feedback))
00968 {
00969 return $manual_feedback;
00970 }
00971 $correct_feedback = $this->object->getFeedbackGeneric(1);
00972 $incorrect_feedback = $this->object->getFeedbackGeneric(0);
00973 if (strlen($correct_feedback.$incorrect_feedback))
00974 {
00975 $reached_points = $this->object->calculateReachedPoints($active_id);
00976 $max_points = $this->object->getMaximumPoints();
00977 if ($reached_points == $max_points)
00978 {
00979 $output = $correct_feedback;
00980 }
00981 else
00982 {
00983 $output = $incorrect_feedback;
00984 }
00985 }
00986 return $this->object->prepareTextareaOutput($output, TRUE);
00987 }
00988
00996 function feedback()
00997 {
00998
00999 }
01000 }
01001 ?>