exercise_show.php 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111
  1. <?php //$id: $
  2. /* For licensing terms, see /dokeos_license.txt */
  3. /**
  4. *
  5. * @package dokeos.exercise
  6. * @author Julio Montoya Armas Added switchable fill in blank option added
  7. * @version $Id: exercise_show.php 20089 2009-04-24 21:12:54Z cvargas1 $
  8. *
  9. * @todo remove the debug code and use the general debug library
  10. * @todo use the Database:: functions
  11. * @todo small letters for table variables
  12. */
  13. // name of the language file that needs to be included
  14. $language_file=array('exercice','tracking');
  15. // including the global dokeos file
  16. include('../inc/global.inc.php');
  17. // including additional libraries
  18. include_once('exercise.class.php');
  19. include_once('question.class.php');
  20. include_once('answer.class.php');
  21. include_once(api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  22. // answer types
  23. define('UNIQUE_ANSWER', 1);
  24. define('MULTIPLE_ANSWER', 2);
  25. define('FILL_IN_BLANKS', 3);
  26. define('MATCHING', 4);
  27. define('FREE_ANSWER', 5);
  28. define('HOTSPOT', 6);
  29. if ( empty ( $origin ) ) {
  30. $origin = $_REQUEST['origin'];
  31. }
  32. if ($origin == 'learnpath')
  33. api_protect_course_script();
  34. else
  35. api_protect_course_script(true);
  36. // Database table definitions
  37. $TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
  38. $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
  39. $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
  40. $TBL_REPONSES = Database::get_course_table(TABLE_QUIZ_ANSWER);
  41. $main_user_table = Database :: get_main_table(TABLE_MAIN_USER);
  42. $main_course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  43. $TBL_TRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
  44. $TBL_TRACK_ATTEMPT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
  45. $dsp_percent = false;
  46. $debug=0;
  47. if($debug>0) {
  48. echo str_repeat('&nbsp;',0).'Entered exercise_result.php'."<br />\n";var_dump($_POST);
  49. }
  50. // general parameters passed via POST/GET
  51. if ( empty ( $learnpath_id ) ) {
  52. $learnpath_id = $_REQUEST['learnpath_id'];
  53. }
  54. if ( empty ( $learnpath_item_id ) ) {
  55. $learnpath_item_id = $_REQUEST['learnpath_item_id'];
  56. }
  57. if ( empty ( $formSent ) ) {
  58. $formSent= $_REQUEST['formSent'];
  59. }
  60. if ( empty ( $exerciseResult ) ) {
  61. $exerciseResult = $_SESSION['exerciseResult'];
  62. }
  63. if ( empty ( $questionId ) ) {
  64. $questionId = $_REQUEST['questionId'];
  65. }
  66. if ( empty ( $choice ) ) {
  67. $choice = $_REQUEST['choice'];
  68. }
  69. if ( empty ( $questionNum ) ) {
  70. $questionNum = $_REQUEST['questionNum'];
  71. }
  72. if ( empty ( $nbrQuestions ) ) {
  73. $nbrQuestions = $_REQUEST['nbrQuestions'];
  74. }
  75. if ( empty ( $questionList ) ) {
  76. $questionList = $_SESSION['questionList'];
  77. }
  78. if ( empty ( $objExercise ) ) {
  79. $objExercise = $_SESSION['objExercise'];
  80. }
  81. if ( empty ( $exeId ) ) {
  82. $exeId = $_REQUEST['id'];
  83. }
  84. if ( empty ( $action ) ) {
  85. $action = $_GET['action'];
  86. }
  87. $is_allowedToEdit=api_is_allowed_to_edit() || $is_courseTutor;
  88. $nameTools=get_lang('CorrectTest');
  89. if (isset($_SESSION['gradebook'])){
  90. $gradebook= $_SESSION['gradebook'];
  91. }
  92. if (!empty($gradebook) && $gradebook=='view') {
  93. $interbreadcrumb[]= array (
  94. 'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
  95. 'name' => get_lang('Gradebook')
  96. );
  97. }
  98. if($origin=='user_course') {
  99. $interbreadcrumb[] = array ("url" => "../user/user.php?cidReq=".Security::remove_XSS($_GET['course']), "name" => get_lang("Users"));
  100. $interbreadcrumb[] = array("url" => "../mySpace/myStudents.php?student=".Security::remove_XSS($_GET['student'])."&course=".$_course['id']."&details=true&origin=".Security::remove_XSS($_GET['origin']) , "name" => get_lang("DetailsStudentInCourse"));
  101. } else if($origin=='tracking_course') {
  102. $interbreadcrumb[] = array ("url" => "../mySpace/index.php", "name" => get_lang('MySpace'));
  103. $interbreadcrumb[] = array ("url" => "../mySpace/myStudents.php?student=".Security::remove_XSS($_GET['student']).'&details=true&origin='.$origin.'&course='.Security::remove_XSS($_GET['cidReq']), "name" => get_lang("DetailsStudentInCourse"));
  104. } else if($origin=='student_progress') {
  105. $interbreadcrumb[] = array ("url" => "../auth/my_progress.php?id_session".Security::remove_XSS($_GET['id_session'])."&course=".$_cid, "name" => get_lang('MyProgress'));
  106. unset($_cid);
  107. } else {
  108. $interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices'));
  109. $this_section=SECTION_COURSES;
  110. }
  111. if ($origin != 'learnpath') {
  112. Display::display_header($nameTools,"Exercise");
  113. }
  114. $emailId = $_REQUEST['email'];
  115. $user_name = $_REQUEST['user'];
  116. $test = $_REQUEST['test'];
  117. $dt = $_REQUEST['dt'];
  118. $marks = $_REQUEST['res'];
  119. $id = $_REQUEST['id'];
  120. ?>
  121. <style type="text/css">
  122. <!--
  123. #comments {
  124. position:absolute;
  125. left:795px;
  126. top:0px;
  127. width:200px;
  128. height:75px;
  129. z-index:1;
  130. }
  131. -->
  132. </style>
  133. <link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_CODE_PATH).'css/'.api_get_setting('stylesheets').'/default.css'; ?>" />
  134. <script language="javascript">
  135. function showfck(sid,marksid)
  136. {
  137. document.getElementById(sid).style.display='block';
  138. document.getElementById(marksid).style.display='block';
  139. var comment = 'feedback_'+sid;
  140. document.getElementById(comment).style.display='none';
  141. }
  142. function getFCK(vals,marksid)
  143. {
  144. var f=document.getElementById('myform');
  145. var m_id = marksid.split(',');
  146. for(var i=0;i<m_id.length;i++){
  147. var oHidn = document.createElement("input");
  148. oHidn.type = "hidden";
  149. var selname = oHidn.name = "marks_"+m_id[i];
  150. var selid = document.forms['marksform_'+m_id[i]].marks.selectedIndex;
  151. oHidn.value = document.forms['marksform_'+m_id[i]].marks.options[selid].text;
  152. f.appendChild(oHidn);
  153. }
  154. var ids = vals.split(',');
  155. for(var k=0;k<ids.length;k++){
  156. var oHidden = document.createElement("input");
  157. oHidden.type = "hidden";
  158. oHidden.name = "comments_"+ids[k];
  159. oEditor = FCKeditorAPI.GetInstance(oHidden.name) ;
  160. oHidden.value = oEditor.GetXHTML(true);
  161. f.appendChild(oHidden);
  162. }
  163. //f.submit();
  164. }
  165. </script>
  166. <?php
  167. /**
  168. * This function gets the comments of an exercise
  169. *
  170. * @param int $id
  171. * @param int $question_id
  172. * @return str the comment
  173. */
  174. function get_comments($id,$question_id)
  175. {
  176. global $TBL_TRACK_ATTEMPT;
  177. $sql = "SELECT teacher_comment FROM ".$TBL_TRACK_ATTEMPT." where exe_id='".Database::escape_string($id)."' and question_id = '".Database::escape_string($question_id)."' ORDER by question_id";
  178. $sqlres = api_sql_query($sql, __FILE__, __LINE__);
  179. $comm = Database::result($sqlres,0,"teacher_comment");
  180. return $comm;
  181. }
  182. /**
  183. * Display the answers to a multiple choice question
  184. *
  185. * @param integer Answer type
  186. * @param integer Student choice
  187. * @param string Textual answer
  188. * @param string Comment on answer
  189. * @param string Correct answer comment
  190. * @param integer Exercise ID
  191. * @param integer Question ID
  192. * @param boolean Whether to show the answer comment or not
  193. * @return void
  194. */
  195. function display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect, $id, $questionId, $ans)
  196. {
  197. ?>
  198. <tr>
  199. <td width="5%" align="center">
  200. <img src="../img/<?php echo ($answerType == UNIQUE_ANSWER)?'radio':'checkbox'; echo $studentChoice?'_on':'_off'; ?>.gif"
  201. border="0" alt="" />
  202. </td>
  203. <td width="5%" align="center">
  204. <img src="../img/<?php echo ($answerType == UNIQUE_ANSWER)?'radio':'checkbox'; echo $answerCorrect?'_on':'_off'; ?>.gif"
  205. border="0" alt=" " />
  206. </td>
  207. <td width="40%" style="border-bottom: 1px solid #4171B5;">
  208. <?php
  209. $answer=api_parse_tex($answer);
  210. echo $answer;
  211. ?>
  212. </td>
  213. <td width="20%" style="border-bottom: 1px solid #4171B5;">
  214. <?php
  215. $answerComment=api_parse_tex($answerComment);
  216. if($studentChoice)
  217. {
  218. if(!$answerCorrect)
  219. {
  220. echo '<span style="font-weight: bold; color: #FF0000;">'.nl2br(make_clickable(stripslashes($answerComment))).'</span>';
  221. }
  222. else{
  223. echo '<span style="font-weight: bold; color: #008000;">'.nl2br(make_clickable(stripslashes($answerComment))).'</span>';
  224. }
  225. }
  226. else
  227. {
  228. echo '&nbsp;';
  229. }
  230. ?>
  231. </td>
  232. <?php
  233. if ($ans==1) {
  234. $comm = get_comments($id,$questionId);
  235. }
  236. ?>
  237. </tr>
  238. <?php
  239. }
  240. /**
  241. * Shows the answer to a fill-in-the-blanks question, as HTML
  242. * @param string Answer text
  243. * @param int Exercise ID
  244. * @param int Question ID
  245. * @return void
  246. */
  247. function display_fill_in_blanks_answer($answer,$id,$questionId)
  248. {
  249. ?>
  250. <tr>
  251. <td>
  252. <?php echo $answer; ?>
  253. </td><?php
  254. if(!api_is_allowed_to_edit()) {?>
  255. <td>
  256. <?php
  257. $comm = get_comments($id,$questionId);
  258. //echo $comm;
  259. ?>
  260. </td>
  261. </tr>
  262. <?php }
  263. }
  264. /**
  265. * Shows the answer to a free-answer question, as HTML
  266. * @param string Answer text
  267. * @param int Exercise ID
  268. * @param int Question ID
  269. * @return void
  270. */
  271. function display_free_answer($answer,$id,$questionId) {
  272. ?>
  273. <tr>
  274. <td>
  275. <?php echo nl2br(stripslashes($answer)); ?>
  276. </td> <?php if(!api_is_allowed_to_edit()) {?>
  277. <td>
  278. <?php
  279. $comm = get_comments($id,$questionId);
  280. ?>
  281. </td>
  282. <?php }?>
  283. </tr>
  284. <?php
  285. }
  286. /**
  287. * Displays the answer to a hotspot question
  288. *
  289. * @param int $answerId
  290. * @param string $answer
  291. * @param string $studentChoice
  292. * @param string $answerComment
  293. */
  294. function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComment) {
  295. //global $hotspot_colors;
  296. $hotspot_colors = array("", // $i starts from 1 on next loop (ugly fix)
  297. "#4271B5",
  298. "#FE8E16",
  299. "#3B3B3B",
  300. "#BCD631",
  301. "#D63173",
  302. "#D7D7D7",
  303. "#90AFDD",
  304. "#AF8640",
  305. "#4F9242",
  306. "#F4EB24",
  307. "#ED2024",
  308. "#45C7F0",
  309. "#F7BDE2");
  310. ?>
  311. <tr>
  312. <td valign="top" align="left">
  313. <div style="width:100%;">
  314. <div style="height:11px; width:11px; background-color:<?php echo $hotspot_colors[$answerId]; ?>; float:left; margin:3px;"></div>
  315. <div><?php echo $answer ?></div>
  316. </div>
  317. </td>
  318. <td valign="top" align="left"><?php echo $answerId; ?></td>
  319. <td valign="top" align="left">
  320. <?php $studentChoice = ($studentChoice)?get_lang('Correct'):get_lang('Fault'); echo $studentChoice; ?>
  321. </td>
  322. <td valign="top" align="left" >
  323. <?php
  324. $answerComment=api_parse_tex($answerComment);
  325. if($studentChoice) {
  326. echo '<span style="font-weight: bold; color: #FF0000;">'.nl2br(make_clickable(stripslashes($answerComment))).'</span>';
  327. } else {
  328. echo '<span style="font-weight: bold; color: #008000;">'.nl2br(make_clickable(stripslashes($answerComment))).'</span>';
  329. }
  330. ?>
  331. </td>
  332. </tr>
  333. <?php
  334. }
  335. /*
  336. ==============================================================================
  337. MAIN CODE
  338. ==============================================================================
  339. */
  340. ?>
  341. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  342. <tr>
  343. <td colspan="2">
  344. <?php
  345. $sql_test_name='SELECT title, description, results_disabled FROM '.$TBL_EXERCICES.' as exercises, '.$TBL_TRACK_EXERCICES.' as track_exercises WHERE exercises.id=track_exercises.exe_exo_id AND track_exercises.exe_id="'.Database::escape_string($id).'"';
  346. $result=api_sql_query($sql_test_name);
  347. $show_results = true;
  348. // Avoiding the "Score 0/0" message when the exe_id is not set
  349. if (Database::num_rows($result)>0 && isset($id)) {
  350. $test=Database::result($result,0,0);
  351. $exerciseTitle=api_parse_tex($test);
  352. $exerciseDexcription=Database::result($result,0,1);
  353. // if the results_disabled of the Quiz is 1 when block the script
  354. $result_disabled=Database::result($result,0,2);
  355. if (!(api_is_platform_admin() || api_is_course_admin()) ) {
  356. if ($result_disabled==1) {
  357. //api_not_allowed();
  358. $show_results = false;
  359. //Display::display_warning_message(get_lang('CantViewResults'));
  360. if ($origin!='learnpath') {
  361. Display::display_warning_message(get_lang('ThankYouForPassingTheTest').'<br /><br /><a href="exercice.php">'.(get_lang('BackToExercisesList')).'</a>', false);
  362. echo '</td>
  363. </tr>
  364. </table>';
  365. }
  366. }
  367. }
  368. $user_restriction = $is_allowedToEdit ? '' : "AND user_id=".intval($_user['user_id'])." ";
  369. $query = "SELECT attempts.question_id, answer from ".$TBL_TRACK_ATTEMPT." as attempts
  370. INNER JOIN ".$TBL_TRACK_EXERCICES." as stats_exercices ON stats_exercices.exe_id=attempts.exe_id
  371. INNER JOIN ".$TBL_EXERCICE_QUESTION." as quizz_rel_questions ON quizz_rel_questions.exercice_id=stats_exercices.exe_exo_id AND quizz_rel_questions.question_id = attempts.question_id
  372. INNER JOIN ".$TBL_QUESTIONS." as questions ON questions.id=quizz_rel_questions.question_id
  373. WHERE attempts.exe_id='".Database::escape_string($id)."' $user_restriction
  374. GROUP BY quizz_rel_questions.question_order, attempts.question_id";
  375. //GROUP BY questions.position, attempts.question_id";
  376. $result =api_sql_query($query, __FILE__, __LINE__);
  377. } else {
  378. Display::display_warning_message(get_lang('CantViewResults'));
  379. $show_results = false;
  380. echo '</td>
  381. </tr>
  382. </table>';
  383. }
  384. if ($origin == 'learnpath') {
  385. $show_results = false;
  386. }
  387. if ($show_results) {
  388. ?>
  389. <table>
  390. <tr>
  391. <td style="font-weight:bold"><?php echo get_lang('CourseTitle')?> : </td>
  392. <td><?php echo $_course['name'] ?></td>
  393. </tr>
  394. <tr>
  395. <td style="font-weight:bold"><?php echo get_lang('User')?> : </td>
  396. <td><?php echo $user_name ?></td>
  397. </tr>
  398. <tr>
  399. <td style="font-weight:bold">
  400. <?php echo get_lang("Exercise"); ?>
  401. </td>
  402. <td>
  403. <?php echo stripslashes($test)?><br />
  404. <?php echo $exerciseDexcription; ?>
  405. </td>
  406. </tr>
  407. </table>
  408. <br />
  409. </table>
  410. <?php
  411. }
  412. $i=$totalScore=$totalWeighting=0;
  413. if($debug>0){echo "ExerciseResult: "; var_dump($exerciseResult); echo "QuestionList: ";var_dump($questionList);}
  414. // for each question
  415. $questionList = array();
  416. $exerciseResult = array();
  417. $k=0;
  418. $counter=0;
  419. while ($row = Database::fetch_array($result)) {
  420. $questionList[] = $row['question_id'];
  421. $exerciseResult[] = $row['answer'];
  422. }
  423. //echo '<pre>';print_R($questionList);
  424. //we hide the results
  425. if ($show_results)
  426. foreach($questionList as $questionId) {
  427. $counter++;
  428. $k++;
  429. $choice=$exerciseResult[$questionId];
  430. // creates a temporary Question object
  431. $objQuestionTmp = Question::read($questionId);
  432. $questionName=$objQuestionTmp->selectTitle();
  433. $questionDescription=$objQuestionTmp->selectDescription();
  434. $questionWeighting=$objQuestionTmp->selectWeighting();
  435. $answerType=$objQuestionTmp->selectType();
  436. $quesId =$objQuestionTmp->selectId(); //added by priya saini
  437. // destruction of the Question object
  438. unset($objQuestionTmp);
  439. if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER) {
  440. $colspan=2;
  441. }
  442. if($answerType == MATCHING || $answerType == FREE_ANSWER) {
  443. $colspan=2;
  444. } else {
  445. $colspan=2;
  446. }
  447. ?>
  448. <div id="question_title" class="sectiontitle">
  449. <?php echo get_lang("Question").' '.($counter).' : '.$questionName; ?>
  450. </div>
  451. <div id="question_description">
  452. <?php echo $questionDescription; ?>
  453. </div>
  454. <?php
  455. if($answerType == MULTIPLE_ANSWER) {
  456. $choice=array();
  457. ?>
  458. <table width="100%" border="0" cellspacing="3" cellpadding="3">
  459. <tr>
  460. <td>&nbsp;</td>
  461. </tr>
  462. <tr>
  463. <td><i><?php echo get_lang("Choice"); ?></i> </td>
  464. <td><i><?php echo get_lang("ExpectedChoice"); ?></i></td>
  465. <td><i><?php echo get_lang("Answer"); ?></i></td>
  466. <td><i><?php echo get_lang("Comment"); ?></i></td>
  467. </tr>
  468. <tr>
  469. <td>&nbsp;</td>
  470. </tr>
  471. <?php
  472. // construction of the Answer object
  473. $objAnswerTmp=new Answer($questionId);
  474. $nbrAnswers=$objAnswerTmp->selectNbrAnswers();
  475. $questionScore=0;
  476. for($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
  477. $answer=$objAnswerTmp->selectAnswer($answerId);
  478. $answerComment=$objAnswerTmp->selectComment($answerId);
  479. $answerCorrect=$objAnswerTmp->isCorrect($answerId);
  480. $answerWeighting=$objAnswerTmp->selectWeighting($answerId);
  481. $queryans = "select * from ".$TBL_TRACK_ATTEMPT." where exe_id = '".Database::escape_string($id)."' and question_id= '".Database::escape_string($questionId)."'";
  482. $resultans = api_sql_query($queryans, __FILE__, __LINE__);
  483. while ($row = Database::fetch_array($resultans)) {
  484. $ind = $row['answer'];
  485. $choice[$ind] = 1;
  486. }
  487. $studentChoice=$choice[$answerId];
  488. if($studentChoice) {
  489. $questionScore+=$answerWeighting;
  490. $totalScore+=$answerWeighting;
  491. }
  492. ?>
  493. <tr>
  494. <td> <?php
  495. if($answerId==1)
  496. display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$id,$questionId,$answerId);
  497. else
  498. display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$id,$questionId,"");
  499. ?>
  500. </td>
  501. </tr>
  502. <?php
  503. $i++;
  504. }?>
  505. </table>
  506. <?php
  507. } elseif ($answerType == UNIQUE_ANSWER) {
  508. ?>
  509. <table width="100%" border="0" cellspacing="3" cellpadding="3">
  510. <tr>
  511. <td>&nbsp;</td>
  512. </tr>
  513. <tr>
  514. <td><i><?php echo get_lang("Choice"); ?></i> </td>
  515. <td><i><?php echo get_lang("ExpectedChoice"); ?></i></td>
  516. <td><i><?php echo get_lang("Answer"); ?></i></td>
  517. <td><i><?php echo get_lang("Comment"); ?></i></td>
  518. </tr>
  519. <tr>
  520. <td>&nbsp;</td>
  521. </tr>
  522. <?php
  523. $objAnswerTmp=new Answer($questionId);
  524. $nbrAnswers=$objAnswerTmp->selectNbrAnswers();
  525. $questionScore=0;
  526. for ($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
  527. $answer=$objAnswerTmp->selectAnswer($answerId);
  528. $answerComment=$objAnswerTmp->selectComment($answerId);
  529. $answerCorrect=$objAnswerTmp->isCorrect($answerId);
  530. $answerWeighting=$objAnswerTmp->selectWeighting($answerId);
  531. $queryans = "select answer from ".$TBL_TRACK_ATTEMPT." where exe_id = '".Database::escape_string($id)."' and question_id= '".Database::escape_string($questionId)."'";
  532. $resultans = api_sql_query($queryans, __FILE__, __LINE__);
  533. $choice = Database::result($resultans,0,"answer");
  534. $studentChoice=($choice == $answerId)?1:0;
  535. if ($studentChoice) {
  536. $questionScore+=$answerWeighting;
  537. $totalScore+=$answerWeighting;
  538. }
  539. ?>
  540. <tr>
  541. <td>
  542. <?php
  543. if($answerId==1)
  544. display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$id,$questionId,$answerId);
  545. else
  546. display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$id,$questionId,"");
  547. ?>
  548. </td>
  549. </tr>
  550. <?php
  551. $i++;
  552. }
  553. ?>
  554. </table>
  555. <?php
  556. } elseif($answerType == FILL_IN_BLANKS){
  557. ?>
  558. <table width="100%" border="0" cellspacing="3" cellpadding="3">
  559. <tr>
  560. <td>&nbsp;</td>
  561. </tr>
  562. <tr>
  563. <td><i><?php echo get_lang("Answer"); ?></i> </td>
  564. </tr>
  565. <tr>
  566. <td>&nbsp;</td>
  567. </tr>
  568. <?php
  569. $objAnswerTmp=new Answer($questionId);
  570. $nbrAnswers=$objAnswerTmp->selectNbrAnswers();
  571. $questionScore=0;
  572. for ($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
  573. $answer=$objAnswerTmp->selectAnswer($answerId);
  574. $answerComment=$objAnswerTmp->selectComment($answerId);
  575. $answerCorrect=$objAnswerTmp->isCorrect($answerId);
  576. $answerWeighting=$objAnswerTmp->selectWeighting($answerId);
  577. // the question is encoded like this
  578. // [A] B [C] D [E] F::10,10,10@1
  579. // number 1 before the "@" means that is a switchable fill in blank question
  580. // [A] B [C] D [E] F::10,10,10@ or [A] B [C] D [E] F::10,10,10
  581. // means that is a normal fill blank question
  582. $pre_array = explode('::', $answer);
  583. // is switchable fill blank or not
  584. $is_set_switchable = explode('@', $pre_array[1]);
  585. $switchable_answer_set=false;
  586. if ($is_set_switchable[1]==1) {
  587. $switchable_answer_set=true;
  588. }
  589. $answer = $pre_array[0];
  590. // splits weightings that are joined with a comma
  591. $answerWeighting = explode(',',$is_set_switchable[0]);
  592. //list($answer,$answerWeighting)=explode('::',$multiple[0]);
  593. //$answerWeighting=explode(',',$answerWeighting);
  594. // we save the answer because it will be modified
  595. $temp=$answer;
  596. // TeX parsing
  597. // 1. find everything between the [tex] and [/tex] tags
  598. $startlocations=strpos($temp,'[tex]');
  599. $endlocations=strpos($temp,'[/tex]');
  600. if($startlocations !== false && $endlocations !== false) {
  601. $texstring=substr($temp,$startlocations,$endlocations-$startlocations+6);
  602. // 2. replace this by {texcode}
  603. $temp=str_replace($texstring,'{texcode}',$temp);
  604. }
  605. $j=0;
  606. // the loop will stop at the end of the text
  607. $i=0;
  608. //normal fill in blank
  609. if (!$switchable_answer_set) {
  610. while(1) {
  611. // quits the loop if there are no more blanks
  612. if(($pos = strpos($temp,'[')) === false) {
  613. // adds the end of the text
  614. $answer.=$temp;
  615. // TeX parsing
  616. $texstring = api_parse_tex($texstring);
  617. break;
  618. }
  619. $temp=substr($temp,$pos+1);
  620. // quits the loop if there are no more blanks
  621. if(($pos = strpos($temp,']')) === false) {
  622. break;
  623. }
  624. $queryfill = "select answer from ".$TBL_TRACK_ATTEMPT." where exe_id = '".Database::escape_string($id)."' and question_id= '".Database::escape_string($questionId)."'";
  625. $resfill = api_sql_query($queryfill, __FILE__, __LINE__);
  626. $str=Database::result($resfill,0,"answer");
  627. preg_match_all ('#\[([^[/]*)/#', $str, $arr);
  628. $choice = $arr[1];
  629. $choice[$j]=trim($choice[$j]);
  630. // if the word entered by the student IS the same as the one defined by the professor
  631. if(strtolower(substr($temp,0,$pos)) == stripslashes(strtolower($choice[$j]))) {
  632. // gives the related weighting to the student
  633. $questionScore+=$answerWeighting[$j];
  634. // increments total score
  635. $totalScore+=$answerWeighting[$j];
  636. }
  637. // else if the word entered by the student IS NOT the same as the one defined by the professor
  638. $j++;
  639. $temp=substr($temp,$pos+1);
  640. $i=$i+1;
  641. }
  642. $answer = $str;
  643. } else {
  644. //multiple fill in blank
  645. while(1) {
  646. // quits the loop if there are no more blanks
  647. if(($pos = strpos($temp,'[')) === false)
  648. {
  649. // adds the end of the text
  650. $answer.=$temp;
  651. // TeX parsing
  652. $texstring = api_parse_tex($texstring);
  653. //$answer=str_replace("{texcode}",$texstring,$answer);
  654. break;
  655. }
  656. // adds the piece of text that is before the blank and ended by [
  657. $real_text[]=substr($temp,0,$pos+1);
  658. $answer.=substr($temp,0,$pos+1);
  659. $temp=substr($temp,$pos+1);
  660. // quits the loop if there are no more blanks
  661. if(($pos = strpos($temp,']')) === false)
  662. {
  663. // adds the end of the text
  664. //$answer.=$temp;
  665. break;
  666. }
  667. $queryfill = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT." WHERE exe_id = '".Database::escape_string($id)."' and question_id= '".Database::escape_string($questionId)."'";
  668. $resfill = api_sql_query($queryfill, __FILE__, __LINE__);
  669. $str=Database::result($resfill,0,"answer");
  670. preg_match_all ('#\[([^[/]*)/#', $str, $arr);
  671. $choice = $arr[1];
  672. $choice[$j]=trim($choice[$j]);
  673. $user_tags[]=stripslashes(strtolower($choice[$j]));
  674. $correct_tags[]=strtolower(substr($temp,0,$pos));
  675. $j++;
  676. $temp=substr($temp,$pos+1);
  677. $i=$i+1;
  678. }
  679. $answer='';
  680. for($i=0;$i<count($correct_tags);$i++)
  681. {
  682. if (in_array($user_tags[$i],$correct_tags))
  683. {
  684. // gives the related weighting to the student
  685. $questionScore+=$answerWeighting[$i];
  686. // increments total score
  687. $totalScore+=$answerWeighting[$i];
  688. }
  689. }
  690. $answer = $str;
  691. }
  692. //echo $questionScore."-".$totalScore;
  693. ?>
  694. <tr>
  695. <td>
  696. <?php display_fill_in_blanks_answer($answer,$id,$questionId); ?> </td>
  697. </tr>
  698. <?php
  699. $i++;
  700. }
  701. ?>
  702. </table>
  703. <?php
  704. } elseif($answerType == FREE_ANSWER) {
  705. ?>
  706. <table width="100%" border="0" cellspacing="3" cellpadding="3">
  707. <tr>
  708. <td>&nbsp;</td>
  709. </tr>
  710. <tr>
  711. <td><i><?php echo get_lang("Answer"); ?></i> </td>
  712. </tr>
  713. <tr>
  714. <td>&nbsp;</td>
  715. </tr>
  716. <?php
  717. $objAnswerTmp=new Answer($questionId);
  718. $nbrAnswers=$objAnswerTmp->selectNbrAnswers();
  719. $questionScore=0;
  720. $query = "select answer, marks from ".$TBL_TRACK_ATTEMPT." where exe_id = '".Database::escape_string($id)."' and question_id= '".Database::escape_string($questionId)."'";
  721. $resq=api_sql_query($query);
  722. $choice = Database::result($resq,0,"answer");
  723. $questionScore = Database::result($resq,0,"marks");
  724. if($questionScore==-1){
  725. $totalScore+=0;
  726. }
  727. else{
  728. $totalScore+=$questionScore;
  729. }
  730. ?>
  731. <tr>
  732. <td valign="top"><?php display_free_answer($choice, $id, $questionId);?> </td>
  733. </tr>
  734. </table>
  735. <?php
  736. } elseif($answerType == MATCHING) {
  737. $objAnswerTmp=new Answer($questionId);
  738. $table_ans = Database :: get_course_table(TABLE_QUIZ_ANSWER);
  739. $TBL_TRACK_ATTEMPT= Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
  740. $sql_select_answer = 'SELECT id, answer, correct, position FROM '.$table_ans.' WHERE question_id="'.Database::escape_string($questionId).'" AND correct<>0';
  741. $sql_answer = 'SELECT position, answer FROM '.$table_ans.' WHERE question_id="'.Database::escape_string($questionId).'" AND correct=0';
  742. $res_answer = api_sql_query($sql_answer, __FILE__, __LINE__);
  743. // getting the real answer
  744. $real_list =array();
  745. while($real_answer = Database::fetch_array($res_answer)) {
  746. $real_list[$real_answer['position']]= $real_answer['answer'];
  747. }
  748. $res_answers = api_sql_query($sql_select_answer, __FILE__, __LINE__);
  749. echo '<table width="100%" height="71" border="0" cellspacing="3" cellpadding="3" >';
  750. echo '<tr><td colspan="2">&nbsp;</td></tr>';
  751. echo '<tr>
  752. <td><span style="font-style: italic;">'.get_lang("ElementList").'</span> </td>
  753. <td><span style="font-style: italic;">'.get_lang("CorrespondsTo").'</span></td>
  754. </tr>';
  755. echo '<tr><td colspan="2">&nbsp;</td></tr>';
  756. $questionScore=0;
  757. while($a_answers = Database::fetch_array($res_answers)) {
  758. $i_answer_id = $a_answers['id']; //3
  759. $s_answer_label = $a_answers['answer']; // your dady - you mother
  760. $i_answer_correct_answer = $a_answers['correct']; //1 - 2
  761. $i_answer_position = $a_answers['position']; // 3 - 4
  762. $sql_user_answer =
  763. 'SELECT answers.answer
  764. FROM '.$TBL_TRACK_ATTEMPT.' as track_e_attempt
  765. INNER JOIN '.$table_ans.' as answers
  766. ON answers.position = track_e_attempt.answer
  767. AND track_e_attempt.question_id=answers.question_id
  768. WHERE answers.correct = 0
  769. AND track_e_attempt.exe_id = "'.Database::escape_string($id).'"
  770. AND track_e_attempt.question_id = "'.Database::escape_string($questionId).'"
  771. AND track_e_attempt.position="'.Database::escape_string($i_answer_position).'"';
  772. $res_user_answer = api_sql_query($sql_user_answer, __FILE__, __LINE__);
  773. if (Database::num_rows($res_user_answer)>0 )
  774. $s_user_answer = Database::result($res_user_answer,0,0); // rich - good looking
  775. else
  776. $s_user_answer = '';
  777. //$s_correct_answer = $s_answer_label; // your ddady - your mother
  778. $s_correct_answer = $real_list[$i_answer_correct_answer];
  779. $i_answerWeighting=$objAnswerTmp->selectWeighting($i_answer_id);
  780. //if($s_user_answer == $s_correct_answer) // rich == your ddady?? wrong
  781. //echo $s_user_answer.' - '.$real_list[$i_answer_correct_answer];
  782. if($s_user_answer == $real_list[$i_answer_correct_answer]) // rich == your ddady?? wrong
  783. {
  784. $questionScore+=$i_answerWeighting;
  785. $totalScore+=$i_answerWeighting;
  786. }
  787. else
  788. {
  789. $s_user_answer = '<span style="color: #FF0000; text-decoration: line-through;">'.$s_user_answer.'</span>';
  790. }
  791. echo '<tr>';
  792. echo '<td>'.$s_answer_label.'</td><td>'.$s_user_answer.' / <b><span style="color: #008000;">'.$s_correct_answer.'</span></b></td>';
  793. echo '</tr>';
  794. }
  795. echo '</table>';
  796. } else if($answerType == HOTSPOT) {
  797. ?>
  798. <table width="355" border="0">
  799. <tr>
  800. <td>&nbsp;</td>
  801. </tr>
  802. <?php
  803. $objAnswerTmp=new Answer($questionId);
  804. $nbrAnswers=$objAnswerTmp->selectNbrAnswers();
  805. $questionScore=0;
  806. ?>
  807. <tr>
  808. <td valign="top" align="left" style="padding-left:0px;" >
  809. <table style="border: 1px solid #4271b5;border-bottom:none" width="556px">
  810. <?php
  811. for($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
  812. $answer=$objAnswerTmp->selectAnswer($answerId);
  813. $answerComment=$objAnswerTmp->selectComment($answerId);
  814. $answerCorrect=$objAnswerTmp->isCorrect($answerId);
  815. $answerWeighting=$objAnswerTmp->selectWeighting($answerId);
  816. $TBL_TRACK_HOTSPOT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
  817. $query = "select hotspot_correct from ".$TBL_TRACK_HOTSPOT." where hotspot_exe_id = '".Database::escape_string($id)."' and hotspot_question_id= '".Database::escape_string($questionId)."' AND hotspot_answer_id='".Database::escape_string($answerId)."'";
  818. $resq=api_sql_query($query);
  819. $choice = Database::result($resq,0,"hotspot_correct");
  820. display_hotspot_answer($answerId,$answer,$choice,$answerComment);
  821. $i++;
  822. }
  823. $queryfree = "select marks from ".$TBL_TRACK_ATTEMPT." where exe_id = '".Database::escape_string($id)."' and question_id= '".Database::escape_string($questionId)."'";
  824. $resfree = api_sql_query($queryfree, __FILE__, __LINE__);
  825. $questionScore= Database::result($resfree,0,"marks");
  826. $totalScore+=$questionScore;
  827. ?>
  828. </table>
  829. </td></tr>
  830. <?php
  831. echo '
  832. <tr>
  833. <td colspan="2">
  834. <object type="application/x-shockwave-flash" data="../plugin/hotspot/hotspot_solution.swf?modifyAnswers='.$questionId.'&exe_id='.$id.'&from_db=0" width="556" height="421">
  835. <param name="movie" value="../plugin/hotspot/hotspot_solution.swf?modifyAnswers='.$questionId.'&exe_id='.$id.'&from_db=1" />
  836. </object>
  837. </td>
  838. </tr>
  839. </table><br/>';
  840. }
  841. ?>
  842. <table width="100%" border="0" cellspacing="3" cellpadding="0">
  843. <?php
  844. if($is_allowedToEdit) {
  845. ?>
  846. <tr>
  847. <td>
  848. <?php
  849. $name = "fckdiv".$questionId;
  850. $marksname = "marksName".$questionId;
  851. ?>
  852. <br />
  853. <a href="javascript://" onclick="showfck('<?php echo $name; ?>','<?php echo $marksname; ?>');">
  854. <?php
  855. if ($answerType == FREE_ANSWER)
  856. echo get_lang('EditCommentsAndMarks');
  857. else {
  858. if ($action=='edit')
  859. echo get_lang('EditIndividualComment');
  860. else {
  861. echo get_lang('AddComments');
  862. }
  863. }
  864. ?></a>
  865. <br />
  866. <div id="feedback_<?= $name ?>" style="width:100%">
  867. <?php
  868. $comnt = trim(get_comments($id,$questionId));
  869. if (empty($comnt)) {
  870. echo '<br />';
  871. } else {
  872. echo '<div id="question_feedback">'.$comnt.'</div>';
  873. }
  874. ?>
  875. </div>
  876. <div id="<?php echo $name; ?>" style="display:none">
  877. <?php
  878. $arrid[] = $questionId;
  879. $fck_attribute['Width'] = '100%';
  880. $fck_attribute['Height'] = '120';
  881. $fck_attribute['ToolbarSet'] = 'CommentAnswers';
  882. $fck_attribute['Config']['ToolbarStartExpanded']='false';
  883. $feedback_form = new FormValidator('frmcomments'.$questionId,'post','');
  884. $feedback_form->addElement('html','<br>');
  885. $renderer =& $feedback_form->defaultRenderer();
  886. $renderer->setFormTemplate('<form{attributes}><div align="left">{content}</div></form>');
  887. $renderer->setElementTemplate('<div align="left">{element}</div>');
  888. $comnt =get_comments($id,$questionId);
  889. ${user.$questionId}['comments_'.$questionId] = $comnt;
  890. $feedback_form->addElement('html_editor','comments_'.$questionId,false);
  891. $feedback_form->addElement('html','<br>');
  892. //$feedback_form->addElement('submit','submitQuestion',get_lang('Ok'));
  893. $feedback_form->setDefaults(${user.$questionId});
  894. $feedback_form->display();
  895. echo '</div>';
  896. } else {
  897. $comnt = get_comments($id,$questionId);
  898. ?>
  899. <tr>
  900. <td>
  901. <br />
  902. <?php
  903. if (!empty($comnt)) {
  904. echo '<b>'.get_lang('FeedbackType').'</b>';
  905. echo '<div id="question_feedback">'.$comnt.'</div>';
  906. }
  907. ?>
  908. </td>
  909. <td>
  910. <?php
  911. }
  912. ?>
  913. <?php
  914. if($is_allowedToEdit) {
  915. if ($answerType == FREE_ANSWER) {
  916. $marksname = "marksName".$questionId;
  917. ?>
  918. <div id="<?php echo $marksname; ?>" style="display:none">
  919. <form name="marksform_<?php echo $questionId; ?>" method="post" action="">
  920. <?php
  921. $arrmarks[] = $questionId;
  922. echo get_lang("AssignMarks");
  923. echo "&nbsp;<select name='marks' id='marks'>";
  924. for($i=0;$i<=$questionWeighting;$i++) {
  925. ?>
  926. <option <?php if ($i==$questionScore) echo "selected='selected'";?>>
  927. <?php echo $i;
  928. ?></option>
  929. <?php } ?>
  930. </select>
  931. </form><br/ ></div><?php
  932. if($questionScore==-1) {
  933. $questionScore=0;
  934. echo '<br />'.get_lang('notCorrectedYet');
  935. }
  936. } else {
  937. $arrmarks[] = $questionId;
  938. echo '<div id="'.$marksname.'" style="display:none"><form name="marksform_'.$questionId.'" method="post" action="">
  939. <select name="marks" id="marks" style="display:none;"><option>'.$questionScore.'</option></select></form><br/ ></div>';
  940. }
  941. } else {
  942. if($questionScore==-1) {
  943. $questionScore=0;
  944. }
  945. }
  946. ?>
  947. </td>
  948. </tr>
  949. </table>
  950. <div id="question_score">
  951. <?php
  952. $my_total_score = float_format($questionScore,1);
  953. $my_total_weight = float_format($questionWeighting,1);
  954. echo get_lang('Score')." : $my_total_score/$my_total_weight";
  955. ?>
  956. </div>
  957. <?php
  958. unset($objAnswerTmp);
  959. $i++;
  960. $totalWeighting+=$questionWeighting;
  961. }
  962. if($origin!='learnpath') {
  963. //$query = "update ".$TBL_TRACK_EXERCICES." set exe_result = $totalScore where exe_id = '$id'";
  964. //api_sql_query($query,__FILE__,__LINE__);
  965. if ($show_results) {
  966. echo '<div id="question_score">'.get_lang('YourTotalScore')." ";
  967. if($dsp_percent == true) {
  968. $my_result = number_format(($totalScore/$totalWeighting)*100,1,'.','');
  969. $my_result = float_format($my_result,1);
  970. echo $my_result."%";
  971. } else {
  972. $my_total_score = float_format($totalScore,1);
  973. $my_total_weight = float_format($totalWeighting,1);
  974. echo $my_total_score."/".$my_total_weight;
  975. }
  976. echo '!</div>';
  977. }
  978. } else {
  979. echo '<br /><br />';
  980. Display::display_normal_message(get_lang('ExerciseFinished'));
  981. echo '<br />';
  982. }
  983. if (is_array($arrid) && is_array($arrmarks)) {
  984. $strids = implode(",",$arrid);
  985. $marksid = implode(",",$arrmarks);
  986. }
  987. if($is_allowedToEdit) {
  988. if (in_array($origin, array('tracking_course','user_course'))) {
  989. echo ' <form name="myform" id="myform" action="exercice.php?show=result&comments=update&exeid='.$id.'&test='.urlencode($test).'&emailid='.$emailId.'&origin='.$origin.'&student='.$_GET['student'].'&details=true&course='.$_GET['cidReq'].'" method="post">';
  990. if (isset($_GET['myid']) && isset($_GET['my_lp_id']) && isset($_GET['student'])) {
  991. ?>
  992. <input type = "hidden" name="lp_item_id" value="<?php echo Security::remove_XSS($_GET['myid']); ?>">
  993. <input type = "hidden" name="lp_item_view_id" value="<?php echo Security::remove_XSS($_GET['my_lp_id']); ?>">
  994. <input type = "hidden" name="student_id" value="<?php echo Security::remove_XSS($_GET['student']);?>">
  995. <input type = "hidden" name="total_score" value="<?php echo $totalScore; ?>">
  996. <input type = "hidden" name="total_time" value="<?php echo Security::remove_XSS($_GET['total_time']);?>">
  997. <input type = "hidden" name="totalWeighting" value="<?php echo $totalWeighting; ?>">
  998. <?php
  999. }
  1000. } else {
  1001. echo ' <form name="myform" id="myform" action="exercice.php?show=result&comments=update&exeid='.$id.'&test='.$test.'&emailid='.$emailId.'&totalWeighting='.$totalWeighting.'" method="post">';
  1002. }
  1003. if ($origin!='learnpath' && $origin!='student_progress') {
  1004. ?>
  1005. <button type="submit" class="save" value="<?php echo get_lang('Ok'); ?>" onclick="getFCK('<?php echo $strids; ?>','<?php echo $marksid; ?>');"><?php echo get_lang('FinishTest'); ?></button>
  1006. </form>
  1007. <?php
  1008. }
  1009. }
  1010. if ($origin=='student_progress') {?>
  1011. <button type="button" class="save" onclick="top.location.href='../newscorm/lp_controller.php?cidReq=<?php echo api_get_course_id()?>&amp;action=view&amp;lp_id=<?php echo $learnpath_id ?>&amp;lp_item_id=<?php echo $learnpath_item_id ?>&amp;exeId=<?php echo $exeId ?>'" value="<?php echo get_lang('Finish'); ?>" ><?php echo get_lang('Finish');?></button>
  1012. <?php } else if($origin=='myprogress') {?>
  1013. <button type="button" class="save" onclick="top.location.href='../auth/my_progress.php?course=<?php echo api_get_course_id()?>'" value="<?php echo get_lang('Finish'); ?>" ><?php echo get_lang('Finish');?></button>
  1014. <?php }
  1015. if ($origin != 'learnpath') {
  1016. //we are not in learnpath tool
  1017. Display::display_footer();
  1018. } else {
  1019. $lp_mode = $_SESSION['lp_mode'];
  1020. if ($lp_mode == 'fullscreen') {
  1021. ?>
  1022. <button type="button" class="save" onclick="window.opener.location.href='../newscorm/lp_controller.php?cidReq=<?php echo api_get_course_id()?>&amp;action=view&amp;lp_id=<?php echo $learnpath_id ?>&amp;lp_item_id=<?php echo $learnpath_item_id ?>&amp;exeId=<?php echo $exeId ?>';window.close()" value="<?php echo get_lang('Finish'); ?>"><?php echo get_lang('Finish');?></button>
  1023. <?php } else { ?>
  1024. <button type="button" class="save" onclick="top.location.href='../newscorm/lp_controller.php?cidReq=<?php echo api_get_course_id()?>&amp;action=view&amp;lp_id=<?php echo $learnpath_id ?>&amp;lp_item_id=<?php echo $learnpath_item_id ?>&amp;exeId=<?php echo $exeId ?>';" value="<?php echo get_lang('Finish'); ?>"><?php echo get_lang('Finish');?></button>
  1025. <?php }
  1026. //record the results in the learning path, using the SCORM interface (API)
  1027. echo '<script language="javascript" type="text/javascript">window.parent.API.void_save_asset('.$totalScore.','.$totalWeighting.');</script>'."\n";
  1028. echo '</body></html>';
  1029. }
  1030. //destroying the session
  1031. api_session_unregister('questionList');
  1032. unset ($questionList);
  1033. api_session_unregister('exerciseResult');
  1034. unset ($exerciseResult);
  1035. ?>