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;
66 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
70 $this->
object->setPoints(
$_POST[
"points"]);
82 if (
$_POST[
'delete_applet'])
85 $this->
object->deleteJavaAppletFilename();
89 $this->
object->setJavaAppletFilename(
$_POST[
'uploaded_javaapplet'] );
93 if (!empty($_FILES[
'javaappletName'][
'tmp_name']))
95 $this->
object->setJavaAppletFilename( $_FILES[
'javaappletName'][
'name'],
96 $_FILES[
'javaappletName'][
'tmp_name']
99 $this->
object->setJavaCode(
$_POST[
"java_code"] );
100 $this->
object->setJavaCodebase(
$_POST[
"java_codebase"] );
101 $this->
object->setJavaArchive(
$_POST[
"java_archive"] );
102 $this->
object->setJavaWidth(
$_POST[
"java_width"] );
103 $this->
object->setJavaHeight(
$_POST[
"java_height"] );
105 $this->
object->flushParams();
106 if (is_array(
$_POST[
'kvp'][
'key'] ))
108 foreach (
$_POST[
'kvp'][
'key'] as $idx => $val)
110 if (strlen( $val ) && strlen(
$_POST[
'kvp'][
'value'][$idx] ))
112 $this->
object->addParameter( $val,
$_POST[
'kvp'][
'value'][$idx] );
127 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
129 $form->setFormAction($this->ctrl->getFormAction($this));
131 $form->setMultipart(
true);
132 $form->setTableWidth(
"100%");
133 $form->setId(
"assjavaapplet");
146 $form->setValuesByPost();
147 $errors = !$form->checkInput();
148 $form->setValuesByPost();
149 if (
$errors) $checkonly =
false;
152 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
160 $points->
setValue( $this->object->getPoints() );
161 $points->setRequired( TRUE );
162 $points->setSize( 3 );
163 $points->setMinValue( 0.0 );
167 $header->setTitle( $this->lng->txt(
"applet_attributes" ) );
171 $javaapplet = $this->
object->getJavaAppletFilename();
172 $applet =
new ilFileInputGUI($this->lng->txt(
'javaapplet' ),
'javaappletName');
174 $applet->setRequired(
false );
176 if (strlen( $javaapplet ))
183 $delete->setOptionTitle( $this->lng->txt(
'delete' ) );
184 $delete->setValue( 1 );
185 $applet->addSubItem( $delete );
190 $code =
new ilTextInputGUI($this->lng->txt(
"code" ),
"java_code");
191 $code->
setValue( $this->object->getJavaCode() );
192 $code->setRequired( TRUE );
195 if (!strlen( $javaapplet ))
198 $archive =
new ilTextInputGUI($this->lng->txt(
"archive" ),
"java_archive");
199 $archive->
setValue( $this->object->getJavaArchive() );
200 $archive->setRequired(
false );
204 $codebase =
new ilTextInputGUI($this->lng->txt(
"codebase" ),
"java_codebase");
205 $codebase->
setValue( $this->object->getJavaCodebase() );
206 $codebase->setRequired(
false );
213 $width->setSize( 6 );
214 $width->setMinValue( 50 );
215 $width->setMaxLength( 6 );
216 $width->setValue( $this->object->getJavaWidth() );
217 $width->setRequired( TRUE );
223 $height->setSize( 6 );
224 $height->setMinValue( 50 );
225 $height->setMaxLength( 6 );
226 $height->setValue( $this->object->getJavaHeight() );
227 $height->setRequired( TRUE );
231 $header->setTitle( $this->lng->txt(
"applet_parameters" ) );
234 include_once
"./Modules/TestQuestionPool/classes/class.ilKVPWizardInputGUI.php";
237 for ($i = 0; $i < $this->
object->getParameterCount(); $i++)
239 $param = $this->
object->getParameter( $i );
240 array_push( $values, array( $param[
'name'], $param[
'value'] ) );
242 if (count( $values ) == 0)
244 array_push( $values, array(
"",
"" ) );
246 $kvp->setKeyName( $this->lng->txt(
'name' ) );
247 $kvp->setValueName( $this->lng->txt(
'value' ) );
248 $kvp->setValues( $values );
258 $position = key(
$_POST[
'cmd'][
'addkvp']);
259 $this->
object->addParameterAtIndex($position+1,
"",
"");
269 $position = key(
$_POST[
'cmd'][
'removekvp']);
270 $this->
object->removeParameter($position);
290 $graphicalOutput = FALSE,
291 $result_output = FALSE,
292 $show_question_only = TRUE,
293 $show_feedback = FALSE,
294 $show_correct_solution = FALSE,
295 $show_manual_scoring = FALSE,
296 $show_question_text = TRUE
299 $userdata = $this->
object->getActiveUserData($active_id);
302 include_once
"./Services/UICore/classes/class.ilTemplate.php";
303 include_once
"./Modules/Test/classes/class.ilObjTest.php";
304 $template =
new ilTemplate(
"tpl.il_as_qpl_javaapplet_question_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
305 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
306 if (strlen($userdata[
"test_id"]))
308 $template->setCurrentBlock(
"appletparam");
309 $template->setVariable(
"PARAM_NAME",
"test_type");
312 $template->setVariable(
"PARAM_VALUE",
"0");
316 $template->setVariable(
"PARAM_VALUE",
"1");
318 $template->parseCurrentBlock();
320 if (strlen($userdata[
"test_id"]))
322 $template->setCurrentBlock(
"appletparam");
323 $template->setVariable(
"PARAM_NAME",
"test_id");
324 $template->setVariable(
"PARAM_VALUE", $userdata[
"test_id"]);
325 $template->parseCurrentBlock();
327 $template->setCurrentBlock(
"appletparam");
328 $template->setVariable(
"PARAM_NAME",
"active_id");
329 $template->setVariable(
"PARAM_VALUE", $active_id);
330 $template->parseCurrentBlock();
331 $template->setCurrentBlock(
"appletparam");
332 $template->setVariable(
"PARAM_NAME",
"question_id");
333 $template->setVariable(
"PARAM_VALUE", $this->object->getId());
334 $template->parseCurrentBlock();
335 if (strlen($userdata[
"user_id"]))
337 $template->setCurrentBlock(
"appletparam");
338 $template->setVariable(
"PARAM_NAME",
"user_id");
339 $template->setVariable(
"PARAM_VALUE", $userdata[
"user_id"]);
340 $template->parseCurrentBlock();
342 $template->setCurrentBlock(
"appletparam");
343 $template->setVariable(
"PARAM_NAME",
"points_max");
344 $template->setVariable(
"PARAM_VALUE", $this->object->getPoints());
345 $template->parseCurrentBlock();
346 $template->setCurrentBlock(
"appletparam");
347 $template->setVariable(
"PARAM_NAME",
"session_id");
348 $template->setVariable(
"PARAM_VALUE",
$_COOKIE[
"PHPSESSID"]);
349 $template->parseCurrentBlock();
350 $template->setCurrentBlock(
"appletparam");
351 $template->setVariable(
"PARAM_NAME",
"client");
352 $template->setVariable(
"PARAM_VALUE", CLIENT_ID);
353 $template->parseCurrentBlock();
354 $template->setCurrentBlock(
"appletparam");
355 $template->setVariable(
"PARAM_NAME",
"pass");
357 $template->setVariable(
"PARAM_VALUE", $actualpass);
358 $template->parseCurrentBlock();
360 for ($i = 0; $i < $this->
object->getParameterCount(); $i++)
362 $parameter = $this->
object->getParameter($i);
363 $template->setCurrentBlock(
"appletparam");
364 $template->setVariable(
"PARAM_NAME", $parameter[
"name"]);
365 $template->setVariable(
"PARAM_VALUE", $parameter[
"value"]);
366 $template->parseCurrentBlock();
369 if (($active_id > 0) && (!$show_correct_solution))
372 include_once
"./Modules/Test/classes/class.ilObjTest.php";
373 $info = $this->
object->getReachedInformation($active_id,
$pass);
374 foreach ($info as $kk => $infodata)
376 $template->setCurrentBlock(
"appletparam");
377 $template->setVariable(
"PARAM_NAME",
"value_" . $infodata[
"order"] .
"_1");
378 $template->setVariable(
"PARAM_VALUE", $infodata[
"value1"]);
379 $template->parseCurrentBlock();
380 $template->setCurrentBlock(
"appletparam");
381 $template->setVariable(
"PARAM_NAME",
"value_" . $infodata[
"order"] .
"_2");
382 $template->setVariable(
"PARAM_VALUE", $infodata[
"value2"]);
383 $template->parseCurrentBlock();
387 $questiontext = $this->
object->getQuestion();
388 if ($show_question_text==
true)
390 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
392 $template->setVariable(
"APPLET_WIDTH", $this->object->getJavaWidth());
393 $template->setVariable(
"APPLET_HEIGHT", $this->object->getJavaHeight());
394 $template->setVariable(
"APPLET_CODE", $this->object->getJavaCode());
395 if (strlen($this->object->getJavaArchive()) > 0)
397 $template->setVariable(
"APPLET_ARCHIVE",
" archive=\"".$this->object->getJavaArchive().
"\"");
401 if (strpos($this->object->getJavaAppletFilename(),
".jar") !== FALSE)
403 $template->setVariable(
"APPLET_ARCHIVE",
" archive=\"".$this->object->getJavaPathWeb().$this->object->getJavaAppletFilename().
"\"");
406 if (strlen($this->object->getJavaCodebase()) > 0)
408 $template->setVariable(
"APPLET_CODEBASE",
" codebase=\"".$this->object->getJavaCodebase().
"\"");
412 if (strpos($this->object->getJavaAppletFilename(),
".class") !== FALSE)
414 $template->setVariable(
"APPLET_CODEBASE",
" codebase=\"".$this->object->getJavaPathWeb().
"\"");
417 if (($active_id > 0) && (!$show_correct_solution))
419 if ($graphicalOutput)
422 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
423 if ($reached_points == $this->object->getPoints())
425 $template->setCurrentBlock(
"icon_ok");
427 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
428 $template->parseCurrentBlock();
432 $template->setCurrentBlock(
"icon_ok");
433 if ($reached_points > 0)
436 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
441 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
443 $template->parseCurrentBlock();
447 $questionoutput = $template->get();
449 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $feedback);
450 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
452 $solutionoutput = $solutiontemplate->get();
453 if (!$show_question_only)
458 return $solutionoutput;
461 function getPreview($show_question_only = FALSE, $showInlineFeedback =
false)
464 include_once
"./Services/UICore/classes/class.ilTemplate.php";
465 $template =
new ilTemplate(
"tpl.il_as_qpl_javaapplet_question_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
466 $template->setCurrentBlock(
"appletparam");
467 $template->setVariable(
"PARAM_NAME",
"question_id");
468 $template->setVariable(
"PARAM_VALUE", $this->object->getId());
469 $template->parseCurrentBlock();
470 $template->setCurrentBlock(
"appletparam");
471 $template->setVariable(
"PARAM_NAME",
"points_max");
472 $template->setVariable(
"PARAM_VALUE", $this->object->getPoints());
473 $template->parseCurrentBlock();
474 $template->setCurrentBlock(
"appletparam");
475 $template->setVariable(
"PARAM_NAME",
"session_id");
476 $template->setVariable(
"PARAM_VALUE",
$_COOKIE[
"PHPSESSID"]);
477 $template->parseCurrentBlock();
478 $template->setCurrentBlock(
"appletparam");
479 $template->setVariable(
"PARAM_NAME",
"client");
480 $template->setVariable(
"PARAM_VALUE", CLIENT_ID);
481 $template->parseCurrentBlock();
483 for ($i = 0; $i < $this->
object->getParameterCount(); $i++)
485 $parameter = $this->
object->getParameter($i);
486 $template->setCurrentBlock(
"appletparam");
487 $template->setVariable(
"PARAM_NAME", $parameter[
"name"]);
488 $template->setVariable(
"PARAM_VALUE", $parameter[
"value"]);
489 $template->parseCurrentBlock();
492 $questiontext = $this->
object->getQuestion();
493 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
494 $template->setVariable(
"APPLET_WIDTH", $this->object->getJavaWidth());
495 $template->setVariable(
"APPLET_HEIGHT", $this->object->getJavaHeight());
496 $template->setVariable(
"APPLET_CODE", $this->object->getJavaCode());
497 if (strlen($this->object->getJavaArchive()) > 0)
499 $template->setVariable(
"APPLET_ARCHIVE",
" archive=\"".$this->object->getJavaArchive().
"\"");
503 if (strpos($this->object->getJavaAppletFilename(),
".jar") !== FALSE)
505 $template->setVariable(
"APPLET_ARCHIVE",
" archive=\"".$this->object->getJavaPathWeb().$this->object->getJavaAppletFilename().
"\"");
508 if (strlen($this->object->getJavaCodebase()) > 0)
510 $template->setVariable(
"APPLET_CODEBASE",
" codebase=\"".$this->object->getJavaCodebase().
"\"");
514 if (strpos($this->object->getJavaAppletFilename(),
".class") !== FALSE)
516 $template->setVariable(
"APPLET_CODEBASE",
" codebase=\"".$this->object->getJavaPathWeb().
"\"");
519 $questionoutput = $template->get();
520 if (!$show_question_only)
525 return $questionoutput;
530 $userdata = $this->
object->getActiveUserData($active_id);
532 include_once
"./Services/UICore/classes/class.ilTemplate.php";
533 $template =
new ilTemplate(
"tpl.il_as_qpl_javaapplet_question_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
534 $template->setCurrentBlock(
"appletparam");
535 $template->setVariable(
"PARAM_NAME",
"test_type");
536 include_once
"./Modules/Test/classes/class.ilObjTest.php";
539 $template->setVariable(
"PARAM_VALUE",
"0");
543 $template->setVariable(
"PARAM_VALUE",
"1");
545 $template->parseCurrentBlock();
546 $template->setCurrentBlock(
"appletparam");
547 $template->setVariable(
"PARAM_NAME",
"active_id");
548 $template->setVariable(
"PARAM_VALUE", $active_id);
549 $template->parseCurrentBlock();
550 $template->setCurrentBlock(
"appletparam");
551 $template->setVariable(
"PARAM_NAME",
"test_id");
552 $template->setVariable(
"PARAM_VALUE", $userdata[
"test_id"]);
553 $template->parseCurrentBlock();
554 $template->setCurrentBlock(
"appletparam");
555 $template->setVariable(
"PARAM_NAME",
"question_id");
556 $template->setVariable(
"PARAM_VALUE", $this->object->getId());
557 $template->parseCurrentBlock();
558 $template->setCurrentBlock(
"appletparam");
559 $template->setVariable(
"PARAM_NAME",
"user_id");
560 $template->setVariable(
"PARAM_VALUE", $userdata[
"user_id"]);
561 $template->parseCurrentBlock();
562 $template->setCurrentBlock(
"appletparam");
563 $template->setVariable(
"PARAM_NAME",
"points_max");
564 $template->setVariable(
"PARAM_VALUE", $this->object->getPoints());
565 $template->parseCurrentBlock();
566 $template->setCurrentBlock(
"appletparam");
567 $template->setVariable(
"PARAM_NAME",
"session_id");
568 $template->setVariable(
"PARAM_VALUE",
$_COOKIE[
"PHPSESSID"]);
569 $template->parseCurrentBlock();
570 $template->setCurrentBlock(
"appletparam");
571 $template->setVariable(
"PARAM_NAME",
"client");
572 $template->setVariable(
"PARAM_VALUE", CLIENT_ID);
573 $template->parseCurrentBlock();
574 $template->setCurrentBlock(
"appletparam");
575 $template->setVariable(
"PARAM_NAME",
"pass");
577 $template->setVariable(
"PARAM_VALUE", $actualpass);
578 $template->parseCurrentBlock();
579 $template->setCurrentBlock(
"appletparam");
580 $template->setVariable(
"PARAM_NAME",
"post_url");
582 $template->parseCurrentBlock();
584 for ($i = 0; $i < $this->
object->getParameterCount(); $i++)
586 $parameter = $this->
object->getParameter($i);
587 $template->setCurrentBlock(
"appletparam");
588 $template->setVariable(
"PARAM_NAME", $parameter[
"name"]);
589 $template->setVariable(
"PARAM_VALUE", $parameter[
"value"]);
590 $template->parseCurrentBlock();
596 include_once
"./Modules/Test/classes/class.ilObjTest.php";
601 $info = $this->
object->getReachedInformation($active_id,
$pass);
602 foreach ($info as $kk => $infodata)
604 $template->setCurrentBlock(
"appletparam");
605 $template->setVariable(
"PARAM_NAME",
"value_" . $infodata[
"order"] .
"_1");
606 $template->setVariable(
"PARAM_VALUE", $infodata[
"value1"]);
607 $template->parseCurrentBlock();
608 $template->setCurrentBlock(
"appletparam");
609 $template->setVariable(
"PARAM_NAME",
"value_" . $infodata[
"order"] .
"_2");
610 $template->setVariable(
"PARAM_VALUE", $infodata[
"value2"]);
611 $template->parseCurrentBlock();
613 include_once
'./Services/Administration/classes/class.ilSetting.php';
615 if ($soapSetting->get(
"soap_user_administration") == 1)
617 $template->setCurrentBlock(
"appletparam");
618 $template->setVariable(
"PARAM_NAME",
"server");
623 $questiontext = $this->
object->getQuestion();
624 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
625 $template->setVariable(
"APPLET_WIDTH", $this->object->getJavaWidth());
626 $template->setVariable(
"APPLET_HEIGHT", $this->object->getJavaHeight());
627 $template->setVariable(
"APPLET_CODE", $this->object->getJavaCode());
628 if (strlen($this->object->getJavaArchive()) > 0)
630 $template->setVariable(
"APPLET_ARCHIVE",
" archive=\"".$this->object->getJavaArchive().
"\"");
634 if (strpos($this->object->getJavaAppletFilename(),
".jar") !== FALSE)
636 $template->setVariable(
"APPLET_ARCHIVE",
" archive=\"".$this->object->getJavaPathWeb().$this->object->getJavaAppletFilename().
"\"");
639 if (strlen($this->object->getJavaCodebase()) > 0)
641 $template->setVariable(
"APPLET_CODEBASE",
" codebase=\"".$this->object->getJavaCodebase().
"\"");
645 if (strpos($this->object->getJavaAppletFilename(),
".class") !== FALSE)
647 $template->setVariable(
"APPLET_CODEBASE",
" codebase=\"".$this->object->getJavaPathWeb().
"\"");
650 $questionoutput = $template->get();
651 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
664 global $rbacsystem, $ilTabs;
666 $ilTabs->clearTargets();
668 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
669 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
670 $q_type = $this->
object->getQuestionType();
674 $classname = $q_type .
"GUI";
675 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
676 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
681 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
684 $ilTabs->addTarget(
"edit_page",
685 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
686 array(
"edit",
"insert",
"exec_pg"),
687 "",
"", $force_active);
693 $force_active =
false;
694 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
697 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
698 $commands =
$_POST[
"cmd"];
699 if (is_array($commands))
701 foreach ($commands as $key => $value)
703 if (preg_match(
"/^delete_.*/", $key, $matches))
705 $force_active =
true;
710 $ilTabs->addTarget(
"edit_question",
712 array(
"editQuestion",
"save",
"saveEdit",
"addkvp",
"removekvp",
"originalSyncForm"),
713 $classname,
"", $force_active);
728 $ilTabs->addTarget(
"statistics",
729 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
740 return $this->
object->prepareTextareaOutput($output, TRUE);