exercise_submit_modal.php 23 KB

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