exercise_submit_modal.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use ChamiloSession as Session;
  4. /**
  5. * @package chamilo.exercise
  6. *
  7. * @author Julio Montoya <gugli100@gmail.com>
  8. */
  9. require_once __DIR__.'/../inc/global.inc.php';
  10. api_protect_course_script(false);
  11. require_once api_get_path(LIBRARY_PATH).'geometry.lib.php';
  12. //Display::display_reduced_header();
  13. echo '<div id="delineation-container">';
  14. $message = null;
  15. $dbg_local = 0;
  16. $gradebook = null;
  17. $final_overlap = null;
  18. $final_missing = null;
  19. $final_excess = null;
  20. $threadhold1 = null;
  21. $threadhold2 = null;
  22. $threadhold3 = null;
  23. $exerciseResult = Session::read('exerciseResult');
  24. $exerciseResultCoordinates = isset($_REQUEST['exerciseResultCoordinates']) ? $_REQUEST['exerciseResultCoordinates'] : null;
  25. $origin = api_get_origin();
  26. // if origin is learnpath
  27. $learnpath_id = 0;
  28. if (isset($_REQUEST['learnpath_id'])) {
  29. $learnpath_id = intval($_REQUEST['learnpath_id']);
  30. }
  31. $learnpath_item_id = 0;
  32. if (isset($_REQUEST['learnpath_item_id'])) {
  33. $learnpath_item_id = intval($_REQUEST['learnpath_item_id']);
  34. }
  35. $_SESSION['hotspot_coord'] = [];
  36. $newquestionList = Session::read('newquestionList', []);
  37. $questionList = Session::read('questionList');
  38. $exerciseId = intval($_GET['exerciseId']);
  39. $exerciseType = intval($_GET['exerciseType']);
  40. $questionNum = intval($_GET['num']);
  41. $nbrQuestions = isset($_GET['nbrQuestions']) ? intval($_GET['nbrQuestions']) : null;
  42. //clean extra session variables
  43. Session::erase('objExerciseExtra'.$exerciseId);
  44. Session::erase('exerciseResultExtra'.$exerciseId);
  45. Session::erase('questionListExtra'.$exerciseId);
  46. // Round-up the coordinates
  47. $user_array = '';
  48. if (isset($_GET['hotspot'])) {
  49. $coords = explode('/', $_GET['hotspot']);
  50. if (is_array($coords) && count($coords) > 0) {
  51. foreach ($coords as $coord) {
  52. if (!empty($coord)) {
  53. list($x, $y) = explode(';', $coord);
  54. $user_array .= round($x).';'.round($y).'/';
  55. }
  56. }
  57. }
  58. }
  59. $choice_value = '';
  60. $user_array = substr($user_array, 0, -1);
  61. if (isset($_GET['choice'])) {
  62. $choice_value = intval($_GET['choice']);
  63. }
  64. // Getting the options by js
  65. if (empty($choice_value)) {
  66. echo "<script>
  67. // this works for only radio buttons
  68. var f = window.document.frm_exercise;
  69. var choice_js='';
  70. var hotspot = new Array();
  71. var hotspotcoord = new Array();
  72. var counter=0;
  73. for ( var i = 0; i < f.elements.length; i++ ) {
  74. if (f.elements[i].type=='radio' && f.elements[i].checked) {
  75. choice_js = f.elements[i].value;
  76. counter ++;
  77. }
  78. if (f.elements[i].type=='hidden' ) {
  79. var name = f.elements[i].name;
  80. if (name.substr(0,7)=='hotspot')
  81. hotspot.push(f.elements[i].value);
  82. if (name.substr(0,20)=='hotspot_coordinates')
  83. hotspotcoord.push(f.elements[i].value);
  84. }
  85. }
  86. if (counter==0) {
  87. choice_js=-1; // this is an error
  88. }
  89. ";
  90. // IMPORTANT
  91. //this is the real redirect function
  92. //echo 'window.location.href = "exercise_submit_modal.php?learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id.'&hotspotcoord="+ hotspotcoord + "&hotspot="+ hotspot + "&choice="+ choice_js + "&exerciseId='.$exerciseId.'&num='.$questionNum.'&exerciseType='.$exerciseType.'&origin='.$origin.'&gradebook='.$gradebook.'";';
  93. echo ' url = "exercise_submit_modal.php?learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id.'&hotspotcoord="+ hotspotcoord + "&hotspot="+ hotspot + "&choice="+ choice_js + "&exerciseId='.$exerciseId.'&num='.$questionNum.'&exerciseType='.$exerciseType.'&'.api_get_cidreq().'&gradebook='.$gradebook.'";';
  94. echo "$('#global-modal .modal-body').load(url);";
  95. echo '</script>';
  96. exit;
  97. }
  98. $choice = [];
  99. $questionid = $questionList[$questionNum];
  100. // $choice_value => value of the user selection
  101. $choice[$questionid] = isset($choice_value) ? $choice_value : null;
  102. // initializing
  103. if (!is_array($exerciseResult)) {
  104. $exerciseResult = [];
  105. }
  106. // if the user has answered at least one question
  107. if (is_array($choice)) {
  108. if ($exerciseType == EXERCISE_FEEDBACK_TYPE_DIRECT) {
  109. // $exerciseResult receives the content of the form.
  110. // Each choice of the student is stored into the array $choice
  111. $exerciseResult = $choice;
  112. } else {
  113. // gets the question ID from $choice. It is the key of the array
  114. list($key) = array_keys($choice);
  115. // if the user didn't already answer this question
  116. if (!isset($exerciseResult[$key])) {
  117. // stores the user answer into the array
  118. $exerciseResult[$key] = $choice[$key];
  119. }
  120. }
  121. }
  122. // the script "exercise_result.php" will take the variable $exerciseResult from the session
  123. Session::write('exerciseResult', $exerciseResult);
  124. Session::write('exerciseResultCoordinates', $exerciseResultCoordinates);
  125. // creates a temporary Question object
  126. if (in_array($questionid, $questionList)) {
  127. $objQuestionTmp = Question:: read($questionid);
  128. $questionName = $objQuestionTmp->selectTitle();
  129. $questionDescription = $objQuestionTmp->selectDescription();
  130. $questionWeighting = $objQuestionTmp->selectWeighting();
  131. $answerType = $objQuestionTmp->selectType();
  132. $quesId = $objQuestionTmp->selectId(); //added by priya saini
  133. }
  134. $objAnswerTmp = new Answer($questionid);
  135. $nbrAnswers = $objAnswerTmp->selectNbrAnswers();
  136. $choice = $exerciseResult[$questionid];
  137. $destination = [];
  138. $comment = '';
  139. $next = 1;
  140. $_SESSION['hotspot_coord'] = [];
  141. $_SESSION['hotspot_dest'] = [];
  142. $overlap_color = $missing_color = $excess_color = false;
  143. $organs_at_risk_hit = 0;
  144. $wrong_results = false;
  145. $hot_spot_load = false;
  146. $questionScore = 0;
  147. $totalScore = 0;
  148. if (!empty($choice_value)) {
  149. for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
  150. $answer = $objAnswerTmp->selectAnswer($answerId);
  151. $answerComment = $objAnswerTmp->selectComment($answerId);
  152. $answerDestination = $objAnswerTmp->selectDestination($answerId);
  153. $answerCorrect = $objAnswerTmp->isCorrect($answerId);
  154. $answerWeighting = $objAnswerTmp->selectWeighting($answerId);
  155. $numAnswer = $objAnswerTmp->selectAutoId($answerId);
  156. //delineation
  157. $delineation_cord = $objAnswerTmp->selectHotspotCoordinates(1);
  158. $answer_delineation_destination = $objAnswerTmp->selectDestination(1);
  159. if ($dbg_local > 0) {
  160. error_log(__LINE__.' answerId: '.$answerId.'('.$answerType.') - user delineation_cord: '.$delineation_cord.' - $answer_delineation_destination: '.$answer_delineation_destination, 0);
  161. }
  162. switch ($answerType) {
  163. // for unique answer
  164. case UNIQUE_ANSWER:
  165. $studentChoice = ($choice_value == $numAnswer) ? 1 : 0;
  166. if ($studentChoice) {
  167. $questionScore += $answerWeighting;
  168. $totalScore += $answerWeighting;
  169. $newquestionList[] = $questionid;
  170. }
  171. break;
  172. case HOT_SPOT_DELINEATION:
  173. $studentChoice = $choice[$answerId];
  174. if ($studentChoice) {
  175. $newquestionList[] = $questionid;
  176. }
  177. if ($answerId === 1) {
  178. $questionScore += $answerWeighting;
  179. $totalScore += $answerWeighting;
  180. $_SESSION['hotspot_coord'][1] = $delineation_cord;
  181. $_SESSION['hotspot_dest'][1] = $answer_delineation_destination;
  182. }
  183. break;
  184. }
  185. if ($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER) {
  186. if ($studentChoice) {
  187. $destination = $answerDestination;
  188. $comment = $answerComment;
  189. }
  190. } elseif ($answerType == HOT_SPOT_DELINEATION) {
  191. if ($next) {
  192. if ($dbg_local > 0) {
  193. error_log(__LINE__.' - next', 0);
  194. }
  195. $hot_spot_load = true; //apparently the script is called twice
  196. $user_answer = $user_array;
  197. $_SESSION['exerciseResultCoordinates'][$questionid] = $user_answer; //needed for exercise_result.php
  198. // we compare only the delineation not the other points
  199. $answer_question = $_SESSION['hotspot_coord'][1];
  200. $answerDestination = $_SESSION['hotspot_dest'][1];
  201. $poly_user = convert_coordinates($user_answer, '/');
  202. $poly_answer = convert_coordinates($answer_question, '|');
  203. $max_coord = poly_get_max($poly_user, $poly_answer);
  204. if (empty($_GET['hotspot'])) { //no user response
  205. $overlap = -2;
  206. } else {
  207. $poly_user_compiled = poly_compile($poly_user, $max_coord);
  208. $poly_answer_compiled = poly_compile(
  209. $poly_answer,
  210. $max_coord
  211. );
  212. $poly_results = poly_result(
  213. $poly_answer_compiled,
  214. $poly_user_compiled,
  215. $max_coord
  216. );
  217. $overlap = $poly_results['both'];
  218. $poly_answer_area = $poly_results['s1'];
  219. $poly_user_area = $poly_results['s2'];
  220. $missing = $poly_results['s1Only'];
  221. $excess = $poly_results['s2Only'];
  222. }
  223. //$overlap = round(polygons_overlap($poly_answer,$poly_user)); //this is an area in pixels
  224. if ($dbg_local > 0) {
  225. error_log(__LINE__.' - Polygons results are '.print_r($poly_results, 1), 0);
  226. }
  227. if ($overlap < 1) {
  228. //shortcut to avoid complicated calculations
  229. $final_overlap = 0;
  230. $final_missing = 100;
  231. $final_excess = 100;
  232. } else {
  233. // the final overlap is the percentage of the initial polygon that is overlapped by the user's polygon
  234. $final_overlap = round(((float) $overlap / (float) $poly_answer_area) * 100);
  235. if ($dbg_local > 1) {
  236. error_log(__LINE__.' - Final overlap is '.$final_overlap, 0);
  237. }
  238. // the final missing area is the percentage of the initial polygon that is not overlapped by the user's polygon
  239. $final_missing = 100 - $final_overlap;
  240. if ($dbg_local > 1) {
  241. error_log(__LINE__.' - Final missing is '.$final_missing, 0);
  242. }
  243. // the final excess area is the percentage of the initial polygon's size that is covered by the user's polygon outside of the initial polygon
  244. $final_excess = round((((float) $poly_user_area - (float) $overlap) / (float) $poly_answer_area) * 100);
  245. if ($dbg_local > 1) {
  246. error_log(__LINE__.' - Final excess is '.$final_excess, 0);
  247. }
  248. }
  249. $destination_items = explode('@@', $answerDestination);
  250. $threadhold_total = $destination_items[0];
  251. $threadhold_items = explode(';', $threadhold_total);
  252. $threadhold1 = $threadhold_items[0]; // overlap
  253. $threadhold2 = $threadhold_items[1]; // excess
  254. $threadhold3 = $threadhold_items[2]; //missing
  255. // if is delineation
  256. if ($answerId === 1) {
  257. //setting colors
  258. if ($final_overlap >= $threadhold1) {
  259. $overlap_color = true; //echo 'a';
  260. }
  261. if ($final_excess <= $threadhold2) {
  262. $excess_color = true; //echo 'b';
  263. }
  264. if ($final_missing <= $threadhold3) {
  265. $missing_color = true; //echo 'c';
  266. }
  267. $try_hotspot = null;
  268. $lp_hotspot = null;
  269. $url_hotspot = null;
  270. $select_question_hotspot = null;
  271. // if pass
  272. //if ($final_overlap>=$threadhold1 && $final_missing<=$threadhold2 && $final_excess<=$threadhold3) {
  273. if ($final_overlap >= $threadhold1 && $final_missing <= $threadhold3 && $final_excess <= $threadhold2) {
  274. $next = 1; //go to the oars
  275. $result_comment = get_lang('Acceptable');
  276. } else {
  277. $next = 1; //Go to the oars. If $next = 0 we will show this message: "One (or more) area at risk has been hit" instead of the table resume with the results
  278. $wrong_results = true;
  279. $result_comment = get_lang('Unacceptable');
  280. }
  281. $special_comment = $comment = $answerDestination = $objAnswerTmp->selectComment(1);
  282. $answerDestination = $objAnswerTmp->selectDestination(1);
  283. $destination_items = explode('@@', $answerDestination);
  284. $try_hotspot = $destination_items[1];
  285. $lp_hotspot = $destination_items[2];
  286. $select_question_hotspot = $destination_items[3];
  287. $url_hotspot = $destination_items[4];
  288. } elseif ($answerId > 1) {
  289. if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') {
  290. if ($dbg_local > 0) {
  291. error_log(__LINE__.' - answerId is of type noerror', 0);
  292. }
  293. //type no error shouldn't be treated
  294. $next = 1;
  295. continue;
  296. }
  297. if ($dbg_local > 0) {
  298. error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR', 0);
  299. }
  300. //check the intersection between the oar and the user
  301. //echo 'user'; print_r($x_user_list); print_r($y_user_list);
  302. //echo 'official';print_r($x_list);print_r($y_list);
  303. //$result = get_intersection_data($x_list,$y_list,$x_user_list,$y_user_list);
  304. //$delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId);
  305. $delineation_cord = $objAnswerTmp->selectHotspotCoordinates($answerId); //getting the oars coordinates
  306. $poly_answer = convert_coordinates($delineation_cord, '|');
  307. $max_coord = poly_get_max(
  308. $poly_user,
  309. $poly_answer
  310. ); //getting max coordinates
  311. $test = false;
  312. // if ($answerId == 2 ){$test = true;} for test oars
  313. if (empty($_GET['hotspot'])) { //no user response
  314. $overlap = false;
  315. } else {
  316. // poly_compile really works tested with gnuplot
  317. $poly_user_compiled = poly_compile(
  318. $poly_user,
  319. $max_coord,
  320. $test
  321. ); //$poly_user is already set when answerid = 1
  322. $poly_answer_compiled = poly_compile(
  323. $poly_answer,
  324. $max_coord,
  325. $test
  326. );
  327. $overlap = poly_touch(
  328. $poly_user_compiled,
  329. $poly_answer_compiled,
  330. $max_coord
  331. );
  332. }
  333. if ($overlap == false) {
  334. //all good, no overlap
  335. $next = 1;
  336. continue;
  337. } else {
  338. if ($dbg_local > 0) {
  339. error_log(
  340. __LINE__.' - Overlap is '.$overlap.': OAR hit',
  341. 0
  342. );
  343. }
  344. $organs_at_risk_hit++;
  345. //show the feedback
  346. $next = 1;
  347. $comment = $answerDestination = $objAnswerTmp->selectComment(
  348. $answerId
  349. );
  350. $answerDestination = $objAnswerTmp->selectDestination(
  351. $answerId
  352. );
  353. $destination_items = explode('@@', $answerDestination);
  354. $try_hotspot = $destination_items[1];
  355. $lp_hotspot = $destination_items[2];
  356. $select_question_hotspot = $destination_items[3];
  357. $url_hotspot = $destination_items[4];
  358. }
  359. }
  360. } else {
  361. // the first delineation feedback
  362. if ($dbg_local > 0) {
  363. error_log(__LINE__.' first', 0);
  364. }
  365. }
  366. }
  367. }
  368. if ($overlap_color) {
  369. $overlap_color = 'green';
  370. } else {
  371. $overlap_color = 'red';
  372. }
  373. if ($missing_color) {
  374. $missing_color = 'green';
  375. } else {
  376. $missing_color = 'red';
  377. }
  378. if ($excess_color) {
  379. $excess_color = 'green';
  380. } else {
  381. $excess_color = 'red';
  382. }
  383. if (!is_numeric($final_overlap)) {
  384. $final_overlap = 0;
  385. }
  386. if (!is_numeric($final_missing)) {
  387. $final_missing = 0;
  388. }
  389. if (!is_numeric($final_excess)) {
  390. $final_excess = 0;
  391. }
  392. if ($final_excess > 100) {
  393. $final_excess = 100;
  394. }
  395. $table_resume = '<table class="data_table">
  396. <tr class="row_odd">
  397. <td></td>
  398. <td ><b>'.get_lang('Requirements').'</b></td>
  399. <td><b>'.get_lang('YourAnswer').'</b></td>
  400. </tr>
  401. <tr class="row_even">
  402. <td><b>'.get_lang('Overlap').'</b></td>
  403. <td>'.get_lang('Min').' '.$threadhold1.'</td>
  404. <td><div style="color:'.$overlap_color.'">'.(($final_overlap < 0) ? 0 : intval($final_overlap)).'</div></td>
  405. </tr>
  406. <tr>
  407. <td><b>'.get_lang('Excess').'</b></td>
  408. <td>'.get_lang('Max').' '.$threadhold2.'</td>
  409. <td><div style="color:'.$excess_color.'">'.(($final_excess < 0) ? 0 : intval($final_excess)).'</div></td>
  410. </tr>
  411. <tr class="row_even">
  412. <td><b>'.get_lang('Missing').'</b></td>
  413. <td>'.get_lang('Max').' '.$threadhold3.'</td>
  414. <td><div style="color:'.$missing_color.'">'.(($final_missing < 0) ? 0 : intval($final_missing)).'</div></td>
  415. </tr>
  416. </table>';
  417. }
  418. Session::write('newquestionList', $newquestionList);
  419. $links = '';
  420. if (isset($choice_value) && $choice_value == -1) {
  421. if ($answerType != HOT_SPOT_DELINEATION) {
  422. $links .= '<a href="#" onclick="tb_remove();">'.get_lang('ChooseAnAnswer').'</a><br />';
  423. }
  424. }
  425. $destinationid = null;
  426. if ($answerType != HOT_SPOT_DELINEATION) {
  427. if (!empty($destination)) {
  428. $item_list = explode('@@', $destination);
  429. $try = $item_list[0];
  430. $lp = $item_list[1];
  431. $destinationid = $item_list[2];
  432. $url = $item_list[3];
  433. }
  434. $table_resume = '';
  435. } else {
  436. $try = $try_hotspot;
  437. $lp = $lp_hotspot;
  438. $destinationid = $select_question_hotspot;
  439. $url = $url_hotspot;
  440. if ($organs_at_risk_hit == 0 && $wrong_results == false) {
  441. // no error = no oar and no wrong result for delineation
  442. //show if no error
  443. //echo 'no error';
  444. $comment = $answerComment = $objAnswerTmp->selectComment($nbrAnswers);
  445. $answerDestination = $objAnswerTmp->selectDestination($nbrAnswers);
  446. //we send the error
  447. $destination_items = explode('@@', $answerDestination);
  448. $try = $destination_items[1];
  449. $lp = $destination_items[2];
  450. $destinationid = $destination_items[3];
  451. $url = $destination_items[4];
  452. $exerciseResult[$questionid] = 1;
  453. } else {
  454. $exerciseResult[$questionid] = 0;
  455. }
  456. }
  457. // the link to retry the question
  458. if (isset($try) && $try == 1) {
  459. $num_value_array = array_keys($questionList, $questionid);
  460. $links .= Display:: return_icon(
  461. 'reload.gif',
  462. '',
  463. ['style' => 'padding-left:0px;padding-right:5px;']
  464. ).'<a onclick="SendEx('.$num_value_array[0].');" href="#">'.get_lang('TryAgain').'</a><br /><br />';
  465. }
  466. // the link to theory (a learning path)
  467. if (!empty($lp)) {
  468. $lp_url = api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$lp;
  469. $list = new LearnpathList(api_get_user_id());
  470. $flat_list = $list->get_flat_list();
  471. $links .= Display:: return_icon(
  472. 'theory.gif',
  473. '',
  474. ['style' => 'padding-left:0px;padding-right:5px;']
  475. ).'<a target="_blank" href="'.$lp_url.'">'.get_lang('SeeTheory').'</a><br />';
  476. }
  477. $links .= '<br />';
  478. // the link to an external website or link
  479. if (!empty($url)) {
  480. $links .= Display:: return_icon(
  481. 'link.gif',
  482. '',
  483. ['style' => 'padding-left:0px;padding-right:5px;']
  484. ).'<a target="_blank" href="'.$url.'">'.get_lang('VisitUrl').'</a><br /><br />';
  485. }
  486. // the link to finish the test
  487. if ($destinationid == -1) {
  488. $links .= Display:: return_icon(
  489. 'finish.gif',
  490. '',
  491. ['style' => 'width:22px; height:22px; padding-left:0px;padding-right:5px;']
  492. ).'<a onclick="SendEx(-1);" href="#">'.get_lang('EndActivity').'</a><br /><br />';
  493. } else {
  494. // the link to other question
  495. if (in_array($destinationid, $questionList)) {
  496. $objQuestionTmp = Question :: read($destinationid);
  497. $questionName = $objQuestionTmp->selectTitle();
  498. $num_value_array = (array_keys($questionList, $destinationid));
  499. $links .= Display:: return_icon(
  500. 'quiz.png',
  501. '',
  502. ['style' => 'padding-left:0px;padding-right:5px;']
  503. );
  504. $links .= '<a onclick="SendEx('.$num_value_array[0].');" href="#">'.
  505. get_lang('GoToQuestion').' '.$num_value_array[0].'</a><br /><br />';
  506. }
  507. }
  508. echo '<script>
  509. function SendEx(num) {
  510. if (num == -1) {
  511. window.location.href = "exercise_result.php?take_session=1&exerciseId='.$exerciseId.'&num="+num+"&exerciseType='.$exerciseType.'&origin='.$origin.'&learnpath_item_id='.$learnpath_item_id.'&learnpath_id='.$learnpath_id.'";
  512. //tb_remove();
  513. } else {
  514. num -= 1;
  515. window.location.href = "exercise_submit.php?tryagain=1&exerciseId='.$exerciseId.'&num="+num+"&exerciseType='.$exerciseType.'&origin='.$origin.'&learnpath_item_id='.$learnpath_item_id.'&learnpath_id='.$learnpath_id.'";
  516. //tb_remove();
  517. }
  518. return false;
  519. }
  520. </script>';
  521. if ($links != '') {
  522. echo '<h1><div style="color:#333;">'.get_lang('Feedback').'</div></h1>';
  523. if ($answerType == HOT_SPOT_DELINEATION) {
  524. if ($organs_at_risk_hit > 0) {
  525. //$message='<p>'.get_lang('YourDelineation').'</p>';
  526. //$message.=$table_resume;
  527. $message .= '<br />'.get_lang('ResultIs').' <b>'.get_lang('Unacceptable').'</b><br />';
  528. //if ($wrong_results) { }
  529. $message .= '<p style="color:#DC0A0A;"><b>'.get_lang('OARHit').'</b></p>';
  530. $message .= '<p>'.$comment.'</p>';
  531. } else {
  532. $message = '<p>'.get_lang('YourDelineation').'</p>';
  533. $message .= $table_resume;
  534. $message .= '<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />';
  535. $message .= '<p>'.$comment.'</p>';
  536. }
  537. echo $message;
  538. } else {
  539. echo '<p>'.$comment.'</p>';
  540. }
  541. echo '<h3>'.$links.'</h3>';
  542. echo '</div>';
  543. Session::write('hot_spot_result', $message);
  544. $_SESSION['hotspot_delineation_result'][$exerciseId][$questionid] = [$message, $exerciseResult[$questionid]];
  545. //reseting the exerciseResult variable
  546. Session::write('exerciseResult', $exerciseResult);
  547. //save this variables just in case the exercise loads an LP with other exercise
  548. $_SESSION['objExerciseExtra'.$exerciseId] = $_SESSION['objExercise'];
  549. $_SESSION['exerciseResultExtra'.$exerciseId] = $_SESSION['exerciseResult'];
  550. $_SESSION['questionListExtra'.$exerciseId] = $_SESSION['questionList'];
  551. } else {
  552. $questionNum++;
  553. echo '<script>
  554. window.location.href = "exercise_submit.php?exerciseId='.$exerciseId.'&num='.$questionNum.'&exerciseType='.$exerciseType.'&'.api_get_cidreq().'";
  555. //tb_remove();
  556. </script>';
  557. }
  558. echo '</div>';
  559. //Display::display_footer();