answer_admin.inc.php 44 KB

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