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. * @author Julio Montoya <gugli100@gmail.com>
  7. */
  8. //require_once '../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 = [];
  23. if (Session::has('exerciseResult')) {
  24. $exerciseResult = Session::read('exerciseResult');
  25. }
  26. $exerciseResultCoordinates = isset($_REQUEST['exerciseResultCoordinates']) ? $_REQUEST['exerciseResultCoordinates'] : null;
  27. if (empty($origin)) {
  28. $origin = Security::remove_XSS($_REQUEST['origin']);
  29. }
  30. // if origin is learnpath
  31. $learnpath_id = 0;
  32. if (isset($_REQUEST['learnpath_id'])) {
  33. $learnpath_id = intval($_REQUEST['learnpath_id']);
  34. }
  35. $learnpath_item_id = 0;
  36. if (isset($_REQUEST['learnpath_item_id'])) {
  37. $learnpath_item_id = intval($_REQUEST['learnpath_item_id']);
  38. }
  39. $_SESSION['hotspot_coord']=array();
  40. $newquestionList= isset($_SESSION['newquestionList']) ? $_SESSION['newquestionList'] : [];
  41. $questionList = $_SESSION['questionList'];
  42. $exerciseId = intval($_GET['exerciseId']);
  43. $exerciseType = intval($_GET['exerciseType']);
  44. $questionNum = intval($_GET['num']);
  45. $nbrQuestions = isset($_GET['nbrQuestions']) ? intval($_GET['nbrQuestions']) : null;
  46. //clean extra session variables
  47. Session::erase('objExerciseExtra'.$exerciseId);
  48. Session::erase('exerciseResultExtra'.$exerciseId);
  49. Session::erase('questionListExtra'.$exerciseId);
  50. //round-up the coordinates
  51. $user_array = '';
  52. if (isset($_GET['hotspot'])) {
  53. $coords = explode('/', $_GET['hotspot']);
  54. if (is_array($coords) && count($coords) > 0) {
  55. foreach ($coords as $coord) {
  56. if (!empty($coord)) {
  57. list($x, $y) = explode(';', $coord);
  58. $user_array .= round($x).';'.round($y).'/';
  59. }
  60. }
  61. }
  62. }
  63. $choice_value = '';
  64. $user_array = substr($user_array,0,-1);
  65. if (isset($_GET['choice'])){
  66. $choice_value = intval($_GET['choice']);
  67. }
  68. // Getting the options by js
  69. if (empty($choice_value)) {
  70. echo "<script>
  71. // this works for only radio buttons
  72. var f = self.parent.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. 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.'&origin='.$origin.'&gradebook='.$gradebook.'";';
  98. echo "$('#global-modal .modal-body').load(url);";
  99. echo '</script>';
  100. exit;
  101. }
  102. $choice = array();
  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 = array();
  109. }
  110. // if the user has answered at least one question
  111. if (is_array($choice)) {
  112. if ($exerciseType == EXERCISE_FEEDBACK_TYPE_DIRECT) {
  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. /*
  130. // if it is the last question (only for a sequential exercise)
  131. if($questionNum >= $nbrQuestions)
  132. {
  133. if($debug>0){echo str_repeat('&nbsp;',0).'Redirecting to exercise_result.php - Remove debug option to let this happen'."<br />\n";}
  134. // goes to the script that will show the result of the exercise
  135. // header("Location: exercise_result.php?origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id");
  136. // echo 'location result';
  137. }*/
  138. // gets the student choice for this question
  139. //print_r($choice); echo "<br>";
  140. // creates a temporary Question object
  141. if (in_array($questionid, $questionList)) {
  142. $objQuestionTmp = Question :: read($questionid);
  143. $questionName =$objQuestionTmp->selectTitle();
  144. $questionDescription=$objQuestionTmp->selectDescription();
  145. $questionWeighting =$objQuestionTmp->selectWeighting();
  146. $answerType =$objQuestionTmp->selectType();
  147. $quesId =$objQuestionTmp->selectId(); //added by priya saini
  148. }
  149. $objAnswerTmp=new Answer($questionid);
  150. $nbrAnswers=$objAnswerTmp->selectNbrAnswers();
  151. //echo 'answe_type '.$answerType;echo '<br />';
  152. $choice = $exerciseResult[$questionid];
  153. $destination=array();
  154. $comment='';
  155. $next=1;
  156. $_SESSION['hotspot_coord'] = array();
  157. $_SESSION['hotspot_dest'] = array();
  158. $overlap_color = $missing_color = $excess_color=false;
  159. $organs_at_risk_hit = 0;
  160. $wrong_results = false;
  161. $hot_spot_load = false;
  162. $questionScore = 0;
  163. $totalScore = 0;
  164. if (!empty($choice_value)) {
  165. for ($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
  166. $answer = $objAnswerTmp->selectAnswer($answerId);
  167. $answerComment = $objAnswerTmp->selectComment($answerId);
  168. $answerDestination = $objAnswerTmp->selectDestination($answerId);
  169. $answerCorrect = $objAnswerTmp->isCorrect($answerId);
  170. $answerWeighting = $objAnswerTmp->selectWeighting($answerId);
  171. $numAnswer = $objAnswerTmp->selectAutoId($answerId);
  172. //delineation
  173. $delineation_cord = $objAnswerTmp->selectHotspotCoordinates(1);
  174. $answer_delineation_destination=$objAnswerTmp->selectDestination(1);
  175. if ($dbg_local>0) { error_log(__LINE__.' answerId: '.$answerId.'('.$answerType.') - user delineation_cord: '.$delineation_cord.' - $answer_delineation_destination: '.$answer_delineation_destination,0);}
  176. switch($answerType) {
  177. // for unique answer
  178. case UNIQUE_ANSWER :
  179. $studentChoice = ($choice_value == $numAnswer)?1:0;
  180. if ($studentChoice) {
  181. $questionScore +=$answerWeighting;
  182. $totalScore +=$answerWeighting;
  183. $newquestionList[]=$questionid;
  184. }
  185. break;
  186. case HOT_SPOT_DELINEATION :
  187. $studentChoice=$choice[$answerId];
  188. if ($studentChoice) {
  189. $newquestionList[]=$questionid;
  190. }
  191. if ($answerId===1) {
  192. $questionScore +=$answerWeighting;
  193. $totalScore +=$answerWeighting;
  194. $_SESSION['hotspot_coord'][1] =$delineation_cord;
  195. $_SESSION['hotspot_dest'][1] =$answer_delineation_destination;
  196. }
  197. break;
  198. }
  199. if ($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER) {
  200. //display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect);
  201. if ($studentChoice) {
  202. $destination = $answerDestination;
  203. $comment = $answerComment;
  204. }
  205. } elseif($answerType == HOT_SPOT_DELINEATION) {
  206. if ($next) {
  207. if ($dbg_local>0) { error_log(__LINE__.' - next',0);}
  208. $hot_spot_load = true; //apparently the script is called twice
  209. $user_answer = $user_array;
  210. $_SESSION['exerciseResultCoordinates'][$questionid]=$user_answer; //needed for exercise_result.php
  211. // we compare only the delineation not the other points
  212. $answer_question = $_SESSION['hotspot_coord'][1];
  213. $answerDestination = $_SESSION['hotspot_dest'][1];
  214. $poly_user = convert_coordinates($user_answer,'/');
  215. $poly_answer = convert_coordinates($answer_question,'|');
  216. $max_coord = poly_get_max($poly_user,$poly_answer);
  217. if (empty($_GET['hotspot'])) { //no user response
  218. $overlap = -2;
  219. } else {
  220. $poly_user_compiled = poly_compile($poly_user,$max_coord);
  221. $poly_answer_compiled = poly_compile($poly_answer,$max_coord);
  222. $poly_results = poly_result($poly_answer_compiled,$poly_user_compiled,$max_coord);
  223. $overlap = $poly_results['both'];
  224. $poly_answer_area = $poly_results['s1'];
  225. $poly_user_area = $poly_results['s2'];
  226. $missing = $poly_results['s1Only'];
  227. $excess = $poly_results['s2Only'];
  228. }
  229. //$overlap = round(polygons_overlap($poly_answer,$poly_user)); //this is an area in pixels
  230. if ($dbg_local>0) { error_log(__LINE__.' - Polygons results are '.print_r($poly_results,1),0);}
  231. if ($overlap < 1) {
  232. //shortcut to avoid complicated calculations
  233. $final_overlap = 0;
  234. $final_missing = 100;
  235. $final_excess = 100;
  236. } else {
  237. // the final overlap is the percentage of the initial polygon that is overlapped by the user's polygon
  238. $final_overlap = round(((float)$overlap / (float)$poly_answer_area)*100);
  239. if ($dbg_local>1) { error_log(__LINE__.' - Final overlap is '.$final_overlap,0);}
  240. // the final missing area is the percentage of the initial polygon that is not overlapped by the user's polygon
  241. $final_missing = 100 - $final_overlap;
  242. if ($dbg_local>1) { error_log(__LINE__.' - Final missing is '.$final_missing,0);}
  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) { error_log(__LINE__.' - Final excess is '.$final_excess,0);}
  246. }
  247. $destination_items= explode('@@', $answerDestination);
  248. $threadhold_total = $destination_items[0];
  249. $threadhold_items=explode(';',$threadhold_total);
  250. $threadhold1 = $threadhold_items[0]; // overlap
  251. $threadhold2 = $threadhold_items[1]; // excess
  252. $threadhold3 = $threadhold_items[2]; //missing
  253. // echo $final_overlap.' '.$threadhold1 .' - '. $final_missing.' '. $threadhold2 .' - '. $final_excess.' '. $threadhold3;
  254. // if is delineation
  255. if ($answerId===1) {
  256. //setting colors
  257. if ($final_overlap >= $threadhold1) {
  258. $overlap_color = true; //echo 'a';
  259. }
  260. if ($final_excess <= $threadhold2) {
  261. $excess_color = true; //echo 'b';
  262. }
  263. if ($final_missing <= $threadhold3) {
  264. $missing_color = true; //echo 'c';
  265. }
  266. // if pass
  267. //if ($final_overlap>=$threadhold1 && $final_missing<=$threadhold2 && $final_excess<=$threadhold3) {
  268. if ($final_overlap>=$threadhold1 && $final_missing<=$threadhold3 && $final_excess<=$threadhold2) {
  269. $next=1; //go to the oars
  270. $result_comment=get_lang('Acceptable');
  271. } else {
  272. $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
  273. $wrong_results = true;
  274. $result_comment=get_lang('Unacceptable');
  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. //echo 'show the feedback';
  283. }
  284. } elseif($answerId>1) {
  285. if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') {
  286. if ($dbg_local>0) { error_log(__LINE__.' - answerId is of type noerror',0);}
  287. //type no error shouldn't be treated
  288. $next = 1;
  289. continue;
  290. }
  291. if ($dbg_local>0) { error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR',0);}
  292. //check the intersection between the oar and the user
  293. //echo 'user'; print_r($x_user_list); print_r($y_user_list);
  294. //echo 'official';print_r($x_list);print_r($y_list);
  295. //$result = get_intersection_data($x_list,$y_list,$x_user_list,$y_user_list);
  296. //$delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId);
  297. $delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId); //getting the oars coordinates
  298. $poly_answer = convert_coordinates($delineation_cord,'|');
  299. $max_coord = poly_get_max($poly_user,$poly_answer); //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($poly_user,$max_coord,$test);//$poly_user is already set when answerid = 1
  307. $poly_answer_compiled = poly_compile($poly_answer,$max_coord,$test);
  308. $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled,$max_coord);
  309. }
  310. if ($overlap == false) {
  311. //all good, no overlap
  312. $next = 1;
  313. continue;
  314. } else {
  315. if ($dbg_local>0) { error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit',0);}
  316. $organs_at_risk_hit++;
  317. //show the feedback
  318. $next=1;
  319. $comment=$answerDestination=$objAnswerTmp->selectComment($answerId);
  320. $answerDestination=$objAnswerTmp->selectDestination($answerId);
  321. $destination_items= explode('@@', $answerDestination);
  322. $try_hotspot=$destination_items[1];
  323. $lp_hotspot=$destination_items[2];
  324. $select_question_hotspot=$destination_items[3];
  325. $url_hotspot=$destination_items[4];
  326. }
  327. }
  328. } else {
  329. // the first delineation feedback
  330. if ($dbg_local>0) { error_log(__LINE__.' first',0);}
  331. //we send the error
  332. }
  333. }
  334. }
  335. if ($overlap_color) {
  336. $overlap_color='green';
  337. } else {
  338. $overlap_color='red';
  339. }
  340. if ($missing_color) {
  341. $missing_color='green';
  342. } else {
  343. $missing_color='red';
  344. }
  345. if ($excess_color) {
  346. $excess_color='green';
  347. } else {
  348. $excess_color='red';
  349. }
  350. if (!is_numeric($final_overlap)) {
  351. $final_overlap = 0;
  352. }
  353. if (!is_numeric($final_missing)) {
  354. $final_missing = 0;
  355. }
  356. if (!is_numeric($final_excess)) {
  357. $final_excess = 0;
  358. }
  359. if ($final_excess>100) {
  360. $final_excess = 100;
  361. }
  362. $table_resume = '<table class="data_table" >
  363. <tr class="row_odd" >
  364. <td></td>
  365. <td ><b>'.get_lang('Requirements').'</b></td>
  366. <td><b>'.get_lang('YourAnswer').'</b></td>
  367. </tr>
  368. <tr class="row_even">
  369. <td><b>'.get_lang('Overlap').'</b></td>
  370. <td>'.get_lang('Min').' '.$threadhold1.'</td>
  371. <td><div style="color:'.$overlap_color.'">'.(($final_overlap < 0)?0:intval($final_overlap)).'</div></td>
  372. </tr>
  373. <tr>
  374. <td><b>'.get_lang('Excess').'</b></td>
  375. <td>'.get_lang('Max').' '.$threadhold2.'</td>
  376. <td><div style="color:'.$excess_color.'">'.(($final_excess < 0)?0:intval($final_excess)).'</div></td>
  377. </tr>
  378. <tr class="row_even">
  379. <td><b>'.get_lang('Missing').'</b></td>
  380. <td>'.get_lang('Max').' '.$threadhold3.'</td>
  381. <td><div style="color:'.$missing_color.'">'.(($final_missing < 0)?0:intval($final_missing)).'</div></td>
  382. </tr>
  383. </table>';
  384. }
  385. $_SESSION['newquestionList'] = $newquestionList;
  386. $links='';
  387. if (isset($choice_value) && $choice_value == -1) {
  388. if ($answerType != HOT_SPOT_DELINEATION) {
  389. $links .= '<a href="#" onclick="self.parent.tb_remove();">'.get_lang('ChooseAnAnswer').'</a><br />';
  390. }
  391. }
  392. $destinationid = null;
  393. if ($answerType != HOT_SPOT_DELINEATION) {
  394. if (!empty($destination)) {
  395. $item_list = explode('@@',$destination);
  396. //print_R($item_list);
  397. $try = $item_list[0];
  398. $lp = $item_list[1];
  399. $destinationid= $item_list[2];
  400. $url=$item_list[3];
  401. }
  402. $table_resume='';
  403. } else {
  404. $try = $try_hotspot;
  405. $lp = $lp_hotspot;
  406. $destinationid= $select_question_hotspot;
  407. $url=$url_hotspot;
  408. if ($organs_at_risk_hit==0 && $wrong_results==false ) {
  409. // no error = no oar and no wrong result for delineation
  410. //show if no error
  411. //echo 'no error';
  412. $comment= $answerComment = $objAnswerTmp->selectComment($nbrAnswers);
  413. $answerDestination = $objAnswerTmp->selectDestination($nbrAnswers);
  414. //we send the error
  415. $destination_items= explode('@@', $answerDestination);
  416. $try=$destination_items[1];
  417. $lp=$destination_items[2];
  418. $destinationid=$destination_items[3];
  419. $url=$destination_items[4];
  420. $exerciseResult[$questionid] = 1;
  421. } else {
  422. $exerciseResult[$questionid] = 0;
  423. }
  424. }
  425. // the link to retry the question
  426. if (isset($try) && $try==1) {
  427. $num_value_array= (array_keys($questionList, $questionid));
  428. $links.= Display :: return_icon('reload.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a onclick="SendEx('.$num_value_array[0].');" href="#">'.get_lang('TryAgain').'</a><br /><br />';
  429. }
  430. // the link to theory (a learning path)
  431. if (!empty($lp)) {
  432. $lp_url= api_get_path(WEB_CODE_PATH) . 'lp/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$lp;
  433. $list = new LearnpathList(api_get_user_id());
  434. $flat_list = $list->get_flat_list();
  435. $links.= Display :: return_icon('theory.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a target="_blank" href="'.$lp_url.'">'.get_lang('SeeTheory').'</a><br />';
  436. }
  437. $links.='<br />';
  438. // the link to an external website or link
  439. if (!empty($url)) {
  440. $links.= Display :: return_icon('link.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a target="_blank" href="'.$url.'">'.get_lang('VisitUrl').'</a><br /><br />';
  441. }
  442. // the link to finish the test
  443. if ($destinationid==-1) {
  444. $links.= Display :: return_icon('finish.gif', '', array ('style' => 'width:22px; height:22px; padding-left:0px;padding-right:5px;')).'<a onclick="SendEx(-1);" href="#">'.get_lang('EndActivity').'</a><br /><br />';
  445. } else {
  446. // the link to other question
  447. if (in_array($destinationid,$questionList)) {
  448. $objQuestionTmp = Question :: read($destinationid);
  449. $questionName=$objQuestionTmp->selectTitle();
  450. $num_value_array= (array_keys($questionList, $destinationid));
  451. $links .= Display:: return_icon(
  452. 'quiz.png',
  453. '',
  454. array('style' => 'padding-left:0px;padding-right:5px;')
  455. ).'<a onclick="SendEx('.$num_value_array[0].');" href="#">'.get_lang(
  456. 'GoToQuestion'
  457. ).' '.$num_value_array[0].'</a><br /><br />';
  458. }
  459. }
  460. echo '<script>
  461. function SendEx(num) {
  462. if (num == -1) {
  463. 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.'";
  464. self.parent.tb_remove();
  465. } else {
  466. num -= 1;
  467. 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.'";
  468. self.parent.tb_remove();
  469. }
  470. }
  471. </script>';
  472. if ($links!='') {
  473. /*echo '<div id="ModalContent" style="padding-bottom:30px;padding-top:10px;padding-left:20px;padding-right:20px;">
  474. <a onclick="self.parent.tb_remove();" href="#" style="float:right; margin-top:-10px;">'.api_ucfirst(get_lang('Close')).'</a>';*/
  475. echo '<h1><div style="color:#333;">'.get_lang('Feedback').'</div></h1>';
  476. if ($answerType == HOT_SPOT_DELINEATION) {
  477. if ($organs_at_risk_hit > 0) {
  478. //$message='<p>'.get_lang('YourDelineation').'</p>';
  479. //$message.=$table_resume;
  480. $message.='<br />'.get_lang('ResultIs').' <b>'.get_lang('Unacceptable').'</b><br />';
  481. //if ($wrong_results) { }
  482. $message.='<p style="color:#DC0A0A;"><b>'.get_lang('OARHit').'</b></p>';
  483. $message.='<p>'.$comment.'</p>';
  484. } else {
  485. $message='<p>'.get_lang('YourDelineation').'</p>';
  486. $message.=$table_resume;
  487. $message.='<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />';
  488. $message.='<p>'.$comment.'</p>';
  489. }
  490. echo $message;
  491. } else {
  492. echo '<p>'.$comment.'</p>';
  493. }
  494. echo '<h3>'.$links.'</h3>';
  495. echo '</div>';
  496. $_SESSION['hot_spot_result']=$message;
  497. $_SESSION['hotspot_delineation_result'][$exerciseId][$questionid] = array($message, $exerciseResult[$questionid]);
  498. //reseting the exerciseResult variable
  499. Session::write('exerciseResult',$exerciseResult);
  500. //save this variables just in case the exercise loads an LP with other exercise
  501. $_SESSION['objExerciseExtra'.$exerciseId] = $_SESSION['objExercise'];
  502. $_SESSION['exerciseResultExtra'.$exerciseId] = $_SESSION['exerciseResult'];
  503. $_SESSION['questionListExtra'.$exerciseId] = $_SESSION['questionList'];
  504. } else {
  505. $questionNum++;
  506. echo '<script>
  507. self.parent.window.location.href = "exercise_submit.php?exerciseId='.$exerciseId.'&num='.$questionNum.'&exerciseType='.$exerciseType.'&origin='.$origin.'";
  508. //self.parent.tb_remove();
  509. </script>';
  510. }
  511. echo '</div>';