exercise_submit_modal.php 24 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. /**
  8. * Code
  9. */
  10. $language_file=array('exercice');
  11. require_once '../inc/global.inc.php';
  12. api_protect_course_script(false);
  13. require_once api_get_path(INCLUDE_PATH).'reduced_header.inc.php';
  14. require_once api_get_path(LIBRARY_PATH).'geometry.lib.php';
  15. $dbg_local = 0;
  16. require_once 'exercise.class.php';
  17. require_once 'question.class.php';
  18. require_once 'answer.class.php';
  19. require_once 'exercise.lib.php';
  20. if (empty ($exerciseResult)) {
  21. $exerciseResult = $_SESSION['exerciseResult'];
  22. }
  23. if (empty($exerciseResultCoordinates)) {
  24. $exerciseResultCoordinates = $_REQUEST['exerciseResultCoordinates'];
  25. }
  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['questionnum']);
  42. $nbrQuestions = intval($_GET['nbrQuestions']);
  43. //clean extra session variables
  44. api_session_unregister('objExerciseExtra'.$exerciseId);
  45. api_session_unregister('exerciseResultExtra'.$exerciseId);
  46. api_session_unregister('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. list($x,$y) = explode(';',$coord);
  53. $user_array .= round($x).';'.round($y).'/';
  54. }
  55. }
  56. $user_array = substr($user_array,0,-1);
  57. if (isset($_GET['choice'])){
  58. $choice_value = intval($_GET['choice']);
  59. }
  60. // getting the options by js
  61. if (empty($choice_value)) {
  62. echo '<script type="text/javascript">'."
  63. // this works for only radio buttons
  64. var f= self.parent.window.document.frm_exercise;
  65. var choice_js='';
  66. var hotspot = new Array();
  67. var hotspotcoord = new Array();
  68. var counter=0;
  69. for( var i = 0; i < f.elements.length; i++ )
  70. {
  71. if (f.elements[i].type=='radio' && f.elements[i].checked)
  72. {
  73. //alert( f.elements[i].name);
  74. choice_js = f.elements[i].value;
  75. counter ++;
  76. }
  77. if (f.elements[i].type=='hidden' )
  78. {
  79. name = f.elements[i].name;
  80. if (name.substr(0,7)=='hotspot')
  81. hotspot.push(f.elements[i].value);
  82. if (name.substr(0,20)=='hotspot_coordinates')
  83. hotspotcoord.push(f.elements[i].value);
  84. //hotspot = f.elements[i].value;
  85. }
  86. }
  87. if (counter==0)
  88. {
  89. choice_js=-1; // this is an error
  90. }
  91. //alert(choice_js);
  92. ";
  93. // IMPORTANT
  94. //this is the real redirect function
  95. 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.'&questionnum='.$questionNum.'&exerciseType='.$exerciseType.'&origin='.$origin.'&gradebook='.$gradebook.'";</script>';
  96. }
  97. $choice=array();
  98. $questionid= $questionList[$questionNum];
  99. // $choice_value => value of the user selection
  100. $choice[$questionid]=$choice_value;
  101. // initializing
  102. if(!is_array($exerciseResult)) {
  103. $exerciseResult=array();
  104. }
  105. // if the user has answered at least one question
  106. if(is_array($choice)) {
  107. if($exerciseType == 1) {
  108. // $exerciseResult receives the content of the form.
  109. // Each choice of the student is stored into the array $choice
  110. $exerciseResult=$choice;
  111. } else {
  112. // gets the question ID from $choice. It is the key of the array
  113. list($key)=array_keys($choice);
  114. // if the user didn't already answer this question
  115. if(!isset($exerciseResult[$key])) {
  116. // stores the user answer into the array
  117. $exerciseResult[$key]=$choice[$key];
  118. }
  119. }
  120. }
  121. // the script "exercise_result.php" will take the variable $exerciseResult from the session
  122. api_session_register('exerciseResult');
  123. api_session_register('exerciseResultCoordinates');
  124. /*
  125. // if it is the last question (only for a sequential exercise)
  126. if($questionNum >= $nbrQuestions)
  127. {
  128. if($debug>0){echo str_repeat('&nbsp;',0).'Redirecting to exercise_result.php - Remove debug option to let this happen'."<br />\n";}
  129. // goes to the script that will show the result of the exercise
  130. // header("Location: exercise_result.php?origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id");
  131. // echo 'location result';
  132. }*/
  133. // gets the student choice for this question
  134. //print_r($choice); echo "<br>";
  135. // creates a temporary Question object
  136. if (in_array($questionid, $questionList)) {
  137. $objQuestionTmp = Question :: read($questionid);
  138. $questionName =$objQuestionTmp->selectTitle();
  139. $questionDescription=$objQuestionTmp->selectDescription();
  140. $questionWeighting =$objQuestionTmp->selectWeighting();
  141. $answerType =$objQuestionTmp->selectType();
  142. $quesId =$objQuestionTmp->selectId(); //added by priya saini
  143. }
  144. $objAnswerTmp=new Answer($questionid);
  145. $nbrAnswers=$objAnswerTmp->selectNbrAnswers();
  146. //echo 'answe_type '.$answerType;echo '<br />';
  147. $choice=$exerciseResult[$questionid];
  148. $destination=array();
  149. $comment='';
  150. $next=1;
  151. $_SESSION['hotspot_coord']=array();
  152. $_SESSION['hotspot_dest']=array();
  153. $overlap_color=$missing_color=$excess_color=false;
  154. $organs_at_risk_hit=0;
  155. $wrong_results = false;
  156. $hot_spot_load = false;
  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. //echo $questionScore;
  195. if ($studentChoice) {
  196. $destination=$answerDestination;
  197. $comment=$answerComment;
  198. }
  199. } elseif($answerType == HOT_SPOT_DELINEATION) {
  200. if ($next) {
  201. if ($dbg_local>0) { error_log(__LINE__.' - next',0);}
  202. $hot_spot_load = true; //apparently the script is called twice
  203. $user_answer = $user_array;
  204. $_SESSION['exerciseResultCoordinates'][$questionid]=$user_answer; //needed for exercise_result.php
  205. // we compare only the delineation not the other points
  206. $answer_question = $_SESSION['hotspot_coord'][1];
  207. $answerDestination = $_SESSION['hotspot_dest'][1];
  208. $poly_user = convert_coordinates($user_answer,'/');
  209. $poly_answer = convert_coordinates($answer_question,'|');
  210. $max_coord = poly_get_max($poly_user,$poly_answer);
  211. if (empty($_GET['hotspot'])) { //no user response
  212. $overlap = -2;
  213. } else {
  214. $poly_user_compiled = poly_compile($poly_user,$max_coord);
  215. $poly_answer_compiled = poly_compile($poly_answer,$max_coord);
  216. $poly_results = poly_result($poly_answer_compiled,$poly_user_compiled,$max_coord);
  217. $overlap = $poly_results['both'];
  218. $poly_answer_area = $poly_results['s1'];
  219. $poly_user_area = $poly_results['s2'];
  220. $missing = $poly_results['s1Only'];
  221. $excess = $poly_results['s2Only'];
  222. }
  223. //$overlap = round(polygons_overlap($poly_answer,$poly_user)); //this is an area in pixels
  224. if ($dbg_local>0) { error_log(__LINE__.' - Polygons results are '.print_r($poly_results,1),0);}
  225. if ($overlap < 1) {
  226. //shortcut to avoid complicated calculations
  227. $final_overlap = 0;
  228. $final_missing = 100;
  229. $final_excess = 100;
  230. } else {
  231. // the final overlap is the percentage of the initial polygon that is overlapped by the user's polygon
  232. $final_overlap = round(((float)$overlap / (float)$poly_answer_area)*100);
  233. if ($dbg_local>1) { error_log(__LINE__.' - Final overlap is '.$final_overlap,0);}
  234. // the final missing area is the percentage of the initial polygon that is not overlapped by the user's polygon
  235. $final_missing = 100 - $final_overlap;
  236. if ($dbg_local>1) { error_log(__LINE__.' - Final missing is '.$final_missing,0);}
  237. // 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
  238. $final_excess = round((((float)$poly_user_area-(float)$overlap)/(float)$poly_answer_area)*100);
  239. if ($dbg_local>1) { error_log(__LINE__.' - Final excess is '.$final_excess,0);}
  240. }
  241. $destination_items= explode('@@', $answerDestination);
  242. $threadhold_total = $destination_items[0];
  243. $threadhold_items=explode(';',$threadhold_total);
  244. $threadhold1 = $threadhold_items[0]; // overlap
  245. $threadhold2 = $threadhold_items[1]; // excess
  246. $threadhold3 = $threadhold_items[2]; //missing
  247. // echo $final_overlap.' '.$threadhold1 .' - '. $final_missing.' '. $threadhold2 .' - '. $final_excess.' '. $threadhold3;
  248. // if is delineation
  249. if ($answerId===1) {
  250. //setting colors
  251. if ($final_overlap>=$threadhold1) {
  252. $overlap_color=true; //echo 'a';
  253. }
  254. //echo $excess.'-'.$threadhold2;
  255. if ($final_excess<=$threadhold2) {
  256. $excess_color=true; //echo 'b';
  257. }
  258. //echo '--------'.$missing.'-'.$threadhold3;
  259. if ($final_missing<=$threadhold3) {
  260. $missing_color=true; //echo 'c';
  261. }
  262. // if pass
  263. //if ($final_overlap>=$threadhold1 && $final_missing<=$threadhold2 && $final_excess<=$threadhold3) {
  264. if ($final_overlap>=$threadhold1 && $final_missing<=$threadhold3 && $final_excess<=$threadhold2) {
  265. $next=1; //go to the oars
  266. $result_comment=get_lang('Acceptable');
  267. } else {
  268. $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
  269. $wrong_results = true;
  270. $result_comment=get_lang('Unacceptable');
  271. $sepecial_comment = $comment=$answerDestination=$objAnswerTmp->selectComment(1);
  272. $answerDestination=$objAnswerTmp->selectDestination(1);
  273. $destination_items= explode('@@', $answerDestination);
  274. $try_hotspot=$destination_items[1];
  275. $lp_hotspot=$destination_items[2];
  276. $select_question_hotspot=$destination_items[3];
  277. $url_hotspot=$destination_items[4];
  278. //echo 'show the feedback';
  279. }
  280. } elseif($answerId>1) {
  281. if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') {
  282. if ($dbg_local>0) { error_log(__LINE__.' - answerId is of type noerror',0);}
  283. //type no error shouldn't be treated
  284. $next = 1;
  285. continue;
  286. }
  287. if ($dbg_local>0) { error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR',0);}
  288. //check the intersection between the oar and the user
  289. //echo 'user'; print_r($x_user_list); print_r($y_user_list);
  290. //echo 'official';print_r($x_list);print_r($y_list);
  291. //$result = get_intersection_data($x_list,$y_list,$x_user_list,$y_user_list);
  292. //$delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId);
  293. $delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId); //getting the oars coordinates
  294. $poly_answer = convert_coordinates($delineation_cord,'|');
  295. $max_coord = poly_get_max($poly_user,$poly_answer); //getting max coordinates
  296. $test = false;
  297. // if ($answerId == 2 ){$test = true;} for test oars
  298. if (empty($_GET['hotspot'])) { //no user response
  299. $overlap = false;
  300. } else {
  301. // poly_compile really works tested with gnuplot
  302. $poly_user_compiled = poly_compile($poly_user,$max_coord,$test);//$poly_user is already set when answerid = 1
  303. $poly_answer_compiled = poly_compile($poly_answer,$max_coord,$test);
  304. $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled,$max_coord);
  305. }
  306. if ($overlap == false) {
  307. //all good, no overlap
  308. $next = 1;
  309. continue;
  310. } else {
  311. if ($dbg_local>0) { error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit',0);}
  312. $organs_at_risk_hit++;
  313. //show the feedback
  314. $next=1;
  315. $comment=$answerDestination=$objAnswerTmp->selectComment($answerId);
  316. $answerDestination=$objAnswerTmp->selectDestination($answerId);
  317. $destination_items= explode('@@', $answerDestination);
  318. $try_hotspot=$destination_items[1];
  319. $lp_hotspot=$destination_items[2];
  320. $select_question_hotspot=$destination_items[3];
  321. $url_hotspot=$destination_items[4];
  322. }
  323. }
  324. } else {
  325. // the first delineation feedback
  326. if ($dbg_local>0) { error_log(__LINE__.' first',0);}
  327. //we send the error
  328. }
  329. }
  330. }
  331. if ($overlap_color) {
  332. $overlap_color='green';
  333. } else {
  334. $overlap_color='red';
  335. }
  336. if ($missing_color) {
  337. $missing_color='green';
  338. } else {
  339. $missing_color='red';
  340. }
  341. if ($excess_color) {
  342. $excess_color='green';
  343. } else {
  344. $excess_color='red';
  345. }
  346. if (!is_numeric($final_overlap)) {
  347. $final_overlap = 0;
  348. }
  349. if (!is_numeric($final_missing)) {
  350. $final_missing = 0;
  351. }
  352. if (!is_numeric($final_excess)) {
  353. $final_excess = 0;
  354. }
  355. if ($final_excess>100) {
  356. $final_excess = 100;
  357. }
  358. $table_resume='<table class="data_table" >
  359. <tr class="row_odd" >
  360. <td></td>
  361. <td ><b>'.get_lang('Requirements').'</b></td>
  362. <td><b>'.get_lang('YourAnswer').'</b></td>
  363. </tr>
  364. <tr class="row_even">
  365. <td><b>'.get_lang('Overlap').'</b></td>
  366. <td>'.get_lang('Min').' '.$threadhold1.'</td>
  367. <td><div style="color:'.$overlap_color.'">'.(($final_overlap < 0)?0:intval($final_overlap)).'</div></td>
  368. </tr>
  369. <tr>
  370. <td><b>'.get_lang('Excess').'</b></td>
  371. <td>'.get_lang('Max').' '.$threadhold2.'</td>
  372. <td><div style="color:'.$excess_color.'">'.(($final_excess < 0)?0:intval($final_excess)).'</div></td>
  373. </tr>
  374. <tr class="row_even">
  375. <td><b>'.get_lang('Missing').'</b></td>
  376. <td>'.get_lang('Max').' '.$threadhold3.'</td>
  377. <td><div style="color:'.$missing_color.'">'.(($final_missing < 0)?0:intval($final_missing)).'</div></td>
  378. </tr>
  379. </table>';
  380. //var_dump($final_overlap, $threadhold1 , $final_missing, $threadhold2 , $final_excess, $threadhold3);
  381. }
  382. $_SESSION['newquestionList']=$newquestionList;
  383. if ($choice_value==-1) {
  384. $links. '<a href="#" onclick="self.parent.tb_remove();">'.get_lang('ChooseAnAnswer').'</a>';
  385. }
  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. $links='';
  419. // the link to retry the question
  420. if ($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. require_once('../newscorm/learnpathList.class.php');
  428. $list = new LearnpathList(api_get_user_id());
  429. $flat_list = $list->get_flat_list();
  430. $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 />';
  431. }
  432. $links.='<br />';
  433. // the link to an external website or link
  434. if (!empty($url)) {
  435. $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 />';
  436. }
  437. // the link to finish the test
  438. if ($destinationid==-1) {
  439. $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 />';
  440. } else {
  441. // the link to other question
  442. if (in_array($destinationid,$questionList)) {
  443. $objQuestionTmp = Question :: read($destinationid);
  444. $questionName=$objQuestionTmp->selectTitle();
  445. $num_value_array= (array_keys($questionList, $destinationid));
  446. $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 />';
  447. }
  448. }
  449. echo '<script>
  450. function SendEx(num) {
  451. if (num==-1) {
  452. self.parent.window.location.href = "exercise_result.php?take_session=1&exerciseId='.$exerciseId.'&questionNum="+num+"&exerciseType='.$exerciseType.'&origin='.$origin.'&learnpath_item_id='.$learnpath_item_id.'&learnpath_id='.$learnpath_id.'";
  453. self.parent.tb_remove();
  454. } else {
  455. self.parent.window.location.href = "exercise_submit.php?tryagain=1&exerciseId='.$exerciseId.'&questionNum="+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;" id="exercise_close_link">'.api_ucfirst(get_lang('Close')).'</a>
  463. <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 '<a onclick="self.parent.tb_remove();" href="#" style="float:right;">'.get_lang('Close').'</a>';
  484. echo '</div>';
  485. $_SESSION['hot_spot_result']=$message;
  486. //saving the hotspot delineation results
  487. /*
  488. if ($hot_spot_load) { // apparently the popup load 2 times @todo check this
  489. $exeId = create_event_exercice($exerciseId);
  490. // only insert the user delineation
  491. //for($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
  492. $tbl_track_e_hotspot = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
  493. // Save into db
  494. $sql = "INSERT INTO $tbl_track_e_hotspot (hotspot_user_id, hotspot_course_code, hotspot_exe_id, hotspot_question_id, hotspot_answer_id, hotspot_correct, hotspot_coordinate )
  495. VALUES ('".Database::escape_string($_user['user_id'])."', '".Database::escape_string($_course['id'])."', '".Database::escape_string($exeId)."', '".Database::escape_string($questionid)."', '".Database::escape_string($answerId)."', '".Database::escape_string($exerciseResult[$questionid])."', '".Database::escape_string($user_array)."')";
  496. $result = api_sql_query($sql,__FILE__,__LINE__);
  497. //}
  498. }*/
  499. $_SESSION['hotspot_delineation_result'][$exerciseId][$questionid] = array($message, $exerciseResult[$questionid]);
  500. //reseting the exerciseResult variable
  501. api_session_register('exerciseResult');
  502. //save this variables just in case the exercise loads an LP with other exercise
  503. $_SESSION['objExerciseExtra'.$exerciseId] = $_SESSION['objExercise'];
  504. $_SESSION['exerciseResultExtra'.$exerciseId] = $_SESSION['exerciseResult'];
  505. $_SESSION['questionListExtra'.$exerciseId] = $_SESSION['questionList'];
  506. } else {
  507. $questionNum++;
  508. echo '<script>
  509. self.parent.window.location.href = "exercise_submit.php?exerciseId='.$exerciseId.'&questionNum='.$questionNum.'&exerciseType='.$exerciseType.'&origin='.$origin.'";
  510. //self.parent.tb_remove();
  511. </script>';
  512. }