exercise_submit_modal.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  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 = self.parent.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. 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. // if pass
  268. //if ($final_overlap>=$threadhold1 && $final_missing<=$threadhold2 && $final_excess<=$threadhold3) {
  269. if ($final_overlap >= $threadhold1 && $final_missing <= $threadhold3 && $final_excess <= $threadhold2) {
  270. $next = 1; //go to the oars
  271. $result_comment = get_lang('Acceptable');
  272. } else {
  273. $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
  274. $wrong_results = true;
  275. $result_comment = get_lang('Unacceptable');
  276. $special_comment = $comment = $answerDestination = $objAnswerTmp->selectComment(1);
  277. $answerDestination = $objAnswerTmp->selectDestination(1);
  278. $destination_items = explode('@@', $answerDestination);
  279. $try_hotspot = $destination_items[1];
  280. $lp_hotspot = $destination_items[2];
  281. $select_question_hotspot = $destination_items[3];
  282. $url_hotspot = $destination_items[4];
  283. }
  284. } elseif ($answerId > 1) {
  285. if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') {
  286. if ($dbg_local > 0) {
  287. error_log(__LINE__.' - answerId is of type noerror', 0);
  288. }
  289. //type no error shouldn't be treated
  290. $next = 1;
  291. continue;
  292. }
  293. if ($dbg_local > 0) {
  294. error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR', 0);
  295. }
  296. //check the intersection between the oar and the user
  297. //echo 'user'; print_r($x_user_list); print_r($y_user_list);
  298. //echo 'official';print_r($x_list);print_r($y_list);
  299. //$result = get_intersection_data($x_list,$y_list,$x_user_list,$y_user_list);
  300. //$delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId);
  301. $delineation_cord = $objAnswerTmp->selectHotspotCoordinates($answerId); //getting the oars coordinates
  302. $poly_answer = convert_coordinates($delineation_cord, '|');
  303. $max_coord = poly_get_max(
  304. $poly_user,
  305. $poly_answer
  306. ); //getting max coordinates
  307. $test = false;
  308. // if ($answerId == 2 ){$test = true;} for test oars
  309. if (empty($_GET['hotspot'])) { //no user response
  310. $overlap = false;
  311. } else {
  312. // poly_compile really works tested with gnuplot
  313. $poly_user_compiled = poly_compile(
  314. $poly_user,
  315. $max_coord,
  316. $test
  317. ); //$poly_user is already set when answerid = 1
  318. $poly_answer_compiled = poly_compile(
  319. $poly_answer,
  320. $max_coord,
  321. $test
  322. );
  323. $overlap = poly_touch(
  324. $poly_user_compiled,
  325. $poly_answer_compiled,
  326. $max_coord
  327. );
  328. }
  329. if ($overlap == false) {
  330. //all good, no overlap
  331. $next = 1;
  332. continue;
  333. } else {
  334. if ($dbg_local > 0) {
  335. error_log(
  336. __LINE__.' - Overlap is '.$overlap.': OAR hit',
  337. 0
  338. );
  339. }
  340. $organs_at_risk_hit++;
  341. //show the feedback
  342. $next = 1;
  343. $comment = $answerDestination = $objAnswerTmp->selectComment(
  344. $answerId
  345. );
  346. $answerDestination = $objAnswerTmp->selectDestination(
  347. $answerId
  348. );
  349. $destination_items = explode('@@', $answerDestination);
  350. $try_hotspot = $destination_items[1];
  351. $lp_hotspot = $destination_items[2];
  352. $select_question_hotspot = $destination_items[3];
  353. $url_hotspot = $destination_items[4];
  354. }
  355. }
  356. } else {
  357. // the first delineation feedback
  358. if ($dbg_local > 0) {
  359. error_log(__LINE__.' first', 0);
  360. }
  361. }
  362. }
  363. }
  364. if ($overlap_color) {
  365. $overlap_color = 'green';
  366. } else {
  367. $overlap_color = 'red';
  368. }
  369. if ($missing_color) {
  370. $missing_color = 'green';
  371. } else {
  372. $missing_color = 'red';
  373. }
  374. if ($excess_color) {
  375. $excess_color = 'green';
  376. } else {
  377. $excess_color = 'red';
  378. }
  379. if (!is_numeric($final_overlap)) {
  380. $final_overlap = 0;
  381. }
  382. if (!is_numeric($final_missing)) {
  383. $final_missing = 0;
  384. }
  385. if (!is_numeric($final_excess)) {
  386. $final_excess = 0;
  387. }
  388. if ($final_excess > 100) {
  389. $final_excess = 100;
  390. }
  391. $table_resume = '<table class="data_table">
  392. <tr class="row_odd">
  393. <td></td>
  394. <td ><b>'.get_lang('Requirements').'</b></td>
  395. <td><b>'.get_lang('YourAnswer').'</b></td>
  396. </tr>
  397. <tr class="row_even">
  398. <td><b>'.get_lang('Overlap').'</b></td>
  399. <td>'.get_lang('Min').' '.$threadhold1.'</td>
  400. <td><div style="color:'.$overlap_color.'">'.(($final_overlap < 0) ? 0 : intval($final_overlap)).'</div></td>
  401. </tr>
  402. <tr>
  403. <td><b>'.get_lang('Excess').'</b></td>
  404. <td>'.get_lang('Max').' '.$threadhold2.'</td>
  405. <td><div style="color:'.$excess_color.'">'.(($final_excess < 0) ? 0 : intval($final_excess)).'</div></td>
  406. </tr>
  407. <tr class="row_even">
  408. <td><b>'.get_lang('Missing').'</b></td>
  409. <td>'.get_lang('Max').' '.$threadhold3.'</td>
  410. <td><div style="color:'.$missing_color.'">'.(($final_missing < 0) ? 0 : intval($final_missing)).'</div></td>
  411. </tr>
  412. </table>';
  413. }
  414. Session::write('newquestionList', $newquestionList);
  415. $links = '';
  416. if (isset($choice_value) && $choice_value == -1) {
  417. if ($answerType != HOT_SPOT_DELINEATION) {
  418. $links .= '<a href="#" onclick="self.parent.tb_remove();">'.get_lang('ChooseAnAnswer').'</a><br />';
  419. }
  420. }
  421. $destinationid = null;
  422. if ($answerType != HOT_SPOT_DELINEATION) {
  423. if (!empty($destination)) {
  424. $item_list = explode('@@', $destination);
  425. $try = $item_list[0];
  426. $lp = $item_list[1];
  427. $destinationid = $item_list[2];
  428. $url = $item_list[3];
  429. }
  430. $table_resume = '';
  431. } else {
  432. $try = $try_hotspot;
  433. $lp = $lp_hotspot;
  434. $destinationid = $select_question_hotspot;
  435. $url = $url_hotspot;
  436. if ($organs_at_risk_hit == 0 && $wrong_results == false) {
  437. // no error = no oar and no wrong result for delineation
  438. //show if no error
  439. //echo 'no error';
  440. $comment = $answerComment = $objAnswerTmp->selectComment($nbrAnswers);
  441. $answerDestination = $objAnswerTmp->selectDestination($nbrAnswers);
  442. //we send the error
  443. $destination_items = explode('@@', $answerDestination);
  444. $try = $destination_items[1];
  445. $lp = $destination_items[2];
  446. $destinationid = $destination_items[3];
  447. $url = $destination_items[4];
  448. $exerciseResult[$questionid] = 1;
  449. } else {
  450. $exerciseResult[$questionid] = 0;
  451. }
  452. }
  453. // the link to retry the question
  454. if (isset($try) && $try == 1) {
  455. $num_value_array = array_keys($questionList, $questionid);
  456. $links .= Display:: return_icon(
  457. 'reload.gif',
  458. '',
  459. ['style' => 'padding-left:0px;padding-right:5px;']
  460. ).'<a onclick="SendEx('.$num_value_array[0].');" href="#">'.get_lang('TryAgain').'</a><br /><br />';
  461. }
  462. // the link to theory (a learning path)
  463. if (!empty($lp)) {
  464. $lp_url = api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$lp;
  465. $list = new LearnpathList(api_get_user_id());
  466. $flat_list = $list->get_flat_list();
  467. $links .= Display:: return_icon(
  468. 'theory.gif',
  469. '',
  470. ['style' => 'padding-left:0px;padding-right:5px;']
  471. ).'<a target="_blank" href="'.$lp_url.'">'.get_lang('SeeTheory').'</a><br />';
  472. }
  473. $links .= '<br />';
  474. // the link to an external website or link
  475. if (!empty($url)) {
  476. $links .= Display:: return_icon(
  477. 'link.gif',
  478. '',
  479. ['style' => 'padding-left:0px;padding-right:5px;']
  480. ).'<a target="_blank" href="'.$url.'">'.get_lang('VisitUrl').'</a><br /><br />';
  481. }
  482. // the link to finish the test
  483. if ($destinationid == -1) {
  484. $links .= Display:: return_icon(
  485. 'finish.gif',
  486. '',
  487. ['style' => 'width:22px; height:22px; padding-left:0px;padding-right:5px;']
  488. ).'<a onclick="SendEx(-1);" href="#">'.get_lang('EndActivity').'</a><br /><br />';
  489. } else {
  490. // the link to other question
  491. if (in_array($destinationid, $questionList)) {
  492. $objQuestionTmp = Question :: read($destinationid);
  493. $questionName = $objQuestionTmp->selectTitle();
  494. $num_value_array = (array_keys($questionList, $destinationid));
  495. $links .= Display:: return_icon(
  496. 'quiz.png',
  497. '',
  498. ['style' => 'padding-left:0px;padding-right:5px;']
  499. );
  500. $links .= '<a onclick="SendEx('.$num_value_array[0].');" href="#">'.
  501. get_lang('GoToQuestion').' '.$num_value_array[0].'</a><br /><br />';
  502. }
  503. }
  504. echo '<script>
  505. function SendEx(num) {
  506. if (num == -1) {
  507. self.parent.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.'";
  508. self.parent.tb_remove();
  509. } else {
  510. num -= 1;
  511. self.parent.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.'";
  512. self.parent.tb_remove();
  513. }
  514. }
  515. </script>';
  516. if ($links != '') {
  517. echo '<h1><div style="color:#333;">'.get_lang('Feedback').'</div></h1>';
  518. if ($answerType == HOT_SPOT_DELINEATION) {
  519. if ($organs_at_risk_hit > 0) {
  520. //$message='<p>'.get_lang('YourDelineation').'</p>';
  521. //$message.=$table_resume;
  522. $message .= '<br />'.get_lang('ResultIs').' <b>'.get_lang('Unacceptable').'</b><br />';
  523. //if ($wrong_results) { }
  524. $message .= '<p style="color:#DC0A0A;"><b>'.get_lang('OARHit').'</b></p>';
  525. $message .= '<p>'.$comment.'</p>';
  526. } else {
  527. $message = '<p>'.get_lang('YourDelineation').'</p>';
  528. $message .= $table_resume;
  529. $message .= '<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />';
  530. $message .= '<p>'.$comment.'</p>';
  531. }
  532. echo $message;
  533. } else {
  534. echo '<p>'.$comment.'</p>';
  535. }
  536. echo '<h3>'.$links.'</h3>';
  537. echo '</div>';
  538. Session::write('hot_spot_result', $message);
  539. $_SESSION['hotspot_delineation_result'][$exerciseId][$questionid] = [$message, $exerciseResult[$questionid]];
  540. //reseting the exerciseResult variable
  541. Session::write('exerciseResult', $exerciseResult);
  542. //save this variables just in case the exercise loads an LP with other exercise
  543. $_SESSION['objExerciseExtra'.$exerciseId] = $_SESSION['objExercise'];
  544. $_SESSION['exerciseResultExtra'.$exerciseId] = $_SESSION['exerciseResult'];
  545. $_SESSION['questionListExtra'.$exerciseId] = $_SESSION['questionList'];
  546. } else {
  547. $questionNum++;
  548. echo '<script>
  549. self.parent.window.location.href = "exercise_submit.php?exerciseId='.$exerciseId.'&num='.$questionNum.'&exerciseType='.$exerciseType.'&'.api_get_cidreq().'";
  550. //self.parent.tb_remove();
  551. </script>';
  552. }
  553. echo '</div>';
  554. Display::display_footer();