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