answer_admin.inc.php 53 KB

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