exercice_submit.php 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102
  1. <?php // $Id: exercice_submit.php 20089 2009-04-24 21:12:54Z cvargas1 $
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004-2008 Dokeos SPRL
  6. Copyright (c) 2003 Ghent University (UGent)
  7. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  8. Copyright (c) various contributors
  9. For a full list of contributors, see "credits.txt".
  10. The full license can be read in "license.txt".
  11. This program is free software; you can redistribute it and/or
  12. modify it under the terms of the GNU General Public License
  13. as published by the Free Software Foundation; either version 2
  14. of the License, or (at your option) any later version.
  15. See the GNU General Public License for more details.
  16. Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
  17. Mail: info@dokeos.com
  18. ==============================================================================
  19. */
  20. /**
  21. * Exercise submission
  22. * This script allows to run an exercise. According to the exercise type, questions
  23. * can be on an unique page, or one per page with a Next button.
  24. *
  25. * One exercise may contain different types of answers (unique or multiple selection,
  26. * matching, fill in blanks, free answer, hot-spot).
  27. *
  28. * Questions are selected randomly or not.
  29. *
  30. * When the user has answered all questions and clicks on the button "Ok",
  31. * it goes to exercise_result.php
  32. *
  33. * Notice : This script is also used to show a question before modifying it by
  34. * the administrator
  35. * @package dokeos.exercise
  36. * @author Olivier Brouckaert
  37. * @author Julio Montoya multiple fill in blank option added
  38. * @version $Id: exercice_submit.php 20089 2009-04-24 21:12:54Z cvargas1 $
  39. */
  40. include('exercise.class.php');
  41. include('question.class.php');
  42. include('answer.class.php');
  43. include('exercise.lib.php');
  44. // debug var. Set to 0 to hide all debug display. Set to 1 to display debug messages.
  45. $debug = 0;
  46. /*
  47. // answer types
  48. define('UNIQUE_ANSWER', 1);
  49. define('MULTIPLE_ANSWER', 2);
  50. define('FILL_IN_BLANKS', 3);
  51. define('MATCHING', 4);
  52. define('FREE_ANSWER', 5);
  53. define('HOT_SPOT', 6);
  54. define('HOT_SPOT_ORDER', 7);
  55. */
  56. // name of the language file that needs to be included
  57. $language_file='exercice';
  58. include_once('../inc/global.inc.php');
  59. $this_section=SECTION_COURSES;
  60. /* ------------ ACCESS RIGHTS ------------ */
  61. // notice for unauthorized people.
  62. api_protect_course_script(true);
  63. include_once(api_get_path(LIBRARY_PATH).'text.lib.php');
  64. $is_allowedToEdit=api_is_allowed_to_edit();
  65. $_configuration['live_exercise_tracking'] = true;
  66. $stat_table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
  67. $exercice_attemp_table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
  68. $TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
  69. $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
  70. $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
  71. $TBL_REPONSES = Database::get_course_table(TABLE_QUIZ_ANSWER);
  72. // general parameters passed via POST/GET
  73. if ( empty ( $origin ) ) {
  74. $origin = $_REQUEST['origin'];
  75. }
  76. if ( empty ( $learnpath_id ) ) {
  77. $learnpath_id = Database::escape_string($_REQUEST['learnpath_id']);
  78. }
  79. if ( empty ( $learnpath_item_id ) ) {
  80. $learnpath_item_id = Database::escape_string($_REQUEST['learnpath_item_id']);
  81. }
  82. if ( empty ( $formSent ) ) {
  83. $formSent = $_REQUEST['formSent'];
  84. }
  85. if ( empty ( $exerciseResult ) ) {
  86. $exerciseResult = $_REQUEST['exerciseResult'];
  87. }
  88. if ( empty ( $exerciseResultCoordinates ) ) {
  89. $exerciseResultCoordinates = $_REQUEST['exerciseResultCoordinates'];
  90. }
  91. if ( empty ( $exerciseType ) ) {
  92. $exerciseType = $_REQUEST['exerciseType'];
  93. }
  94. if ( empty ( $exerciseId ) ) {
  95. $exerciseId = intval($_REQUEST['exerciseId']);
  96. }
  97. if ( empty ( $choice ) ) {
  98. $choice = $_REQUEST['choice'];
  99. }
  100. if (empty($_REQUEST['choice'])) {
  101. $choice = $_REQUEST['choice2'];
  102. }
  103. if ( empty ( $questionNum ) ) {
  104. $questionNum = Database::escape_string($_REQUEST['questionNum']);
  105. }
  106. if ( empty ( $nbrQuestions ) ) {
  107. $nbrQuestions = Database::escape_string($_REQUEST['nbrQuestions']);
  108. }
  109. if ( empty ($buttonCancel) ) {
  110. $buttonCancel = $_REQUEST['buttonCancel'];
  111. }
  112. $error = '';
  113. if (!isset($exerciseType)) {
  114. $exe_start_date= time();
  115. $_SESSION['exercice_start_date'] = $exe_start_date;
  116. }
  117. // if the user has clicked on the "Cancel" button
  118. if($buttonCancel)
  119. {
  120. // returns to the exercise list
  121. header("Location: exercice.php?origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id");
  122. exit();
  123. }
  124. if ($origin == 'learnpath' && isset($_GET['not_multiple_attempt']) && $_GET['not_multiple_attempt'] == strval(intval($_GET['not_multiple_attempt']))) {
  125. $not_multiple_attempt = (int)$_GET['not_multiple_attempt'];
  126. if ($not_multiple_attempt === 1) {
  127. include_once('../inc/reduced_header.inc.php');
  128. Display::display_warning_message(get_lang('ReachedOneAttempt'));
  129. exit;
  130. }
  131. }
  132. if ($origin=='builder') {
  133. /*******************************/
  134. /* Clears the exercise session */
  135. /*******************************/
  136. if(isset($_SESSION['objExercise'])) { api_session_unregister('objExercise'); unset($objExercise); }
  137. if(isset($_SESSION['objQuestion'])) { api_session_unregister('objQuestion'); unset($objQuestion); }
  138. if(isset($_SESSION['objAnswer'])) { api_session_unregister('objAnswer'); unset($objAnswer); }
  139. if(isset($_SESSION['questionList'])) { api_session_unregister('questionList'); unset($questionList); }
  140. if(isset($_SESSION['newquestionList'])) { api_session_unregister('newquestionList'); unset($newquestionList); }
  141. if(isset($_SESSION['exerciseResult'])) { api_session_unregister('exerciseResult'); unset($exerciseResult); }
  142. if(isset($_SESSION['exerciseResultCoordinates'])) { api_session_unregister('exerciseResultCoordinates'); unset($exerciseResultCoordinates); }
  143. }
  144. $safe_lp_id = ($learnpath_id=='')?0:(int)$learnpath_id;
  145. $safe_lp_item_id = ($learnpath_item_id=='')?0:(int)$learnpath_item_id;
  146. $condition = ' WHERE ' .
  147. 'exe_exo_id = '."'".$exerciseId."'".' AND ' .
  148. 'exe_user_id = '."'".api_get_user_id()."'".' AND ' .
  149. 'exe_cours_id = '."'".$_course['id']."'".' AND ' .
  150. 'status = '."'incomplete'".' AND '.
  151. 'orig_lp_id = '."'".$safe_lp_id."'".' AND '.
  152. 'orig_lp_item_id = '."'".$safe_lp_item_id."'".' AND '.
  153. 'session_id = '."'".(int)$_SESSION['id_session']."'";
  154. $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
  155. $result=api_sql_query("SELECT type,feedback_type FROM $TBL_EXERCICES WHERE id=$exerciseId",__FILE__,__LINE__);
  156. $exercise_row = Database::fetch_array($result);
  157. $exerciseType = $exercise_row['type'];
  158. $exerciseFeedbackType= $exercise_row['feedback_type'];
  159. if ($_configuration['live_exercise_tracking'] == true && $exerciseType == 2 && $exerciseFeedbackType!=1) {
  160. $query = 'SELECT * FROM '.$stat_table.$condition;
  161. $result_select = api_sql_query($query,__FILE__,__LINE__);
  162. if(Database::num_rows($result_select) > 0 ){
  163. $getIncomplete = Database::fetch_array($result_select);
  164. $exe_id = $getIncomplete['exe_id'];
  165. if ($_SERVER['REQUEST_METHOD']!='POST') {
  166. define('QUESTION_LIST_ALREADY_LOGGED',1);
  167. $recorded['questionList'] = explode(',',$getIncomplete['data_tracking']);
  168. $query = 'SELECT * FROM '.$exercice_attemp_table.' WHERE exe_id = '.$getIncomplete['exe_id'].' ORDER BY tms ASC';
  169. $result = api_sql_query($query,__FILE__,__LINE__);
  170. while ($row = Database::fetch_array($result)) {
  171. $recorded['exerciseResult'][$row['question_id']] = 1;
  172. }
  173. $exerciseResult = $_SESSION['exerciseResult'] = $recorded['exerciseResult'];
  174. $exerciseType = 2;
  175. $questionNum = count($recorded['exerciseResult']);
  176. $questionNum++;
  177. $questionList = $_SESSION['questionList'] = $recorded['questionList'];
  178. }
  179. } else {
  180. $table_recorded_not_exist = true;
  181. }
  182. }
  183. // if the user has submitted the form
  184. if ($formSent) {
  185. if ($debug>0) {
  186. echo str_repeat('&nbsp;',0).'$formSent was set'."<br />\n";
  187. }
  188. // initializing
  189. if (!is_array($exerciseResult)) {
  190. $exerciseResult=array();
  191. $exerciseResultCoordinates=array();
  192. }
  193. // if the user has answered at least one question
  194. if (is_array($choice)) {
  195. if ($debug>0) {
  196. echo str_repeat('&nbsp;',0).'$choice is an array'."<br />\n";
  197. }
  198. if ($exerciseType == 1) {
  199. // $exerciseResult receives the content of the form.
  200. // Each choice of the student is stored into the array $choice
  201. $exerciseResult=$choice;
  202. if (isset($_POST['hotspot'])) {
  203. $exerciseResultCoordinates = $_POST['hotspot'];
  204. }
  205. } else {
  206. // gets the question ID from $choice. It is the key of the array
  207. list($key)=array_keys($choice);
  208. // if the user didn't already answer this question
  209. if (!isset($exerciseResult[$key])) {
  210. // stores the user answer into the array
  211. $exerciseResult[$key]=$choice[$key];
  212. //saving each question
  213. if ($_configuration['live_exercise_tracking'] == true && $exerciseType == 2 && $exerciseFeedbackType!=1) {
  214. $nro_question = $questionNum;// - 1;
  215. //START of saving and qualifying each question submitted
  216. //------------------------------------------------------------------------------------------
  217. //
  218. define('ENABLED_LIVE_EXERCISE_TRACKING',1);
  219. require_once 'question.class.php';
  220. require_once 'answer.class.php';
  221. require_once(api_get_path(LIBRARY_PATH).'events.lib.inc.php');
  222. $counter=0;
  223. $main_course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  224. $table_ans = Database :: get_course_table(TABLE_QUIZ_ANSWER);
  225. //foreach($questionList as $questionId)
  226. if (true) {
  227. $exeId = $exe_id;
  228. $questionId = $key;
  229. $counter++;
  230. // gets the student choice for this question
  231. $choice=$exerciseResult[$questionId];
  232. // creates a temporary Question object
  233. $objQuestionTmp = Question :: read($questionId);
  234. $questionName=$objQuestionTmp->selectTitle();
  235. $questionDescription=$objQuestionTmp->selectDescription();
  236. $questionWeighting=$objQuestionTmp->selectWeighting();
  237. $answerType=$objQuestionTmp->selectType();
  238. $quesId =$objQuestionTmp->selectId(); //added by priya saini
  239. // destruction of the Question object
  240. unset($objQuestionTmp);
  241. // construction of the Answer object
  242. $objAnswerTmp=new Answer($questionId);
  243. $nbrAnswers=$objAnswerTmp->selectNbrAnswers();
  244. $questionScore=0;
  245. if ($answerType == FREE_ANSWER) {
  246. $nbrAnswers = 1;
  247. }
  248. for ($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
  249. $answer=$objAnswerTmp->selectAnswer($answerId);
  250. $answerComment=$objAnswerTmp->selectComment($answerId);
  251. $answerCorrect=$objAnswerTmp->isCorrect($answerId);
  252. $answerWeighting=$objAnswerTmp->selectWeighting($answerId);
  253. switch ($answerType) {
  254. // for unique answer
  255. case UNIQUE_ANSWER :
  256. $studentChoice=($choice == $answerId)?1:0;
  257. if ($studentChoice) {
  258. $questionScore+=$answerWeighting;
  259. $totalScore+=$answerWeighting;
  260. }
  261. break;
  262. // for multiple answers
  263. case MULTIPLE_ANSWER :
  264. $studentChoice=$choice[$answerId];
  265. if ($studentChoice) {
  266. $questionScore+=$answerWeighting;
  267. $totalScore+=$answerWeighting;
  268. }
  269. break;
  270. // for fill in the blanks
  271. case FILL_IN_BLANKS :
  272. // the question is encoded like this
  273. // [A] B [C] D [E] F::10,10,10@1
  274. // number 1 before the "@" means that is a switchable fill in blank question
  275. // [A] B [C] D [E] F::10,10,10@ or [A] B [C] D [E] F::10,10,10
  276. // means that is a normal fill blank question
  277. // first we explode the "::"
  278. $pre_array = explode('::', $answer);
  279. // is switchable fill blank or not
  280. $last = count($pre_array)-1;
  281. $is_set_switchable = explode('@', $pre_array[$last]);
  282. $switchable_answer_set=false;
  283. if (isset($is_set_switchable[1]) && $is_set_switchable[1]==1) {
  284. $switchable_answer_set=true;
  285. }
  286. $answer = '';
  287. for ($k=0; $k<$last; $k++) {
  288. $answer .= $pre_array[$k];
  289. }
  290. // splits weightings that are joined with a comma
  291. $answerWeighting = explode(',',$is_set_switchable[0]);
  292. // we save the answer because it will be modified
  293. $temp=$answer;
  294. // TeX parsing
  295. // 1. find everything between the [tex] and [/tex] tags
  296. $startlocations=strpos($temp,'[tex]');
  297. $endlocations=strpos($temp,'[/tex]');
  298. if ($startlocations !== false && $endlocations !== false) {
  299. $texstring=substr($temp,$startlocations,$endlocations-$startlocations+6);
  300. // 2. replace this by {texcode}
  301. $temp=str_replace($texstring,'{texcode}',$temp);
  302. }
  303. $answer='';
  304. $j=0;
  305. //initialise answer tags
  306. $user_tags=array();
  307. $correct_tags=array();
  308. $real_text=array();
  309. // the loop will stop at the end of the text
  310. while (1) {
  311. // quits the loop if there are no more blanks (detect '[')
  312. if (($pos = strpos($temp,'[')) === false) {
  313. // adds the end of the text
  314. $answer=$temp;
  315. // TeX parsing - replacement of texcode tags
  316. $texstring = api_parse_tex($texstring);
  317. $answer=str_replace("{texcode}",$texstring,$answer);
  318. $real_text[] = $answer;
  319. break; //no more "blanks", quit the loop
  320. }
  321. // adds the piece of text that is before the blank
  322. //and ends with '[' into a general storage array
  323. $real_text[]=substr($temp,0,$pos+1);
  324. $answer.=substr($temp,0,$pos+1);
  325. //take the string remaining (after the last "[" we found)
  326. $temp=substr($temp,$pos+1);
  327. // quit the loop if there are no more blanks, and update $pos to the position of next ']'
  328. if (($pos = strpos($temp,']')) === false) {
  329. // adds the end of the text
  330. $answer.=$temp;
  331. break;
  332. }
  333. $choice[$j]=trim($choice[$j]);
  334. $user_tags[]=stripslashes(strtolower($choice[$j]));
  335. //put the contents of the [] answer tag into correct_tags[]
  336. $correct_tags[]=strtolower(substr($temp,0,$pos));
  337. $j++;
  338. $temp=substr($temp,$pos+1);
  339. //$answer .= ']';
  340. }
  341. $answer='';
  342. $real_correct_tags = $correct_tags;
  343. $chosen_list=array();
  344. for ($i=0;$i<count($real_correct_tags);$i++) {
  345. if ($i==0) {
  346. $answer.=$real_text[0];
  347. }
  348. if (!$switchable_answer_set) {
  349. if ($correct_tags[$i]==$user_tags[$i]) {
  350. // gives the related weighting to the student
  351. $questionScore+=$answerWeighting[$i];
  352. // increments total score
  353. $totalScore+=$answerWeighting[$i];
  354. // adds the word in green at the end of the string
  355. $answer.=stripslashes($correct_tags[$i]);
  356. }
  357. // else if the word entered by the student IS NOT the same as the one defined by the professor
  358. elseif(!empty($user_tags[$i])) {
  359. // adds the word in red at the end of the string, and strikes it
  360. $answer.='<font color="red"><s>'.stripslashes($user_tags[$i]).'</s></font>';
  361. } else {
  362. // adds a tabulation if no word has been typed by the student
  363. $answer.='&nbsp;&nbsp;&nbsp;';
  364. }
  365. } else {
  366. // switchable fill in the blanks
  367. if (in_array($user_tags[$i],$correct_tags)) {
  368. $chosen_list[]=$user_tags[$i];
  369. $correct_tags=array_diff($correct_tags,$chosen_list);
  370. // gives the related weighting to the student
  371. $questionScore+=$answerWeighting[$i];
  372. // increments total score
  373. $totalScore+=$answerWeighting[$i];
  374. // adds the word in green at the end of the string
  375. $answer.=stripslashes($user_tags[$i]);
  376. } elseif(!empty($user_tags[$i])) {
  377. // else if the word entered by the student IS NOT the same as the one defined by the professor
  378. // adds the word in red at the end of the string, and strikes it
  379. $answer.='<font color="red"><s>'.stripslashes($user_tags[$i]).'</s></font>';
  380. } else {
  381. // adds a tabulation if no word has been typed by the student
  382. $answer.='&nbsp;&nbsp;&nbsp;';
  383. }
  384. }
  385. // adds the correct word, followed by ] to close the blank
  386. $answer.=' / <font color="green"><b>'.$real_correct_tags[$i].'</b></font>]';
  387. if ( isset( $real_text[$i+1] ) ) {
  388. $answer.=$real_text[$i+1];
  389. }
  390. }
  391. break;
  392. // for free answer
  393. case FREE_ANSWER :
  394. $studentChoice=$choice;
  395. if ($studentChoice) {
  396. //Score is at -1 because the question has'nt been corected
  397. $questionScore=-1;
  398. $totalScore+=0;
  399. }
  400. break;
  401. // for matching
  402. case MATCHING :
  403. if ($answerCorrect) {
  404. if ($answerCorrect == $choice[$answerId]) {
  405. $questionScore+=$answerWeighting;
  406. $totalScore+=$answerWeighting;
  407. $choice[$answerId]=$matching[$choice[$answerId]];
  408. } elseif(!$choice[$answerId]) {
  409. $choice[$answerId]='&nbsp;&nbsp;&nbsp;';
  410. } else {
  411. $choice[$answerId]='<font color="red"><s>'.$matching[$choice[$answerId]].'</s></font>';
  412. }
  413. } else {
  414. $matching[$answerId]=$answer;
  415. }
  416. break;
  417. // for hotspot with no order
  418. case HOT_SPOT : $studentChoice=$choice[$answerId];
  419. if($studentChoice) {
  420. $questionScore+=$answerWeighting;
  421. $totalScore+=$answerWeighting;
  422. }
  423. $tbl_track_e_hotspot = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
  424. // Save into db
  425. $sql = "INSERT INTO $tbl_track_e_hotspot (`hotspot_user_id` , `hotspot_course_code` , `hotspot_exe_id` , `hotspot_question_id` , `hotspot_answer_id` , `hotspot_correct` , `hotspot_coordinate` )
  426. VALUES ('".Database::escape_string($_user['user_id'])."', '".Database::escape_string($_course['id'])."', '".Database::escape_string($exeId)."', '".Database::escape_string($questionId)."', '".Database::escape_string($answerId)."', '".Database::escape_string($studentChoice)."', '".Database::escape_string($_SESSION['exerciseResultCoordinates'][$questionId][$answerId])."')";
  427. $result = api_sql_query($sql,__FILE__,__LINE__);
  428. break;
  429. // for hotspot with fixed order
  430. case HOT_SPOT_ORDER : $studentChoice=$choice['order'][$answerId];
  431. if ($studentChoice == $answerId) {
  432. $questionScore+=$answerWeighting;
  433. $totalScore+=$answerWeighting;
  434. $studentChoice = true;
  435. } else {
  436. $studentChoice = false;
  437. }
  438. break;
  439. } // end switch Answertype
  440. } // end for that loops over all answers of the current question
  441. // destruction of Answer
  442. unset($objAnswerTmp);
  443. $i++;
  444. $totalWeighting+=$questionWeighting;
  445. //added by priya saini
  446. if ($_configuration['tracking_enabled']) {
  447. if (empty($choice)) {
  448. $choice = 0;
  449. }
  450. if ($answerType==MULTIPLE_ANSWER ) {
  451. if ($choice != 0) {
  452. $reply = array_keys($choice);
  453. for ($i=0;$i<sizeof($reply);$i++) {
  454. $ans = $reply[$i];
  455. exercise_attempt($questionScore,$ans,$quesId,$exeId,$i);
  456. }
  457. } else {
  458. exercise_attempt($questionScore, 0 ,$quesId,$exeId,0);
  459. }
  460. } elseif ($answerType==MATCHING) {
  461. $j=sizeof($matching)+1;
  462. for ($i=0;$i<sizeof($choice);$i++,$j++) {
  463. $val = $choice[$j];
  464. if (preg_match_all ('#<font color="red"><s>([0-9a-z ]*)</s></font>#', $val, $arr1)) {
  465. $val = $arr1[1][0];
  466. }
  467. $val=addslashes($val);
  468. $val=strip_tags($val);
  469. $sql = "select position from $table_ans where question_id='".Database::escape_string($questionId)."' and answer='".Database::escape_string($val)."' AND correct=0";
  470. $res = api_sql_query($sql, __FILE__, __LINE__);
  471. if (Database::num_rows($res)>0) {
  472. $answer = Database::result($res,0,"position");
  473. } else {
  474. $answer = '';
  475. }
  476. exercise_attempt($questionScore,$answer,$quesId,$exeId,$j);
  477. }
  478. } elseif ($answerType==FREE_ANSWER) {
  479. $answer = $choice;
  480. exercise_attempt($questionScore,$answer,$quesId,$exeId,0);
  481. } elseif ($answerType==UNIQUE_ANSWER) {
  482. $sql = "select id from $table_ans where question_id='".Database::escape_string($questionId)."' and position='".Database::escape_string($choice)."'";
  483. $res = api_sql_query($sql, __FILE__, __LINE__);
  484. $answer = Database::result($res,0,"id");
  485. exercise_attempt($questionScore,$answer,$quesId,$exeId,0);
  486. } else {
  487. exercise_attempt($questionScore,$answer,$quesId,$exeId,0);
  488. }
  489. }
  490. }
  491. // end huge foreach() block that loops over all questions
  492. //at loops over all questions
  493. $sql_update = 'UPDATE '.$stat_table.' SET exe_result = exe_result + '.(int)$totalScore.',exe_weighting = exe_weighting + '.(int)$totalWeighting.' WHERE exe_id = '.$exe_id;
  494. api_sql_query($sql_update ,__FILE__,__LINE__);
  495. //END of saving and qualifying
  496. //------------------------------------------------------------------------------------------
  497. //
  498. }
  499. if (isset($_POST['hotspot'])) {
  500. $exerciseResultCoordinates[$key] = $_POST['hotspot'][$key];
  501. }
  502. }
  503. }
  504. if ($debug>0) {
  505. echo str_repeat('&nbsp;',0).'$choice is an array - end'."<br />\n";
  506. }
  507. }
  508. // the script "exercise_result.php" will take the variable $exerciseResult from the session
  509. api_session_register('exerciseResult');
  510. api_session_register('exerciseResultCoordinates');
  511. // if it is the last question (only for a sequential exercise)
  512. if($exerciseType == 1 || $questionNum >= $nbrQuestions) {
  513. if ($debug>0) {
  514. echo str_repeat('&nbsp;',0).'Redirecting to exercise_result.php - Remove debug option to let this happen'."<br />\n";
  515. }
  516. // goes to the script that will show the result of the exercise
  517. if ($exerciseType == 1) {
  518. header("Location: exercise_result.php?exerciseType=$exerciseType&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id");
  519. } else {
  520. if ($exe_id!='') {
  521. //clean incomplete
  522. $update_query = 'UPDATE '.$stat_table.' SET '."status = '', data_tracking='', exe_date = '".date('Y-m-d H:i:s')."'".' WHERE exe_id = '.$exe_id;
  523. api_sql_query($update_query,__FILE__,__LINE__);
  524. }
  525. header("Location: exercise_show.php?id=$exeId&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id");
  526. }
  527. exit();
  528. }
  529. if ($debug>0) {
  530. echo str_repeat('&nbsp;',0).'$formSent was set - end'."<br />\n";
  531. }
  532. }
  533. // if the object is not in the session
  534. //why destroying the exercise when a LP is loaded ?
  535. //if (!isset($_SESSION['objExercise']) || $origin == 'learnpath' || $_SESSION['objExercise']->id != $_REQUEST['exerciseId']) {
  536. if (!isset($_SESSION['objExercise']) || $_SESSION['objExercise']->id != $_REQUEST['exerciseId']) {
  537. if ($debug>0) {
  538. echo str_repeat('&nbsp;',0).'$_SESSION[objExercise] was unset'."<br />\n";
  539. }
  540. // construction of Exercise
  541. $objExercise=new Exercise();
  542. unset($_SESSION['questionList']);
  543. // if the specified exercise doesn't exist or is disabled
  544. if (!$objExercise->read($exerciseId) || (!$objExercise->selectStatus() && !$is_allowedToEdit && ($origin != 'learnpath') )) {
  545. unset($objExercise);
  546. $error = get_lang('ExerciseNotFound');
  547. //die(get_lang('ExerciseNotFound'));
  548. } else {
  549. // saves the object into the session
  550. api_session_register('objExercise');
  551. if ($debug>0) {
  552. echo str_repeat('&nbsp;',0).'$_SESSION[objExercise] was unset - set now - end'."<br />\n";
  553. }
  554. }
  555. }
  556. if (!isset($objExcercise) && isset($_SESSION['objExercise'])) {
  557. $objExercise = $_SESSION['objExercise'];
  558. }
  559. if (!is_object($objExercise)) {
  560. header('Location: exercice.php');
  561. exit();
  562. }
  563. $Exe_starttime = $objExercise->start_time;
  564. $Exe_endtime = $objExercise->end_time;
  565. $quizID = $objExercise->selectId();
  566. $exerciseAttempts=$objExercise->selectAttempts();
  567. $exerciseTitle=$objExercise->selectTitle();
  568. $exerciseDescription=$objExercise->selectDescription();
  569. $exerciseDescription=stripslashes($exerciseDescription);
  570. $exerciseSound=$objExercise->selectSound();
  571. $randomQuestions=$objExercise->isRandom();
  572. $exerciseType=$objExercise->selectType();
  573. $table_quiz_test= Database :: get_course_table(TABLE_QUIZ_TEST);
  574. //if (!isset($_SESSION['questionList']) || $origin == 'learnpath') {
  575. //in LP's is enabled the "remember question" feature?
  576. $my_exe_id=Security::remove_XSS($_GET['exerciseId']);
  577. if (!isset($_SESSION['questionList'])) {
  578. if ($debug>0){echo str_repeat('&nbsp;',0).'$_SESSION[questionList] was unset'."<br />\n";}
  579. // selects the list of question ID
  580. $my_question_list=array();
  581. $questionList = ($randomQuestions?$objExercise->selectRandomList():$objExercise->selectQuestionList());
  582. // saves the question list into the session
  583. $sql='SELECT random FROM '.$table_quiz_test.' WHERE id="'.Database::escape_string($my_exe_id).'";';
  584. $rs=api_sql_query($sql,__FILE__,__LINE__);
  585. $row_number=Database::fetch_array($rs);
  586. $z=0;
  587. if ($row_number['random']<>0) {
  588. foreach ($questionList as $infoquestionList) {
  589. if ($z<$row_number['random']) {
  590. $my_question_list[$z]=$infoquestionList;
  591. } else {
  592. break;
  593. }
  594. $z++;
  595. }
  596. // $questionList=array();
  597. $questionList=$my_question_list;
  598. }
  599. api_session_register('questionList');
  600. if ($debug>0){echo str_repeat('&nbsp;',0).'$_SESSION[questionList] was unset - set now - end'."<br />\n";}
  601. }
  602. if(!isset($objExcercise) && isset($_SESSION['objExercise'])) {
  603. $questionList = $_SESSION['questionList'];
  604. }
  605. $quizStartTime = time();
  606. api_session_register('quizStartTime');
  607. $nbrQuestions=sizeof($questionList);
  608. // if questionNum comes from POST and not from GET
  609. if(!$questionNum || $_POST['questionNum']) {
  610. // only used for sequential exercises (see $exerciseType)
  611. if(!$questionNum) {
  612. $questionNum=1;
  613. } else {
  614. $questionNum++;
  615. }
  616. }
  617. if (isset($_SESSION['gradebook'])){
  618. $gradebook= $_SESSION['gradebook'];
  619. }
  620. if (!empty($gradebook) && $gradebook=='view') {
  621. $interbreadcrumb[]= array (
  622. 'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
  623. 'name' => get_lang('Gradebook')
  624. );
  625. }
  626. //$nameTools=get_lang('Exercice');
  627. $interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices'));
  628. $interbreadcrumb[]=array("url" => "#","name" => $exerciseTitle);
  629. if ($origin != 'learnpath') { //so we are not in learnpath tool
  630. $htmlHeadXtra[] = "<script type=\"text/javascript\" src=\"../plugin/hotspot/JavaScriptFlashGateway.js\"></script>
  631. <script src=\"../plugin/hotspot/hotspot.js\" type=\"text/javascript\"></script>
  632. <script language=\"JavaScript\" type=\"text/javascript\">
  633. <!--
  634. // -----------------------------------------------------------------------------
  635. // Globals
  636. // Major version of Flash required
  637. var requiredMajorVersion = 7;
  638. // Minor version of Flash required
  639. var requiredMinorVersion = 0;
  640. // Minor version of Flash required
  641. var requiredRevision = 0;
  642. // the version of javascript supported
  643. var jsVersion = 1.0;
  644. // -----------------------------------------------------------------------------
  645. // -->
  646. </script>
  647. <script language=\"VBScript\" type=\"text/vbscript\">
  648. <!-- // Visual basic helper required to detect Flash Player ActiveX control version information
  649. Function VBGetSwfVer(i)
  650. on error resume next
  651. Dim swControl, swVersion
  652. swVersion = 0
  653. set swControl = CreateObject(\"ShockwaveFlash.ShockwaveFlash.\" + CStr(i))
  654. if (IsObject(swControl)) then
  655. swVersion = swControl.GetVariable(\"\$version\")
  656. end if
  657. VBGetSwfVer = swVersion
  658. End Function
  659. // -->
  660. </script>
  661. <script language=\"JavaScript1.1\" type=\"text/javascript\">
  662. <!-- // Detect Client Browser type
  663. var isIE = (navigator.appVersion.indexOf(\"MSIE\") != -1) ? true : false;
  664. var isWin = (navigator.appVersion.toLowerCase().indexOf(\"win\") != -1) ? true : false;
  665. var isOpera = (navigator.userAgent.indexOf(\"Opera\") != -1) ? true : false;
  666. jsVersion = 1.1;
  667. // JavaScript helper required to detect Flash Player PlugIn version information
  668. function JSGetSwfVer(i){
  669. // NS/Opera version >= 3 check for Flash plugin in plugin array
  670. if (navigator.plugins != null && navigator.plugins.length > 0) {
  671. if (navigator.plugins[\"Shockwave Flash 2.0\"] || navigator.plugins[\"Shockwave Flash\"]) {
  672. var swVer2 = navigator.plugins[\"Shockwave Flash 2.0\"] ? \" 2.0\" : \"\";
  673. var flashDescription = navigator.plugins[\"Shockwave Flash\" + swVer2].description;
  674. descArray = flashDescription.split(\" \");
  675. tempArrayMajor = descArray[2].split(\".\");
  676. versionMajor = tempArrayMajor[0];
  677. versionMinor = tempArrayMajor[1];
  678. if ( descArray[3] != \"\" ) {
  679. tempArrayMinor = descArray[3].split(\"r\");
  680. } else {
  681. tempArrayMinor = descArray[4].split(\"r\");
  682. }
  683. versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
  684. flashVer = versionMajor + \".\" + versionMinor + \".\" + versionRevision;
  685. } else {
  686. flashVer = -1;
  687. }
  688. }
  689. // MSN/WebTV 2.6 supports Flash 4
  690. else if (navigator.userAgent.toLowerCase().indexOf(\"webtv/2.6\") != -1) flashVer = 4;
  691. // WebTV 2.5 supports Flash 3
  692. else if (navigator.userAgent.toLowerCase().indexOf(\"webtv/2.5\") != -1) flashVer = 3;
  693. // older WebTV supports Flash 2
  694. else if (navigator.userAgent.toLowerCase().indexOf(\"webtv\") != -1) flashVer = 2;
  695. // Can't detect in all other cases
  696. else {
  697. flashVer = -1;
  698. }
  699. return flashVer;
  700. }
  701. // When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
  702. function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
  703. {
  704. reqVer = parseFloat(reqMajorVer + \".\" + reqRevision);
  705. // loop backwards through the versions until we find the newest version
  706. for (i=25;i>0;i--) {
  707. if (isIE && isWin && !isOpera) {
  708. versionStr = VBGetSwfVer(i);
  709. } else {
  710. versionStr = JSGetSwfVer(i);
  711. }
  712. if (versionStr == -1 ) {
  713. return false;
  714. } else if (versionStr != 0) {
  715. if(isIE && isWin && !isOpera) {
  716. tempArray = versionStr.split(\" \");
  717. tempString = tempArray[1];
  718. versionArray = tempString .split(\",\");
  719. } else {
  720. versionArray = versionStr.split(\".\");
  721. }
  722. versionMajor = versionArray[0];
  723. versionMinor = versionArray[1];
  724. versionRevision = versionArray[2];
  725. versionString = versionMajor + \".\" + versionRevision; // 7.0r24 == 7.24
  726. versionNum = parseFloat(versionString);
  727. // is the major.revision >= requested major.revision AND the minor version >= requested minor
  728. if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
  729. return true;
  730. } else {
  731. return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );
  732. }
  733. }
  734. }
  735. }
  736. // -->
  737. </script>";
  738. Display::display_header($nameTools,"Exercise");
  739. }
  740. else
  741. {
  742. if(empty($charset))
  743. {
  744. $charset = 'ISO-8859-15';
  745. }
  746. header('Content-Type: text/html; charset='. $charset);
  747. @$document_language = Database::get_language_isocode($language_interface);
  748. if(empty($document_language))
  749. {
  750. //if there was no valid iso-code, use the english one
  751. $document_language = 'en';
  752. }
  753. /*
  754. * HTML HEADER
  755. */
  756. ?>
  757. <!DOCTYPE html
  758. PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  759. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  760. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $document_language; ?>" lang="<?php echo $document_language; ?>">
  761. <head>
  762. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>" />
  763. </head>
  764. <body>
  765. <link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_CODE_PATH).'css/'.api_get_setting('stylesheets').'/frames.css'; ?>" />
  766. <link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_CODE_PATH).'css/'.api_get_setting('stylesheets').'/default.css'; ?>" />
  767. <?php
  768. }
  769. // I'm in a preview mode
  770. if (api_is_course_admin() && $origin!='learnpath') {
  771. echo '<div class="actions">';
  772. echo Display::return_icon('quiz.gif', get_lang('GoBackToEx')).'<a href="admin.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'">'.get_lang('GoBackToEx').'</a>';
  773. echo Display::return_icon('edit.gif', get_lang('ModifyExercise')).'<a href="exercise_admin.php?modifyExercise=yes&exerciseId='.$objExercise->id.'">'.get_lang('ModifyExercise').'</a>';
  774. echo '</div>';
  775. }
  776. $exerciseTitle=api_parse_tex($exerciseTitle);
  777. echo "<h3>".$exerciseTitle."</h3>";
  778. if( $exerciseAttempts > 0){
  779. $user_id = api_get_user_id();
  780. $course_code = api_get_course_id();
  781. $sql = "SELECT count(*) FROM $stat_table WHERE exe_exo_id = '$quizID'
  782. AND exe_user_id = '$user_id'
  783. AND status != 'incomplete'
  784. AND orig_lp_id = $safe_lp_id
  785. AND orig_lp_item_id = $safe_lp_item_id
  786. AND exe_cours_id = '$course_code' AND session_id = '".(int)$_SESSION['id_session']."'";
  787. $aquery = api_sql_query($sql, __FILE__, __LINE__);
  788. $attempt = Database::fetch_array($aquery);
  789. if ( $attempt[0] >= $exerciseAttempts ) {
  790. if (!api_is_allowed_to_edit()) {
  791. Display::display_warning_message(sprintf(get_lang('ReachedMaxAttempts'),$exerciseTitle,$exerciseAttempts),false);
  792. if ($origin != 'learnpath')
  793. Display::display_footer();
  794. exit;
  795. } else {
  796. Display::display_warning_message(sprintf(get_lang('ReachedMaxAttemptsAdmin'),$exerciseTitle,$exerciseAttempts),false);
  797. }
  798. }
  799. }
  800. if (!function_exists('convert_date_to_number')) {
  801. function convert_date_to_number($default){
  802. // 2008-10-12 00:00:00 ---to--> 12345672218 (timestamp)
  803. $parts = split(' ',$default);
  804. list($d_year,$d_month,$d_day) = split('-',$parts[0]);
  805. list($d_hour,$d_minute,$d_second) = split(':',$parts[1]);
  806. return mktime($d_hour, $d_minute, $d_second, $d_month, $d_day, $d_year);
  807. }
  808. }
  809. $limit_time_exists = (($Exe_starttime!='0000-00-00 00:00:00')||($Exe_endtime!='0000-00-00 00:00:00'))? true : false;
  810. if($limit_time_exists){
  811. $exercise_start_time = convert_date_to_number($Exe_starttime);
  812. $exercise_end_time = convert_date_to_number($Exe_endtime);
  813. $time_now = convert_date_to_number(date('Y-m-d H:i:s'));
  814. $permission_to_start = (($time_now - $exercise_start_time)>0)?true:false;
  815. if($_SERVER['REQUEST_METHOD']!='POST')$exercise_timeover = (($time_now - $exercise_end_time)>0)?true:false;
  816. if($permission_to_start == false || $exercise_timeover == true ){ //
  817. if(!api_is_allowed_to_edit()){
  818. $message_warning = ($permission_to_start == false)? get_lang('ExerciseNoStartedYet') : get_lang('ReachedTimeLimit') ;
  819. Display::display_warning_message(sprintf($message_warning,$exerciseTitle,$exerciseAttempts));
  820. Display::display_footer();
  821. exit;
  822. } else {
  823. $message_warning = ($permission_to_start == false)? get_lang('ExerciseNoStartedAdmin') : get_lang('ReachedTimeLimitAdmin') ;
  824. Display::display_warning_message(sprintf($message_warning,$exerciseTitle,$exerciseAttempts));
  825. }
  826. }
  827. }
  828. if(!empty($error))
  829. {
  830. Display::display_error_message($error,false);
  831. }
  832. else
  833. {
  834. if(!empty($exerciseSound)) {
  835. echo "<a href=\"../document/download.php?doc_url=%2Faudio%2F".$exerciseSound."\" target=\"_blank\">",
  836. "<img src=\"../img/sound.gif\" border=\"0\" align=\"absmiddle\" alt=",get_lang('Sound')."\" /></a>";
  837. }
  838. // Get number of hotspot questions for javascript validation
  839. $number_of_hotspot_questions = 0;
  840. $onsubmit = '';
  841. $i=0;
  842. //i have a doubt in this line cvargas
  843. //var_dump($questionList);
  844. if (!strcmp($questionList[0],'')===0) {
  845. foreach($questionList as $questionId) {
  846. $i++;
  847. $objQuestionTmp = Question :: read($questionId);
  848. // for sequential exercises
  849. if($exerciseType == 2) {
  850. // if it is not the right question, goes to the next loop iteration
  851. if($questionNum != $i) {
  852. continue;
  853. }
  854. else
  855. {
  856. if ($objQuestionTmp->selectType() == HOT_SPOT)
  857. {
  858. $number_of_hotspot_questions++;
  859. }
  860. break;
  861. }
  862. }
  863. else
  864. {
  865. if ($objQuestionTmp->selectType() == HOT_SPOT)
  866. {
  867. $number_of_hotspot_questions++;
  868. }
  869. }
  870. }
  871. }
  872. if($number_of_hotspot_questions > 0)
  873. {
  874. $onsubmit = "onsubmit=\"return validateFlashVar('".$number_of_hotspot_questions."', '".get_lang('HotspotValidateError1')."', '".get_lang('HotspotValidateError2')."');\"";
  875. }
  876. $s="<p>$exerciseDescription</p>";
  877. if($exerciseType==2){
  878. $s2 = "&exerciseId=".$exerciseId;
  879. }
  880. $s.=" <form method='post' action='".api_get_self()."?autocomplete=off".$s2."' name='frm_exercise' $onsubmit>
  881. <input type='hidden' name='formSent' value='1' />
  882. <input type='hidden' name='exerciseType' value='".$exerciseType."' />
  883. <input type='hidden' name='exerciseId' value='".$exerciseId."' />
  884. <input type='hidden' name='questionNum' value='".$questionNum."' />
  885. <input type='hidden' name='nbrQuestions' value='".$nbrQuestions."' />
  886. <input type='hidden' name='origin' value='".$origin."' />
  887. <input type='hidden' name='learnpath_id' value='".$learnpath_id."' />
  888. <input type='hidden' name='learnpath_item_id' value='".$learnpath_item_id."' />
  889. <table width='100%' border='0' cellpadding='1' cellspacing='0'>
  890. <tr>
  891. <td>
  892. <table width='100%' cellpadding='3' cellspacing='0' border='0'>";
  893. echo $s;
  894. $i=1;
  895. foreach($questionList as $questionId) {
  896. // for sequential exercises
  897. if($exerciseType == 2) {
  898. // if it is not the right question, goes to the next loop iteration
  899. if ($questionNum != $i ) {
  900. $i++;
  901. continue;
  902. } else {
  903. if ($exerciseFeedbackType != 1) {
  904. // if the user has already answered this question
  905. if (isset($exerciseResult[$questionId])) {
  906. // construction of the Question object
  907. $objQuestionTmp = Question::read($questionId);
  908. $questionName=$objQuestionTmp->selectTitle();
  909. // destruction of the Question object
  910. unset($objQuestionTmp);
  911. Display::display_normal_message(get_lang('AlreadyAnswered'));
  912. $i++;
  913. //echo '<tr><td>'.get_lang('AlreadyAnswered').' &quot;'.$questionName.'&quot;</td></tr>';
  914. break;
  915. }
  916. }
  917. }
  918. }
  919. // shows the question and its answers
  920. showQuestion($questionId, false, $origin,$i,$nbrQuestions);
  921. $i++;
  922. // for sequential exercises
  923. if($exerciseType == 2) {
  924. // quits the loop
  925. break;
  926. }
  927. }
  928. // end foreach()
  929. echo "
  930. <!-- <button type='submit' name='buttonCancel' class='cancel'>".get_lang('Cancel')."</button>
  931. &nbsp;&nbsp; //--><br />";
  932. $submit_btn="<button class=\"save\" type='submit' name='submit'>";
  933. // $submit_btn.=get_lang('ValidateAnswer');
  934. if ($objExercise->selectFeedbackType()==1 && $_SESSION['objExercise']->selectType()==2) {
  935. $submit_btn='';
  936. echo '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/thickbox.js" type="text/javascript"></script>';
  937. echo '<style type="text/css" media="all">@import "'.api_get_path(WEB_LIBRARY_PATH).'javascript/thickbox.css";</style>';
  938. $hotspot_get=$_POST['hotspot'];
  939. // Show a hidden div
  940. echo "<script>$(document).ready( function(){
  941. $('.rounded').corners();
  942. $('.rounded_inner').corners();
  943. });</script>";
  944. //echo '<br /><span class="rounded" style="width: 300px; margin-top: 10px; padding: 3px; background-color:#ccc;"><span style="width: 300px" class="rounded_inner" ><a href="exercise_submit_modal.php?hotspot='.$hotspot_get.'&nbrQuestions='.$nbrQuestions.'&questionnum='.$questionNum.'&exerciseType='.$exerciseType.'&exerciseId='.$exerciseId.'&placeValuesBeforeTB_=savedValues&TB_iframe=true&height=480&width=640&modal=true" title="" class="thickbox" id="validationButton">'.get_lang('ValidateAnswer').'</a></span></span><br /><br /><br />';
  945. echo '<br />
  946. <div class="rounded" style="text-align: center;">
  947. <div class="rounded_inner">
  948. <a href="exercise_submit_modal.php?hotspot='.$hotspot_get.'&nbrQuestions='.$nbrQuestions.'&questionnum='.$questionNum.'&exerciseType='.$exerciseType.'&exerciseId='.$exerciseId.'&origin='.$origin.'&placeValuesBeforeTB_=savedValues&TB_iframe=true&height=480&width=640&modal=true" title="" class="thickbox" id="validationButton">'.get_lang('ValidateAnswer').'</a>
  949. </div>
  950. </div><br /><br /><br />';
  951. } else {
  952. if ($exerciseType == 1 || $nbrQuestions == $questionNum)
  953. {
  954. $submit_btn.=get_lang('ValidateAnswer');
  955. }
  956. else
  957. {
  958. $submit_btn.=get_lang('NextQuestion').' &gt;';
  959. }
  960. $submit_btn.= "</button>";
  961. }
  962. echo $submit_btn;
  963. echo "</table>
  964. </td>
  965. </tr>
  966. </table></form>";
  967. $b=2;
  968. }
  969. if($_configuration['live_exercise_tracking'] == true && $exerciseFeedbackType!=1) {
  970. //if($questionNum < 2){
  971. if($table_recorded_not_exist){
  972. if($exerciseType == 2){
  973. api_sql_query("INSERT INTO $stat_table(exe_exo_id,exe_user_id,exe_cours_id,status,session_id,data_tracking,start_date,orig_lp_id,orig_lp_item_id)
  974. VALUES('$exerciseId','".api_get_user_id()."','".$_course['id']."','incomplete','".api_get_session_id()."','".implode(',',$questionList)."','".date('Y-m-d H:i:s')."',$safe_lp_id,$safe_lp_item_id)",__FILE__,__LINE__);
  975. } else {
  976. api_sql_query("INSERT INTO $stat_table (exe_exo_id,exe_user_id,exe_cours_id,status,session_id,start_date,orig_lp_id,orig_lp_item_id)
  977. VALUES('$exerciseId','".api_get_user_id()."','".$_course['id']."','incomplete','".api_get_session_id()."','".date('Y-m-d H:i:s')."',$safe_lp_id,$safe_lp_item_id)",__FILE__,__LINE__);
  978. }
  979. }
  980. }
  981. if ($origin != 'learnpath') {
  982. //so we are not in learnpath tool
  983. Display::display_footer();
  984. }