exercise_result.php 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195
  1. <?php
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2008 Dokeos SPRL
  6. For a full list of contributors, see "credits.txt".
  7. The full license can be read in "license.txt".
  8. This program is free software; you can redistribute it and/or
  9. modify it under the terms of the GNU General Public License
  10. as published by the Free Software Foundation; either version 2
  11. of the License, or (at your option) any later version.
  12. See the GNU General Public License for more details.
  13. Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
  14. Mail: info@dokeos.com
  15. ==============================================================================
  16. */
  17. /**
  18. * Exercise result
  19. * This script gets informations from the script "exercise_submit.php",
  20. * through the session, and calculates the score of the student for
  21. * that exercise.
  22. * Then it shows the results on the screen.
  23. * @package dokeos.exercise
  24. * @author Olivier Brouckaert, main author
  25. * @author Roan Embrechts, some refactoring
  26. * @author Julio Montoya Armas switchable fill in blank option added
  27. * @version $Id: exercise_result.php 17605 2009-01-08 22:29:28Z cfasanando $
  28. *
  29. * @todo split more code up in functions, move functions to library?
  30. */
  31. /*
  32. ==============================================================================
  33. INIT SECTION
  34. ==============================================================================
  35. */
  36. include('exercise.class.php');
  37. include('question.class.php');
  38. include('answer.class.php');
  39. if($_GET['origin']=='learnpath')
  40. {
  41. require_once ('../newscorm/learnpath.class.php');
  42. require_once ('../newscorm/learnpathItem.class.php');
  43. require_once ('../newscorm/scorm.class.php');
  44. require_once ('../newscorm/scormItem.class.php');
  45. require_once ('../newscorm/aicc.class.php');
  46. require_once ('../newscorm/aiccItem.class.php');
  47. }
  48. /*
  49. // answer types
  50. define('UNIQUE_ANSWER', 1);
  51. define('MULTIPLE_ANSWER', 2);
  52. define('FILL_IN_BLANKS', 3);
  53. define('MATCHING', 4);
  54. define('FREE_ANSWER', 5);
  55. define('HOT_SPOT', 6);
  56. define('HOT_SPOT_ORDER', 7);
  57. */
  58. global $_cid;
  59. // name of the language file that needs to be included
  60. $language_file='exercice';
  61. include('../inc/global.inc.php');
  62. $this_section=SECTION_COURSES;
  63. /* ------------ ACCESS RIGHTS ------------ */
  64. // notice for unauthorized people.
  65. api_protect_course_script(true);
  66. include_once(api_get_path(LIBRARY_PATH).'events.lib.inc.php');
  67. include_once(api_get_path(LIBRARY_PATH).'mail.lib.inc.php');
  68. include_once(api_get_path(LIBRARY_PATH).'course.lib.php');
  69. // Database table definitions
  70. $TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
  71. $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
  72. $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
  73. $TBL_REPONSES = Database::get_course_table(TABLE_QUIZ_ANSWER);
  74. $TBL_TRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
  75. $TBL_TRACK_ATTEMPT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
  76. $main_user_table = Database :: get_main_table(TABLE_MAIN_USER);
  77. $main_course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  78. $table_ans = Database :: get_course_table(TABLE_QUIZ_ANSWER);
  79. //temp values to move to AWACS
  80. $dsp_percent = false; //false to display total score as absolute values
  81. //debug param. 0: no display - 1: debug display
  82. $debug=0;
  83. if($debug>0){echo str_repeat('&nbsp;',0).'Entered exercise_result.php'."<br />\n";var_dump($_POST);}
  84. // general parameters passed via POST/GET
  85. if ( empty ( $origin ) ) {
  86. $origin = $_REQUEST['origin'];
  87. }
  88. if ( empty ( $learnpath_id ) ) {
  89. $learnpath_id = $_REQUEST['learnpath_id'];
  90. }
  91. if ( empty ( $learnpath_item_id ) ) {
  92. $learnpath_item_id = $_REQUEST['learnpath_item_id'];
  93. }
  94. if ( empty ( $formSent ) ) {
  95. $formSent = $_REQUEST['formSent'];
  96. }
  97. if ( empty ( $exerciseResult ) ) {
  98. $exerciseResult = $_SESSION['exerciseResult'];
  99. }
  100. if ( empty ( $questionId ) ) {
  101. $questionId = $_REQUEST['questionId'];
  102. }
  103. if ( empty ( $choice ) ) {
  104. $choice = $_REQUEST['choice'];
  105. }
  106. if ( empty ( $questionNum ) ) {
  107. $questionNum = $_REQUEST['questionNum'];
  108. }
  109. if ( empty ( $nbrQuestions ) ) {
  110. $nbrQuestions = $_REQUEST['nbrQuestions'];
  111. }
  112. if ( empty ( $questionList ) ) {
  113. $questionList = $_SESSION['questionList'];
  114. }
  115. if ( empty ( $objExercise ) ) {
  116. $objExercise = $_SESSION['objExercise'];
  117. }
  118. if ( empty ( $exerciseType ) ) {
  119. $exerciseType = $_REQUEST['exerciseType'];
  120. }
  121. $_configuration['live_exercise_tracking'] = false;
  122. if($_configuration['live_exercise_tracking']) define('ENABLED_LIVE_EXERCISE_TRACKING',1);
  123. if($_configuration['live_exercise_tracking'] == true && $exerciseType == 1){
  124. $_configuration['live_exercise_tracking'] = false;
  125. }
  126. $main_user_table = Database :: get_main_table(TABLE_MAIN_USER);
  127. $main_admin_table = Database :: get_main_table(TABLE_MAIN_ADMIN);
  128. $courseName = $_SESSION['_course']['name'];
  129. $query = "select user_id from $main_admin_table";
  130. $admin_id = mysql_result(api_sql_query($query),0,"user_id");
  131. $uinfo = api_get_user_info($admin_id);
  132. $from = $uinfo['mail'];
  133. $from_name = $uinfo['firstname'].' '.$uinfo['lastname'];
  134. $str = $_SERVER['REQUEST_URI'];
  135. $arr = explode('/',$str);
  136. $url = api_get_path(WEB_CODE_PATH).'exercice/exercice.php?'.api_get_cidreq().'&show=result';
  137. //$url = $_SERVER['SERVER_NAME'].'/'.$arr[1].'/';
  138. // if the above variables are empty or incorrect, stops the script
  139. if(!is_array($exerciseResult) || !is_array($questionList) || !is_object($objExercise))
  140. {
  141. header('Location: exercice.php');
  142. exit();
  143. }
  144. $exerciseTitle=$objExercise->selectTitle();
  145. $exerciseDescription=$objExercise->selectDescription();
  146. $exerciseDescription=stripslashes($exerciseDescription);
  147. $nameTools=get_lang('Exercice');
  148. $interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices'));
  149. $htmlHeadXtra[] = "<script type=\"text/javascript\" src=\"../plugin/hotspot/JavaScriptFlashGateway.js\"></script>
  150. <script src=\"../plugin/hotspot/hotspot.js\" type=\"text/javascript\"></script>
  151. <script language=\"JavaScript\" type=\"text/javascript\">
  152. <!--
  153. // -----------------------------------------------------------------------------
  154. // Globals
  155. // Major version of Flash required
  156. var requiredMajorVersion = 7;
  157. // Minor version of Flash required
  158. var requiredMinorVersion = 0;
  159. // Minor version of Flash required
  160. var requiredRevision = 0;
  161. // the version of javascript supported
  162. var jsVersion = 1.0;
  163. // -----------------------------------------------------------------------------
  164. // -->
  165. </script>
  166. <script language=\"VBScript\" type=\"text/vbscript\">
  167. <!-- // Visual basic helper required to detect Flash Player ActiveX control version information
  168. Function VBGetSwfVer(i)
  169. on error resume next
  170. Dim swControl, swVersion
  171. swVersion = 0
  172. set swControl = CreateObject(\"ShockwaveFlash.ShockwaveFlash.\" + CStr(i))
  173. if (IsObject(swControl)) then
  174. swVersion = swControl.GetVariable(\"\$version\")
  175. end if
  176. VBGetSwfVer = swVersion
  177. End Function
  178. // -->
  179. </script>
  180. <script language=\"JavaScript1.1\" type=\"text/javascript\">
  181. <!-- // Detect Client Browser type
  182. var isIE = (navigator.appVersion.indexOf(\"MSIE\") != -1) ? true : false;
  183. var isWin = (navigator.appVersion.toLowerCase().indexOf(\"win\") != -1) ? true : false;
  184. var isOpera = (navigator.userAgent.indexOf(\"Opera\") != -1) ? true : false;
  185. jsVersion = 1.1;
  186. // JavaScript helper required to detect Flash Player PlugIn version information
  187. function JSGetSwfVer(i){
  188. // NS/Opera version >= 3 check for Flash plugin in plugin array
  189. if (navigator.plugins != null && navigator.plugins.length > 0) {
  190. if (navigator.plugins[\"Shockwave Flash 2.0\"] || navigator.plugins[\"Shockwave Flash\"]) {
  191. var swVer2 = navigator.plugins[\"Shockwave Flash 2.0\"] ? \" 2.0\" : \"\";
  192. var flashDescription = navigator.plugins[\"Shockwave Flash\" + swVer2].description;
  193. descArray = flashDescription.split(\" \");
  194. tempArrayMajor = descArray[2].split(\".\");
  195. versionMajor = tempArrayMajor[0];
  196. versionMinor = tempArrayMajor[1];
  197. if ( descArray[3] != \"\" ) {
  198. tempArrayMinor = descArray[3].split(\"r\");
  199. } else {
  200. tempArrayMinor = descArray[4].split(\"r\");
  201. }
  202. versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
  203. flashVer = versionMajor + \".\" + versionMinor + \".\" + versionRevision;
  204. } else {
  205. flashVer = -1;
  206. }
  207. }
  208. // MSN/WebTV 2.6 supports Flash 4
  209. else if (navigator.userAgent.toLowerCase().indexOf(\"webtv/2.6\") != -1) flashVer = 4;
  210. // WebTV 2.5 supports Flash 3
  211. else if (navigator.userAgent.toLowerCase().indexOf(\"webtv/2.5\") != -1) flashVer = 3;
  212. // older WebTV supports Flash 2
  213. else if (navigator.userAgent.toLowerCase().indexOf(\"webtv\") != -1) flashVer = 2;
  214. // Can't detect in all other cases
  215. else {
  216. flashVer = -1;
  217. }
  218. return flashVer;
  219. }
  220. // When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
  221. function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
  222. {
  223. reqVer = parseFloat(reqMajorVer + \".\" + reqRevision);
  224. // loop backwards through the versions until we find the newest version
  225. for (i=25;i>0;i--) {
  226. if (isIE && isWin && !isOpera) {
  227. versionStr = VBGetSwfVer(i);
  228. } else {
  229. versionStr = JSGetSwfVer(i);
  230. }
  231. if (versionStr == -1 ) {
  232. return false;
  233. } else if (versionStr != 0) {
  234. if(isIE && isWin && !isOpera) {
  235. tempArray = versionStr.split(\" \");
  236. tempString = tempArray[1];
  237. versionArray = tempString .split(\",\");
  238. } else {
  239. versionArray = versionStr.split(\".\");
  240. }
  241. versionMajor = versionArray[0];
  242. versionMinor = versionArray[1];
  243. versionRevision = versionArray[2];
  244. versionString = versionMajor + \".\" + versionRevision; // 7.0r24 == 7.24
  245. versionNum = parseFloat(versionString);
  246. // is the major.revision >= requested major.revision AND the minor version >= requested minor
  247. if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
  248. return true;
  249. } else {
  250. return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );
  251. }
  252. }
  253. }
  254. }
  255. // -->
  256. </script>";
  257. if ($origin != 'learnpath')
  258. {
  259. //so we are not in learnpath tool
  260. Display::display_header($nameTools,"Exercise");
  261. }
  262. else
  263. {
  264. if(empty($charset))
  265. {
  266. $charset = 'ISO-8859-15';
  267. }
  268. header('Content-Type: text/html; charset='. $charset);
  269. @$document_language = Database::get_language_isocode($language_interface);
  270. if(empty($document_language))
  271. {
  272. //if there was no valid iso-code, use the english one
  273. $document_language = 'en';
  274. }
  275. /*
  276. * HTML HEADER
  277. */
  278. ?>
  279. <!DOCTYPE html
  280. PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  281. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  282. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $document_language; ?>" lang="<?php echo $document_language; ?>">
  283. <head>
  284. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
  285. </head>
  286. <body>
  287. <link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_CODE_PATH).'css/'.api_get_setting('stylesheets').'/frames.css'; ?>" />
  288. <?php
  289. }
  290. if($objExercise->results_disabled)
  291. {
  292. ob_start();
  293. }
  294. /*
  295. ==============================================================================
  296. FUNCTIONS
  297. ==============================================================================
  298. */
  299. function display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect)
  300. {
  301. ?>
  302. <tr>
  303. <td width="5%" align="center">
  304. <img src="../img/<?php echo ($answerType == UNIQUE_ANSWER)?'radio':'checkbox'; echo $studentChoice?'_on':'_off'; ?>.gif"
  305. border="0" alt="" />
  306. </td>
  307. <td width="5%" align="center">
  308. <img src="../img/<?php echo ($answerType == UNIQUE_ANSWER)?'radio':'checkbox'; echo $answerCorrect?'_on':'_off'; ?>.gif"
  309. border="0" alt=" " />
  310. </td>
  311. <td width="45%" style="border-bottom: 1px solid #4171B5;">
  312. <?php
  313. $answer=api_parse_tex($answer);
  314. echo $answer; ?>
  315. </td>
  316. <td width="45%" style="border-bottom: 1px solid #4171B5;">
  317. <?php
  318. $answerComment=api_parse_tex($answerComment);
  319. if($studentChoice)
  320. {
  321. if(!$answerCorrect)
  322. {
  323. echo '<span style="font-weight: bold; color: #FF0000;">'.nl2br(make_clickable(stripslashes($answerComment))).'</span>';
  324. }
  325. else{
  326. echo '<span style="font-weight: bold; color: #008000;">'.nl2br(make_clickable(stripslashes($answerComment))).'</span>';
  327. }
  328. }
  329. else
  330. {
  331. echo '&nbsp;';
  332. }
  333. ?>
  334. </td>
  335. </tr>
  336. <?php
  337. }
  338. function display_fill_in_blanks_answer($answer)
  339. {
  340. ?>
  341. <tr>
  342. <td>
  343. <?php echo nl2br($answer); ?>
  344. </td>
  345. </tr>
  346. <?php
  347. }
  348. function display_free_answer($answer)
  349. {
  350. ?>
  351. <tr>
  352. <td width="55%">
  353. <?php echo nl2br(stripslashes($answer)); ?>
  354. </td>
  355. <td width="45%">
  356. <?php echo get_lang('notCorrectedYet');?>
  357. </td>
  358. </tr>
  359. <?php
  360. }
  361. function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComment)
  362. {
  363. //global $hotspot_colors;
  364. $hotspot_colors = array("", // $i starts from 1 on next loop (ugly fix)
  365. "#4271B5",
  366. "#FE8E16",
  367. "#3B3B3B",
  368. "#BCD631",
  369. "#D63173",
  370. "#D7D7D7",
  371. "#90AFDD",
  372. "#AF8640",
  373. "#4F9242",
  374. "#F4EB24",
  375. "#ED2024",
  376. "#45C7F0",
  377. "#F7BDE2");
  378. ?>
  379. <tr>
  380. <td valign="top">
  381. <div style="float:left; padding-left:5px;">
  382. <div style="display:inline; float:left; width:80px;"><?php echo $answer ?></div>
  383. <div style="height:11px; width:11px; background-color:<?php echo $hotspot_colors[$answerId]; ?>; display:inline; float:left; margin-top:3px;"></div>
  384. </div>
  385. </td>
  386. <td valign="top"><?php echo $answerId; ?></td>
  387. <td valign="top">
  388. <?php $studentChoice = ($studentChoice)?get_lang('Correct'):get_lang('Fault'); echo $studentChoice; ?>
  389. </td>
  390. <td valign="top">
  391. <?php echo stripslashes($answerComment); ?>
  392. </td>
  393. </tr>
  394. <?php
  395. }
  396. /*
  397. ==============================================================================
  398. MAIN CODE
  399. ==============================================================================
  400. */
  401. $exerciseTitle=api_parse_tex($exerciseTitle);
  402. ?>
  403. <h3><?php echo $exerciseTitle ?>: <?php echo get_lang("Result"); ?></h3>
  404. <?php echo $exerciseDescription; ?>
  405. <form method="get" action="exercice.php">
  406. <input type="hidden" name="origin" value="<?php echo $origin; ?>" />
  407. <input type="hidden" name="learnpath_id" value="<?php echo $learnpath_id; ?>" />
  408. <input type="hidden" name="learnpath_item_id" value="<?php echo $learnpath_item_id; ?>" />
  409. <?php
  410. $i=$totalScore=$totalWeighting=0;
  411. if($debug>0){echo "ExerciseResult: "; var_dump($exerciseResult); echo "QuestionList: ";var_dump($questionList);}
  412. // added by Priya Saini
  413. //$sql = "select max(exe_Id) as id from ".$TBL_TRACK_EXERCICES;
  414. /*
  415. $sql = "select max(exe_Id) as id from ".$TBL_TRACK_ATTEMPT;
  416. $res = api_sql_query($sql, __FILE__, __LINE__);
  417. $exeId =mysql_result($res,0,"id");
  418. $exeId=$exeId+1;
  419. */
  420. if($_configuration['tracking_enabled'])
  421. {
  422. // Create an empty exercise
  423. $exeId= create_event_exercice($objExercise->selectId());
  424. }
  425. $counter=0;
  426. foreach($questionList as $questionId)
  427. {
  428. $counter++;
  429. // gets the student choice for this question
  430. $choice=$exerciseResult[$questionId];
  431. //print_r($choice); echo "<br>";
  432. // creates a temporary Question object
  433. $objQuestionTmp = Question :: read($questionId);
  434. $questionName=$objQuestionTmp->selectTitle();
  435. $questionDescription=$objQuestionTmp->selectDescription();
  436. $questionWeighting=$objQuestionTmp->selectWeighting();
  437. $answerType=$objQuestionTmp->selectType();
  438. $quesId =$objQuestionTmp->selectId(); //added by priya saini
  439. // destruction of the Question object
  440. unset($objQuestionTmp);
  441. if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER)
  442. {
  443. $colspan=4;
  444. }
  445. elseif($answerType == MATCHING || $answerType == FREE_ANSWER)
  446. {
  447. $colspan=2;
  448. }
  449. elseif($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER)
  450. {
  451. $colspan=4;
  452. $rowspan=$nbrAnswers+1;
  453. }
  454. else
  455. {
  456. $colspan=1;
  457. }
  458. ?>
  459. <table width="100%" border="0" cellpadding="3" cellspacing="2">
  460. <tr bgcolor="#E6E6E6">
  461. <td colspan="<?php echo $colspan; ?>">
  462. <?php echo get_lang("Question").' '.($counter).' : '.$questionName; ?>
  463. </td>
  464. </tr>
  465. <tr>
  466. <td colspan="<?php echo $colspan; ?>">
  467. <i>
  468. <?php echo $questionDescription; ?>
  469. </i>
  470. </td>
  471. </tr>
  472. <?php
  473. if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER)
  474. {
  475. ?>
  476. <tr>
  477. <td width="5%" valign="top" align="center" nowrap="nowrap">
  478. <i><?php echo get_lang("Choice"); ?></i>
  479. </td>
  480. <td width="5%" valign="top" nowrap="nowrap">
  481. <i><?php echo get_lang("ExpectedChoice"); ?></i>
  482. </td>
  483. <td width="45%" valign="top">
  484. <i><?php echo get_lang("Answer"); ?></i>
  485. </td>
  486. <td width="45%" valign="top">
  487. <i><?php echo get_lang("Comment"); ?></i>
  488. </td>
  489. </tr>
  490. <?php
  491. }
  492. elseif($answerType == FILL_IN_BLANKS)
  493. {
  494. ?>
  495. <tr>
  496. <td>
  497. <i><?php echo get_lang("Answer"); ?></i>
  498. </td>
  499. </tr>
  500. <?php
  501. }
  502. elseif($answerType == FREE_ANSWER)
  503. {
  504. ?>
  505. <tr>
  506. <td width="55%">
  507. <i><?php echo get_lang("Answer"); ?></i>
  508. </td>
  509. <td width="45%" valign="top">
  510. <i><?php echo get_lang("Comment"); ?></i>
  511. </td>
  512. </tr>
  513. <?php
  514. }
  515. elseif($answerType == HOT_SPOT)
  516. {
  517. ?>
  518. <tr>
  519. <td valign="top" colspan="2">
  520. <table width="556" border="0">
  521. <tr>
  522. <td width="40%" valign="top">
  523. <i><?php echo get_lang("CorrectAnswer"); ?></i><br /><br />
  524. </td>
  525. <td width="15%" valign="top">
  526. <i><?php echo get_lang("ClickNumber"); ?></i><br /><br />
  527. </td>
  528. <td width="20%" valign="top">
  529. <i><?php echo get_lang('HotspotHit'); ?></i><br /><br />
  530. </td>
  531. <td width="25%" valign="top">
  532. <i><?php echo get_lang("Comment"); ?></i><br /><br />
  533. </td>
  534. </tr>
  535. <?php
  536. }
  537. else
  538. {
  539. ?>
  540. <tr>
  541. <td width="50%">
  542. <i><?php echo get_lang("ElementList"); ?></i>
  543. </td>
  544. <td width="50%">
  545. <i><?php echo get_lang("CorrespondsTo"); ?></i>
  546. </td>
  547. </tr>
  548. <?php
  549. }
  550. // construction of the Answer object
  551. $objAnswerTmp=new Answer($questionId);
  552. $nbrAnswers=$objAnswerTmp->selectNbrAnswers();
  553. $questionScore=0;
  554. if($answerType == FREE_ANSWER)
  555. $nbrAnswers = 1;
  556. for($answerId=1;$answerId <= $nbrAnswers;$answerId++)
  557. {
  558. $answer=$objAnswerTmp->selectAnswer($answerId);
  559. $answerComment=$objAnswerTmp->selectComment($answerId);
  560. $answerCorrect=$objAnswerTmp->isCorrect($answerId);
  561. $answerWeighting=$objAnswerTmp->selectWeighting($answerId);
  562. switch($answerType)
  563. {
  564. // for unique answer
  565. case UNIQUE_ANSWER :
  566. $studentChoice=($choice == $answerId)?1:0;
  567. if($studentChoice)
  568. {
  569. $questionScore+=$answerWeighting;
  570. $totalScore+=$answerWeighting;
  571. }
  572. break;
  573. // for multiple answers
  574. case MULTIPLE_ANSWER :
  575. $studentChoice=$choice[$answerId];
  576. if($studentChoice)
  577. {
  578. $questionScore+=$answerWeighting;
  579. $totalScore+=$answerWeighting;
  580. }
  581. break;
  582. // for fill in the blanks
  583. case FILL_IN_BLANKS :
  584. // the question is encoded like this
  585. // [A] B [C] D [E] F::10,10,10@1
  586. // number 1 before the "@" means that is a switchable fill in blank question
  587. // [A] B [C] D [E] F::10,10,10@ or [A] B [C] D [E] F::10,10,10
  588. // means that is a normal fill blank question
  589. // first we explode the "::"
  590. $pre_array = explode('::', $answer);
  591. // is switchable fill blank or not
  592. $last = count($pre_array)-1;
  593. $is_set_switchable = explode('@', $pre_array[$last]);
  594. $switchable_answer_set=false;
  595. if (isset($is_set_switchable[1]) && $is_set_switchable[1]==1)
  596. {
  597. $switchable_answer_set=true;
  598. }
  599. $answer = '';
  600. for ($k=0; $k<$last; $k++)
  601. {
  602. $answer .= $pre_array[$k];
  603. }
  604. // splits weightings that are joined with a comma
  605. $answerWeighting = explode(',',$is_set_switchable[0]);
  606. // we save the answer because it will be modified
  607. $temp=$answer;
  608. // TeX parsing
  609. // 1. find everything between the [tex] and [/tex] tags
  610. $startlocations=strpos($temp,'[tex]');
  611. $endlocations=strpos($temp,'[/tex]');
  612. if($startlocations !== false && $endlocations !== false)
  613. {
  614. $texstring=substr($temp,$startlocations,$endlocations-$startlocations+6);
  615. // 2. replace this by {texcode}
  616. $temp=str_replace($texstring,'{texcode}',$temp);
  617. }
  618. $answer='';
  619. $j=0;
  620. //initialise answer tags
  621. $user_tags=array();
  622. $correct_tags=array();
  623. $real_text=array();
  624. // the loop will stop at the end of the text
  625. while(1)
  626. {
  627. // quits the loop if there are no more blanks (detect '[')
  628. if(($pos = strpos($temp,'[')) === false)
  629. {
  630. // adds the end of the text
  631. $answer=$temp;
  632. // TeX parsing - replacement of texcode tags
  633. $texstring = api_parse_tex($texstring);
  634. $answer=str_replace("{texcode}",$texstring,$answer);
  635. $real_text[] = $answer;
  636. break; //no more "blanks", quit the loop
  637. }
  638. // adds the piece of text that is before the blank
  639. //and ends with '[' into a general storage array
  640. $real_text[]=substr($temp,0,$pos+1);
  641. $answer.=substr($temp,0,$pos+1);
  642. //take the string remaining (after the last "[" we found)
  643. $temp=substr($temp,$pos+1);
  644. // quit the loop if there are no more blanks, and update $pos to the position of next ']'
  645. if(($pos = strpos($temp,']')) === false)
  646. {
  647. // adds the end of the text
  648. $answer.=$temp;
  649. break;
  650. }
  651. $choice[$j]=trim($choice[$j]);
  652. $user_tags[]=stripslashes(strtolower($choice[$j]));
  653. //put the contents of the [] answer tag into correct_tags[]
  654. $correct_tags[]=strtolower(substr($temp,0,$pos));
  655. $j++;
  656. $temp=substr($temp,$pos+1);
  657. //$answer .= ']';
  658. }
  659. $answer='';
  660. $real_correct_tags = $correct_tags;
  661. $chosen_list=array();
  662. for($i=0;$i<count($real_correct_tags);$i++)
  663. {
  664. if ($i==0)
  665. {
  666. $answer.=$real_text[0];
  667. }
  668. if (!$switchable_answer_set)
  669. {
  670. if ($correct_tags[$i]==$user_tags[$i])
  671. {
  672. // gives the related weighting to the student
  673. $questionScore+=$answerWeighting[$i];
  674. // increments total score
  675. $totalScore+=$answerWeighting[$i];
  676. // adds the word in green at the end of the string
  677. $answer.=stripslashes($correct_tags[$i]);
  678. }
  679. // else if the word entered by the student IS NOT the same as the one defined by the professor
  680. elseif(!empty($user_tags[$i]))
  681. {
  682. // adds the word in red at the end of the string, and strikes it
  683. $answer.='<font color="red"><s>'.stripslashes($user_tags[$i]).'</s></font>';
  684. }
  685. else
  686. {
  687. // adds a tabulation if no word has been typed by the student
  688. $answer.='&nbsp;&nbsp;&nbsp;';
  689. }
  690. }
  691. else
  692. { // switchable fill in the blanks
  693. if (in_array($user_tags[$i],$correct_tags))
  694. {
  695. $chosen_list[]=$user_tags[$i];
  696. $correct_tags=array_diff($correct_tags,$chosen_list);
  697. // gives the related weighting to the student
  698. $questionScore+=$answerWeighting[$i];
  699. // increments total score
  700. $totalScore+=$answerWeighting[$i];
  701. // adds the word in green at the end of the string
  702. $answer.=stripslashes($user_tags[$i]);
  703. } // else if the word entered by the student IS NOT the same as the one defined by the professor
  704. elseif(!empty($user_tags[$i]))
  705. {
  706. // adds the word in red at the end of the string, and strikes it
  707. $answer.='<font color="red"><s>'.stripslashes($user_tags[$i]).'</s></font>';
  708. }
  709. else
  710. {
  711. // adds a tabulation if no word has been typed by the student
  712. $answer.='&nbsp;&nbsp;&nbsp;';
  713. }
  714. }
  715. // adds the correct word, followed by ] to close the blank
  716. $answer.=' / <font color="green"><b>'.$real_correct_tags[$i].'</b></font>]';
  717. if ( isset( $real_text[$i+1] ) ) {
  718. $answer.=$real_text[$i+1];
  719. }
  720. }
  721. break;
  722. // for free answer
  723. case FREE_ANSWER :
  724. $studentChoice=$choice;
  725. if($studentChoice)
  726. {
  727. //Score is at -1 because the question has'nt been corected
  728. $questionScore=-1;
  729. $totalScore+=0;
  730. }
  731. break;
  732. // for matching
  733. case MATCHING :
  734. if($answerCorrect)
  735. {
  736. if($answerCorrect == $choice[$answerId])
  737. {
  738. $questionScore+=$answerWeighting;
  739. $totalScore+=$answerWeighting;
  740. $choice[$answerId]=$matching[$choice[$answerId]];
  741. }
  742. elseif(!$choice[$answerId])
  743. {
  744. $choice[$answerId]='&nbsp;&nbsp;&nbsp;';
  745. }
  746. else
  747. {
  748. $choice[$answerId]='<font color="red"><s>'.$matching[$choice[$answerId]].'</s></font>';
  749. }
  750. }
  751. else
  752. {
  753. $matching[$answerId]=$answer;
  754. }
  755. break;
  756. // for hotspot with no order
  757. case HOT_SPOT : $studentChoice=$choice[$answerId];
  758. if($studentChoice)
  759. {
  760. $questionScore+=$answerWeighting;
  761. $totalScore+=$answerWeighting;
  762. }
  763. break;
  764. // for hotspot with fixed order
  765. case HOT_SPOT_ORDER : $studentChoice=$choice['order'][$answerId];
  766. if($studentChoice == $answerId)
  767. {
  768. $questionScore+=$answerWeighting;
  769. $totalScore+=$answerWeighting;
  770. $studentChoice = true;
  771. }
  772. else
  773. {
  774. $studentChoice = false;
  775. }
  776. break;
  777. } // end switch Answertype
  778. if($answerType != MATCHING || $answerCorrect)
  779. {
  780. if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER)
  781. {
  782. display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect);
  783. }
  784. elseif($answerType == FILL_IN_BLANKS)
  785. {
  786. display_fill_in_blanks_answer($answer);
  787. }
  788. elseif($answerType == FREE_ANSWER)
  789. {
  790. // to store the details of open questions in an array to be used in mail
  791. $arrques[] = $questionName;
  792. $arrans[] = $choice;
  793. $firstName = $_SESSION['_user']['firstName'];
  794. $lastName = $_SESSION['_user']['lastName'];
  795. $mail = $_SESSION['_user']['mail'];
  796. $coursecode = $_SESSION['_course']['id'];
  797. $to = '';
  798. $teachers = array();
  799. if(api_get_setting('use_session_mode')=='true' && !empty($_SESSION['id_session']))
  800. {
  801. $teachers = CourseManager::get_coach_list_from_course_code($coursecode,$_SESSION['id_session']);
  802. }
  803. else
  804. {
  805. $teachers = CourseManager::get_teacher_list_from_course_code($coursecode);
  806. }
  807. $num = count($teachers);
  808. if($num>1)
  809. {
  810. $to = array();
  811. foreach($teachers as $teacher)
  812. {
  813. $to[] = $teacher['email'];
  814. }
  815. }elseif($num>0){
  816. foreach($teachers as $teacher)
  817. {
  818. $to = $teacher['email'];
  819. }
  820. }else{
  821. //this is a problem (it means that there is no admin for this course)
  822. }
  823. display_free_answer($choice);
  824. }
  825. elseif($answerType == HOT_SPOT)
  826. {
  827. $tbl_track_e_hotspot = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
  828. // Save into db
  829. $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` )
  830. 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])."')";
  831. $result = api_sql_query($sql,__FILE__,__LINE__);
  832. display_hotspot_answer($answerId, $answer, $studentChoice, $answerComment);
  833. }
  834. elseif($answerType == HOT_SPOT_ORDER)
  835. {
  836. display_hotspot_order_answer($answerId, $answer, $studentChoice, $answerComment);
  837. }
  838. else
  839. {
  840. ?>
  841. <tr>
  842. <td width="50%">
  843. <?php
  844. $answer=api_parse_tex($answer);
  845. echo $answer; ?>
  846. </td>
  847. <td width="50%">
  848. <?php echo $choice[$answerId]; ?> / <font color="green"><b>
  849. <?php
  850. $matching[$answerCorrect]=api_parse_tex($matching[$answerCorrect]);
  851. echo $matching[$answerCorrect]; ?></b></font>
  852. </td>
  853. </tr>
  854. <?php
  855. }
  856. }
  857. } // end for that loops over all answers of the current question
  858. if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER)
  859. {
  860. // We made an extra table for the answers
  861. echo "</table></td></tr>";
  862. ?>
  863. <tr>
  864. <td colspan="2">
  865. <i><?php echo get_lang('Hotspot'); ?></i><br /><br />
  866. <object type="application/x-shockwave-flash" data="../plugin/hotspot/hotspot_solution.swf?modifyAnswers=<?php echo $questionId ?>&exe_id=&from_db=0" width="556" height="421">
  867. <param name="movie" value="../plugin/hotspot/hotspot_solution.swf?modifyAnswers=<?php echo $questionId ?>&exe_id=&from_db=0" />
  868. </object>
  869. </td>
  870. </tr>
  871. <?php
  872. }
  873. ?>
  874. <tr>
  875. <td colspan="<?php echo $colspan; ?>" align="left">
  876. <b>
  877. <?php
  878. if($questionScore==-1){
  879. echo get_lang('Score')." : 0/$questionWeighting";
  880. }
  881. else{
  882. echo get_lang('Score')." : $questionScore/$questionWeighting";
  883. }
  884. ?></b><br /><br />
  885. </td>
  886. </tr>
  887. </table>
  888. <?php
  889. // destruction of Answer
  890. unset($objAnswerTmp);
  891. $i++;
  892. $totalWeighting+=$questionWeighting;
  893. //added by priya saini
  894. if($_configuration['tracking_enabled'])
  895. {
  896. if(empty($choice)){
  897. $choice = 0;
  898. }
  899. if ($answerType==MULTIPLE_ANSWER )
  900. {
  901. if ($choice != 0)
  902. {
  903. $reply = array_keys($choice);
  904. for ($i=0;$i<sizeof($reply);$i++)
  905. {
  906. $ans = $reply[$i];
  907. exercise_attempt($questionScore,$ans,$quesId,$exeId,$i);
  908. }
  909. }
  910. else
  911. {
  912. exercise_attempt($questionScore, 0 ,$quesId,$exeId,0);
  913. }
  914. }
  915. elseif ($answerType==MATCHING)
  916. {
  917. $j=sizeof($matching)+1;
  918. for ($i=0;$i<sizeof($choice);$i++,$j++)
  919. {
  920. $val = $choice[$j];
  921. if (preg_match_all ('#<font color="red"><s>([0-9a-z ]*)</s></font>#', $val, $arr1))
  922. $val = $arr1[1][0];
  923. $val=addslashes($val);
  924. $val=strip_tags($val);
  925. $sql = "select position from $table_ans where question_id='".Database::escape_string($questionId)."' and answer='".Database::escape_string($val)."' AND correct=0";
  926. $res = api_sql_query($sql, __FILE__, __LINE__);
  927. $answer = mysql_result($res,0,"position");
  928. exercise_attempt($questionScore,$answer,$quesId,$exeId,$j);
  929. }
  930. }
  931. elseif ($answerType==FREE_ANSWER)
  932. {
  933. $answer = $choice;
  934. exercise_attempt($questionScore,$answer,$quesId,$exeId,0);
  935. }
  936. elseif ($answerType==UNIQUE_ANSWER)
  937. {
  938. $sql = "select id from $table_ans where question_id='".Database::escape_string($questionId)."' and position='".Database::escape_string($choice)."'";
  939. $res = api_sql_query($sql, __FILE__, __LINE__);
  940. $answer = mysql_result($res,0,"id");
  941. exercise_attempt($questionScore,$answer,$quesId,$exeId,0);
  942. }
  943. else
  944. {
  945. exercise_attempt($questionScore,$answer,$quesId,$exeId,0);
  946. }
  947. }
  948. } // end huge foreach() block that loops over all questions
  949. ?>
  950. <table width="100%" border="0" cellpadding="3" cellspacing="2">
  951. <tr>
  952. <td>
  953. <b><?php echo get_lang('YourTotalScore')." ";
  954. if($dsp_percent == true){
  955. echo number_format(($totalScore/$totalWeighting)*100,1,'.','')."%";
  956. }else{
  957. echo $totalScore."/".$totalWeighting;
  958. }
  959. ?></b>
  960. </td>
  961. </tr>
  962. <tr>
  963. <td>
  964. <br />
  965. <?php
  966. if ($origin != 'learnpath') {
  967. ?>
  968. <input type="submit" value="<?php echo get_lang('Finish'); ?>" />
  969. <?php
  970. } else {
  971. ?>
  972. <input type="button" onclick="top.location.href='../newscorm/lp_controller.php?cidReq=<?php echo api_get_course_id()?>&amp;action=view&amp;lp_id=<?php echo $learnpath_id ?>&amp;lp_item_id=<?php echo $learnpath_item_id ?>'" value="<?php echo get_lang('Finish'); ?>" />
  973. <?php }?>
  974. </td>
  975. </tr>
  976. </table>
  977. </form>
  978. <br />
  979. <?php
  980. /*
  981. ==============================================================================
  982. Tracking of results
  983. ==============================================================================
  984. */
  985. if($_configuration['tracking_enabled'])
  986. {
  987. // Updates the empty exercise
  988. $safe_lp_id = $learnpath_id==''?0:(int)$learnpath_id;
  989. $safe_lp_item_id = $learnpath_item_id==''?0:(int)$learnpath_item_id;
  990. update_event_exercice($exeId, $objExercise->selectId(),$totalScore,$totalWeighting,api_get_session_id(),$safe_lp_id,$safe_lp_item_id);
  991. }
  992. if($objExercise->results_disabled)
  993. {
  994. ob_end_clean();
  995. Display :: display_normal_message(get_lang('ExerciseFinished').'<br /><a href="exercice.php" />'.get_lang('Back').'</a>',false);
  996. }
  997. if ($origin != 'learnpath')
  998. {
  999. //we are not in learnpath tool
  1000. Display::display_footer();
  1001. }else{
  1002. //record the results in the learning path, using the SCORM interface (API)
  1003. echo '<script language="javascript" type="text/javascript">window.parent.API.void_save_asset('.$totalScore.','.$totalWeighting.');</script>'."\n";
  1004. echo '</body></html>';
  1005. }
  1006. if(count($arrques)>0)
  1007. {
  1008. $mycharset = api_get_setting('platform_charset');
  1009. $msg = '<html><head>
  1010. <link rel="stylesheet" href="'.api_get_path(WEB_CODE_PATH).'css/'.api_get_setting('stylesheets').'/default.css" type="text/css">
  1011. <meta content="text/html; charset='.$mycharset.'" http-equiv="content-type">';
  1012. $msg .= '</head>
  1013. <body><br />
  1014. <p>'.get_lang('OpenQuestionsAttempted').' :
  1015. </p>
  1016. <p>'.get_lang('AttemptDetails').' : ><br />
  1017. </p>
  1018. <table width="730" height="136" border="0" cellpadding="3" cellspacing="3">
  1019. <tr>
  1020. <td width="229" valign="top"><h2>&nbsp;&nbsp;'.get_lang('CourseName').'</h2></td>
  1021. <td width="469" valign="top"><h2>#course#</h2></td>
  1022. </tr>
  1023. <tr>
  1024. <td width="229" valign="top" class="outerframe">&nbsp;&nbsp;'.get_lang('TestAttempted').'</span></td>
  1025. <td width="469" valign="top" class="outerframe">#exercise#</td>
  1026. </tr>
  1027. <tr>
  1028. <td valign="top">&nbsp;&nbsp;<span class="style10">'.get_lang('StudentName').'</span></td>
  1029. <td valign="top" >#firstName# #lastName#</td>
  1030. </tr>
  1031. <tr>
  1032. <td valign="top" >&nbsp;&nbsp;'.get_lang('StudentEmail').' </td>
  1033. <td valign="top"> #mail#</td>
  1034. </tr></table>
  1035. <p><br />'.get_lang('OpenQuestionsAttemptedAre').' :</p>
  1036. <table width="730" height="136" border="0" cellpadding="3" cellspacing="3">';
  1037. for($i=0;$i<sizeof($arrques);$i++)
  1038. {
  1039. $msg.='
  1040. <tr>
  1041. <td width="220" valign="top" bgcolor="#E5EDF8">&nbsp;&nbsp;<span class="style10">'.get_lang('Question').'</span></td>
  1042. <td width="473" valign="top" bgcolor="#F3F3F3"><span class="style16"> #questionName#</span></td>
  1043. </tr>
  1044. <tr>
  1045. <td width="220" valign="top" bgcolor="#E5EDF8">&nbsp;&nbsp;<span class="style10">'.get_lang('Answer').' </span></td>
  1046. <td valign="top" bgcolor="#F3F3F3"><span class="style16"> #answer#</span></td>
  1047. </tr>';
  1048. $msg1= str_replace("#exercise#",$exerciseTitle,$msg);
  1049. $msg= str_replace("#firstName#",$firstName,$msg1);
  1050. $msg1= str_replace("#lastName#",$lastName,$msg);
  1051. $msg= str_replace("#mail#",$mail,$msg1);
  1052. $msg1= str_replace("#questionName#",$arrques[$i],$msg);
  1053. $msg= str_replace("#answer#",$arrans[$i],$msg1);
  1054. $msg1= str_replace("#i#",$i,$msg);
  1055. $msg= str_replace("#course#",$courseName,$msg1);
  1056. }
  1057. $msg.='</table><br>
  1058. <span class="style16">'.get_lang('ClickToCommentAndGiveFeedback').',<br />
  1059. <a href="#url#">#url#</a></span></body></html>';
  1060. $msg1= str_replace("#url#",$url,$msg);
  1061. $mail_content = stripslashes($msg1);
  1062. $student_name = $_SESSION['_user']['firstName'].' '.$_SESSION['_user']['lastName'];
  1063. $subject = get_lang('OpenQuestionsAttempted');
  1064. $from = api_get_setting('noreply_email_address');
  1065. if($from == ''){
  1066. if(isset($_SESSION['id_session']) && $_SESSION['id_session'] != ''){
  1067. $sql = 'SELECT user.email,user.lastname,user.firstname FROM '.TABLE_MAIN_SESSION.' as session, '.TABLE_MAIN_USER.' as user
  1068. WHERE session.id_coach = user.user_id
  1069. AND session.id = "'.Database::escape_string($_SESSION['id_session']).'"
  1070. ';
  1071. $result=api_sql_query($sql,__FILE__,__LINE__);
  1072. $from = mysql_result($result,0,'email');
  1073. $from_name = mysql_result($result,0,'firstname').' '.mysql_result($result,0,'lastname');
  1074. }
  1075. else{
  1076. $array = explode(' ',$_SESSION['_course']['titular']);
  1077. $firstname = $array[1];
  1078. $lastname = $array[0];
  1079. $sql = 'SELECT email,lastname,firstname FROM '.TABLE_MAIN_USER.'
  1080. WHERE firstname = "'.Database::escape_string($firstname).'"
  1081. AND lastname = "'.Database::escape_string($lastname).'"
  1082. ';
  1083. $result=api_sql_query($sql,__FILE__,__LINE__);
  1084. $from = mysql_result($result,0,'email');
  1085. $from_name = mysql_result($result,0,'firstname').' '.mysql_result($result,0,'lastname');
  1086. }
  1087. }
  1088. api_mail_html($student_name, $to, $subject, $mail_content, $from_name, $from, array('encoding'=>$mycharset,'charset'=>$mycharset));
  1089. }
  1090. ?>