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

assessment/classes/class.assTextSubsetGUI.php

Go to the documentation of this file.
00001 <?php
00002  /*
00003    +----------------------------------------------------------------------------+
00004    | ILIAS open source                                                          |
00005    +----------------------------------------------------------------------------+
00006    | Copyright (c) 1998-2001 ILIAS open source, University of Cologne           |
00007    |                                                                            |
00008    | This program is free software; you can redistribute it and/or              |
00009    | modify it under the terms of the GNU General Public License                |
00010    | as published by the Free Software Foundation; either version 2             |
00011    | of the License, or (at your option) any later version.                     |
00012    |                                                                            |
00013    | This program is distributed in the hope that it will be useful,            |
00014    | but WITHOUT ANY WARRANTY; without even the implied warranty of             |
00015    | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              |
00016    | GNU General Public License for more details.                               |
00017    |                                                                            |
00018    | You should have received a copy of the GNU General Public License          |
00019    | along with this program; if not, write to the Free Software                |
00020    | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
00021    +----------------------------------------------------------------------------+
00022 */
00023 
00024 include_once "./assessment/classes/class.assQuestionGUI.php";
00025 include_once "./assessment/classes/inc.AssessmentConstants.php";
00026 
00038 class assTextSubsetGUI extends assQuestionGUI
00039 {
00048         function assTextSubsetGUI(
00049                         $id = -1
00050         )
00051         {
00052                 $this->assQuestionGUI();
00053                 include_once "./assessment/classes/class.assTextSubset.php";
00054                 $this->object = new assTextSubset();
00055                 if ($id >= 0)
00056                 {
00057                         $this->object->loadFromDb($id);
00058                 }
00059         }
00060 
00061         function getCommand($cmd)
00062         {
00063                 return $cmd;
00064         }
00065 
00066 
00075         function getQuestionType()
00076         {
00077                 return "assTextSubset";
00078         }
00079 
00087         function editQuestion()
00088         {
00089                 $javascript = "<script type=\"text/javascript\">function initialSelect() {\n%s\n}</script>";
00090                 // single response
00091                 $this->getQuestionTemplate();
00092                 $this->tpl->addBlockFile("QUESTION_DATA", "question_data", "tpl.il_as_qpl_textsubset.html", true);
00093                 // output of existing single response answers
00094                 for ($i = 0; $i < $this->object->getAnswerCount(); $i++)
00095                 {
00096                         $this->tpl->setCurrentBlock("answers");
00097                         $answer = $this->object->getAnswer($i);
00098                         $this->tpl->setVariable("VALUE_ANSWER_COUNTER", $answer->getOrder() + 1);
00099                         $this->tpl->setVariable("ANSWER_ORDER", $answer->getOrder());
00100                         $this->tpl->setVariable("VALUE_ANSWER", ilUtil::prepareFormOutput($answer->getAnswertext()));
00101                         $this->tpl->setVariable("VALUE_POINTS", ilUtil::prepareFormOutput($answer->getPoints()));
00102                         $this->tpl->parseCurrentBlock();
00103                 }
00104                 if ($this->object->getAnswerCount() > 0)
00105                 {
00106                         $this->tpl->setCurrentBlock("answersheading");
00107                         $this->tpl->setVariable("TEXT_ANSWER_TEXT", $this->lng->txt("answer_text"));
00108                         $this->tpl->setVariable("TEXT_POINTS", $this->lng->txt("points"));
00109                         $this->tpl->parseCurrentBlock();
00110                 }
00111 
00112                 $internallinks = array(
00113                         "lm" => $this->lng->txt("obj_lm"),
00114                         "st" => $this->lng->txt("obj_st"),
00115                         "pg" => $this->lng->txt("obj_pg"),
00116                         "glo" => $this->lng->txt("glossary_term")
00117                 );
00118                 foreach ($internallinks as $key => $value)
00119                 {
00120                         $this->tpl->setCurrentBlock("internallink");
00121                         $this->tpl->setVariable("TYPE_INTERNAL_LINK", $key);
00122                         $this->tpl->setVariable("TEXT_INTERNAL_LINK", $value);
00123                         $this->tpl->parseCurrentBlock();
00124                 }
00125                 
00126                 $this->tpl->setCurrentBlock("HeadContent");
00127                 if ($this->object->getAnswerCount() == 0)
00128                 {
00129                         $this->tpl->setVariable("CONTENT_BLOCK", sprintf($javascript, "document.frm_textsubset.title.focus();"));
00130                 }
00131                 else
00132                 {
00133                         switch ($this->ctrl->getCmd())
00134                         {
00135                                 case "add":
00136                                         $this->tpl->setVariable("CONTENT_BLOCK", sprintf($javascript, "document.frm_textsubset.answer_".($this->object->getAnswerCount() - $_POST["nrOfAnswers"]).".focus(); document.getElementById('answer_".($this->object->getAnswerCount() - $_POST["nrOfAnswers"])."').scrollIntoView(\"true\");"));
00137                                         break;
00138                                 case "":
00139                                         if ($this->object->getAnswerCount() == 0)
00140                                         {
00141                                                 $this->tpl->setVariable("CONTENT_BLOCK", sprintf($javascript, "document.frm_textsubset.title.focus();"));
00142                                         }
00143                                         else
00144                                         {
00145                                                 $this->tpl->setVariable("CONTENT_BLOCK", sprintf($javascript, "document.frm_textsubset.answer_".($this->object->getAnswerCount() - 1).".focus(); document.getElementById('answer_".($this->object->getAnswerCount() - 1)."').scrollIntoView(\"true\");"));
00146                                         }
00147                                         break;
00148                                 default:
00149                                         $this->tpl->setVariable("CONTENT_BLOCK", sprintf($javascript, "document.frm_textsubset.title.focus();"));
00150                                         break;
00151                         }
00152                 }
00153                 $this->tpl->parseCurrentBlock();
00154 
00155                 // Add text rating options
00156                 $text_options = array(
00157                         array("ci", $this->lng->txt("cloze_textgap_case_insensitive")),
00158                         array("cs", $this->lng->txt("cloze_textgap_case_sensitive")),
00159                         array("l1", sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "1")),
00160                         array("l2", sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "2")),
00161                         array("l3", sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "3")),
00162                         array("l4", sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "4")),
00163                         array("l5", sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "5"))
00164                 );
00165                 $text_rating = $this->object->getTextRating();
00166                 foreach ($text_options as $text_option)
00167                 {
00168                         $this->tpl->setCurrentBlock("text_rating");
00169                         $this->tpl->setVariable("RATING_VALUE", $text_option[0]);
00170                         $this->tpl->setVariable("RATING_TEXT", $text_option[1]);
00171                         if (strcmp($text_rating, $text_option[0]) == 0)
00172                         {
00173                                 $this->tpl->setVariable("SELECTED_RATING_VALUE", " selected=\"selected\"");
00174                         }
00175                         $this->tpl->parseCurrentBlock();
00176                 }
00177 
00178                 if ($this->object->getAnswerCount() > 0)
00179                 {
00180                         $this->tpl->setCurrentBlock("selectall");
00181                         $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
00182                         $this->tpl->parseCurrentBlock();
00183                         $this->tpl->setCurrentBlock("existinganswers");
00184                         $this->tpl->setVariable("DELETE", $this->lng->txt("delete"));
00185                         $this->tpl->setVariable("MOVE", $this->lng->txt("move"));
00186                         $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\">");
00187                         $this->tpl->parseCurrentBlock();
00188                 }
00189                 
00190                 for ($i = 1; $i < 10; $i++)
00191                 {
00192                         $this->tpl->setCurrentBlock("numbers");
00193                         $this->tpl->setVariable("VALUE_NUMBER", $i);
00194                         if ($i == 1)
00195                         {
00196                                 $this->tpl->setVariable("TEXT_NUMBER", $i . " " . $this->lng->txt("answer"));
00197                         }
00198                         else
00199                         {
00200                                 $this->tpl->setVariable("TEXT_NUMBER", $i . " " . $this->lng->txt("answers"));
00201                         }
00202                         $this->tpl->parseCurrentBlock();
00203                 }
00204 
00205                 $this->tpl->setCurrentBlock("question_data");
00206                 $this->tpl->setVariable("TEXTSUBSET_ID", $this->object->getId());
00207                 $this->tpl->setVariable("VALUE_TEXTSUBSET_TITLE", ilUtil::prepareFormOutput($this->object->getTitle()));
00208                 $this->tpl->setVariable("VALUE_TEXTSUBSET_COMMENT", ilUtil::prepareFormOutput($this->object->getComment()));
00209                 $this->tpl->setVariable("VALUE_TEXTSUBSET_AUTHOR", ilUtil::prepareFormOutput($this->object->getAuthor()));
00210                 $this->tpl->setVariable("VALUE_CORRECTANSWERS", $this->object->getCorrectAnswers());
00211                 $this->tpl->setVariable("VALUE_POINTS", $this->object->getMaximumPoints());
00212                 $questiontext = $this->object->getQuestion();
00213                 $this->tpl->setVariable("VALUE_QUESTION", ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($questiontext)));
00214                 $this->tpl->setVariable("VALUE_ADD_ANSWER", $this->lng->txt("add"));
00215                 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
00216                 $this->tpl->setVariable("TEXT_AUTHOR", $this->lng->txt("author"));
00217                 $this->tpl->setVariable("TEXT_COMMENT", $this->lng->txt("description"));
00218                 $this->tpl->setVariable("TEXT_QUESTION", $this->lng->txt("question"));
00219                 $this->tpl->setVariable("TEXT_SOLUTION_HINT", $this->lng->txt("solution_hint"));
00220                 $this->tpl->setVariable("TEXT_RATING", $this->lng->txt("text_rating"));
00221                 $this->tpl->setVariable("TEXT_POINTS", $this->lng->txt("maximum_points"));
00222                 $this->tpl->setVariable("TEXT_CORRECTANSWERS", $this->lng->txt("nr_of_correct_answers"));
00223                 
00224                 // estimated working time
00225                 $est_working_time = $this->object->getEstimatedWorkingTime();
00226                 $this->tpl->setVariable("TEXT_WORKING_TIME", $this->lng->txt("working_time"));
00227                 $this->tpl->setVariable("TIME_FORMAT", $this->lng->txt("time_format"));
00228                 $this->tpl->setVariable("VALUE_WORKING_TIME", ilUtil::makeTimeSelect("Estimated", false, $est_working_time[h], $est_working_time[m], $est_working_time[s]));
00229 
00230                 if (count($this->object->suggested_solutions))
00231                 {
00232                         $solution_array = $this->object->getSuggestedSolution(0);
00233                         include_once "./assessment/classes/class.assQuestion.php";
00234                         $href = assQuestion::_getInternalLinkHref($solution_array["internal_link"]);
00235                         $this->tpl->setVariable("TEXT_VALUE_SOLUTION_HINT", " <a href=\"$href\" target=\"content\">" . $this->lng->txt("solution_hint"). "</a> ");
00236                         $this->tpl->setVariable("BUTTON_REMOVE_SOLUTION", $this->lng->txt("remove"));
00237                         $this->tpl->setVariable("BUTTON_ADD_SOLUTION", $this->lng->txt("change"));
00238                         $this->tpl->setVariable("VALUE_SOLUTION_HINT", $solution_array["internal_link"]);
00239                 }
00240                 else
00241                 {
00242                         $this->tpl->setVariable("BUTTON_ADD_SOLUTION", $this->lng->txt("add"));
00243                 }
00244                 $this->tpl->setVariable("SAVE",$this->lng->txt("save"));
00245                 $this->tpl->setVariable("SAVE_EDIT", $this->lng->txt("save_edit"));
00246                 $this->tpl->setVariable("CANCEL",$this->lng->txt("cancel"));
00247                 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00248                 $this->ctrl->setParameter($this, "sel_question_types", "assTextSubset");
00249                 $this->tpl->setVariable("ACTION_TEXTSUBSET_TEST", $this->ctrl->getFormAction($this));
00250                 $this->tpl->setVariable("TEXT_QUESTION_TYPE", $this->lng->txt("assTextSubset"));
00251                 $this->outOtherQuestionData();
00252 
00253                 $this->tpl->parseCurrentBlock();
00254                 include_once "./Services/RTE/classes/class.ilRTE.php";
00255                 $rtestring = ilRTE::_getRTEClassname();
00256                 include_once "./Services/RTE/classes/class.$rtestring.php";
00257                 $rte = new $rtestring();
00258                 $rte->addPlugin("latex");
00259                 $rte->addButton("latex");
00260                 include_once "./classes/class.ilObject.php";
00261                 $obj_id = $_GET["q_id"];
00262                 $obj_type = ilObject::_lookupType($_GET["ref_id"], TRUE);
00263                 $rte->addRTESupport($obj_id, $obj_type, "assessment");
00264 
00265                 $this->tpl->setCurrentBlock("adm_content");
00266                 $this->tpl->setVariable("BODY_ATTRIBUTES", " onload=\"initialSelect();\""); 
00267                 $this->tpl->parseCurrentBlock();
00268         }
00269         
00273         function deleteAnswer()
00274         {
00275                 $this->writePostData();
00276                 $answers = $_POST["chb_answers"];
00277                 if (is_array($answers))
00278                 {
00279                         arsort($answers);
00280                         foreach ($answers as $answer)
00281                         {
00282                                 $this->object->deleteAnswer($answer);
00283                         }
00284                 }
00285                 $this->editQuestion();
00286         }
00287 
00291         function add()
00292         {
00293                 //$this->setObjectData();
00294                 $this->writePostData();
00295 
00296                 for ($i = 0; $i < $_POST["nrOfAnswers"]; $i++)
00297                 {
00298                         $this->object->addAnswer(
00299                                 "",
00300                                 1,
00301                                 count($this->object->answers)
00302                         );
00303                 }
00304 
00305                 $this->editQuestion();
00306         }
00307         
00308         function save()
00309         {
00310                 $unfilled_answer = false;
00311                 foreach ($_POST as $key => $value)
00312                 {
00313                         if (preg_match("/answer_(\d+)/", $key, $matches))
00314                         {
00315                                 if (!$value)
00316                                 {
00317                                         $unfilled_answer = true;
00318                                 }
00319                         }
00320                 }
00321                 if ($unfilled_answer)
00322                 {
00323                         sendInfo($this->lng->txt("qpl_answertext_fields_not_filled"));
00324                         $this->writePostData();
00325                         $this->editQuestion();
00326                 }
00327                 else
00328                 {
00329                         parent::save();
00330                 }
00331         }
00332         
00333         function saveEdit()
00334         {
00335                 $unfilled_answer = false;
00336                 foreach ($_POST as $key => $value)
00337                 {
00338                         if (preg_match("/answer_(\d+)/", $key, $matches))
00339                         {
00340                                 if (!$value)
00341                                 {
00342                                         $unfilled_answer = true;
00343                                 }
00344                         }
00345                 }
00346                 if ($unfilled_answer)
00347                 {
00348                         sendInfo($this->lng->txt("qpl_answertext_fields_not_filled"));
00349                         $this->writePostData();
00350                         $this->editQuestion();
00351                 }
00352                 else
00353                 {
00354                         parent::saveEdit();
00355                 }
00356         }
00357 
00361         function checkInput()
00362         {
00363                 $cmd = $this->ctrl->getCmd();
00364 
00365                 if ((!$_POST["title"]) or (!$_POST["author"]) or (!$_POST["question"]) or (!$_POST["correctanswers"]))
00366                 {
00367                         return false;
00368                 }
00369                 return true;
00370         }
00371 
00380         function writePostData()
00381         {
00382 //echo "here!"; exit;
00383 //echo "<br>assTextSubsetGUI->writePostData()";
00384                 $result = 0;
00385                 if (!$this->checkInput())
00386                 {
00387                         $result = 1;
00388                 }
00389 
00390                 if (($result) and (strcmp($this->ctrl->getCmd(), "add") == 0))
00391                 {
00392                         // You cannot add answers before you enter the required data
00393                         sendInfo($this->lng->txt("fill_out_all_required_fields_add_answer"));
00394                 }
00395 
00396                 $this->object->setTitle(ilUtil::stripSlashes($_POST["title"]));
00397                 $this->object->setAuthor(ilUtil::stripSlashes($_POST["author"]));
00398                 $this->object->setComment(ilUtil::stripSlashes($_POST["comment"]));
00399                 include_once "./classes/class.ilObjAdvancedEditing.php";
00400                 $questiontext = ilUtil::stripSlashes($_POST["question"], false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment"));
00401                 $this->object->setQuestion($questiontext);
00402                 $this->object->setSuggestedSolution($_POST["solution_hint"], 0);
00403                 $this->object->setCorrectAnswers($_POST["correctanswers"]);
00404                 $this->object->setTextRating($_POST["text_rating"]);
00405 
00406                 $saved = $this->writeOtherPostData($result);
00407 
00408                 // Delete all existing answers and create new answers from the form data
00409                 $this->object->flushAnswers();
00410 
00411                 // Add all answers from the form into the object
00412                 foreach ($_POST as $key => $value)
00413                 {
00414                         if (preg_match("/answer_(\d+)/", $key, $matches))
00415                         {
00416                                 $this->object->addAnswer(
00417                                         ilUtil::stripSlashes($_POST["$key"]),
00418                                         ilUtil::stripSlashes($_POST["points_".$matches[1]]),
00419                                         ilUtil::stripSlashes($matches[1])
00420                                         );
00421                         }
00422                 }
00423 
00424                 // Set the question id from a hidden form parameter
00425                 if ($_POST["textsubset_id"] > 0)
00426                 {
00427                         $this->object->setId($_POST["textsubset_id"]);
00428                 }
00429 
00430                 $maximum_points = $this->object->getMaximumPoints();
00431                 if (($maximum_points <= 0) && (count($this->object->answers) > 0))
00432                 {
00433                         $result = 1;
00434                         $this->setErrorMessage($this->lng->txt("enter_enough_positive_points"));
00435                 }
00436                 $this->object->setPoints($maximum_points);
00437                 
00438                 if ($saved)
00439                 {
00440                         // If the question was saved automatically before an upload, we have to make
00441                         // sure, that the state after the upload is saved. Otherwise the user could be
00442                         // irritated, if he presses cancel, because he only has the question state before
00443                         // the upload process.
00444                         $this->object->saveToDb();
00445                         $_GET["q_id"] = $this->object->getId();
00446                 }
00447 
00448                 return $result;
00449         }
00450         
00451         function outQuestionForTest($formaction, $active_id, $pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE)
00452         {
00453                 $test_output = $this->getTestOutput($active_id, $pass, $is_postponed, $use_post_solutions); 
00454                 $this->tpl->setVariable("QUESTION_OUTPUT", $test_output);
00455                 $this->tpl->setVariable("FORMACTION", $formaction);
00456         }
00457 
00458         function getSolutionOutput($active_id, $pass = NULL, $graphicalOutput = FALSE, $result_output = FALSE, $show_question_only = TRUE)
00459         {
00460                 // get the solution of the user for the active pass or from the last pass if allowed
00461                 $solutions = array();
00462                 if ($active_id)
00463                 {
00464                         $solutions =& $this->object->getSolutionValues($active_id, $pass);
00465                 }
00466                 else
00467                 {
00468                         $rank = array();
00469                         foreach ($this->object->answers as $answer)
00470                         {
00471                                 if ($answer->getPoints() > 0)
00472                                 {
00473                                         if (!is_array($rank[$answer->getPoints()]))
00474                                         {
00475                                                 $rank[$answer->getPoints()] = array();
00476                                         }
00477                                         array_push($rank[$answer->getPoints()], $answer->getAnswertext());
00478                                 }
00479                         }
00480                         krsort($rank, SORT_NUMERIC);
00481                         foreach ($rank as $index => $bestsolutions)
00482                         {
00483                                 array_push($solutions, array("value1" => join(",", $bestsolutions), "points" => $index));
00484                         }
00485                 }
00486                 
00487                 // generate the question output
00488                 include_once "./classes/class.ilTemplate.php";
00489                 $template = new ilTemplate("tpl.il_as_qpl_textsubset_output_solution.html", TRUE, TRUE, TRUE);
00490                 $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", TRUE, TRUE, TRUE);
00491                 $available_answers =& $this->object->getAvailableAnswers();
00492                 for ($i = 0; $i < $this->object->getCorrectAnswers(); $i++)
00493                 {
00494                         if ((!$test_id) && (strcmp($solutions[$i]["value1"], "") == 0))
00495                         {
00496                         }
00497                         else
00498                         {
00499                                 if ($active_id)
00500                                 {
00501                                         if ($graphicalOutput)
00502                                         {
00503                                                 // output of ok/not ok icons for user entered solutions
00504                                                 $index = $this->object->isAnswerCorrect($available_answers, $solutions[$i]["value1"]);
00505                                                 $correct = FALSE;
00506                                                 if ($index !== FALSE)
00507                                                 {
00508                                                         unset($available_answers[$index]);
00509                                                         $correct = TRUE;
00510                                                 }
00511                                                 if ($correct)
00512                                                 {
00513                                                         $template->setCurrentBlock("icon_ok");
00514                                                         $template->setVariable("ICON_OK", ilUtil::getImagePath("icon_ok.gif"));
00515                                                         $template->setVariable("TEXT_OK", $this->lng->txt("answer_is_right"));
00516                                                         $template->parseCurrentBlock();
00517                                                 }
00518                                                 else
00519                                                 {
00520                                                         $template->setCurrentBlock("icon_ok");
00521                                                         $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_not_ok.gif"));
00522                                                         $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_wrong"));
00523                                                         $template->parseCurrentBlock();
00524                                                 }
00525                                         }
00526                                 }
00527                                 $template->setCurrentBlock("textsubset_row");
00528                                 $template->setVariable("SOLUTION", $solutions[$i]["value1"]);
00529                                 $template->setVariable("COUNTER", $i+1);
00530                                 if ($result_output)
00531                                 {
00532                                         $points = $solutions[$i]["points"];
00533                                         $resulttext = ($points == 1) ? "(%s " . $this->lng->txt("point") . ")" : "(%s " . $this->lng->txt("points") . ")"; 
00534                                         $template->setVariable("RESULT_OUTPUT", sprintf($resulttext, $points));
00535                                 }
00536                                 $template->parseCurrentBlock();
00537                         }
00538                 }
00539                 $questiontext = $this->object->getQuestion();
00540                 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
00541                 $questionoutput = $template->get();
00542                 $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
00543 
00544                 $solutionoutput = $solutiontemplate->get(); 
00545                 if (!$show_question_only)
00546                 {
00547                         // get page object output
00548                         $pageoutput = $this->getILIASPage();
00549                         $solutionoutput = preg_replace("/(<div( xmlns:xhtml\=\"http:\/\/www.w3.org\/1999\/xhtml\"){0,1} class\=\"ilc_Question\"><\/div>)/ims", $solutionoutput, $pageoutput);
00550                 }
00551                 return $solutionoutput;
00552         }
00553         
00554         function getPreview()
00555         {
00556                 // generate the question output
00557                 include_once "./classes/class.ilTemplate.php";
00558                 $template = new ilTemplate("tpl.il_as_qpl_textsubset_output.html", TRUE, TRUE, TRUE);
00559                 $width = $this->object->getMaxTextboxWidth();
00560                 for ($i = 0; $i < $this->object->getCorrectAnswers(); $i++)
00561                 {
00562                         $template->setCurrentBlock("textsubset_row");
00563                         $template->setVariable("COUNTER", $i+1);
00564                         $template->setVariable("TEXTFIELD_ID", sprintf("%02d", $i+1));
00565                         $template->setVariable("TEXTFIELD_SIZE", $width);
00566                         $template->parseCurrentBlock();
00567                 }
00568                 $questiontext = $this->object->getQuestion();
00569                 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
00570                 $questionoutput = $template->get();
00571                 $questionoutput = preg_replace("/<div[^>]*?>(.*)<\/div>/is", "\\1", $questionoutput);
00572                 return $questionoutput;
00573         }
00574 
00575         function getTestOutput($active_id, $pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE)
00576         {
00577                 // get page object output
00578                 $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id);
00579 
00580                 // get the solution of the user for the active pass or from the last pass if allowed
00581                 $user_solution = "";
00582                 if ($active_id)
00583                 {
00584                         $solutions = NULL;
00585                         include_once "./assessment/classes/class.ilObjTest.php";
00586                         if (ilObjTest::_getHidePreviousResults($active_id, true))
00587                         {
00588                                 if (is_null($pass)) $pass = ilObjTest::_getPass($active_id);
00589                         }
00590                         $solutions =& $this->object->getSolutionValues($active_id, $pass);
00591                 }
00592                 
00593                 // generate the question output
00594                 include_once "./classes/class.ilTemplate.php";
00595                 $template = new ilTemplate("tpl.il_as_qpl_textsubset_output.html", TRUE, TRUE, TRUE);
00596                 $width = $this->object->getMaxTextboxWidth();
00597                 for ($i = 0; $i < $this->object->getCorrectAnswers(); $i++)
00598                 {
00599                         $template->setCurrentBlock("textsubset_row");
00600                         foreach ($solutions as $idx => $solution_value)
00601                         {
00602                                 if ($idx == $i)
00603                                 {
00604                                         $template->setVariable("TEXTFIELD_VALUE", " value=\"" . $solution_value["value1"]."\"");
00605                                 }
00606                         }
00607                         $template->setVariable("COUNTER", $i+1);
00608                         $template->setVariable("TEXTFIELD_ID", sprintf("%02d", $i+1));
00609                         $template->setVariable("TEXTFIELD_SIZE", $width);
00610                         $template->parseCurrentBlock();
00611                 }
00612                 $questiontext = $this->object->getQuestion();
00613                 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
00614                 $questionoutput = $template->get();
00615                 $questionoutput = preg_replace("/(<div( xmlns:xhtml\=\"http:\/\/www.w3.org\/1999\/xhtml\"){0,1} class\=\"ilc_Question\"><\/div>)/ims", $questionoutput, $pageoutput);
00616                 return $questionoutput;
00617         }
00618 
00619         function addSuggestedSolution()
00620         {
00621                 $_SESSION["subquestion_index"] = 0;
00622                 if ($_POST["cmd"]["addSuggestedSolution"])
00623                 {
00624                         if ($this->writePostData())
00625                         {
00626                                 sendInfo($this->getErrorMessage());
00627                                 $this->editQuestion();
00628                                 return;
00629                         }
00630                         if (!$this->checkInput())
00631                         {
00632                                 sendInfo($this->lng->txt("fill_out_all_required_fields_add_answer"));
00633                                 $this->editQuestion();
00634                                 return;
00635                         }
00636                 }
00637                 $this->object->saveToDb();
00638                 $_GET["q_id"] = $this->object->getId();
00639                 $this->tpl->setVariable("HEADER", $this->object->getTitle());
00640                 $this->getQuestionTemplate();
00641                 parent::addSuggestedSolution();
00642         }
00643         
00644 }
00645 ?>

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