4 require_once
'./Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
5 require_once
'./Modules/TestQuestionPool/interfaces/interface.ilGuiQuestionScoringAdjustable.php';
6 include_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
36 include_once
'./Modules/TestQuestionPool/classes/class.assJavaApplet.php';
40 $this->
object->loadFromDb($id);
46 if (substr(
$cmd, 0, 6) ==
"delete")
63 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
68 $this->
object->setPoints(
$_POST[
"points"]);
80 if (
$_POST[
'delete_applet'])
83 $this->
object->deleteJavaAppletFilename();
87 $this->
object->setJavaAppletFilename(
$_POST[
'uploaded_javaapplet'] );
91 if (!empty($_FILES[
'javaappletName'][
'tmp_name']))
93 $this->
object->setJavaAppletFilename( $_FILES[
'javaappletName'][
'name'],
94 $_FILES[
'javaappletName'][
'tmp_name']
97 $this->
object->setJavaCode(
$_POST[
"java_code"] );
98 $this->
object->setJavaCodebase(
$_POST[
"java_codebase"] );
99 $this->
object->setJavaArchive(
$_POST[
"java_archive"] );
100 $this->
object->setJavaWidth(
$_POST[
"java_width"] );
101 $this->
object->setJavaHeight(
$_POST[
"java_height"] );
103 $this->
object->flushParams();
104 if (is_array(
$_POST[
'kvp'][
'key'] ))
106 foreach (
$_POST[
'kvp'][
'key'] as $idx => $val)
108 if (strlen( $val ) && strlen(
$_POST[
'kvp'][
'value'][$idx] ))
110 $this->
object->addParameter( $val,
$_POST[
'kvp'][
'value'][$idx] );
125 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
127 $form->setFormAction($this->ctrl->getFormAction($this));
129 $form->setMultipart(
true);
130 $form->setTableWidth(
"100%");
131 $form->setId(
"assjavaapplet");
144 $form->setValuesByPost();
145 $errors = !$form->checkInput();
146 $form->setValuesByPost();
147 if (
$errors) $checkonly =
false;
150 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
158 $points->
setValue( $this->object->getPoints() );
159 $points->setRequired( TRUE );
160 $points->setSize( 3 );
161 $points->setMinValue( 0.0 );
165 $header->setTitle( $this->lng->txt(
"applet_attributes" ) );
169 $javaapplet = $this->
object->getJavaAppletFilename();
170 $applet =
new ilFileInputGUI($this->lng->txt(
'javaapplet' ),
'javaappletName');
172 $applet->setRequired(
false );
174 if (strlen( $javaapplet ))
181 $delete->setOptionTitle( $this->lng->txt(
'delete' ) );
182 $delete->setValue( 1 );
183 $applet->addSubItem( $delete );
188 $code =
new ilTextInputGUI($this->lng->txt(
"code" ),
"java_code");
189 $code->
setValue( $this->object->getJavaCode() );
190 $code->setRequired( TRUE );
193 if (!strlen( $javaapplet ))
196 $archive =
new ilTextInputGUI($this->lng->txt(
"archive" ),
"java_archive");
197 $archive->
setValue( $this->object->getJavaArchive() );
198 $archive->setRequired(
false );
202 $codebase =
new ilTextInputGUI($this->lng->txt(
"codebase" ),
"java_codebase");
203 $codebase->
setValue( $this->object->getJavaCodebase() );
204 $codebase->setRequired(
false );
211 $width->setSize( 6 );
212 $width->setMinValue( 50 );
213 $width->setMaxLength( 6 );
214 $width->setValue( $this->object->getJavaWidth() );
215 $width->setRequired( TRUE );
221 $height->setSize( 6 );
222 $height->setMinValue( 50 );
223 $height->setMaxLength( 6 );
224 $height->setValue( $this->object->getJavaHeight() );
225 $height->setRequired( TRUE );
229 $header->setTitle( $this->lng->txt(
"applet_parameters" ) );
232 include_once
"./Modules/TestQuestionPool/classes/class.ilKVPWizardInputGUI.php";
235 for ($i = 0; $i < $this->
object->getParameterCount(); $i++)
237 $param = $this->
object->getParameter( $i );
238 array_push( $values, array( $param[
'name'], $param[
'value'] ) );
240 if (count( $values ) == 0)
242 array_push( $values, array(
"",
"" ) );
244 $kvp->setKeyName( $this->lng->txt(
'name' ) );
245 $kvp->setValueName( $this->lng->txt(
'value' ) );
246 $kvp->setValues( $values );
256 $position = key(
$_POST[
'cmd'][
'addkvp']);
257 $this->
object->addParameterAtIndex($position+1,
"",
"");
267 $position = key(
$_POST[
'cmd'][
'removekvp']);
268 $this->
object->removeParameter($position);
274 $test_output = $this->
getTestOutput($active_id,
$pass, $is_postponed, $use_post_solutions);
275 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
276 $this->tpl->setVariable(
"FORMACTION", $formaction);
295 $graphicalOutput = FALSE,
296 $result_output = FALSE,
297 $show_question_only = TRUE,
298 $show_feedback = FALSE,
299 $show_correct_solution = FALSE,
300 $show_manual_scoring = FALSE,
301 $show_question_text = TRUE
304 $userdata = $this->
object->getActiveUserData($active_id);
307 include_once
"./Services/UICore/classes/class.ilTemplate.php";
308 include_once
"./Modules/Test/classes/class.ilObjTest.php";
309 $template =
new ilTemplate(
"tpl.il_as_qpl_javaapplet_question_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
310 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
311 if (strlen($userdata[
"test_id"]))
313 $template->setCurrentBlock(
"appletparam");
314 $template->setVariable(
"PARAM_NAME",
"test_type");
317 $template->setVariable(
"PARAM_VALUE",
"0");
321 $template->setVariable(
"PARAM_VALUE",
"1");
323 $template->parseCurrentBlock();
325 if (strlen($userdata[
"test_id"]))
327 $template->setCurrentBlock(
"appletparam");
328 $template->setVariable(
"PARAM_NAME",
"test_id");
329 $template->setVariable(
"PARAM_VALUE", $userdata[
"test_id"]);
330 $template->parseCurrentBlock();
332 $template->setCurrentBlock(
"appletparam");
333 $template->setVariable(
"PARAM_NAME",
"active_id");
334 $template->setVariable(
"PARAM_VALUE", $active_id);
335 $template->parseCurrentBlock();
336 $template->setCurrentBlock(
"appletparam");
337 $template->setVariable(
"PARAM_NAME",
"question_id");
338 $template->setVariable(
"PARAM_VALUE", $this->object->getId());
339 $template->parseCurrentBlock();
340 if (strlen($userdata[
"user_id"]))
342 $template->setCurrentBlock(
"appletparam");
343 $template->setVariable(
"PARAM_NAME",
"user_id");
344 $template->setVariable(
"PARAM_VALUE", $userdata[
"user_id"]);
345 $template->parseCurrentBlock();
347 $template->setCurrentBlock(
"appletparam");
348 $template->setVariable(
"PARAM_NAME",
"points_max");
349 $template->setVariable(
"PARAM_VALUE", $this->object->getPoints());
350 $template->parseCurrentBlock();
351 $template->setCurrentBlock(
"appletparam");
352 $template->setVariable(
"PARAM_NAME",
"session_id");
353 $template->setVariable(
"PARAM_VALUE",
$_COOKIE[
"PHPSESSID"]);
354 $template->parseCurrentBlock();
355 $template->setCurrentBlock(
"appletparam");
356 $template->setVariable(
"PARAM_NAME",
"client");
357 $template->setVariable(
"PARAM_VALUE", CLIENT_ID);
358 $template->parseCurrentBlock();
359 $template->setCurrentBlock(
"appletparam");
360 $template->setVariable(
"PARAM_NAME",
"pass");
362 $template->setVariable(
"PARAM_VALUE", $actualpass);
363 $template->parseCurrentBlock();
365 for ($i = 0; $i < $this->
object->getParameterCount(); $i++)
367 $parameter = $this->
object->getParameter($i);
368 $template->setCurrentBlock(
"appletparam");
369 $template->setVariable(
"PARAM_NAME", $parameter[
"name"]);
370 $template->setVariable(
"PARAM_VALUE", $parameter[
"value"]);
371 $template->parseCurrentBlock();
374 if (($active_id > 0) && (!$show_correct_solution))
377 include_once
"./Modules/Test/classes/class.ilObjTest.php";
378 $info = $this->
object->getReachedInformation($active_id,
$pass);
379 foreach ($info as $kk => $infodata)
381 $template->setCurrentBlock(
"appletparam");
382 $template->setVariable(
"PARAM_NAME",
"value_" . $infodata[
"order"] .
"_1");
383 $template->setVariable(
"PARAM_VALUE", $infodata[
"value1"]);
384 $template->parseCurrentBlock();
385 $template->setCurrentBlock(
"appletparam");
386 $template->setVariable(
"PARAM_NAME",
"value_" . $infodata[
"order"] .
"_2");
387 $template->setVariable(
"PARAM_VALUE", $infodata[
"value2"]);
388 $template->parseCurrentBlock();
392 $questiontext = $this->
object->getQuestion();
393 if ($show_question_text==
true)
395 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
397 $template->setVariable(
"APPLET_WIDTH", $this->object->getJavaWidth());
398 $template->setVariable(
"APPLET_HEIGHT", $this->object->getJavaHeight());
399 $template->setVariable(
"APPLET_CODE", $this->object->getJavaCode());
400 if (strlen($this->object->getJavaArchive()) > 0)
402 $template->setVariable(
"APPLET_ARCHIVE",
" archive=\"".$this->object->getJavaArchive().
"\"");
406 if (strpos($this->object->getJavaAppletFilename(),
".jar") !== FALSE)
408 $template->setVariable(
"APPLET_ARCHIVE",
" archive=\"".$this->object->getJavaPathWeb().$this->object->getJavaAppletFilename().
"\"");
411 if (strlen($this->object->getJavaCodebase()) > 0)
413 $template->setVariable(
"APPLET_CODEBASE",
" codebase=\"".$this->object->getJavaCodebase().
"\"");
417 if (strpos($this->object->getJavaAppletFilename(),
".class") !== FALSE)
419 $template->setVariable(
"APPLET_CODEBASE",
" codebase=\"".$this->object->getJavaPathWeb().
"\"");
422 if (($active_id > 0) && (!$show_correct_solution))
424 if ($graphicalOutput)
427 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
428 if ($reached_points == $this->object->getPoints())
430 $template->setCurrentBlock(
"icon_ok");
432 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
433 $template->parseCurrentBlock();
437 $template->setCurrentBlock(
"icon_ok");
438 if ($reached_points > 0)
441 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
446 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
448 $template->parseCurrentBlock();
452 $questionoutput = $template->get();
454 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $feedback);
455 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
457 $solutionoutput = $solutiontemplate->get();
458 if (!$show_question_only)
461 $solutionoutput =
'<div class="ilc_question_Standard">'.$solutionoutput.
"</div>";
463 return $solutionoutput;
469 include_once
"./Services/UICore/classes/class.ilTemplate.php";
470 $template =
new ilTemplate(
"tpl.il_as_qpl_javaapplet_question_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
471 $template->setCurrentBlock(
"appletparam");
472 $template->setVariable(
"PARAM_NAME",
"question_id");
473 $template->setVariable(
"PARAM_VALUE", $this->object->getId());
474 $template->parseCurrentBlock();
475 $template->setCurrentBlock(
"appletparam");
476 $template->setVariable(
"PARAM_NAME",
"points_max");
477 $template->setVariable(
"PARAM_VALUE", $this->object->getPoints());
478 $template->parseCurrentBlock();
479 $template->setCurrentBlock(
"appletparam");
480 $template->setVariable(
"PARAM_NAME",
"session_id");
481 $template->setVariable(
"PARAM_VALUE",
$_COOKIE[
"PHPSESSID"]);
482 $template->parseCurrentBlock();
483 $template->setCurrentBlock(
"appletparam");
484 $template->setVariable(
"PARAM_NAME",
"client");
485 $template->setVariable(
"PARAM_VALUE", CLIENT_ID);
486 $template->parseCurrentBlock();
488 for ($i = 0; $i < $this->
object->getParameterCount(); $i++)
490 $parameter = $this->
object->getParameter($i);
491 $template->setCurrentBlock(
"appletparam");
492 $template->setVariable(
"PARAM_NAME", $parameter[
"name"]);
493 $template->setVariable(
"PARAM_VALUE", $parameter[
"value"]);
494 $template->parseCurrentBlock();
497 $questiontext = $this->
object->getQuestion();
498 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
499 $template->setVariable(
"APPLET_WIDTH", $this->object->getJavaWidth());
500 $template->setVariable(
"APPLET_HEIGHT", $this->object->getJavaHeight());
501 $template->setVariable(
"APPLET_CODE", $this->object->getJavaCode());
502 if (strlen($this->object->getJavaArchive()) > 0)
504 $template->setVariable(
"APPLET_ARCHIVE",
" archive=\"".$this->object->getJavaArchive().
"\"");
508 if (strpos($this->object->getJavaAppletFilename(),
".jar") !== FALSE)
510 $template->setVariable(
"APPLET_ARCHIVE",
" archive=\"".$this->object->getJavaPathWeb().$this->object->getJavaAppletFilename().
"\"");
513 if (strlen($this->object->getJavaCodebase()) > 0)
515 $template->setVariable(
"APPLET_CODEBASE",
" codebase=\"".$this->object->getJavaCodebase().
"\"");
519 if (strpos($this->object->getJavaAppletFilename(),
".class") !== FALSE)
521 $template->setVariable(
"APPLET_CODEBASE",
" codebase=\"".$this->object->getJavaPathWeb().
"\"");
524 $questionoutput = $template->get();
525 if (!$show_question_only)
530 return $questionoutput;
535 $userdata = $this->
object->getActiveUserData($active_id);
537 include_once
"./Services/UICore/classes/class.ilTemplate.php";
538 $template =
new ilTemplate(
"tpl.il_as_qpl_javaapplet_question_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
539 $template->setCurrentBlock(
"appletparam");
540 $template->setVariable(
"PARAM_NAME",
"test_type");
541 include_once
"./Modules/Test/classes/class.ilObjTest.php";
544 $template->setVariable(
"PARAM_VALUE",
"0");
548 $template->setVariable(
"PARAM_VALUE",
"1");
550 $template->parseCurrentBlock();
551 $template->setCurrentBlock(
"appletparam");
552 $template->setVariable(
"PARAM_NAME",
"active_id");
553 $template->setVariable(
"PARAM_VALUE", $active_id);
554 $template->parseCurrentBlock();
555 $template->setCurrentBlock(
"appletparam");
556 $template->setVariable(
"PARAM_NAME",
"test_id");
557 $template->setVariable(
"PARAM_VALUE", $userdata[
"test_id"]);
558 $template->parseCurrentBlock();
559 $template->setCurrentBlock(
"appletparam");
560 $template->setVariable(
"PARAM_NAME",
"question_id");
561 $template->setVariable(
"PARAM_VALUE", $this->object->getId());
562 $template->parseCurrentBlock();
563 $template->setCurrentBlock(
"appletparam");
564 $template->setVariable(
"PARAM_NAME",
"user_id");
565 $template->setVariable(
"PARAM_VALUE", $userdata[
"user_id"]);
566 $template->parseCurrentBlock();
567 $template->setCurrentBlock(
"appletparam");
568 $template->setVariable(
"PARAM_NAME",
"points_max");
569 $template->setVariable(
"PARAM_VALUE", $this->object->getPoints());
570 $template->parseCurrentBlock();
571 $template->setCurrentBlock(
"appletparam");
572 $template->setVariable(
"PARAM_NAME",
"session_id");
573 $template->setVariable(
"PARAM_VALUE",
$_COOKIE[
"PHPSESSID"]);
574 $template->parseCurrentBlock();
575 $template->setCurrentBlock(
"appletparam");
576 $template->setVariable(
"PARAM_NAME",
"client");
577 $template->setVariable(
"PARAM_VALUE", CLIENT_ID);
578 $template->parseCurrentBlock();
579 $template->setCurrentBlock(
"appletparam");
580 $template->setVariable(
"PARAM_NAME",
"pass");
582 $template->setVariable(
"PARAM_VALUE", $actualpass);
583 $template->parseCurrentBlock();
584 $template->setCurrentBlock(
"appletparam");
585 $template->setVariable(
"PARAM_NAME",
"post_url");
587 $template->parseCurrentBlock();
589 for ($i = 0; $i < $this->
object->getParameterCount(); $i++)
591 $parameter = $this->
object->getParameter($i);
592 $template->setCurrentBlock(
"appletparam");
593 $template->setVariable(
"PARAM_NAME", $parameter[
"name"]);
594 $template->setVariable(
"PARAM_VALUE", $parameter[
"value"]);
595 $template->parseCurrentBlock();
601 include_once
"./Modules/Test/classes/class.ilObjTest.php";
606 $info = $this->
object->getReachedInformation($active_id,
$pass);
607 foreach ($info as $kk => $infodata)
609 $template->setCurrentBlock(
"appletparam");
610 $template->setVariable(
"PARAM_NAME",
"value_" . $infodata[
"order"] .
"_1");
611 $template->setVariable(
"PARAM_VALUE", $infodata[
"value1"]);
612 $template->parseCurrentBlock();
613 $template->setCurrentBlock(
"appletparam");
614 $template->setVariable(
"PARAM_NAME",
"value_" . $infodata[
"order"] .
"_2");
615 $template->setVariable(
"PARAM_VALUE", $infodata[
"value2"]);
616 $template->parseCurrentBlock();
618 include_once
'./Services/Administration/classes/class.ilSetting.php';
620 if ($soapSetting->get(
"soap_user_administration") == 1)
622 $template->setCurrentBlock(
"appletparam");
623 $template->setVariable(
"PARAM_NAME",
"server");
628 $questiontext = $this->
object->getQuestion();
629 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
630 $template->setVariable(
"APPLET_WIDTH", $this->object->getJavaWidth());
631 $template->setVariable(
"APPLET_HEIGHT", $this->object->getJavaHeight());
632 $template->setVariable(
"APPLET_CODE", $this->object->getJavaCode());
633 if (strlen($this->object->getJavaArchive()) > 0)
635 $template->setVariable(
"APPLET_ARCHIVE",
" archive=\"".$this->object->getJavaArchive().
"\"");
639 if (strpos($this->object->getJavaAppletFilename(),
".jar") !== FALSE)
641 $template->setVariable(
"APPLET_ARCHIVE",
" archive=\"".$this->object->getJavaPathWeb().$this->object->getJavaAppletFilename().
"\"");
644 if (strlen($this->object->getJavaCodebase()) > 0)
646 $template->setVariable(
"APPLET_CODEBASE",
" codebase=\"".$this->object->getJavaCodebase().
"\"");
650 if (strpos($this->object->getJavaAppletFilename(),
".class") !== FALSE)
652 $template->setVariable(
"APPLET_CODEBASE",
" codebase=\"".$this->object->getJavaPathWeb().
"\"");
655 $questionoutput = $template->get();
656 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
669 global $rbacsystem, $ilTabs;
671 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
672 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
673 $q_type = $this->
object->getQuestionType();
677 $classname = $q_type .
"GUI";
678 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
679 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
684 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
687 $ilTabs->addTarget(
"edit_page",
688 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
689 array(
"edit",
"insert",
"exec_pg"),
690 "",
"", $force_active);
694 $ilTabs->addTarget(
"preview",
695 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"preview"),
697 "ilAssQuestionPageGUI",
"", $force_active);
700 $force_active =
false;
701 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
704 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
705 $commands =
$_POST[
"cmd"];
706 if (is_array($commands))
708 foreach ($commands as $key => $value)
710 if (preg_match(
"/^delete_.*/", $key, $matches))
712 $force_active =
true;
717 $ilTabs->addTarget(
"edit_question",
719 array(
"editQuestion",
"save",
"saveEdit",
"addkvp",
"removekvp",
"originalSyncForm"),
720 $classname,
"", $force_active);
731 $ilTabs->addTarget(
"solution_hint",
732 $this->ctrl->getLinkTargetByClass($classname,
"suggestedsolution"),
733 array(
"suggestedsolution",
"saveSuggestedSolution",
"outSolutionExplorer",
"cancel",
734 "addSuggestedSolution",
"cancelExplorer",
"linkChilds",
"removeSuggestedSolution"
744 $ilTabs->addTarget(
"statistics",
745 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
750 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
755 global $___test_express_mode;
757 if (!
$_GET[
'test_express_mode'] && !$___test_express_mode) {
758 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"),
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
762 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"), $link);
767 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));
774 return $this->
object->prepareTextareaOutput($output, TRUE);