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

Modules/TestQuestionPool/classes/class.assMatchingQuestionGUI.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 "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
00025 include_once "./Modules/Test/classes/inc.AssessmentConstants.php";
00026 
00037 class assMatchingQuestionGUI extends assQuestionGUI
00038 {
00047         function assMatchingQuestionGUI(
00048                 $id = -1
00049         )
00050         {
00051                 $this->assQuestionGUI();
00052                 include_once "./Modules/TestQuestionPool/classes/class.assMatchingQuestion.php";
00053                 $this->object = new assMatchingQuestion();
00054                 if ($id >= 0)
00055                 {
00056                         $this->object->loadFromDb($id);
00057                 }
00058         }
00059 
00060         function getCommand($cmd)
00061         {
00062                 if (substr($cmd, 0, 6) == "delete")
00063                 {
00064                         $cmd = "delete";
00065                 }
00066                 if (substr($cmd, 0, 6) == "upload")
00067                 {
00068                         $cmd = "upload";
00069                 }
00070 
00071                 return $cmd;
00072         }
00073 
00081         function editQuestion($has_error = 0, $delete = false)
00082         {
00083                 $multiline_answers = $this->object->getMultilineAnswerSetting();
00084                 $this->getQuestionTemplate();
00085                 $this->tpl->addBlockFile("QUESTION_DATA", "question_data", "tpl.il_as_qpl_matching.html", "Modules/TestQuestionPool");
00086 
00087                 $tblrow = array("tblrow1top", "tblrow2top");
00088                 // Vorhandene Anworten ausgeben
00089                 for ($i = 0; $i < $this->object->get_matchingpair_count(); $i++)
00090                 {
00091                         $thispair = $this->object->get_matchingpair($i);
00092                         if ($this->object->get_matching_type() == MT_TERMS_PICTURES)
00093                         {
00094                                 $this->tpl->setCurrentBlock("pictures");
00095                                 $this->tpl->setVariable("ANSWER_ORDER", $i);
00096                                 $this->tpl->setVariable("PICTURE_ID", $thispair->getPictureId());
00097                                 $this->tpl->setVariable("COLOR_CLASS", $tblrow[$i % 2]);
00098                                 $filename = $thispair->getPicture();
00099                                 if ($filename)
00100                                 {
00101                                         $imagepath = $this->object->getImagePathWeb() . $thispair->getPicture();
00102                                         $this->tpl->setVariable("UPLOADED_IMAGE", "<img src=\"$imagepath.thumb.jpg\" alt=\"" . $this->lng->txt("qpl_display_fullsize_image") . "\" title=\"" . $this->lng->txt("qpl_display_fullsize_image") . "\" border=\"\" />");
00103                                         $this->tpl->setVariable("IMAGE_FILENAME", $thispair->getPicture());
00104                                         $this->tpl->setVariable("VALUE_PICTURE", $thispair->getPicture());
00105                                 }
00106                                 $this->tpl->setVariable("UPLOAD", $this->lng->txt("upload"));
00107                         }
00108                         elseif ($this->object->get_matching_type() == MT_TERMS_DEFINITIONS)
00109                         {
00110                                 $this->tpl->setCurrentBlock("definitions");
00111                                 $this->tpl->setVariable("ANSWER_ORDER", $i);
00112                                 $this->tpl->setVariable("DEFINITION_ID", $thispair->getDefinitionId());
00113                                 $this->tpl->setVariable("VALUE_DEFINITION", ilUtil::prepareFormOutput($thispair->getDefinition()));
00114                                 $this->tpl->setVariable("COLOR_CLASS", $tblrow[$i % 2]);
00115                         }
00116                         $this->tpl->parseCurrentBlock();
00117                         $this->tpl->setCurrentBlock("answers");
00118                         $this->tpl->setVariable("VALUE_ANSWER_COUNTER", $i + 1);
00119                         $this->tpl->setVariable("ANSWER_ORDER", $i);
00120                         $this->tpl->setVariable("TERM_ID", $thispair->getTermId());
00121                         $this->tpl->setVariable("VALUE_TERM", ilUtil::prepareFormOutput($thispair->getTerm()));
00122                         $this->tpl->setVariable("TEXT_MATCHES", $this->lng->txt("matches"));
00123                         $this->tpl->setVariable("VALUE_MATCHINGPAIR_POINTS", $thispair->getPoints());
00124                         $this->tpl->setVariable("COLOR_CLASS", $tblrow[$i % 2]);
00125                         $this->tpl->parseCurrentBlock();
00126                 }
00127                 
00128                 if ($this->object->get_matching_type() == MT_TERMS_DEFINITIONS)
00129                 {
00130                         /*
00131                         $this->tpl->setCurrentBlock("multiline_answers");
00132                         if ($multiline_answers)
00133                         {
00134                                 $this->tpl->setVariable("SELECTED_SHOW_MULTILINE_ANSWERS", " selected=\"selected\"");
00135                         }
00136                         $this->tpl->setVariable("TEXT_HIDE_MULTILINE_ANSWERS", $this->lng->txt("multiline_definitions_hide"));
00137                         $this->tpl->setVariable("TEXT_SHOW_MULTILINE_ANSWERS", $this->lng->txt("multiline_definitions_show"));
00138                         $this->tpl->parseCurrentBlock();
00139                         */
00140                 }
00141                 
00142                 if ($this->object->get_matchingpair_count())
00143                 {
00144                         $this->tpl->setCurrentBlock("answerhead");
00145                         $this->tpl->setVariable("TEXT_POINTS", $this->lng->txt("points"));
00146                         $this->tpl->setVariable("TERM", $this->lng->txt("term"));
00147                         if ($this->object->get_matching_type() == MT_TERMS_PICTURES)
00148                         {
00149                                 $this->tpl->setVariable("PICTURE_OR_DEFINITION", $this->lng->txt("picture"));
00150                         }
00151                         else
00152                         {
00153                                 $this->tpl->setVariable("PICTURE_OR_DEFINITION", $this->lng->txt("definition"));
00154                         }
00155                         $this->tpl->parseCurrentBlock();
00156                         $this->tpl->setCurrentBlock("selectall");
00157                         $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
00158                         $i++;
00159                         $this->tpl->setVariable("COLOR_CLASS", $tblrow[$i % 2]);
00160                         $this->tpl->parseCurrentBlock();
00161                         $this->tpl->setCurrentBlock("QFooter");
00162                         $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\"/>");
00163                         $this->tpl->setVariable("DELETE", $this->lng->txt("delete"));
00164                         $this->tpl->parseCurrentBlock();
00165                 }
00166                 // call to other question data i.e. estimated working time block
00167                 $this->outOtherQuestionData();
00168 
00169                 // Check the creation of new answer text fields
00170                 $allow_add_pair = 1;
00171                 foreach ($_POST as $key => $value)
00172                 {
00173                         if (preg_match("/(term|picture|definition)_(\d+)_(\d+)/", $key, $matches))
00174                         {
00175                                 if (strlen($value) == 0)
00176                                 {
00177                                         $allow_add_pair = 0;
00178                                 }
00179                         }
00180                 }
00181                 $add_random_id = "";
00182                 if (($this->ctrl->getCmd() == "addPair") and $allow_add_pair and (!$has_error))
00183                 {
00184                         $i++;
00185                         // Template für neue Antwort erzeugen
00186                         if ($this->object->get_matching_type() == MT_TERMS_PICTURES)
00187                         {
00188                                 $this->tpl->setCurrentBlock("pictures");
00189                                 $this->tpl->setVariable("ANSWER_ORDER", $this->object->get_matchingpair_count());
00190                                 $this->tpl->setVariable("PICTURE_ID", $this->object->get_random_id());
00191                                 $this->tpl->setVariable("VALUE_PICTURE", "");
00192                                 $this->tpl->setVariable("UPLOAD", $this->lng->txt("upload"));
00193                         }
00194                         elseif ($this->object->get_matching_type() == MT_TERMS_DEFINITIONS)
00195                         {
00196                                 $this->tpl->setCurrentBlock("definitions");
00197                                 $this->tpl->setVariable("ANSWER_ORDER", $this->object->get_matchingpair_count());
00198                                 $this->tpl->setVariable("DEFINITION_ID", $this->object->get_random_id());
00199                                 $this->tpl->setVariable("VALUE_DEFINITION", "");
00200                         }
00201                         $this->tpl->parseCurrentBlock();
00202                         $this->tpl->setCurrentBlock("answers");
00203                         $this->tpl->setVariable("TEXT_MATCHING_PAIR", $this->lng->txt("matching_pair"));
00204                         $this->tpl->setVariable("VALUE_ANSWER_COUNTER", $this->object->get_matchingpair_count() + 1);
00205                         $this->tpl->setVariable("TEXT_MATCHES", $this->lng->txt("matches"));
00206                         $this->tpl->setVariable("ANSWER_ORDER", $this->object->get_matchingpair_count());
00207                         $add_random_id = $this->object->get_random_id();
00208                         $this->tpl->setVariable("TERM_ID", $add_random_id);
00209                         $this->tpl->setVariable("VALUE_MATCHINGPAIR_POINTS", sprintf("%s", 0));
00210                         $this->tpl->setVariable("COLOR_CLASS", $tblrow[$i % 2]);
00211                         $this->tpl->parseCurrentBlock();
00212                 }
00213                 else if ($this->ctrl->getCmd() == "addPair")
00214                 {
00215                         $this->error .= $this->lng->txt("fill_out_all_matching_pairs") . "<br />";
00216                 }
00217 
00218                 $internallinks = array(
00219                         "lm" => $this->lng->txt("obj_lm"),
00220                         "st" => $this->lng->txt("obj_st"),
00221                         "pg" => $this->lng->txt("obj_pg"),
00222                         "glo" => $this->lng->txt("glossary_term")
00223                 );
00224                 foreach ($internallinks as $key => $value)
00225                 {
00226                         $this->tpl->setCurrentBlock("internallink");
00227                         $this->tpl->setVariable("TYPE_INTERNAL_LINK", $key);
00228                         $this->tpl->setVariable("TEXT_INTERNAL_LINK", $value);
00229                         $this->tpl->parseCurrentBlock();
00230                 }
00231                 
00232                 $this->tpl->setCurrentBlock("HeadContent");
00233                 $this->tpl->addJavascript("./Services/JavaScript/js/Basic.js");
00234                 $javascript = "<script type=\"text/javascript\">ilAddOnLoad(initialSelect);\n".
00235                         "function initialSelect() {\n%s\n}</script>";
00236                 if ($delete)
00237                 {
00238                         if ($this->object->get_matchingpair_count() > 0)
00239                         {
00240                                 $thispair = $this->object->get_matchingpair($this->object->get_matchingpair_count()-1);
00241                                 $this->tpl->setVariable("CONTENT_BLOCK", sprintf($javascript, "document.frm_matching.term_".($this->object->get_matchingpair_count()-1)."_" . $thispair->getTermId().".focus(); document.frm_matching.term_".($this->object->get_matchingpair_count()-1)."_" . $thispair->getTermId().".scrollIntoView(\"true\");"));
00242                         }
00243                         else
00244                         {
00245                                 $this->tpl->setVariable("CONTENT_BLOCK", sprintf($javascript, "document.frm_matching.title.focus();"));
00246                         }
00247                 }
00248                 else
00249                 {
00250                         switch ($this->ctrl->getCmd())
00251                         {
00252                                 case "addPair":
00253                                         $this->tpl->setVariable("CONTENT_BLOCK", sprintf($javascript, "document.frm_matching.term_".($this->object->get_matchingpair_count())."_" . $add_random_id.".focus(); document.frm_matching.term_".($this->object->get_matchingpair_count())."_" . $add_random_id.".scrollIntoView(\"true\");"));
00254                                         break;
00255                                 default:
00256                                         $this->tpl->setVariable("CONTENT_BLOCK", sprintf($javascript, "document.frm_matching.title.focus();"));
00257                                         break;
00258                         }
00259                 }
00260                 $this->tpl->parseCurrentBlock();
00261                 $this->tpl->setCurrentBlock("question_data");
00262                 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
00263                 $this->tpl->setVariable("TEXT_AUTHOR", $this->lng->txt("author"));
00264                 $this->tpl->setVariable("TEXT_COMMENT", $this->lng->txt("description"));
00265                 $this->tpl->setVariable("TEXT_QUESTION", $this->lng->txt("question"));
00266                 $this->tpl->setVariable("TEXT_SHUFFLE_ANSWERS", $this->lng->txt("shuffle_answers"));
00267                 $this->tpl->setVariable("TXT_SHUFFLE_TERMS", $this->lng->txt("matching_shuffle_terms"));
00268                 if ($this->object->get_matching_type() == MT_TERMS_DEFINITIONS)
00269                 {
00270                         $this->tpl->setVariable("TXT_YES", $this->lng->txt("matching_shuffle_terms_definitions"));
00271                         $this->tpl->setVariable("TXT_SHUFFLE_PICTURES", $this->lng->txt("matching_shuffle_definitions"));
00272                 }
00273                 else
00274                 {
00275                         $this->tpl->setVariable("TXT_YES", $this->lng->txt("matching_shuffle_terms_pictures"));
00276                         $this->tpl->setVariable("TXT_SHUFFLE_PICTURES", $this->lng->txt("matching_shuffle_pictures"));
00277                 }
00278                 $this->tpl->setVariable("TXT_NO", $this->lng->txt("no"));
00279                 switch ($this->object->getShuffle())
00280                 {
00281                         case 1:
00282                                 $this->tpl->setVariable("SELECTED_YES", " selected=\"selected\"");
00283                                 break;
00284                         case 2:
00285                                 $this->tpl->setVariable("SELECTED_SHUFFLE_TERMS", " selected=\"selected\"");
00286                                 break;
00287                         case 3:
00288                                 $this->tpl->setVariable("SELECTED_SHUFFLE_PICTURES", " selected=\"selected\"");
00289                                 break;
00290                         default:
00291                                 $this->tpl->setVariable("SELECTED_NO", " selected=\"selected\"");
00292                                 break;
00293                 }
00294                 $this->tpl->setVariable("MATCHING_ID", $this->object->getId());
00295                 $this->tpl->setVariable("VALUE_MATCHING_TITLE", ilUtil::prepareFormOutput($this->object->getTitle()));
00296                 $this->tpl->setVariable("VALUE_MATCHING_COMMENT", ilUtil::prepareFormOutput($this->object->getComment()));
00297                 $this->tpl->setVariable("VALUE_MATCHING_AUTHOR", ilUtil::prepareFormOutput($this->object->getAuthor()));
00298                 $questiontext = $this->object->getQuestion();
00299                 $this->tpl->setVariable("VALUE_QUESTION", ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($questiontext)));
00300                 $this->tpl->setVariable("VALUE_ADD_ANSWER", $this->lng->txt("add_matching_pair"));
00301                 $this->tpl->setVariable("TEXT_TYPE", $this->lng->txt("type"));
00302                 $this->tpl->setVariable("TEXT_TYPE_TERMS_PICTURES", $this->lng->txt("match_terms_and_pictures"));
00303                 $this->tpl->setVariable("TEXT_TYPE_TERMS_DEFINITIONS", $this->lng->txt("match_terms_and_definitions"));
00304                 if ($this->object->get_matching_type() == MT_TERMS_DEFINITIONS)
00305                 {
00306                         $this->tpl->setVariable("SELECTED_DEFINITIONS", " selected=\"selected\"");
00307                 }
00308                 elseif ($this->object->get_matching_type() == MT_TERMS_PICTURES)
00309                 {
00310                         $this->tpl->setVariable("SELECTED_PICTURES", " selected=\"selected\"");
00311                 }
00312                 $this->tpl->setVariable("TEXT_SOLUTION_HINT", $this->lng->txt("solution_hint"));
00313                 if (count($this->object->suggested_solutions))
00314                 {
00315                         $solution_array = $this->object->getSuggestedSolution(0);
00316                         include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
00317                         $href = assQuestion::_getInternalLinkHref($solution_array["internal_link"]);
00318                         $this->tpl->setVariable("TEXT_VALUE_SOLUTION_HINT", " <a href=\"$href\" target=\"content\">" . $this->lng->txt("solution_hint"). "</a> ");
00319                         $this->tpl->setVariable("BUTTON_REMOVE_SOLUTION", $this->lng->txt("remove"));
00320                         $this->tpl->setVariable("BUTTON_ADD_SOLUTION", $this->lng->txt("change"));
00321                         $this->tpl->setVariable("VALUE_SOLUTION_HINT", $solution_array["internal_link"]);
00322                 }
00323                 else
00324                 {
00325                         $this->tpl->setVariable("BUTTON_ADD_SOLUTION", $this->lng->txt("add"));
00326                 }
00327                 $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
00328                 $this->tpl->setVariable("SET_EDIT_MODE", $this->lng->txt("set_edit_mode"));
00329                 $this->tpl->setVariable("SAVE_EDIT", $this->lng->txt("save_edit"));
00330                 $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
00331                 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00332                 $this->ctrl->setParameter($this, "sel_question_types", "assMatchingQuestion");
00333                 $this->tpl->setVariable("TEXT_QUESTION_TYPE", $this->lng->txt("assMatchingQuestion"));
00334                 $this->tpl->setVariable("ACTION_MATCHING_QUESTION",     $this->ctrl->getFormAction($this));
00335 
00336                 $this->tpl->parseCurrentBlock();
00337                 if ($this->error)
00338                 {
00339                         ilUtil::sendInfo($this->error);
00340                 }
00341                 include_once "./Services/RTE/classes/class.ilRTE.php";
00342                 $rtestring = ilRTE::_getRTEClassname();
00343                 include_once "./Services/RTE/classes/class.$rtestring.php";
00344                 $rte = new $rtestring();
00345                 $rte->addPlugin("latex");
00346                 $rte->addButton("latex"); $rte->addButton("pastelatex");
00347                 include_once "./classes/class.ilObject.php";
00348                 $obj_id = $_GET["q_id"];
00349                 $obj_type = ilObject::_lookupType($_GET["ref_id"], TRUE);
00350                 $rte->addRTESupport($obj_id, $obj_type, "assessment");
00351                 $this->tpl->setCurrentBlock("adm_content");
00352                 //$this->tpl->setVariable("BODY_ATTRIBUTES", " onload=\"initialSelect();\""); 
00353                 $this->tpl->parseCurrentBlock();
00354         }
00355 
00359         function addPair()
00360         {
00361                 $result = $this->writePostData();
00362                 $this->editQuestion($result);
00363         }
00364 
00368         function upload()
00369         {
00370                 $this->writePostData();
00371                 $this->editQuestion();
00372         }
00373 
00374 
00378         function delete()
00379         {
00380                 $this->writePostData();
00381                 if (is_array($_POST["chb_answer"]))
00382                 {
00383                         $deleteanswers = $_POST["chb_answer"];
00384                         rsort($deleteanswers);
00385                         foreach ($deleteanswers as $value)
00386                         {
00387                                 $this->object->delete_matchingpair($value);
00388                         }
00389                 }
00390                 $this->editQuestion(0, true);
00391         }
00392 
00401         function writePostData()
00402         {
00403                 $saved = false;
00404                 $result = 0;
00405 
00406                 if (!$this->checkInput())
00407                 {
00408                         $result = 1;
00409                 }
00410 
00411                 if (($result) and ($_POST["cmd"]["addPair"]))
00412                 {
00413                         // You cannot add matching pairs before you enter the required data
00414                         $this->error .= $this->lng->txt("fill_out_all_required_fields_add_matching") . "<br />";
00415                 }
00416 
00417                 $this->object->setTitle(ilUtil::stripSlashes($_POST["title"]));
00418                 $this->object->setAuthor(ilUtil::stripSlashes($_POST["author"]));
00419                 $this->object->setComment(ilUtil::stripSlashes($_POST["comment"]));
00420                 include_once "./classes/class.ilObjAdvancedEditing.php";
00421                 $questiontext = ilUtil::stripSlashes($_POST["question"], false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment"));
00422                 $this->object->setQuestion($questiontext);
00423                 $this->object->setSuggestedSolution($_POST["solution_hint"], 0);
00424                 $this->object->setShuffle($_POST["shuffle"]);
00425                 // adding estimated working time
00426                 $saved = $saved | $this->writeOtherPostData($result);
00427                 $this->object->setMatchingType($_POST["matching_type"]);
00428                 //$this->object->setMultilineAnswerSetting($_POST["multilineAnswers"]);
00429 
00430                 // Delete all existing answers and create new answers from the form data
00431                 $this->object->flush_matchingpairs();
00432                 $saved = false;
00433 
00434                 // Add all answers from the form into the object
00435                 $postvalues = $_POST;
00436                 foreach ($postvalues as $key => $value)
00437                 {
00438                         $matching_text = "";
00439                         if (preg_match("/term_(\d+)_(\d+)/", $key, $matches))
00440                         {
00441                                 // find out random id for term
00442                                 foreach ($_POST as $key2 => $value2)
00443                                 {
00444                                         if (preg_match("/(definition|picture)_$matches[1]_(\d+)/", $key2, $matches2))
00445                                         {
00446                                                 $matchingtext_id = $matches2[2];
00447                                                 if (strcmp($matches2[1], "definition") == 0)
00448                                                 {
00449                                                         $matching_text = $_POST["definition_$matches[1]_$matches2[2]"];
00450                                                 }
00451                                                 else
00452                                                 {
00453                                                         $matching_text = $_POST["picture_$matches[1]_$matches2[2]"];
00454                                                 }
00455                                         }
00456                                 }
00457                                 
00458                                 // save picture file if matching terms and pictures
00459                                 if ($this->object->get_matching_type() == MT_TERMS_PICTURES)
00460                                 {
00461                                         foreach ($_FILES as $key2 => $value2)
00462                                         {
00463                                                 if (preg_match("/picture_$matches[1]_(\d+)/", $key2, $matches2))
00464                                                 {
00465                                                         if ($value2["tmp_name"])
00466                                                         {
00467                                                                 // upload the matching picture
00468                                                                 if ($this->object->getId() <= 0)
00469                                                                 {
00470                                                                         $this->object->saveToDb();
00471                                                                         $saved = true;
00472                                                                         $this->error .= $this->lng->txt("question_saved_for_upload") . "<br />";
00473                                                                 }
00474                                                                 $value2['name'] = $this->object->createNewImageFileName($value2['name']);
00475                                                                 $upload_result = $this->object->setImageFile($value2['name'], $value2['tmp_name']);
00476                                                                 switch ($upload_result)
00477                                                                 {
00478                                                                         case 0:
00479                                                                                 $_POST["picture_$matches[1]_".$matches2[1]] = $value2['name'];
00480                                                                                 $matching_text = $value2['name'];
00481                                                                                 break;
00482                                                                         case 1:
00483                                                                                 $this->error .= $this->lng->txt("error_image_upload_wrong_format") . "<br />";
00484                                                                                 break;
00485                                                                         case 2:
00486                                                                                 $this->error .= $this->lng->txt("error_image_upload_copy_file") . "<br />";
00487                                                                                 break;
00488                                                                 }
00489                                                         }
00490                                                 }
00491                                         }
00492                                 }
00493                                 $points = $_POST["points_$matches[1]"];
00494                                 if ($points < 0)
00495                                 {
00496                                         $result = 1;
00497                                         $this->setErrorMessage($this->lng->txt("negative_points_not_allowed"));
00498                                 }
00499                                 $this->object->add_matchingpair(
00500                                         ilUtil::stripSlashes($_POST["$key"]),
00501                                         ilUtil::stripSlashes($matching_text),
00502                                         ilUtil::stripSlashes($points),
00503                                         ilUtil::stripSlashes($matches[2]),
00504                                         ilUtil::stripSlashes($matchingtext_id)
00505                                 );
00506                         }
00507                 }
00508 
00509                 if ($saved)
00510                 {
00511                         // If the question was saved automatically before an upload, we have to make
00512                         // sure, that the state after the upload is saved. Otherwise the user could be
00513                         // irritated, if he presses cancel, because he only has the question state before
00514                         // the upload process.
00515                         $this->object->saveToDb();
00516                         $this->ctrl->setParameter($this, "q_id", $this->object->getId());
00517                 }
00518                 return $result;
00519         }
00520 
00521         function outQuestionForTest($formaction, $active_id, $pass = NULL, $is_postponed = FALSE, $user_post_solution = FALSE)
00522         {
00523                 $test_output = $this->getTestOutput($active_id, $pass, $is_postponed, $user_post_solution); 
00524                 $this->tpl->setVariable("QUESTION_OUTPUT", $test_output);
00525                 if ($this->object->getOutputType() == OUTPUT_JAVASCRIPT)
00526                 {
00527                         $this->tpl->setVariable("BODY_ATTRIBUTES", " onload=\"setDragelementPositions();show_solution();\"");
00528                 }
00529                 $this->tpl->setVariable("FORMACTION", $formaction);
00530         }
00531 
00532         function getSolutionOutput($active_id, $pass = NULL, $graphicalOutput = FALSE, $result_output = FALSE, $show_question_only = TRUE, $show_feedback = FALSE)
00533         {
00534                 // generate the question output
00535                 include_once "./classes/class.ilTemplate.php";
00536                 $template = new ilTemplate("tpl.il_as_qpl_matching_output_solution.html", TRUE, TRUE, "Modules/TestQuestionPool");
00537                 $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html",TRUE, TRUE, "Modules/TestQuestionPool");
00538                 
00539                 $keys = array_keys($this->object->matchingpairs);
00540 
00541                 $solutions = array();
00542                 if ($active_id)
00543                 {
00544                         include_once "./Modules/Test/classes/class.ilObjTest.php";
00545                         $solutions =& $this->object->getSolutionValues($active_id, $pass);
00546                         $solution_script .= "";
00547                 }
00548                 else
00549                 {
00550                         foreach ($this->object->matchingpairs as $pair)
00551                         {
00552                                 array_push($solutions, array("value1" => $pair->getTermId(), "value2" => $pair->getDefinitionId()));
00553                         }
00554                 }
00555                 foreach ($keys as $idx)
00556                 {
00557                         $answer = $this->object->matchingpairs[$idx];
00558                         if ($active_id)
00559                         {
00560                                 if ($graphicalOutput)
00561                                 {
00562                                         // output of ok/not ok icons for user entered solutions
00563                                         $ok = FALSE;
00564                                         foreach ($solutions as $solution)
00565                                         {
00566                                                 if ($answer->getDefinitionId() == $solution["value2"])
00567                                                 {
00568                                                         if ($answer->getTermId() == $solution["value1"])
00569                                                         {
00570                                                                 $ok = TRUE;
00571                                                         }
00572                                                 }
00573                                         }
00574                                         if ($ok)
00575                                         {
00576                                                 $template->setCurrentBlock("icon_ok");
00577                                                 $template->setVariable("ICON_OK", ilUtil::getImagePath("icon_ok.gif"));
00578                                                 $template->setVariable("TEXT_OK", $this->lng->txt("answer_is_right"));
00579                                                 $template->parseCurrentBlock();
00580                                         }
00581                                         else
00582                                         {
00583                                                 $template->setCurrentBlock("icon_ok");
00584                                                 $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_not_ok.gif"));
00585                                                 $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_wrong"));
00586                                                 $template->parseCurrentBlock();
00587                                         }
00588                                 }
00589                         }
00590 
00591                         if ($this->object->get_matching_type() == MT_TERMS_PICTURES)
00592                         {
00593                                 $template->setCurrentBlock("standard_matching_pictures");
00594                                 $template->setVariable("DEFINITION_ID", $answer->getPictureId());
00595                                 $size = getimagesize($this->object->getImagePath() . $answer->getPicture()  . ".thumb.jpg");
00596                                 $template->setVariable("THUMBNAIL_WIDTH", $size[0]);
00597                                 $template->setVariable("THUMBNAIL_HEIGHT", $size[1]);
00598                                 $template->setVariable("THUMBNAIL_HREF", $this->object->getImagePathWeb() . $answer->getPicture() . ".thumb.jpg");
00599                                 $template->setVariable("THUMB_ALT", $this->lng->txt("image"));
00600                                 $template->setVariable("THUMB_TITLE", $this->lng->txt("image"));
00601                                 $template->parseCurrentBlock();
00602                         }
00603                         else
00604                         {
00605                                 $template->setCurrentBlock("standard_matching_terms");
00606                                 $template->setVariable("DEFINITION", $this->object->prepareTextareaOutput($answer->getDefinition(), TRUE));
00607                                 $template->parseCurrentBlock();
00608                         }
00609 
00610                         $template->setCurrentBlock("standard_matching_row");
00611                         $template->setVariable("MATCHES", $this->lng->txt("matches"));
00612                         if ($result_output)
00613                         {
00614                                 $points = $answer->getPoints();
00615                                 $resulttext = ($points == 1) ? "(%s " . $this->lng->txt("point") . ")" : "(%s " . $this->lng->txt("points") . ")"; 
00616                                 $template->setVariable("RESULT_OUTPUT", sprintf($resulttext, $points));
00617                         }
00618                         $hasoutput = FALSE;
00619                         foreach ($solutions as $solution)
00620                         {
00621                                 if ($answer->getDefinitionId() == $solution["value2"])
00622                                 {
00623                                         foreach ($this->object->matchingpairs as $pair)
00624                                         {
00625                                                 if ($pair->getTermId() == $solution["value1"])
00626                                                 {
00627                                                         $template->setVariable("SOLUTION", ilUtil::prepareFormOutput($pair->getTerm()));
00628                                                         $hasoutput = TRUE;
00629                                                 }
00630                                         }
00631                                 }
00632                         }
00633                         if (!$hasoutput)
00634                         {
00635                                 $template->setVariable("SOLUTION", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
00636                         }
00637                         $template->parseCurrentBlock();
00638                 }
00639                 
00640                 $questiontext = $this->object->getQuestion();
00641                 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
00642                 $questionoutput = $template->get();
00643                 $feedback = ($show_feedback) ? $this->getAnswerFeedbackOutput($active_id, $pass) : "";
00644                 if (strlen($feedback)) $solutiontemplate->setVariable("FEEDBACK", $feedback);
00645                 $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
00646 
00647                 $solutionoutput = $solutiontemplate->get(); 
00648                 if (!$show_question_only)
00649                 {
00650                         // get page object output
00651                         $pageoutput = $this->getILIASPage();
00652                         $solutionoutput = "<div class=\"ilias_content\">" . preg_replace("/(<div( xmlns:xhtml\=\"http:\/\/www.w3.org\/1999\/xhtml\"){0,1} class\=\"ilc_Question\"><\/div>)/ims", "</div><div class=\"ilc_Question\">" . $solutionoutput . "</div><div class=\"ilias_content\">", $pageoutput) . "</div>";
00653                 }
00654                 return $solutionoutput;
00655         }
00656         
00657         function getPreview($show_question_only = FALSE)
00658         {
00659                 // generate the question output
00660                 include_once "./classes/class.ilTemplate.php";
00661                 $template = new ilTemplate("tpl.il_as_qpl_matching_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
00662                 
00663                 // shuffle output
00664                 $keys = array_keys($this->object->matchingpairs);
00665                 $keys2 = $keys;
00666                 if ($this->object->getShuffle())
00667                 {
00668                         if (($this->object->getShuffle() == 3) || ($this->object->getShuffle() == 1))
00669                                 $keys = $this->object->pcArrayShuffle(array_keys($this->object->matchingpairs));
00670                         if (($this->object->getShuffle() == 2) || ($this->object->getShuffle() == 1))
00671                                 $keys2 = $this->object->pcArrayShuffle(array_keys($this->object->matchingpairs));
00672                 }
00673 
00674                 foreach ($keys as $idx)
00675                 {
00676                         $answer = $this->object->matchingpairs[$idx];
00677                         foreach ($keys2 as $comboidx)
00678                         {
00679                                 $comboanswer = $this->object->matchingpairs[$comboidx];
00680                                 $template->setCurrentBlock("matching_selection");
00681                                 $template->setVariable("VALUE_SELECTION", $comboanswer->getTermId());
00682                                 $template->setVariable("TEXT_SELECTION", ilUtil::prepareFormOutput($comboanswer->getTerm()));
00683                                 $template->parseCurrentBlock();
00684                         }
00685                         if ($this->object->get_matching_type() == MT_TERMS_PICTURES)
00686                         {
00687                                 $template->setCurrentBlock("standard_matching_pictures");
00688                                 $template->setVariable("DEFINITION_ID", $answer->getPictureId());
00689                                 $template->setVariable("IMAGE_HREF", $this->object->getImagePathWeb() . $answer->getPicture());
00690                                 $template->setVariable("THUMBNAIL_HREF", $this->object->getImagePathWeb() . $answer->getPicture() . ".thumb.jpg");
00691                                 $template->setVariable("THUMB_ALT", $this->lng->txt("image"));
00692                                 $template->setVariable("THUMB_TITLE", $this->lng->txt("image"));
00693                                 $template->parseCurrentBlock();
00694                         }
00695                         else
00696                         {
00697                                 $template->setCurrentBlock("standard_matching_terms");
00698                                 $template->setVariable("DEFINITION", $this->object->prepareTextareaOutput($answer->getDefinition(), TRUE));
00699                                 $template->parseCurrentBlock();
00700                         }
00701 
00702                         $template->setCurrentBlock("standard_matching_row");
00703                         $template->setVariable("MATCHES", $this->lng->txt("matches"));
00704                         $template->setVariable("DEFINITION_ID", $answer->getDefinitionId());
00705                         $template->setVariable("PLEASE_SELECT", $this->lng->txt("please_select"));
00706                         $template->parseCurrentBlock();
00707                 }
00708                 
00709                 $questiontext = $this->object->getQuestion();
00710                 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
00711                 $questionoutput = $template->get();
00712                 if (!$show_question_only)
00713                 {
00714                         // get page object output
00715                         $pageoutput = $this->getILIASPage();
00716                         $questionoutput = preg_replace("/(<div( xmlns:xhtml\=\"http:\/\/www.w3.org\/1999\/xhtml\"){0,1} class\=\"ilc_Question\"><\/div>)/ims", $questionoutput, $pageoutput);
00717                 }
00718                 else
00719                 {
00720                         $questionoutput = preg_replace("/<div[^>]*?>(.*)<\/div>/is", "\\1", $questionoutput);
00721                 }
00722 
00723                 return $questionoutput;
00724         }
00725 
00726         function getTestOutput($active_id, $pass = NULL, $is_postponed = FALSE, $user_post_solution = FALSE)
00727         {
00728                 // get page object output
00729                 $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id);
00730 
00731                 // generate the question output
00732                 include_once "./classes/class.ilTemplate.php";
00733                 $template = new ilTemplate("tpl.il_as_qpl_matching_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
00734                 
00735                 // shuffle output
00736                 $keys = array_keys($this->object->matchingpairs);
00737                 $keys2 = $keys;
00738                 if (is_array($user_post_solution))
00739                 {
00740                         $keys = $_SESSION["matching_keys"];
00741                         $keys2 = $_SESSION["matching_keys2"];
00742                 }
00743                 else
00744                 {
00745                         if ($this->object->getShuffle())
00746                         {
00747                                 if (($this->object->getShuffle() == 3) || ($this->object->getShuffle() == 1))
00748                                         $keys = $this->object->pcArrayShuffle(array_keys($this->object->matchingpairs));
00749                                 if (($this->object->getShuffle() == 2) || ($this->object->getShuffle() == 1))
00750                                         $keys2 = $this->object->pcArrayShuffle(array_keys($this->object->matchingpairs));
00751                         }
00752                 }
00753                 $_SESSION["matching_keys"] = $keys;
00754                 $_SESSION["matching_keys2"] = $keys2;
00755 
00756                 if ($active_id)
00757                 {
00758                         $solutions = NULL;
00759                         include_once "./Modules/Test/classes/class.ilObjTest.php";
00760                         if (!ilObjTest::_getUsePreviousAnswers($active_id, true))
00761                         {
00762                                 if (is_null($pass)) $pass = ilObjTest::_getPass($active_id);
00763                         }
00764                         if (is_array($user_post_solution)) 
00765                         { 
00766                                 $solutions = array();
00767                                 foreach ($user_post_solution as $key => $value)
00768                                 {
00769                                         if (preg_match("/sel_matching_(\d+)/", $key, $matches))
00770                                         {
00771                                                 array_push($solutions, array("value1" => $value, "value2" => $matches[1]));
00772                                         }
00773                                 }
00774                         }
00775                         else
00776                         { 
00777                                 $solutions =& $this->object->getSolutionValues($active_id, $pass);
00778                         }
00779                         $solution_script .= "";
00780                         foreach ($solutions as $idx => $solution_value)
00781                         {
00782                                 if ($this->object->getOutputType() == OUTPUT_JAVASCRIPT)
00783                                 {
00784                                         if (($solution_value["value2"] > 1) && ($solution_value["value1"] > 1))
00785                                         {
00786                                                 $solution_script .= "addSolution(" . $solution_value["value1"] . "," . $solution_value["value2"] . ");\n";
00787                                         }
00788                                 }
00789                         }
00790                 }
00791                 if ($this->object->getOutputType() == OUTPUT_JAVASCRIPT)
00792                 {
00793                         foreach ($keys as $idx)
00794                         {
00795                                 $answer = $this->object->matchingpairs[$idx];
00796                                 $template->setCurrentBlock("dragelements");
00797                                 $template->setVariable("DRAGELEMENT", $answer->getDefinitionId());
00798                                 $template->parseCurrentBlock();
00799                                 $template->setCurrentBlock("dropzones");
00800                                 $template->setVariable("DROPZONE", $answer->getTermId());
00801                                 $template->parseCurrentBlock();
00802                                 $template->setCurrentBlock("hidden_values");
00803                                 $template->setVariable("MATCHING_ID", $answer->getDefinitionId());
00804                                 $template->parseCurrentBlock();
00805                         }
00806 
00807                         foreach ($keys as $arrayindex => $idx)
00808                         {
00809                                 $answer = $this->object->matchingpairs[$idx];
00810                                 if ($this->object->get_matching_type() == MT_TERMS_PICTURES)
00811                                 {
00812                                         $template->setCurrentBlock("matching_pictures");
00813                                         $template->setVariable("DEFINITION_ID", $answer->getPictureId());
00814                                         $template->setVariable("IMAGE_HREF", $this->object->getImagePathWeb() . $answer->getPicture());
00815                                         $template->setVariable("THUMBNAIL_HREF", $this->object->getImagePathWeb() . $answer->getPicture() . ".thumb.jpg");
00816                                         $template->setVariable("THUMB_ALT", $this->lng->txt("image"));
00817                                         $template->setVariable("THUMB_TITLE", $this->lng->txt("image"));
00818                                         $template->setVariable("ENLARGE_HREF", ilUtil::getImagePath("enlarge.gif", false));
00819                                         $template->setVariable("ENLARGE_ALT", $this->lng->txt("enlarge"));
00820                                         $template->setVariable("ENLARGE_TITLE", $this->lng->txt("enlarge"));
00821                                         $template->parseCurrentBlock();
00822                                 }
00823                                 else
00824                                 {
00825                                         $template->setCurrentBlock("matching_terms");
00826                                         $template->setVariable("DEFINITION_ID", $answer->getDefinitionId());
00827                                         $template->setVariable("DEFINITION_TEXT", $this->object->prepareTextareaOutput($answer->getDefinition(), TRUE));
00828                                         $template->parseCurrentBlock();
00829                                 }
00830                                 $template->setCurrentBlock("javascript_matching_row");
00831                                 $template->setVariable("MATCHES", $this->lng->txt("matches"));
00832                                 $shuffledTerm = $this->object->matchingpairs[$keys2[$arrayindex]];
00833                                 $template->setVariable("DROPZONE_ID", $shuffledTerm->getTermId());
00834                                 $template->setVariable("TERM_ID", $shuffledTerm->getTermId());
00835                                 $template->setVariable("TERM_TEXT", $shuffledTerm->getTerm());
00836                                 $template->parseCurrentBlock();
00837                         }
00838                         
00839                         if ($this->object->get_matching_type() == MT_TERMS_PICTURES)
00840                         {
00841                                 $template->setVariable("RESET_TEXT", $this->lng->txt("reset_pictures"));
00842                         }
00843                         else
00844                         {
00845                                 $template->setVariable("RESET_TEXT", $this->lng->txt("reset_definitions"));
00846                         }
00847                         $template->setVariable("JAVASCRIPT_HINT", $this->lng->txt("matching_question_javascript_hint"));
00848                         $template->setVariable("SHOW_SOLUTIONS", "<script type=\"text/javascript\">\nfunction show_solution() {\n$solution_script\n}\n</script>\n");
00849                 }
00850                 else
00851                 {
00852                         foreach ($keys as $idx)
00853                         {
00854                                 $answer = $this->object->matchingpairs[$idx];
00855                                 foreach ($keys2 as $comboidx)
00856                                 {
00857                                         $comboanswer = $this->object->matchingpairs[$comboidx];
00858                                         $template->setCurrentBlock("matching_selection");
00859                                         $template->setVariable("VALUE_SELECTION", $comboanswer->getTermId());
00860                                         $template->setVariable("TEXT_SELECTION", ilUtil::prepareFormOutput($comboanswer->getTerm()));
00861                                         foreach ($solutions as $solution)
00862                                         {
00863                                                 if (($comboanswer->getTermId() == $solution["value1"]) && ($answer->getDefinitionId() == $solution["value2"]))
00864                                                 {
00865                                                         $template->setVariable("SELECTED_SELECTION", " selected=\"selected\"");
00866                                                 }
00867                                         }
00868                                         $template->parseCurrentBlock();
00869                                 }
00870                                 if ($this->object->get_matching_type() == MT_TERMS_PICTURES)
00871                                 {
00872                                         $template->setCurrentBlock("standard_matching_pictures");
00873                                         $template->setVariable("DEFINITION_ID", $answer->getPictureId());
00874                                         $template->setVariable("IMAGE_HREF", $this->object->getImagePathWeb() . $answer->getPicture());
00875                                         $template->setVariable("THUMBNAIL_HREF", $this->object->getImagePathWeb() . $answer->getPicture() . ".thumb.jpg");
00876                                         $template->setVariable("THUMB_ALT", $this->lng->txt("image"));
00877                                         $template->setVariable("THUMB_TITLE", $this->lng->txt("image"));
00878                                         $template->parseCurrentBlock();
00879                                 }
00880                                 else
00881                                 {
00882                                         $template->setCurrentBlock("standard_matching_terms");
00883                                         $template->setVariable("DEFINITION", $this->object->prepareTextareaOutput($answer->getDefinition(), TRUE));
00884                                         $template->parseCurrentBlock();
00885                                 }
00886 
00887                                 $template->setCurrentBlock("standard_matching_row");
00888                                 $template->setVariable("MATCHES", $this->lng->txt("matches"));
00889                                 $template->setVariable("DEFINITION_ID", $answer->getDefinitionId());
00890                                 $template->setVariable("PLEASE_SELECT", $this->lng->txt("please_select"));
00891                                 $template->parseCurrentBlock();
00892                         }
00893                 }
00894                 
00895                 $questiontext = $this->object->getQuestion();
00896                 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
00897                 $questionoutput = $template->get();
00898                 $questionoutput = preg_replace("/(<div( xmlns:xhtml\=\"http:\/\/www.w3.org\/1999\/xhtml\"){0,1} class\=\"ilc_Question\"><\/div>)/ims", $questionoutput, $pageoutput);
00899                 return $questionoutput;
00900         }
00901 
00905         function checkInput()
00906         {
00907                 if ((!$_POST["title"]) or (!$_POST["author"]) or (!$_POST["question"]))
00908                 {
00909                         return false;
00910                 }
00911                 return true;
00912         }
00913 
00914 
00915         function addSuggestedSolution()
00916         {
00917                 $_SESSION["subquestion_index"] = 0;
00918                 if ($_POST["cmd"]["addSuggestedSolution"])
00919                 {
00920                         if ($this->writePostData())
00921                         {
00922                                 ilUtil::sendInfo($this->getErrorMessage());
00923                                 $this->editQuestion();
00924                                 return;
00925                         }
00926                         if (!$this->checkInput())
00927                         {
00928                                 ilUtil::sendInfo($this->lng->txt("fill_out_all_required_fields_add_answer"));
00929                                 $this->editQuestion();
00930                                 return;
00931                         }
00932                 }
00933                 $this->object->saveToDb();
00934                 $this->ctrl->setParameter($this, "q_id", $this->object->getId());
00935                 $this->tpl->setVariable("HEADER", $this->object->getTitle());
00936                 $this->getQuestionTemplate();
00937                 parent::addSuggestedSolution();
00938         }       
00939 
00940         function editMode()
00941         {
00942                 global $ilUser;
00943                 
00944                 //$this->object->setMultilineAnswerSetting($_POST["multilineAnswers"]);
00945                 $this->object->setMatchingType($_POST["matching_type"]);
00946                 $this->writePostData();
00947                 $this->editQuestion();
00948         }
00949 
00957         function saveFeedback()
00958         {
00959                 include_once "./classes/class.ilObjAdvancedEditing.php";
00960                 $this->object->saveFeedbackGeneric(0, ilUtil::stripSlashes($_POST["feedback_incomplete"], false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment")));
00961                 $this->object->saveFeedbackGeneric(1, ilUtil::stripSlashes($_POST["feedback_complete"], false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment")));
00962                 $this->object->cleanupMediaObjectUsage();
00963                 parent::saveFeedback();
00964         }
00965 
00973         function feedback()
00974         {
00975                 $this->tpl->addBlockFile("ADM_CONTENT", "feedback", "tpl.il_as_qpl_matching_feedback.html", "Modules/TestQuestionPool");
00976                 $this->tpl->setVariable("FEEDBACK_TEXT", $this->lng->txt("feedback"));
00977                 $this->tpl->setVariable("FEEDBACK_COMPLETE", $this->lng->txt("feedback_complete_solution"));
00978                 $this->tpl->setVariable("VALUE_FEEDBACK_COMPLETE", ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(1)), FALSE));
00979                 $this->tpl->setVariable("FEEDBACK_INCOMPLETE", $this->lng->txt("feedback_incomplete_solution"));
00980                 $this->tpl->setVariable("VALUE_FEEDBACK_INCOMPLETE", ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(0)), FALSE));
00981                 $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
00982                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00983 
00984                 include_once "./Services/RTE/classes/class.ilRTE.php";
00985                 $rtestring = ilRTE::_getRTEClassname();
00986                 include_once "./Services/RTE/classes/class.$rtestring.php";
00987                 $rte = new $rtestring();
00988                 $rte->addPlugin("latex");
00989                 $rte->addButton("latex"); $rte->addButton("pastelatex");
00990                 include_once "./classes/class.ilObject.php";
00991                 $obj_id = $_GET["q_id"];
00992                 $obj_type = ilObject::_lookupType($_GET["ref_id"], TRUE);
00993                 $rte->addRTESupport($obj_id, $obj_type, "assessment");
00994         }
00995 
01003         function setQuestionTabs()
01004         {
01005                 global $rbacsystem, $ilTabs;
01006                 
01007                 $this->ctrl->setParameterByClass("ilpageobjectgui", "q_id", $_GET["q_id"]);
01008                 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
01009                 $q_type = $this->object->getQuestionType();
01010 
01011                 if (strlen($q_type))
01012                 {
01013                         $classname = $q_type . "GUI";
01014                         $this->ctrl->setParameterByClass(strtolower($classname), "sel_question_types", $q_type);
01015                         $this->ctrl->setParameterByClass(strtolower($classname), "q_id", $_GET["q_id"]);
01016                 }
01017 
01018                 if ($_GET["q_id"])
01019                 {
01020                         if ($rbacsystem->checkAccess('write', $_GET["ref_id"]))
01021                         {
01022                                 // edit page
01023                                 $ilTabs->addTarget("edit_content",
01024                                         $this->ctrl->getLinkTargetByClass("ilPageObjectGUI", "view"),
01025                                         array("view", "insert", "exec_pg"),
01026                                         "", "", $force_active);
01027                         }
01028         
01029                         // edit page
01030                         $ilTabs->addTarget("preview",
01031                                 $this->ctrl->getLinkTargetByClass("ilPageObjectGUI", "preview"),
01032                                 array("preview"),
01033                                 "ilPageObjectGUI", "", $force_active);
01034                 }
01035 
01036                 $force_active = false;
01037                 if ($rbacsystem->checkAccess('write', $_GET["ref_id"]))
01038                 {
01039                         $url = "";
01040                         if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname, "editQuestion");
01041                         // edit question properties
01042                         $ilTabs->addTarget("edit_properties",
01043                                 $url,
01044                                 array("editQuestion", "save", "cancel", "addSuggestedSolution",
01045                                         "cancelExplorer", "linkChilds", "removeSuggestedSolution",
01046                                         "addPair", "delete", "editMode", "upload",
01047                                         "saveEdit"),
01048                                 $classname, "", $force_active);
01049                 }
01050 
01051                 if ($_GET["q_id"])
01052                 {
01053                         $ilTabs->addTarget("feedback",
01054                                 $this->ctrl->getLinkTargetByClass($classname, "feedback"),
01055                                 array("feedback", "saveFeedback"),
01056                                 $classname, "");
01057                 }
01058                 
01059                 // Assessment of questions sub menu entry
01060                 if ($_GET["q_id"])
01061                 {
01062                         $ilTabs->addTarget("statistics",
01063                                 $this->ctrl->getLinkTargetByClass($classname, "assessment"),
01064                                 array("assessment"),
01065                                 $classname, "");
01066                 }
01067                 
01068                 if (($_GET["calling_test"] > 0) || ($_GET["test_ref_id"] > 0))
01069                 {
01070                         $ref_id = $_GET["calling_test"];
01071                         if (strlen($ref_id) == 0) $ref_id = $_GET["test_ref_id"];
01072                         $ilTabs->setBackTarget($this->lng->txt("backtocallingtest"), "ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
01073                 }
01074                 else
01075                 {
01076                         $ilTabs->setBackTarget($this->lng->txt("qpl"), $this->ctrl->getLinkTargetByClass("ilobjquestionpoolgui", "questions"));
01077                 }
01078         }
01079 }
01080 ?>

Generated on Fri Dec 13 2013 17:56:54 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1