exercise_result.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Exercise result
  5. * This script gets informations from the script "exercise_submit.php",
  6. * through the session, and calculates the score of the student for
  7. * that exercise.
  8. * Then it shows the results on the screen.
  9. * @package chamilo.exercise
  10. * @author Olivier Brouckaert, main author
  11. * @author Roan Embrechts, some refactoring
  12. * @author Julio Montoya Armas switchable fill in blank option added
  13. * @version $Id: exercise_result.php 22201 2009-07-17 19:57:03Z cfasanando $
  14. *
  15. * @todo split more code up in functions, move functions to library?
  16. */
  17. /* INIT SECTION */
  18. require_once 'exercise.class.php';
  19. require_once 'exercise.lib.php';
  20. require_once 'question.class.php';
  21. require_once 'answer.class.php';
  22. // Name of the language file that needs to be included
  23. $language_file='exercice';
  24. require_once '../inc/global.inc.php';
  25. if ($_GET['origin']=='learnpath') {
  26. require_once '../newscorm/learnpath.class.php';
  27. require_once '../newscorm/learnpathItem.class.php';
  28. require_once '../newscorm/scorm.class.php';
  29. require_once '../newscorm/scormItem.class.php';
  30. require_once '../newscorm/aicc.class.php';
  31. require_once '../newscorm/aiccItem.class.php';
  32. }
  33. require_once api_get_path(LIBRARY_PATH).'exercise_show_functions.lib.php';
  34. require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php';
  35. require_once api_get_path(LIBRARY_PATH).'course.lib.php';
  36. $this_section=SECTION_COURSES;
  37. /* ACCESS RIGHTS */
  38. // notice for unauthorized people.
  39. api_protect_course_script(true);
  40. // Database table definitions
  41. $TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
  42. $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
  43. $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
  44. $TBL_REPONSES = Database::get_course_table(TABLE_QUIZ_ANSWER);
  45. $TBL_TRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
  46. $TBL_TRACK_ATTEMPT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
  47. $main_user_table = Database::get_main_table(TABLE_MAIN_USER);
  48. $main_admin_table = Database::get_main_table(TABLE_MAIN_ADMIN);
  49. $main_course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
  50. //temp values to move to admin settings
  51. $dsp_percent = false; //false to display total score as absolute values
  52. //debug param. 0: no display - 1: debug display
  53. $debug=1;
  54. if($debug>0){error_log('Entered exercise_result.php: '.print_r($_POST,1));}
  55. // general parameters passed via POST/GET
  56. if ( empty ( $origin ) ) { $origin = Security::remove_XSS($_REQUEST['origin']);}
  57. if ( empty ( $learnpath_id ) ) { $learnpath_id = intval($_REQUEST['learnpath_id']);}
  58. if ( empty ( $learnpath_item_id ) ) { $learnpath_item_id = intval($_REQUEST['learnpath_item_id']);}
  59. if ( empty ( $learnpath_item_view_id ) ) { $learnpath_item_view_id = intval($_REQUEST['learnpath_item_view_id']);}
  60. if ( empty ( $formSent ) ) { $formSent = $_REQUEST['formSent'];}
  61. if ( empty ( $exerciseResult ) ) { $exerciseResult = $_SESSION['exerciseResult'];}
  62. if ( empty ( $exerciseResultCoordinates)){ $exerciseResultCoordinates = $_SESSION['exerciseResultCoordinates'];}
  63. if ( empty ( $questionId ) ) { $questionId = $_REQUEST['questionId'];}
  64. if ( empty ( $choice ) ) { $choice = $_REQUEST['choice'];}
  65. if ( empty ( $questionNum ) ) { $questionNum = $_REQUEST['questionNum'];}
  66. if ( empty ( $nbrQuestions ) ) { $nbrQuestions = $_REQUEST['nbrQuestions'];}
  67. if ( empty ( $questionList ) ) { $questionList = $_SESSION['questionList'];}
  68. if ( empty ( $objExercise ) ) { $objExercise = $_SESSION['objExercise'];}
  69. if ( empty ( $exerciseType ) ) { $exerciseType = $_REQUEST['exerciseType'];}
  70. //@todo There should be some doc about this settings
  71. $_configuration['live_exercise_tracking'] = false;
  72. if($_configuration['live_exercise_tracking']) define('ENABLED_LIVE_EXERCISE_TRACKING',1);
  73. if($_configuration['live_exercise_tracking'] && $exerciseType == 1){
  74. $_configuration['live_exercise_tracking'] = false;
  75. }
  76. $arrques = array();
  77. $arrans = array();
  78. // set admin name as person who sends the results e-mail (lacks policy about whom should really send the results)
  79. $query = "SELECT user_id FROM $main_admin_table LIMIT 1"; //get all admins from admin table
  80. $admin_id = Database::result(Database::query($query),0,"user_id");
  81. $uinfo = api_get_user_info($admin_id);
  82. $from = $uinfo['mail'];
  83. $from_name = api_get_person_name($uinfo['firstname'], $uinfo['lastname'], null, PERSON_NAME_EMAIL_ADDRESS);
  84. $str = $_SERVER['REQUEST_URI'];
  85. $url = api_get_path(WEB_CODE_PATH).'exercice/exercice.php?'.api_get_cidreq().'&show=result';
  86. // if the above variables are empty or incorrect, we don't have any result to show, so stop the script
  87. if(!is_array($exerciseResult) || !is_array($questionList) || !is_object($objExercise)) {
  88. if ($debug) {error_log('Exit exercise result'); error_log('$exerciseResult:'.print_r($exerciseResult,1)); error_log('$questionList:'.print_r($questionList,1));error_log('$objExercise:'.print_r($objExercise,1));}
  89. header('Location: exercice.php');
  90. exit();
  91. }
  92. $gradebook = '';
  93. if (isset($_SESSION['gradebook'])) {
  94. $gradebook= $_SESSION['gradebook'];
  95. }
  96. if (!empty($gradebook) && $gradebook=='view') {
  97. $interbreadcrumb[]= array ('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('ToolGradebook'));
  98. }
  99. $nameTools=get_lang('Exercice');
  100. $interbreadcrumb[]=array("url" => "exercice.php?gradebook=$gradebook","name" => get_lang('Exercices'));
  101. //$htmlHeadXtra[] = $objExercise->show_lp_javascript();
  102. if ($origin != 'learnpath') {
  103. //so we are not in learnpath tool
  104. Display::display_header($nameTools,get_lang('Exercise'));
  105. } else {
  106. header('Content-Type: text/html; charset='.api_get_system_encoding());
  107. $document_language = api_get_language_isocode();
  108. /* HTML HEADER */
  109. ?>
  110. <!DOCTYPE html
  111. PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  112. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  113. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $document_language; ?>" lang="<?php echo $document_language; ?>">
  114. <head>
  115. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>" />
  116. <link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_CODE_PATH).'css/'.api_get_setting('stylesheets').'/default.css'; ?>" />
  117. </head>
  118. <body dir="<?php echo api_get_text_direction(); ?>">
  119. <?php
  120. }
  121. if ($objExercise->results_disabled) {
  122. ob_start();
  123. }
  124. /* DISPLAY AND MAIN PROCESS */
  125. // I'm in a preview mode as course admin. Display the action menu.
  126. if (api_is_course_admin() && $origin != 'learnpath') {
  127. echo '<div class="actions">';
  128. echo Display::return_icon('back.png', get_lang('GoBackToQuestionList')).'<a href="admin.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'">'.get_lang('GoBackToQuestionList').'</a>';
  129. echo Display::return_icon('edit.gif', get_lang('ModifyExercise')).'<a href="exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$objExercise->id.'">'.get_lang('ModifyExercise').'</a>';
  130. echo '</div>';
  131. }
  132. $exerciseTitle=text_filter($objExercise->selectTitle());
  133. //show exercise title
  134. if($origin != 'learnpath') {?>
  135. <h2><?php echo Display::return_icon('quiz_big.png', get_lang('Result')).' '; echo $exerciseTitle; ?> : <?php echo get_lang("Result"); ?></h2>
  136. <?php echo $objExercise->selectDescription(); ?>
  137. <?php } ?>
  138. <form method="get" action="exercice.php?<?php echo api_get_cidreq() ?>">
  139. <input type="hidden" name="origin" value="<?php echo $origin; ?>" />
  140. <input type="hidden" name="learnpath_id" value="<?php echo $learnpath_id; ?>" />
  141. <input type="hidden" name="learnpath_item_id" value="<?php echo $learnpath_item_id; ?>" />
  142. <input type="hidden" name="learnpath_item_view_id" value="<?php echo $learnpath_item_view_id; ?>" />
  143. <?php
  144. $i=$totalScore=$totalWeighting=0;
  145. if($debug>0){error_log ("ExerciseResult: ".print_r($exerciseResult,1)); error_log("QuestionList: ".print_r($questionList,1));}
  146. if ($_configuration['tracking_enabled']) {
  147. // Create an empty exercise
  148. if (api_is_allowed_to_session_edit() )
  149. $exeId= create_event_exercice($objExercise->selectId());
  150. }
  151. $counter=0;
  152. // Loop over all question to show results for each of them, one by one
  153. foreach ($questionList as $questionId) {
  154. $counter++;
  155. // gets the student choice for this question
  156. $choice = $exerciseResult[$questionId];
  157. // creates a temporary Question object
  158. $objQuestionTmp = Question :: read($questionId);
  159. // initialize question information
  160. $questionName = $objQuestionTmp->selectTitle();
  161. $questionDescription = $objQuestionTmp->selectDescription();
  162. $questionWeighting = $objQuestionTmp->selectWeighting();
  163. $answerType = $objQuestionTmp->selectType();
  164. $quesId = $objQuestionTmp->selectId(); //added by priya saini
  165. // destruction of the Question object
  166. unset($objQuestionTmp);
  167. // decide how many columns we want to use to show the results of each type
  168. if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_COMBINATION) {
  169. $colspan=4;
  170. } elseif($answerType == MATCHING || $answerType == FREE_ANSWER) {
  171. $colspan=2;
  172. } elseif($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER) {
  173. $colspan=4;
  174. $rowspan=$nbrAnswers+1;
  175. } else {
  176. $colspan=1;
  177. }
  178. // show titles
  179. if ($origin != 'learnpath') {?>
  180. <table width="100%" border="0" cellpadding="3" cellspacing="2">
  181. <tr>
  182. <td colspan="<?php echo $colspan; ?>">
  183. <div id="question_title" class="sectiontitle">
  184. <?php echo get_lang("Question").' '.($counter).' : '.$questionName; ?>
  185. </div>
  186. </td>
  187. </tr>
  188. <tr>
  189. <td colspan="<?php echo $colspan; ?>">
  190. <i><?php echo $questionDescription; ?></i>
  191. </td>
  192. </tr>
  193. <?php
  194. if ($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_COMBINATION ) {
  195. ?>
  196. <tr>
  197. <td width="5%" valign="top" align="center" nowrap="nowrap">
  198. <i><?php echo get_lang("Choice"); ?></i>
  199. </td>
  200. <td width="5%" align="center" nowrap="nowrap">
  201. <i><?php echo get_lang("ExpectedChoice"); ?></i>
  202. </td>
  203. <td width="45%" valign="top">
  204. <i><?php echo get_lang("Answer"); ?></i>
  205. </td>
  206. <?php if ($objExercise->feedbacktype != EXERCISE_FEEDBACK_TYPE_EXAM) { ?>
  207. <td width="45%" valign="top">
  208. <i><?php echo get_lang("Comment"); ?></i>
  209. </td>
  210. <?php } else { ?>
  211. <td>&nbsp;</td>
  212. <?php } ?>
  213. </tr>
  214. <?php
  215. } elseif ($answerType == FILL_IN_BLANKS) { ?>
  216. <tr>
  217. <td>
  218. <i><?php echo get_lang("Answer"); ?></i>
  219. </td>
  220. </tr>
  221. <?php
  222. } elseif ($answerType == FREE_ANSWER) {
  223. ?>
  224. <tr>
  225. <td width="55%">
  226. <i><?php echo get_lang("Answer"); ?></i>
  227. </td>
  228. <?php if ($objExercise->feedbacktype != EXERCISE_FEEDBACK_TYPE_EXAM) { ?>
  229. <td width="45%" valign="top">
  230. <i><?php echo get_lang("Comment"); ?></i>
  231. </td>
  232. <?php } else { ?>
  233. <td>&nbsp;</td>
  234. <?php } ?>
  235. </tr>
  236. <?php
  237. } elseif ($answerType == HOT_SPOT) {
  238. ?>
  239. <tr>
  240. <td valign="top" colspan="2">
  241. <table width="552" border="1" bordercolor="#A4A4A4" style="border-collapse: collapse;">
  242. <tr>
  243. <td width="152" valign="top">
  244. <i><?php echo get_lang("CorrectAnswer"); ?></i><br /><br />
  245. </td>
  246. <td width="100" valign="top">
  247. <i><?php echo get_lang('HotspotHit'); ?></i><br /><br />
  248. </td>
  249. <?php if ($objExercise->feedbacktype != EXERCISE_FEEDBACK_TYPE_EXAM) { ?>
  250. <td width="300" valign="top">
  251. <i><?php echo get_lang("Comment"); ?></i><br /><br />
  252. </td>
  253. <?php } else { ?>
  254. <td>&nbsp;</td>
  255. <?php } ?>
  256. </tr>
  257. <?php
  258. } else { //matching type
  259. ?>
  260. <tr>
  261. <td width="50%">
  262. <i><?php echo get_lang("ElementList"); ?></i>
  263. </td>
  264. <td width="50%">
  265. <i><?php echo get_lang("CorrespondsTo"); ?></i>
  266. </td>
  267. </tr>
  268. <?php
  269. }
  270. }
  271. // We're inside *one* question. Go through each possible answer for this question
  272. $result = $objExercise->manage_answer($exeId, $questionId, $choice,'exercise_result', $exerciseResultCoordinates, true);
  273. $totalScore += $result['score'];
  274. $totalWeighting += $result['weight'];
  275. } // end huge foreach() block that loops over all questions
  276. if($origin != 'learnpath') {
  277. echo '<div id="question_score">';
  278. echo get_lang('YourTotalScore')." ";
  279. if ($dsp_percent) {
  280. echo number_format(($totalScore/$totalWeighting)*100,1,'.','')."%";
  281. } else {
  282. echo float_format($totalScore,1)."/".float_format($totalWeighting,1);
  283. }
  284. echo '</div>';
  285. ?>
  286. <button type="submit" class="save"><?php echo get_lang('Finish');?></button>
  287. <?php
  288. }
  289. // Tracking of results
  290. if ($_configuration['tracking_enabled']) {
  291. // Updates the empty exercise
  292. $safe_lp_id = $learnpath_id==''?0:(int)$learnpath_id;
  293. $safe_lp_item_id = $learnpath_item_id==''?0:(int)$learnpath_item_id;
  294. $safe_lp_item_view_id = $learnpath_item_view_id==''?0:(int)$learnpath_item_view_id;
  295. $quizDuration = (!empty($_SESSION['quizStartTime']) ? time() - $_SESSION['quizStartTime'] : 0);
  296. if (api_is_allowed_to_session_edit() ) {
  297. update_event_exercice($exeId, $objExercise->selectId(),$totalScore, $totalWeighting,api_get_session_id(),$safe_lp_id,$safe_lp_item_id,$safe_lp_item_view_id, $quizDuration);
  298. }
  299. }
  300. if($objExercise->results_disabled) {
  301. ob_end_clean();
  302. if ($origin != 'learnpath') {
  303. Display :: display_normal_message(get_lang('ExerciseFinished').'<br /><a href="exercice.php" />'.get_lang('Back').'</a>',false);
  304. } else {
  305. Display :: display_normal_message(get_lang('ExerciseFinished').'<br /><br />',false);
  306. $lp_mode = $_SESSION['lp_mode'];
  307. $url = '../newscorm/lp_controller.php?cidReq='.api_get_course_id().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exeId.'&fb_type='.$objExercise->feedbacktype;
  308. $href = ($lp_mode == 'fullscreen')?' window.opener.location.href="'.$url.'" ':' top.location.href="'.$url.'" ';
  309. echo '<script language="javascript" type="text/javascript">'.$href.'</script>'."\n";
  310. //record the results in the learning path, using the SCORM interface (API)
  311. echo '<script language="javascript" type="text/javascript">window.parent.API.void_save_asset('.$totalScore.','.$totalWeighting.');</script>'."\n";
  312. echo '</body></html>';
  313. }
  314. } else {
  315. //show score
  316. if ($origin == 'learnpath') {
  317. Display::display_normal_message(get_lang('ExerciseFinished'));
  318. $lp_mode = $_SESSION['lp_mode'];
  319. $url = '../newscorm/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exeId.'&fb_type='.$objExercise->feedbacktype;
  320. $href = ($lp_mode == 'fullscreen')?' window.opener.location.href="'.$url.'" ':' top.location.href="'.$url.'" ';
  321. echo '<script language="javascript" type="text/javascript">'.$href.'</script>'."\n";
  322. //record the results in the learning path, using the SCORM interface (API)
  323. echo '<script language="javascript" type="text/javascript">window.parent.API.void_save_asset('.$totalScore.','.$totalWeighting.');</script>'."\n";
  324. echo '</body></html>';
  325. }
  326. }
  327. if ($origin != 'learnpath') {
  328. //we are not in learnpath tool
  329. Display::display_footer();
  330. }
  331. // Email configuration settings
  332. require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
  333. $user_info = UserManager::get_user_info_by_id(api_get_user_id());
  334. $firstName = $user_info['firstname'];
  335. $lastName = $user_info['lastname'];
  336. $mail = $user_info['email'];
  337. $coursecode = api_get_course_id();
  338. $courseName = $_SESSION['_course']['name'];
  339. $to = '';
  340. $teachers = array();
  341. if(api_get_setting('use_session_mode')=='true' && !empty($_SESSION['id_session'])) {
  342. $teachers = CourseManager::get_coach_list_from_course_code($coursecode,$_SESSION['id_session']);
  343. } else {
  344. $teachers = CourseManager::get_teacher_list_from_course_code($coursecode);
  345. }
  346. $num = count($teachers);
  347. if($num>1) {
  348. $to = array();
  349. foreach($teachers as $teacher) {
  350. $to[] = $teacher['email'];
  351. }
  352. }elseif($num>0){
  353. foreach($teachers as $teacher) {
  354. $to = $teacher['email'];
  355. }
  356. } else {
  357. //this is a problem (it means that there is no admin for this course)
  358. }
  359. // we are able to send emails to the teachers?
  360. if (api_get_course_setting('email_alert_manager_on_new_quiz') == 1 ) {
  361. // only for "simple tests"
  362. if ($origin != 'learnpath') {
  363. //has a unique answer?
  364. $mycharset = api_get_system_encoding();
  365. $msg = '<html><head>
  366. <link rel="stylesheet" href="'.api_get_path(WEB_CODE_PATH).'css/'.api_get_setting('stylesheets').'/default.css" type="text/css">
  367. <meta content="text/html; charset='.$mycharset.'" http-equiv="content-type"></head>';
  368. if(count($arrques)>0) {
  369. $msg .= '
  370. <body><br />
  371. <p>'.get_lang('OpenQuestionsAttempted').' :
  372. </p>
  373. <p>'.get_lang('AttemptDetails').' : <br />
  374. </p>
  375. <table width="730" height="136" border="0" cellpadding="3" cellspacing="3">
  376. <tr>
  377. <td width="229" valign="top"><h2>&nbsp;&nbsp;'.get_lang('CourseName').'</h2></td>
  378. <td width="469" valign="top"><h2>#course#</h2></td>
  379. </tr>
  380. <tr>
  381. <td width="229" valign="top" class="outerframe">&nbsp;&nbsp;'.get_lang('TestAttempted').'</span></td>
  382. <td width="469" valign="top" class="outerframe">#exercise#</td>
  383. </tr>
  384. <tr>
  385. <td valign="top">&nbsp;&nbsp;<span class="style10">'.get_lang('StudentName').'</span></td>
  386. '.(api_is_western_name_order() ? '<td valign="top" >#firstName# #lastName#</td>' : '<td valign="top" >#lastName# #firstName#</td>').'
  387. </tr>
  388. <tr>
  389. <td valign="top" >&nbsp;&nbsp;'.get_lang('StudentEmail').' </td>
  390. <td valign="top"> #mail#</td>
  391. </tr></table>
  392. <p><br />'.get_lang('OpenQuestionsAttemptedAre').' :</p>
  393. <table width="730" height="136" border="0" cellpadding="3" cellspacing="3">';
  394. for($i=0;$i<sizeof($arrques);$i++) {
  395. $msg.='
  396. <tr>
  397. <td width="220" valign="top" bgcolor="#E5EDF8">&nbsp;&nbsp;<span class="style10">'.get_lang('Question').'</span></td>
  398. <td width="473" valign="top" bgcolor="#F3F3F3"><span class="style16"> #questionName#</span></td>
  399. </tr>
  400. <tr>
  401. <td width="220" valign="top" bgcolor="#E5EDF8">&nbsp;&nbsp;<span class="style10">'.get_lang('Answer').' </span></td>
  402. <td valign="top" bgcolor="#F3F3F3"><span class="style16"> #answer#</span></td>
  403. </tr>';
  404. $msg1= str_replace("#exercise#",$exerciseTitle,$msg);
  405. $msg= str_replace("#firstName#",$firstName,$msg1);
  406. $msg1= str_replace("#lastName#",$lastName,$msg);
  407. $msg= str_replace("#mail#",$mail,$msg1);
  408. $msg1= str_replace("#questionName#",$arrques[$i],$msg);
  409. $msg= str_replace("#answer#",$arrans[$i],$msg1);
  410. $msg1= str_replace("#i#",$i,$msg);
  411. $msg= str_replace("#course#",$courseName,$msg1);
  412. }
  413. $msg.='</table><br>
  414. <span class="style16">'.get_lang('ClickToCommentAndGiveFeedback').',<br />
  415. <a href="#url#">#url#</a></span></body></html>';
  416. $msg1= str_replace("#url#",$url,$msg);
  417. $mail_content = $msg1;
  418. $sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
  419. $email_admin = api_get_setting('emailAdministrator');
  420. $subject = get_lang('OpenQuestionsAttempted');
  421. $result = @api_mail_html('', $to, $subject, $mail_content, $sender_name, $email_admin, array('charset'=>$mycharset));
  422. } else {
  423. $msg .= '<body>
  424. <p>'.get_lang('ExerciseAttempted').' <br />
  425. </p>
  426. <table width="730" height="136" border="0" cellpadding="3" cellspacing="3">
  427. <tr>
  428. <td width="229" valign="top"><h2>&nbsp;&nbsp;'.get_lang('CourseName').'</h2></td>
  429. <td width="469" valign="top"><h2>#course#</h2></td>
  430. </tr>
  431. <tr>
  432. <td width="229" valign="top" class="outerframe">&nbsp;&nbsp;'.get_lang('TestAttempted').'</span></td>
  433. <td width="469" valign="top" class="outerframe">#exercise#</td>
  434. </tr>
  435. <tr>
  436. <td valign="top">&nbsp;&nbsp;<span class="style10">'.get_lang('StudentName').'</span></td>
  437. '.(api_is_western_name_order() ? '<td valign="top" >#firstName# #lastName#</td>' : '<td valign="top" >#lastName# #firstName#</td>').'
  438. </tr>
  439. <tr>
  440. <td valign="top" >&nbsp;&nbsp;'.get_lang('StudentEmail').' </td>
  441. <td valign="top"> #mail#</td>
  442. </tr></table>';
  443. $msg= str_replace("#exercise#",$exerciseTitle,$msg);
  444. $msg= str_replace("#firstName#",$firstName,$msg);
  445. $msg= str_replace("#lastName#",$lastName,$msg);
  446. $msg= str_replace("#mail#",$mail,$msg);
  447. $msg= str_replace("#course#",$courseName,$msg);
  448. $msg.='<br />
  449. <span class="style16">'.get_lang('ClickToCommentAndGiveFeedback').',<br />
  450. <a href="#url#">#url#</a></span></body></html>';
  451. $msg= str_replace("#url#",$url,$msg);
  452. $mail_content = $msg;
  453. $sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
  454. $email_admin = api_get_setting('emailAdministrator');
  455. $subject = get_lang('ExerciseAttempted');
  456. $result = @api_mail_html('', $to, $subject, $mail_content, $sender_name, $email_admin, array('charset'=>$mycharset));
  457. }
  458. }
  459. }