exercise_submit_modal.php 23 KB

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