ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.assJavaAppletGUI.php
Go to the documentation of this file.
1 <?php
2  /*
3  +----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +----------------------------------------------------------------------------+
22 */
23 
24 include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
25 include_once "./Modules/Test/classes/inc.AssessmentConstants.php";
26 
38 {
47  function __construct($id = -1)
48  {
50  include_once "./Modules/TestQuestionPool/classes/class.assJavaApplet.php";
51  $this->object = new assJavaApplet();
52  if ($id >= 0)
53  {
54  $this->object->loadFromDb($id);
55  }
56  }
57 
58  function getCommand($cmd)
59  {
60  if (substr($cmd, 0, 6) == "delete")
61  {
62  $cmd = "delete";
63  }
64  return $cmd;
65  }
66 
73  function writePostData($always = false)
74  {
75  $hasErrors = (!$always) ? $this->editQuestion(true) : false;
76  if (!$hasErrors)
77  {
78  $this->object->setTitle($_POST["title"]);
79  $this->object->setAuthor($_POST["author"]);
80  $this->object->setComment($_POST["comment"]);
81  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
82  $questiontext = $_POST["question"];
83  $this->object->setQuestion($questiontext);
84  $this->object->setEstimatedWorkingTime(
85  $_POST["Estimated"]["hh"],
86  $_POST["Estimated"]["mm"],
87  $_POST["Estimated"]["ss"]
88  );
89  $this->object->setPoints($_POST["points"]);
90 
91  if ($_POST['delete_applet'])
92  {
93  // delete the applet file
94  $this->object->deleteJavaAppletFilename();
95  }
96  else
97  {
98  $this->object->setJavaAppletFilename($_POST['uploaded_javaapplet']);
99  }
100 
101  //setting java applet
102  if (!empty($_FILES['javaappletName']['tmp_name']))
103  {
104  $this->object->setJavaAppletFilename($_FILES['javaappletName']['name'], $_FILES['javaappletName']['tmp_name']);
105  }
106  $this->object->setJavaCode($_POST["java_code"]);
107  $this->object->setJavaCodebase($_POST["java_codebase"]);
108  $this->object->setJavaArchive($_POST["java_archive"]);
109  $this->object->setJavaWidth($_POST["java_width"]);
110  $this->object->setJavaHeight($_POST["java_height"]);
111 
112  $this->object->flushParams();
113  if (is_array($_POST['kvp']['key']))
114  {
115  foreach ($_POST['kvp']['key'] as $idx => $val)
116  {
117  if (strlen($val) && strlen($_POST['kvp']['value'][$idx]))
118  {
119  $this->object->addParameter($val, $_POST['kvp']['value'][$idx]);
120  }
121  }
122  }
123  return 0;
124  }
125  else
126  {
127  return 1;
128  }
129  }
130 
136  public function editQuestion($checkonly = FALSE)
137  {
138  $save = ((strcmp($this->ctrl->getCmd(), "save") == 0) || (strcmp($this->ctrl->getCmd(), "saveEdit") == 0)) ? TRUE : FALSE;
139  $this->getQuestionTemplate();
140 
141  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
142  $form = new ilPropertyFormGUI();
143  $form->setFormAction($this->ctrl->getFormAction($this));
144  $form->setTitle($this->outQuestionType());
145  $form->setMultipart(true);
146  $form->setTableWidth("100%");
147  $form->setId("assjavaapplet");
148 
149  $this->addBasicQuestionFormProperties($form);
150 
151  // points
152  $points = new ilNumberInputGUI($this->lng->txt("points"), "points");
153  $points->setValue($this->object->getPoints());
154  $points->setRequired(TRUE);
155  $points->setSize(3);
156  $points->setMinValue(0.0);
157  $form->addItem($points);
158 
159  $header = new ilFormSectionHeaderGUI();
160  $header->setTitle($this->lng->txt("applet_attributes"));
161  $form->addItem($header);
162 
163  // java applet
164  $javaapplet = $this->object->getJavaAppletFilename();
165  $applet = new ilFileInputGUI($this->lng->txt('javaapplet'), 'javaappletName');
166  $applet->setSuffixes(array('jar','class'));
167  $applet->setRequired(false);
168 
169  if (strlen($javaapplet))
170  {
171  $filename = new ilNonEditableValueGUI($this->lng->txt('filename'), 'uploaded_javaapplet');
172  $filename->setValue($javaapplet);
173  $applet->addSubItem($filename);
174 
175  $delete = new ilCheckboxInputGUI('', 'delete_applet');
176  $delete->setOptionTitle($this->lng->txt('delete'));
177  $delete->setValue(1);
178  $applet->addSubItem($delete);
179  }
180  $form->addItem($applet);
181 
182  // Code
183  $code = new ilTextInputGUI($this->lng->txt("code"), "java_code");
184  $code->setValue($this->object->getJavaCode());
185  $code->setRequired(TRUE);
186  $form->addItem($code);
187 
188  if (!strlen($javaapplet))
189  {
190  // Archive
191  $archive = new ilTextInputGUI($this->lng->txt("archive"), "java_archive");
192  $archive->setValue($this->object->getJavaArchive());
193  $archive->setRequired(false);
194  $form->addItem($archive);
195 
196  // Codebase
197  $codebase = new ilTextInputGUI($this->lng->txt("codebase"), "java_codebase");
198  $codebase->setValue($this->object->getJavaCodebase());
199  $codebase->setRequired(false);
200  $form->addItem($codebase);
201  }
202 
203  // Width
204  $width = new ilNumberInputGUI($this->lng->txt("width"), "java_width");
205  $width->setDecimals(0);
206  $width->setSize(6);
207  $width->setMinValue(50);
208  $width->setMaxLength(6);
209  $width->setValue($this->object->getJavaWidth());
210  $width->setRequired(TRUE);
211  $form->addItem($width);
212 
213  // Height
214  $height = new ilNumberInputGUI($this->lng->txt("height"), "java_height");
215  $height->setDecimals(0);
216  $height->setSize(6);
217  $height->setMinValue(50);
218  $height->setMaxLength(6);
219  $height->setValue($this->object->getJavaHeight());
220  $height->setRequired(TRUE);
221  $form->addItem($height);
222 
223  $header = new ilFormSectionHeaderGUI();
224  $header->setTitle($this->lng->txt("applet_parameters"));
225  $form->addItem($header);
226 
227  include_once "./Modules/TestQuestionPool/classes/class.ilKVPWizardInputGUI.php";
228  $kvp = new ilKVPWizardInputGUI($this->lng->txt("applet_parameters"), "kvp");
229  $values = array();
230  for ($i = 0; $i < $this->object->getParameterCount(); $i++)
231  {
232  $param = $this->object->getParameter($i);
233  array_push($values, array($param['name'], $param['value']));
234  }
235  if (count($values) == 0)
236  {
237  array_push($values, array("", ""));
238  }
239  $kvp->setKeyName($this->lng->txt('name'));
240  $kvp->setValueName($this->lng->txt('value'));
241  $kvp->setValues($values);
242  $form->addItem($kvp);
243 
244  $this->addQuestionFormCommandButtons($form);
245 
246  $errors = false;
247 
248  if ($save)
249  {
250  $form->setValuesByPost();
251  $errors = !$form->checkInput();
252  $form->setValuesByPost(); // again, because checkInput now performs the whole stripSlashes handling and we need this if we don't want to have duplication of backslashes
253  if ($errors) $checkonly = false;
254  }
255 
256  if (!$checkonly) $this->tpl->setVariable("QUESTION_DATA", $form->getHTML());
257  return $errors;
258  }
259 
263  public function addkvp()
264  {
265  $this->writePostData(true);
266  $position = key($_POST['cmd']['addkvp']);
267  $this->object->addParameterAtIndex($position+1, "", "");
268  $this->editQuestion();
269  }
270 
274  public function removekvp()
275  {
276  $this->writePostData(true);
277  $position = key($_POST['cmd']['removekvp']);
278  $this->object->removeParameter($position);
279  $this->editQuestion();
280  }
281 
282  function outQuestionForTest($formaction, $active_id, $pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE)
283  {
284  $test_output = $this->getTestOutput($active_id, $pass, $is_postponed, $use_post_solutions);
285  $this->tpl->setVariable("QUESTION_OUTPUT", $test_output);
286  $this->tpl->setVariable("FORMACTION", $formaction);
287  }
288 
303  $active_id,
304  $pass = NULL,
305  $graphicalOutput = FALSE,
306  $result_output = FALSE,
307  $show_question_only = TRUE,
308  $show_feedback = FALSE,
309  $show_correct_solution = FALSE,
310  $show_manual_scoring = FALSE
311  )
312  {
313  $userdata = $this->object->getActiveUserData($active_id);
314 
315  // generate the question output
316  include_once "./classes/class.ilTemplate.php";
317  include_once "./Modules/Test/classes/class.ilObjTest.php";
318  $template = new ilTemplate("tpl.il_as_qpl_javaapplet_question_output_solution.html", TRUE, TRUE, "Modules/TestQuestionPool");
319  $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html",TRUE, TRUE, "Modules/TestQuestionPool");
320  if (strlen($userdata["test_id"]))
321  {
322  $template->setCurrentBlock("appletparam");
323  $template->setVariable("PARAM_NAME", "test_type");
325  {
326  $template->setVariable("PARAM_VALUE", "0");
327  }
328  else
329  {
330  $template->setVariable("PARAM_VALUE", "1");
331  }
332  $template->parseCurrentBlock();
333  }
334  if (strlen($userdata["test_id"]))
335  {
336  $template->setCurrentBlock("appletparam");
337  $template->setVariable("PARAM_NAME", "test_id");
338  $template->setVariable("PARAM_VALUE", $userdata["test_id"]);
339  $template->parseCurrentBlock();
340  }
341  $template->setCurrentBlock("appletparam");
342  $template->setVariable("PARAM_NAME", "active_id");
343  $template->setVariable("PARAM_VALUE", $active_id);
344  $template->parseCurrentBlock();
345  $template->setCurrentBlock("appletparam");
346  $template->setVariable("PARAM_NAME", "question_id");
347  $template->setVariable("PARAM_VALUE", $this->object->getId());
348  $template->parseCurrentBlock();
349  if (strlen($userdata["user_id"]))
350  {
351  $template->setCurrentBlock("appletparam");
352  $template->setVariable("PARAM_NAME", "user_id");
353  $template->setVariable("PARAM_VALUE", $userdata["user_id"]);
354  $template->parseCurrentBlock();
355  }
356  $template->setCurrentBlock("appletparam");
357  $template->setVariable("PARAM_NAME", "points_max");
358  $template->setVariable("PARAM_VALUE", $this->object->getPoints());
359  $template->parseCurrentBlock();
360  $template->setCurrentBlock("appletparam");
361  $template->setVariable("PARAM_NAME", "session_id");
362  $template->setVariable("PARAM_VALUE", $_COOKIE["PHPSESSID"]);
363  $template->parseCurrentBlock();
364  $template->setCurrentBlock("appletparam");
365  $template->setVariable("PARAM_NAME", "client");
366  $template->setVariable("PARAM_VALUE", CLIENT_ID);
367  $template->parseCurrentBlock();
368  $template->setCurrentBlock("appletparam");
369  $template->setVariable("PARAM_NAME", "pass");
370  $actualpass = ilObjTest::_getPass($active_id);
371  $template->setVariable("PARAM_VALUE", $actualpass);
372  $template->parseCurrentBlock();
373  // additional parameters
374  for ($i = 0; $i < $this->object->getParameterCount(); $i++)
375  {
376  $parameter = $this->object->getParameter($i);
377  $template->setCurrentBlock("appletparam");
378  $template->setVariable("PARAM_NAME", $parameter["name"]);
379  $template->setVariable("PARAM_VALUE", $parameter["value"]);
380  $template->parseCurrentBlock();
381  }
382 
383  if (($active_id > 0) && (!$show_correct_solution))
384  {
385  $solutions = NULL;
386  include_once "./Modules/Test/classes/class.ilObjTest.php";
387  $info = $this->object->getReachedInformation($active_id, $pass);
388  foreach ($info as $kk => $infodata)
389  {
390  $template->setCurrentBlock("appletparam");
391  $template->setVariable("PARAM_NAME", "value_" . $infodata["order"] . "_1");
392  $template->setVariable("PARAM_VALUE", $infodata["value1"]);
393  $template->parseCurrentBlock();
394  $template->setCurrentBlock("appletparam");
395  $template->setVariable("PARAM_NAME", "value_" . $infodata["order"] . "_2");
396  $template->setVariable("PARAM_VALUE", $infodata["value2"]);
397  $template->parseCurrentBlock();
398  }
399  }
400 
401  $questiontext = $this->object->getQuestion();
402  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
403  $template->setVariable("APPLET_WIDTH", $this->object->getJavaWidth());
404  $template->setVariable("APPLET_HEIGHT", $this->object->getJavaHeight());
405  $template->setVariable("APPLET_CODE", $this->object->getJavaCode());
406  if (strlen($this->object->getJavaArchive()) > 0)
407  {
408  $template->setVariable("APPLET_ARCHIVE", " archive=\"".$this->object->getJavaArchive()."\"");
409  }
410  else
411  {
412  if (strpos($this->object->getJavaAppletFilename(), ".jar") !== FALSE)
413  {
414  $template->setVariable("APPLET_ARCHIVE", " archive=\"".$this->object->getJavaPathWeb().$this->object->getJavaAppletFilename()."\"");
415  }
416  }
417  if (strlen($this->object->getJavaCodebase()) > 0)
418  {
419  $template->setVariable("APPLET_CODEBASE", " codebase=\"".$this->object->getJavaCodebase()."\"");
420  }
421  else
422  {
423  if (strpos($this->object->getJavaAppletFilename(), ".class") !== FALSE)
424  {
425  $template->setVariable("APPLET_CODEBASE", " codebase=\"".$this->object->getJavaPathWeb()."\"");
426  }
427  }
428  if (($active_id > 0) && (!$show_correct_solution))
429  {
430  if ($graphicalOutput)
431  {
432  // output of ok/not ok icons for user entered solutions
433  $reached_points = $this->object->getReachedPoints($active_id, $pass);
434  if ($reached_points == $this->object->getPoints())
435  {
436  $template->setCurrentBlock("icon_ok");
437  $template->setVariable("ICON_OK", ilUtil::getImagePath("icon_ok.gif"));
438  $template->setVariable("TEXT_OK", $this->lng->txt("answer_is_right"));
439  $template->parseCurrentBlock();
440  }
441  else
442  {
443  $template->setCurrentBlock("icon_ok");
444  if ($reached_points > 0)
445  {
446  $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_mostly_ok.gif"));
447  $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_not_correct_but_positive"));
448  }
449  else
450  {
451  $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_not_ok.gif"));
452  $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_wrong"));
453  }
454  $template->parseCurrentBlock();
455  }
456  }
457  }
458  $questionoutput = $template->get();
459  $feedback = ($show_feedback) ? $this->getAnswerFeedbackOutput($active_id, $pass) : "";
460  if (strlen($feedback)) $solutiontemplate->setVariable("FEEDBACK", $feedback);
461  $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
462 
463  $solutionoutput = $solutiontemplate->get();
464  if (!$show_question_only)
465  {
466  // get page object output
467  $solutionoutput = $this->getILIASPage($solutionoutput);
468  }
469  return $solutionoutput;
470  }
471 
472  function getPreview($show_question_only = FALSE)
473  {
474  // generate the question output
475  include_once "./classes/class.ilTemplate.php";
476  $template = new ilTemplate("tpl.il_as_qpl_javaapplet_question_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
477  $template->setCurrentBlock("appletparam");
478  $template->setVariable("PARAM_NAME", "question_id");
479  $template->setVariable("PARAM_VALUE", $this->object->getId());
480  $template->parseCurrentBlock();
481  $template->setCurrentBlock("appletparam");
482  $template->setVariable("PARAM_NAME", "points_max");
483  $template->setVariable("PARAM_VALUE", $this->object->getPoints());
484  $template->parseCurrentBlock();
485  $template->setCurrentBlock("appletparam");
486  $template->setVariable("PARAM_NAME", "session_id");
487  $template->setVariable("PARAM_VALUE", $_COOKIE["PHPSESSID"]);
488  $template->parseCurrentBlock();
489  $template->setCurrentBlock("appletparam");
490  $template->setVariable("PARAM_NAME", "client");
491  $template->setVariable("PARAM_VALUE", CLIENT_ID);
492  $template->parseCurrentBlock();
493  // additional parameters
494  for ($i = 0; $i < $this->object->getParameterCount(); $i++)
495  {
496  $parameter = $this->object->getParameter($i);
497  $template->setCurrentBlock("appletparam");
498  $template->setVariable("PARAM_NAME", $parameter["name"]);
499  $template->setVariable("PARAM_VALUE", $parameter["value"]);
500  $template->parseCurrentBlock();
501  }
502 
503  $questiontext = $this->object->getQuestion();
504  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
505  $template->setVariable("APPLET_WIDTH", $this->object->getJavaWidth());
506  $template->setVariable("APPLET_HEIGHT", $this->object->getJavaHeight());
507  $template->setVariable("APPLET_CODE", $this->object->getJavaCode());
508  if (strlen($this->object->getJavaArchive()) > 0)
509  {
510  $template->setVariable("APPLET_ARCHIVE", " archive=\"".$this->object->getJavaArchive()."\"");
511  }
512  else
513  {
514  if (strpos($this->object->getJavaAppletFilename(), ".jar") !== FALSE)
515  {
516  $template->setVariable("APPLET_ARCHIVE", " archive=\"".$this->object->getJavaPathWeb().$this->object->getJavaAppletFilename()."\"");
517  }
518  }
519  if (strlen($this->object->getJavaCodebase()) > 0)
520  {
521  $template->setVariable("APPLET_CODEBASE", " codebase=\"".$this->object->getJavaCodebase()."\"");
522  }
523  else
524  {
525  if (strpos($this->object->getJavaAppletFilename(), ".class") !== FALSE)
526  {
527  $template->setVariable("APPLET_CODEBASE", " codebase=\"".$this->object->getJavaPathWeb()."\"");
528  }
529  }
530  $questionoutput = $template->get();
531  if (!$show_question_only)
532  {
533  // get page object output
534  $questionoutput = $this->getILIASPage($questionoutput);
535  }
536  return $questionoutput;
537  }
538 
539  function getTestOutput($active_id, $pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE)
540  {
541  $userdata = $this->object->getActiveUserData($active_id);
542  // generate the question output
543  include_once "./classes/class.ilTemplate.php";
544  $template = new ilTemplate("tpl.il_as_qpl_javaapplet_question_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
545  $template->setCurrentBlock("appletparam");
546  $template->setVariable("PARAM_NAME", "test_type");
547  include_once "./Modules/Test/classes/class.ilObjTest.php";
549  {
550  $template->setVariable("PARAM_VALUE", "0");
551  }
552  else
553  {
554  $template->setVariable("PARAM_VALUE", "1");
555  }
556  $template->parseCurrentBlock();
557  $template->setCurrentBlock("appletparam");
558  $template->setVariable("PARAM_NAME", "active_id");
559  $template->setVariable("PARAM_VALUE", $active_id);
560  $template->parseCurrentBlock();
561  $template->setCurrentBlock("appletparam");
562  $template->setVariable("PARAM_NAME", "test_id");
563  $template->setVariable("PARAM_VALUE", $userdata["test_id"]);
564  $template->parseCurrentBlock();
565  $template->setCurrentBlock("appletparam");
566  $template->setVariable("PARAM_NAME", "question_id");
567  $template->setVariable("PARAM_VALUE", $this->object->getId());
568  $template->parseCurrentBlock();
569  $template->setCurrentBlock("appletparam");
570  $template->setVariable("PARAM_NAME", "user_id");
571  $template->setVariable("PARAM_VALUE", $userdata["user_id"]);
572  $template->parseCurrentBlock();
573  $template->setCurrentBlock("appletparam");
574  $template->setVariable("PARAM_NAME", "points_max");
575  $template->setVariable("PARAM_VALUE", $this->object->getPoints());
576  $template->parseCurrentBlock();
577  $template->setCurrentBlock("appletparam");
578  $template->setVariable("PARAM_NAME", "session_id");
579  $template->setVariable("PARAM_VALUE", $_COOKIE["PHPSESSID"]);
580  $template->parseCurrentBlock();
581  $template->setCurrentBlock("appletparam");
582  $template->setVariable("PARAM_NAME", "client");
583  $template->setVariable("PARAM_VALUE", CLIENT_ID);
584  $template->parseCurrentBlock();
585  $template->setCurrentBlock("appletparam");
586  $template->setVariable("PARAM_NAME", "pass");
587  $actualpass = ilObjTest::_getPass($active_id);
588  $template->setVariable("PARAM_VALUE", $actualpass);
589  $template->parseCurrentBlock();
590  $template->setCurrentBlock("appletparam");
591  $template->setVariable("PARAM_NAME", "post_url");
592  $template->setVariable("PARAM_VALUE", ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/Modules/TestQuestionPool/save_question_post_data.php");
593  $template->parseCurrentBlock();
594  // additional parameters
595  for ($i = 0; $i < $this->object->getParameterCount(); $i++)
596  {
597  $parameter = $this->object->getParameter($i);
598  $template->setCurrentBlock("appletparam");
599  $template->setVariable("PARAM_NAME", $parameter["name"]);
600  $template->setVariable("PARAM_VALUE", $parameter["value"]);
601  $template->parseCurrentBlock();
602  }
603 
604  if ($active_id)
605  {
606  $solutions = NULL;
607  include_once "./Modules/Test/classes/class.ilObjTest.php";
608  if (!ilObjTest::_getUsePreviousAnswers($active_id, true))
609  {
610  if (is_null($pass)) $pass = ilObjTest::_getPass($active_id);
611  }
612  $info = $this->object->getReachedInformation($active_id, $pass);
613  foreach ($info as $kk => $infodata)
614  {
615  $template->setCurrentBlock("appletparam");
616  $template->setVariable("PARAM_NAME", "value_" . $infodata["order"] . "_1");
617  $template->setVariable("PARAM_VALUE", $infodata["value1"]);
618  $template->parseCurrentBlock();
619  $template->setCurrentBlock("appletparam");
620  $template->setVariable("PARAM_NAME", "value_" . $infodata["order"] . "_2");
621  $template->setVariable("PARAM_VALUE", $infodata["value2"]);
622  $template->parseCurrentBlock();
623  }
624  include_once './Services/Administration/classes/class.ilSetting.php';
625  $soapSetting = new ilSetting();
626  if ($soapSetting->get("soap_user_administration") == 1)
627  {
628  $template->setCurrentBlock("appletparam");
629  $template->setVariable("PARAM_NAME", "server");
630  $template->setVariable("PARAM_VALUE", ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/webservice/soap/server.php");
631  }
632  }
633 
634  $questiontext = $this->object->getQuestion();
635  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
636  $template->setVariable("APPLET_WIDTH", $this->object->getJavaWidth());
637  $template->setVariable("APPLET_HEIGHT", $this->object->getJavaHeight());
638  $template->setVariable("APPLET_CODE", $this->object->getJavaCode());
639  if (strlen($this->object->getJavaArchive()) > 0)
640  {
641  $template->setVariable("APPLET_ARCHIVE", " archive=\"".$this->object->getJavaArchive()."\"");
642  }
643  else
644  {
645  if (strpos($this->object->getJavaAppletFilename(), ".jar") !== FALSE)
646  {
647  $template->setVariable("APPLET_ARCHIVE", " archive=\"".$this->object->getJavaPathWeb().$this->object->getJavaAppletFilename()."\"");
648  }
649  }
650  if (strlen($this->object->getJavaCodebase()) > 0)
651  {
652  $template->setVariable("APPLET_CODEBASE", " codebase=\"".$this->object->getJavaCodebase()."\"");
653  }
654  else
655  {
656  if (strpos($this->object->getJavaAppletFilename(), ".class") !== FALSE)
657  {
658  $template->setVariable("APPLET_CODEBASE", " codebase=\"".$this->object->getJavaPathWeb()."\"");
659  }
660  }
661  $questionoutput = $template->get();
662  $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput);
663  return $pageoutput;
664  }
665 
671  function saveFeedback()
672  {
673  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
674  $errors = $this->feedback(true);
675  $this->object->saveFeedbackGeneric(0, $_POST["feedback_incomplete"]);
676  $this->object->saveFeedbackGeneric(1, $_POST["feedback_complete"]);
677  $this->object->cleanupMediaObjectUsage();
679  }
680 
688  function setQuestionTabs()
689  {
690  global $rbacsystem, $ilTabs;
691 
692  $this->ctrl->setParameterByClass("ilpageobjectgui", "q_id", $_GET["q_id"]);
693  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
694  $q_type = $this->object->getQuestionType();
695 
696  if (strlen($q_type))
697  {
698  $classname = $q_type . "GUI";
699  $this->ctrl->setParameterByClass(strtolower($classname), "sel_question_types", $q_type);
700  $this->ctrl->setParameterByClass(strtolower($classname), "q_id", $_GET["q_id"]);
701  }
702 
703  if ($_GET["q_id"])
704  {
705  if ($rbacsystem->checkAccess('write', $_GET["ref_id"]))
706  {
707  // edit page
708  $ilTabs->addTarget("edit_content",
709  $this->ctrl->getLinkTargetByClass("ilPageObjectGUI", "edit"),
710  array("edit", "insert", "exec_pg"),
711  "", "", $force_active);
712  }
713 
714  // edit page
715  $ilTabs->addTarget("preview",
716  $this->ctrl->getLinkTargetByClass("ilPageObjectGUI", "preview"),
717  array("preview"),
718  "ilPageObjectGUI", "", $force_active);
719  }
720 
721  $force_active = false;
722  if ($rbacsystem->checkAccess('write', $_GET["ref_id"]))
723  {
724  $url = "";
725  if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname, "editQuestion");
726  $commands = $_POST["cmd"];
727  if (is_array($commands))
728  {
729  foreach ($commands as $key => $value)
730  {
731  if (preg_match("/^delete_.*/", $key, $matches))
732  {
733  $force_active = true;
734  }
735  }
736  }
737  // edit question properties
738  $ilTabs->addTarget("edit_properties",
739  $url,
740  array("editQuestion", "save", "saveEdit", "addkvp", "removekvp", "originalSyncForm"),
741  $classname, "", $force_active);
742  }
743 
744  if ($_GET["q_id"])
745  {
746  $ilTabs->addTarget("feedback",
747  $this->ctrl->getLinkTargetByClass($classname, "feedback"),
748  array("feedback", "saveFeedback"),
749  $classname, "");
750  }
751 
752  if ($_GET["q_id"])
753  {
754  $ilTabs->addTarget("solution_hint",
755  $this->ctrl->getLinkTargetByClass($classname, "suggestedsolution"),
756  array("suggestedsolution", "saveSuggestedSolution", "outSolutionExplorer", "cancel",
757  "addSuggestedSolution","cancelExplorer", "linkChilds", "removeSuggestedSolution"
758  ),
759  $classname,
760  ""
761  );
762  }
763 
764  // Assessment of questions sub menu entry
765  if ($_GET["q_id"])
766  {
767  $ilTabs->addTarget("statistics",
768  $this->ctrl->getLinkTargetByClass($classname, "assessment"),
769  array("assessment"),
770  $classname, "");
771  }
772 
773  if (($_GET["calling_test"] > 0) || ($_GET["test_ref_id"] > 0))
774  {
775  $ref_id = $_GET["calling_test"];
776  if (strlen($ref_id) == 0) $ref_id = $_GET["test_ref_id"];
777  $ilTabs->setBackTarget($this->lng->txt("backtocallingtest"), "ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
778  }
779  else
780  {
781  $ilTabs->setBackTarget($this->lng->txt("qpl"), $this->ctrl->getLinkTargetByClass("ilobjquestionpoolgui", "questions"));
782  }
783  }
784 }
785 ?>