exercise_submit_modal.php 24 KB

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