answer_admin.inc.php 43 KB

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