exercise_submit_modal.php 23 KB

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