24 include_once 
"./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
 
   25 include_once 
"./Modules/Test/classes/inc.AssessmentConstants.php";
 
   50                 include_once 
"./Modules/TestQuestionPool/classes/class.assMatchingQuestion.php";
 
   55                         $this->
object->loadFromDb($id);
 
   72                 $hasErrors = (!$always) ? $this->
editQuestion(
true) : 
false;
 
   75                         $this->
object->setTitle(
$_POST[
"title"]);
 
   76                         $this->
object->setAuthor(
$_POST[
"author"]);
 
   77                         $this->
object->setComment(
$_POST[
"comment"]);
 
   78                         include_once 
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
 
   79                         $questiontext = 
$_POST[
"question"];
 
   80                         $this->
object->setQuestion($questiontext);
 
   83                                 $this->
object->setShuffle(
$_POST[
"shuffle"]);
 
   87                                 $this->
object->setShuffle(1);
 
   89                         $this->
object->setThumbGeometry(
$_POST[
"thumb_geometry"]);
 
   90                         $this->
object->setElementHeight(
$_POST[
"element_height"]);
 
   93                                 $this->
object->setNrOfTries(
$_POST[
'nr_of_tries']);
 
   96                         $this->
object->setEstimatedWorkingTime(
 
  103                         $this->
object->flushMatchingPairs();
 
  104                         $this->
object->flushTerms();
 
  105                         $this->
object->flushDefinitions();
 
  109                         include_once 
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php";
 
  110                         foreach (
$_POST[
'terms'][
'answer'] as $index => $answer)
 
  113                                 if (strlen($_FILES[
'terms'][
'name'][
'image'][$index]))
 
  116                                         $name = $_FILES[
'terms'][
'name'][
'image'][$index];
 
  117                                         if ($this->object->setImageFile($_FILES[
'terms'][
'tmp_name'][
'image'][$index], $this->object->getEncryptedFilename($name)))
 
  119                                                 $filename = $this->
object->getEncryptedFilename($name);
 
  129                         include_once 
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingDefinition.php";
 
  130                         foreach (
$_POST[
'definitions'][
'answer'] as $index => $answer)
 
  133                                 if (strlen($_FILES[
'definitions'][
'name'][
'image'][$index]))
 
  136                                         $name = $_FILES[
'definitions'][
'name'][
'image'][$index];
 
  137                                         if ($this->object->setImageFile($_FILES[
'definitions'][
'tmp_name'][
'image'][$index], $this->object->getEncryptedFilename($name)))
 
  139                                                 $filename = $this->
object->getEncryptedFilename($name);
 
  150                         if (is_array(
$_POST[
'pairs'][
'points']))
 
  152                                 include_once 
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingPair.php";
 
  153                                 foreach (
$_POST[
'pairs'][
'points'] as $index => $points)
 
  155                                         $term_id = 
$_POST[
'pairs'][
'term'][$index];
 
  156                                         $definition_id = 
$_POST[
'pairs'][
'definition'][$index];
 
  157                                         $this->
object->addMatchingPair($this->object->getTermWithIdentifier($term_id), $this->
object->getDefinitionWithIdentifier($definition_id), $points);
 
  174                 $position = key(
$_POST[
'cmd'][
'uploadterms']);
 
  184                 $position = key(
$_POST[
'cmd'][
'removeimageterms']);
 
  186                 $this->
object->removeTermImage($position);
 
  196                 $position = key(
$_POST[
'cmd'][
'uploaddefinitions']);
 
  206                 $position = key(
$_POST[
'cmd'][
'removeimagedefinitions']);
 
  208                 $this->
object->removeDefinitionImage($position);
 
  215                 $position = key(
$_POST[
"cmd"][
"addterms"]);
 
  216                 $this->
object->insertTerm($position+1);
 
  223                 $position = key(
$_POST[
"cmd"][
"removeterms"]);
 
  224                 $this->
object->deleteTerm($position);
 
  231                 $position = key(
$_POST[
"cmd"][
"adddefinitions"]);
 
  232                 $this->
object->insertDefinition($position+1);
 
  239                 $position = key(
$_POST[
"cmd"][
"removedefinitions"]);
 
  240                 $this->
object->deleteDefinition($position);
 
  247                 $position = key(
$_POST[
"cmd"][
"addpairs"]);
 
  248                 $this->
object->insertMatchingPair($position+1);
 
  255                 $position = key(
$_POST[
"cmd"][
"removepairs"]);
 
  256                 $this->
object->deleteMatchingPair($position);
 
  267                 $save = ((strcmp($this->ctrl->getCmd(), 
"save") == 0) || (strcmp($this->ctrl->getCmd(), 
"saveEdit") == 0)) ? TRUE : FALSE;
 
  270                 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
 
  272                 $form->setFormAction($this->ctrl->getFormAction($this));
 
  274                 $form->setMultipart(
true);
 
  275                 $form->setTableWidth(
"100%");
 
  276                 $form->setId(
"matching");
 
  280                 $hidden->setValue($matchingtype);
 
  281                 $form->addItem($hidden);
 
  289                         $shuffle = 
new ilSelectInputGUI($this->lng->txt(
"shuffle_answers"), 
"shuffle");
 
  290                         $shuffle_options = array(
 
  291                                 0 => $this->lng->txt(
"no"),
 
  292                                 1 => $this->lng->txt(
"matching_shuffle_terms_definitions"),
 
  293                                 2 => $this->lng->txt(
"matching_shuffle_terms"),
 
  294                                 3 => $this->lng->txt(
"matching_shuffle_definitions")
 
  297                         $shuffle->setValue($this->object->getShuffle());
 
  298                         $shuffle->setRequired(FALSE);
 
  299                         $form->addItem($shuffle);
 
  301                         $element_height = 
new ilNumberInputGUI($this->lng->txt(
"element_height"), 
"element_height");
 
  302                         $element_height->
setValue($this->object->getElementHeight());
 
  303                         $element_height->setRequired(
false);
 
  304                         $element_height->setMaxLength(6);
 
  305                         $element_height->setMinValue(20);
 
  306                         $element_height->setSize(6);
 
  307                         $element_height->setInfo($this->lng->txt(
"element_height_info"));
 
  308                         $form->addItem($element_height);
 
  310                         $geometry = 
new ilNumberInputGUI($this->lng->txt(
"thumb_geometry"), 
"thumb_geometry");
 
  311                         $geometry->
setValue($this->object->getThumbGeometry());
 
  312                         $geometry->setRequired(
true);
 
  313                         $geometry->setMaxLength(6);
 
  314                         $geometry->setMinValue(20);
 
  315                         $geometry->setSize(6);
 
  316                         $geometry->setInfo($this->lng->txt(
"thumb_geometry_info"));
 
  317                         $form->addItem($geometry);
 
  321                 include_once 
"./Modules/TestQuestionPool/classes/class.ilMatchingWizardInputGUI.php";
 
  324                 $definitions->setRequired(
true);
 
  325                 $definitions->setQuestionObject($this->
object);
 
  326                 $definitions->setTextName($this->lng->txt(
'definition_text'));
 
  327                 $definitions->setImageName($this->lng->txt(
'definition_image'));
 
  328                 include_once 
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingDefinition.php";
 
  330                 $definitionvalues = $this->
object->getDefinitions();
 
  331                 $definitions->setValues($definitionvalues);
 
  332                 $form->addItem($definitions);
 
  335                 include_once 
"./Modules/TestQuestionPool/classes/class.ilMatchingWizardInputGUI.php";
 
  338                 $terms->setRequired(
true);
 
  339                 $terms->setQuestionObject($this->
object);
 
  340                 $terms->setTextName($this->lng->txt(
'term_text'));
 
  341                 $terms->setImageName($this->lng->txt(
'term_image'));
 
  342                 include_once 
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php";
 
  344                 $termvalues = $this->
object->getTerms();
 
  345                 $terms->setValues($termvalues);
 
  346                 $form->addItem($terms);
 
  349                 include_once 
"./Modules/TestQuestionPool/classes/class.ilMatchingPairWizardInputGUI.php";
 
  352                 $pairs->setTerms($this->object->getTerms());
 
  353                 $pairs->setDefinitions($this->object->getDefinitions());
 
  354                 include_once 
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingPair.php";
 
  355                 if (count($this->object->getMatchingPairs()) == 0)
 
  359                 $pairs->setPairs($this->object->getMatchingPairs());
 
  360                 $form->addItem($pairs);
 
  368                         $form->setValuesByPost();
 
  369                         $errors = !$form->checkInput();
 
  370                         $form->setValuesByPost(); 
 
  371                         if ((!
$errors) && (count($terms->getValues()) < (count($definitions->getValues()))))
 
  374                                 $terms->setAlert($this->lng->txt(
"msg_number_of_terms_too_low"));
 
  377                         if (
$errors) $checkonly = 
false;
 
  380                 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
 
  386                 $test_output = $this->
getTestOutput($active_id, 
$pass, $is_postponed, $user_post_solution); 
 
  387                 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
 
  388                 $this->tpl->setVariable(
"FORMACTION", $formaction);
 
  407                 $graphicalOutput = FALSE,
 
  408                 $result_output = FALSE,
 
  409                 $show_question_only = TRUE,
 
  410                 $show_feedback = FALSE,
 
  411                 $show_correct_solution = FALSE,
 
  412                 $show_manual_scoring = FALSE
 
  416                 include_once 
"./classes/class.ilTemplate.php";
 
  417                 $template = 
new ilTemplate(
"tpl.il_as_qpl_matching_output_solution.html", TRUE, TRUE, 
"Modules/TestQuestionPool");
 
  418                 $solutiontemplate = 
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE, 
"Modules/TestQuestionPool");
 
  420                 $solutions = array();
 
  421                 if (($active_id > 0) && (!$show_correct_solution))
 
  423                         include_once 
"./Modules/Test/classes/class.ilObjTest.php";
 
  424                         $solutions =& $this->
object->getSolutionValues($active_id, 
$pass);
 
  425                         $solution_script .= 
"";
 
  429                         foreach ($this->object->getMatchingPairs() as $pair)
 
  431                                 array_push($solutions, array(
"value1" => $pair->term->identifier, 
"value2" => $pair->definition->identifier));
 
  436                 foreach ($solutions as $solution)
 
  438                         $definition = $this->
object->getDefinitionWithIdentifier($solution[
'value2']);
 
  439                         $term = $this->
object->getTermWithIdentifier($solution[
'value1']);
 
  441                         if (is_object($definition))
 
  443                                 if (strlen($definition->picture))
 
  445                                         $template->setCurrentBlock(
'definition_image');
 
  446                                         $template->setVariable(
'ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->picture);
 
  449                                         $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $definition->picture);
 
  450                                         $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
 
  452                                         $template->setVariable(
"TEXT_DEFINITION", (strlen($definition->text)) ? $this->lng->txt(
'definition') . 
' ' . ($i+1) . 
': ' . 
ilUtil::prepareFormOutput($definition->text) : $this->lng->txt(
'definition') . 
' ' . ($i+1));
 
  453                                         $template->parseCurrentBlock();
 
  457                                         $template->setCurrentBlock(
'definition_text');
 
  458                                         $template->setVariable(
"DEFINITION", $this->object->prepareTextareaOutput($definition->text, TRUE));
 
  459                                         $template->parseCurrentBlock();
 
  462                         if (is_object($term))
 
  464                                 if (strlen($term->picture))
 
  466                                         $template->setCurrentBlock(
'term_image');
 
  467                                         $template->setVariable(
'ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->picture);
 
  470                                         $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $term->picture);
 
  471                                         $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
 
  472                                         $template->setVariable(
"TEXT_TERM", (strlen($term->text)) ? $this->lng->txt(
'term') . 
' ' . ($i+1) . 
': ' . 
ilUtil::prepareFormOutput($term->text) : $this->lng->txt(
'term') . 
' ' . ($i+1));
 
  474                                         $template->parseCurrentBlock();
 
  478                                         $template->setCurrentBlock(
'term_text');
 
  479                                         $template->setVariable(
"TERM", $this->object->prepareTextareaOutput($term->text, TRUE));
 
  480                                         $template->parseCurrentBlock();
 
  484                         if (($active_id > 0) && (!$show_correct_solution))
 
  486                                 if ($graphicalOutput)
 
  490                                         foreach ($this->object->getMatchingPairs() as $pair)
 
  492                                                 if (is_object($term)) 
if (($pair->definition->identifier == $definition->identifier) && ($pair->term->identifier == $term->identifier)) 
$ok = 
true;
 
  496                                                 $template->setCurrentBlock(
"icon_ok");
 
  498                                                 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
 
  499                                                 $template->parseCurrentBlock();
 
  503                                                 $template->setCurrentBlock(
"icon_ok");
 
  505                                                 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
 
  506                                                 $template->parseCurrentBlock();
 
  514                                 foreach ($this->object->getMatchingPairs() as $pair)
 
  516                                         foreach ($solutions as $solution)
 
  518                                                 if (($solution[
'value2'] == $pair->definition->identifier) && ($solution[
'value1'] == $pair->term->identifier))
 
  520                                                         $points = $pair->points;
 
  524                                 $resulttext = ($points == 1) ? 
"(%s " . $this->lng->txt(
"point") . 
")" : 
"(%s " . $this->lng->txt(
"points") . 
")"; 
 
  525                                 $template->setCurrentBlock(
"result_output");
 
  526                                 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $points));
 
  527                                 $template->parseCurrentBlock();
 
  530                         $template->setCurrentBlock(
"row");
 
  531                         if ($this->object->getEstimatedElementHeight() > 0)
 
  533                                 $template->setVariable(
"ELEMENT_HEIGHT", 
" style=\"height: " . $this->object->getEstimatedElementHeight() . 
"px;\"");
 
  535                         $template->setVariable(
"TEXT_MATCHES", $this->lng->txt(
"matches"));
 
  536                         $template->parseCurrentBlock();
 
  539                 $questiontext = $this->
