00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 include_once "./assessment/classes/class.assQuestion.php";
00024 include_once "./assessment/classes/inc.AssessmentConstants.php";
00025
00036 class ASS_JavaApplet extends ASS_Question
00037 {
00045 var $question;
00046
00054 var $javaapplet_filename;
00055
00063 var $java_code;
00064
00072 var $java_width;
00073
00081 var $java_height;
00082
00090 var $parameters;
00091
00107 function ASS_JavaApplet(
00108 $title = "",
00109 $comment = "",
00110 $author = "",
00111 $owner = -1,
00112 $question = "",
00113 $javaapplet_filename = ""
00114 )
00115 {
00116 $this->ASS_Question($title, $comment, $author, $owner);
00117 $this->question = $question;
00118 $this->javaapplet_filename = $javaapplet_filename;
00119 $this->parameters = array();
00120 }
00121
00122
00132 function to_xml($a_include_header = true, $a_include_binary = true, $a_shuffle = false, $test_output = false, $force_image_references = false)
00133 {
00134 include_once("./classes/class.ilXmlWriter.php");
00135 $a_xml_writer = new ilXmlWriter;
00136
00137 $a_xml_writer->xmlHeader();
00138 $a_xml_writer->xmlStartTag("questestinterop");
00139 $attrs = array(
00140 "ident" => "il_".IL_INST_ID."_qst_".$this->getId(),
00141 "title" => $this->getTitle()
00142 );
00143 $a_xml_writer->xmlStartTag("item", $attrs);
00144
00145 $a_xml_writer->xmlElement("qticomment", NULL, $this->getComment());
00146
00147 $workingtime = $this->getEstimatedWorkingTime();
00148 $duration = sprintf("P0Y0M0DT%dH%dM%dS", $workingtime["h"], $workingtime["m"], $workingtime["s"]);
00149 $a_xml_writer->xmlElement("duration", NULL, $duration);
00150
00151 $a_xml_writer->xmlStartTag("itemmetadata");
00152 $a_xml_writer->xmlStartTag("qtimetadata");
00153 $a_xml_writer->xmlStartTag("qtimetadatafield");
00154 $a_xml_writer->xmlElement("fieldlabel", NULL, "ILIAS_VERSION");
00155 $a_xml_writer->xmlElement("fieldentry", NULL, $this->ilias->getSetting("ilias_version"));
00156 $a_xml_writer->xmlEndTag("qtimetadatafield");
00157 $a_xml_writer->xmlStartTag("qtimetadatafield");
00158 $a_xml_writer->xmlElement("fieldlabel", NULL, "QUESTIONTYPE");
00159 $a_xml_writer->xmlElement("fieldentry", NULL, JAVAAPPLET_QUESTION_IDENTIFIER);
00160 $a_xml_writer->xmlEndTag("qtimetadatafield");
00161 $a_xml_writer->xmlStartTag("qtimetadatafield");
00162 $a_xml_writer->xmlElement("fieldlabel", NULL, "AUTHOR");
00163 $a_xml_writer->xmlElement("fieldentry", NULL, $this->getAuthor());
00164 $a_xml_writer->xmlEndTag("qtimetadatafield");
00165 $a_xml_writer->xmlEndTag("qtimetadata");
00166 $a_xml_writer->xmlEndTag("itemmetadata");
00167
00168
00169 $attrs = array(
00170 "label" => $this->getTitle()
00171 );
00172 $a_xml_writer->xmlStartTag("presentation", $attrs);
00173
00174 $a_xml_writer->xmlStartTag("flow");
00175
00176 $a_xml_writer->xmlStartTag("material");
00177 $a_xml_writer->xmlElement("mattext", NULL, $this->getQuestion());
00178 $a_xml_writer->xmlEndTag("material");
00179 $solution = $this->getSuggestedSolution(0);
00180 if (count($solution))
00181 {
00182 if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $solution["internal_link"], $matches))
00183 {
00184 $a_xml_writer->xmlStartTag("material");
00185 $intlink = "il_" . IL_INST_ID . "_" . $matches[2] . "_" . $matches[3];
00186 if (strcmp($matches[1], "") != 0)
00187 {
00188 $intlink = $solution["internal_link"];
00189 }
00190 $attrs = array(
00191 "label" => "suggested_solution"
00192 );
00193 $a_xml_writer->xmlElement("mattext", $attrs, $intlink);
00194 $a_xml_writer->xmlEndTag("material");
00195 }
00196 }
00197
00198 $a_xml_writer->xmlStartTag("material");
00199 $attrs = array(
00200 "label" => "applet data",
00201 "uri" => $this->getJavaAppletFilename(),
00202 "height" => $this->getJavaHeight(),
00203 "width" => $this->getJavaWidth(),
00204 "embedded" => "base64"
00205 );
00206 $javapath = $this->getJavaPath() . $this->getJavaAppletFilename();
00207 $fh = @fopen($javapath, "rb");
00208 if ($fh == false)
00209 {
00210 return;
00211 }
00212 $javafile = fread($fh, filesize($javapath));
00213 fclose($fh);
00214 $base64 = base64_encode($javafile);
00215 $a_xml_writer->xmlElement("matapplet", $attrs, $base64);
00216
00217 if ($this->buildParamsOnly())
00218 {
00219 if ($this->java_code)
00220 {
00221 $attrs = array(
00222 "label" => "java_code"
00223 );
00224 $a_xml_writer->xmlElement("mattext", $attrs, $this->java_code);
00225 }
00226 foreach ($this->parameters as $key => $value)
00227 {
00228 $attrs = array(
00229 "label" => $value["name"]
00230 );
00231 $a_xml_writer->xmlElement("mattext", $attrs, $value["value"]);
00232 }
00233 if ($test_output)
00234 {
00235 include_once "./assessment/classes/class.ilObjTest.php";
00236 $attrs = array(
00237 "label" => "test_type"
00238 );
00239 $a_xml_writer->xmlElement("mattext", $attrs, ilObjTest::_getTestType($test_output));
00240 $attrs = array(
00241 "label" => "test_id"
00242 );
00243 $a_xml_writer->xmlElement("mattext", $attrs, $test_output);
00244 $attrs = array(
00245 "label" => "question_id"
00246 );
00247 $a_xml_writer->xmlElement("mattext", $attrs, $this->getId());
00248 $attrs = array(
00249 "label" => "user_id"
00250 );
00251 global $ilUser;
00252 $a_xml_writer->xmlElement("mattext", $attrs, $ilUser->id);
00253 $attrs = array(
00254 "label" => "points_max"
00255 );
00256 $a_xml_writer->xmlElement("mattext", $attrs, $this->getPoints());
00257 $attrs = array(
00258 "label" => "session_id"
00259 );
00260 $a_xml_writer->xmlElement("mattext", $attrs, $_COOKIE["PHPSESSID"]);
00261 $attrs = array(
00262 "label" => "client"
00263 );
00264 $a_xml_writer->xmlElement("mattext", $attrs, CLIENT_ID);
00265 include_once "./assessment/classes/class.ilObjTest.php";
00266 $attrs = array(
00267 "label" => "pass"
00268 );
00269 $pass = ilObjTest::_getPass($ilUser->id, $test_output);
00270 $a_xml_writer->xmlElement("mattext", $attrs, $pass);
00271 $attrs = array(
00272 "label" => "post_url"
00273 );
00274
00275 $a_xml_writer->xmlElement("mattext", $attrs, ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/assessment/save_java_question_result.php");
00276
00277 $info = array();
00278 if (ilObjTest::_getHidePreviousResults($test_output, true))
00279 {
00280 $info = $this->getReachedInformation($ilUser->id, $test_output, $pass);
00281 }
00282 else
00283 {
00284 $pass = $this->getSolutionMaxPass($user_id, $test_output);
00285 $info = $this->getReachedInformation($ilUser->id, $test_output, $pass);
00286 }
00287 foreach ($info as $kk => $infodata)
00288 {
00289 $attrs = array(
00290 "label" => "value_" . $infodata["order"] . "_1"
00291 );
00292 $a_xml_writer->xmlElement("mattext", $attrs, $infodata["value1"]);
00293 $attrs = array(
00294 "label" => "value_" . $infodata["order"] . "_2"
00295 );
00296 $a_xml_writer->xmlElement("mattext", $attrs, $infodata["value2"]);
00297 }
00298 }
00299 }
00300 $a_xml_writer->xmlEndTag("material");
00301 $a_xml_writer->xmlStartTag("material");
00302 $attrs = array(
00303 "label" => "points"
00304 );
00305 $a_xml_writer->xmlElement("mattext", $attrs, $this->getPoints());
00306 $a_xml_writer->xmlEndTag("material");
00307
00308 $a_xml_writer->xmlEndTag("flow");
00309 $a_xml_writer->xmlEndTag("presentation");
00310
00311 $a_xml_writer->xmlEndTag("item");
00312 $a_xml_writer->xmlEndTag("questestinterop");
00313
00314 $xml = $a_xml_writer->xmlDumpMem(FALSE);
00315 if (!$a_include_header)
00316 {
00317 $pos = strpos($xml, "?>");
00318 $xml = substr($xml, $pos + 2);
00319 }
00320 return $xml;
00321 }
00322
00331 function splitParams($params = "")
00332 {
00333 $params_array = split("<separator>", $params);
00334 foreach ($params_array as $pair)
00335 {
00336 if (preg_match("/(.*?)\=(.*)/", $pair, $matches))
00337 {
00338 switch ($matches[1])
00339 {
00340 case "java_code" :
00341 $this->java_code = $matches[2];
00342 break;
00343 case "java_width" :
00344 $this->java_width = $matches[2];
00345 break;
00346 case "java_height" :
00347 $this->java_height = $matches[2];
00348 break;
00349 }
00350 if (preg_match("/param_name_(\d+)/", $matches[1], $found_key))
00351 {
00352 $this->parameters[$found_key[1]]["name"] = $matches[2];
00353 }
00354 if (preg_match("/param_value_(\d+)/", $matches[1], $found_key))
00355 {
00356 $this->parameters[$found_key[1]]["value"] = $matches[2];
00357 }
00358 }
00359 }
00360 }
00361
00370 function buildParams()
00371 {
00372 $params_array = array();
00373 if ($this->java_code)
00374 {
00375 array_push($params_array, "java_code=$this->java_code");
00376 }
00377 if ($this->java_width)
00378 {
00379 array_push($params_array, "java_width=$this->java_width");
00380 }
00381 if ($this->java_height)
00382 {
00383 array_push($params_array, "java_height=$this->java_height");
00384 }
00385 foreach ($this->parameters as $key => $value)
00386 {
00387 array_push($params_array, "param_name_$key=" . $value["name"]);
00388 array_push($params_array, "param_value_$key=" . $value["value"]);
00389 }
00390 return join($params_array, "<separator>");
00391 }
00392
00401 function buildParamsOnly()
00402 {
00403 $params_array = array();
00404 if ($this->java_code)
00405 {
00406 array_push($params_array, "java_code=$this->java_code");
00407 }
00408 foreach ($this->parameters as $key => $value)
00409 {
00410 array_push($params_array, "param_name_$key=" . $value["name"]);
00411 array_push($params_array, "param_value_$key=" . $value["value"]);
00412 }
00413 return join($params_array, "<separator>");
00414 }
00415
00424 function isComplete()
00425 {
00426 if (($this->title) and ($this->author) and ($this->question) and ($this->javaapplet_filename) and ($this->java_width) and ($this->java_height) and ($this->getMaximumPoints() > 0))
00427 {
00428 return true;
00429 }
00430 else
00431 {
00432 return false;
00433 }
00434 }
00435
00436
00445 function saveToDb($original_id = "")
00446 {
00447 global $ilias;
00448
00449 $complete = 0;
00450 if ($this->isComplete())
00451 {
00452 $complete = 1;
00453 }
00454
00455 $db = & $ilias->db;
00456
00457 $params = $this->buildParams();
00458 $estw_time = $this->getEstimatedWorkingTime();
00459 $estw_time = sprintf("%02d:%02d:%02d", $estw_time['h'], $estw_time['m'], $estw_time['s']);
00460
00461 if ($original_id)
00462 {
00463 $original_id = $db->quote($original_id);
00464 }
00465 else
00466 {
00467 $original_id = "NULL";
00468 }
00469
00470 if ($this->id == -1)
00471 {
00472
00473 $now = getdate();
00474 $question_type = $this->getQuestionType();
00475 $created = sprintf("%04d%02d%02d%02d%02d%02d", $now['year'], $now['mon'], $now['mday'], $now['hours'], $now['minutes'], $now['seconds']);
00476 $query = sprintf("INSERT INTO qpl_questions (question_id, question_type_fi, obj_fi, title, comment, author, owner, question_text, points, working_time, shuffle, complete, image_file, params, created, original_id, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, NULL)",
00477 $db->quote($question_type . ""),
00478 $db->quote($this->obj_id . ""),
00479 $db->quote($this->title . ""),
00480 $db->quote($this->comment . ""),
00481 $db->quote($this->author . ""),
00482 $db->quote($this->owner . ""),
00483 $db->quote($this->question . ""),
00484 $db->quote($this->points . ""),
00485 $db->quote($estw_time . ""),
00486 $db->quote($this->shuffle . ""),
00487 $db->quote($complete . ""),
00488 $db->quote($this->javaapplet_filename . ""),
00489 $db->quote($params . ""),
00490 $db->quote($created . ""),
00491 $original_id
00492 );
00493
00494 $result = $db->query($query);
00495 if ($result == DB_OK)
00496 {
00497 $this->id = $this->ilias->db->getLastInsertId();
00498
00499
00500 $this->createPageObject();
00501
00502
00503 if ($this->getTestId() > 0)
00504 {
00505 $this->insertIntoTest($this->getTestId());
00506 }
00507 }
00508 }
00509 else
00510 {
00511
00512 $query = sprintf("UPDATE qpl_questions SET obj_fi = %s, title = %s, comment = %s, author = %s, question_text = %s, points = %s, working_time=%s, shuffle = %s, complete = %s, image_file = %s, params = %s WHERE question_id = %s",
00513 $db->quote($this->obj_id. ""),
00514 $db->quote($this->title . ""),
00515 $db->quote($this->comment . ""),
00516 $db->quote($this->author . ""),
00517 $db->quote($this->question . ""),
00518 $db->quote($this->points . ""),
00519 $db->quote($estw_time . ""),
00520 $db->quote($this->shuffle . ""),
00521 $db->quote($complete . ""),
00522 $db->quote($this->javaapplet_filename . ""),
00523 $db->quote($params . ""),
00524 $db->quote($this->id . "")
00525 );
00526 $result = $db->query($query);
00527 }
00528 parent::saveToDb($original_id);
00529 }
00530
00540 function loadFromDb($question_id)
00541 {
00542 global $ilias;
00543
00544 $db = & $ilias->db;
00545 $query = sprintf("SELECT * FROM qpl_questions WHERE question_id = %s",
00546 $db->quote($question_id)
00547 );
00548 $result = $db->query($query);
00549
00550 if (strcmp(strtolower(get_class($result)), db_result) == 0)
00551 {
00552 if ($result->numRows() == 1)
00553 {
00554 $data = $result->fetchRow(DB_FETCHMODE_OBJECT);
00555 $this->id = $question_id;
00556 $this->title = $data->title;
00557 $this->comment = $data->comment;
00558 $this->obj_id = $data->obj_fi;
00559 $this->author = $data->author;
00560 $this->points = $data->points;
00561 $this->owner = $data->owner;
00562 $this->original_id = $data->original_id;
00563 $this->javaapplet_filename = $data->image_file;
00564 $this->question = $data->question_text;
00565 $this->solution_hint = $data->solution_hint;
00566 $this->splitParams($data->params);
00567 $this->setShuffle($data->shuffle);
00568 $this->setEstimatedWorkingTime(substr($data->working_time, 0, 2), substr($data->working_time, 3, 2), substr($data->working_time, 6, 2));
00569 }
00570 }
00571 parent::loadFromDb($question_id);
00572 }
00573
00581 function duplicate($for_test = true, $title = "", $author = "", $owner = "")
00582 {
00583 if ($this->id <= 0)
00584 {
00585
00586 return;
00587 }
00588
00589 $this_id = $this->getId();
00590 $clone = $this;
00591 include_once ("./assessment/classes/class.assQuestion.php");
00592 $original_id = ASS_Question::_getOriginalId($this->id);
00593 $clone->id = -1;
00594 if ($title)
00595 {
00596 $clone->setTitle($title);
00597 }
00598 if ($author)
00599 {
00600 $clone->setAuthor($author);
00601 }
00602 if ($owner)
00603 {
00604 $clone->setOwner($owner);
00605 }
00606 if ($for_test)
00607 {
00608 $clone->saveToDb($original_id);
00609 }
00610 else
00611 {
00612 $clone->saveToDb();
00613 }
00614
00615
00616 $clone->copyPageOfQuestion($this_id);
00617
00618
00619 $clone->duplicateApplet($this_id);
00620 return $clone->id;
00621 }
00622
00630 function copyObject($target_questionpool, $title = "")
00631 {
00632 if ($this->id <= 0)
00633 {
00634
00635 return;
00636 }
00637
00638 $clone = $this;
00639 include_once ("./assessment/classes/class.assQuestion.php");
00640 $original_id = ASS_Question::_getOriginalId($this->id);
00641 $clone->id = -1;
00642 $source_questionpool = $this->getObjId();
00643 $clone->setObjId($target_questionpool);
00644 if ($title)
00645 {
00646 $clone->setTitle($title);
00647 }
00648 $clone->saveToDb();
00649
00650
00651 $clone->copyPageOfQuestion($original_id);
00652
00653
00654 $clone->copyApplet($original_id, $source_questionpool);
00655 return $clone->id;
00656 }
00657
00658 function duplicateApplet($question_id)
00659 {
00660 $javapath = $this->getJavaPath();
00661 $javapath_original = preg_replace("/([^\d])$this->id([^\d])/", "\${1}$question_id\${2}", $javapath);
00662 if (!file_exists($javapath))
00663 {
00664 ilUtil::makeDirParents($javapath);
00665 }
00666 $filename = $this->getJavaAppletFilename();
00667 if (!copy($javapath_original . $filename, $javapath . $filename)) {
00668 print "java applet could not be duplicated!!!! ";
00669 }
00670 }
00671
00672 function copyApplet($question_id, $source_questionpool)
00673 {
00674 $javapath = $this->getJavaPath();
00675 $javapath_original = preg_replace("/([^\d])$this->id([^\d])/", "\${1}$question_id\${2}", $javapath);
00676 $javapath_original = str_replace("/$this->obj_id/", "/$source_questionpool/", $javapath_original);
00677 if (!file_exists($javapath))
00678 {
00679 ilUtil::makeDirParents($javapath);
00680 }
00681 $filename = $this->getJavaAppletFilename();
00682 if (!copy($javapath_original . $filename, $javapath . $filename)) {
00683 print "java applet could not be copied!!!! ";
00684 }
00685 }
00686
00696 function getQuestion()
00697 {
00698 return $this->question;
00699 }
00700
00710 function setQuestion($question = "")
00711 {
00712 $this->question = $question;
00713 }
00714
00723 function getMaximumPoints()
00724 {
00725 return $this->points;
00726 }
00727
00736 function getJavaCode()
00737 {
00738 return $this->java_code;
00739 }
00740
00749 function setJavaCode($java_code = "")
00750 {
00751 $this->java_code = $java_code;
00752 }
00753
00762 function getJavaWidth()
00763 {
00764 return $this->java_width;
00765 }
00766
00775 function setJavaWidth($java_width = "")
00776 {
00777 $this->java_width = $java_width;
00778 }
00779
00788 function getJavaHeight()
00789 {
00790 return $this->java_height;
00791 }
00792
00801 function setJavaHeight($java_height = "")
00802 {
00803 $this->java_height = $java_height;
00804 }
00805
00817 function calculateReachedPoints($user_id, $test_id, $pass = NULL)
00818 {
00819 global $ilDB;
00820
00821 $found_values = array();
00822 if (is_null($pass))
00823 {
00824 $pass = $this->getSolutionMaxPass($user_id, $test_id);
00825 }
00826 $query = sprintf("SELECT * FROM tst_solutions WHERE user_fi = %s AND test_fi = %s AND question_fi = %s AND pass = %s",
00827 $ilDB->quote($user_id . ""),
00828 $ilDB->quote($test_id . ""),
00829 $ilDB->quote($this->getId() . ""),
00830 $ilDB->quote($pass . "")
00831 );
00832 $result = $ilDB->query($query);
00833 $points = 0;
00834 while ($data = $result->fetchRow(DB_FETCHMODE_OBJECT))
00835 {
00836 $points += $data->points;
00837 }
00838
00839
00840 $query = sprintf("SELECT * FROM tst_tests WHERE test_id = %s",
00841 $ilDB->quote($test_id)
00842 );
00843 $result = $ilDB->query($query);
00844 if ($result->numRows() == 1)
00845 {
00846 $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
00847 if ($row["count_system"] == 1)
00848 {
00849 if ($points != $this->getMaximumPoints())
00850 {
00851 $points = 0;
00852 }
00853 }
00854 }
00855 else
00856 {
00857 $points = 0;
00858 }
00859 return $points;
00860 }
00861
00871 function getReachedInformation($user_id, $test_id, $pass = NULL)
00872 {
00873 $found_values = array();
00874 if (is_null($pass))
00875 {
00876 $pass = $this->getSolutionMaxPass($user_id, $test_id);
00877 }
00878 $query = sprintf("SELECT * FROM tst_solutions WHERE user_fi = %s AND test_fi = %s AND question_fi = %s AND pass = %s",
00879 $this->ilias->db->quote($user_id . ""),
00880 $this->ilias->db->quote($test_id . ""),
00881 $this->ilias->db->quote($this->getId() . ""),
00882 $this->ilias->db->quote($pass . "")
00883 );
00884 $result = $this->ilias->db->query($query);
00885 $counter = 1;
00886 $user_result = array();
00887 while ($data = $result->fetchRow(DB_FETCHMODE_OBJECT))
00888 {
00889 $true = 0;
00890 if ($data->points > 0)
00891 {
00892 $true = 1;
00893 }
00894 $solution = array(
00895 "order" => "$counter",
00896 "points" => "$data->points",
00897 "true" => "$true",
00898 "value1" => "$data->value1",
00899 "value2" => "$data->value2",
00900 );
00901 $counter++;
00902 array_push($user_result, $solution);
00903 }
00904 return $user_result;
00905 }
00906
00917 function addParameter($name = "", $value = "")
00918 {
00919 $index = $this->getParameterIndex($name);
00920 if ($index > -1)
00921 {
00922 $this->parameters[$index] = array("name" => $name, "value" => $value);
00923 }
00924 else
00925 {
00926 array_push($this->parameters, array("name" => $name, "value" => $value));
00927 }
00928 }
00929
00941 function addParameterAtIndex($index = 0, $name = "", $value = "")
00942 {
00943 $this->parameters[$index] = array("name" => $name, "value" => $value);
00944 }
00945
00955 function removeParameter($name)
00956 {
00957 foreach ($this->parameters as $key => $value)
00958 {
00959 if (strcmp($name, $value["name"]) == 0)
00960 {
00961 array_splice($this->parameters, $key, 1);
00962 return;
00963 }
00964 }
00965 }
00966
00977 function getParameter($index)
00978 {
00979 if (($index < 0) or ($index >= count($this->parameters)))
00980 {
00981 return undef;
00982 }
00983 return $this->parameters[$index];
00984 }
00985
00996 function getParameterIndex($name)
00997 {
00998 foreach ($this->parameters as $key => $value)
00999 {
01000 if (array_key_exists($name, $value))
01001 {
01002 return $key;
01003 }
01004 }
01005 return -1;
01006 }
01007
01017 function getParameterCount()
01018 {
01019 return count($this->parameters);
01020 }
01021
01030 function flushParams()
01031 {
01032 $this->parameters = array();
01033 }
01034
01045 function saveWorkingData($test_id, $pass = NULL)
01046 {
01047 parent::saveWorkingData($test_id, $pass);
01048 return true;
01049 }
01050
01060 function getJavaAppletFilename()
01061 {
01062 return $this->javaapplet_filename;
01063 }
01064
01074 function setJavaAppletFilename($javaapplet_filename, $javaapplet_tempfilename = "")
01075 {
01076 if (!empty($javaapplet_filename))
01077 {
01078 $this->javaapplet_filename = $javaapplet_filename;
01079 }
01080 if (!empty($javaapplet_tempfilename))
01081 {
01082 $javapath = $this->getJavaPath();
01083 if (!file_exists($javapath))
01084 {
01085 ilUtil::makeDirParents($javapath);
01086 }
01087
01088
01089 if (!ilUtil::moveUploadedFile($javaapplet_tempfilename, $javaapplet_filename, $javapath.$javaapplet_filename))
01090 {
01091 print "java applet not uploaded!!!! ";
01092 }
01093 }
01094 }
01095
01096 function syncWithOriginal()
01097 {
01098 global $ilias;
01099 if ($this->original_id)
01100 {
01101 $complete = 0;
01102 if ($this->isComplete())
01103 {
01104 $complete = 1;
01105 }
01106 $db = & $ilias->db;
01107
01108 $estw_time = $this->getEstimatedWorkingTime();
01109 $estw_time = sprintf("%02d:%02d:%02d", $estw_time['h'], $estw_time['m'], $estw_time['s']);
01110
01111 $query = sprintf("UPDATE qpl_questions SET obj_fi = %s, title = %s, comment = %s, author = %s, question_text = %s, points = %s, working_time=%s, shuffle = %s, complete = %s, image_file = %s, params = %s WHERE question_id = %s",
01112 $db->quote($this->obj_id. ""),
01113 $db->quote($this->title . ""),
01114 $db->quote($this->comment . ""),
01115 $db->quote($this->author . ""),
01116 $db->quote($this->question . ""),
01117 $db->quote($this->points . ""),
01118 $db->quote($estw_time . ""),
01119 $db->quote($this->shuffle . ""),
01120 $db->quote($complete . ""),
01121 $db->quote($this->javaapplet_filename . ""),
01122 $db->quote($params . ""),
01123 $db->quote($this->original_id . "")
01124 );
01125 $result = $db->query($query);
01126
01127 parent::syncWithOriginal();
01128 }
01129 }
01130
01139 function getQuestionType()
01140 {
01141 return 7;
01142 }
01143 }
01144
01145 ?>