exercise_show.php 39 KB

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