object->getQuestion();
 
  540                 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
 
  541                 $questionoutput = $template->get();
 
  543                 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $feedback);
 
  544                 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
 
  546                 $solutionoutput = $solutiontemplate->get(); 
 
  547                 if (!$show_question_only)
 
  552                 return $solutionoutput;
 
  560                 include_once 
"./classes/class.ilTemplate.php";
 
  561                 $template = 
new ilTemplate(
"tpl.il_as_qpl_matching_output_js.html", TRUE, TRUE, 
"Modules/TestQuestionPool");
 
  564                 if (strcmp($this->ctrl->getCmd(), 
'preview') == 0)
 
  566                         if (array_key_exists(
'js', 
$_GET))
 
  568                                 $ilUser->writePref(
'tst_javascript', 
$_GET[
'js']);
 
  570                         $jstemplate = 
new ilTemplate(
"tpl.il_as_qpl_javascript_switch.html", TRUE, TRUE, 
"Modules/TestQuestionPool");
 
  571                         if ($ilUser->getPref(
"tst_javascript") == 1)
 
  574                                 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_ALT", $this->lng->txt(
"disable_javascript"));
 
  575                                 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_TITLE", $this->lng->txt(
"disable_javascript"));
 
  576                                 $this->ctrl->setParameterByClass($this->ctrl->getCmdClass(), 
"js", 
"0");
 
  577                                 $jstemplate->setVariable(
"JAVASCRIPT_URL", $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), $this->ctrl->getCmd()));
 
  582                                 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_ALT", $this->lng->txt(
