exercise_submit_modal.php 23 KB

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