dokeos-exercise
[ class tree: dokeos-exercise ] [ index: dokeos-exercise ] [ all elements ]

Source for file answer_admin.inc.php

Documentation is available at answer_admin.inc.php

  1. <?php
  2. /*
  3.     DOKEOS - elearning and course management software
  4.  
  5.     For a full list of contributors, see documentation/credits.html
  6.  
  7.     This program is free software; you can redistribute it and/or
  8.     modify it under the terms of the GNU General Public License
  9.     as published by the Free Software Foundation; either version 2
  10.     of the License, or (at your option) any later version.
  11.     See "documentation/licence.html" more details.
  12.  
  13.     Contact:
  14.         Dokeos
  15.         Rue des Palais 44 Paleizenstraat
  16.         B-1030 Brussels - Belgium
  17.         Tel. +32 (2) 211 34 56
  18. */
  19.  
  20.  
  21. /**
  22. *    This script allows to manage answers. It is included from the script admin.php
  23. *    @package dokeos.exercise
  24. *     @author Olivier Brouckaert
  25. *     @version $Id: answer_admin.inc.php 13301 2007-09-27 03:47:39Z yannoo $
  26. */
  27.  
  28.  
  29. // ALLOWED_TO_INCLUDE is defined in admin.php
  30. if(!defined('ALLOWED_TO_INCLUDE'))
  31. {
  32.     exit();
  33. }
  34. if(!is_object($objQuestion))
  35. {
  36.     $objQuestion Question :: read($_GET['modifyAnswers']);
  37. }
  38.  
  39. $questionName=$objQuestion->selectTitle();
  40. $answerType=$objQuestion->selectType();
  41. $pictureName=$objQuestion->selectPicture();
  42.  
  43. $debug 0// debug variable to get where we are
  44.  
  45. $okPicture=empty($pictureName)?false:true;
  46.  
  47. // if we come from the warning box "this question is used in serveral exercises"
  48. if($modifyIn)
  49. {
  50.     if($debug>0){echo '$modifyIn was set'."<br />\n";}
  51.     // if the user has chosed to modify the question only in the current exercise
  52.     if($modifyIn == 'thisExercise')
  53.     {
  54.         // duplicates the question
  55.         $questionId=$objQuestion->duplicate();
  56.  
  57.         // deletes the old question
  58.         $objQuestion->delete($exerciseId);
  59.  
  60.         // removes the old question ID from the question list of the Exercise object
  61.         $objExercise->removeFromList($modifyAnswers);
  62.  
  63.         // adds the new question ID into the question list of the Exercise object
  64.         $objExercise->addToList($questionId);
  65.  
  66.         // construction of the duplicated Question
  67.         $objQuestion Question::read($questionId);
  68.  
  69.         // adds the exercise ID into the exercise list of the Question object
  70.         $objQuestion->addToList($exerciseId);
  71.  
  72.         // copies answers from $modifyAnswers to $questionId
  73.         $objAnswer->duplicate($questionId);
  74.  
  75.         // construction of the duplicated Answers
  76.  
  77.         $objAnswer=new Answer($questionId);
  78.     }
  79.  
  80.     if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER)
  81.     {
  82.         $correct=unserialize($correct);
  83.         $reponse=unserialize($reponse);
  84.         $comment=unserialize($comment);
  85.         $weighting=unserialize($weighting);
  86.     }
  87.     //matching
  88.     elseif($answerType == MATCHING)
  89.     {
  90.         $option=unserialize($option);
  91.         $match=unserialize($match);
  92.         $sel=unserialize($sel);
  93.         $weighting=unserialize($weighting);
  94.     }
  95.     //free answer
  96.     elseif($answerType == FREE_ANSWER )
  97.     {
  98.         $reponse=unserialize($reponse);
  99.         $comment=unserialize($comment);
  100.         $free_comment=$comment;
  101.         $weighting=unserialize($weighting);
  102.  
  103.     }
  104.     elseif ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER)
  105.     {
  106.         $color=unserialize($color);
  107.         $reponse=unserialize($reponse);
  108.         $comment=unserialize($comment);
  109.         $weighting=unserialize($weighting);
  110.         $hotspot_coordinates=unserialize($hotspot_coordinates);
  111.         $hotspot_type=unserialize($hotspot_type);
  112.  
  113.  
  114.     }
  115.     //fill in blanks
  116.   else
  117.     {
  118.         $reponse=unserialize($reponse);
  119.         $comment=unserialize($comment);
  120.         $blanks=unserialize($blanks);
  121.         $weighting=unserialize($weighting);
  122.     }
  123.  
  124.     unset($buttonBack);
  125. }
  126.  
  127. // the answer form has been submitted
  128. if($submitAnswers || $buttonBack)
  129. {
  130.     if($debug>0){echo '$submitAnswers or $buttonBack was set'."<br />\n";}
  131.     if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER)
  132.     {
  133.       if($debug>0){echo '&nbsp;&nbsp;$answerType is UNIQUE_ANSWER or MULTIPLE_ANSWER'."<br />\n";}
  134.         $questionWeighting=$nbrGoodAnswers=0;
  135.  
  136.         for($i=1;$i <= $nbrAnswers;$i++)
  137.         {
  138.             $reponse[$i]=trim($reponse[$i]);
  139.             $comment[$i]=trim($comment[$i]);
  140.             $weighting[$i]=intval($weighting[$i]);
  141.  
  142.             if($answerType == UNIQUE_ANSWER)
  143.             {
  144.             if($debug>0){echo str_repeat('&nbsp;',4).'$answerType is UNIQUE_ANSWER'."<br />\n";}
  145.                 $goodAnswer=($correct == $i)?1:0;
  146.             }
  147.             else
  148.             {
  149.                 $goodAnswer=$correct[$i];
  150.             }
  151.  
  152.             if($goodAnswer)
  153.             {
  154.                 $nbrGoodAnswers++;
  155.  
  156.                 // a good answer can't have a negative weighting
  157.                 $weighting[$i]=abs($weighting[$i]);
  158.  
  159.                 // calculates the sum of answer weighting only if it is different from 0 and the answer is good
  160.                 if($weighting[$i])
  161.                 {
  162.                     $questionWeighting+=$weighting[$i];
  163.                 }
  164.             }
  165.             elseif($answerType == MULTIPLE_ANSWER)
  166.             {
  167.             if($debug>0){echo str_repeat('&nbsp;',4).'$answerType is MULTIPLE_ANSWER'."<br />\n";}
  168.                 // a bad answer can't have a positive weighting
  169.                 $weighting[$i]=0-abs($weighting[$i]);
  170.             }
  171.  
  172.             // checks if field is empty
  173.             if(empty($reponse[$i]&& $reponse[$i!= '0')
  174.             {
  175.                 $msgErr=get_lang('GiveAnswers');
  176.  
  177.                 // clears answers already recorded into the Answer object
  178.                 $objAnswer->cancel();
  179.  
  180.                 break;
  181.             }
  182.             else
  183.             {
  184.                 // adds the answer into the object
  185.                 $objAnswer->createAnswer($reponse[$i],$goodAnswer,$comment[$i],$weighting[$i],$i);
  186.                 //added
  187.                 //if($_REQUEST['myid']==1)
  188.                     $mainurl="admin.php";
  189.                 //    else
  190.                   //  $mainurl="question_pool.php";
  191.                     ?>
  192.                     <script>
  193.                     window.location.href='<?php echo $mainurl;?>';
  194.                     </script>
  195.                     <?php
  196.             }
  197.         }  // end for()
  198.  
  199.         if(empty($msgErr))
  200.         {
  201.             if(!$nbrGoodAnswers)
  202.             {
  203.                 $msgErr=($answerType == UNIQUE_ANSWER)?get_lang('ChooseGoodAnswer'):get_lang('ChooseGoodAnswers');
  204.  
  205.                 // clears answers already recorded into the Answer object
  206.                 $objAnswer->cancel();
  207.             }
  208.             // checks if the question is used in several exercises
  209.             elseif($exerciseId && !$modifyIn && $objQuestion->selectNbrExercises(1)
  210.             {
  211.                 $usedInSeveralExercises=1;
  212.             }
  213.             else
  214.             {
  215.                 // saves the answers into the data base
  216.                 $objAnswer->save();
  217.  
  218.                 // sets the total weighting of the question
  219.                 $objQuestion->updateWeighting($questionWeighting);
  220.                 $objQuestion->save($exerciseId);
  221.  
  222.                 $editQuestion=$questionId;
  223.  
  224.                 unset($modifyAnswers);
  225.             }
  226.         }
  227.     }
  228.     elseif($answerType == FILL_IN_BLANKS)
  229.     {
  230.         if($debug>0){echo str_repeat('&nbsp;',2).'$answerType is FILL_IN_BLANKS'."<br />\n";}
  231.         $reponse=trim($reponse);
  232.  
  233.         if(!$buttonBack)
  234.         {
  235.             if($debug>0){echo str_repeat('&nbsp;',4).'$buttonBack is not set'."<br />\n";}
  236.             if($setWeighting)
  237.             {
  238.                 $blanks=unserialize($blanks);
  239.  
  240.                 // checks if the question is used in several exercises
  241.                 if($exerciseId && !$modifyIn && $objQuestion->selectNbrExercises(1)
  242.                 {
  243.                     $usedInSeveralExercises=1;
  244.                 }
  245.                 else
  246.                 {
  247.                     // separates text and weightings by '::'
  248.                     $reponse.='::';
  249.  
  250.                     $questionWeighting=0;
  251.  
  252.                     foreach($weighting as $val)
  253.                     {
  254.                         // a blank can't have a negative weighting
  255.                         $val=abs($val);
  256.  
  257.                         $questionWeighting+=$val;
  258.  
  259.                         // adds blank weighting at the end of the text
  260.                         $reponse.=$val.',';
  261.                     }
  262.  
  263.                     $reponse=substr($reponse,0,-1);
  264.  
  265.                     $objAnswer->createAnswer($reponse,0,'',0,'');
  266.                     $objAnswer->save();
  267.                     //added
  268.                     //if($_REQUEST['myid']==1)
  269.                     $mainurl="admin.php";
  270.                 //    else
  271.                   //  $mainurl="question_pool.php";
  272.                     ?>
  273.                     <script>
  274.                     window.location.href='<?php echo $mainurl;?>';
  275.                     </script>
  276.                     <?php
  277.  
  278.  
  279.                     // sets the total weighting of the question
  280.                     $objQuestion->updateWeighting($questionWeighting);
  281.                     $objQuestion->save($exerciseId);
  282.  
  283.                     $editQuestion=$questionId;
  284.  
  285.                     unset($modifyAnswers);
  286.                 }
  287.             }
  288.             // if no text has been typed or the text contains no blank
  289.             elseif(empty($reponse))
  290.             {
  291.                 $msgErr=get_lang('GiveText');
  292.             }
  293.             elseif(!ereg('\[.+\]',$reponse))
  294.             {
  295.                 $msgErr=get_lang('DefineBlanks');
  296.             }
  297.             else
  298.             {
  299.                 // now we're going to give a weighting to each blank
  300.                 $setWeighting=1;
  301.  
  302.                 unset($submitAnswers);
  303.  
  304.                 // removes character '::' possibly inserted by the user in the text
  305.                 $reponse=str_replace('::','',$reponse);
  306.  
  307.                 // we save the answer because it will be modified
  308.                 $temp=$reponse;
  309.  
  310.                 // 1. find everything between the [tex] and [/tex] tags
  311.                 $startlocations=strpos($temp,'[tex]');
  312.                 $endlocations=strpos($temp,'[/tex]');
  313.  
  314.                 if($startlocations !== false && $endlocations !== false)
  315.                 {
  316.                     $texstring=substr($temp,$startlocations,$endlocations-$startlocations+6);
  317.  
  318.                     // 2. replace this by {texcode}
  319.                     $temp=str_replace($texstring,"{texcode}",$temp);
  320.                 }
  321.  
  322.                 // blanks will be put into an array
  323.                 $blanks=Array();
  324.  
  325.                 $i=1;
  326.  
  327.                 // the loop will stop at the end of the text
  328.                 while(1)
  329.                 {
  330.                     // quits the loop if there are no more blanks
  331.                     if(($pos strpos($temp,'[')) === false)
  332.                     {
  333.                         break;
  334.                     }
  335.  
  336.                     // removes characters till '['
  337.                     $temp=substr($temp,$pos+1);
  338.  
  339.                     // quits the loop if there are no more blanks
  340.                     if(($pos strpos($temp,']')) === false)
  341.                     {
  342.                         break;
  343.                     }
  344.  
  345.                     // stores the found blank into the array
  346.                     $blanks[$i++]=substr($temp,0,$pos);
  347.  
  348.                     // removes the character ']'
  349.                     $temp=substr($temp,$pos+1);
  350.                 }
  351.             }
  352.         }
  353.         else
  354.         {
  355.             unset($setWeighting);
  356.         }
  357.     }
  358.     elseif($answerType == FREE_ANSWER)
  359.     {
  360.         if($debug>0){echo str_repeat('&nbsp;',2).'$answerType is FREE_ANSWER'."<br />\n";}
  361.         if empty $free_comment ) ) {
  362.             $free_comment $_POST['comment'];
  363.         }
  364.         if empty $weighting ) ) {
  365.             $weighting $_POST['weighting'];
  366.             $weightingtemp $_POST['weighting'];
  367.  
  368.         }
  369.  
  370.         if(!$buttonBack)
  371.         {
  372.             if($debug>0){echo str_repeat('&nbsp;',4).'$buttonBack is not set'."<br />\n";}
  373.             if($setWeighting)
  374.             {
  375.                 if($debug>0){echo str_repeat('&nbsp;',6).'$setWeighting is set'."<br />\n";}
  376.                 // checks if the question is used in several exercises
  377.                 if($exerciseId && !$modifyIn && $objQuestion->selectNbrExercises(1)
  378.                 {
  379.                     $usedInSeveralExercises=1;
  380.                 }
  381.                 else
  382.                 {
  383.  
  384.                     $objAnswer->createAnswer('',0,$free_comment,$weighting,'');
  385.                     $objAnswer->save();
  386.                     // sets the total weighting of the question
  387.                     $objQuestion->updateWeighting($weighting);
  388.                     $objQuestion->save($exerciseId);
  389.  
  390.                     $editQuestion=$questionId;
  391.  
  392.                     unset($modifyAnswers);//added
  393.                     //if($_REQUEST['myid']==1)
  394.                    $mainurl="admin.php";
  395.                 //    else
  396.                   //  $mainurl="question_pool.php";
  397.                     ?>
  398.                     <script>
  399.                     window.location.href='<?php echo $mainurl;?>';
  400.                     </script>
  401.                     <?php
  402.                 }
  403.             }
  404.             // if no text has been typed or the text contains no blank
  405.             elseif(empty($free_comment))
  406.             {
  407.                 if($debug>0){echo str_repeat('&nbsp;',6).'$free_comment is empty'."<br />\n";}
  408.                 $msgErr=get_lang('GiveText');
  409.             }
  410.             /*elseif(!ereg('\[.+\]',$reponse))
  411.             {
  412.                 $msgErr=get_lang('DefineBlanks');
  413.             }*/
  414.             else
  415.             {
  416.                 if($debug>0){echo str_repeat('&nbsp;',6).'$setWeighting is not set and $free_comment is not empty'."<br />\n";}
  417.  
  418.                 // now we're going to give a weighting to each blank
  419.                 $setWeighting=1;
  420.  
  421.                 unset($submitAnswers);
  422.             }
  423.         }
  424.         else
  425.         {
  426.             unset($setWeighting);
  427.         }
  428.     }
  429.     elseif($answerType == MATCHING)
  430.     {
  431.         if($debug>0){echo str_repeat('&nbsp;',2).'$answerType is MATCHING'."<br />\n";}
  432.         for($i=1;$i <= $nbrOptions;$i++)
  433.         {
  434.             $option[$i]=trim($option[$i]);
  435.  
  436.             // checks if field is empty
  437.             if(empty($option[$i]&& $option[$i!= '0')
  438.             {
  439.                 $msgErr=get_lang('FillLists');
  440.  
  441.                 // clears options already recorded into the Answer object
  442.                 $objAnswer->cancel();
  443.  
  444.                 break;
  445.             }
  446.             else
  447.             {
  448.                 // adds the option into the object
  449.                 $objAnswer->createAnswer($option[$i],0,'',0,$i);
  450.             }
  451.         }
  452.  
  453.         $questionWeighting=0;
  454.  
  455.         if(empty($msgErr))
  456.         {
  457.             for($j=1;$j <= $nbrMatches;$i++,$j++)
  458.             {
  459.                 $match[$i]=trim($match[$i]);
  460.                 $weighting[$i]=abs(intval($weighting[$i]));
  461.  
  462.                 $questionWeighting+=$weighting[$i];
  463.  
  464.                 // checks if field is empty
  465.                 if(empty($match[$i]&& $match[$i!= '0')
  466.                 {
  467.                     $msgErr=get_lang('FillLists');
  468.  
  469.                     // clears matches already recorded into the Answer object
  470.                     $objAnswer->cancel();
  471.  
  472.                     break;
  473.                 }
  474.                 // check if correct number
  475.                 else
  476.                 {
  477.                     // adds the answer into the object
  478.                     $objAnswer->createAnswer($match[$i],$sel[$i],'',$weighting[$i],$i);
  479.                     //added
  480.                     //if($_REQUEST['myid']==1)
  481.                     $mainurl="admin.php";
  482.                     //else
  483.                     //$mainurl="question_pool.php";
  484.                     ?>
  485.                     <script>
  486.                     window.location.href='<?php echo $mainurl;?>';
  487.                     </script>
  488.                     <?php
  489.                 }
  490.             }
  491.         }
  492.  
  493.         if(empty($msgErr))
  494.         {
  495.             // checks if the question is used in several exercises
  496.             if($exerciseId && !$modifyIn && $objQuestion->selectNbrExercises(1)
  497.             {
  498.                 $usedInSeveralExercises=1;
  499.             }
  500.             else
  501.             {
  502.                 // all answers have been recorded, so we save them into the data base
  503.                 $objAnswer->save();
  504.  
  505.                 // sets the total weighting of the question
  506.                 $objQuestion->updateWeighting($questionWeighting);
  507.                 $objQuestion->save($exerciseId);
  508.  
  509.                 $editQuestion=$questionId;
  510.  
  511.                 unset($modifyAnswers);
  512.             }
  513.         }
  514.     }
  515.     elseif($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER)
  516.     {
  517.         $questionWeighting=$nbrGoodAnswers=0;
  518.  
  519.         for($i=1;$i <= $nbrAnswers;$i++)
  520.         {
  521.             if($debug>0){echo str_repeat('&nbsp;',4).'$answerType is HOT_SPOT'."<br />\n";}
  522.  
  523.             $reponse[$i]=trim($reponse[$i]);
  524.             $comment[$i]=trim($comment[$i]);
  525.             $weighting[$i]=intval($weighting[$i]);
  526.  
  527.             // checks if field is empty
  528.             if(empty($reponse[$i]&& $reponse[$i!= '0')
  529.             {
  530.                 $msgErr=get_lang('HotspotGiveAnswers');
  531.  
  532.                 // clears answers already recorded into the Answer object
  533.                 $objAnswer->cancel();
  534.  
  535.                 break;
  536.             }
  537.  
  538.             if($weighting[$i<= 0)
  539.             {
  540.                 $msgErr=get_lang('HotspotWeightingError');
  541.  
  542.                 // clears answers already recorded into the Answer object
  543.                 $objAnswer->cancel();
  544.  
  545.                 break;
  546.             }
  547.             if($hotspot_coordinates[$i== '0;0|0|0' || empty($hotspot_coordinates[$i]))
  548.             {
  549.                 $msgErr=get_lang('HotspotNotDrawn');
  550.  
  551.                 // clears answers already recorded into the Answer object
  552.                 $objAnswer->cancel();
  553.  
  554.                 break;
  555.             }
  556.  
  557.         }  // end for()
  558.  
  559.  
  560.         if(empty($msgErr))
  561.         {
  562.             if($exerciseId && !$modifyIn && $objQuestion->selectNbrExercises(1)
  563.             {
  564.                 $usedInSeveralExercises=1;
  565.             }
  566.             else
  567.             {
  568.                 for($i=1;$i <= $nbrAnswers;$i++)
  569.                 {
  570.                     if($debug>0){echo str_repeat('&nbsp;',4).'$answerType is HOT_SPOT'."<br />\n";}
  571.  
  572.                     $reponse[$i]=trim($reponse[$i]);
  573.                     $comment[$i]=addslashes(trim($comment[$i]));
  574.                     $weighting[$i]=intval($weighting[$i]);
  575.                     if($weighting[$i])
  576.                     {
  577.                         $questionWeighting+=$weighting[$i];
  578.                     }
  579.  
  580.                     // creates answer
  581.                     $objAnswer->createAnswer($reponse[$i]'',$comment[$i],$weighting[$i],$i,$hotspot_coordinates[$i],$hotspot_type[$i]);
  582.                 }  // end for()
  583.                 // saves the answers into the data base
  584.                 $objAnswer->save();
  585.  
  586.                 // sets the total weighting of the question
  587.                 $objQuestion->updateWeighting($questionWeighting);
  588.                 $objQuestion->save($exerciseId);
  589.  
  590.                 $editQuestion=$questionId;
  591.  
  592.                 unset($modifyAnswers);
  593.             }
  594.         }
  595.     }
  596.     if($debug>0){echo '$modifyIn was set - end'."<br />\n";}
  597.  
  598. }
  599.  
  600. if($modifyAnswers)
  601. {
  602.  
  603.  
  604.     if($debug>0){echo str_repeat('&nbsp;',0).'$modifyAnswers is set'."<br />\n";}
  605.  
  606.     // construction of the Answer object
  607.     $objAnswer=new Answer($questionId);
  608.  
  609.  
  610.     api_session_register('objAnswer');
  611.  
  612.     if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER)
  613.     {
  614.        if($debug>0){echo str_repeat('&nbsp;',2).'$answerType is UNIQUE_ANSWER or MULTIPLE_ANSWER'."<br />\n";}
  615.         if(!$nbrAnswers)
  616.         {
  617.             $nbrAnswers=$objAnswer->selectNbrAnswers();
  618.  
  619.             $reponse=Array();
  620.             $comment=Array();
  621.             $weighting=Array();
  622.  
  623.             // initializing
  624.             if($answerType == MULTIPLE_ANSWER)
  625.             {
  626.                 $correct=Array();
  627.             }
  628.             else
  629.             {
  630.                 $correct=0;
  631.             }
  632.  
  633.             for($i=1;$i <= $nbrAnswers;$i++)
  634.             {
  635.                 $reponse[$i]=$objAnswer->selectAnswer($i);
  636.                 $comment[$i]=$objAnswer->selectComment($i);
  637.                 $weighting[$i]=$objAnswer->selectWeighting($i);
  638.  
  639.                 if($answerType == MULTIPLE_ANSWER)
  640.                 {
  641.                     $correct[$i]=$objAnswer->isCorrect($i);
  642.                 }
  643.                 elseif($objAnswer->isCorrect($i))
  644.                 {
  645.                     $correct=$i;
  646.                 }
  647.             }
  648.         }
  649.  
  650.         if($lessAnswers)
  651.         {
  652.             $nbrAnswers--;
  653.         }
  654.  
  655.         if($moreAnswers)
  656.         {
  657.             $nbrAnswers++;
  658.         }
  659.  
  660.         // minimum 2 answers
  661.         if($nbrAnswers 2)
  662.         {
  663.             $nbrAnswers=2;
  664.         }
  665.     }
  666.     elseif($answerType == FILL_IN_BLANKS)
  667.     {
  668.        if($debug>0){echo str_repeat('&nbsp;',2).'$answerType is FILL_IN_BLANKS'."<br />\n";}
  669.         if(!$submitAnswers && !$buttonBack)
  670.         {
  671.             if(!$setWeighting)
  672.             {
  673.                 $reponse=$objAnswer->selectAnswer(1);
  674.  
  675.                 list($reponse,$weighting)=explode('::',$reponse);
  676.  
  677.                 $weighting=explode(',',$weighting);
  678.  
  679.                 $temp=Array();
  680.  
  681.                 // keys of the array go from 1 to N and not from 0 to N-1
  682.                 for($i=0;$i sizeof($weighting);$i++)
  683.                 {
  684.                     $temp[$i+1]=$weighting[$i];
  685.                 }
  686.  
  687.                 $weighting=$temp;
  688.             }
  689.             elseif(!$modifyIn)
  690.             {
  691.                 $weighting=unserialize($weighting);
  692.             }
  693.         }
  694.     }
  695.     elseif($answerType == FREE_ANSWER)
  696.     {
  697.         if($debug>0){echo str_repeat('&nbsp;',2).'$answerType is FREE_ANSWER'."<br />\n";}
  698.         if(!$submitAnswers && !$buttonBack)
  699.         {
  700.             if($debug>0){echo str_repeat('&nbsp;',4).'$submitAnswers && $buttonsBack are unset'."<br />\n";}
  701.             if(!$setWeighting)
  702.             {
  703.                 if($debug>0){echo str_repeat('&nbsp;',6).'$setWeighting is unset'."<br />\n";}
  704.  
  705.                 //YW: not quite  sure about whether the comment has already been recovered,
  706.                 // but as we have passed into the submitAnswers loop, this should be in the
  707.                 // objAnswer object.
  708.                 $free_comment $objAnswer->selectComment(1);
  709.                 $weighting=$objAnswer->selectWeighting(1)//added
  710.             }
  711.             elseif(!$modifyIn)
  712.             {
  713.                 if($debug>0){echo str_repeat('&nbsp;',6).'$setWeighting is set and $modifyIn is unset'."<br />\n";}
  714.                 $weighting=unserialize($weighting);
  715.             }
  716.         }
  717.     }
  718.     elseif($answerType == MATCHING)
  719.     {
  720.         if($debug>0){echo str_repeat('&nbsp;',2).'$answerType is MATCHING'."<br />\n";}
  721.         if(!$nbrOptions || !$nbrMatches)
  722.         {
  723.             $option=Array();
  724.             $match=Array();
  725.             $sel=Array();
  726.  
  727.             $nbrOptions=$nbrMatches=0;
  728.  
  729.             // fills arrays with data from de data base
  730.             for($i=1;$i <= $objAnswer->selectNbrAnswers();$i++)
  731.             {
  732.                 // it is a match
  733.                 if($objAnswer->isCorrect($i))
  734.                 {
  735.                     $match[$i]=$objAnswer->selectAnswer($i);
  736.                     $sel[$i]=$objAnswer->isCorrect($i);
  737.                     $weighting[$i]=$objAnswer->selectWeighting($i);
  738.                     $nbrMatches++;
  739.                 }
  740.                 // it is an option
  741.                 else
  742.                 {
  743.                     $option[$i]=$objAnswer->selectAnswer($i);
  744.                     $nbrOptions++;
  745.                 }
  746.             }
  747.         }
  748.  
  749.         if($lessOptions)
  750.         {
  751.             // keeps the correct sequence of array keys when removing an option from the list
  752.             for($i=$nbrOptions+1,$j=1;$nbrOptions && $j <= $nbrMatches;$i++,$j++)
  753.             {
  754.                 $match[$i-1]=$match[$i];
  755.                 $sel[$i-1]=$sel[$i];
  756.                 $weighting[$i-1]=$weighting[$i];
  757.             }
  758.  
  759.             unset($match[$i-1]);
  760.             unset($sel[$i-1]);
  761.  
  762.             $nbrOptions--;
  763.         }
  764.  
  765.         if($moreOptions)
  766.         {
  767.             // keeps the correct sequence of array keys when adding an option into the list
  768.             for($i=$nbrMatches+$nbrOptions;$i $nbrOptions;$i--)
  769.             {
  770.                 $match[$i+1]=$match[$i];
  771.                 $sel[$i+1]=$sel[$i];
  772.                 $weighting[$i+1]=$weighting[$i];
  773.             }
  774.  
  775.             unset($match[$i+1]);
  776.             unset($sel[$i+1]);
  777.  
  778.             $nbrOptions++;
  779.         }
  780.  
  781.         if($lessMatches)
  782.         {
  783.             $nbrMatches--;
  784.         }
  785.  
  786.         if($moreMatches)
  787.         {
  788.             $nbrMatches++;
  789.         }
  790.  
  791.         // minimum 2 options
  792.         if($nbrOptions 2)
  793.         {
  794.             $nbrOptions=2;
  795.         }
  796.  
  797.         // minimum 2 matches
  798.         if($nbrMatches 2)
  799.         {
  800.             $nbrMatches=2;
  801.         }
  802.  
  803.     }
  804.     elseif ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER)
  805.     {
  806.         if($debug>0){echo str_repeat('&nbsp;',2).'$answerType is HOT_SPOT'."<br />\n";}
  807.  
  808.         $TBL_ANSWERS Database::get_course_table(TABLE_QUIZ_ANSWER);
  809.  
  810.         if(!$nbrAnswers)
  811.         {
  812.  
  813.             $nbrAnswers=$objAnswer->selectNbrAnswers();
  814.  
  815.             $reponse=Array();
  816.             $comment=Array();
  817.             $weighting=Array();
  818.             $hotspot_coordinates=Array();
  819.             $hotspot_type=array();
  820.  
  821.  
  822.             for($i=1;$i <= $nbrAnswers;$i++)
  823.             {
  824.                 $reponse[$i]=$objAnswer->selectAnswer($i);
  825.                 $comment[$i]=$objAnswer->selectComment($i);
  826.                 $weighting[$i]=$objAnswer->selectWeighting($i);
  827.                 $hotspot_coordinates[$i]=$objAnswer->selectHotspotCoordinates($i);
  828.                 $hotspot_type[$i]=$objAnswer->selectHotspotType($i);
  829.             }
  830.  
  831.  
  832.         }
  833.  
  834.         $_SESSION['tmp_answers'array();
  835.         $_SESSION['tmp_answers']['answer'$reponse;
  836.         $_SESSION['tmp_answers']['comment'$comment;
  837.         $_SESSION['tmp_answers']['weighting'$weighting;
  838.         $_SESSION['tmp_answers']['hotspot_coordinates'$hotspot_coordinates;
  839.         $_SESSION['tmp_answers']['hotspot_type'$hotspot_type;
  840.  
  841.         if($lessAnswers)
  842.         {
  843.             // At least 1 answer
  844.             if ($nbrAnswers 1{
  845.  
  846.                 $nbrAnswers--;
  847.  
  848.                 // Remove the last answer
  849.                 $tmp array_pop($_SESSION['tmp_answers']['answer']);
  850.                 $tmp array_pop($_SESSION['tmp_answers']['comment']);
  851.                 $tmp array_pop($_SESSION['tmp_answers']['weighting']);
  852.                 $tmp array_pop($_SESSION['tmp_answers']['hotspot_coordinates']);
  853.                 $tmp array_pop($_SESSION['tmp_answers']['hotspot_type']);
  854.             }
  855.             else
  856.             {
  857.                 $msgErr=get_lang('MinHotspot');
  858.             }
  859.         }
  860.  
  861.         if($moreAnswers)
  862.         {
  863.             if ($nbrAnswers 12)
  864.             {
  865.                 $nbrAnswers++;
  866.  
  867.                 // Add a new answer
  868.                 $_SESSION['tmp_answers']['answer'][]='';
  869.                 $_SESSION['tmp_answers']['comment'][]='';
  870.                 $_SESSION['tmp_answers']['weighting'][]='1';
  871.                 $_SESSION['tmp_answers']['hotspot_coordinates'][]='0;0|0|0';
  872.                 $_SESSION['tmp_answers']['hotspot_type'][]='square';
  873.             }
  874.             else
  875.             {
  876.                 $msgErr=get_lang('MaxHotspot');
  877.             }
  878.         }
  879.  
  880.     }
  881.  
  882.     if(!$usedInSeveralExercises)
  883.     {
  884.         if($debug>0){echo str_repeat('&nbsp;',2).'$usedInSeveralExercises is untrue'."<br />\n";}
  885.  
  886.         if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER)
  887.         {
  888.             if($debug>0){echo str_repeat('&nbsp;',4).'$answerType is UNIQUE_ANSWER or MULTIPLE_ANSWER'."<br />\n";}
  889.  
  890.  
  891.  
  892.  
  893. ?>
  894.  
  895.  
  896.  
  897.  
  898.  
  899. <h3>
  900.   <?php echo $questionName?>
  901. </h3>
  902. <?php
  903.         /*if ($exerciseId==0){
  904.     ?>
  905.         <form method="post" action="<?php echo api_get_self(); ?>?modifyAnswers=<?php  echo $modifyAnswers; ?>">
  906.         <?php }
  907.         else
  908.         {
  909.         ?>
  910.         <form method="post" action="<?php echo api_get_self(); ?>?exerciseId=<?php  echo $exerciseId; ?>">
  911.         <?php
  912.         }*/
  913.  
  914.  
  915. ?>
  916. <form method="post" action="<?php echo api_get_self()?>?modifyAnswers=<?php  echo $modifyAnswers?>">
  917.  
  918.  
  919. <input type="hidden" name="formSent" value="1">
  920. <input type="hidden" name="nbrAnswers" value="<?php echo $nbrAnswers?>">
  921. <input type="hidden" name="myid" value="<?php echo $_REQUEST['myid']?>">
  922.  
  923. <table width="650" border="0" cellpadding="5">
  924.  
  925. <?php
  926.             if($okPicture)
  927.             {
  928. ?>
  929.  
  930. <tr>
  931.   <td colspan="5" align="center"><img src="../document/download.php?doc_url=%2Fimages%2F<?php echo $pictureName?>" border="0"></td>
  932. </tr>
  933.  
  934. <?php
  935.             }
  936.  
  937.             if(!empty($msgErr))
  938.             {
  939. ?>
  940.  
  941. <tr>
  942.   <td colspan="5">
  943.  
  944. <?php
  945.     Display::display_normal_message($msgErr)//main API
  946. ?>
  947.  
  948.   </td>
  949. </tr>
  950.  
  951. <?php
  952.             }
  953. ?>
  954.  
  955. <tr>
  956.   <td colspan="5"><?php echo get_lang('Answers')?> :</td>
  957. </tr>
  958. <tr bgcolor="#E6E6E6">
  959.   <td>N°</td>
  960.   <td><?php echo get_lang('True')?></td>
  961.   <td><?php echo get_lang('Answer')?></td>
  962.   <td><?php echo get_lang('Comment')?></td>
  963.   <td><?php echo get_lang('QuestionWeighting')?></td>
  964. </tr>
  965.  
  966. <?php
  967.             for($i=1;$i <= $nbrAnswers;$i++)
  968.             {
  969. ?>
  970.  
  971. <tr>
  972.   <td valign="top"><?php echo $i?></td>
  973.  
  974. <?php
  975.                 if($answerType == UNIQUE_ANSWER)
  976.                 {
  977. ?>
  978.  
  979.   <td valign="top"><input class="checkbox" type="radio" value="<?php echo $i?>" name="correct" <?php if($correct == $iecho 'checked="checked"'?>></td>
  980.  
  981. <?php
  982.                 }
  983.                 else
  984.                 {
  985. ?>
  986.  
  987.   <td valign="top"><input class="checkbox" type="checkbox" value="1" name="correct[<?php echo $i?>]" <?php if($correct[$i]echo 'checked="checked"'?>></td>
  988.  
  989. <?php
  990.                 }
  991. ?>
  992.  
  993.   <td align="left"><textarea wrap="virtual" rows="7" cols="25" name="reponse[<?php echo $i?>]"><?php echo htmlentities($reponse[$i],ENT_QUOTES,$charset)?></textarea></td>
  994.   <td align="left"><textarea wrap="virtual" rows="7" cols="25" name="comment[<?php echo $i?>]"><?php echo htmlentities($comment[$i],ENT_QUOTES,$charset)?></textarea></td>
  995.  
  996.     <td valign="top"><input type="text" name="weighting[<?php echo $i?>]" size="5" value="<?php echo isset($weighting[$i])?$weighting[$i]:0?>"></td>
  997. </tr>
  998.  
  999. <?php
  1000.               }
  1001. ?>
  1002.  
  1003. <tr>
  1004.   <td colspan="5">
  1005.     <input type="submit" name="submitAnswers" value="<?php echo get_lang('Ok')?>">
  1006.     &nbsp;&nbsp;<input type="submit" name="lessAnswers" value="<?php echo get_lang('LessAnswers')?>">
  1007.     &nbsp;&nbsp;<input type="submit" name="moreAnswers" value="<?php echo get_lang('MoreAnswers')?>">
  1008.     <!-- &nbsp;&nbsp;<input type="submit" name="cancelAnswers" value="<?php echo get_lang('Cancel')?>" onclick="javascript:if(!confirm('<?php echo addslashes(htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset))?>')) return false;"> //-->
  1009.   </td>
  1010. </tr>
  1011. </table>
  1012. </form>
  1013.  
  1014. <?php
  1015.         }
  1016.         elseif($answerType == FILL_IN_BLANKS)
  1017.         {
  1018.  if($debug>0){echo str_repeat('&nbsp;',4).'$answerType is FILL_IN_BLANKS'."<br />\n";}
  1019.  
  1020. ?>
  1021.  
  1022. <h3>
  1023.   <?php echo $questionName?>
  1024. </h3>
  1025.  
  1026. <form name="formulaire" method="post" action="<?php echo api_get_self()?>?modifyAnswers=<?php echo $modifyAnswers?>">
  1027. <input type="hidden" name="formSent" value="1">
  1028. <input type="hidden" name="setWeighting" value="<?php echo $setWeighting?>">
  1029. <input type="hidden" name="myid" value="<?php echo $_REQUEST['myid']?>">
  1030.  
  1031. <?php
  1032.             if(!$setWeighting)
  1033.             {
  1034. ?>
  1035.  
  1036. <input type="hidden" name="weighting" value="<?php echo $submitAnswers?htmlentities($weighting,ENT_QUOTES,$charset):htmlentities(serialize($weighting),ENT_QUOTES,$charset)?>">
  1037.  
  1038. <table border="0" cellpadding="5" width="500">
  1039.  
  1040. <?php
  1041.                 if($okPicture)
  1042.                {
  1043. ?>
  1044.  
  1045. <tr>
  1046.   <td align="center"><img src="../document/download.php?doc_url=%2Fimages%2F<?php echo $pictureName?>" border="0"></td>
  1047. </tr>
  1048.  
  1049. <?php
  1050.                 }
  1051.  
  1052.                 if(!empty($msgErr))
  1053.                 {
  1054. ?>
  1055.  
  1056. <tr>
  1057.   <td colspan="2">
  1058.  
  1059. <?php
  1060.                     Display::display_normal_message($msgErr)//main API
  1061. ?>
  1062.  
  1063.   </td>
  1064. </tr>
  1065.  
  1066. <?php
  1067.                 }
  1068. ?>
  1069.  
  1070. <tr>
  1071.   <td><?php echo get_lang('TypeTextBelow').', '.get_lang('And').' '.get_lang('UseTagForBlank')?> :</td>
  1072. </tr>
  1073. <tr>
  1074.   <td><textarea wrap="virtual" name="reponse" cols="65" rows="6"><?php if(!$submitAnswers && empty($reponse)) echo get_lang('DefaultTextInBlanks')else echo htmlentities($reponse,ENT_QUOTES,$charset)?></textarea></td>
  1075. </tr>
  1076. <tr>
  1077.   <td colspan="5">
  1078.     <!-- <input type="submit" name="cancelAnswers" value="<?php echo get_lang('Cancel')?>" onclick="javascript:if(!confirm('<?php echo addslashes(htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset))?>')) return false;">
  1079.     &nbsp;&nbsp; //--> <input type="submit" name="submitAnswers" value="<?php echo get_lang('Ok')?>">
  1080.   </td>
  1081. </tr>
  1082. </table>
  1083.  
  1084. <?php
  1085. }
  1086.  else
  1087. {
  1088. ?>
  1089. <input type="hidden" name="blanks" value="<?php echo htmlentities(serialize($blanks),ENT_QUOTES,$charset)?>">
  1090. <input type="hidden" name="reponse" value="<?php echo htmlentities($reponse,ENT_QUOTES,$charset)?>">
  1091. <table border="0" cellpadding="5" width="500">
  1092. <?php
  1093.                 if(!empty($msgErr))
  1094.                 {
  1095. ?>
  1096.  
  1097. <tr>
  1098.   <td colspan="2">
  1099.  
  1100. <?php
  1101.                     Display::display_normal_message($msgErr)//main API
  1102. ?>
  1103.  
  1104.   </td>
  1105. </tr>
  1106.  
  1107. <?php
  1108.                 }
  1109. ?>
  1110.  
  1111. <tr>
  1112.   <td colspan="2"><?php echo get_lang('WeightingForEachBlank')?> :</td>
  1113. </tr>
  1114. <tr>
  1115.   <td colspan="2">&nbsp;</td>
  1116. </tr>
  1117.  
  1118. <?php
  1119.                 foreach($blanks as $i=>$blank)
  1120.                 {
  1121. ?>
  1122.  
  1123. <tr>
  1124.   <td width="50%"><?php echo $blank?> :</td>
  1125.   <td width="50%"><input type="text" name="weighting[<?php echo $i?>]" size="5" value="<?php echo intval($weighting[$i])?>"></td>
  1126. </tr>
  1127.  
  1128. <?php
  1129.                 }
  1130. ?>
  1131.  
  1132. <tr>
  1133.   <td colspan="2">&nbsp;</td>
  1134. </tr>
  1135. <tr>
  1136.   <td colspan="2">
  1137.     <input type="submit" name="buttonBack" value="&lt; <?php echo get_lang('Back')?>">
  1138.     &nbsp;&nbsp;<input type="submit" name="submitAnswers" value="<?php echo get_lang('Ok')?>">
  1139.     <!-- &nbsp;&nbsp;<input type="submit" name="cancelAnswers" value="<?php echo get_lang('Cancel')?>" onclick="javascript:if(!confirm('<?php echo addslashes(htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset))?>')) return false;"> //-->
  1140.   </td>
  1141. </tr>
  1142. </table>
  1143.  
  1144. <?php
  1145.             }
  1146. ?>
  1147.  
  1148. </form>
  1149.  
  1150. <?php
  1151.         }
  1152.         elseif($answerType == FREE_ANSWER//edited by Priya Saini
  1153.         {
  1154.             if($debug>0){echo str_repeat('&nbsp;',4).'$answerType is FREE_ANSWER'."<br />\n";}
  1155.             ?>
  1156.             <h3>
  1157.             <?php echo $questionName;?></h3><?php
  1158.             $sql "select description from `".$TBL_QUESTIONS."` where id = '$questionId'";
  1159.             $res api_sql_query($sql,_FILE_,_LINE_);
  1160.             ?>
  1161.             &nbsp; &nbsp; &nbsp;
  1162.             <?php
  1163.             echo $desc mysql_result($res,0,'description');
  1164.              ?>
  1165.  
  1166.             <form name="formulaire" method="post" action="<?php echo api_get_self()?>?modifyAnswers=<?php echo $modifyAnswers?>">
  1167.             <input type="hidden" name="formSent" value="1">
  1168.             <input type="hidden" name="setWeighting" value="1">
  1169.             <input type="hidden" name="myid" value="<?php  echo $_REQUEST['myid'];?>">
  1170.              <table border="0" cellpadding="5" width="500">
  1171.             <?php
  1172.                 if($okPicture)
  1173.                 echo "Ok picture";
  1174.             ?>
  1175.  
  1176.                 <tr>
  1177.                  <td align="center"><img src="../document/download.php?doc_url=%2Fimages%2F<?php echo $pictureName?>" border="0"></td>
  1178.                 </tr>
  1179.             <?php
  1180.                 }
  1181.  
  1182.                 if(!empty($msgErr))
  1183.                 {
  1184.             ?>
  1185.                 <tr>
  1186.                 <td colspan="2">
  1187.             <?php
  1188.                     Display::display_normal_message($msgErr)//main API
  1189.             ?>
  1190.  
  1191.                   </td>
  1192.                 </tr>
  1193.             <?php
  1194.                 }
  1195.              if(!$submitAnswers && empty($free_comment))
  1196.                 echo '';
  1197.             else
  1198.                 echo htmlentities($free_comment,ENT_QUOTES,$charset)?>
  1199.                    <tr><td width="22%"><?php echo get_lang('QuestionWeighting')?></td>
  1200.                 <td width="78%"><input type="text" size="4" name="weighting" value="<?php if(!$submitAnswers && !isset($weighting)) echo '0'else echo $weighting?>"></td>
  1201.                 </tr>
  1202.                 <tr>
  1203.                <td colspan="5">
  1204.                     <input type="submit" name="submitAnswers" value="<?php echo get_lang('Ok')?>">
  1205.                   </td>
  1206.                 </tr>
  1207.             </table>
  1208. <?php
  1209.        }
  1210.       //end of FREE_ANSWER type*/
  1211.         elseif($answerType == MATCHING)
  1212.         {
  1213. ?>
  1214.  
  1215. <h3>
  1216.   <?php echo $questionName?>
  1217. </h3>
  1218.  
  1219. <form method="post" action="<?php echo api_get_self()?>?modifyAnswers=<?php echo $modifyAnswers?>">
  1220. <input type="hidden" name="formSent" value="1">
  1221. <input type="hidden" name="nbrOptions" value="<?php echo $nbrOptions?>">
  1222. <input type="hidden" name="nbrMatches" value="<?php echo $nbrMatches?>">
  1223. <input type="hidden" name="myid" value="<?php echo $_REQUEST['myid'];?>">
  1224.  
  1225. <table border="0" cellpadding="5">
  1226.  
  1227. <?php
  1228.             if($okPicture)
  1229.             {
  1230. ?>
  1231.  
  1232. <tr>
  1233.   <td colspan="4" align="center"><img src="../document/download.php?doc_url=%2Fimages%2F<?php echo $pictureName?>" border="0"></td>
  1234. </tr>
  1235.  
  1236. <?php
  1237.             }
  1238.  
  1239.             if(!empty($msgErr))
  1240.             {
  1241. ?>
  1242.  
  1243. <tr>
  1244.   <td colspan="4">
  1245.  
  1246. <?php
  1247.                 Display::display_normal_message($msgErr)//main API
  1248. ?>
  1249.  
  1250.   </td>
  1251. </tr>
  1252.  
  1253. <?php
  1254.             }
  1255.  
  1256.             $listeOptions=Array();
  1257.  
  1258.             // creates an array with the option letters
  1259.             for($i=1,$j='A';$i <= $nbrOptions;$i++,$j++)
  1260.             {
  1261.                 $listeOptions[$i]=$j;
  1262.             }
  1263. ?>
  1264.  
  1265. <tr>
  1266.   <td colspan="3"><?php echo get_lang('MakeCorrespond')?> :</td>
  1267.   <td><?php echo get_lang('QuestionWeighting')?> :</td>
  1268. </tr>
  1269.  
  1270. <?php
  1271.             for($j=1;$j <= $nbrMatches;$i++,$j++)
  1272.             {
  1273. ?>
  1274.  
  1275. <tr>
  1276.   <td><?php echo $j?></td>
  1277.   <td><input type="text" name="match[<?php echo $i?>]" size="58" value="<?php if(!$formSent && !isset($match[$i])) echo ${"langDefaultMakeCorrespond$j"}else echo htmlentities($match[$i],ENT_QUOTES,$charset)?>"></td>
  1278.   <td align="center"><select name="sel[<?php echo $i?>]">
  1279.  
  1280. <?php
  1281.                 foreach($listeOptions as $key=>$val)
  1282.                 {
  1283. ?>
  1284.  
  1285.     <option value="<?php echo $key?><?php if((!$submitAnswers && !isset($sel[$i]&& $j == && $val == 'B'|| $sel[$i== $keyecho 'selected="selected"'?>><?php echo $val?></option>
  1286.  
  1287. <?php
  1288.                 // end foreach()
  1289. ?>
  1290.  
  1291.   </select></td>
  1292.   <td align="center"><input type="text" size="8" name="weighting[<?php echo $i?>]" value="<?php if(!$submitAnswers && !isset($weighting[$i])) echo '5'else echo $weighting[$i]?>"></td>
  1293. </tr>
  1294.  
  1295. <?php
  1296.             // end for()
  1297. ?>
  1298.  
  1299. <tr>
  1300.   <td colspan="4">
  1301.     <input type="submit" name="lessMatches" value="<?php echo get_lang('LessElements')?>">
  1302.     &nbsp;&nbsp;<input type="submit" name="moreMatches" value="<?php echo get_lang('MoreElements')?>">
  1303.   </td>
  1304. </tr>
  1305. <tr>
  1306.   <td colspan="4"><?php echo get_lang('DefineOptions')?> :</td>
  1307. </tr>
  1308.  
  1309. <?php
  1310.             foreach($listeOptions as $key=>$val)
  1311.             {
  1312. ?>
  1313.  
  1314. <tr>
  1315.   <td><?php echo $val?></td>
  1316.   <td colspan="3"><input type="text" name="option[<?php echo $key?>]" size="80" value="<?php if(!$formSent && !isset($option[$key])) echo get_lang("DefaultMatchingOpt$val")else echo htmlentities($option[$key],ENT_QUOTES,$charset)?>"></td>
  1317. </tr>
  1318.  
  1319. <?php
  1320.             // end foreach()
  1321. ?>
  1322.  
  1323. <tr>
  1324.   <td colspan="4">
  1325.     <input type="submit" name="lessOptions" value="<?php echo get_lang('LessElements')?>">
  1326.     &nbsp;&nbsp;<input type="submit" name="moreOptions" value="<?php echo get_lang('MoreElements')?>">
  1327.   </td>
  1328. </tr>
  1329. <tr>
  1330.   <td colspan="4">&nbsp;</td>
  1331. </tr>
  1332. <tr>
  1333.   <td colspan="4">
  1334.     <!-- <input type="submit" name="cancelAnswers" value="<?php echo get_lang('Cancel')?>" onclick="javascript:if(!confirm('<?php echo addslashes(htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset))?>')) return false;">
  1335.     &nbsp;&nbsp; //--> <input type="submit" name="submitAnswers" value="<?php echo get_lang('Ok')?>">
  1336.   </td>
  1337. </tr>
  1338. </table>
  1339. </form>
  1340.  
  1341. <?php
  1342.         }
  1343.         elseif ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER)
  1344.         {
  1345.             if($debug>0){echo str_repeat('&nbsp;',4).'$answerType is HOT_SPOT'."<br />\n";}
  1346.             $hotspot_colors array(""// $i starts from 1 on next loop (ugly fix)
  1347.                                     "#4271B5",
  1348.                                     "#FE8E16",
  1349.                                     "#3B3B3B",
  1350.                                     "#BCD631",
  1351.                                     "#D63173",
  1352.                                     "#D7D7D7",
  1353.                                     "#90AFDD",
  1354.                                     "#AF8640",
  1355.                                     "#4F9242",
  1356.                                     "#F4EB24",
  1357.                                     "#ED2024",
  1358.                                     "#45C7F0",
  1359.                                     "#F7BDE2");
  1360. ?>
  1361.  
  1362. <h3>
  1363.   <?php echo $langQuestion.": ".$questionName?>
  1364. </h3>
  1365. <?php
  1366.     if(!empty($msgErr))
  1367.     {
  1368.         Display::display_normal_message($msgErr)//main API
  1369.     }
  1370. ?>
  1371. <table border="0" cellpadding="0" cellspacing="0" width="100%">
  1372.     <tr>
  1373.         <td colspan="2" style="border:1px solid #4271b5; border-bottom:none;"><?php echo stripslashes(get_lang('HotspotChoose'))?></td>
  1374.     </tr>
  1375.     <tr>
  1376.         <td width="550" valign="top">
  1377.             <script type="text/javascript">
  1378.                 <!--
  1379.                 // Version check based upon the values entered above in "Globals"
  1380.                 var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
  1381.  
  1382.  
  1383.                 // Check to see if the version meets the requirements for playback
  1384.                 if (hasReqestedVersion) {  // if we've detected an acceptable version
  1385.                     var oeTags = '<object type="application/x-shockwave-flash" data="../plugin/hotspot/hotspot_admin.swf?modifyAnswers=<?php echo $modifyAnswers ?>" width="550" height="377">'
  1386.                                 + '<param name="movie" value="../plugin/hotspot/hotspot_admin.swf?modifyAnswers=<?php echo $modifyAnswers ?>" />'
  1387.                                 + '<param name="test" value="OOoowww fo shooww" />'
  1388.                                 + '</object>';
  1389.                     document.write(oeTags);   // embed the Flash Content SWF when all tests are passed
  1390.                 } else {  // flash is too old or we can't detect the plugin
  1391.                     var alternateContent = 'Error<br \/>'
  1392.                         + 'This content requires the Macromedia Flash Player.<br \/>'
  1393.                         + '<a href=http://www.macromedia.com/go/getflash/>Get Flash<\/a>';
  1394.                     document.write(alternateContent);  // insert non-flash content
  1395.                 }
  1396.                 // -->
  1397.             </script>
  1398.         </td>
  1399.         <td valign="top">
  1400.             <form method="post" action="<?php echo api_get_self()?>?modifyAnswers=<?php echo $modifyAnswers?>" name="frm_exercise">
  1401.                 <input type="hidden" name="formSent" value="1" />
  1402.                 <input type="hidden" name="nbrAnswers" value="<?php echo $nbrAnswers?>" />
  1403.                 <table border="0" cellpadding="3" cellspacing="0" style="border: 1px solid #4271b5; border-left:none; width: 100%; ">
  1404.                     <!--
  1405.                     <tr>
  1406.                       <td colspan="5"><?php echo get_lang('AnswerHotspot')?> :</td>
  1407.                     </tr>
  1408.                     -->
  1409.                     <tr style="background-color: #E6E6E6; height: 37px">
  1410.                       <td style="width: 20px; border-bottom: 1px solid #4271b5">&nbsp;<?php /* echo get_lang('Hotspot'); */ ?></td>
  1411.                       <td style="width: 100px; border-bottom: 1px solid #4271b5"><?php echo get_lang('Description')?>*</td>
  1412.                       <td style="border-bottom: 1px solid #4271b5"><?php echo get_lang('Comment')?></td>
  1413.                       <td style="width: 60px; border-bottom: 1px solid #4271b5"><?php echo get_lang('QuestionWeighting')?>*</td>
  1414.                     </tr>
  1415.  
  1416.                     <?php
  1417.                                 for($i=1;$i <= $nbrAnswers;$i++)
  1418.                                 {
  1419.                     ?>
  1420.  
  1421.                     <tr>
  1422.                       <td valign="top"><div style="height: 15px; width: 15px; background-color: <?php echo $hotspot_colors[$i]?>"> </div></td>
  1423.                       <td valign="top" align="left"><input type="text" name="reponse[<?php echo $i?>]" value="<?php echo htmlentities($reponse[$i],ENT_QUOTES,$charset)?>" size="12" /></td>
  1424.                       <td align="left"><textarea wrap="virtual" rows="3" cols="10" name="comment[<?php echo $i?>]" style="width: 100%"><?php echo htmlentities($comment[$i],ENT_QUOTES,$charset)?></textarea></td>
  1425.                       <td valign="top"><input type="text" name="weighting[<?php echo $i?>]" size="1" value="<?php echo (isset($weighting[$i]$weighting[$i1)?>" />
  1426.                       <input type="hidden" name="hotspot_coordinates[<?php echo $i?>]" value="<?php echo (empty($hotspot_coordinates[$i]'0;0|0|0' $hotspot_coordinates[$i])?>" />
  1427.                       <input type="hidden" name="hotspot_type[<?php echo $i?>]" value="<?php echo (empty($hotspot_type[$i]'square' $hotspot_type[$i])?>" /></td>
  1428.                     </tr>
  1429.  
  1430.                     <?php
  1431.                                   }
  1432.                     ?>
  1433.  
  1434.                     <tr>
  1435.                       <td colspan="5">
  1436.                         <input type="submit" name="lessAnswers" value="<?php echo get_lang('LessHotspots')?>" />
  1437.                         <input type="submit" name="moreAnswers" value="<?php echo get_lang('MoreHotspots')?>" />
  1438.                         <hr noshade="noshade" size="1" style="color: #4271b5" />
  1439.                         <input type="submit" name="submitAnswers" value="<?php echo get_lang('Ok')?>" />
  1440.                         <input type="submit" name="cancelAnswers" value="<?php echo get_lang('Cancel')?>" onclick="javascript:if(!confirm('<?php echo addslashes(htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset))?>')) return false;" />
  1441.                       </td>
  1442.                     </tr>
  1443.                 </table>
  1444.             </form>
  1445.             <table cellpadding="0" cellspacing="0">
  1446.                 <tr>
  1447.                     <td style="text-align:center; vertical-align:top; width:20px;">*</td>
  1448.                     <td style="width:auto;"><?php echo get_lang('HotspotRequired')?></td>
  1449.                 </tr>
  1450.             </table>
  1451.         </td>
  1452.     </tr>
  1453. </table>
  1454.  
  1455.  
  1456.  
  1457.  
  1458. <?php
  1459.         }
  1460.     }
  1461.     if($debug>0){echo str_repeat('&nbsp;',0).'$modifyAnswers was set - end'."<br />\n";}
  1462. }
  1463. ?>

Documentation generated on Thu, 12 Jun 2008 12:58:59 -0500 by phpDocumentor 1.4.1