"enable_javascript"));
 
  583                                 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_TITLE", $this->lng->txt(
"enable_javascript"));
 
  584                                 $this->ctrl->setParameterByClass($this->ctrl->getCmdClass(), 
"js", 
"1");
 
  585                                 $jstemplate->setVariable(
"JAVASCRIPT_URL", $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), $this->ctrl->getCmd()));
 
  587                         $jsswitch = $jstemplate->get();
 
  588                         if ($ilUser->getPref(
'tst_javascript')) $this->object->setOutputType(
OUTPUT_JAVASCRIPT);
 
  592                 $terms = $this->
object->getTerms();
 
  593                 $definitions = $this->
object->getDefinitions();
 
  594                 switch ($this->object->getShuffle())
 
  597                                 $terms = $this->
object->pcArrayShuffle($terms);
 
  598                                 $definitions = $this->
object->pcArrayShuffle($definitions);
 
  601                                 $terms = $this->
object->pcArrayShuffle($terms);
 
  604                                 $definitions = $this->
object->pcArrayShuffle($definitions);
 
  608                 include_once 
"./Services/YUI/classes/class.ilYuiUtil.php";
 
  613                 foreach ($definitions as $definition)
 
  615                         if (strlen($definition->picture))
 
  617                                 $template->setCurrentBlock(
"definition_picture");
 
  618                                 $template->setVariable(
"DEFINITION_ID", $definition->identifier);
 
  619                                 $template->setVariable(
"IMAGE_HREF", $this->object->getImagePathWeb() . $definition->picture);
 
  620                                 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->picture;
 
  621                                 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $definition->picture;
 
  622                                 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
 
  623                                 $template->setVariable(
"THUMBNAIL_HREF", $thumbweb);
 
  624                                 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"image"));
 
  625                                 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"image"));
 
  626                                 $template->setVariable(
"TEXT_DEFINITION", (strlen($definition->text)) ? $this->object->prepareTextareaOutput($definition->text, TRUE) : 
'');
 
  627                                 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
 
  629                                 $template->parseCurrentBlock();
 
  633                                 $template->setCurrentBlock(
"definition_text");
 
  634                                 $template->setVariable(
"DEFINITION", $this->object->prepareTextareaOutput($definition->text, TRUE));
 
  635                                 $template->parseCurrentBlock();
 
  638                         $template->setCurrentBlock(
"droparea");
 
  639                         $template->setVariable(
"ID_DROPAREA", $definition->identifier);
 
  640                         $template->setVariable(
"QUESTION_ID", $this->object->getId());
 
  641                         if ($this->object->getEstimatedElementHeight() > 0)
 
  643                                 $template->setVariable(
"ELEMENT_HEIGHT", 
" style=\"height: " . $this->object->getEstimatedElementHeight() . 
"px;\"");
 
  645                         $template->parseCurrentBlock();
 
  647                         $template->setCurrentBlock(
"init_dropareas");
 
  648                         $template->setVariable(
"COUNTER", $counter++);
 
  649                         $template->setVariable(
"ID_DROPAREA", $definition->identifier);
 
  650                         $template->parseCurrentBlock();
 
  656                 foreach ($terms as $term)
 
  658                         if (strlen($term->picture))
 
  660                                 $template->setCurrentBlock(
"term_picture");
 
  661                                 $template->setVariable(
"TERM_ID", $term->identifier);
 
  662                                 $template->setVariable(
"IMAGE_HREF", $this->object->getImagePathWeb() . $term->picture);
 
  663                                 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->picture;
 
  664                                 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $term->picture;
 
  665                                 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
 
  666                                 $template->setVariable(
"THUMBNAIL_HREF", $thumbweb);
 
  667                                 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"image"));
 
  668                                 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"image"));
 
  669                                 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
 
  670                                 $template->setVariable(
"TEXT_TERM", (strlen($term->text)) ? $this->object->prepareTextareaOutput($term->text, TRUE) : 
'');
 
  672                                 $template->parseCurrentBlock();
 
  676                                 $template->setCurrentBlock(
"term_text");
 
  677                                 $template->setVariable(
"TERM_TEXT", $this->object->prepareTextareaOutput($term->text, TRUE));
 
  678                                 $template->parseCurrentBlock();
 
  680                         $template->setCurrentBlock(
"draggable");
 
  681                         $template->setVariable(
"ID_DRAGGABLE", $term->identifier);
 
  682                         if ($this->object->getEstimatedElementHeight() > 0)
 
  684                                 $template->setVariable(
"ELEMENT_HEIGHT", 
" style=\"height: " . $this->object->getEstimatedElementHeight() . 
"px;\"");
 
  686                         $template->parseCurrentBlock();
 
  688                         $template->setCurrentBlock(
"init_draggables");
 
  689                         $template->setVariable(
"COUNTER", $counter++);
 
  690                         $template->setVariable(
"ID_DRAGGABLE", $term->identifier);
 
  691                         $template->parseCurrentBlock();
 
  694                 $template->setVariable(
"RESET_BUTTON", $this->lng->txt(
"reset_terms"));
 
  696                 $this->tpl->setVariable(
"LOCATION_ADDITIONAL_STYLESHEET", 
ilUtil::getStyleSheetLocation(
"output", 
"test_javascript.css", 
"Modules/TestQuestionPool"));
 
  698                 $questiontext = $this->
