24 include_once
"./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
25 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
51 include_once
"./Modules/TestQuestionPool/classes/class.assJavaApplet.php";
55 $this->
object->loadFromDb($id);
61 if (substr(
$cmd, 0, 6) ==
"delete")
76 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
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(
90 $this->
object->setPoints(
$_POST[
"points"]);
92 if (
$_POST[
'delete_applet'])
95 $this->
object->deleteJavaAppletFilename();
99 $this->
object->setJavaAppletFilename(
$_POST[
'uploaded_javaapplet']);
103 if (!empty($_FILES[
'javaappletName'][
'tmp_name']))
105 $this->
object->setJavaAppletFilename($_FILES[
'javaappletName'][
'name'], $_FILES[
'javaappletName'][
'tmp_name']);
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"]);
113 $this->
object->flushParams();
114 if (is_array(
$_POST[
'kvp'][
'key']))
116 foreach (
$_POST[
'kvp'][
'key'] as $idx => $val)
118 if (strlen($val) && strlen(
$_POST[
'kvp'][
'value'][$idx]))
120 $this->
object->addParameter($val,
$_POST[
'kvp'][
'value'][$idx]);
142 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
144 $form->setFormAction($this->ctrl->getFormAction($this));
146 $form->setMultipart(
true);
147 $form->setTableWidth(
"100%");
148 $form->setId(
"assjavaapplet");
154 $points->
setValue($this->object->getPoints());
155 $points->setRequired(TRUE);
157 $points->setMinValue(0.0);
158 $form->addItem($points);
161 $header->setTitle($this->lng->txt(
"applet_attributes"));
162 $form->addItem($header);
165 $javaapplet = $this->
object->getJavaAppletFilename();
166 $applet =
new ilFileInputGUI($this->lng->txt(
'javaapplet'),
'javaappletName');
168 $applet->setRequired(
false);
170 if (strlen($javaapplet))
177 $delete->setOptionTitle($this->lng->txt(
'delete'));
178 $delete->setValue(1);
179 $applet->addSubItem($delete);
181 $form->addItem($applet);
185 $code->
setValue($this->object->getJavaCode());
186 $code->setRequired(TRUE);
187 $form->addItem($code);
189 if (!strlen($javaapplet))
192 $archive =
new ilTextInputGUI($this->lng->txt(
"archive"),
"java_archive");
193 $archive->
setValue($this->object->getJavaArchive());
194 $archive->setRequired(
false);
195 $form->addItem($archive);
198 $codebase =
new ilTextInputGUI($this->lng->txt(
"codebase"),
"java_codebase");
199 $codebase->
setValue($this->object->getJavaCodebase());
200 $codebase->setRequired(
false);
201 $form->addItem($codebase);
208 $width->setMinValue(50);
209 $width->setMaxLength(6);
210 $width->setValue($this->object->getJavaWidth());
211 $width->setRequired(TRUE);
212 $form->addItem($width);
218 $height->setMinValue(50);
219 $height->setMaxLength(6);
220 $height->setValue($this->object->getJavaHeight());
221 $height->setRequired(TRUE);
222 $form->addItem($height);
225 $header->setTitle($this->lng->txt(
"applet_parameters"));
226 $form->addItem($header);
228 include_once
"./Modules/TestQuestionPool/classes/class.ilKVPWizardInputGUI.php";
231 for ($i = 0; $i < $this->
object->getParameterCount(); $i++)
233 $param = $this->
object->getParameter($i);
234 array_push($values, array($param[
'name'], $param[
'value']));
236 if (count($values) == 0)
238 array_push($values, array(
"",
""));
240 $kvp->setKeyName($this->lng->txt(
'name'));
241 $kvp->setValueName($this->lng->txt(
'value'));
242 $kvp->setValues($values);
243 $form->addItem($kvp);
251 $form->setValuesByPost();
252 $errors = !$form->checkInput();
253 $form->setValuesByPost();
254 if (
$errors) $checkonly =
false;
257 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
267 $position = key(
$_POST[
'cmd'][
'addkvp']);
268 $this->
object->addParameterAtIndex($position+1,
"",
"");
278 $position = key(
$_POST[
'cmd'][
'removekvp']);
279 $this->
object->removeParameter($position);
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);
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
315 $userdata = $this->
object->getActiveUserData($active_id);
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"]))
324 $template->setCurrentBlock(
"appletparam");
325 $template->setVariable(
"PARAM_NAME",
"test_type");
328 $template->setVariable(
"PARAM_VALUE",
"0");
332 $template->setVariable(
"PARAM_VALUE",
"1");
334 $template->parseCurrentBlock();
336 if (strlen($userdata[
"test_id"]))
338 $template->setCurrentBlock(
"appletparam");
339 $template->setVariable(
"PARAM_NAME",
"test_id");
340 $template->setVariable(
"PARAM_VALUE", $userdata[
"test_id"]);
341 $template->parseCurrentBlock();
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"]))
353 $template->setCurrentBlock(
"appletparam");
354 $template->setVariable(
"PARAM_NAME",
"user_id");
355 $template->setVariable(
"PARAM_VALUE", $userdata[
"user_id"]);
356 $template->parseCurrentBlock();
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");
373 $template->setVariable(
"PARAM_VALUE", $actualpass);
374 $template->parseCurrentBlock();
376 for ($i = 0; $i < $this->
object->getParameterCount(); $i++)
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();
385 if (($active_id > 0) && (!$show_correct_solution))
388 include_once
"./Modules/Test/classes/class.ilObjTest.php";
389 $info = $this->
object->getReachedInformation($active_id,
$pass);
390 foreach ($info as $kk => $infodata)
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();
403 $questiontext = $this->
object->getQuestion();
404 if ($show_question_text==
true)
406 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
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)
413 $template->setVariable(
"APPLET_ARCHIVE",
" archive=\"".$this->object->getJavaArchive().
"\"");
417 if (strpos($this->object->getJavaAppletFilename(),
".jar") !== FALSE)
419 $template->setVariable(
"APPLET_ARCHIVE",
" archive=\"".$this->object->getJavaPathWeb().$this->object->getJavaAppletFilename().
"\"");
422 if (strlen($this->object->getJavaCodebase()) > 0)
424 $template->setVariable(
"APPLET_CODEBASE",
" codebase=\"".$this->object->getJavaCodebase().
"\"");
428 if (strpos($this->object->getJavaAppletFilename(),
".class") !== FALSE)
430 $template->setVariable(
"APPLET_CODEBASE",
" codebase=\"".$this->object->getJavaPathWeb().
"\"");
433 if (($active_id > 0) && (!$show_correct_solution))
435 if ($graphicalOutput)
438 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
439 if ($reached_points == $this->object->getPoints())
441 $template->setCurrentBlock(
"icon_ok");
443 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
444 $template->parseCurrentBlock();
448 $template->setCurrentBlock(
"icon_ok");
449 if ($reached_points > 0)
452 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
457 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
459 $template->parseCurrentBlock();
463 $questionoutput = $template->get();
465 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput($feedback,
true));
466 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
468 $solutionoutput = $solutiontemplate->get();
469 if (!$show_question_only)
472 $solutionoutput =
'<div class="ilc_question_Standard">'.$solutionoutput.
"</div>";
474 return $solutionoutput;
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();
499 for ($i = 0; $i < $this->
object->getParameterCount(); $i++)
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();
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)
515 $template->setVariable(
"APPLET_ARCHIVE",
" archive=\"".$this->object->getJavaArchive().
"\"");
519 if (strpos($this->object->getJavaAppletFilename(),
".jar") !== FALSE)
521 $template->setVariable(
"APPLET_ARCHIVE",
" archive=\"".$this->object->getJavaPathWeb().$this->object->getJavaAppletFilename().
"\"");
524 if (strlen($this->object->getJavaCodebase()) > 0)
526 $template->setVariable(
"APPLET_CODEBASE",
" codebase=\"".$this->object->getJavaCodebase().
"\"");
530 if (strpos($this->object->getJavaAppletFilename(),
".class") !== FALSE)
532 $template->setVariable(
"APPLET_CODEBASE",
" codebase=\"".$this->object->getJavaPathWeb().
"\"");
535 $questionoutput = $template->get();
536 if (!$show_question_only)
541 return $questionoutput;
546 $userdata = $this->
object->getActiveUserData($active_id);
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";
555 $template->setVariable(
"PARAM_VALUE",
"0");
559 $template->setVariable(
"PARAM_VALUE",
"1");
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");
593 $template->setVariable(
"PARAM_VALUE", $actualpass);
594 $template->parseCurrentBlock();
595 $template->setCurrentBlock(
"appletparam");
596 $template->setVariable(
"PARAM_NAME",
"post_url");
598 $template->parseCurrentBlock();
600 for ($i = 0; $i < $this->
object->getParameterCount(); $i++)
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();
612 include_once
"./Modules/Test/classes/class.ilObjTest.php";
617 $info = $this->
object->getReachedInformation($active_id,
$pass);
618 foreach ($info as $kk => $infodata)
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();
629 include_once
'./Services/Administration/classes/class.ilSetting.php';
631 if ($soapSetting->get(
"soap_user_administration") == 1)
633 $template->setCurrentBlock(
"appletparam");
634 $template->setVariable(
"PARAM_NAME",
"server");
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)
646 $template->setVariable(
"APPLET_ARCHIVE",
" archive=\"".$this->object->getJavaArchive().
"\"");
650 if (strpos($this->object->getJavaAppletFilename(),
".jar") !== FALSE)
652 $template->setVariable(
"APPLET_ARCHIVE",
" archive=\"".$this->object->getJavaPathWeb().$this->object->getJavaAppletFilename().
"\"");
655 if (strlen($this->object->getJavaCodebase()) > 0)
657 $template->setVariable(
"APPLET_CODEBASE",
" codebase=\"".$this->object->getJavaCodebase().
"\"");
661 if (strpos($this->object->getJavaAppletFilename(),
".class") !== FALSE)
663 $template->setVariable(
"APPLET_CODEBASE",
" codebase=\"".$this->object->getJavaPathWeb().
"\"");
666 $questionoutput = $template->get();
667 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
678 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
680 $this->
object->saveFeedbackGeneric(0,
$_POST[
"feedback_incomplete"]);
681 $this->
object->saveFeedbackGeneric(1,
$_POST[
"feedback_complete"]);
682 $this->
object->cleanupMediaObjectUsage();
695 global $rbacsystem, $ilTabs;
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();
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"]);
710 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
713 $ilTabs->addTarget(
"edit_page",
714 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"edit"),
715 array(
"edit",
"insert",
"exec_pg"),
716 "",
"", $force_active);
720 $ilTabs->addTarget(
"preview",
721 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"preview"),
723 "ilPageObjectGUI",
"", $force_active);
726 $force_active =
false;
727 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
730 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
731 $commands =
$_POST[
"cmd"];
732 if (is_array($commands))
734 foreach ($commands as $key => $value)
736 if (preg_match(
"/^delete_.*/", $key, $matches))
738 $force_active =
true;
743 $ilTabs->addTarget(
"edit_question",
745 array(
"editQuestion",
"save",
"saveEdit",
"addkvp",
"removekvp",
"originalSyncForm"),
746 $classname,
"", $force_active);
751 $ilTabs->addTarget(
"feedback",
752 $this->ctrl->getLinkTargetByClass($classname,
"feedback"),
753 array(
"feedback",
"saveFeedback"),
762 $ilTabs->addTarget(
"solution_hint",
763 $this->ctrl->getLinkTargetByClass($classname,
"suggestedsolution"),
764 array(
"suggestedsolution",
"saveSuggestedSolution",
"outSolutionExplorer",
"cancel",
765 "addSuggestedSolution",
"cancelExplorer",
"linkChilds",
"removeSuggestedSolution"
775 $ilTabs->addTarget(
"statistics",
776 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
781 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
786 global $___test_express_mode;
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");
793 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"), $link);
798 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));
805 return $this->
object->prepareTextareaOutput($output, TRUE);