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

Modules/TestQuestionPool/classes/class.assFlashAppGUI.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 
00041 class assFlashAppGUI extends assQuestionGUI
00042 {
00051         function assFlashAppGUI(
00052                 $id = -1
00053         )
00054         {
00055                 $this->assQuestionGUI();
00056                 include_once "./Modules/TestQuestionPool/classes/class.assFlashApp.php";
00057                 $this->object = new assFlashApp();
00058                 if ($id >= 0)
00059                 {
00060                         $this->object->loadFromDb($id);
00061                 }
00062         }
00063 
00072         function getQuestionType()
00073         {
00074                 return "assFlashApp";
00075         }
00076 
00077         function getCommand($cmd)
00078         {
00079                 if (substr($cmd, 0, 6) == "delete")
00080                 {
00081                         $cmd = "delete";
00082                 }
00083                 return $cmd;
00084         }
00085 
00093         function editQuestion()
00094         {
00095                 $this->getQuestionTemplate();
00096                 $this->tpl->addBlockFile("QUESTION_DATA", "question_data", "tpl.il_as_qpl_flashapp_question.html", "Modules/TestQuestionPool");
00097                 if ($this->error)
00098                 {
00099                         ilUtil::sendInfo($this->error);
00100                 }
00101                 // call to other question data i.e. estimated working time block
00102                 $this->outOtherQuestionData();
00103                 // image block
00104                 $this->tpl->setCurrentBlock("post_save");
00105 
00106                 $internallinks = array(
00107                         "lm" => $this->lng->txt("obj_lm"),
00108                         "st" => $this->lng->txt("obj_st"),
00109                         "pg" => $this->lng->txt("obj_pg"),
00110                         "glo" => $this->lng->txt("glossary_term")
00111                 );
00112                 foreach ($internallinks as $key => $value)
00113                 {
00114                         $this->tpl->setCurrentBlock("internallink");
00115                         $this->tpl->setVariable("TYPE_INTERNAL_LINK", $key);
00116                         $this->tpl->setVariable("TEXT_INTERNAL_LINK", $value);
00117                         $this->tpl->parseCurrentBlock();
00118                 }
00119                 
00120                 $this->tpl->setVariable("TEXT_SOLUTION_HINT", $this->lng->txt("solution_hint"));
00121                 if (count($this->object->suggested_solutions))
00122                 {
00123                         $solution_array = $this->object->getSuggestedSolution(0);
00124                         include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
00125                         $href = assQuestion::_getInternalLinkHref($solution_array["internal_link"]);
00126                         $this->tpl->setVariable("TEXT_VALUE_SOLUTION_HINT", " <a href=\"$href\" target=\"content\">" . $this->lng->txt("solution_hint"). "</a> ");
00127                         $this->tpl->setVariable("BUTTON_REMOVE_SOLUTION", $this->lng->txt("remove"));
00128                         $this->tpl->setVariable("BUTTON_ADD_SOLUTION", $this->lng->txt("change"));
00129                         $this->tpl->setVariable("VALUE_SOLUTION_HINT", $solution_array["internal_link"]);
00130                 }
00131                 else
00132                 {
00133                         $this->tpl->setVariable("BUTTON_ADD_SOLUTION", $this->lng->txt("add"));
00134                 }
00135                 
00136                 // java applet block
00137                 $javaapplet = $this->object->getFlashFilename();
00138                 $this->tpl->setVariable("TEXT_FLASHFILE", $this->lng->txt("flashfile"));
00139                 if (!empty($javaapplet))
00140                 {
00141                         $this->tpl->setVariable("FLASHFILE_FILENAME", $javaapplet);
00142                         $this->tpl->setVariable("VALUE_FLASHFILE_UPLOAD", $this->lng->txt("change"));
00143                         $this->tpl->setCurrentBlock("flashfileupload");
00144                         $this->tpl->setVariable("UPLOADED_FLASHFILE", $javaapplet);
00145                         $this->tpl->parse("javaappletupload");
00146                         $this->tpl->setCurrentBlock("delete_flash");
00147                         $this->tpl->setVariable("VALUE_FLASHFILE_DELETE", $this->lng->txt("delete"));
00148                         $this->tpl->parseCurrentBlock();
00149                 }
00150                 else
00151                 {
00152                         $this->tpl->setVariable("VALUE_FLASHFILE_UPLOAD", $this->lng->txt("upload"));
00153                 }
00154                 $this->tpl->setVariable("TEXT_POINTS", $this->lng->txt("available_points"));
00155                 $this->tpl->setVariable("VALUE_FLASH_POINTS", $this->object->getPoints());
00156                 $this->tpl->parseCurrentBlock();
00157 
00158                 
00159                 if ((strlen($this->object->getTitle()) > 0) && (strlen($this->object->getAuthor()) > 0) && (strlen($this->object->getQuestion()) > 0) && ($this->object->getPoints() > 0))
00160                 {
00161                         $emptyname = 0;
00162                         for ($i = 0; $i < $this->object->getParameterCount(); $i++)
00163                         {
00164                                 // create template for existing applet parameters
00165                                 $this->tpl->setCurrentBlock("delete_parameter");
00166                                 $this->tpl->setVariable("VALUE_DELETE_PARAMETER", $this->lng->txt("delete"));
00167                                 $this->tpl->setVariable("DELETE_PARAMETER_COUNT", $i);
00168                                 $this->tpl->parseCurrentBlock();
00169                                 $this->tpl->setCurrentBlock("flash_parameter");
00170                                 $this->tpl->setVariable("PARAM_PARAM", $this->lng->txt("applet_parameter") . " " . ($i+1));
00171                                 $this->tpl->setVariable("PARAM_NAME", $this->lng->txt("name"));
00172                                 $this->tpl->setVariable("PARAM_VALUE", $this->lng->txt("value"));
00173                                 $param = $this->object->getParameter($i);
00174                                 $this->tpl->setVariable("PARAM_NAME_VALUE", $param["name"]);
00175                                 $this->tpl->setVariable("PARAM_VALUE_VALUE", $param["value"]);
00176                                 $this->tpl->setVariable("PARAM_COUNTER", $i);
00177                                 $this->tpl->parseCurrentBlock();
00178                                 if (!$param["name"])
00179                                 {
00180                                         $emptyname = 1;
00181                                 }
00182                         }
00183                         if ($this->ctrl->getCmd() == "addParameter")
00184                         {
00185                                 if ($emptyname == 0)
00186                                 {
00187                                         // create template for new applet parameter
00188                                         $this->tpl->setCurrentBlock("flash_parameter");
00189                                         $this->tpl->setVariable("PARAM_PARAM", $this->lng->txt("applet_new_parameter"));
00190                                         $this->tpl->setVariable("PARAM_NAME", $this->lng->txt("name"));
00191                                         $this->tpl->setVariable("PARAM_VALUE", $this->lng->txt("value"));
00192                                         $this->tpl->setVariable("PARAM_COUNTER", $this->object->getParameterCount());
00193                                         $this->tpl->parseCurrentBlock();
00194                                 }
00195                                 else
00196                                 {
00197                                         ilUtil::sendInfo($this->lng->txt("too_many_empty_parameters"));
00198                                 }
00199                         }
00200                         if (!strlen($javaapplet))
00201                         {
00202                                 
00203                                 $this->tpl->setVariable("VALUE_ARCHIVE", $this->object->getFlashFilename());
00204                                 
00205                         }
00206 
00207                         $this->tpl->setCurrentBlock("flashcode");
00208                         $this->tpl->setVariable("FLASH_ATTRIBUTES", $this->lng->txt("flash_attributes"));
00209                         $this->tpl->setVariable("TEXT_CODE", $this->lng->txt("code"));
00210                         $this->tpl->setVariable("TEXT_WIDTH", $this->lng->txt("width"));
00211                         $this->tpl->setVariable("TEXT_HEIGHT", $this->lng->txt("height"));
00212                         
00213                         $this->tpl->setVariable("VALUE_WIDTH", $this->object->getFlashWidth());
00214                         $this->tpl->setVariable("VALUE_HEIGHT", $this->object->getFlashHeight());
00215                         $this->tpl->setVariable("FLASH_PARAMETERS", $this->lng->txt("flash_parameters"));
00216                         $this->tpl->setVariable("VALUE_ADD_PARAMETER", $this->lng->txt("add_flash_parameter"));
00217                         $this->tpl->parseCurrentBlock();
00218                 }
00219 
00220                 $this->tpl->setCurrentBlock("HeadContent");
00221                 $this->tpl->addJavascript("./Services/JavaScript/js/Basic.js");
00222                 $javascript = "<script type=\"text/javascript\">ilAddOnLoad(initialSelect);\n".
00223                         "function initialSelect() {\n%s\n}</script>";
00224                 $this->tpl->setVariable("CONTENT_BLOCK", sprintf($javascript, "document.frm_javaapplet.title.focus();"));
00225                 $this->tpl->parseCurrentBlock();
00226                 $this->tpl->setCurrentBlock("question_data");
00227                 $this->tpl->setVariable("FLASHFILE_ID", $this->object->getId());
00228                 $this->tpl->setVariable("VALUE_FLASHFILE_TITLE", ilUtil::prepareFormOutput($this->object->getTitle()));
00229                 $this->tpl->setVariable("VALUE_FLASHFILE_COMMENT", ilUtil::prepareFormOutput($this->object->getComment()));
00230                 $this->tpl->setVariable("VALUE_FLASHFILE_AUTHOR", ilUtil::prepareFormOutput($this->object->getAuthor()));
00231                 $questiontext = $this->object->getQuestion();
00232                 $this->tpl->setVariable("VALUE_QUESTION", ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($questiontext)));
00233                 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
00234                 $this->tpl->setVariable("TEXT_AUTHOR", $this->lng->txt("author"));
00235                 $this->tpl->setVariable("TEXT_COMMENT", $this->lng->txt("description"));
00236                 $this->tpl->setVariable("TEXT_QUESTION", $this->lng->txt("question"));
00237                 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00238 
00239                 $this->tpl->setVariable("SAVE",$this->lng->txt("save"));
00240                 $this->tpl->setVariable("SAVE_EDIT", $this->lng->txt("save_edit"));
00241                 $this->tpl->setVariable("CANCEL",$this->lng->txt("cancel"));
00242                 $this->ctrl->setParameter($this, "sel_question_types", "assFlashApp");
00243                 $this->tpl->setVariable("TEXT_QUESTION_TYPE", $this->lng->txt("assFlashApp"));
00244                 $formaction = $this->ctrl->getFormaction($this);
00245                 if ($this->object->getId() > 0)
00246                 {
00247                         if (!preg_match("/q_id\=\d+/", $formaction))
00248                         {
00249                                 $formaction = str_replace("q_id=", "q_id=" . $this->object->getId(), $formaction);
00250                         }
00251                 }
00252                 $this->tpl->setVariable("ACTION_FLASH_QUESTION", $formaction);
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"); $rte->addButton("pastelatex");
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         }
00270 
00271 
00275         function uploadingFlash()
00276         {
00277                 $result = $this->writePostData();
00278                 if ($result == 0)
00279                 {
00280                         $this->object->saveToDb();
00281                 }
00282                 $this->editQuestion();
00283         }
00284 
00285 
00289         function removeFlash()
00290         {
00291                 $this->object->deleteFlashFilename();
00292                 $this->object->saveToDb();
00293                 $this->editQuestion();
00294         }
00295 
00299         function addParameter()
00300         {
00301                 $this->writePostData();
00302                 $this->editQuestion();
00303         }
00304 
00308         function delete()
00309         {
00310                 $this->writePostData();
00311                 $this->editQuestion();
00312         }
00313 
00322         function writePostData()
00323         {
00324                 $result = 0;
00325                 $saved = false;
00326                 if (!$this->checkInput())
00327                 {
00328                         $result = 1;
00329                 }
00330                 $this->object->setTitle(ilUtil::stripSlashes($_POST["title"]));
00331                 $this->object->setAuthor(ilUtil::stripSlashes($_POST["author"]));
00332                 $this->object->setComment(ilUtil::stripSlashes($_POST["comment"]));
00333                 include_once "./classes/class.ilObjAdvancedEditing.php";
00334                 $questiontext = ilUtil::stripSlashes($_POST["question"], true, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment"));
00335                 $this->object->setQuestion($questiontext);
00336                 $this->object->setSuggestedSolution($_POST["solution_hint"], 0);
00337                 $this->object->setShuffle($_POST["shuffle"]);
00338                 $this->object->setPoints($_POST["flash_points"]);
00339                 if ($_POST["flash_points"] < 0)
00340                 {
00341                         $result = 1;
00342                         $this->setErrorMessage($this->lng->txt("negative_points_not_allowed"));
00343                 }
00344                 // adding estimated working time
00345                 $saved = $saved | $this->writeOtherPostData($result);
00346 
00347                 if ($result == 0)
00348                 {
00349                         //setting java applet
00350                         if (empty($_FILES['flashfileName']['tmp_name']))
00351                         {
00352                                 $this->object->setFlashFilename(ilUtil::stripSlashes($_POST['uploaded_flashfile']));
00353                         }
00354                         else
00355                         {
00356                                 if ($this->object->getId() < 1)
00357                                 {
00358                                         $saved = 1;
00359                                         $this->object->saveToDb();
00360                                 }
00361                                 $this->object->setFlashFilename($_FILES['flashfileName']['name'], $_FILES['flashfileName']['tmp_name']);
00362                         }
00363                         if ((strlen($this->object->getTitle()) > 0) && (strlen($this->object->getAuthor()) > 0) && (strlen($this->object->getQuestion()) > 0) && ($this->object->getPoints() > 0) && array_key_exists("flash_height", $_POST))
00364                         {
00365 
00366                                 //$this->object->setJavaArchive($_POST["java_archive"]);
00367                                 $this->object->setFlashWidth($_POST["flash_width"]);
00368                                 $this->object->setFlashHeight($_POST["flash_height"]);
00369                                 if ((!$_POST["flash_width"]) or (!$_POST["flash_height"])) $result = 1;
00370                                 $this->object->flushParams();
00371                                 foreach ($_POST as $key => $value)
00372                                 {
00373                                         if (preg_match("/param_name_(\d+)/", $key, $matches))
00374                                         {
00375                                                 $this->object->addParameterAtIndex($matches[1], $value, $_POST["param_value_$matches[1]"]);
00376                                         }
00377                                 }
00378                                 if (preg_match("/delete_(\d+)/", $this->ctrl->getCmd(), $matches))
00379                                 {
00380                                         $this->object->removeParameter($_POST["param_name_$matches[1]"]);
00381                                 }
00382                         }
00383                 }
00384                 if ($saved)
00385                 {
00386                         $this->object->saveToDb();
00387                         $this->error .= $this->lng->txt("question_saved_for_upload");
00388                 }
00389                 return $result;
00390         }
00391 
00392         function outQuestionForTest($formaction, $active_id, $pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE)
00393         {
00394                 $test_output = $this->getTestOutput($active_id, $pass, $is_postponed, $use_post_solutions); 
00395                 $this->tpl->setVariable("QUESTION_OUTPUT", $test_output);
00396                 $this->tpl->setVariable("FORMACTION", $formaction);
00397         }
00398 
00399         function getSolutionOutput($active_id, $pass = NULL, $graphicalOutput = FALSE, $result_output = FALSE, $show_question_only = TRUE, $show_feedback = FALSE)
00400         {
00401                 $userdata = $this->object->getActiveUserData($active_id);
00402 
00403                 // generate the question output
00404                 include_once "./classes/class.ilTemplate.php";
00405                 include_once "./Modules/Test/classes/class.ilObjTest.php";
00406                 $template = new ilTemplate("tpl.il_as_qpl_flashapp_question_output_solution.html", TRUE, TRUE, "Modules/TestQuestionPool");
00407                 $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html",TRUE, TRUE, "Modules/TestQuestionPool");
00408 
00409                 if ($active_id)
00410                 {
00411                         $this->createTmpData($active_id);
00412                                 
00413                         // Variablen, die mittels GET an die Flashanwendung übergeben werden
00414                         // Diese dienen dazu das temporäre File zu lokalisieren TMP_PATH/SESSION
00415                         $template->setVariable("SESSION", $_COOKIE["PHPSESSID"]);
00416                         $template->setVariable("TMP_PATH", $this->object->getFlashPathWeb());
00417                 }
00418                 
00419                 $questiontext = $this->object->getQuestion();
00420                 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
00421                 $template->setVariable("VALUE_WIDTH", $this->object->getFlashWidth());
00422                 $template->setVariable("VALUE_HEIGHT", $this->object->getFlashHeight());
00423                 
00424 
00425                 if (strpos($this->object->getFlashFilename(), ".swf") !== FALSE)
00426                 {
00427                         $template->setVariable("FLASH_SRC", $this->object->getFlashPathWeb().$this->object->getFlashFilename());
00428                 }
00429         
00430 
00431                 if ($active_id)
00432                 {
00433                         if ($graphicalOutput)
00434                         {
00435                                 // output of ok/not ok icons for user entered solutions
00436                                 $reached_points = $this->object->getReachedPoints($active_id, $pass);
00437                                 if ($reached_points == $this->object->getMaximumPoints())
00438                                 {
00439                                         $template->setCurrentBlock("icon_ok");
00440                                         $template->setVariable("ICON_OK", ilUtil::getImagePath("icon_ok.gif"));
00441                                         $template->setVariable("TEXT_OK", $this->lng->txt("answer_is_right"));
00442                                         $template->parseCurrentBlock();
00443                                 }
00444                                 else
00445                                 {
00446                                         $template->setCurrentBlock("icon_ok");
00447                                         if ($reached_points > 0)
00448                                         {
00449                                                 $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_mostly_ok.gif"));
00450                                                 $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_not_correct_but_positive"));
00451                                         }
00452                                         else
00453                                         {
00454                                                 $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_not_ok.gif"));
00455                                                 $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_wrong"));
00456                                         }
00457                                         $template->parseCurrentBlock();
00458                                 }
00459                         }
00460                 }
00461                 $questionoutput = $template->get();
00462                 $feedback = ($show_feedback) ? $this->getAnswerFeedbackOutput($active_id, $pass) : "";
00463                 if (strlen($feedback)) $solutiontemplate->setVariable("FEEDBACK", $feedback);
00464                 $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
00465 
00466                 $solutionoutput = $solutiontemplate->get(); 
00467                 if (!$show_question_only)
00468                 {
00469                         // get page object output
00470                         $pageoutput = $this->getILIASPage();
00471                         $solutionoutput = preg_replace("/(<div( xmlns:xhtml\=\"http:\/\/www.w3.org\/1999\/xhtml\"){0,1} class\=\"ilc_Question\"><\/div>)/ims", "<div class=\"ilc_Question\">" . $solutionoutput . "</div>", $pageoutput);
00472                 }
00473                 return $solutionoutput;
00474         }
00475         
00476         function getQuestion()
00477         {
00478                 // generate the question output
00479                 include_once "./classes/class.ilTemplate.php";
00480                 $template = new ilTemplate("tpl.il_as_qpl_flashapp_question_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
00481                 
00482 
00483                 $questiontext = $this->object->getQuestion();
00484                 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
00485                 $template->setVariable("VALUE_WIDTH", $this->object->getFlashWidth());
00486                 $template->setVariable("VALUE_HEIGHT", $this->object->getFlashHeight());
00487                 
00488                 
00489                         if (strpos($this->object->getFlashFilename(), ".swf") !== FALSE)
00490                         {
00491                                 $template->setVariable("FLASH_SRC", $this->object->getFlashPathWeb().$this->object->getFlashFilename());
00492                                 
00493                         }
00494                 
00495                 $questionoutput = $template->get();
00496                 $questionoutput = preg_replace("/<div[^>]*?>(.*)<\/div>/is", "\\1", $questionoutput);
00497                 
00498                 //echo "flash_src".$this->object->getFlashPathWeb().$this->object->getFlashFilename();
00499                 return $questionoutput;
00500         }
00501         
00502         function getActiveUserData($active_id)
00503         {
00504                 global $ilDB;
00505                 $query = sprintf("SELECT * FROM tst_active WHERE active_id = %s",
00506                         $ilDB->quote($active_id . "")
00507                 );
00508                 $result = $ilDB->query($query);
00509                 if ($result->numRows())
00510                 {
00511                         $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
00512                         return array("user_id" => $row["user_fi"], "test_id" => $row["test_fi"]);
00513                 }
00514                 else
00515                 {
00516                         return array();
00517                 }
00518         }
00519         
00520         function getTestOutput($active_id, $pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE)
00521         {
00522                 $this->createTmpData($active_id);
00523                 
00524                 // get page object output
00525                 $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id);
00526                 $userdata = $this->getActiveUserData($active_id);
00527                 // generate the question output
00528                 include_once "./classes/class.ilTemplate.php";
00529                 $template = new ilTemplate("tpl.il_as_qpl_flashapp_question_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
00530                 
00531                 
00532                 // Variablen, die mittels GET an die Flashanwendung übergeben werden
00533                 // Diese dienen dazu das temporäre File zu lokalisieren TMP_PATH/SESSION
00534                 $template->setVariable("SESSION", $_COOKIE["PHPSESSID"]);
00535                 $template->setVariable("TMP_PATH", $this->object->getFlashPathWeb());
00536 
00537 
00538                 
00539                 
00540                 $questiontext = $this->object->getQuestion();
00541                 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
00542                 $template->setVariable("VALUE_WIDTH", $this->object->getFlashWidth());
00543                 $template->setVariable("VALUE_HEIGHT", $this->object->getFlashHeight());
00544                 
00545                 
00546                 
00547                         if (strpos($this->object->getFlashFilename(), ".swf") !== FALSE)
00548                         {
00549                                 //echo "via Flash... ";
00550                                 $template->setVariable("FLASH_SRC", $this->object->getFlashPathWeb().$this->object->getFlashFilename());
00551                         }
00552                 
00553                 $questionoutput = $template->get();
00554                 $questionoutput = str_replace("<div xmlns:xhtml=\"http://www.w3.org/1999/xhtml\" class=\"ilc_Question\"></div>", $questionoutput, $pageoutput);
00555                 return $questionoutput;
00556         }
00557         
00558         function getPreview($show_question_only = FALSE)
00559         {
00560                 $this->createTmpData($active_id);
00561                 
00562                 // get page object output
00563                 $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id);
00564                 $userdata = $this->getActiveUserData($active_id);
00565                 // generate the question output
00566                 include_once "./classes/class.ilTemplate.php";
00567                 $template = new ilTemplate("tpl.il_as_qpl_flashapp_question_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
00568                 
00569                 
00570                 // Variablen, die mittels GET an die Flashanwendung übergeben werden
00571                 // Diese dienen dazu das temporäre File zu lokalisieren TMP_PATH/SESSION
00572                 $template->setVariable("SESSION", $_COOKIE["PHPSESSID"]);
00573                 $template->setVariable("TMP_PATH", $this->object->getFlashPathWeb());
00574 
00575 
00576                 
00577                 
00578                 $questiontext = $this->object->getQuestion();
00579                 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
00580                 $template->setVariable("VALUE_WIDTH", $this->object->getFlashWidth());
00581                 $template->setVariable("VALUE_HEIGHT", $this->object->getFlashHeight());
00582                 
00583                 
00584                 
00585                         if (strpos($this->object->getFlashFilename(), ".swf") !== FALSE)
00586                         {
00587                                 //echo "via Flash... ";
00588                                 $template->setVariable("FLASH_SRC", $this->object->getFlashPathWeb().$this->object->getFlashFilename());
00589                         }
00590                 
00591                         $questionoutput = $template->get();
00592                         if (!$show_question_only)
00593                         {
00594                                 // get page object output
00595                                 $pageoutput = $this->getILIASPage();
00596                                 $questionoutput = preg_replace("/(<div( xmlns:xhtml\=\"http:\/\/www.w3.org\/1999\/xhtml\"){0,1} class\=\"ilc_Question\"><\/div>)/ims", $questionoutput, $pageoutput);
00597                         }
00598                         else
00599                         {
00600                                 $questionoutput = preg_replace("/<div[^>]*?>(.*)<\/div>/is", "\\1", $questionoutput);
00601                         }
00602 
00603                         return $questionoutput;
00604         }
00605 
00610          function createTmpData($active_id)
00611          {
00612                 $userdata = $this->getActiveUserData($active_id);
00613                 
00614                 include_once "./Modules/Test/classes/class.ilObjTest.php";
00615                 //$tmp_data =  "testtype=". ilObjTest::_getTestType($active_id);
00616                 $tmp_data .= "test_id=". $userdata["test_id"];
00617                 $tmp_data .= "&id=". $this->object->getId();
00618                 $tmp_data .= "&user_id=". $userdata["user_id"];
00619                 $tmp_data .= "&points=". $this->object->getPoints();
00620                 $tmp_data .= "&sessionid=". $_COOKIE["PHPSESSID"];
00621                 $tmp_data .= "&client_id=". CLIENT_ID;
00622                 $tmp_data .= "&pass=". ilObjTest::_getPass($active_id);
00623                 $tmp_data .= "&post_url=". ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/Modules/TestQuestionPool/save_flash_question_result.php";
00624                 if ($active_id)
00625                 {
00626                         $solutions = NULL;
00627                         if (!ilObjTest::_getUsePreviousAnswers($active_id, true))
00628                         {
00629                                 if (is_null($pass)) $pass = ilObjTest::_getPass($active_id);
00630                         }
00631                         $info = $this->object->getReachedInformation($active_id, $pass);
00632                         //echo sizeof($this->object->getReachedInformation(11, 3));
00633                         foreach ($info as $kk => $infodata)
00634                         {
00635                                 $tmp_data .= "&value_" . $infodata["order"] . "_1=";
00636                                 $tmp_data .= $infodata["value1"];
00637                         }
00638                 }
00639                 
00640                 $questiontext = $this->object->getQuestion();
00641                 $tmp_data .= "&width=". $this->object->getFlashWidth();
00642                 $tmp_data .= "&height=". $this->object->getFlashHeight();
00643                 
00644                 
00645                         if (strpos($this->object->getFlashFilename(), ".swf") !== FALSE)
00646                         {
00647                                 $tmp_data .= "&flash_src=". $this->object->getFlashPathWeb().$this->object->getFlashFilename();
00648                         }
00649                 
00650                 
00651         // temporäres File wird geschrieben
00652         //echo $tmp_data;
00653                         if (!$this->object->writeTmpFile($tmp_data))
00654                         die ("Not able to create tmp data file!");      
00655          }
00656          
00660         function checkInput()
00661         {
00662                 
00663                 if ((strlen($_POST["title"]) == 0) or (strlen($_POST["author"]) == 0) or (strlen($_POST["question"]) == 0) or (strlen($_POST["flash_points"]) == 0))
00664                 {
00665                         $this->error .= $this->lng->txt("fill_out_all_required_fields");
00666                         return false;
00667                 }
00668                 return true;
00669         }
00670 
00671 
00672         function addSuggestedSolution()
00673         {
00674                 $_SESSION["subquestion_index"] = 0;
00675                 if ($_POST["cmd"]["addSuggestedSolution"])
00676                 {
00677                         if ($this->writePostData())
00678                         {
00679                                 ilUtil::sendInfo($this->getErrorMessage());
00680                                 $this->editQuestion();
00681                                 return;
00682                         }
00683                         if ($result != 0)
00684                         {
00685                                 $this->editQuestion();
00686                                 return;
00687                         }
00688                 }
00689                 $this->object->saveToDb();
00690                 $this->ctrl->setParameter($this, "q_id", $this->object->getId());
00691                 $this->tpl->setVariable("HEADER", $this->object->getTitle());
00692                 $this->getQuestionTemplate();
00693                 parent::addSuggestedSolution();
00694         }
00695 
00703         function setQuestionTabs()
00704         {
00705                 global $rbacsystem, $ilTabs;
00706                 
00707                 $this->ctrl->setParameterByClass("ilpageobjectgui", "q_id", $_GET["q_id"]);
00708                 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
00709                 $q_type = $this->object->getQuestionType();
00710 
00711                 if (strlen($q_type))
00712                 {
00713                         $classname = $q_type . "GUI";
00714                         $this->ctrl->setParameterByClass(strtolower($classname), "sel_question_types", $q_type);
00715                         $this->ctrl->setParameterByClass(strtolower($classname), "q_id", $_GET["q_id"]);
00716                 }
00717 
00718                 if ($_GET["q_id"])
00719                 {
00720                         if ($rbacsystem->checkAccess('write', $_GET["ref_id"]))
00721                         {
00722                                 // edit page
00723                                 $ilTabs->addTarget("edit_content",
00724                                         $this->ctrl->getLinkTargetByClass("ilPageObjectGUI", "view"),
00725                                         array("view", "insert", "exec_pg"),
00726                                         "", "", $force_active);
00727                         }
00728         
00729                         // edit page
00730                         $ilTabs->addTarget("preview",
00731                                 $this->ctrl->getLinkTargetByClass("ilPageObjectGUI", "preview"),
00732                                 array("preview"),
00733                                 "ilPageObjectGUI", "", $force_active);
00734                 }
00735 
00736                 $force_active = false;
00737                 $commands = $_POST["cmd"];
00738                 if (is_array($commands))
00739                 {
00740                         foreach ($commands as $key => $value)
00741                         {
00742                                 if (preg_match("/^delete_.*/", $key, $matches) || 
00743                                         preg_match("/^addSelectGapText_.*/", $key, $matches) ||
00744                                         preg_match("/^addGapText_.*/", $key, $matches) ||
00745                                         preg_match("/^upload_.*/", $key, $matches) ||
00746                                         preg_match("/^addSuggestedSolution_.*/", $key, $matches) ||
00747                                         preg_match("/^removeSuggestedSolution_.*/", $key, $matches)
00748                                         )
00749                                 {
00750                                         $force_active = true;
00751                                 }
00752                         }
00753                 }
00754                 if ($rbacsystem->checkAccess('write', $_GET["ref_id"]))
00755                 {
00756                         $url = "";
00757                         if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname, "editQuestion");
00758                         // edit question properties
00759                         $ilTabs->addTarget("edit_properties",
00760                                 $url,
00761                                 array("editQuestion", "save", "cancel", "addSuggestedSolution",
00762                                          "cancelExplorer", "linkChilds", "removeSuggestedSolution",
00763                                          "createGaps", "saveEdit", "changeGapType"),
00764                                 $classname, "", $force_active);
00765                 }
00766 
00767                 if ($_GET["q_id"])
00768                 {
00769                         $ilTabs->addTarget("feedback",
00770                                 $this->ctrl->getLinkTargetByClass($classname, "feedback"),
00771                                 array("feedback", "saveFeedback"),
00772                                 $classname, "");
00773                 }
00774                 
00775                 // Assessment of questions sub menu entry
00776                 if ($_GET["q_id"])
00777                 {
00778                         $ilTabs->addTarget("statistics",
00779                                 $this->ctrl->getLinkTargetByClass($classname, "assessment"),
00780                                 array("assessment"),
00781                                 $classname, "");
00782                 }
00783                 
00784                 if (($_GET["calling_test"] > 0) || ($_GET["test_ref_id"] > 0))
00785                 {
00786                         $ref_id = $_GET["calling_test"];
00787                         if (strlen($ref_id) == 0) $ref_id = $_GET["test_ref_id"];
00788                         $ilTabs->setBackTarget($this->lng->txt("backtocallingtest"), "ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
00789                 }
00790                 else
00791                 {
00792                         $ilTabs->setBackTarget($this->lng->txt("qpl"), $this->ctrl->getLinkTargetByClass("ilobjquestionpoolgui", "questions"));
00793                 }
00794         }
00795 
00803         function saveFeedback()
00804         {
00805                 include_once "./classes/class.ilObjAdvancedEditing.php";
00806                 $this->object->saveFeedbackGeneric(0, ilUtil::stripSlashes($_POST["feedback_incomplete"], false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment")));
00807                 $this->object->saveFeedbackGeneric(1, ilUtil::stripSlashes($_POST["feedback_complete"], false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment")));
00808                 $this->object->cleanupMediaObjectUsage();
00809 
00810                 // additional feedback processing
00811                 $this->feedback();
00812         }
00813 
00821         function feedback()
00822         {
00823                 $this->tpl->addBlockFile("ADM_CONTENT", "feedback", "tpl.il_as_qpl_mytype_feedback.html", "Modules/TestQuestionPool");
00824                 $this->tpl->setVariable("FEEDBACK_TEXT", $this->lng->txt("feedback"));
00825                 $this->tpl->setVariable("FEEDBACK_COMPLETE", $this->lng->txt("feedback_complete_solution"));
00826                 $this->tpl->setVariable("VALUE_FEEDBACK_COMPLETE", ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(1)), FALSE));
00827                 $this->tpl->setVariable("FEEDBACK_INCOMPLETE", $this->lng->txt("feedback_incomplete_solution"));
00828                 $this->tpl->setVariable("VALUE_FEEDBACK_INCOMPLETE", ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(0)), FALSE));
00829                 $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
00830                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00831                 
00832                 // additional feedback if needed
00833 
00834                 include_once "./Services/RTE/classes/class.ilRTE.php";
00835                 $rtestring = ilRTE::_getRTEClassname();
00836                 include_once "./Services/RTE/classes/class.$rtestring.php";
00837                 $rte = new $rtestring();
00838                 $rte->addPlugin("latex");
00839                 $rte->addButton("latex"); $rte->addButton("pastelatex");
00840                 include_once "./classes/class.ilObject.php";
00841                 $obj_id = $_GET["q_id"];
00842                 $obj_type = ilObject::_lookupType($_GET["ref_id"], TRUE);
00843                 $rte->addRTESupport($obj_id, $obj_type, "assessment");
00844         }
00845 
00846 }
00847 ?>

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