object->getQuestion();
 
  699                 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
 
  700                 $questionoutput = $jsswitch . $template->get();
 
  701                 if (!$show_question_only)
 
  706                 return $questionoutput;
 
  714                 include_once 
"./classes/class.ilTemplate.php";
 
  715                 $template = 
new ilTemplate(
"tpl.il_as_qpl_matching_output.html", TRUE, TRUE, 
"Modules/TestQuestionPool");
 
  718                 if (strcmp($this->ctrl->getCmd(), 
'preview') == 0)
 
  720                         if (array_key_exists(
'js', 
$_GET))
 
  722                                 $ilUser->writePref(
'tst_javascript', 
$_GET[
'js']);
 
  724                         $jstemplate = 
new ilTemplate(
"tpl.il_as_qpl_javascript_switch.html", TRUE, TRUE, 
"Modules/TestQuestionPool");
 
  725                         if ($ilUser->getPref(
"tst_javascript") == 1)
 
  728                                 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_ALT", $this->lng->txt(
"disable_javascript"));
 
  729                                 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_TITLE", $this->lng->txt(
"disable_javascript"));
 
  730                                 $this->ctrl->setParameterByClass($this->ctrl->getCmdClass(), 
"js", 
"0");
 
  731                                 $jstemplate->setVariable(
"JAVASCRIPT_URL", $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), $this->ctrl->getCmd()));
 
  736                                 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_ALT", $this->lng->txt(
