• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

assessment/classes/class.assQuestionGUI.php

Go to the documentation of this file.
00001 <?php
00002  /*
00003    +----------------------------------------------------------------------------+
00004    | ILIAS open source                                                          |
00005    +----------------------------------------------------------------------------+
00006    | Copyright (c) 1998-2001 ILIAS open source, University of Cologne           |
00007    |                                                                            |
00008    | This program is free software; you can redistribute it and/or              |
00009    | modify it under the terms of the GNU General Public License                |
00010    | as published by the Free Software Foundation; either version 2             |
00011    | of the License, or (at your option) any later version.                     |
00012    |                                                                            |
00013    | This program is distributed in the hope that it will be useful,            |
00014    | but WITHOUT ANY WARRANTY; without even the implied warranty of             |
00015    | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              |
00016    | GNU General Public License for more details.                               |
00017    |                                                                            |
00018    | You should have received a copy of the GNU General Public License          |
00019    | along with this program; if not, write to the Free Software                |
00020    | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
00021    +----------------------------------------------------------------------------+
00022 */
00023 
00024 include_once "./assessment/classes/inc.AssessmentConstants.php";
00025 
00037 class assQuestionGUI
00038 {
00046         var $object;
00047 
00048         var $tpl;
00049         var $lng;
00050         var $error;
00051         var $errormessage;
00052         
00056         var $sequence_no;
00060         var $question_count;
00061         
00069         function assQuestionGUI()
00070         {
00071                 global $lng, $tpl, $ilCtrl;
00072 
00073 
00074                 $this->lng =& $lng;
00075                 $this->tpl =& $tpl;
00076                 $this->ctrl =& $ilCtrl;
00077                 $this->ctrl->saveParameter($this, "q_id");
00078 
00079                 include_once "./assessment/classes/class.assQuestion.php";
00080                 $this->errormessage = $this->lng->txt("fill_out_all_required_fields");
00081                 $this->object = new assQuestion();
00082         }
00083 
00087         function &executeCommand()
00088         {
00089                 $cmd = $this->ctrl->getCmd("editQuestion");
00090                 $next_class = $this->ctrl->getNextClass($this);
00091 
00092                 $cmd = $this->getCommand($cmd);
00093 
00094                 switch($next_class)
00095                 {
00096                         default:
00097                                 $ret =& $this->$cmd();
00098                                 break;
00099                 }
00100                 return $ret;
00101         }
00102 
00103         function getCommand($cmd)
00104         {
00105                 return $cmd;
00106         }
00107 
00108 
00117         function getQuestionType()
00118         {
00119                 return "";
00120         }
00121 
00125         function getType()
00126         {
00127                 return $this->getQuestionType();
00128         }
00129 
00137         function outOtherQuestionData()
00138         {
00139                 $est_working_time = $this->object->getEstimatedWorkingTime();
00140                 $this->tpl->setVariable("TEXT_WORKING_TIME", $this->lng->txt("working_time"));
00141                 $this->tpl->setVariable("TIME_FORMAT", $this->lng->txt("time_format"));
00142                 $this->tpl->setVariable("VALUE_WORKING_TIME", ilUtil::makeTimeSelect("Estimated", false, $est_working_time[h], $est_working_time[m], $est_working_time[s]));
00143         }
00144 
00153         function writePostData()
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                 // catch feedback message
00166                 sendInfo();
00167 
00168                 $total_of_answers = $this->object->getTotalAnswers();
00169                 $counter = 0;
00170                 $color_class = array("tblrow1", "tblrow2");
00171                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_qpl_assessment_of_questions.html", true);
00172 
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 
00195                 $instances =& $this->object->getInstances();
00196                 $counter = 0;
00197                 foreach ($instances as $instance)
00198                 {
00199                         if (is_array($instance["refs"]))
00200                         {
00201                                 foreach ($instance["refs"] as $ref_id)
00202                                 {
00203                                         $this->tpl->setCurrentBlock("references");
00204                                         $this->tpl->setVariable("GOTO", "./goto.php?target=tst_" . $ref_id);
00205                                         $this->tpl->setVariable("TEXT_GOTO", $this->lng->txt("perma_link"));
00206                                         $this->tpl->parseCurrentBlock();
00207                                 }
00208                         }
00209                         $this->tpl->setCurrentBlock("instance_row");
00210                         $this->tpl->setVariable("TEST_TITLE", $instance["title"]);
00211                         $this->tpl->setVariable("TEST_AUTHOR", $instance["author"]);
00212                         $this->tpl->setVariable("QUESTION_ID", $instance["question_id"]);
00213                         $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00214                         $counter++;
00215                         $this->tpl->parseCurrentBlock();
00216                 }
00217                 $this->tpl->setCurrentBlock("instances");
00218                 $this->tpl->setVariable("TEXT_TEST_TITLE", $this->lng->txt("title"));
00219                 $this->tpl->setVariable("TEXT_TEST_AUTHOR", $this->lng->txt("author"));
00220                 $this->tpl->setVariable("TEXT_TEST_LOCATION", $this->lng->txt("location"));
00221                 $this->tpl->setVariable("INSTANCES_TITLE", $this->lng->txt("question_instances_title"));
00222                 $this->tpl->parseCurrentBlock();
00223 
00224                 $this->tpl->setCurrentBlock("adm_content");
00225                 $this->tpl->setVariable("TXT_QUESTION_TITLE", $this->lng->txt("question_cumulated_statistics"));
00226                 $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("result"));
00227                 $this->tpl->setVariable("TXT_VALUE", $this->lng->txt("value"));
00228                 $this->tpl->parseCurrentBlock();
00229         }
00230 
00239         function writeOtherPostData($result = 0)
00240         {
00241                 $this->object->setEstimatedWorkingTime(
00242                         ilUtil::stripSlashes($_POST["Estimated"][h]),
00243                         ilUtil::stripSlashes($_POST["Estimated"][m]),
00244                         ilUtil::stripSlashes($_POST["Estimated"][s])
00245                 );
00246 
00247                 $saved = false;
00248                 return $saved;
00249         }
00250 
00262         function &_getQuestionGUI($question_type, $question_id = -1)
00263         {
00264                 include_once "./assessment/classes/class.assQuestion.php";
00265                 if ((!$question_type) and ($question_id > 0))
00266                 {
00267                         $question_type = assQuestion::getQuestionTypeFromDb($question_id);
00268 // echo ":".$question_type;
00269                 }
00270                 if (strlen($question_type) == 0) return NULL;
00271                 include_once "./assessment/classes/class.".$question_type."GUI.php";
00272                 $question_type_gui = $question_type . "GUI";
00273                 $question =& new $question_type_gui();
00274                 if ($question_id > 0)
00275                 {
00276                         $question->object->loadFromDb($question_id);
00277                 }
00278                 return $question;
00279         }
00280 
00281         function _getGUIClassNameForId($a_q_id)
00282         {
00283                 include_once "./assessment/classes/class.assQuestion.php";
00284                 include_once "./assessment/classes/class.assQuestionGUI.php";
00285                 $q_type =  assQuestion::getQuestionTypeFromDb($a_q_id);
00286                 $class_name = assQuestionGUI::_getClassNameForQType($q_type);
00287                 return $class_name;
00288         }
00289 
00290         function _getClassNameForQType($q_type)
00291         {
00292                 return $q_type . "GUI";
00293         }
00294 
00305         function &createQuestionGUI($question_type, $question_id = -1)
00306         {
00307                 include_once "./assessment/classes/class.assQuestionGUI.php";
00308                 $this->question =& assQuestionGUI::_getQuestionGUI($question_type, $question_id);
00309         }
00310 
00314         function getQuestionTemplate()
00315         {
00316                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.il_as_qpl_content.html", true);
00317                 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00318                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_question.html", true);
00319         }
00320 
00329         function getILIASPage()
00330         {
00331                 include_once("content/classes/Pages/class.ilPageObject.php");
00332                 include_once("content/classes/Pages/class.ilPageObjectGUI.php");
00333                 $page =& new ilPageObject("qpl", $this->object->getId());
00334                 $page_gui =& new ilPageObjectGUI($page);
00335                 $page_gui->setTemplateTargetVar($a_temp_var);
00336                 $page_gui->setFileDownloadLink("ilias.php?baseClass=ilObjTestGUI&cmd=downloadFile".
00337                         "&amp;ref_id=".$_GET["ref_id"]);
00338                 $page_gui->setFullscreenLink("ilias.php?baseClass=ilObjTestGUI&cmd=fullscreen".
00339                         "&amp;ref_id=".$_GET["ref_id"]);
00340                 $page_gui->setSourcecodeDownloadScript("ilias.php?baseClass=ilObjTestGUI&ref_id=".$_GET["ref_id"]);
00341                 $page_gui->setOutputMode("presentation");
00342                 $page_gui->setPresentationTitle("");
00343                 return $page_gui->presentation();
00344         }
00345 
00349         function outQuestionPage($a_temp_var, $a_postponed = false, $active_id = "")
00350         {
00351                 $postponed = "";
00352                 if ($a_postponed)
00353                 {
00354                         $postponed = " (" . $this->lng->txt("postponed") . ")";
00355                 }
00356 
00357                 include_once("content/classes/Pages/class.ilPageObject.php");
00358                 include_once("content/classes/Pages/class.ilPageObjectGUI.php");
00359                 $this->lng->loadLanguageModule("content");
00360                 $page =& new ilPageObject("qpl", $this->object->getId());
00361                 $page_gui =& new ilPageObjectGUI($page);
00362                 $page_gui->setTemplateTargetVar($a_temp_var);
00363                 $page_gui->setFileDownloadLink("ilias.php?baseClass=ilObjTestGUI&cmd=downloadFile".
00364                         "&amp;ref_id=".$_GET["ref_id"]);
00365                 $page_gui->setFullscreenLink("ilias.php?baseClass=ilObjTestGUI&cmd=fullscreen".
00366                         "&amp;ref_id=".$_GET["ref_id"]);
00367                 $page_gui->setSourcecodeDownloadScript("ilias.php?baseClass=ilObjTestGUI&ref_id=".$_GET["ref_id"]);
00368                 $page_gui->setOutputMode("presentation");
00369                 include_once "./assessment/classes/class.ilObjTest.php";
00370 
00371                 $maxpoints = "";
00372                 if (!ilObjTest::_getHideTitlePoints($active_id))
00373                 {
00374                         $maxpoints = $this->object->getMaximumPoints();
00375                         if ($maxpoints == 1)
00376                         {
00377                                 $maxpoints = " (".$maxpoints." ".$this->lng->txt("point").")";
00378                         }
00379                         else
00380                         {
00381                                 $maxpoints = " (".$maxpoints." ".$this->lng->txt("points").")";
00382                         }
00383                 }
00384                 $page_gui->setPresentationTitle(sprintf($this->lng->txt("tst_position"), $this->getSequenceNumber(), $this->getQuestionCount())." - ".$this->object->getTitle().$postponed.$maxpoints);
00385                 $presentation = $page_gui->presentation();
00386                 if (strlen($maxpoints)) $presentation = str_replace($maxpoints, "<em>$maxpoints</em>", $presentation);
00387                 return $presentation;
00388         }
00389         
00393         function cancel()
00394         {
00395                 if ($_GET["calling_test"])
00396                 {
00397                         $_GET["ref_id"] = $_GET["calling_test"];
00398                         ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=".$_GET["calling_test"]);
00399                 }
00400                 elseif ($_GET["test_ref_id"])
00401                 {
00402                         $_GET["ref_id"] = $_GET["test_ref_id"];
00403                         ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=".$_GET["test_ref_id"]);
00404                 }
00405                 else
00406                 {
00407                         if ($_GET["q_id"] > 0)
00408                         {
00409                                 $this->ctrl->setParameterByClass("ilpageobjectgui", "q_id", $_GET["q_id"]);
00410                                 $this->ctrl->redirectByClass("ilpageobjectgui", "view");
00411                         }
00412                         else
00413                         {
00414                                 $this->ctrl->redirectByClass("ilobjquestionpoolgui", "questions");
00415                         }
00416                 }
00417         }
00418 
00419         function originalSyncForm()
00420         {
00421                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_tst_sync_original.html", true);
00422                 $this->tpl->setCurrentBlock("adm_content");
00423                 $this->tpl->setVariable("BUTTON_YES", $this->lng->txt("yes"));
00424                 $this->tpl->setVariable("BUTTON_NO", $this->lng->txt("no"));
00425                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00426                 $this->tpl->setVariable("TEXT_SYNC", $this->lng->txt("confirm_sync_questions"));
00427                 $this->tpl->parseCurrentBlock();
00428         }
00429         
00430         function sync()
00431         {
00432                 $original_id = $this->object->original_id;
00433                 if ($original_id)
00434                 {
00435                         $this->object->syncWithOriginal();
00436                 }
00437                 $_GET["ref_id"] = $_GET["calling_test"];
00438                 ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=".$_GET["calling_test"]);
00439         }
00440 
00441         function cancelSync()
00442         {
00443                 $_GET["ref_id"] = $_GET["calling_test"];
00444                 ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=".$_GET["calling_test"]);
00445         }
00446                 
00450         function saveEdit()
00451         {
00452                 global $ilUser;
00453 
00454                 $result = $this->writePostData();
00455                 if ($result == 0)
00456                 {
00457                         $ilUser->setPref("tst_lastquestiontype", $this->object->getQuestionType());
00458                         $ilUser->writePref("tst_lastquestiontype", $this->object->getQuestionType());
00459                         $this->object->saveToDb();
00460                         $originalexists = $this->object->_questionExists($this->object->original_id);
00461                         include_once "./assessment/classes/class.assQuestion.php";
00462                         if ($_GET["calling_test"] && $originalexists && assQuestion::_isWriteable($this->object->original_id, $ilUser->getId()))
00463                         {
00464                                 $this->originalSyncForm();
00465                         }
00466                         elseif ($_GET["calling_test"])
00467                         {
00468                                 $_GET["ref_id"] = $_GET["calling_test"];
00469                                 ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=".$_GET["calling_test"]);
00470                                 return;
00471                         }
00472                         elseif ($_GET["test_ref_id"])
00473                         {
00474                                 include_once ("./assessment/classes/class.ilObjTest.php");
00475                                 $_GET["ref_id"] = $_GET["test_ref_id"];
00476                                 $test =& new ilObjTest($_GET["test_ref_id"], true);
00477                                 $test->insertQuestion($this->object->getId());
00478                                 ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=".$_GET["test_ref_id"]);
00479                         }
00480                         else
00481                         {
00482                                 $_GET["q_id"] = $this->object->getId();
00483                                 $this->editQuestion();
00484                                 if (strcmp($_SESSION["info"], "") != 0)
00485                                 {
00486                                         sendInfo($_SESSION["info"] . "<br />" . $this->lng->txt("msg_obj_modified"), false);
00487                                 }
00488                                 else
00489                                 {
00490                                         sendInfo($this->lng->txt("msg_obj_modified"), false);
00491                                 }
00492                                 $this->ctrl->setParameterByClass("ilpageobjectgui", "q_id", $this->object->getId());
00493                                 $this->ctrl->redirectByClass("ilpageobjectgui", "view");
00494                         }
00495                 }
00496                 else
00497                 {
00498       sendInfo($this->lng->txt("fill_out_all_required_fields"));
00499                         $this->editQuestion();
00500                 }
00501         }
00502 
00506         function save()
00507         {
00508                 global $ilUser;
00509                 
00510                 $old_id = $_GET["q_id"];
00511                 $result = $this->writePostData();
00512                 if ($result == 0)
00513                 {
00514                         $ilUser->setPref("tst_lastquestiontype", $this->object->getQuestionType());
00515                         $ilUser->writePref("tst_lastquestiontype", $this->object->getQuestionType());
00516                         $this->object->saveToDb();
00517                         $originalexists = $this->object->_questionExists($this->object->original_id);
00518                         include_once "./assessment/classes/class.assQuestion.php";
00519                         if ($_GET["calling_test"] && $originalexists && assQuestion::_isWriteable($this->object->original_id, $ilUser->getId()))
00520                         {
00521                                 $this->originalSyncForm();
00522                         }
00523                         elseif ($_GET["calling_test"])
00524                         {
00525                                 $_GET["ref_id"] = $_GET["calling_test"];
00526                                 ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=".$_GET["calling_test"]);
00527                                 return;
00528                         }
00529                         elseif ($_GET["test_ref_id"])
00530                         {
00531                                 include_once ("./assessment/classes/class.ilObjTest.php");
00532                                 $_GET["ref_id"] = $_GET["test_ref_id"];
00533                                 $test =& new ilObjTest($_GET["test_ref_id"], true);
00534                                 $test->insertQuestion($this->object->getId());
00535                                 ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=".$_GET["test_ref_id"]);
00536                         }
00537                         else
00538                         {
00539                                 $_GET["q_id"] = $this->object->getId();
00540                                 if ($_GET["q_id"] !=  $old_id)
00541                                 {
00542                                         // first save
00543                                         $this->ctrl->setParameterByClass($_GET["cmdClass"], "q_id", $this->object->getId());
00544                                         $this->ctrl->setParameterByClass($_GET["cmdClass"], "sel_question_types", $_GET["sel_question_types"]);
00545                                         sendInfo($this->lng->txt("msg_obj_modified"), true);
00546                                         $this->ctrl->redirectByClass($_GET["cmdClass"], "editQuestion");
00547                                 }
00548                                 if (strcmp($_SESSION["info"], "") != 0)
00549                                 {
00550                                         sendInfo($_SESSION["info"] . "<br />" . $this->lng->txt("msg_obj_modified"), false);
00551                                 }
00552                                 else
00553                                 {
00554                                         sendInfo($this->lng->txt("msg_obj_modified"), false);
00555                                 }
00556                                 $this->editQuestion();
00557         //                      $this->ctrl->setParameterByClass("ilpageobjectgui", "q_id", $this->object->getId());
00558         //                      $this->ctrl->redirectByClass("ilpageobjectgui", "view");
00559                         }
00560                 }
00561                 else
00562                 {
00563       sendInfo($this->getErrorMessage());
00564                         $this->editQuestion();
00565                 }
00566         }
00567 
00571         function apply()
00572         {
00573                 $this->writePostData();
00574                 $this->object->saveToDb();
00575                 $_GET["q_id"] = $this->object->getId();
00576                 $this->editQuestion();
00577         }
00578         
00579         function cancelExplorer()
00580         {
00581                 unset($_SESSION["subquestion_index"]);
00582                 unset($_SESSION["link_new_type"]);
00583                 $this->editQuestion();
00584         }
00585         
00593         function addSuggestedSolution()
00594         {
00595                 global $tree;
00596 
00597                 include_once("./assessment/classes/class.ilSolutionExplorer.php");
00598                 switch ($_POST["internalLinkType"])
00599                 {
00600                         case "lm":
00601                                 $_SESSION["link_new_type"] = "lm";
00602                                 $_SESSION["search_link_type"] = "lm";
00603                                 break;
00604                         case "glo":
00605                                 $_SESSION["link_new_type"] = "glo";
00606                                 $_SESSION["search_link_type"] = "glo";
00607                                 break;
00608                         case "st":
00609                                 $_SESSION["link_new_type"] = "lm";
00610                                 $_SESSION["search_link_type"] = "st";
00611                                 break;
00612                         case "pg":
00613                                 $_SESSION["link_new_type"] = "lm";
00614                                 $_SESSION["search_link_type"] = "pg";
00615                                 break;
00616                         default:
00617                                 if (!$_SESSION["link_new_type"])
00618                                 {
00619                                         $_SESSION["link_new_type"] = "lm";
00620                                 }
00621                                 break;
00622                 }
00623 
00624                 sendInfo($this->lng->txt("select_object_to_link"));
00625                 
00626                 $exp = new ilSolutionExplorer($this->ctrl->getLinkTarget($this,'addSuggestedSolution'), get_class($this));
00627 
00628                 $exp->setExpand($_GET["expand"] ? $_GET["expand"] : $tree->readRootId());
00629                 $exp->setExpandTarget($this->ctrl->getLinkTarget($this,'addSuggestedSolution'));
00630                 $exp->setTargetGet("ref_id");
00631                 $exp->setRefId($this->cur_ref_id);
00632                 $exp->addFilter($_SESSION["link_new_type"]);
00633                 $exp->setSelectableType($_SESSION["link_new_type"]);
00634 
00635                 // build html-output
00636                 $exp->setOutput(0);
00637 
00638                 $this->tpl->addBlockFile("EXPLORER", "explorer", "tpl.il_as_qpl_explorer.html", true);
00639                 $this->tpl->setVariable("EXPLORER_TREE",$exp->getOutput());
00640                 $this->tpl->setVariable("BUTTON_CANCEL",$this->lng->txt("cancel"));
00641                 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00642                 $this->tpl->parseCurrentBlock();
00643         }
00644         
00645         function removeSuggestedSolution()
00646         {
00647                 $this->object->suggested_solutions = array();
00648                 $this->object->saveToDb();
00649                 $this->editQuestion();
00650         }
00651         
00652         function addPG()
00653         {
00654                 $subquestion_index = 0;
00655                 if ($_SESSION["subquestion_index"] >= 0)
00656                 {
00657                         $subquestion_index = $_SESSION["subquestion_index"];
00658                 }
00659                 $this->object->setSuggestedSolution("il__pg_" . $_GET["pg"], $subquestion_index);
00660                 unset($_SESSION["subquestion_index"]);
00661                 unset($_SESSION["link_new_type"]);
00662                 unset($_SESSION["search_link_type"]);
00663                 sendInfo($this->lng->txt("suggested_solution_added_successfully"));
00664                 $this->editQuestion();
00665         }
00666         
00667         function addST()
00668         {
00669                 $subquestion_index = 0;
00670                 if ($_SESSION["subquestion_index"] >= 0)
00671                 {
00672                         $subquestion_index = $_SESSION["subquestion_index"];
00673                 }
00674                 $this->object->setSuggestedSolution("il__st_" . $_GET["st"], $subquestion_index);
00675                 unset($_SESSION["subquestion_index"]);
00676                 unset($_SESSION["link_new_type"]);
00677                 unset($_SESSION["search_link_type"]);
00678                 sendInfo($this->lng->txt("suggested_solution_added_successfully"));
00679                 $this->editQuestion();
00680         }
00681 
00682         function addGIT()
00683         {
00684                 $subquestion_index = 0;
00685                 if ($_SESSION["subquestion_index"] >= 0)
00686                 {
00687                         $subquestion_index = $_SESSION["subquestion_index"];
00688                 }
00689                 $this->object->setSuggestedSolution("il__git_" . $_GET["git"], $subquestion_index);
00690                 unset($_SESSION["subquestion_index"]);
00691                 unset($_SESSION["link_new_type"]);
00692                 unset($_SESSION["search_link_type"]);
00693                 sendInfo($this->lng->txt("suggested_solution_added_successfully"));
00694                 $this->editQuestion();
00695         }
00696         
00697         function linkChilds()
00698         {
00699                 switch ($_SESSION["search_link_type"])
00700                 {
00701                         case "pg":
00702                                 include_once "./content/classes/class.ilLMPageObject.php";
00703                                 include_once("./content/classes/class.ilObjContentObject.php");
00704                                 $cont_obj =& new ilObjContentObject($_GET["source_id"], true);
00705                                 $pages = ilLMPageObject::getPageList($cont_obj->getId());
00706                                 $_GET["q_id"] = $this->object->getId();
00707                                 $this->tpl->setVariable("HEADER", $this->object->getTitle());
00708                                 $this->getQuestionTemplate();
00709                                 $color_class = array("tblrow1", "tblrow2");
00710                                 $counter = 0;
00711                                 $this->tpl->addBlockFile("LINK_SELECTION", "link_selection", "tpl.il_as_qpl_internallink_selection.html", true);
00712                                 foreach($pages as $page)
00713                                 {
00714                                         if($page["type"] == $_SESSION["search_link_type"])
00715                                         {
00716                                                 $this->tpl->setCurrentBlock("linktable_row");
00717                                                 $this->tpl->setVariable("TEXT_LINK", $page["title"]);
00718                                                 $this->tpl->setVariable("TEXT_ADD", $this->lng->txt("add"));
00719                                                 $this->tpl->setVariable("LINK_HREF", $this->ctrl->getLinkTargetByClass(get_class($this), "add" . strtoupper($page["type"])) . "&" . $page["type"] . "=" . $page["obj_id"]);
00720                                                 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00721                                                 $this->tpl->parseCurrentBlock();
00722                                                 $counter++;
00723                                         }
00724                                 }
00725                                 $this->tpl->setCurrentBlock("link_selection");
00726                                 $this->tpl->setVariable("BUTTON_CANCEL",$this->lng->txt("cancel"));
00727                                 $this->tpl->setVariable("TEXT_LINK_TYPE", $this->lng->txt("obj_" . $_SESSION["search_link_type"]));
00728                                 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00729                                 $this->tpl->parseCurrentBlock();
00730                                 break;
00731                         case "st":
00732                                 $_GET["q_id"] = $this->object->getId();
00733                                 $this->tpl->setVariable("HEADER", $this->object->getTitle());
00734                                 $this->getQuestionTemplate();
00735                                 $color_class = array("tblrow1", "tblrow2");
00736                                 $counter = 0;
00737                                 include_once("./content/classes/class.ilObjContentObject.php");
00738                                 $cont_obj =& new ilObjContentObject($_GET["source_id"], true);
00739                                 // get all chapters
00740                                 $ctree =& $cont_obj->getLMTree();
00741                                 $nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId()));
00742                                 $this->tpl->addBlockFile("LINK_SELECTION", "link_selection", "tpl.il_as_qpl_internallink_selection.html", true);
00743                                 foreach($nodes as $node)
00744                                 {
00745                                         if($node["type"] == $_SESSION["search_link_type"])
00746                                         {
00747                                                 $this->tpl->setCurrentBlock("linktable_row");
00748                                                 $this->tpl->setVariable("TEXT_LINK", $node["title"]);
00749                                                 $this->tpl->setVariable("TEXT_ADD", $this->lng->txt("add"));
00750                                                 $this->tpl->setVariable("LINK_HREF", $this->ctrl->getLinkTargetByClass(get_class($this), "add" . strtoupper($node["type"])) . "&" . $node["type"] . "=" . $node["obj_id"]);
00751                                                 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00752                                                 $this->tpl->parseCurrentBlock();
00753                                                 $counter++;
00754                                         }
00755                                 }
00756                                 $this->tpl->setCurrentBlock("link_selection");
00757                                 $this->tpl->setVariable("BUTTON_CANCEL",$this->lng->txt("cancel"));
00758                                 $this->tpl->setVariable("TEXT_LINK_TYPE", $this->lng->txt("obj_" . $_SESSION["search_link_type"]));
00759                                 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00760                                 $this->tpl->parseCurrentBlock();
00761                                 break;
00762                         case "glo":
00763                                 $_GET["q_id"] = $this->object->getId();
00764                                 $this->tpl->setVariable("HEADER", $this->object->getTitle());
00765                                 $this->getQuestionTemplate();
00766                                 $color_class = array("tblrow1", "tblrow2");
00767                                 $counter = 0;
00768                                 $this->tpl->addBlockFile("LINK_SELECTION", "link_selection", "tpl.il_as_qpl_internallink_selection.html", true);
00769                                 include_once "./content/classes/class.ilObjGlossary.php";
00770                                 $glossary =& new ilObjGlossary($_GET["source_id"], true);
00771                                 // get all glossary items
00772                                 $terms = $glossary->getTermList();
00773                                 foreach($terms as $term)
00774                                 {
00775                                         $this->tpl->setCurrentBlock("linktable_row");
00776                                         $this->tpl->setVariable("TEXT_LINK", $term["term"]);
00777                                         $this->tpl->setVariable("TEXT_ADD", $this->lng->txt("add"));
00778                                         $this->tpl->setVariable("LINK_HREF", $this->ctrl->getLinkTargetByClass(get_class($this), "addGIT") . "&git=" . $term["id"]);
00779                                         $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00780                                         $this->tpl->parseCurrentBlock();
00781                                         $counter++;
00782                                 }
00783                                 $this->tpl->setCurrentBlock("link_selection");
00784                                 $this->tpl->setVariable("BUTTON_CANCEL",$this->lng->txt("cancel"));
00785                                 $this->tpl->setVariable("TEXT_LINK_TYPE", $this->lng->txt("glossary_term"));
00786                                 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00787                                 $this->tpl->parseCurrentBlock();
00788                                 break;
00789                         case "lm":
00790                                 $subquestion_index = 0;
00791                                 if ($_SESSION["subquestion_index"] >= 0)
00792                                 {
00793                                         $subquestion_index = $_SESSION["subquestion_index"];
00794                                 }
00795                                 $this->object->setSuggestedSolution("il__lm_" . $_GET["source_id"], $subquestion_index);
00796                                 unset($_SESSION["subquestion_index"]);
00797                                 unset($_SESSION["link_new_type"]);
00798                                 unset($_SESSION["search_link_type"]);
00799                                 sendInfo($this->lng->txt("suggested_solution_added_successfully"));
00800                                 $this->editQuestion();
00801                                 break;
00802                 }
00803         }
00804         
00805         function setSequenceNumber($nr) 
00806         {
00807                 $this->sequence_no = $nr;
00808         }
00809         
00810         function getSequenceNumber() 
00811         {
00812                 return $this->sequence_no;
00813         }
00814         
00815         function setQuestionCount($a_question_count)
00816         {
00817                 $this->question_count = $a_question_count;
00818         }
00819         
00820         function getQuestionCount()
00821         {
00822                 return $this->question_count;
00823         }
00824         
00825         function getErrorMessage()
00826         {
00827                 return $this->errormessage;
00828         }
00829         
00830         function setErrorMessage($errormessage)
00831         {
00832                 $this->errormessage = $errormessage;
00833         }
00834         
00835         function outAdditionalOutput()
00836         {
00837         }
00838 }
00839 ?>

Generated on Fri Dec 13 2013 13:52:05 for ILIAS Release_3_7_x_branch .rev 46817 by  doxygen 1.7.1