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

assessment/classes/class.assJavaAppletGUI.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 assJavaAppletGUI extends assQuestionGUI
00039 {
00048         function assJavaAppletGUI(
00049                 $id = -1
00050         )
00051         {
00052                 $this->assQuestionGUI();
00053                 include_once "./assessment/classes/class.assJavaApplet.php";
00054                 $this->object = new assJavaApplet();
00055                 if ($id >= 0)
00056                 {
00057                         $this->object->loadFromDb($id);
00058                 }
00059         }
00060 
00069         function getQuestionType()
00070         {
00071                 return "assJavaApplet";
00072         }
00073 
00074         function getCommand($cmd)
00075         {
00076                 if (substr($cmd, 0, 6) == "delete")
00077                 {
00078                         $cmd = "delete";
00079                 }
00080                 return $cmd;
00081         }
00082 
00090         function editQuestion()
00091         {
00092                 $this->getQuestionTemplate();
00093                 $this->tpl->addBlockFile("QUESTION_DATA", "question_data", "tpl.il_as_qpl_javaapplet_question.html", true);
00094                 if ($this->error)
00095                 {
00096                         sendInfo($this->error);
00097                 }
00098                 // call to other question data i.e. estimated working time block
00099                 $this->outOtherQuestionData();
00100                 // image block
00101                 $this->tpl->setCurrentBlock("post_save");
00102 
00103                 $internallinks = array(
00104                         "lm" => $this->lng->txt("obj_lm"),
00105                         "st" => $this->lng->txt("obj_st"),
00106                         "pg" => $this->lng->txt("obj_pg"),
00107                         "glo" => $this->lng->txt("glossary_term")
00108                 );
00109                 foreach ($internallinks as $key => $value)
00110                 {
00111                         $this->tpl->setCurrentBlock("internallink");
00112                         $this->tpl->setVariable("TYPE_INTERNAL_LINK", $key);
00113                         $this->tpl->setVariable("TEXT_INTERNAL_LINK", $value);
00114                         $this->tpl->parseCurrentBlock();
00115                 }
00116                 
00117                 $this->tpl->setVariable("TEXT_SOLUTION_HINT", $this->lng->txt("solution_hint"));
00118                 if (count($this->object->suggested_solutions))
00119                 {
00120                         $solution_array = $this->object->getSuggestedSolution(0);
00121                         include_once "./assessment/classes/class.assQuestion.php";
00122                         $href = assQuestion::_getInternalLinkHref($solution_array["internal_link"]);
00123                         $this->tpl->setVariable("TEXT_VALUE_SOLUTION_HINT", " <a href=\"$href\" target=\"content\">" . $this->lng->txt("solution_hint"). "</a> ");
00124                         $this->tpl->setVariable("BUTTON_REMOVE_SOLUTION", $this->lng->txt("remove"));
00125                         $this->tpl->setVariable("BUTTON_ADD_SOLUTION", $this->lng->txt("change"));
00126                         $this->tpl->setVariable("VALUE_SOLUTION_HINT", $solution_array["internal_link"]);
00127                 }
00128                 else
00129                 {
00130                         $this->tpl->setVariable("BUTTON_ADD_SOLUTION", $this->lng->txt("add"));
00131                 }
00132                 
00133                 // java applet block
00134                 $javaapplet = $this->object->getJavaAppletFilename();
00135                 $this->tpl->setVariable("TEXT_JAVAAPPLET", $this->lng->txt("javaapplet"));
00136                 if (!empty($javaapplet))
00137                 {
00138                         $this->tpl->setVariable("JAVAAPPLET_FILENAME", $javaapplet);
00139                         $this->tpl->setVariable("VALUE_JAVAAPPLET_UPLOAD", $this->lng->txt("change"));
00140                         $this->tpl->setCurrentBlock("javaappletupload");
00141                         $this->tpl->setVariable("UPLOADED_JAVAAPPLET", $javaapplet);
00142                         $this->tpl->parse("javaappletupload");
00143                         $this->tpl->setCurrentBlock("delete_applet");
00144                         $this->tpl->setVariable("VALUE_JAVAAPPLET_DELETE", $this->lng->txt("delete"));
00145                         $this->tpl->parseCurrentBlock();
00146                 }
00147                 else
00148                 {
00149                         $this->tpl->setVariable("VALUE_JAVAAPPLET_UPLOAD", $this->lng->txt("upload"));
00150                 }
00151                 $this->tpl->setVariable("TEXT_POINTS", $this->lng->txt("available_points"));
00152                 $this->tpl->setVariable("VALUE_APPLET_POINTS", $this->object->getPoints());
00153                 $this->tpl->parseCurrentBlock();
00154 
00155                 
00156                 if ((strlen($this->object->getTitle()) > 0) && (strlen($this->object->getAuthor()) > 0) && (strlen($this->object->getQuestion()) > 0) && ($this->object->getPoints() > 0))
00157                 {
00158                         $emptyname = 0;
00159                         for ($i = 0; $i < $this->object->getParameterCount(); $i++)
00160                         {
00161                                 // create template for existing applet parameters
00162                                 $this->tpl->setCurrentBlock("delete_parameter");
00163                                 $this->tpl->setVariable("VALUE_DELETE_PARAMETER", $this->lng->txt("delete"));
00164                                 $this->tpl->setVariable("DELETE_PARAMETER_COUNT", $i);
00165                                 $this->tpl->parseCurrentBlock();
00166                                 $this->tpl->setCurrentBlock("applet_parameter");
00167                                 $this->tpl->setVariable("PARAM_PARAM", $this->lng->txt("applet_parameter") . " " . ($i+1));
00168                                 $this->tpl->setVariable("PARAM_NAME", $this->lng->txt("name"));
00169                                 $this->tpl->setVariable("PARAM_VALUE", $this->lng->txt("value"));
00170                                 $param = $this->object->getParameter($i);
00171                                 $this->tpl->setVariable("PARAM_NAME_VALUE", $param["name"]);
00172                                 $this->tpl->setVariable("PARAM_VALUE_VALUE", $param["value"]);
00173                                 $this->tpl->setVariable("PARAM_COUNTER", $i);
00174                                 $this->tpl->parseCurrentBlock();
00175                                 if (!$param["name"])
00176                                 {
00177                                         $emptyname = 1;
00178                                 }
00179                         }
00180                         if ($this->ctrl->getCmd() == "addParameter")
00181                         {
00182                                 if ($emptyname == 0)
00183                                 {
00184                                         // create template for new applet parameter
00185                                         $this->tpl->setCurrentBlock("applet_parameter");
00186                                         $this->tpl->setVariable("PARAM_PARAM", $this->lng->txt("applet_new_parameter"));
00187                                         $this->tpl->setVariable("PARAM_NAME", $this->lng->txt("name"));
00188                                         $this->tpl->setVariable("PARAM_VALUE", $this->lng->txt("value"));
00189                                         $this->tpl->setVariable("PARAM_COUNTER", $this->object->getParameterCount());
00190                                         $this->tpl->parseCurrentBlock();
00191                                 }
00192                                 else
00193                                 {
00194                                         sendInfo($this->lng->txt("too_many_empty_parameters"));
00195                                 }
00196                         }
00197                         if (!strlen($javaapplet))
00198                         {
00199                                 $this->tpl->setVariable("TEXT_ARCHIVE", $this->lng->txt("archive"));
00200                                 $this->tpl->setVariable("VALUE_ARCHIVE", $this->object->getJavaArchive());
00201                                 $this->tpl->setVariable("TEXT_CODEBASE", $this->lng->txt("codebase"));
00202                                 $this->tpl->setVariable("VALUE_CODEBASE", $this->object->getJavaCodebase());
00203                         }
00204 
00205                         $this->tpl->setCurrentBlock("appletcode");
00206                         $this->tpl->setVariable("APPLET_ATTRIBUTES", $this->lng->txt("applet_attributes"));
00207                         $this->tpl->setVariable("TEXT_CODE", $this->lng->txt("code"));
00208                         $this->tpl->setVariable("TEXT_WIDTH", $this->lng->txt("width"));
00209                         $this->tpl->setVariable("TEXT_HEIGHT", $this->lng->txt("height"));
00210                         $this->tpl->setVariable("VALUE_CODE", $this->object->getJavaCode());
00211                         $this->tpl->setVariable("VALUE_WIDTH", $this->object->getJavaWidth());
00212                         $this->tpl->setVariable("VALUE_HEIGHT", $this->object->getJavaHeight());
00213                         $this->tpl->setVariable("APPLET_PARAMETERS", $this->lng->txt("applet_parameters"));
00214                         $this->tpl->setVariable("VALUE_ADD_PARAMETER", $this->lng->txt("add_applet_parameter"));
00215                         $this->tpl->parseCurrentBlock();
00216                 }
00217 
00218                 $this->tpl->setCurrentBlock("HeadContent");
00219                 $javascript = "<script type=\"text/javascript\">function initialSelect() {\n%s\n}</script>";
00220                 $this->tpl->setVariable("CONTENT_BLOCK", sprintf($javascript, "document.frm_javaapplet.title.focus();"));
00221                 $this->tpl->parseCurrentBlock();
00222                 $this->tpl->setCurrentBlock("question_data");
00223                 $this->tpl->setVariable("JAVAAPPLET_ID", $this->object->getId());
00224                 $this->tpl->setVariable("VALUE_JAVAAPPLET_TITLE", ilUtil::prepareFormOutput($this->object->getTitle()));
00225                 $this->tpl->setVariable("VALUE_JAVAAPPLET_COMMENT", ilUtil::prepareFormOutput($this->object->getComment()));
00226                 $this->tpl->setVariable("VALUE_JAVAAPPLET_AUTHOR", ilUtil::prepareFormOutput($this->object->getAuthor()));
00227                 $questiontext = $this->object->getQuestion();
00228                 $this->tpl->setVariable("VALUE_QUESTION", ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($questiontext)));
00229                 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
00230                 $this->tpl->setVariable("TEXT_AUTHOR", $this->lng->txt("author"));
00231                 $this->tpl->setVariable("TEXT_COMMENT", $this->lng->txt("description"));
00232                 $this->tpl->setVariable("TEXT_QUESTION", $this->lng->txt("question"));
00233                 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00234 
00235                 $this->tpl->setVariable("SAVE",$this->lng->txt("save"));
00236                 $this->tpl->setVariable("SAVE_EDIT", $this->lng->txt("save_edit"));
00237                 $this->tpl->setVariable("CANCEL",$this->lng->txt("cancel"));
00238                 $this->ctrl->setParameter($this, "sel_question_types", "assJavaApplet");
00239                 $this->tpl->setVariable("TEXT_QUESTION_TYPE", $this->lng->txt("assJavaApplet"));
00240                 $formaction = $this->ctrl->getFormaction($this);
00241                 if ($this->object->getId() > 0)
00242                 {
00243                         if (!preg_match("/q_id\=\d+/", $formaction))
00244                         {
00245                                 $formaction = str_replace("q_id=", "q_id=" . $this->object->getId(), $formaction);
00246                         }
00247                 }
00248                 $this->tpl->setVariable("ACTION_JAVAAPPLET_QUESTION", $formaction);
00249                 $this->tpl->parseCurrentBlock();
00250                 include_once "./Services/RTE/classes/class.ilRTE.php";
00251                 $rtestring = ilRTE::_getRTEClassname();
00252                 include_once "./Services/RTE/classes/class.$rtestring.php";
00253                 $rte = new $rtestring();
00254                 $rte->addPlugin("latex");
00255                 $rte->addButton("latex");
00256                 include_once "./classes/class.ilObject.php";
00257                 $obj_id = $_GET["q_id"];
00258                 $obj_type = ilObject::_lookupType($_GET["ref_id"], TRUE);
00259                 $rte->addRTESupport($obj_id, $obj_type, "assessment");
00260 
00261                 $this->tpl->setCurrentBlock("adm_content");
00262                 $this->tpl->setVariable("BODY_ATTRIBUTES", " onload=\"initialSelect();\""); 
00263                 $this->tpl->parseCurrentBlock();
00264 
00265         }
00266 
00267 
00271         function uploadingJavaApplet()
00272         {
00273                 $result = $this->writePostData();
00274                 if ($result == 0)
00275                 {
00276                         $this->object->saveToDb();
00277                 }
00278                 $this->editQuestion();
00279         }
00280 
00281 
00285         function removeJavaapplet()
00286         {
00287                 $this->object->deleteJavaAppletFilename();
00288                 $this->object->saveToDb();
00289                 $this->editQuestion();
00290         }
00291 
00295         function addParameter()
00296         {
00297                 $this->writePostData();
00298                 $this->editQuestion();
00299         }
00300 
00304         function delete()
00305         {
00306                 $this->writePostData();
00307                 $this->editQuestion();
00308         }
00309 
00318         function writePostData()
00319         {
00320                 $result = 0;
00321                 $saved = false;
00322                 if (!$this->checkInput())
00323                 {
00324                         $result = 1;
00325                 }
00326 
00327                 $this->object->setTitle(ilUtil::stripSlashes($_POST["title"]));
00328                 $this->object->setAuthor(ilUtil::stripSlashes($_POST["author"]));
00329                 $this->object->setComment(ilUtil::stripSlashes($_POST["comment"]));
00330                 include_once "./classes/class.ilObjAdvancedEditing.php";
00331                 $questiontext = ilUtil::stripSlashes($_POST["question"], false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment"));
00332                 $this->object->setQuestion($questiontext);
00333                 $this->object->setSuggestedSolution($_POST["solution_hint"], 0);
00334                 $this->object->setShuffle($_POST["shuffle"]);
00335                 $this->object->setPoints($_POST["applet_points"]);
00336                 if ($_POST["applet_points"] < 0)
00337                 {
00338                         $result = 1;
00339                         $this->setErrorMessage($this->lng->txt("negative_points_not_allowed"));
00340                 }
00341                 // adding estimated working time
00342                 $saved = $saved | $this->writeOtherPostData($result);
00343 
00344                 if ($result == 0)
00345                 {
00346                         //setting java applet
00347                         if (empty($_FILES['javaappletName']['tmp_name']))
00348                         {
00349                                 $this->object->setJavaAppletFilename(ilUtil::stripSlashes($_POST['uploaded_javaapplet']));
00350                         }
00351                         else
00352                         {
00353                                 if ($this->object->getId() < 1)
00354                                 {
00355                                         $saved = 1;
00356                                         $this->object->saveToDb();
00357                                 }
00358                                 $this->object->setJavaAppletFilename($_FILES['javaappletName']['name'], $_FILES['javaappletName']['tmp_name']);
00359                         }
00360                         if ((strlen($this->object->getTitle()) > 0) && (strlen($this->object->getAuthor()) > 0) && (strlen($this->object->getQuestion()) > 0) && ($this->object->getPoints() > 0) && array_key_exists("java_height", $_POST))
00361                         {
00362                                 $this->object->setJavaCode($_POST["java_code"]);
00363                                 $this->object->setJavaCodebase($_POST["java_codebase"]);
00364                                 $this->object->setJavaArchive($_POST["java_archive"]);
00365                                 $this->object->setJavaWidth($_POST["java_width"]);
00366                                 $this->object->setJavaHeight($_POST["java_height"]);
00367                                 if ((!$_POST["java_width"]) or (!$_POST["java_height"])) $result = 1;
00368                                 $this->object->flushParams();
00369                                 foreach ($_POST as $key => $value)
00370                                 {
00371                                         if (preg_match("/param_name_(\d+)/", $key, $matches))
00372                                         {
00373                                                 $this->object->addParameterAtIndex($matches[1], $value, $_POST["param_value_$matches[1]"]);
00374                                         }
00375                                 }
00376                                 if (preg_match("/delete_(\d+)/", $this->ctrl->getCmd(), $matches))
00377                                 {
00378                                         $this->object->removeParameter($_POST["param_name_$matches[1]"]);
00379                                 }
00380                         }
00381                 }
00382                 if ($saved)
00383                 {
00384                         $this->object->saveToDb();
00385                         $this->error .= $this->lng->txt("question_saved_for_upload");
00386                 }
00387                 return $result;
00388         }
00389 
00390         function outQuestionForTest($formaction, $active_id, $pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE)
00391         {
00392                 $test_output = $this->getTestOutput($active_id, $pass, $is_postponed, $use_post_solutions); 
00393                 $this->tpl->setVariable("QUESTION_OUTPUT", $test_output);
00394                 $this->tpl->setVariable("FORMACTION", $formaction);
00395         }
00396 
00397         function getSolutionOutput($active_id, $pass = NULL, $graphicalOutput = FALSE, $result_output = FALSE, $show_question_only = TRUE)
00398         {
00399                 $userdata = $this->object->getActiveUserData($active_id);
00400 
00401                 // generate the question output
00402                 include_once "./assessment/classes/class.ilObjTest.php";
00403                 include_once "./classes/class.ilTemplate.php";
00404                 $template = new ilTemplate("tpl.il_as_qpl_javaapplet_question_output_solution.html", TRUE, TRUE, TRUE);
00405                 $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", TRUE, TRUE, TRUE);
00406                 if ($active_id > 0)
00407                 {
00408                         $template->setCurrentBlock("appletparam");
00409                         $template->setVariable("PARAM_NAME", "test_type");
00410                         $template->setVariable("PARAM_VALUE", ilObjTest::_getTestType($active_id));
00411                         $template->parseCurrentBlock();
00412                 }
00413                 if (strlen($userdata["test_id"]))
00414                 {
00415                         $template->setCurrentBlock("appletparam");
00416                         $template->setVariable("PARAM_NAME", "test_id");
00417                         $template->setVariable("PARAM_VALUE", $userdata["test_id"]);
00418                         $template->parseCurrentBlock();
00419                 }
00420                 $template->setCurrentBlock("appletparam");
00421                 $template->setVariable("PARAM_NAME", "question_id");
00422                 $template->setVariable("PARAM_VALUE", $this->object->getId());
00423                 $template->parseCurrentBlock();
00424                 if (strlen($userdata["user_id"]))
00425                 {
00426                         $template->setCurrentBlock("appletparam");
00427                         $template->setVariable("PARAM_NAME", "user_id");
00428                         $template->setVariable("PARAM_VALUE", $userdata["user_id"]);
00429                         $template->parseCurrentBlock();
00430                 }
00431                 $template->setCurrentBlock("appletparam");
00432                 $template->setVariable("PARAM_NAME", "points_max");
00433                 $template->setVariable("PARAM_VALUE", $this->object->getPoints());
00434                 $template->parseCurrentBlock();
00435                 $template->setCurrentBlock("appletparam");
00436                 $template->setVariable("PARAM_NAME", "session_id");
00437                 $template->setVariable("PARAM_VALUE", $_COOKIE["PHPSESSID"]);
00438                 $template->parseCurrentBlock();
00439                 $template->setCurrentBlock("appletparam");
00440                 $template->setVariable("PARAM_NAME", "client");
00441                 $template->setVariable("PARAM_VALUE", CLIENT_ID);
00442                 $template->parseCurrentBlock();
00443                 $template->setCurrentBlock("appletparam");
00444                 $template->setVariable("PARAM_NAME", "pass");
00445                 $actualpass = ilObjTest::_getPass($active_id);
00446                 $template->setVariable("PARAM_VALUE", $actualpass);
00447                 $template->parseCurrentBlock();
00448                 // additional parameters
00449                 for ($i = 0; $i < $this->object->getParameterCount(); $i++)
00450                 {
00451                         $parameter = $this->object->getParameter($i);
00452                         $template->setCurrentBlock("appletparam");
00453                         $template->setVariable("PARAM_NAME", $parameter["name"]);
00454                         $template->setVariable("PARAM_VALUE", $parameter["value"]);
00455                         $template->parseCurrentBlock();
00456                 }
00457 
00458                 if ($active_id)
00459                 {
00460                         $solutions = NULL;
00461                         include_once "./assessment/classes/class.ilObjTest.php";
00462                         $info = $this->object->getReachedInformation($active_id, $pass);
00463                         foreach ($info as $kk => $infodata)
00464                         {
00465                                 $template->setCurrentBlock("appletparam");
00466                                 $template->setVariable("PARAM_NAME", "value_" . $infodata["order"] . "_1");
00467                                 $template->setVariable("PARAM_VALUE", $infodata["value1"]);
00468                                 $template->parseCurrentBlock();
00469                                 $template->setCurrentBlock("appletparam");
00470                                 $template->setVariable("PARAM_NAME", "value_" . $infodata["order"] . "_2");
00471                                 $template->setVariable("PARAM_VALUE", $infodata["value2"]);
00472                                 $template->parseCurrentBlock();
00473                         }
00474                 }
00475                 
00476                 $questiontext = $this->object->getQuestion();
00477                 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
00478                 $template->setVariable("APPLET_WIDTH", $this->object->getJavaWidth());
00479                 $template->setVariable("APPLET_HEIGHT", $this->object->getJavaHeight());
00480                 $template->setVariable("APPLET_CODE", $this->object->getJavaCode());
00481                 if (strlen($this->object->getJavaArchive()) > 0)
00482                 {
00483                         $template->setVariable("APPLET_ARCHIVE", " archive=\"".$this->object->getJavaArchive()."\"");
00484                 }
00485                 else
00486                 {
00487                         if (strpos($this->object->getJavaAppletFilename(), ".jar") !== FALSE)
00488                         {
00489                                 $template->setVariable("APPLET_ARCHIVE", " archive=\"".$this->object->getJavaPathWeb().$this->object->getJavaAppletFilename()."\"");
00490                         }
00491                 }
00492                 if (strlen($this->object->getJavaCodebase()) > 0)
00493                 {
00494                         $template->setVariable("APPLET_CODEBASE", " codebase=\"".$this->object->getJavaCodebase()."\"");
00495                 }
00496                 else
00497                 {
00498                         if (strpos($this->object->getJavaAppletFilename(), ".class") !== FALSE)
00499                         {
00500                                 $template->setVariable("APPLET_CODEBASE", " codebase=\"".$this->object->getJavaPathWeb()."\"");
00501                         }
00502                 }
00503                 if ($active_id)
00504                 {
00505                         if ($graphicalOutput)
00506                         {
00507                                 // output of ok/not ok icons for user entered solutions
00508                                 $reached_points = $this->object->getReachedPoints($active_id);
00509                                 if ($reached_points == $this->object->getMaximumPoints())
00510                                 {
00511                                         $template->setCurrentBlock("icon_ok");
00512                                         $template->setVariable("ICON_OK", ilUtil::getImagePath("icon_ok.gif"));
00513                                         $template->setVariable("TEXT_OK", $this->lng->txt("answer_is_right"));
00514                                         $template->parseCurrentBlock();
00515                                 }
00516                                 else
00517                                 {
00518                                         $template->setCurrentBlock("icon_ok");
00519                                         if ($reached_points > 0)
00520                                         {
00521                                                 $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_mostly_ok.gif"));
00522                                                 $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_not_correct_but_positive"));
00523                                         }
00524                                         else
00525                                         {
00526                                                 $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_not_ok.gif"));
00527                                                 $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_wrong"));
00528                                         }
00529                                         $template->parseCurrentBlock();
00530                                 }
00531                         }
00532                 }
00533                 $questionoutput = $template->get();
00534                 $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
00535 
00536                 $solutionoutput = $solutiontemplate->get(); 
00537                 if (!$show_question_only)
00538                 {
00539                         // get page object output
00540                         $pageoutput = $this->getILIASPage();
00541                         $solutionoutput = preg_replace("/(<div( xmlns:xhtml\=\"http:\/\/www.w3.org\/1999\/xhtml\"){0,1} class\=\"ilc_Question\"><\/div>)/ims", $solutionoutput, $pageoutput);
00542                 }
00543                 return $solutionoutput;
00544         }
00545         
00546         function getPreview()
00547         {
00548                 // generate the question output
00549                 include_once "./classes/class.ilTemplate.php";
00550                 $template = new ilTemplate("tpl.il_as_qpl_javaapplet_question_output.html", TRUE, TRUE, TRUE);
00551                 $template->setCurrentBlock("appletparam");
00552                 $template->setVariable("PARAM_NAME", "question_id");
00553                 $template->setVariable("PARAM_VALUE", $this->object->getId());
00554                 $template->parseCurrentBlock();
00555                 $template->setCurrentBlock("appletparam");
00556                 $template->setVariable("PARAM_NAME", "points_max");
00557                 $template->setVariable("PARAM_VALUE", $this->object->getPoints());
00558                 $template->parseCurrentBlock();
00559                 $template->setCurrentBlock("appletparam");
00560                 $template->setVariable("PARAM_NAME", "session_id");
00561                 $template->setVariable("PARAM_VALUE", $_COOKIE["PHPSESSID"]);
00562                 $template->parseCurrentBlock();
00563                 $template->setCurrentBlock("appletparam");
00564                 $template->setVariable("PARAM_NAME", "client");
00565                 $template->setVariable("PARAM_VALUE", CLIENT_ID);
00566                 $template->parseCurrentBlock();
00567                 // additional parameters
00568                 for ($i = 0; $i < $this->object->getParameterCount(); $i++)
00569                 {
00570                         $parameter = $this->object->getParameter($i);
00571                         $template->setCurrentBlock("appletparam");
00572                         $template->setVariable("PARAM_NAME", $parameter["name"]);
00573                         $template->setVariable("PARAM_VALUE", $parameter["value"]);
00574                         $template->parseCurrentBlock();
00575                 }
00576 
00577                 $questiontext = $this->object->getQuestion();
00578                 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
00579                 $template->setVariable("APPLET_WIDTH", $this->object->getJavaWidth());
00580                 $template->setVariable("APPLET_HEIGHT", $this->object->getJavaHeight());
00581                 $template->setVariable("APPLET_CODE", $this->object->getJavaCode());
00582                 if (strlen($this->object->getJavaArchive()) > 0)
00583                 {
00584                         $template->setVariable("APPLET_ARCHIVE", " archive=\"".$this->object->getJavaArchive()."\"");
00585                 }
00586                 else
00587                 {
00588                         if (strpos($this->object->getJavaAppletFilename(), ".jar") !== FALSE)
00589                         {
00590                                 $template->setVariable("APPLET_ARCHIVE", " archive=\"".$this->object->getJavaPathWeb().$this->object->getJavaAppletFilename()."\"");
00591                         }
00592                 }
00593                 if (strlen($this->object->getJavaCodebase()) > 0)
00594                 {
00595                         $template->setVariable("APPLET_CODEBASE", " codebase=\"".$this->object->getJavaCodebase()."\"");
00596                 }
00597                 else
00598                 {
00599                         if (strpos($this->object->getJavaAppletFilename(), ".class") !== FALSE)
00600                         {
00601                                 $template->setVariable("APPLET_CODEBASE", " codebase=\"".$this->object->getJavaPathWeb()."\"");
00602                         }
00603                 }
00604                 $questionoutput = $template->get();
00605                 $questionoutput = preg_replace("/<div[^>]*?>(.*)<\/div>/is", "\\1", $questionoutput);
00606                 return $questionoutput;
00607         }
00608         
00609         function getTestOutput($active_id, $pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE)
00610         {
00611                 // get page object output
00612                 $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id);
00613                 $userdata = $this->object->getActiveUserData($active_id);
00614                 // generate the question output
00615                 include_once "./classes/class.ilTemplate.php";
00616                 include_once "./assessment/classes/class.ilObjTest.php";
00617                 $template = new ilTemplate("tpl.il_as_qpl_javaapplet_question_output.html", TRUE, TRUE, TRUE);
00618                 $template->setCurrentBlock("appletparam");
00619                 $template->setVariable("PARAM_NAME", "test_type");
00620                 $template->setVariable("PARAM_VALUE", ilObjTest::_getTestType($active_id));
00621                 $template->parseCurrentBlock();
00622                 $template->setCurrentBlock("appletparam");
00623                 $template->setVariable("PARAM_NAME", "test_id");
00624                 $template->setVariable("PARAM_VALUE", $userdata["test_id"]);
00625                 $template->parseCurrentBlock();
00626                 $template->setCurrentBlock("appletparam");
00627                 $template->setVariable("PARAM_NAME", "question_id");
00628                 $template->setVariable("PARAM_VALUE", $this->object->getId());
00629                 $template->parseCurrentBlock();
00630                 $template->setCurrentBlock("appletparam");
00631                 $template->setVariable("PARAM_NAME", "user_id");
00632                 $template->setVariable("PARAM_VALUE", $userdata["user_id"]);
00633                 $template->parseCurrentBlock();
00634                 $template->setCurrentBlock("appletparam");
00635                 $template->setVariable("PARAM_NAME", "points_max");
00636                 $template->setVariable("PARAM_VALUE", $this->object->getPoints());
00637                 $template->parseCurrentBlock();
00638                 $template->setCurrentBlock("appletparam");
00639                 $template->setVariable("PARAM_NAME", "session_id");
00640                 $template->setVariable("PARAM_VALUE", $_COOKIE["PHPSESSID"]);
00641                 $template->parseCurrentBlock();
00642                 $template->setCurrentBlock("appletparam");
00643                 $template->setVariable("PARAM_NAME", "client");
00644                 $template->setVariable("PARAM_VALUE", CLIENT_ID);
00645                 $template->parseCurrentBlock();
00646                 $template->setCurrentBlock("appletparam");
00647                 $template->setVariable("PARAM_NAME", "pass");
00648                 $actualpass = ilObjTest::_getPass($active_id);
00649                 $template->setVariable("PARAM_VALUE", $actualpass);
00650                 $template->parseCurrentBlock();
00651                 $template->setCurrentBlock("appletparam");
00652                 $template->setVariable("PARAM_NAME", "post_url");
00653                 $template->setVariable("PARAM_VALUE", ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/assessment/save_question_post_data.php");
00654                 $template->parseCurrentBlock();
00655                 
00656                 // additional parameters
00657                 for ($i = 0; $i < $this->object->getParameterCount(); $i++)
00658                 {
00659                         $parameter = $this->object->getParameter($i);
00660                         $template->setCurrentBlock("appletparam");
00661                         $template->setVariable("PARAM_NAME", $parameter["name"]);
00662                         $template->setVariable("PARAM_VALUE", $parameter["value"]);
00663                         $template->parseCurrentBlock();
00664                 }
00665 
00666                 if ($active_id)
00667                 {
00668                         $solutions = NULL;
00669                         include_once "./assessment/classes/class.ilObjTest.php";
00670                         if (ilObjTest::_getHidePreviousResults($active_id, true))
00671                         {
00672                                 if (is_null($pass)) $pass = ilObjTest::_getPass($active_id);
00673                         }
00674                         $info = $this->object->getReachedInformation($active_id, $pass);
00675                         foreach ($info as $kk => $infodata)
00676                         {
00677                                 $template->setCurrentBlock("appletparam");
00678                                 $template->setVariable("PARAM_NAME", "value_" . $infodata["order"] . "_1");
00679                                 $template->setVariable("PARAM_VALUE", $infodata["value1"]);
00680                                 $template->parseCurrentBlock();
00681                                 $template->setCurrentBlock("appletparam");
00682                                 $template->setVariable("PARAM_NAME", "value_" . $infodata["order"] . "_2");
00683                                 $template->setVariable("PARAM_VALUE", $infodata["value2"]);
00684                                 $template->parseCurrentBlock();
00685                         }
00686                 }
00687                 
00688                 $questiontext = $this->object->getQuestion();
00689                 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
00690                 $template->setVariable("APPLET_WIDTH", $this->object->getJavaWidth());
00691                 $template->setVariable("APPLET_HEIGHT", $this->object->getJavaHeight());
00692                 $template->setVariable("APPLET_CODE", $this->object->getJavaCode());
00693                 if (strlen($this->object->getJavaArchive()) > 0)
00694                 {
00695                         $template->setVariable("APPLET_ARCHIVE", " archive=\"".$this->object->getJavaArchive()."\"");
00696                 }
00697                 else
00698                 {
00699                         if (strpos($this->object->getJavaAppletFilename(), ".jar") !== FALSE)
00700                         {
00701                                 $template->setVariable("APPLET_ARCHIVE", " archive=\"".$this->object->getJavaPathWeb().$this->object->getJavaAppletFilename()."\"");
00702                         }
00703                 }
00704                 if (strlen($this->object->getJavaCodebase()) > 0)
00705                 {
00706                         $template->setVariable("APPLET_CODEBASE", " codebase=\"".$this->object->getJavaCodebase()."\"");
00707                 }
00708                 else
00709                 {
00710                         if (strpos($this->object->getJavaAppletFilename(), ".class") !== FALSE)
00711                         {
00712                                 $template->setVariable("APPLET_CODEBASE", " codebase=\"".$this->object->getJavaPathWeb()."\"");
00713                         }
00714                 }
00715                 $questionoutput = $template->get();
00716                 $questionoutput = preg_replace("/(<div( xmlns:xhtml\=\"http:\/\/www.w3.org\/1999\/xhtml\"){0,1} class\=\"ilc_Question\"><\/div>)/ims", $questionoutput, $pageoutput);
00717                 return $questionoutput;
00718         }
00719         
00723         function checkInput()
00724         {
00725                 if ((strlen($_POST["title"]) == 0) or (strlen($_POST["author"]) == 0) or (strlen($_POST["question"]) == 0) or (strlen($_POST["applet_points"]) == 0))
00726                 {
00727                         $this->error .= $this->lng->txt("fill_out_all_required_fields");
00728                         return false;
00729                 }
00730                 return true;
00731         }
00732 
00733 
00734         function addSuggestedSolution()
00735         {
00736                 $_SESSION["subquestion_index"] = 0;
00737                 if ($_POST["cmd"]["addSuggestedSolution"])
00738                 {
00739                         if ($this->writePostData())
00740                         {
00741                                 sendInfo($this->getErrorMessage());
00742                                 $this->editQuestion();
00743                                 return;
00744                         }
00745                         if ($result != 0)
00746                         {
00747                                 $this->editQuestion();
00748                                 return;
00749                         }
00750                 }
00751                 $this->object->saveToDb();
00752                 $_GET["q_id"] = $this->object->getId();
00753                 $this->tpl->setVariable("HEADER", $this->object->getTitle());
00754                 $this->getQuestionTemplate();
00755                 parent::addSuggestedSolution();
00756         }
00757 }
00758 ?>

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