"enable_javascript"));
 
  737                                 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_TITLE", $this->lng->txt(
"enable_javascript"));
 
  738                                 $this->ctrl->setParameterByClass($this->ctrl->getCmdClass(), 
"js", 
"1");
 
  739                                 $jstemplate->setVariable(
"JAVASCRIPT_URL", $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), $this->ctrl->getCmd()));
 
  741                         $jsswitch = $jstemplate->get();
 
  742                         if ($ilUser->getPref(
'tst_javascript')) $this->object->setOutputType(
OUTPUT_JAVASCRIPT);
 
  751                 $terms = $this->
object->getTerms();
 
  752                 $definitions = $this->
object->getDefinitions();
 
  753                 switch ($this->object->getShuffle())
 
  756                                 $terms = $this->
object->pcArrayShuffle($terms);
 
  757                                 $definitions = $this->
object->pcArrayShuffle($definitions);
 
  760                                 $terms = $this->
object->pcArrayShuffle($terms);
 
  763                                 $definitions = $this->
object->pcArrayShuffle($definitions);
 
  767                 for ($i = 0; $i < count($definitions); $i++)
 
  769                         $definition = $definitions[$i];
 
  770                         if (is_object($definition))
 
  772                                 if (strlen($definition->picture))
 
  774                                         $template->setCurrentBlock(
'definition_image');
 
  775                                         $template->setVariable(
'ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->picture);
 
  778                                         $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $definition->picture);
 
  779                                         $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
 
  781                                         $template->setVariable(
"TEXT_DEFINITION", (strlen($definition->text)) ? $this->lng->txt(
'definition') . 
' ' . ($i+1) . 
': ' . $this->object->prepareTextareaOutput($definition->text, TRUE) : $this->lng->txt(
'definition') . 
' ' . ($i+1));
 
  782                                         $template->parseCurrentBlock();
 
  786                                         $template->setCurrentBlock(
'definition_text');
 
  787                                         $template->setVariable(
"DEFINITION", $this->object->prepareTextareaOutput($definition->text, TRUE));
 
  788                                         $template->parseCurrentBlock();
 
  792                         $template->setCurrentBlock(
'option');
 
  793                         $template->setVariable(
"VALUE_OPTION", 0);
 
  795                         $template->parseCurrentBlock();
 
  797                         foreach ($terms as $term)
 
  799                                 $template->setCurrentBlock(
'option');
 
  800                                 $template->setVariable(
"VALUE_OPTION", $term->identifier);
 
  801                                 $template->setVariable(
"TEXT_OPTION", (strlen($term->text)) ? $this->lng->txt(
'term') . 
' ' . ($j) . 
': ' . 
ilUtil::prepareFormOutput($term->text) : $this->lng->txt(
'term') . 
' ' . ($j));
 
  802                                 $template->parseCurrentBlock();
 
  806                         $template->setCurrentBlock(
'row');
 
  807                         $template->setVariable(
"TEXT_MATCHES", $this->lng->txt(
"matches"));
 
  808                         if ($this->object->getEstimatedElementHeight() > 0)
 
  810                                 $template->setVariable(
"ELEMENT_HEIGHT", 
" style=\"height: " . $this->object->getEstimatedElementHeight() . 
"px;\"");
 
  812                         $template->setVariable(
"QUESTION_ID", $this->object->getId());
 
  813                         $template->setVariable(
"DEFINITION_ID", $definition->identifier);
 
  814                         $template->parseCurrentBlock();
 
  818                 foreach ($terms as $term)
 
  820                         if (strlen($term->picture))
 
  822                                 $template->setCurrentBlock(
'term_image');
 
  823                                 $template->setVariable(
'ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->picture);
 
  826                                 $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $term->picture);
 
  827                                 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
 
  828                                 $template->setVariable(
"TEXT_TERM", (strlen($term->text)) ? $this->lng->txt(
'term') . 
' ' . ($i+1) . 
': ' . $this->object->prepareTextareaOutput($term->text, TRUE) : $this->lng->txt(
'term') . 
' ' . ($i+1));
 
  830                                 $template->parseCurrentBlock();
 
  834                                 $template->setCurrentBlock(
'term_text');
 
  835                                 $template->setVariable(
"TERM", $this->object->prepareTextareaOutput($term->text, TRUE));
 
  836                                 $template->parseCurrentBlock();
 
  838                         $template->touchBlock(
'terms');
 
  842                 $questiontext = $this->
