answer_admin.inc.php 44 KB

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