exercise_show.php 40 KB

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