object->getQuestion();
 
  843                 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
 
  846                 $questionoutput = $jsswitch . $template->get();
 
  847                 if (!$show_question_only)
 
  852                 return $questionoutput;
 
  858                 foreach ($solution as $solution_values)
 
  860                         $id = $solution_values[
'value2'];
 
  861                         array_push($neworder, $this->object->getDefinitionWithIdentifier($id));
 
  869                 include_once 
"./classes/class.ilTemplate.php";
 
  870                 $template = 
new ilTemplate(
"tpl.il_as_qpl_matching_output_js.html", TRUE, TRUE, 
"Modules/TestQuestionPool");
 
  875                         include_once 
"./Modules/Test/classes/class.ilObjTest.php";
 
  880                         if (is_array($user_post_solution)) 
 
  882                                 $solutions = array();
 
  883                                 foreach ($user_post_solution[
'matching'][$this->object->getId()] as $definition => $term)
 
  885                                         array_push($solutions, array(
"value1" => $term, 
"value2" => $definition));
 
  890                                 $solutions =& $this->
object->getSolutionValues($active_id, 
$pass);
 
  893                         foreach ($solutions as $idx => $solution_value)
 
  897                                         if (($solution_value[
"value2"] > -1) && ($solution_value[
"value1"] > -1))
 
  899                                                 $template->setCurrentBlock(
"restoreposition");
 
  900                                                 $template->setVariable(
"TERM_ID", $solution_value[
"value1"]);
 
  901                                                 $template->setVariable(
"PICTURE_DEFINITION_ID", $solution_value[
"value2"]);
 
  902                                                 $template->parseCurrentBlock();
 
  909                 $terms = $this->
object->getTerms();
 
  910                 $definitions = $this->
object->getDefinitions();
 
  911                 switch ($this->object->getShuffle())
 
  914                                 $terms = $this->
object->pcArrayShuffle($terms);
 
  915                                 if (count($solutions))
 
  921                                         $definitions = $this->
object->pcArrayShuffle($definitions);
 
  925                                 $terms = $this->
object->pcArrayShuffle($terms);
 
  928                                 if (count($solutions))
 
  934                                         $definitions = $this->
object->pcArrayShuffle($definitions);
 
  939                 include_once 
"./Services/YUI/classes/class.ilYuiUtil.php";
 
  944                 foreach ($definitions as $definition)
 
  946                         if (strlen($definition->picture))
 
  948                                 $template->setCurrentBlock(
"definition_picture");
 
  949                                 $template->setVariable(
"DEFINITION_ID", $definition->identifier);
 
  950                                 $template->setVariable(
"IMAGE_HREF", $this->object->getImagePathWeb() . $definition->picture);
 
  951                                 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->picture;
 
  952                                 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $definition->picture;
 
  953                                 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
 
  954                                 $template->setVariable(
"THUMBNAIL_HREF", $thumbweb);
 
  955                                 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"image"));
 
  956                                 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"image"));
 
  957                                 $template->setVariable(
"TEXT_DEFINITION", (strlen($definition->text)) ? 
ilUtil::prepareFormOutput($definition->text) : 
'');
 
  958                                 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
 
  960                                 $template->parseCurrentBlock();
 
  964                                 $template->setCurrentBlock(
"definition_text");
 
  965                                 $template->setVariable(
"DEFINITION", $this->object->prepareTextareaOutput($definition->text, 
true));
 
  966                                 $template->parseCurrentBlock();
 
  969                         $template->setCurrentBlock(
"droparea");
 
  970                         $template->setVariable(
"ID_DROPAREA", $definition->identifier);
 
  971                         $template->setVariable(
"QUESTION_ID", $this->object->getId());
 
  972                         if ($this->object->getEstimatedElementHeight() > 0)
 
  974                                 $template->setVariable(
"ELEMENT_HEIGHT", 
" style=\"height: " . $this->object->getEstimatedElementHeight() . 
"px;\"");
 
  976                         $template->parseCurrentBlock();
 
  978                         $template->setCurrentBlock(
"init_dropareas");
 
  979                         $template->setVariable(
"COUNTER", $counter++);
 
  980                         $template->setVariable(
"ID_DROPAREA", $definition->identifier);
 
  981                         $template->parseCurrentBlock();
 
  987                 foreach ($terms as $term)
 
  989                         if (strlen($term->picture))
 
  991                                 $template->setCurrentBlock(
"term_picture");
 
  992                                 $template->setVariable(
"TERM_ID", $term->identifier);
 
  993                                 $template->setVariable(
"IMAGE_HREF", $this->object->getImagePathWeb() . $term->picture);
 
  994                                 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->picture;
 
  995                                 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $term->picture;
 
  996                                 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
 
  997                                 $template->setVariable(
"THUMBNAIL_HREF", $thumbweb);
 
  998                                 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"image"));
 
  999                                 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"image"));
 
 1000                                 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
 
 1003                                 $template->parseCurrentBlock();
 
 1007                                 $template->setCurrentBlock(
"term_text");
 
 1008                                 $template->setVariable(
"TERM_TEXT", $this->object->prepareTextareaOutput($term->text, 
true));
 
 1009                                 $template->parseCurrentBlock();
 
 1011                         $template->setCurrentBlock(
"draggable");
 
 1012                         $template->setVariable(
"ID_DRAGGABLE", $term->identifier);
 
 1013                         if ($this->object->getEstimatedElementHeight() > 0)
 
 1015                                 $template->setVariable(
"ELEMENT_HEIGHT", 
" style=\"height: " . $this->object->getEstimatedElementHeight() . 
"px;\"");
 
 1017                         $template->parseCurrentBlock();
 
 1019                         $template->setCurrentBlock(
"init_draggables");
 
 1020                         $template->setVariable(
"COUNTER", $counter++);
 
 1021                         $template->setVariable(
"ID_DRAGGABLE", $term->identifier);
 
 1022                         $template->parseCurrentBlock();
 
 1025                 $template->setVariable(
"RESET_BUTTON", $this->lng->txt(
"reset_terms"));
 
 1027                 $this->tpl->setVariable(
"LOCATION_ADDITIONAL_STYLESHEET", 
ilUtil::getStyleSheetLocation(
"output", 
"test_javascript.css", 
"Modules/TestQuestionPool"));
 
 1029                 $questiontext = $this->
