answer_admin.inc.php 43 KB

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