answer_admin.inc.php 44 KB

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