object->getQuestion();
 
 1030                 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
 
 1031                 $questionoutput = $template->get();
 
 1032                 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
 
 1043                 include_once 
"./classes/class.ilTemplate.php";
 
 1044                 $template = 
new ilTemplate(
"tpl.il_as_qpl_matching_output.html", TRUE, TRUE, 
"Modules/TestQuestionPool");
 
 1049                         include_once 
"./Modules/Test/classes/class.ilObjTest.php";
 
 1054                         if (is_array($user_post_solution)) 
 
 1056                                 $solutions = array();
 
 1057                                 foreach ($user_post_solution[
'matching'][$this->object->getId()] as $definition => $term)
 
 1059                                         array_push($solutions, array(
"value1" => $term, 
"value2" => $definition));
 
 1064                                 $solutions =& $this->
object->getSolutionValues($active_id, 
$pass);
 
 1070                 $terms = $this->
object->getTerms();
 
 1071                 $definitions = $this->
object->getDefinitions();
 
 1072                 switch ($this->object->getShuffle())
 
 1075                                 $terms = $this->
object->pcArrayShuffle($terms);
 
 1076                                 if (count($solutions))
 
 1082                                         $definitions = $this->
object->pcArrayShuffle($definitions);
 
 1086                                 $terms = $this->
object->pcArrayShuffle($terms);
 
 1089                                 if (count($solutions))
 
 1095                                         $definitions = $this->
object->pcArrayShuffle($definitions);
 
 1099                 $maxcount = max(count($terms), count($definitions));
 
 1100                 for ($i = 0; $i < count($definitions); $i++)
 
 1102                         $definition = $definitions[$i];
 
 1103                         if (is_object($definition))
 
 1105                                 if (strlen($definition->picture))
 
 1107                                         $template->setCurrentBlock(
'definition_image');
 
 1108                                         $template->setVariable(
'ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->picture);
 
 1111                                         $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $definition->picture);
 
 1112                                         $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
 
 1114                                         $template->setVariable(
"TEXT_DEFINITION", (strlen($definition->text)) ? $this->lng->txt(
'definition') . 
' ' . ($i+1) . 
': ' . 
ilUtil::prepareFormOutput($definition->text) : $this->lng->txt(
'definition') . 
' ' . ($i+1));
 
 1115                                         $template->parseCurrentBlock();
 
 1119                                         $template->setCurrentBlock(
'definition_text');
 
 1120                                         $template->setVariable(
"DEFINITION", $this->object->prepareTextareaOutput($definition->text, 
true));
 
 1121                                         $template->parseCurrentBlock();
 
 1125                         $template->setCurrentBlock(
'option');
 
 1126                         $template->setVariable(
"VALUE_OPTION", 0);
 
 1128                         $template->parseCurrentBlock();
 
 1130                         foreach ($terms as $term)
 
 1132                                 $template->setCurrentBlock(
'option');
 
 1133                                 $template->setVariable(
"VALUE_OPTION", $term->identifier);
 
 1134                                 $template->setVariable(
"TEXT_OPTION", (strlen($term->text)) ? $this->lng->txt(
'term') . 
' ' . ($j) . 
': ' . 
ilUtil::prepareFormOutput($term->text) : $this->lng->txt(
'term') . 
' ' . ($j));
 
 1135                                 foreach ($solutions as $solution)
 
 1137                                         if ($solution[
"value1"] == $term->identifier && $solution[
"value2"] == $definition->identifier)
 
 1139                                                 $template->setVariable(
"SELECTED_OPTION", 
" selected=\"selected\"");
 
 1142                                 $template->parseCurrentBlock();
 
 1146                         $template->setCurrentBlock(
'row');
 
 1147                         $template->setVariable(
"TEXT_MATCHES", $this->lng->txt(
"matches"));
 
 1148                         if ($this->object->getEstimatedElementHeight() > 0)
 
 1150                                 $template->setVariable(
"ELEMENT_HEIGHT", 
" style=\"height: " . $this->object->getEstimatedElementHeight() . 
"px;\"");
 
 1152                         $template->setVariable(
"QUESTION_ID", $this->object->getId());
 
 1153                         $template->setVariable(
"DEFINITION_ID", $definition->identifier);
 
 1154                         $template->parseCurrentBlock();
 
 1158                 foreach ($terms as $term)
 
 1160                         if (strlen($term->picture))
 
 1162                                 $template->setCurrentBlock(
'term_image');
 
 1163                                 $template->setVariable(
'ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->picture);
 
 1166                                 $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $term->picture);
 
 1167                                 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
 
 1168                                 $template->setVariable(
"TEXT_TERM", (strlen($term->text)) ? $this->lng->txt(
'term') . 
' ' . ($i+1) . 
': ' . 
ilUtil::prepareFormOutput($term->text) : $this->lng->txt(
'term') . 
' ' . ($i+1));
 
 1170                                 $template->parseCurrentBlock();
 
 1174                                 $template->setCurrentBlock(
'term_text');
 
 1175                                 $template->setVariable(
"TERM", $this->object->prepareTextareaOutput($term->text, 
true));
 
 1176                                 $template->parseCurrentBlock();
 
 1178                         $template->touchBlock(
'terms');
 
 1182                 $questiontext = $this->
