24 include_once
"./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
25 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
50 include_once
"./Modules/TestQuestionPool/classes/class.assJavaApplet.php";
54 $this->
object->loadFromDb($id);
60 if (substr(
$cmd, 0, 6) ==
"delete")
75 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
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(
89 $this->
object->setPoints(
$_POST[
"points"]);
91 if (
$_POST[
'delete_applet'])
94 $this->
object->deleteJavaAppletFilename();
98 $this->
object->setJavaAppletFilename(
$_POST[
'uploaded_javaapplet']);
102 if (!empty($_FILES[
'javaappletName'][
'tmp_name']))
104 $this->
object->setJavaAppletFilename($_FILES[
'javaappletName'][
'name'], $_FILES[
'javaappletName'][
'tmp_name']);
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"]);
112 $this->
object->flushParams();
113 if (is_array(
$_POST[
'kvp'][
'key']))
115 foreach (
$_POST[
'kvp'][
'key'] as $idx => $val)
117 if (strlen($val) && strlen(
$_POST[
'kvp'][
'value'][$idx]))
119 $this->
object->addParameter($val,
$_POST[
'kvp'][
'value'][$idx]);
138 $save = ((strcmp($this->ctrl->getCmd(),
"save") == 0) || (strcmp($this->ctrl->getCmd(),
"saveEdit") == 0)) ? TRUE : FALSE;
141 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
143 $form->setFormAction($this->ctrl->getFormAction($this));
145 $form->setMultipart(
true);
146 $form->setTableWidth(
"100%");
147 $form->setId(
"assjavaapplet");
153 $points->setValue($this->object->getPoints());
160 $header->setTitle($this->lng->txt(
"applet_attributes"));
161 $form->addItem($header);
164 $javaapplet = $this->
object->getJavaAppletFilename();
165 $applet =
new ilFileInputGUI($this->lng->txt(
'javaapplet'),
'javaappletName');
167 $applet->setRequired(
false);
169 if (strlen($javaapplet))
176 $delete->setOptionTitle($this->lng->txt(
'delete'));
177 $delete->setValue(1);
178 $applet->addSubItem($delete);
180 $form->addItem($applet);
184 $code->
setValue($this->object->getJavaCode());
185 $code->setRequired(TRUE);
186 $form->addItem($code);
188 if (!strlen($javaapplet))
191 $archive =
new ilTextInputGUI($this->lng->txt(
"archive"),
"java_archive");
192 $archive->
setValue($this->object->getJavaArchive());
193 $archive->setRequired(
false);
194 $form->addItem($archive);
197 $codebase =
new ilTextInputGUI($this->lng->txt(
"codebase"),
"java_codebase");
198 $codebase->
setValue($this->object->getJavaCodebase());
199 $codebase->setRequired(
false);
200 $form->addItem($codebase);
207 $width->setMinValue(50);
208 $width->setMaxLength(6);
209 $width->setValue($this->object->getJavaWidth());
210 $width->setRequired(TRUE);
211 $form->addItem($width);
217 $height->setMinValue(50);
218 $height->setMaxLength(6);
219 $height->setValue($this->object->getJavaHeight());
220 $height->setRequired(TRUE);
221 $form->addItem($height);
224 $header->setTitle($this->lng->txt(
"applet_parameters"));
225 $form->addItem($header);
227 include_once
"./Modules/TestQuestionPool/classes/class.ilKVPWizardInputGUI.php";
230 for ($i = 0; $i < $this->
object->getParameterCount(); $i++)
232 $param = $this->
object->getParameter($i);
233 array_push($values, array($param[
'name'], $param[
'value']));
235 if (count($values) == 0)
237 array_push($values, array(
"",
""));
239 $kvp->setKeyName($this->lng->txt(
'name'));
240 $kvp->setValueName($this->lng->txt(
'value'));
241 $kvp->setValues($values);
242 $form->addItem($kvp);
250 $form->setValuesByPost();
251 $errors = !$form->checkInput();
252 $form->setValuesByPost();
253 if (
$errors) $checkonly =
false;
256 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
266 $position = key(
$_POST[
'cmd'][
'addkvp']);
267 $this->
object->addParameterAtIndex($position+1,
"",
"");
277 $position = key(
$_POST[
'cmd'][
'removekvp']);
278 $this->
object->removeParameter($position);
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);
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
313 $userdata = $this->
object->getActiveUserData($active_id);
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"]))
322 $template->setCurrentBlock(
"appletparam");
323 $template->setVariable(
"PARAM_NAME",
"test_type");
326 $template->setVariable(
"PARAM_VALUE",
"0");
330 $template->setVariable(
"PARAM_VALUE",
"1");
332 $template->parseCurrentBlock();
334 if (strlen($userdata[
"test_id"]))
336 $template->setCurrentBlock(
"appletparam");
337 $template->setVariable(
"PARAM_NAME",
"test_id");
338 $template->setVariable(
"PARAM_VALUE", $userdata[
"test_id"]);
339 $template->parseCurrentBlock();
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"]))
351 $template->setCurrentBlock(
"appletparam");
352 $template->setVariable(
"PARAM_NAME",
"user_id");
353 $template->setVariable(
"PARAM_VALUE", $userdata[
"user_id"]);
354 $template->parseCurrentBlock();
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");
371 $template->setVariable(
"PARAM_VALUE", $actualpass);
372 $template->parseCurrentBlock();
374 for ($i = 0; $i < $this->
object->getParameterCount(); $i++)
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();
383 if (($active_id > 0) && (!$show_correct_solution))
386 include_once
"./Modules/Test/classes/class.ilObjTest.php";
387 $info = $this->
object->getReachedInformation($active_id,
$pass);
388 foreach ($info as $kk => $infodata)
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();
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)
408 $template->setVariable(
"APPLET_ARCHIVE",
" archive=\"".$this->object->getJavaArchive().
"\"");
412 if (strpos($this->object->getJavaAppletFilename(),
".jar") !== FALSE)
414 $template->setVariable(
"APPLET_ARCHIVE",
" archive=\"".$this->object->getJavaPathWeb().$this->object->getJavaAppletFilename().
"\"");
417 if (strlen($this->object->getJavaCodebase()) > 0)
419 $template->setVariable(
"APPLET_CODEBASE",
" codebase=\"".$this->object->getJavaCodebase().
"\"");
423 if (strpos($this->object->getJavaAppletFilename(),
".class") !== FALSE)
425 $template->setVariable(
"APPLET_CODEBASE",
" codebase=\"".$this->object->getJavaPathWeb().
"\"");
428 if (($active_id > 0) && (!$show_correct_solution))
430 if ($graphicalOutput)
433 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
434 if ($reached_points == $this->object->getPoints())
436 $template->setCurrentBlock(
"icon_ok");
438 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
439 $template->parseCurrentBlock();
443 $template->setCurrentBlock(
"icon_ok");
444 if ($reached_points > 0)
447 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
452 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
454 $template->parseCurrentBlock();
458 $questionoutput = $template->get();
460 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $feedback);
461 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
463 $solutionoutput = $solutiontemplate->get();
464 if (!$show_question_only)
469 return $solutionoutput;
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();
494 for ($i = 0; $i < $this->
object->getParameterCount(); $i++)
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();
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)
510 $template->setVariable(
"APPLET_ARCHIVE",
" archive=\"".$this->object->getJavaArchive().
"\"");
514 if (strpos($this->object->getJavaAppletFilename(),
".jar") !== FALSE)
516 $template->setVariable(
"APPLET_ARCHIVE",
" archive=\"".$this->object->getJavaPathWeb().$this->object->getJavaAppletFilename().
"\"");
519 if (strlen($this->object->getJavaCodebase()) > 0)
521 $template->setVariable(
"APPLET_CODEBASE",
" codebase=\"".$this->object->getJavaCodebase().
"\"");
525 if (strpos($this->object->getJavaAppletFilename(),
".class") !== FALSE)
527 $template->setVariable(
"APPLET_CODEBASE",
" codebase=\"".$this->object->getJavaPathWeb().
"\"");
530 $questionoutput = $template->get();
531 if (!$show_question_only)
536 return $questionoutput;
541 $userdata = $this->
object->getActiveUserData($active_id);
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";
550 $template->setVariable(
"PARAM_VALUE",
"0");
554 $template->setVariable(
"PARAM_VALUE",
"1");
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");
588 $template->setVariable(
"PARAM_VALUE", $actualpass);
589 $template->parseCurrentBlock();
590 $template->setCurrentBlock(
"appletparam");
591 $template->setVariable(
"PARAM_NAME",
"post_url");
593 $template->parseCurrentBlock();
595 for ($i = 0; $i < $this->
object->getParameterCount(); $i++)
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();
607 include_once
"./Modules/Test/classes/class.ilObjTest.php";
612 $info = $this->
object->getReachedInformation($active_id,
$pass);
613 foreach ($info as $kk => $infodata)
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();
624 include_once
'./Services/Administration/classes/class.ilSetting.php';
626 if ($soapSetting->get(
"soap_user_administration") == 1)
628 $template->setCurrentBlock(
"appletparam");
629 $template->setVariable(
"PARAM_NAME",
"server");
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)
641 $template->setVariable(
"APPLET_ARCHIVE",
" archive=\"".$this->object->getJavaArchive().
"\"");
645 if (strpos($this->object->getJavaAppletFilename(),
".jar") !== FALSE)
647 $template->setVariable(
"APPLET_ARCHIVE",
" archive=\"".$this->object->getJavaPathWeb().$this->object->getJavaAppletFilename().
"\"");
650 if (strlen($this->object->getJavaCodebase()) > 0)
652 $template->setVariable(
"APPLET_CODEBASE",
" codebase=\"".$this->object->getJavaCodebase().
"\"");
656 if (strpos($this->object->getJavaAppletFilename(),
".class") !== FALSE)
658 $template->setVariable(
"APPLET_CODEBASE",
" codebase=\"".$this->object->getJavaPathWeb().
"\"");
661 $questionoutput = $template->get();
662 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
673 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
675 $this->
object->saveFeedbackGeneric(0,
$_POST[
"feedback_incomplete"]);
676 $this->
object->saveFeedbackGeneric(1,
$_POST[
"feedback_complete"]);
677 $this->
object->cleanupMediaObjectUsage();
690 global $rbacsystem, $ilTabs;
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();
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"]);
705 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
708 $ilTabs->addTarget(
"edit_content",
709 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"edit"),
710 array(
"edit",
"insert",
"exec_pg"),
711 "",
"", $force_active);
715 $ilTabs->addTarget(
"preview",
716 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"preview"),
718 "ilPageObjectGUI",
"", $force_active);
721 $force_active =
false;
722 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
725 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
726 $commands =
$_POST[
"cmd"];
727 if (is_array($commands))
729 foreach ($commands as $key => $value)
731 if (preg_match(
"/^delete_.*/", $key, $matches))
733 $force_active =
true;
738 $ilTabs->addTarget(
"edit_properties",
740 array(
"editQuestion",
"save",
"saveEdit",
"addkvp",
"removekvp",
"originalSyncForm"),
741 $classname,
"", $force_active);
746 $ilTabs->addTarget(
"feedback",
747 $this->ctrl->getLinkTargetByClass($classname,
"feedback"),
748 array(
"feedback",
"saveFeedback"),
754 $ilTabs->addTarget(
"solution_hint",
755 $this->ctrl->getLinkTargetByClass($classname,
"suggestedsolution"),
756 array(
"suggestedsolution",
"saveSuggestedSolution",
"outSolutionExplorer",
"cancel",
757 "addSuggestedSolution",
"cancelExplorer",
"linkChilds",
"removeSuggestedSolution"
767 $ilTabs->addTarget(
"statistics",
768 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
773 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
777 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"),
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
781 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));