exercise_show.php 39 KB

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