answer_admin.inc.php 43 KB

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