4 require_once
'./Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
5 require_once
'./Modules/TestQuestionPool/interfaces/interface.ilGuiQuestionScoringAdjustable.php';
6 require_once
'./Modules/TestQuestionPool/interfaces/interface.ilGuiAnswerScoringAdjustable.php';
7 require_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
37 include_once
"./Modules/TestQuestionPool/classes/class.assMatchingQuestion.php";
42 $this->
object->loadFromDb($id);
55 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
70 $this->
object->flushMatchingPairs();
71 $this->
object->flushTerms();
72 $this->
object->flushDefinitions();
75 require_once
'./Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php';
76 foreach (
$_POST[
'terms'][
'answer'] as $index => $answer)
79 if (strlen( $_FILES[
'terms'][
'name'][
'image'][$index] ))
82 $name = $_FILES[
'terms'][
'name'][
'image'][$index];
83 if ($this->object->setImageFile( $_FILES[
'terms'][
'tmp_name'][
'image'][$index],
84 $this->object->getEncryptedFilename( $name )
88 $filename = $this->
object->getEncryptedFilename( $name );
99 require_once
'./Modules/TestQuestionPool/classes/class.assAnswerMatchingDefinition.php';
100 foreach (
$_POST[
'definitions'][
'answer'] as $index => $answer)
103 if (strlen( $_FILES[
'definitions'][
'name'][
'image'][$index] ))
106 $name = $_FILES[
'definitions'][
'name'][
'image'][$index];
107 if ($this->object->setImageFile( $_FILES[
'definitions'][
'tmp_name'][
'image'][$index],
108 $this->object->getEncryptedFilename( $name )
112 $filename = $this->
object->getEncryptedFilename( $name );
119 $this->
object->addDefinition(
125 if (is_array(
$_POST[
'pairs'][
'points'] ))
127 require_once
'./Modules/TestQuestionPool/classes/class.assAnswerMatchingPair.php';
128 foreach (
$_POST[
'pairs'][
'points'] as $index => $points)
130 $term_id =
$_POST[
'pairs'][
'term'][$index];
131 $definition_id =
$_POST[
'pairs'][
'definition'][$index];
132 $this->
object->addMatchingPair( $this->object->getTermWithIdentifier( $term_id ),
133 $this->
object->getDefinitionWithIdentifier( $definition_id ),
142 if (!$this->object->getSelfAssessmentEditingMode())
144 $this->
object->setShuffle(
$_POST[
"shuffle"] );
148 $this->
object->setShuffle( 1 );
150 $this->
object->setThumbGeometry(
$_POST[
"thumb_geometry"] );
151 $this->
object->setElementHeight(
$_POST[
"element_height"] );
163 $position = key(
$_POST[
'cmd'][
'removeimageterms']);
164 $this->
object->removeTermImage($position);
177 $position = key(
$_POST[
'cmd'][
'removeimagedefinitions']);
178 $this->
object->removeDefinitionImage($position);
185 $position = key(
$_POST[
"cmd"][
"addterms"]);
186 $this->
object->insertTerm($position+1);
193 $position = key(
$_POST[
"cmd"][
"removeterms"]);
194 $this->
object->deleteTerm($position);
201 $position = key(
$_POST[
"cmd"][
"adddefinitions"]);
202 $this->
object->insertDefinition($position+1);
209 $position = key(
$_POST[
"cmd"][
"removedefinitions"]);
210 $this->
object->deleteDefinition($position);
217 $position = key(
$_POST[
"cmd"][
"addpairs"]);
218 $this->
object->insertMatchingPair($position+1);
225 $position = key(
$_POST[
"cmd"][
"removepairs"]);
226 $this->
object->deleteMatchingPair($position);
235 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
237 $form->setFormAction($this->ctrl->getFormAction($this));
239 $form->setMultipart(
true);
240 $form->setTableWidth(
"100%");
241 $form->setId(
"matching");
254 $form->setValuesByPost();
255 $errors = !$form->checkInput();
256 $form->setValuesByPost();
260 $terms = $form->getItemByPostVar(
'terms');
261 $terms->setAlert($this->lng->txt(
"msg_number_of_terms_too_low"));
264 if (
$errors) $checkonly =
false;
267 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
278 $numDefinitions = count($form->
getItemByPostVar(
'definitions')->getValues());
280 if($numTerms >= $numDefinitions)
291 include_once
"./Modules/TestQuestionPool/classes/class.ilMatchingWizardInputGUI.php";
293 if ($this->object->getSelfAssessmentEditingMode())
298 $definitions->setRequired(
true );
299 $definitions->setQuestionObject( $this->
object );
300 $definitions->setTextName( $this->lng->txt(
'definition_text' ) );
301 $definitions->setImageName( $this->lng->txt(
'definition_image' ) );
302 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingDefinition.php";
303 if (!count( $this->object->getDefinitions() ))
307 $definitionvalues = $this->
object->getDefinitions();
308 $definitions->setValues( $definitionvalues );
309 $definitions->checkInput();
310 $form->
addItem( $definitions );
313 include_once
"./Modules/TestQuestionPool/classes/class.ilMatchingWizardInputGUI.php";
315 if ($this->object->getSelfAssessmentEditingMode())
317 $terms->setRequired(
true );
318 $terms->setQuestionObject( $this->
object );
319 $terms->setTextName( $this->lng->txt(
'term_text' ) );
320 $terms->setImageName( $this->lng->txt(
'term_image' ) );
321 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php";
322 if (!count( $this->object->getTerms() ))
324 $termvalues = $this->
object->getTerms();
325 $terms->setValues( $termvalues );
326 $terms->checkInput();
330 include_once
"./Modules/TestQuestionPool/classes/class.ilMatchingPairWizardInputGUI.php";
333 $pairs->setTerms( $this->object->getTerms() );
334 $pairs->setDefinitions( $this->object->getDefinitions() );
335 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingPair.php";
336 if (count( $this->object->getMatchingPairs() ) == 0)
338 $this->
object->addMatchingPair(
new assAnswerMatchingPair($termvalues[0], $definitionvalues[0], 0) );
340 $pairs->setPairs( $this->object->getMatchingPairs() );
349 $hidden->setValue($matchingtype);
352 if (!$this->object->getSelfAssessmentEditingMode())
355 $shuffle =
new ilSelectInputGUI($this->lng->txt(
"shuffle_answers" ),
"shuffle");
356 $shuffle_options = array(
357 0 => $this->lng->txt(
"no" ),
358 1 => $this->lng->txt(
"matching_shuffle_terms_definitions" ),
359 2 => $this->lng->txt(
"matching_shuffle_terms" ),
360 3 => $this->lng->txt(
"matching_shuffle_definitions" )
363 $shuffle->setValue($this->object->getShuffle() != null ? $this->
object->getShuffle() : 1);
364 $shuffle->setRequired( FALSE );
367 $element_height =
new ilNumberInputGUI($this->lng->txt(
"element_height" ),
"element_height");
368 $element_height->
setValue( $this->object->getElementHeight() );
369 $element_height->setRequired(
false );
370 $element_height->setMaxLength( 6 );
371 $element_height->setMinValue( 20 );
372 $element_height->setSize( 6 );
373 $element_height->setInfo( $this->lng->txt(
"element_height_info" ) );
374 $form->
addItem( $element_height );
376 $geometry =
new ilNumberInputGUI($this->lng->txt(
"thumb_geometry" ),
"thumb_geometry");
377 $geometry->
setValue( $this->object->getThumbGeometry() );
378 $geometry->setRequired(
true );
379 $geometry->setMaxLength( 6 );
380 $geometry->setMinValue( 20 );
381 $geometry->setSize( 6 );
382 $geometry->setInfo( $this->lng->txt(
"thumb_geometry_info" ) );
389 $test_output = $this->
getTestOutput($active_id,
$pass, $is_postponed, $user_post_solution);
390 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
391 $this->tpl->setVariable(
"FORMACTION", $formaction);
410 $graphicalOutput = FALSE,
411 $result_output = FALSE,
412 $show_question_only = TRUE,
413 $show_feedback = FALSE,
414 $show_correct_solution = FALSE,
415 $show_manual_scoring = FALSE,
416 $show_question_text = TRUE
420 include_once
"./Services/UICore/classes/class.ilTemplate.php";
421 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
422 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
424 $solutions = array();
425 if (($active_id > 0) && (!$show_correct_solution))
427 include_once
"./Modules/Test/classes/class.ilObjTest.php";
428 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
429 $solution_script .=
"";
433 foreach ($this->object->getMatchingPairs() as $pair)
435 if( $pair->points <= 0 )
440 $solutions[] = array(
441 "value1" => $pair->term->identifier,
442 "value2" => $pair->definition->identifier,
443 'points' => $pair->points
450 foreach ($solutions as $solution)
452 $definition = $this->
object->getDefinitionWithIdentifier($solution[
'value2']);
453 $term = $this->
object->getTermWithIdentifier($solution[
'value1']);
454 $points = $solution[
'points'];
456 if (is_object($definition))
458 if (strlen($definition->picture))
460 $template->setCurrentBlock(
'definition_image');
461 $template->setVariable(
'ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->picture);
464 $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $definition->picture);
465 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
467 $template->setVariable(
"TEXT_DEFINITION", (strlen($definition->text)) ? $this->lng->txt(
'definition') .
' ' . ($i+1) .
': ' .
ilUtil::prepareFormOutput($definition->text) : $this->lng->txt(
'definition') .
' ' . ($i+1));
468 $template->parseCurrentBlock();
472 $template->setCurrentBlock(
'definition_text');
473 $template->setVariable(
"DEFINITION", $this->object->prepareTextareaOutput($definition->text, TRUE));
474 $template->parseCurrentBlock();
477 if (is_object($term))
479 if (strlen($term->picture))
481 $template->setCurrentBlock(
'term_image');
482 $template->setVariable(
'ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->picture);
485 $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $term->picture);
486 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
487 $template->setVariable(
"TEXT_TERM", (strlen($term->text)) ? $this->lng->txt(
'term') .
' ' . ($i+1) .
': ' .
ilUtil::prepareFormOutput($term->text) : $this->lng->txt(
'term') .
' ' . ($i+1));
489 $template->parseCurrentBlock();
493 $template->setCurrentBlock(
'term_text');
494 $template->setVariable(
"TERM", $this->object->prepareTextareaOutput($term->text, TRUE));
495 $template->parseCurrentBlock();
499 if (($active_id > 0) && (!$show_correct_solution))
501 if ($graphicalOutput)
505 foreach ($this->object->getMatchingPairs() as $pair)
515 $template->setCurrentBlock(
"icon_ok");
517 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
518 $template->parseCurrentBlock();
522 $template->setCurrentBlock(
"icon_ok");
524 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
525 $template->parseCurrentBlock();
532 $resulttext = ($points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
533 $template->setCurrentBlock(
"result_output");
534 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $points));
535 $template->parseCurrentBlock();
538 $template->setCurrentBlock(
"row");
539 if ($this->object->getEstimatedElementHeight() > 0)
541 $template->setVariable(
"ELEMENT_HEIGHT",
" style=\"height: " . $this->object->getEstimatedElementHeight() .
"px;\"");
543 $template->setVariable(
"TEXT_MATCHES", $this->lng->txt(
"matches"));
544 $template->parseCurrentBlock();
547 $questiontext = $this->
object->getQuestion();
548 if ($show_question_text==
true)
550 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
553 $questionoutput = $template->get();
559 $feedback .= strlen($fb) ? $fb :
'';
562 $feedback .= strlen($fb) ? $fb :
'';
564 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput($feedback,
true));
566 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
568 $solutionoutput = $solutiontemplate->get();
569 if (!$show_question_only)
572 $solutionoutput =
'<div class="ilc_question_Standard">'.$solutionoutput.
"</div>";
574 return $solutionoutput;
582 include_once
"./Services/UICore/classes/class.ilTemplate.php";
583 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output_js.html", TRUE, TRUE,
"Modules/TestQuestionPool");
586 if (strcmp($this->ctrl->getCmd(),
'preview') == 0)
588 if (array_key_exists(
'js',
$_GET))
590 $ilUser->writePref(
'tst_javascript',
$_GET[
'js']);
592 $jstemplate =
new ilTemplate(
"tpl.il_as_qpl_javascript_switch.html", TRUE, TRUE,
"Modules/TestQuestionPool");
593 if ($ilUser->getPref(
"tst_javascript") == 1)
596 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_ALT", $this->lng->txt(
"disable_javascript"));
597 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_TITLE", $this->lng->txt(
"disable_javascript"));
598 $this->ctrl->setParameterByClass($this->ctrl->getCmdClass(),
"js",
"0");
599 $jstemplate->setVariable(
"JAVASCRIPT_URL", $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), $this->ctrl->getCmd()));
604 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_ALT", $this->lng->txt(
"enable_javascript"));
605 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_TITLE", $this->lng->txt(
"enable_javascript"));
606 $this->ctrl->setParameterByClass($this->ctrl->getCmdClass(),
"js",
"1");
607 $jstemplate->setVariable(
"JAVASCRIPT_URL", $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), $this->ctrl->getCmd()));
609 $jsswitch = $jstemplate->get();
610 if ($ilUser->getPref(
'tst_javascript')) $this->object->setOutputType(
OUTPUT_JAVASCRIPT);
614 $terms = $this->
object->getTerms();
615 $definitions = $this->
object->getDefinitions();
616 switch ($this->object->getShuffle())
619 $terms = $this->
object->pcArrayShuffle($terms);
620 $definitions = $this->
object->pcArrayShuffle($definitions);
623 $terms = $this->
object->pcArrayShuffle($terms);
626 $definitions = $this->
object->pcArrayShuffle($definitions);
630 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
635 foreach ($definitions as $definition)
637 if (strlen($definition->picture))
639 $template->setCurrentBlock(
"definition_picture");
640 $template->setVariable(
"DEFINITION_ID", $definition->identifier);
641 $template->setVariable(
"IMAGE_HREF", $this->object->getImagePathWeb() . $definition->picture);
642 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->picture;
643 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $definition->picture;
644 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
645 $template->setVariable(
"THUMBNAIL_HREF", $thumbweb);
646 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"image"));
647 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"image"));
648 $template->setVariable(
"TEXT_DEFINITION", (strlen($definition->text)) ? $this->object->prepareTextareaOutput($definition->text, TRUE) :
'');
649 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
651 $template->parseCurrentBlock();
655 $template->setCurrentBlock(
"definition_text");
656 $template->setVariable(
"DEFINITION", $this->object->prepareTextareaOutput($definition->text, TRUE));
657 $template->parseCurrentBlock();
660 $template->setCurrentBlock(
"droparea");
661 $template->setVariable(
"ID_DROPAREA", $definition->identifier);
662 $template->setVariable(
"QUESTION_ID", $this->object->getId());
663 if ($this->object->getEstimatedElementHeight() > 0)
665 $template->setVariable(
"ELEMENT_HEIGHT",
" style=\"height: " . $this->object->getEstimatedElementHeight() .
"px;\"");
667 $template->parseCurrentBlock();
669 $template->setCurrentBlock(
"init_dropareas");
670 $template->setVariable(
"COUNTER", $counter++);
671 $template->setVariable(
"ID_DROPAREA", $definition->identifier);
672 $template->parseCurrentBlock();
678 foreach ($terms as $term)
680 if (strlen($term->picture))
682 $template->setCurrentBlock(
"term_picture");
683 $template->setVariable(
"TERM_ID", $term->identifier);
684 $template->setVariable(
"IMAGE_HREF", $this->object->getImagePathWeb() . $term->picture);
685 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->picture;
686 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $term->picture;
687 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
688 $template->setVariable(
"THUMBNAIL_HREF", $thumbweb);
689 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"image"));
690 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"image"));
691 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
692 $template->setVariable(
"TEXT_TERM", (strlen($term->text)) ? $this->object->prepareTextareaOutput($term->text, TRUE) :
'');
694 $template->parseCurrentBlock();
698 $template->setCurrentBlock(
"term_text");
699 $template->setVariable(
"TERM_TEXT", $this->object->prepareTextareaOutput($term->text, TRUE));
700 $template->parseCurrentBlock();
702 $template->setCurrentBlock(
"draggable");
703 $template->setVariable(
"ID_DRAGGABLE", $term->identifier);
704 if ($this->object->getEstimatedElementHeight() > 0)
706 $template->setVariable(
"ELEMENT_HEIGHT",
" style=\"height: " . $this->object->getEstimatedElementHeight() .
"px;\"");
708 $template->parseCurrentBlock();
710 $template->setCurrentBlock(
"init_draggables");
711 $template->setVariable(
"COUNTER", $counter++);
712 $template->setVariable(
"ID_DRAGGABLE", $term->identifier);
713 $template->parseCurrentBlock();
716 $template->setVariable(
"RESET_BUTTON", $this->lng->txt(
"reset_terms"));
718 $this->tpl->setVariable(
"LOCATION_ADDITIONAL_STYLESHEET",
ilUtil::getStyleSheetLocation(
"output",
"test_javascript.css",
"Modules/TestQuestionPool"));
720 $questiontext = $this->
object->getQuestion();
721 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
722 $questionoutput = $jsswitch . $template->get();
723 if (!$show_question_only)
728 return $questionoutput;
736 include_once
"./Services/UICore/classes/class.ilTemplate.php";
737 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
740 if (strcmp($this->ctrl->getCmd(),
'preview') == 0)
742 if (array_key_exists(
'js',
$_GET))
744 $ilUser->writePref(
'tst_javascript',
$_GET[
'js']);
746 $jstemplate =
new ilTemplate(
"tpl.il_as_qpl_javascript_switch.html", TRUE, TRUE,
"Modules/TestQuestionPool");
747 if ($ilUser->getPref(
"tst_javascript") == 1)
750 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_ALT", $this->lng->txt(
"disable_javascript"));
751 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_TITLE", $this->lng->txt(
"disable_javascript"));
752 $this->ctrl->setParameterByClass($this->ctrl->getCmdClass(),
"js",
"0");
753 $jstemplate->setVariable(
"JAVASCRIPT_URL", $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), $this->ctrl->getCmd()));
758 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_ALT", $this->lng->txt(
"enable_javascript"));
759 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_TITLE", $this->lng->txt(
"enable_javascript"));
760 $this->ctrl->setParameterByClass($this->ctrl->getCmdClass(),
"js",
"1");
761 $jstemplate->setVariable(
"JAVASCRIPT_URL", $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), $this->ctrl->getCmd()));
763 $jsswitch = $jstemplate->get();
764 if ($ilUser->getPref(
'tst_javascript')) $this->object->setOutputType(
OUTPUT_JAVASCRIPT);
773 $terms = $this->
object->getTerms();
774 $definitions = $this->
object->getDefinitions();
775 switch ($this->object->getShuffle())
778 $terms = $this->
object->pcArrayShuffle($terms);
779 $definitions = $this->
object->pcArrayShuffle($definitions);
782 $terms = $this->
object->pcArrayShuffle($terms);
785 $definitions = $this->
object->pcArrayShuffle($definitions);
789 foreach ($definitions as $key => $definition)
791 if (is_object($definition))
793 if (strlen($definition->picture))
795 $template->setCurrentBlock(
'definition_image');
796 $template->setVariable(
'ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->picture);
799 $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $definition->picture);
800 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
802 $template->setVariable(
"TEXT_DEFINITION", (strlen($definition->text)) ? $this->lng->txt(
'definition') .
' ' . ($key+1) .
': ' . $this->object->prepareTextareaOutput($definition->text, TRUE) : $this->lng->txt(
'definition') .
' ' . ($key+1));
803 $template->parseCurrentBlock();
807 $template->setCurrentBlock(
'definition_text');
808 $template->setVariable(
"DEFINITION", $this->object->prepareTextareaOutput($definition->text, TRUE));
809 $template->parseCurrentBlock();
813 $template->setCurrentBlock(
'option');
814 $template->setVariable(
"VALUE_OPTION", 0);
816 $template->parseCurrentBlock();
817 foreach ($terms as $key => $term)
819 $template->setCurrentBlock(
'option');
820 $template->setVariable(
"VALUE_OPTION", $term->identifier);
821 $template->setVariable(
"TEXT_OPTION", (strlen($term->text)) ? $this->lng->txt(
'term') .
' ' . ($key +1) .
': ' .
ilUtil::prepareFormOutput($term->text) : $this->lng->txt(
'term') .
' ' . ($key+1));
822 $template->parseCurrentBlock();
825 $template->setCurrentBlock(
'row');
826 $template->setVariable(
"TEXT_MATCHES", $this->lng->txt(
"matches"));
827 if ($this->object->getEstimatedElementHeight() > 0)
829 $template->setVariable(
"ELEMENT_HEIGHT",
" style=\"height: " . $this->object->getEstimatedElementHeight() .
"px;\"");
831 $template->setVariable(
"QUESTION_ID", $this->object->getId());
832 $template->setVariable(
"DEFINITION_ID", $definition->identifier);
833 $template->parseCurrentBlock();
836 foreach ($terms as $key => $term)
838 if (strlen($term->picture))
840 $template->setCurrentBlock(
'term_image');
841 $template->setVariable(
'ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->picture);
844 $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $term->picture);
845 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
846 $template->setVariable(
"TEXT_TERM", (strlen($term->text)) ? $this->lng->txt(
'term') .
' ' . ($key+1) .
': ' . $this->object->prepareTextareaOutput($term->text, TRUE) : $this->lng->txt(
'term') .
' ' . ($key+1));
848 $template->parseCurrentBlock();
852 $template->setCurrentBlock(
'term_text');
853 $template->setVariable(
"TERM", $this->object->prepareTextareaOutput($term->text, TRUE));
854 $template->parseCurrentBlock();
856 $template->touchBlock(
'terms');
859 $questiontext = $this->
object->getQuestion();
860 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
863 $questionoutput = $jsswitch . $template->get();
864 if (!$show_question_only)
869 return $questionoutput;
875 foreach ($solution as $solution_values)
877 $id = $solution_values[
'value2'];
878 array_push($neworder, $this->object->getDefinitionWithIdentifier($id));
886 include_once
"./Services/UICore/classes/class.ilTemplate.php";
887 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output_js.html", TRUE, TRUE,
"Modules/TestQuestionPool");
892 include_once
"./Modules/Test/classes/class.ilObjTest.php";
897 if (is_array($user_post_solution))
899 $solutions = array();
900 foreach ($user_post_solution[
'matching'][$this->object->getId()] as $definition => $term)
902 array_push($solutions, array(
"value1" => $term,
"value2" => $definition));
907 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
910 foreach ($solutions as $idx => $solution_value)
914 if (($solution_value[
"value2"] > -1) && ($solution_value[
"value1"] > -1))
916 $template->setCurrentBlock(
"restoreposition");
917 $template->setVariable(
"TERM_ID", $solution_value[
"value1"]);
918 $template->setVariable(
"PICTURE_DEFINITION_ID", $solution_value[
"value2"]);
919 $template->parseCurrentBlock();
926 $terms = $this->
object->getTerms();
927 $definitions = $this->
object->getDefinitions();
928 switch ($this->object->getShuffle())
931 $terms = $this->
object->pcArrayShuffle($terms);
932 if (count($solutions))
938 $definitions = $this->
object->pcArrayShuffle($definitions);
942 $terms = $this->
object->pcArrayShuffle($terms);
945 if (count($solutions))
951 $definitions = $this->
object->pcArrayShuffle($definitions);
956 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
961 foreach ($definitions as $definition)
963 if (strlen($definition->picture))
965 $template->setCurrentBlock(
"definition_picture");
966 $template->setVariable(
"DEFINITION_ID", $definition->identifier);
967 $template->setVariable(
"IMAGE_HREF", $this->object->getImagePathWeb() . $definition->picture);
968 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->picture;
969 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $definition->picture;
970 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
971 $template->setVariable(
"THUMBNAIL_HREF", $thumbweb);
972 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"image"));
973 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"image"));
974 $template->setVariable(
"TEXT_DEFINITION", (strlen($definition->text)) ?
ilUtil::prepareFormOutput($definition->text) :
'');
975 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
977 $template->parseCurrentBlock();
981 $template->setCurrentBlock(
"definition_text");
982 $template->setVariable(
"DEFINITION", $this->object->prepareTextareaOutput($definition->text,
true));
983 $template->parseCurrentBlock();
986 $template->setCurrentBlock(
"droparea");
987 $template->setVariable(
"ID_DROPAREA", $definition->identifier);
988 $template->setVariable(
"QUESTION_ID", $this->object->getId());
989 if ($this->object->getEstimatedElementHeight() > 0)
991 $template->setVariable(
"ELEMENT_HEIGHT",
" style=\"height: " . $this->object->getEstimatedElementHeight() .
"px;\"");
993 $template->parseCurrentBlock();
995 $template->setCurrentBlock(
"init_dropareas");
996 $template->setVariable(
"COUNTER", $counter++);
997 $template->setVariable(
"ID_DROPAREA", $definition->identifier);
998 $template->parseCurrentBlock();
1004 foreach ($terms as $term)
1006 if (strlen($term->picture))
1008 $template->setCurrentBlock(
"term_picture");
1009 $template->setVariable(
"TERM_ID", $term->identifier);
1010 $template->setVariable(
"IMAGE_HREF", $this->object->getImagePathWeb() . $term->picture);
1011 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->picture;
1012 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $term->picture;
1013 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
1014 $template->setVariable(
"THUMBNAIL_HREF", $thumbweb);
1015 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"image"));
1016 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"image"));
1017 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
1020 $template->parseCurrentBlock();
1024 $template->setCurrentBlock(
"term_text");
1025 $template->setVariable(
"TERM_TEXT", $this->object->prepareTextareaOutput($term->text,
true));
1026 $template->parseCurrentBlock();
1028 $template->setCurrentBlock(
"draggable");
1029 $template->setVariable(
"ID_DRAGGABLE", $term->identifier);
1030 if ($this->object->getEstimatedElementHeight() > 0)
1032 $template->setVariable(
"ELEMENT_HEIGHT",
" style=\"height: " . $this->object->getEstimatedElementHeight() .
"px;\"");
1034 $template->parseCurrentBlock();
1036 $template->setCurrentBlock(
"init_draggables");
1037 $template->setVariable(
"COUNTER", $counter++);
1038 $template->setVariable(
"ID_DRAGGABLE", $term->identifier);
1039 $template->parseCurrentBlock();
1042 $template->setVariable(
"RESET_BUTTON", $this->lng->txt(
"reset_terms"));
1044 $this->tpl->setVariable(
"LOCATION_ADDITIONAL_STYLESHEET",
ilUtil::getStyleSheetLocation(
"output",
"test_javascript.css",
"Modules/TestQuestionPool"));
1046 $questiontext = $this->
object->getQuestion();
1047 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
1048 $questionoutput = $template->get();
1049 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
1060 include_once
"./Services/UICore/classes/class.ilTemplate.php";
1061 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1066 include_once
"./Modules/Test/classes/class.ilObjTest.php";
1071 if (is_array($user_post_solution))
1073 $solutions = array();
1074 foreach ($user_post_solution[
'matching'][$this->object->getId()] as $definition => $term)
1076 array_push($solutions, array(
"value1" => $term,
"value2" => $definition));
1081 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
1087 $terms = $this->
object->getTerms();
1088 $definitions = $this->
object->getDefinitions();
1089 switch ($this->object->getShuffle())
1092 $terms = $this->
object->pcArrayShuffle($terms);
1093 if (count($solutions))
1099 $definitions = $this->
object->pcArrayShuffle($definitions);
1103 $terms = $this->
object->pcArrayShuffle($terms);
1106 if (count($solutions))
1112 $definitions = $this->
object->pcArrayShuffle($definitions);
1116 $maxcount = max(count($terms), count($definitions));
1117 foreach ($definitions as $key => $definition)
1119 if (is_object($definition))
1121 if (strlen($definition->picture))
1123 $template->setCurrentBlock(
'definition_image');
1124 $template->setVariable(
'ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->picture);
1127 $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $definition->picture);
1128 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
1130 $template->setVariable(
"TEXT_DEFINITION", (strlen($definition->text)) ? $this->lng->txt(
'definition') .
' ' . ($key+1) .
': ' .
ilUtil::prepareFormOutput($definition->text) : $this->lng->txt(
'definition') .
' ' . ($key+1));
1131 $template->parseCurrentBlock();
1135 $template->setCurrentBlock(
'definition_text');
1136 $template->setVariable(
"DEFINITION", $this->object->prepareTextareaOutput($definition->text,
true));
1137 $template->parseCurrentBlock();
1141 $template->setCurrentBlock(
'option');
1142 $template->setVariable(
"VALUE_OPTION", 0);
1144 $template->parseCurrentBlock();
1145 foreach ($terms as $key => $term)
1147 $template->setCurrentBlock(
'option');
1148 $template->setVariable(
"VALUE_OPTION", $term->identifier);
1149 $template->setVariable(
"TEXT_OPTION", (strlen($term->text)) ? $this->lng->txt(
'term') .
' ' . ($key+1) .
': ' .
ilUtil::prepareFormOutput($term->text) : $this->lng->txt(
'term') .
' ' . ($key +1));
1150 foreach ($solutions as $solution)
1152 if ($solution[
"value1"] == $term->identifier && $solution[
"value2"] == $definition->identifier)
1154 $template->setVariable(
"SELECTED_OPTION",
" selected=\"selected\"");
1157 $template->parseCurrentBlock();
1160 $template->setCurrentBlock(
'row');
1161 $template->setVariable(
"TEXT_MATCHES", $this->lng->txt(
"matches"));
1162 if ($this->object->getEstimatedElementHeight() > 0)
1164 $template->setVariable(
"ELEMENT_HEIGHT",
" style=\"height: " . $this->object->getEstimatedElementHeight() .
"px;\"");
1166 $template->setVariable(
"QUESTION_ID", $this->object->getId());
1167 $template->setVariable(
"DEFINITION_ID", $definition->identifier);
1168 $template->parseCurrentBlock();
1170 foreach ($terms as $key=>$term)
1172 if (strlen($term->picture))
1174 $template->setCurrentBlock(
'term_image');
1175 $template->setVariable(
'ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->picture);
1178 $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $term->picture);
1179 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
1180 $template->setVariable(
"TEXT_TERM", (strlen($term->text)) ? $this->lng->txt(
'term') .
' ' . ($key+1) .
': ' .
ilUtil::prepareFormOutput($term->text) : $this->lng->txt(
'term') .
' ' . ($key+1));
1182 $template->parseCurrentBlock();
1186 $template->setCurrentBlock(
'term_text');
1187 $template->setVariable(
"TERM", $this->object->prepareTextareaOutput($term->text,
true));
1188 $template->parseCurrentBlock();
1190 $template->touchBlock(
'terms');
1193 $questiontext = $this->
object->getQuestion();
1194 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
1198 $questiontext = $this->
object->getQuestion();
1199 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
1200 $questionoutput = $template->get();
1201 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
1227 global $rbacsystem, $ilTabs;
1229 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
1230 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
1231 $q_type = $this->
object->getQuestionType();
1233 if (strlen($q_type))
1235 $classname = $q_type .
"GUI";
1236 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
1237 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
1242 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
1245 $ilTabs->addTarget(
"edit_page",
1246 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
1247 array(
"edit",
"insert",
"exec_pg"),
1248 "",
"", $force_active);
1252 $ilTabs->addTarget(
"preview",
1253 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"preview"),
1255 "ilAssQuestionPageGUI",
"", $force_active);
1258 $force_active =
false;
1259 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
1262 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
1264 $ilTabs->addTarget(
"edit_question",
1266 array(
"editQuestion",
"save",
"saveEdit",
"removeimageterms",
"uploadterms",
"removeimagedefinitions",
"uploaddefinitions",
1267 "addpairs",
"removepairs",
"addterms",
"removeterms",
"adddefinitions",
"removedefinitions",
"originalSyncForm"),
1268 $classname,
"", $force_active);
1279 $ilTabs->addTarget(
"solution_hint",
1280 $this->ctrl->getLinkTargetByClass($classname,
"suggestedsolution"),
1281 array(
"suggestedsolution",
"saveSuggestedSolution",
"outSolutionExplorer",
"cancel",
1282 "addSuggestedSolution",
"cancelExplorer",
"linkChilds",
"removeSuggestedSolution"
1292 $ilTabs->addTarget(
"statistics",
1293 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
1294 array(
"assessment"),
1298 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
1303 global $___test_express_mode;
1305 if (!
$_GET[
'test_express_mode'] && !$___test_express_mode) {
1306 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"),
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
1310 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"), $link);
1315 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));
1321 $feedback =
'<table><tbody>';
1323 foreach ($this->object->getMatchingPairs() as $idx => $ans)
1325 $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
1326 $this->object->getId(), $idx
1328 $feedback .=
'<tr><td><b><i>' . $ans->definition->text .
'</i></b></td><td>'. $this->lng->txt(
"matches") .
' ';
1329 $feedback .=
'</td><td><b><i>' . $ans->term->text .
'</i></b></td><td> </td><td>';
1330 $feedback .= $fb .
'</td> </tr>';
1333 $feedback .=
'</tbody></table>';
1334 return $this->
object->prepareTextareaOutput($feedback, TRUE);
1362 return array(
'shuffle',
'element_height',
'thumb_geometry');
1367 $element = $form->getItemByPostvar(
'thumb_geometry');
1368 $_POST[
'thumb_geometry'] = $this->
object->getThumbGeometry();
1369 $element->setValue( $this->object->getThumbGeometry() );
1374 foreach(array(
'definitions',
'terms') as $postvar)
1378 $matching_wizardinputgui->setDisableUpload(
true);
1379 $matching_wizardinputgui->setDisableActions(
true);
1380 $matching_wizardinputgui->setDisableText(
true);
1396 foreach($relevant_answers as
$pass)
1398 $passes[$pass[
'active_fi'].
'-'.$pass[
'pass']] =
'-';
1400 $passcount = count($passes);
1402 foreach($relevant_answers as $pass)
1404 $actives[$pass[
'active_fi']] = $pass[
'active_fi'];
1406 $usercount = count($actives);
1407 $tpl =
new ilTemplate(
'tpl.il_as_aggregated_answers_header.html',
true,
true,
"Modules/TestQuestionPool");
1408 $tpl->setVariable(
'HEADERTEXT', $this->lng->txt(
'overview'));
1409 $tpl->setVariable(
'NUMBER_OF_USERS_INFO', $this->lng->txt(
'number_of_users'));
1410 $tpl->setVariable(
'NUMBER_OF_USERS', $usercount);
1411 $tpl->setVariable(
'NUMBER_OF_PASSES_INFO', $this->lng->txt(
'number_of_passes'));
1412 $tpl->setVariable(
'NUMBER_OF_PASSES', $passcount);
1414 $header =
$tpl->get();
1420 return $header . $variants ;
1425 $variants = array();
1426 $passdata = array();
1427 foreach ($relevant_answers_chosen as $relevant_answer)
1429 $pass_ident = $relevant_answer[
'active_fi'].$relevant_answer[
'pass'];
1430 $answer = $passdata[$pass_ident];
1431 if (strlen($answer))
1433 $answer_elements = explode(
',', $answer);
1435 $answer_elements = array();
1437 $answer_elements[] = $relevant_answer[
'value1'].
'.'.$relevant_answer[
'value2'];
1438 $passdata[$pass_ident] = implode(
',',$answer_elements);
1440 foreach($passdata as $passident => $behaviour)
1442 $variants[$behaviour]++;
1450 $tpl =
new ilTemplate(
'tpl.il_as_aggregated_answers_table.html',
true,
true,
"Modules/TestQuestionPool" );
1451 $tpl->setVariable(
'OPTION_HEADER', $this->lng->txt(
'answer_variant' ) );
1452 $tpl->setVariable(
'COUNT_HEADER', $this->lng->txt(
'count' ) );
1453 $tpl->setVariable(
'AGGREGATION_HEADER', $this->lng->txt(
'aggregated_answers_variants' ) );
1454 foreach ($aggregate as
$options => $count)
1456 $tpl->setCurrentBlock(
'aggregaterow' );
1457 $optionstext = array();
1458 foreach (explode(
',',
$options ) as $option)
1460 $pair = explode(
'.',$option);
1461 if($pair[0] == -1 || $pair[1] == -1)
1466 $term = $this->
object->getTermWithIdentifier($pair[0]);
1467 $term_rep = $term->text;
1470 $term_rep .=
' <img src="'
1471 . $this->
object->getImagePathWeb()
1472 . $this->
object->getThumbPrefix()
1477 $definition = $this->
object->getDefinitionWithIdentifier($pair[1]);
1478 $definition_rep = $definition->text;
1479 if($definition->picture)
1481 $definition_rep .=
' <img src="'
1482 . $this->
object->getImagePathWeb()
1483 . $this->
object->getThumbPrefix()
1484 . $definition->picture
1488 $optionstext[] = $definition_rep.
' -> '. $term_rep;
1490 $tpl->setVariable(
'OPTION', implode(
'<br />', $optionstext ) );
1491 $tpl->setVariable(
'COUNT', $count );
1492 $tpl->parseCurrentBlock();
1500 if( !($pair->points > 0) )
1505 if( !is_object($term) )
1510 if( $pair->definition->identifier != $definition->identifier )
1515 if( $pair->term->identifier != $term->identifier )