answer_admin.inc.php 43 KB

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