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

Modules/TestQuestionPool/classes/class.assMultipleChoiceGUI.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 assMultipleChoiceGUI extends assQuestionGUI
00038 {
00039         var $choiceKeys;
00040         
00049         function assMultipleChoiceGUI(
00050                         $id = -1
00051         )
00052         {
00053                 $this->assQuestionGUI();
00054                 include_once "./Modules/TestQuestionPool/classes/class.assMultipleChoice.php";
00055                 $this->object = new assMultipleChoice();
00056                 if ($id >= 0)
00057                 {
00058                         $this->object->loadFromDb($id);
00059                 }
00060         }
00061 
00062         function getCommand($cmd)
00063         {
00064                 if (substr($cmd, 0, 6) == "upload")
00065                 {
00066                         $cmd = "upload";
00067                 }
00068                 if (substr($cmd, 0, 11) == "deleteImage")
00069                 {
00070                         $cmd = "deleteImage";
00071                 }
00072                 return $cmd;
00073         }
00074 
00082         function editQuestion()
00083         {
00084                 //$this->tpl->setVariable("HEADER", $this->object->getTitle());
00085                 
00086                 $this->tpl->addJavascript("./Services/JavaScript/js/Basic.js");
00087                 $javascript = "<script type=\"text/javascript\">ilAddOnLoad(initialSelect);\n".
00088                         "function initialSelect() {\n%s\n}</script>";
00089                 $graphical_answer_setting = $this->object->getGraphicalAnswerSetting();
00090                 $multiline_answers = $this->object->getMultilineAnswerSetting();
00091                 if ($graphical_answer_setting == 0)
00092                 {
00093                         for ($i = 0; $i < $this->object->getAnswerCount(); $i++)
00094                         {
00095                                 $answer = $this->object->getAnswer($i);
00096                                 if (strlen($answer->getImage())) $graphical_answer_setting = 1;
00097                         }
00098                 }
00099                 $this->getQuestionTemplate();
00100                 $this->tpl->addBlockFile("QUESTION_DATA", "question_data", "tpl.il_as_qpl_mc_mr.html", "Modules/TestQuestionPool");
00101 
00102                 if ($this->object->getAnswerCount() > 0)
00103                 {
00104                         $this->tpl->setCurrentBlock("answersheading");
00105                         $this->tpl->setVariable("TEXT_POINTS_CHECKED", $this->lng->txt("points_checked"));
00106                         $this->tpl->setVariable("TEXT_POINTS_UNCHECKED", $this->lng->txt("points_unchecked"));
00107                         $this->tpl->setVariable("TEXT_ANSWER_TEXT", $this->lng->txt("answer_text"));
00108                         $this->tpl->parseCurrentBlock();
00109                         $this->tpl->setCurrentBlock("selectall");
00110                         $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
00111                         $this->tpl->parseCurrentBlock();
00112                         $this->tpl->setCurrentBlock("existinganswers");
00113                         $this->tpl->setVariable("DELETE", $this->lng->txt("delete"));
00114                         $this->tpl->setVariable("MOVE", $this->lng->txt("move"));
00115                         $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\">");
00116                         $this->tpl->parseCurrentBlock();
00117                 }
00118                 for ($i = 0; $i < $this->object->getAnswerCount(); $i++)
00119                 {
00120                         $answer = $this->object->getAnswer($i);
00121                         if ($graphical_answer_setting == 1)
00122                         {
00123                                 $imagefilename = $this->object->getImagePath() . $answer->getImage();
00124                                 if (!@file_exists($imagefilename))
00125                                 {
00126                                         $answer->setImage("");
00127                                 }
00128                                 if (strlen($answer->getImage()))
00129                                 {
00130                                         $imagepath = $this->object->getImagePathWeb() . $answer->getImage();
00131                                         $this->tpl->setCurrentBlock("graphical_answer_image");
00132                                         $this->tpl->setVariable("IMAGE_FILE", $imagepath);
00133                                         if (strlen($answer->getAnswertext()))
00134                                         {
00135                                                 $this->tpl->setVariable("IMAGE_ALT", ilUtil::prepareFormOutput($answer->getAnswertext()));
00136                                         }
00137                                         else
00138                                         {
00139                                                 $this->tpl->setVariable("IMAGE_ALT", $this->lng->txt("image"));
00140                                         }
00141                                         $this->tpl->setVariable("ANSWER_ORDER", $answer->getOrder());
00142                                         $this->tpl->setVariable("DELETE_IMAGE", $this->lng->txt("delete_image"));
00143                                         $this->tpl->parseCurrentBlock();
00144                                 }
00145                                 $this->tpl->setCurrentBlock("graphical_answer");
00146                                 $this->tpl->setVariable("ANSWER_ORDER", $answer->getOrder());
00147                                 $this->tpl->setVariable("UPLOAD_IMAGE", $this->lng->txt("upload_image"));
00148                                 $this->tpl->setVariable("VALUE_IMAGE", $answer->getImage());
00149                                 $this->tpl->parseCurrentBlock();
00150                         }
00151                         if ($multiline_answers)
00152                         {
00153                                 $this->tpl->setCurrentBlock("show_textarea");
00154                                 $this->tpl->setVariable("ANSWER_ANSWER_ORDER", $answer->getOrder());
00155                                 $this->tpl->setVariable("VALUE_ANSWER", ilUtil::prepareFormOutput($answer->getAnswertext()));
00156                                 $this->tpl->parseCurrentBlock();
00157                         }
00158                         else
00159                         {
00160                                 $this->tpl->setCurrentBlock("show_textinput");
00161                                 $this->tpl->setVariable("ANSWER_ANSWER_ORDER", $answer->getOrder());
00162                                 $this->tpl->setVariable("VALUE_ANSWER", ilUtil::prepareFormOutput($answer->getAnswertext()));
00163                                 $this->tpl->parseCurrentBlock();
00164                         }
00165                         $this->tpl->setCurrentBlock("answers");
00166                         $this->tpl->setVariable("VALUE_MULTIPLE_CHOICE_POINTS_CHECKED", $answer->getPoints());
00167                         $this->tpl->setVariable("VALUE_MULTIPLE_CHOICE_POINTS_UNCHECKED", $answer->getPointsUnchecked());
00168                         $this->tpl->setVariable("ANSWER_ORDER", $answer->getOrder());
00169                         $this->tpl->parseCurrentBlock();
00170                 }
00171 
00172                 // call to other question data i.e. estimated working time block
00173                 $this->outOtherQuestionData();
00174 
00175                 $internallinks = array(
00176                         "lm" => $this->lng->txt("obj_lm"),
00177                         "st" => $this->lng->txt("obj_st"),
00178                         "pg" => $this->lng->txt("obj_pg"),
00179                         "glo" => $this->lng->txt("glossary_term")
00180                 );
00181                 foreach ($internallinks as $key => $value)
00182                 {
00183                         $this->tpl->setCurrentBlock("internallink");
00184                         $this->tpl->setVariable("TYPE_INTERNAL_LINK", $key);
00185                         $this->tpl->setVariable("TEXT_INTERNAL_LINK", $value);
00186                         $this->tpl->parseCurrentBlock();
00187                 }
00188                 
00189                 $this->tpl->setCurrentBlock("HeadContent");
00190 
00191                 if ($this->object->getAnswerCount() == 0)
00192                 {
00193                         $this->tpl->setVariable("CONTENT_BLOCK", sprintf($javascript, "document.frm_multiple_choice.title.focus();"));
00194                 }
00195                 else
00196                 {
00197                         switch ($this->ctrl->getCmd())
00198                         {
00199                                 case "add":
00200                                         $nrOfAnswers = $_POST["nrOfAnswers"];
00201                                         if ((strcmp($nrOfAnswers, "yn") == 0) || (strcmp($nrOfAnswers, "tf") == 0)) $nrOfAnswers = 2;
00202                                         $this->tpl->setVariable("CONTENT_BLOCK", sprintf($javascript, "document.frm_multiple_choice.answer_".($this->object->getAnswerCount() - $nrOfAnswers).".focus(); document.getElementById('answer_".($this->object->getAnswerCount() - $nrOfAnswers)."').scrollIntoView(\"true\");"));
00203                                         break;
00204                                 case "deleteAnswer":
00205                                         if ($this->object->getAnswerCount() == 0)
00206                                         {
00207                                                 $this->tpl->setVariable("CONTENT_BLOCK", sprintf($javascript, "document.frm_multiple_choice.title.focus();"));
00208                                         }
00209                                         else
00210                                         {
00211                                                 $this->tpl->setVariable("CONTENT_BLOCK", sprintf($javascript, "document.frm_multiple_choice.answer_".($this->object->getAnswerCount() - 1).".focus(); document.getElementById('answer_".($this->object->getAnswerCount() - 1)."').scrollIntoView(\"true\");"));
00212                                         }
00213                                         break;
00214                                 default:
00215                                         $this->tpl->setVariable("CONTENT_BLOCK", sprintf($javascript, "document.frm_multiple_choice.title.focus();"));
00216                                         break;
00217                         }
00218                 }
00219                 $this->tpl->parseCurrentBlock();
00220                 
00221                 for ($i = 1; $i < 10; $i++)
00222                 {
00223                         $this->tpl->setCurrentBlock("numbers");
00224                         $this->tpl->setVariable("VALUE_NUMBER", $i);
00225                         if ($i == 1)
00226                         {
00227                                 $this->tpl->setVariable("TEXT_NUMBER", $i . " " . $this->lng->txt("answer"));
00228                         }
00229                         else
00230                         {
00231                                 $this->tpl->setVariable("TEXT_NUMBER", $i . " " . $this->lng->txt("answers"));
00232                         }
00233                         $this->tpl->parseCurrentBlock();
00234                 }
00235                 
00236                 $this->tpl->setCurrentBlock("question_data");
00237                 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
00238                 $this->tpl->setVariable("TEXT_AUTHOR", $this->lng->txt("author"));
00239                 $this->tpl->setVariable("TEXT_COMMENT", $this->lng->txt("description"));
00240                 $this->tpl->setVariable("TEXT_QUESTION", $this->lng->txt("question"));
00241                 $this->tpl->setVariable("MULTIPLE_CHOICE_ID", $this->object->getId());
00242                 $this->tpl->setVariable("VALUE_MULTIPLE_CHOICE_TITLE", ilUtil::prepareFormOutput($this->object->getTitle()));
00243                 $this->tpl->setVariable("VALUE_MULTIPLE_CHOICE_COMMENT", ilUtil::prepareFormOutput($this->object->getComment()));
00244                 $this->tpl->setVariable("VALUE_MULTIPLE_CHOICE_AUTHOR", ilUtil::prepareFormOutput($this->object->getAuthor()));
00245                 $this->tpl->setVariable("TEXT_GRAPHICAL_ANSWERS", $this->lng->txt("graphical_answers"));
00246                 $this->tpl->setVariable("TEXT_HIDE_GRAPHICAL_ANSWER_SUPPORT", $this->lng->txt("graphical_answers_hide"));
00247                 $this->tpl->setVariable("TEXT_SHOW_GRAPHICAL_ANSWER_SUPPORT", $this->lng->txt("graphical_answers_show"));
00248                 if ($this->object->getGraphicalAnswerSetting() == 1)
00249                 {
00250                         $this->tpl->setVariable("SELECTED_SHOW_GRAPHICAL_ANSWER_SUPPORT", " selected=\"selected\"");
00251                 }
00252                 if ($multiline_answers)
00253                 {
00254                         $this->tpl->setVariable("SELECTED_SHOW_MULTILINE_ANSWERS", " selected=\"selected\"");
00255                 }
00256                 $this->tpl->setVariable("TEXT_HIDE_MULTILINE_ANSWERS", $this->lng->txt("multiline_answers_hide"));
00257                 $this->tpl->setVariable("TEXT_SHOW_MULTILINE_ANSWERS", $this->lng->txt("multiline_answers_show"));
00258                 $this->tpl->setVariable("SET_EDIT_MODE", $this->lng->txt("set_edit_mode"));
00259                 $questiontext = $this->object->getQuestion();
00260                 $this->tpl->setVariable("VALUE_QUESTION", ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($questiontext)));
00261                 $this->tpl->setVariable("VALUE_ADD_ANSWER", $this->lng->txt("add"));
00262                 $this->tpl->setVariable("TEXT_SHUFFLE_ANSWERS", $this->lng->txt("shuffle_answers"));
00263                 $this->tpl->setVariable("TXT_YES", $this->lng->txt("yes"));
00264                 $this->tpl->setVariable("TXT_NO", $this->lng->txt("no"));
00265                 if ($this->object->getShuffle())
00266                 {
00267                         $this->tpl->setVariable("SELECTED_YES", " selected=\"selected\"");
00268                 }
00269                 else
00270                 {
00271                         $this->tpl->setVariable("SELECTED_NO", " selected=\"selected\"");
00272                 }
00273                 $this->tpl->setVariable("TEXT_SOLUTION_HINT", $this->lng->txt("solution_hint"));
00274                 if (count($this->object->suggested_solutions))
00275                 {
00276                         $solution_array = $this->object->getSuggestedSolution(0);
00277                         include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
00278                         $href = assQuestion::_getInternalLinkHref($solution_array["internal_link"]);
00279                         $this->tpl->setVariable("TEXT_VALUE_SOLUTION_HINT", " <a href=\"$href\" target=\"content\">" . $this->lng->txt("solution_hint"). "</a> ");
00280                         $this->tpl->setVariable("BUTTON_REMOVE_SOLUTION", $this->lng->txt("remove"));
00281                         $this->tpl->setVariable("BUTTON_ADD_SOLUTION", $this->lng->txt("change"));
00282                         $this->tpl->setVariable("VALUE_SOLUTION_HINT", $solution_array["internal_link"]);
00283                 }
00284                 else
00285                 {
00286                         $this->tpl->setVariable("BUTTON_ADD_SOLUTION", $this->lng->txt("add"));
00287                 }
00288                 $this->tpl->setVariable("SAVE",$this->lng->txt("save"));
00289                 $this->tpl->setVariable("SAVE_EDIT", $this->lng->txt("save_edit"));
00290                 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00291                 $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
00292                 $this->ctrl->setParameter($this, "sel_question_types", "assMultipleChoice");
00293                 $this->tpl->setVariable("ACTION_MULTIPLE_CHOICE_TEST", $this->ctrl->getFormAction($this));
00294                 $this->tpl->setVariable("TEXT_QUESTION_TYPE", $this->lng->txt("assMultipleChoice"));
00295                 $this->tpl->parseCurrentBlock();
00296 
00297                 include_once "./Services/RTE/classes/class.ilRTE.php";
00298                 $rtestring = ilRTE::_getRTEClassname();
00299                 include_once "./Services/RTE/classes/class.$rtestring.php";
00300                 $rte = new $rtestring();
00301                 $rte->addPlugin("latex");
00302                 $rte->addButton("latex"); $rte->addButton("pastelatex");
00303                 include_once "./classes/class.ilObject.php";
00304                 $obj_id = $_GET["q_id"];
00305                 $obj_type = ilObject::_lookupType($_GET["ref_id"], TRUE);
00306                 $rte->addRTESupport($obj_id, $obj_type, "assessment");
00307                 $this->tpl->setCurrentBlock("adm_content");
00308                 //$this->tpl->setVariable("BODY_ATTRIBUTES", " onload=\"initialSelect();\""); 
00309                 $this->tpl->parseCurrentBlock();
00310         }
00311 
00315         function add()
00316         {
00317                 //$this->setObjectData();
00318                 $this->writePostData();
00319 
00320                 if (!$this->checkInput())
00321                 {
00322                         ilUtil::sendInfo($this->lng->txt("fill_out_all_required_fields_add_answer"));
00323                 }
00324                 else
00325                 {
00326                         // add an answer template
00327                         $nrOfAnswers = $_POST["nrOfAnswers"];
00328                         switch ($nrOfAnswers)
00329                         {
00330                                 case "tf":
00331                                         // add a true/false answer template
00332                                         $this->object->addAnswer(
00333                                                 $this->lng->txt("true"),
00334                                                 0,
00335                                                 0,
00336                                                 count($this->object->answers),
00337                                                 ""
00338                                         );
00339                                         $this->object->addAnswer(
00340                                                 $this->lng->txt("false"),
00341                                                 0,
00342                                                 0,
00343                                                 count($this->object->answers),
00344                                                 ""
00345                                         );
00346                                         break;
00347                                 case "yn":
00348                                         // add a yes/no answer template
00349                                         $this->object->addAnswer(
00350                                                 $this->lng->txt("yes"),
00351                                                 0,
00352                                                 0,
00353                                                 count($this->object->answers),
00354                                                 ""
00355                                         );
00356                                         $this->object->addAnswer(
00357                                                 $this->lng->txt("no"),
00358                                                 0,
00359                                                 0,
00360                                                 count($this->object->answers),
00361                                                 ""
00362                                         );
00363                                         break;
00364                                 default:
00365                                         for ($i = 0; $i < $nrOfAnswers; $i++)
00366                                         {
00367                                                 $this->object->addAnswer(
00368                                                         $this->lng->txt(""),
00369                                                         0,
00370                                                         0,
00371                                                         count($this->object->answers),
00372                                                         ""
00373                                                 );
00374                                         }
00375                                         break;
00376                         }
00377                 }
00378 
00379                 $this->editQuestion();
00380         }
00381 
00385         function deleteAnswer()
00386         {
00387                 $this->writePostData();
00388                 $answers = $_POST["chb_answers"];
00389                 if (is_array($answers))
00390                 {
00391                         arsort($answers);
00392                         foreach ($answers as $answer)
00393                         {
00394                                 $this->object->deleteAnswer($answer);
00395                         }
00396                 }
00397                 $this->editQuestion();
00398         }
00399 
00403         function checkInput()
00404         {
00405                 $cmd = $this->ctrl->getCmd();
00406 
00407                 if ((!$_POST["title"]) or (!$_POST["author"]) or (!$_POST["question"]))
00408                 {
00409 //echo "<br>checkInput1:FALSE";
00410                         return false;
00411                 }
00412                 foreach ($_POST as $key => $value)
00413                 {
00414                         if (preg_match("/answer_(\d+)/", $key, $matches))
00415                         {
00416                                 if (strlen($value) == 0)
00417                                 {
00418                                         if (strlen($_POST["uploaded_image_".$matches[1]]) == 0)
00419                                         {
00420                                                 return false;
00421                                         }
00422                                 }
00423                         }
00424                 }
00425 
00426                 return true;
00427         }
00428 
00437         function writePostData()
00438         {
00439 //echo "here!"; exit;
00440 //echo "<br>assMultipleChoiceGUI->writePostData()";
00441                 $result = 0;
00442                 if ((!$_POST["title"]) or (!$_POST["author"]) or (!$_POST["question"]))
00443                 {
00444                         $result = 1;
00445                 }
00446 
00447                 if (($result) and (($_POST["cmd"]["add"]) or ($_POST["cmd"]["add_tf"]) or ($_POST["cmd"]["add_yn"])))
00448                 {
00449                         // You cannot add answers before you enter the required data
00450                         ilUtil::sendInfo($this->lng->txt("fill_out_all_required_fields_add_answer"));
00451                         $_POST["cmd"]["add"] = "";
00452                         $_POST["cmd"]["add_yn"] = "";
00453                         $_POST["cmd"]["add_tf"] = "";
00454                 }
00455 
00456                 // Check the creation of new answer text fields
00457                 if ($_POST["cmd"]["add"] or $_POST["cmd"]["add_yn"] or $_POST["cmd"]["add_tf"])
00458                 {
00459                         foreach ($_POST as $key => $value)
00460                         {
00461                                 if (preg_match("/answer_(\d+)/", $key, $matches))
00462                                 {
00463                                         if (!$value)
00464                                         {
00465                                                 $_POST["cmd"]["add"] = "";
00466                                                 $_POST["cmd"]["add_yn"] = "";
00467                                                 $_POST["cmd"]["add_tf"] = "";
00468                                                 ilUtil::sendInfo($this->lng->txt("fill_out_all_answer_fields"));
00469                                         }
00470                                 }
00471                         }
00472                 }
00473 
00474                 $this->object->setTitle(ilUtil::stripSlashes($_POST["title"]));
00475                 $this->object->setAuthor(ilUtil::stripSlashes($_POST["author"]));
00476                 $this->object->setComment(ilUtil::stripSlashes($_POST["comment"]));
00477                 include_once "./classes/class.ilObjAdvancedEditing.php";
00478                 $questiontext = ilUtil::stripSlashes($_POST["question"], false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment"));
00479                 $this->object->setQuestion($questiontext);
00480                 $this->object->setSuggestedSolution($_POST["solution_hint"], 0);
00481                 $this->object->setShuffle($_POST["shuffle"]);
00482 
00483                 $saved = $this->writeOtherPostData($result);
00484                 $this->object->setMultilineAnswerSetting($_POST["multilineAnswers"]);
00485                 $this->object->setGraphicalAnswerSetting($_POST["graphicalAnswerSupport"]);
00486 
00487                 // Delete all existing answers and create new answers from the form data
00488                 $this->object->flushAnswers();
00489                 $graphical_answer_setting = $this->object->getGraphicalAnswerSetting();
00490                 // Add all answers from the form into the object
00491                 foreach ($_POST as $key => $value)
00492                 {
00493                         if (preg_match("/answer_(\d+)/", $key, $matches))
00494                         {
00495                                 $answer_image = $_POST["uploaded_image_".$matches[1]];
00496                                 if ($graphical_answer_setting == 1)
00497                                 {
00498                                         foreach ($_FILES as $key2 => $value2)
00499                                         {
00500                                                 if (preg_match("/image_(\d+)/", $key2, $matches2))
00501                                                 {
00502                                                         if ($matches[1] == $matches2[1])
00503                                                         {
00504                                                                 if ($value2["tmp_name"])
00505                                                                 {
00506                                                                         // upload the image
00507                                                                         if ($this->object->getId() <= 0)
00508                                                                         {
00509                                                                                 $this->object->saveToDb();
00510                                                                                 $saved = true;
00511                                                                                 $this->error .= $this->lng->txt("question_saved_for_upload") . "<br />";
00512                                                                         }
00513                                                                         $value2['name'] = $this->object->createNewImageFileName($value2['name']);
00514                                                                         $upload_result = $this->object->setImageFile($value2['name'], $value2['tmp_name']);
00515                                                                         switch ($upload_result)
00516                                                                         {
00517                                                                                 case 0:
00518                                                                                         $_POST["image_".$matches2[1]] = $value2['name'];
00519                                                                                         $answer_image = $value2['name'];
00520                                                                                         break;
00521                                                                                 case 1:
00522                                                                                         $this->error .= $this->lng->txt("error_image_upload_wrong_format") . "<br />";
00523                                                                                         break;
00524                                                                                 case 2:
00525                                                                                         $this->error .= $this->lng->txt("error_image_upload_copy_file") . "<br />";
00526                                                                                         break;
00527                                                                         }
00528                                                                 }
00529                                                         }
00530                                                 }
00531                                         }
00532                                 }
00533                                 $points = $_POST["points_checked_$matches[1]"];
00534                                 $points_unchecked = $_POST["points_unchecked_$matches[1]"];
00535                                 $answertext = ilUtil::stripSlashes($_POST["$key"], false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment"));
00536                                 $this->object->addAnswer(
00537                                         $answertext,
00538                                         ilUtil::stripSlashes($points),
00539                                         ilUtil::stripSlashes($points_unchecked),
00540                                         ilUtil::stripSlashes($matches[1]),
00541                                         $answer_image
00542                                 );
00543                         }
00544                 }
00545 
00546                 if ($this->object->getMaximumPoints() < 0)
00547                 {
00548                         $result = 1;
00549                         $this->setErrorMessage($this->lng->txt("enter_enough_positive_points"));
00550                 }
00551                 
00552                 // Set the question id from a hidden form parameter
00553                 if ($_POST["multiple_choice_id"] > 0)
00554                 {
00555                         $this->object->setId($_POST["multiple_choice_id"]);
00556                 }
00557                 
00558                 if ($saved)
00559                 {
00560                         // If the question was saved automatically before an upload, we have to make
00561                         // sure, that the state after the upload is saved. Otherwise the user could be
00562                         // irritated, if he presses cancel, because he only has the question state before
00563                         // the upload process.
00564                         $this->object->saveToDb();
00565                         $this->ctrl->setParameter($this, "q_id", $this->object->getId());
00566                 }
00567 
00568                 return $result;
00569         }
00570         
00571         function outQuestionForTest($formaction, $active_id, $pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE)
00572         {
00573                 $test_output = $this->getTestOutput($active_id, $pass, $is_postponed, $use_post_solutions, $show_feedback); 
00574                 $this->tpl->setVariable("QUESTION_OUTPUT", $test_output);
00575                 $this->tpl->setVariable("FORMACTION", $formaction);
00576         }
00577 
00578         function getSolutionOutput($active_id, $pass = NULL, $graphicalOutput = FALSE, $result_output = FALSE, $show_question_only = TRUE, $show_feedback = FALSE)
00579         {
00580                 $keys = $this->getChoiceKeys();
00581                 
00582                 // get the solution of the user for the active pass or from the last pass if allowed
00583                 $user_solution = array();
00584                 if ($active_id)
00585                 {
00586                         $solutions =& $this->object->getSolutionValues($active_id, $pass);
00587                         foreach ($solutions as $idx => $solution_value)
00588                         {
00589                                 array_push($user_solution, $solution_value["value1"]);
00590                         }
00591                 }
00592                 else
00593                 {
00594                         // take the correct solution instead of the user solution
00595                         foreach ($this->object->answers as $index => $answer)
00596                         {
00597                                 $points_checked = $answer->getPointsChecked();
00598                                 $points_unchecked = $answer->getPointsUnchecked();
00599                                 if ($points_checked > $points_unchecked)
00600                                 {
00601                                         if ($points_checked > 0)
00602                                         {
00603                                                 array_push($user_solution, $index);
00604                                         }
00605                                 }
00606                         }
00607                 }
00608                 
00609                 // generate the question output
00610                 include_once "./classes/class.ilTemplate.php";
00611                 $template = new ilTemplate("tpl.il_as_qpl_mc_mr_output_solution.html", TRUE, TRUE, "Modules/TestQuestionPool");
00612                 $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html",TRUE, TRUE, "Modules/TestQuestionPool");
00613                 foreach ($keys as $answer_id)
00614                 {
00615                         $answer = $this->object->answers[$answer_id];
00616                         if ($graphicalOutput)
00617                         {
00618                                 // output of ok/not ok icons for user entered solutions
00619                                 $ok = FALSE;
00620                                 $checked = FALSE;
00621                                 foreach ($user_solution as $mc_solution)
00622                                 {
00623                                         if (strcmp($mc_solution, $answer_id) == 0)
00624                                         {
00625                                                 $checked = TRUE;
00626                                         }
00627                                 }
00628                                 if ($checked)
00629                                 {
00630                                         if ($answer->getPointsChecked() > $answer->getPointsUnchecked())
00631                                         {
00632                                                 $ok = TRUE;
00633                                         }
00634                                         else
00635                                         {
00636                                                 $ok = FALSE;
00637                                         }
00638                                 }
00639                                 else
00640                                 {
00641                                         if ($answer->getPointsChecked() > $answer->getPointsUnchecked())
00642                                         {
00643                                                 $ok = FALSE;
00644                                         }
00645                                         else
00646                                         {
00647                                                 $ok = TRUE;
00648                                         }
00649                                 }
00650                                 if ($ok)
00651                                 {
00652                                         $template->setCurrentBlock("icon_ok");
00653                                         $template->setVariable("ICON_OK", ilUtil::getImagePath("icon_ok.gif"));
00654                                         $template->setVariable("TEXT_OK", $this->lng->txt("answer_is_right"));
00655                                         $template->parseCurrentBlock();
00656                                 }
00657                                 else
00658                                 {
00659                                         $template->setCurrentBlock("icon_ok");
00660                                         $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_not_ok.gif"));
00661                                         $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_wrong"));
00662                                         $template->parseCurrentBlock();
00663                                 }
00664                         }
00665                         if (strlen($answer->getImage()))
00666                         {
00667                                 $template->setCurrentBlock("answer_image");
00668                                 $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $answer->getImage());
00669                                 $alt = $answer->getImage();
00670                                 if (strlen($answer->getAnswertext()))
00671                                 {
00672                                         $alt = $answer->getAnswertext();
00673                                 }
00674                                 $alt = preg_replace("/<[^>]*?>/", "", $alt);
00675                                 $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
00676                                 $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
00677                                 $template->parseCurrentBlock();
00678                         }
00679                         if ($show_feedback)
00680                         {
00681                                 foreach ($user_solution as $mc_solution)
00682                                 {
00683                                         if (strcmp($mc_solution, $answer_id) == 0)
00684                                         {
00685                                                 $fb = $this->object->getFeedbackSingleAnswer($answer_id);
00686                                                 if (strlen($fb))
00687                                                 {
00688                                                         $template->setCurrentBlock("feedback");
00689                                                         $template->setVariable("FEEDBACK", $fb);
00690                                                         $template->parseCurrentBlock();
00691                                                 }
00692                                         }
00693                                 }
00694                         }
00695                         $template->setCurrentBlock("answer_row");
00696                         $template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
00697                         $checked = FALSE;
00698                         if ($result_output)
00699                         {
00700                                 $pointschecked = $this->object->answers[$answer_id]->getPointsChecked();
00701                                 $pointsunchecked = $this->object->answers[$answer_id]->getPointsUnchecked();
00702                                 $resulttextchecked = ($pointschecked == 1) || ($pointschecked == -1) ? "%s " . $this->lng->txt("point") : "%s " . $this->lng->txt("points");
00703                                 $resulttextunchecked = ($pointsunchecked == 1) || ($pointsunchecked == -1) ? "%s " . $this->lng->txt("point") : "%s " . $this->lng->txt("points"); 
00704                                 $template->setVariable("RESULT_OUTPUT", sprintf("(" . $this->lng->txt("checkbox_checked") . " = $resulttextchecked, " . $this->lng->txt("checkbox_unchecked") . " = $resulttextunchecked)", $pointschecked, $pointsunchecked));
00705                         }
00706                         foreach ($user_solution as $mc_solution)
00707                         {
00708                                 if (strcmp($mc_solution, $answer_id) == 0)
00709                                 {
00710                                         $template->setVariable("SOLUTION_IMAGE", ilUtil::getHtmlPath(ilUtil::getImagePath("checkbox_checked.gif")));
00711                                         $template->setVariable("SOLUTION_ALT", $this->lng->txt("checked"));
00712                                         $checked = TRUE;
00713                                 }
00714                         }
00715                         if (!$checked)
00716                         {
00717                                 $template->setVariable("SOLUTION_IMAGE", ilUtil::getHtmlPath(ilUtil::getImagePath("checkbox_unchecked.gif")));
00718                                 $template->setVariable("SOLUTION_ALT", $this->lng->txt("unchecked"));
00719                         }
00720                         $template->parseCurrentBlock();
00721                 }
00722                 $questiontext = $this->object->getQuestion();
00723                 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
00724                 $questionoutput = $template->get();
00725                 $feedback = ($show_feedback) ? $this->getAnswerFeedbackOutput($active_id, $pass) : "";
00726                 if (strlen($feedback)) $solutiontemplate->setVariable("FEEDBACK", $feedback);
00727                 $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
00728 
00729                 $solutionoutput = $solutiontemplate->get(); 
00730                 if (!$show_question_only)
00731                 {
00732                         // get page object output
00733                         $pageoutput = $this->getILIASPage();
00734                         $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>";
00735                 }
00736                 return $solutionoutput;
00737         }
00738         
00739         function getPreview($show_question_only = FALSE)
00740         {
00741                 $keys = $this->getChoiceKeys();
00742                 
00743                 // generate the question output
00744                 include_once "./classes/class.ilTemplate.php";
00745                 $template = new ilTemplate("tpl.il_as_qpl_mc_mr_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
00746                 foreach ($keys as $answer_id)
00747                 {
00748                         $answer = $this->object->answers[$answer_id];
00749                         if (strlen($answer->getImage()))
00750                         {
00751                                 $template->setCurrentBlock("answer_image");
00752                                 $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $answer->getImage());
00753                                 $alt = $answer->getImage();
00754                                 if (strlen($answer->getAnswertext()))
00755                                 {
00756                                         $alt = $answer->getAnswertext();
00757                                 }
00758                                 $alt = preg_replace("/<[^>]*?>/", "", $alt);
00759                                 $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
00760                                 $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
00761                                 $template->parseCurrentBlock();
00762                         }
00763                         $template->setCurrentBlock("answer_row");
00764                         $template->setVariable("ANSWER_ID", $answer_id);
00765                         $template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
00766                         $template->parseCurrentBlock();
00767                 }
00768                 $questiontext = $this->object->getQuestion();
00769                 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
00770                 $questionoutput = $template->get();
00771                 if (!$show_question_only)
00772                 {
00773                         // get page object output
00774                         $pageoutput = $this->getILIASPage();
00775                         $questionoutput = preg_replace("/(<div( xmlns:xhtml\=\"http:\/\/www.w3.org\/1999\/xhtml\"){0,1} class\=\"ilc_Question\"><\/div>)/ims", $questionoutput, $pageoutput);
00776                 }
00777                 else
00778                 {
00779                         $questionoutput = preg_replace("/<div[^>]*?>(.*)<\/div>/is", "\\1", $questionoutput);
00780                 }
00781 
00782                 return $questionoutput;
00783         }
00784 
00785         function getTestOutput($active_id, $pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE)
00786         {
00787                 $keys = $this->getChoiceKeys();
00788                 
00789                 // get page object output
00790                 $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id);
00791 
00792                 // get the solution of the user for the active pass or from the last pass if allowed
00793                 $user_solution = array();
00794                 if ($active_id)
00795                 {
00796                         $solutions = NULL;
00797                         include_once "./Modules/Test/classes/class.ilObjTest.php";
00798                         if (!ilObjTest::_getUsePreviousAnswers($active_id, true))
00799                         {
00800                                 if (is_null($pass)) $pass = ilObjTest::_getPass($active_id);
00801                         }
00802                         $solutions =& $this->object->getSolutionValues($active_id, $pass);
00803                         foreach ($solutions as $idx => $solution_value)
00804                         {
00805                                 array_push($user_solution, $solution_value["value1"]);
00806                         }
00807                 }
00808                 // generate the question output
00809                 include_once "./classes/class.ilTemplate.php";
00810                 $template = new ilTemplate("tpl.il_as_qpl_mc_mr_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
00811                 foreach ($keys as $answer_id)
00812                 {
00813                         $answer = $this->object->answers[$answer_id];
00814                         if (strlen($answer->getImage()))
00815                         {
00816                                 $template->setCurrentBlock("answer_image");
00817                                 $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $answer->getImage());
00818                                 $alt = $answer->getImage();
00819                                 if (strlen($answer->getAnswertext()))
00820                                 {
00821                                         $alt = $answer->getAnswertext();
00822                                 }
00823                                 $alt = preg_replace("/<[^>]*?>/", "", $alt);
00824                                 $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
00825                                 $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
00826                                 $template->parseCurrentBlock();
00827                         }
00828 
00829                         foreach ($user_solution as $mc_solution)
00830                         {
00831                                 if (strcmp($mc_solution, $answer_id) == 0)
00832                                 {
00833                                         if ($show_feedback)
00834                                         {
00835                                                 $feedback = $this->object->getFeedbackSingleAnswer($answer_id);
00836                                                 if (strlen($feedback))
00837                                                 {
00838                                                         $template->setCurrentBlock("feedback");
00839                                                         $template->setVariable("FEEDBACK", $feedback);
00840                                                         $template->parseCurrentBlock();
00841                                                 }
00842                                         }
00843                                 }
00844                         }
00845 
00846                         $template->setCurrentBlock("answer_row");
00847                         $template->setVariable("ANSWER_ID", $answer_id);
00848                         $template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
00849                         foreach ($user_solution as $mc_solution)
00850                         {
00851                                 if (strcmp($mc_solution, $answer_id) == 0)
00852                                 {
00853                                         $template->setVariable("CHECKED_ANSWER", " checked=\"checked\"");
00854                                 }
00855                         }
00856                         $template->parseCurrentBlock();
00857                 }
00858                 $questiontext = $this->object->getQuestion();
00859                 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
00860                 $questionoutput = $template->get();
00861                 $questionoutput = preg_replace("/(<div( xmlns:xhtml\=\"http:\/\/www.w3.org\/1999\/xhtml\"){0,1} class\=\"ilc_Question\"><\/div>)/ims", $questionoutput, $pageoutput);
00862                 return $questionoutput;
00863         }
00864 
00865         function addSuggestedSolution()
00866         {
00867                 $_SESSION["subquestion_index"] = 0;
00868                 if ($_POST["cmd"]["addSuggestedSolution"])
00869                 {
00870                         if ($this->writePostData())
00871                         {
00872                                 ilUtil::sendInfo($this->getErrorMessage());
00873                                 $this->editQuestion();
00874                                 return;
00875                         }
00876                         if (!$this->checkInput())
00877                         {
00878                                 ilUtil::sendInfo($this->lng->txt("fill_out_all_required_fields_add_answer"));
00879                                 $this->editQuestion();
00880                                 return;
00881                         }
00882                 }
00883                 $this->object->saveToDb();
00884                 $this->ctrl->setParameter($this, "q_id", $this->object->getId());
00885                 $this->tpl->setVariable("HEADER", $this->object->getTitle());
00886                 $this->getQuestionTemplate();
00887                 parent::addSuggestedSolution();
00888         }
00889         
00893         function upload()
00894         {
00895                 $this->writePostData();
00896                 $this->editQuestion();
00897         }
00898         
00899         function deleteImage()
00900         {
00901                 if ($this->writePostData())
00902                 {
00903                         ilUtil::sendInfo($this->getErrorMessage());
00904                         $this->editQuestion();
00905                         return;
00906                 }
00907                 $imageorder = "";
00908                 foreach ($_POST["cmd"] as $key => $value)
00909                 {
00910                         if (preg_match("/deleteImage_(\d+)/", $key, $matches))
00911                         {
00912                                 $imageorder = $matches[1];
00913                         }
00914                 }
00915                 for ($i = 0; $i < $this->object->getAnswerCount(); $i++)
00916                 {
00917                         $answer = $this->object->getAnswer($i);
00918                         if ($answer->getOrder() == $imageorder)
00919                         {
00920                                 $this->object->deleteImage($answer->getImage());
00921                                 $this->object->answers[$i]->setImage("");
00922                         }
00923                 }
00924                 $this->editQuestion();
00925         }
00926 
00927         function editMode()
00928         {
00929                 global $ilUser;
00930                 
00931                 $this->object->setMultilineAnswerSetting($_POST["multilineAnswers"]);
00932                 $this->object->setGraphicalAnswerSetting($_POST["graphicalAnswerSupport"]);
00933                 $this->writePostData();
00934                 $this->editQuestion();
00935         }
00936         
00944         function saveFeedback()
00945         {
00946                 include_once "./classes/class.ilObjAdvancedEditing.php";
00947                 $this->object->saveFeedbackGeneric(0, ilUtil::stripSlashes($_POST["feedback_incomplete"], false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment")));
00948                 $this->object->saveFeedbackGeneric(1, ilUtil::stripSlashes($_POST["feedback_complete"], false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment")));
00949                 foreach ($this->object->answers as $index => $answer)
00950                 {
00951                         $this->object->saveFeedbackSingleAnswer($index, ilUtil::stripSlashes($_POST["feedback_answer_$index"], false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment")));
00952                 }
00953                 $this->object->cleanupMediaObjectUsage();
00954                 parent::saveFeedback();
00955         }
00956 
00964         function feedback()
00965         {
00966                 $this->tpl->addBlockFile("ADM_CONTENT", "feedback", "tpl.il_as_qpl_mc_mr_feedback.html", "Modules/TestQuestionPool");
00967                 foreach ($this->object->answers as $index => $answer)
00968                 {
00969                         $this->tpl->setCurrentBlock("feedback_answer");
00970                         $this->tpl->setVariable("FEEDBACK_TEXT_ANSWER", $this->lng->txt("feedback"));
00971                         $this->tpl->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
00972                         $this->tpl->setVariable("ANSWER_ID", $index);
00973                         $this->tpl->setVariable("VALUE_FEEDBACK_ANSWER", ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($this->object->getFeedbackSingleAnswer($index)), FALSE));
00974                         $this->tpl->parseCurrentBlock();
00975                 }
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("FEEDBACK_ANSWERS", $this->lng->txt("feedback_answers"));
00982                 $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
00983                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00984 
00985                 include_once "./Services/RTE/classes/class.ilRTE.php";
00986                 $rtestring = ilRTE::_getRTEClassname();
00987                 include_once "./Services/RTE/classes/class.$rtestring.php";
00988                 $rte = new $rtestring();
00989                 $rte->addPlugin("latex");
00990                 $rte->addButton("latex"); $rte->addButton("pastelatex");
00991                 include_once "./classes/class.ilObject.php";
00992                 $obj_id = $_GET["q_id"];
00993                 $obj_type = ilObject::_lookupType($_GET["ref_id"], TRUE);
00994                 $rte->addRTESupport($obj_id, $obj_type, "assessment");
00995         }
00996 
01004         function setQuestionTabs()
01005         {
01006                 global $rbacsystem, $ilTabs;
01007                 
01008                 $this->ctrl->setParameterByClass("ilpageobjectgui", "q_id", $_GET["q_id"]);
01009                 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
01010                 $q_type = $this->object->getQuestionType();
01011 
01012                 if (strlen($q_type))
01013                 {
01014                         $classname = $q_type . "GUI";
01015                         $this->ctrl->setParameterByClass(strtolower($classname), "sel_question_types", $q_type);
01016                         $this->ctrl->setParameterByClass(strtolower($classname), "q_id", $_GET["q_id"]);
01017                 }
01018 
01019                 if ($_GET["q_id"])
01020                 {
01021                         if ($rbacsystem->checkAccess('write', $_GET["ref_id"]))
01022                         {
01023                                 // edit page
01024                                 $ilTabs->addTarget("edit_content",
01025                                         $this->ctrl->getLinkTargetByClass("ilPageObjectGUI", "view"),
01026                                         array("view", "insert", "exec_pg"),
01027                                         "", "", $force_active);
01028                         }
01029         
01030                         // edit page
01031                         $ilTabs->addTarget("preview",
01032                                 $this->ctrl->getLinkTargetByClass("ilPageObjectGUI", "preview"),
01033                                 array("preview"),
01034                                 "ilPageObjectGUI", "", $force_active);
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                         $force_active = false;
01042                         $commands = $_POST["cmd"];
01043                         if (is_array($commands))
01044                         {
01045                                 foreach ($commands as $key => $value)
01046                                 {
01047                                         if (preg_match("/^deleteImage_.*/", $key, $matches) || 
01048                                                 preg_match("/^upload_.*/", $key, $matches)
01049                                                 )
01050                                         {
01051                                                 $force_active = true;
01052                                         }
01053                                 }
01054                         }
01055                         // edit question properties
01056                         $ilTabs->addTarget("edit_properties",
01057                                 $url,
01058                                 array("editQuestion", "save", "cancel", "addSuggestedSolution",
01059                                         "cancelExplorer", "linkChilds", "removeSuggestedSolution",
01060                                         "toggleGraphicalAnswers", "setMediaMode", "uploadingImage", "add", "editMode", "deleteAnswer",
01061                                         "saveEdit"),
01062                                 $classname, "", $force_active);
01063                 }
01064 
01065                 if ($_GET["q_id"])
01066                 {
01067                         $ilTabs->addTarget("feedback",
01068                                 $this->ctrl->getLinkTargetByClass($classname, "feedback"),
01069                                 array("feedback", "saveFeedback"),
01070                                 $classname, "");
01071                 }
01072                 
01073                 // Assessment of questions sub menu entry
01074                 if ($_GET["q_id"])
01075                 {
01076                         $ilTabs->addTarget("statistics",
01077                                 $this->ctrl->getLinkTargetByClass($classname, "assessment"),
01078                                 array("assessment"),
01079                                 $classname, "");
01080                 }
01081                 
01082                 if (($_GET["calling_test"] > 0) || ($_GET["test_ref_id"] > 0))
01083                 {
01084                         $ref_id = $_GET["calling_test"];
01085                         if (strlen($ref_id) == 0) $ref_id = $_GET["test_ref_id"];
01086                         $ilTabs->setBackTarget($this->lng->txt("backtocallingtest"), "ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
01087                 }
01088                 else
01089                 {
01090                         $ilTabs->setBackTarget($this->lng->txt("qpl"), $this->ctrl->getLinkTargetByClass("ilobjquestionpoolgui", "questions"));
01091                 }
01092         }
01093 
01094         /*
01095          * Create the key index numbers for the array of choices
01096          * 
01097          * @return array
01098          */
01099         function getChoiceKeys()
01100         {
01101                 if (strcmp($_GET["activecommand"], "directfeedback") == 0)
01102                 {
01103                         if (is_array($_SESSION["choicekeys"])) $this->choiceKeys = $_SESSION["choicekeys"];
01104                 }
01105                 if (!is_array($this->choiceKeys))
01106                 {
01107                         $this->choiceKeys = array_keys($this->object->answers);
01108                         if ($this->object->getShuffle())
01109                         {
01110                                 $this->choiceKeys = $this->object->pcArrayShuffle($this->choiceKeys);
01111                         }
01112                 }
01113                 $_SESSION["choicekeys"] = $this->choiceKeys;
01114                 return $this->choiceKeys;
01115         }
01116 }
01117 ?>

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