object->getQuestion();
 
 1183                 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
 
 1187                 $questiontext = $this->
object->getQuestion();
 
 1188                 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
 
 1189                 $questionoutput = $template->get();
 
 1190                 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
 
 1213                 include_once 
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
 
 1215                 $this->
object->saveFeedbackGeneric(0, 
$_POST[
"feedback_incomplete"]);
 
 1216                 $this->
object->saveFeedbackGeneric(1, 
$_POST[
"feedback_complete"]);
 
 1217                 $this->
object->cleanupMediaObjectUsage();
 
 1228                 global $rbacsystem, $ilTabs;
 
 1230                 $this->ctrl->setParameterByClass(
"ilpageobjectgui", 
"q_id", 
$_GET[
"q_id"]);
 
 1231                 include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
 1232                 $q_type = $this->
object->getQuestionType();
 
 1234                 if (strlen($q_type))
 
 1236                         $classname = $q_type . 
"GUI";
 
 1237                         $this->ctrl->setParameterByClass(strtolower($classname), 
"sel_question_types", $q_type);
 
 1238                         $this->ctrl->setParameterByClass(strtolower($classname), 
"q_id", 
$_GET[
"q_id"]);
 
 1243                         if ($rbacsystem->checkAccess(
'write', 
$_GET[
"ref_id"]))
 
 1246                                 $ilTabs->addTarget(
"edit_content",
 
 1247                                         $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI", 
"edit"),
 
 1248                                         array(
"edit", 
"insert", 
"exec_pg"),
 
 1249                                         "", 
"", $force_active);
 
 1253                         $ilTabs->addTarget(
"preview",
 
 1254                                 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI", 
"preview"),
 
 1256                                 "ilPageObjectGUI", 
"", $force_active);
 
 1259                 $force_active = 
false;
 
 1260                 if ($rbacsystem->checkAccess(
'write', 
$_GET[
"ref_id"]))
 
 1263                         if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname, 
"editQuestion");
 
 1265                         $ilTabs->addTarget(
"edit_properties",
 
 1267                                 array(
"editQuestion", 
"save", 
"saveEdit", 
"removeimageterms", 
"uploadterms", 
"removeimagedefinitions", 
"uploaddefinitions",
 
 1268                                         "addpairs", 
"removepairs", 
"addterms", 
"removeterms", 
"adddefinitions", 
"removedefinitions", 
"originalSyncForm"),
 
 1269                                 $classname, 
"", $force_active);
 
 1274                         $ilTabs->addTarget(
"feedback",
 
 1275                                 $this->ctrl->getLinkTargetByClass($classname, 
"feedback"),
 
 1276                                 array(
"feedback", 
"saveFeedback"),
 
 1282                         $ilTabs->addTarget(
"solution_hint",
 
 1283                                 $this->ctrl->getLinkTargetByClass($classname, 
"suggestedsolution"),
 
 1284                                 array(
"suggestedsolution", 
"saveSuggestedSolution", 
"outSolutionExplorer", 
"cancel", 
 
 1285                                 "addSuggestedSolution",
"cancelExplorer", 
"linkChilds", 
"removeSuggestedSolution" 
 1295                         $ilTabs->addTarget(
"statistics",
 
 1296                                 $this->ctrl->getLinkTargetByClass($classname, 
"assessment"),
 
 1297                                 array(
"assessment"),
 
 1301                 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
 
 1305                         $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"), 
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
 
 1309                         $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui", 
"questions"));