exercise_submit_modal.php 23 KB

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