exercise_show.php 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use ChamiloSession as Session;
  4. /**
  5. * Shows the exercise results.
  6. *
  7. * @author Julio Montoya - Added switchable fill in blank option added
  8. *
  9. * @version $Id: exercise_show.php 22256 2009-07-20 17:40:20Z ivantcholakov $
  10. *
  11. * @package chamilo.exercise
  12. *
  13. * @todo remove the debug code and use the general debug library
  14. * @todo small letters for table variables
  15. */
  16. require_once __DIR__.'/../inc/global.inc.php';
  17. $debug = false;
  18. $origin = api_get_origin();
  19. $currentUserId = api_get_user_id();
  20. $printHeaders = $origin === 'learnpath';
  21. $id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0; //exe id
  22. if (empty($id)) {
  23. api_not_allowed(true);
  24. }
  25. // Getting results from the exe_id. This variable also contain all the information about the exercise
  26. $track_exercise_info = ExerciseLib::get_exercise_track_exercise_info($id);
  27. //No track info
  28. if (empty($track_exercise_info)) {
  29. api_not_allowed($printHeaders);
  30. }
  31. $exercise_id = $track_exercise_info['id'];
  32. $student_id = $track_exercise_info['exe_user_id'];
  33. $learnpath_id = $track_exercise_info['orig_lp_id'];
  34. $learnpath_item_id = $track_exercise_info['orig_lp_item_id'];
  35. $lp_item_view_id = $track_exercise_info['orig_lp_item_view_id'];
  36. $isBossOfStudent = false;
  37. if (api_is_student_boss()) {
  38. // Check if boss has access to user info.
  39. if (UserManager::userIsBossOfStudent($currentUserId, $student_id)) {
  40. $isBossOfStudent = true;
  41. } else {
  42. api_not_allowed($printHeaders);
  43. }
  44. } else {
  45. api_protect_course_script($printHeaders, false, true);
  46. }
  47. // Database table definitions
  48. $TBL_EXERCISE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
  49. $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
  50. $TBL_TRACK_EXERCISES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
  51. $TBL_TRACK_ATTEMPT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
  52. if (empty($formSent)) {
  53. $formSent = isset($_REQUEST['formSent']) ? $_REQUEST['formSent'] : null;
  54. }
  55. if (empty($exerciseResult)) {
  56. $exerciseResult = Session::read('exerciseResult');
  57. }
  58. if (empty($choiceDegreeCertainty)) {
  59. $choiceDegreeCertainty = isset($_REQUEST['choiceDegreeCertainty']) ? $_REQUEST['choiceDegreeCertainty'] : null;
  60. }
  61. $questionId = isset($_REQUEST['questionId']) ? $_REQUEST['questionId'] : null;
  62. if (empty($choice)) {
  63. $choice = isset($_REQUEST['choice']) ? $_REQUEST['choice'] : null;
  64. }
  65. if (empty($questionNum)) {
  66. $questionNum = isset($_REQUEST['num']) ? $_REQUEST['num'] : null;
  67. }
  68. if (empty($nbrQuestions)) {
  69. $nbrQuestions = isset($_REQUEST['nbrQuestions']) ? $_REQUEST['nbrQuestions'] : null;
  70. }
  71. if (empty($questionList)) {
  72. $questionList = Session::read('questionList');
  73. }
  74. if (empty($objExercise)) {
  75. $objExercise = Session::read('objExercise');
  76. }
  77. $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
  78. $courseInfo = api_get_course_info();
  79. $sessionId = api_get_session_id();
  80. $is_allowedToEdit =
  81. api_is_allowed_to_edit(null, true) ||
  82. api_is_course_tutor() ||
  83. api_is_session_admin() ||
  84. api_is_drh() ||
  85. api_is_student_boss();
  86. if (!empty($sessionId) && !$is_allowedToEdit) {
  87. if (api_is_course_session_coach(
  88. $currentUserId,
  89. api_get_course_int_id(),
  90. $sessionId
  91. )) {
  92. if (!api_coach_can_edit_view_results(api_get_course_int_id(), $sessionId)) {
  93. api_not_allowed($printHeaders);
  94. }
  95. }
  96. } else {
  97. if (!$is_allowedToEdit) {
  98. api_not_allowed($printHeaders);
  99. }
  100. }
  101. $allowCoachFeedbackExercises = api_get_setting('allow_coach_feedback_exercises') === 'true';
  102. $maxEditors = (int) api_get_setting('exercise_max_ckeditors_in_page');
  103. $isCoachAllowedToEdit = api_is_allowed_to_edit(false, true);
  104. $isFeedbackAllowed = false;
  105. if (api_is_excluded_user_type(true, $student_id)) {
  106. api_not_allowed($printHeaders);
  107. }
  108. $locked = api_resource_is_locked_by_gradebook($exercise_id, LINK_EXERCISE);
  109. if (empty($objExercise)) {
  110. $objExercise = new Exercise();
  111. $objExercise->read($exercise_id);
  112. }
  113. $feedback_type = $objExercise->feedback_type;
  114. // Only users can see their own results
  115. if (!$is_allowedToEdit) {
  116. if ($student_id != $currentUserId) {
  117. api_not_allowed($printHeaders);
  118. }
  119. }
  120. $allowRecordAudio = api_get_setting('enable_record_audio') === 'true';
  121. $allowTeacherCommentAudio = api_get_configuration_value('allow_teacher_comment_audio') === true;
  122. if (api_is_in_gradebook()) {
  123. $interbreadcrumb[] = [
  124. 'url' => Category::getUrl(),
  125. 'name' => get_lang('ToolGradebook'),
  126. ];
  127. }
  128. $interbreadcrumb[] = [
  129. 'url' => 'exercise.php?'.api_get_cidreq(),
  130. 'name' => get_lang('Exercises'),
  131. ];
  132. $interbreadcrumb[] = [
  133. 'url' => 'overview.php?exerciseId='.$exercise_id.'&'.api_get_cidreq(),
  134. 'name' => $objExercise->selectTitle(true),
  135. ];
  136. $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Result')];
  137. $this_section = SECTION_COURSES;
  138. $htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/css/hotspot.css">';
  139. $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/js/hotspot.js"></script>';
  140. $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'annotation/js/annotation.js"></script>';
  141. if ($allowRecordAudio && $allowTeacherCommentAudio) {
  142. $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'rtc/RecordRTC.js"></script>';
  143. $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'wami-recorder/recorder.js"></script>';
  144. $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'wami-recorder/gui.js"></script>';
  145. $htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'swfobject/swfobject.js"></script>';
  146. $htmlHeadXtra[] = api_get_js('record_audio/record_audio.js');
  147. }
  148. if ($action != 'export') {
  149. $scoreJsCode = ExerciseLib::getJsCode();
  150. if ($origin != 'learnpath') {
  151. Display::display_header('');
  152. } else {
  153. $htmlHeadXtra[] = "<style>body { background: none; } </style>";
  154. Display::display_reduced_header();
  155. }
  156. echo Display::toolbarAction('toolbar', [
  157. Display::url(
  158. Display::return_icon('pdf.png', get_lang('Export')),
  159. api_get_self().'?'.api_get_cidreq().'&id='.$id.'&action=export&'
  160. ),
  161. ]); ?>
  162. <script>
  163. <?php echo $scoreJsCode; ?>
  164. var maxEditors = <?php echo $maxEditors; ?>;
  165. function showfck(sid, marksid) {
  166. $('#' + sid).toggleClass('hidden');
  167. $('#' + marksid).toggleClass('hidden');
  168. $('#feedback_' + sid).toggleClass('hidden', !$('#' + sid).is('.hidden'));
  169. }
  170. function openEmailWrapper() {
  171. $('#email_content_wrapper').toggle();
  172. }
  173. function getFCK(vals, marksid) {
  174. var f = document.getElementById('form-email');
  175. var m_id = marksid.split(',');
  176. for (var i = 0; i < m_id.length; i++) {
  177. var oHidn = document.createElement("input");
  178. oHidn.type = "hidden";
  179. var selname = oHidn.name = "marks_" + m_id[i];
  180. var selid = document.forms['marksform_' + m_id[i]].marks.selectedIndex;
  181. oHidn.value = document.forms['marksform_' + m_id[i]].marks.options[selid].value;
  182. f.appendChild(oHidn);
  183. }
  184. var ids = vals.split(',');
  185. for (var k = 0; k < ids.length; k++) {
  186. var oHidden = document.createElement("input");
  187. oHidden.type = "hidden";
  188. oHidden.name = "comments_" + ids[k];
  189. if (CKEDITOR.instances[oHidden.name]) {
  190. oHidden.value = CKEDITOR.instances[oHidden.name].getData();
  191. } else {
  192. oHidden.value = $("textarea[name='" + oHidden.name + "']").val();
  193. }
  194. f.appendChild(oHidden);
  195. }
  196. }
  197. </script>
  198. <?php
  199. }
  200. $show_results = true;
  201. $show_only_total_score = false;
  202. $showTotalScoreAndUserChoicesInLastAttempt = true;
  203. // Avoiding the "Score 0/0" message when the exe_id is not set
  204. if (!empty($track_exercise_info)) {
  205. // if the results_disabled of the Quiz is 1 when block the script
  206. $result_disabled = $track_exercise_info['results_disabled'];
  207. switch ($result_disabled) {
  208. case RESULT_DISABLE_NO_SCORE_AND_EXPECTED_ANSWERS:
  209. $show_results = false;
  210. break;
  211. case RESULT_DISABLE_SHOW_SCORE_ONLY:
  212. $show_results = false;
  213. $show_only_total_score = true;
  214. if ($origin != 'learnpath') {
  215. if ($currentUserId == $student_id) {
  216. echo Display::return_message(
  217. get_lang('ThankYouForPassingTheTest'),
  218. 'warning',
  219. false
  220. );
  221. }
  222. }
  223. break;
  224. case RESULT_DISABLE_DONT_SHOW_SCORE_ONLY_IF_USER_FINISHES_ATTEMPTS_SHOW_ALWAYS_FEEDBACK:
  225. case RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT:
  226. $attempts = Event::getExerciseResultsByUser(
  227. $currentUserId,
  228. $objExercise->id,
  229. api_get_course_int_id(),
  230. api_get_session_id(),
  231. $track_exercise_info['orig_lp_id'],
  232. $track_exercise_info['orig_lp_item_id'],
  233. 'desc'
  234. );
  235. $numberAttempts = count($attempts);
  236. if ($numberAttempts >= $track_exercise_info['max_attempt']) {
  237. $show_results = true;
  238. $show_only_total_score = true;
  239. // Attempt reach max so show score/feedback now
  240. $showTotalScoreAndUserChoicesInLastAttempt = true;
  241. } else {
  242. $show_results = true;
  243. $show_only_total_score = true;
  244. // Last attempt not reach don't show score/feedback
  245. $showTotalScoreAndUserChoicesInLastAttempt = false;
  246. }
  247. break;
  248. }
  249. } else {
  250. echo Display::return_message(get_lang('CantViewResults'), 'warning');
  251. $show_results = false;
  252. }
  253. if ($origin == 'learnpath' && !isset($_GET['fb_type'])) {
  254. $show_results = false;
  255. }
  256. if ($is_allowedToEdit && in_array($action, ['qualify', 'edit', 'export'])) {
  257. $show_results = true;
  258. }
  259. if ($action == 'export') {
  260. ob_start();
  261. }
  262. $user_info = api_get_user_info($student_id);
  263. if ($show_results || $show_only_total_score || $showTotalScoreAndUserChoicesInLastAttempt) {
  264. // Shows exercise header
  265. echo $objExercise->showExerciseResultHeader(
  266. $user_info,
  267. $track_exercise_info
  268. );
  269. }
  270. $i = $totalScore = $totalWeighting = 0;
  271. if ($debug > 0) {
  272. error_log("ExerciseResult: ".print_r($exerciseResult, 1));
  273. error_log("QuestionList: ".print_r($questionList, 1));
  274. }
  275. $arrques = [];
  276. $arrans = [];
  277. $user_restriction = $is_allowedToEdit ? '' : "AND user_id=".intval($student_id)." ";
  278. $sql = "SELECT attempts.question_id, answer
  279. FROM $TBL_TRACK_ATTEMPT as attempts
  280. INNER JOIN ".$TBL_TRACK_EXERCISES." AS stats_exercises
  281. ON stats_exercises.exe_id=attempts.exe_id
  282. INNER JOIN $TBL_EXERCISE_QUESTION AS quizz_rel_questions
  283. ON
  284. quizz_rel_questions.exercice_id=stats_exercises.exe_exo_id AND
  285. quizz_rel_questions.question_id = attempts.question_id AND
  286. quizz_rel_questions.c_id=".api_get_course_int_id()."
  287. INNER JOIN ".$TBL_QUESTIONS." AS questions
  288. ON
  289. questions.id = quizz_rel_questions.question_id AND
  290. questions.c_id = ".api_get_course_int_id()."
  291. WHERE
  292. attempts.exe_id = ".$id." $user_restriction
  293. GROUP BY quizz_rel_questions.question_order, attempts.question_id";
  294. $result = Database::query($sql);
  295. $question_list_from_database = [];
  296. $exerciseResult = [];
  297. while ($row = Database::fetch_array($result)) {
  298. $question_list_from_database[] = $row['question_id'];
  299. $exerciseResult[$row['question_id']] = $row['answer'];
  300. }
  301. // Fixing #2073 Fixing order of questions
  302. if (!empty($track_exercise_info['data_tracking'])) {
  303. $temp_question_list = explode(',', $track_exercise_info['data_tracking']);
  304. // Getting question list from data_tracking
  305. if (!empty($temp_question_list)) {
  306. $questionList = $temp_question_list;
  307. }
  308. // If for some reason data_tracking is empty we select the question list from db
  309. if (empty($questionList)) {
  310. $questionList = $question_list_from_database;
  311. }
  312. } else {
  313. $questionList = $question_list_from_database;
  314. }
  315. // Display the text when finished message if we are on a LP #4227
  316. $end_of_message = $objExercise->selectTextWhenFinished();
  317. if (!empty($end_of_message) && ($origin === 'learnpath')) {
  318. echo Display::return_message($end_of_message, 'normal', false);
  319. echo "<div class='clear'>&nbsp;</div>";
  320. }
  321. // for each question
  322. $total_weighting = 0;
  323. foreach ($questionList as $questionId) {
  324. $objQuestionTmp = Question::read($questionId);
  325. if ($objQuestionTmp) {
  326. $total_weighting += $objQuestionTmp->selectWeighting();
  327. }
  328. }
  329. $counter = 1;
  330. $exercise_content = '';
  331. $category_list = [];
  332. $useAdvancedEditor = true;
  333. if (!empty($maxEditors) && count($questionList) > $maxEditors) {
  334. $useAdvancedEditor = false;
  335. }
  336. $objExercise->export = $action === 'export';
  337. $arrid = [];
  338. $arrmarks = [];
  339. $strids = '';
  340. $marksid = '';
  341. $countPendingQuestions = 0;
  342. foreach ($questionList as $questionId) {
  343. $choice = isset($exerciseResult[$questionId]) ? $exerciseResult[$questionId] : '';
  344. // destruction of the Question object
  345. unset($objQuestionTmp);
  346. $questionWeighting = 0;
  347. $answerType = 0;
  348. $questionScore = 0;
  349. // Creates a temporary Question object
  350. $objQuestionTmp = Question::read($questionId);
  351. if (empty($objQuestionTmp)) {
  352. continue;
  353. }
  354. $questionWeighting = $objQuestionTmp->selectWeighting();
  355. $answerType = $objQuestionTmp->selectType();
  356. // Start buffer
  357. ob_start();
  358. if ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
  359. $choice = [];
  360. }
  361. $relPath = api_get_path(WEB_CODE_PATH);
  362. switch ($answerType) {
  363. case MULTIPLE_ANSWER_COMBINATION:
  364. case MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE:
  365. case UNIQUE_ANSWER:
  366. case UNIQUE_ANSWER_NO_OPTION:
  367. case UNIQUE_ANSWER_IMAGE:
  368. case MULTIPLE_ANSWER:
  369. case MULTIPLE_ANSWER_TRUE_FALSE:
  370. case FILL_IN_BLANKS:
  371. case CALCULATED_ANSWER:
  372. case GLOBAL_MULTIPLE_ANSWER:
  373. case FREE_ANSWER:
  374. case ORAL_EXPRESSION:
  375. case MATCHING:
  376. case DRAGGABLE:
  377. case READING_COMPREHENSION:
  378. case MATCHING_DRAGGABLE:
  379. $question_result = $objExercise->manage_answer(
  380. $id,
  381. $questionId,
  382. $choice,
  383. 'exercise_show',
  384. [],
  385. false,
  386. true,
  387. $show_results,
  388. $objExercise->selectPropagateNeg(),
  389. [],
  390. $showTotalScoreAndUserChoicesInLastAttempt
  391. );
  392. $questionScore = $question_result['score'];
  393. $totalScore += $question_result['score'];
  394. break;
  395. case MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY:
  396. $choiceTmp = [];
  397. $choiceTmp['choice'] = $choice;
  398. $choiceTmp['choiceDegreeCertainty'] = $choiceDegreeCertainty;
  399. $questionResult = $objExercise->manage_answer(
  400. $id,
  401. $questionId,
  402. $choiceTmp,
  403. 'exercise_show',
  404. [],
  405. false,
  406. true,
  407. $show_results,
  408. $objExercise->selectPropagateNeg()
  409. );
  410. $questionScore = $questionResult['score'];
  411. $totalScore += $questionResult['score'];
  412. break;
  413. case HOT_SPOT:
  414. if ($show_results || $showTotalScoreAndUserChoicesInLastAttempt) {
  415. echo '<table width="500" border="0"><tr>
  416. <td valign="top" align="center" style="padding-left:0px;" >
  417. <table border="1" bordercolor="#A4A4A4" style="border-collapse: collapse;" width="552">';
  418. }
  419. $question_result = $objExercise->manage_answer(
  420. $id,
  421. $questionId,
  422. $choice,
  423. 'exercise_show',
  424. [],
  425. false,
  426. true,
  427. $show_results,
  428. $objExercise->selectPropagateNeg(),
  429. [],
  430. $showTotalScoreAndUserChoicesInLastAttempt
  431. );
  432. $questionScore = $question_result['score'];
  433. $totalScore += $question_result['score'];
  434. if ($show_results) {
  435. echo '</table></td></tr>';
  436. echo "
  437. <tr>
  438. <td colspan=\"2\">
  439. <div id=\"hotspot-solution-$questionId-$id\"></div>
  440. <script>
  441. $(function() {
  442. new HotspotQuestion({
  443. questionId: $questionId,
  444. exerciseId: {$objExercise->id},
  445. exeId: $id,
  446. selector: '#hotspot-solution-$questionId-$id',
  447. for: 'solution',
  448. relPath: '$relPath'
  449. });
  450. });
  451. </script>
  452. </td>
  453. </tr>
  454. </table>
  455. <br>
  456. ";
  457. }
  458. break;
  459. case HOT_SPOT_DELINEATION:
  460. $question_result = $objExercise->manage_answer(
  461. $id,
  462. $questionId,
  463. $choice,
  464. 'exercise_show',
  465. [],
  466. false,
  467. true,
  468. $show_results,
  469. $objExercise->selectPropagateNeg(),
  470. 'database',
  471. [],
  472. $showTotalScoreAndUserChoicesInLastAttempt
  473. );
  474. $questionScore = $question_result['score'];
  475. $totalScore += $question_result['score'];
  476. $final_overlap = $question_result['extra']['final_overlap'];
  477. $final_missing = $question_result['extra']['final_missing'];
  478. $final_excess = $question_result['extra']['final_excess'];
  479. $overlap_color = $question_result['extra']['overlap_color'];
  480. $missing_color = $question_result['extra']['missing_color'];
  481. $excess_color = $question_result['extra']['excess_color'];
  482. $threadhold1 = $question_result['extra']['threadhold1'];
  483. $threadhold2 = $question_result['extra']['threadhold2'];
  484. $threadhold3 = $question_result['extra']['threadhold3'];
  485. if ($show_results) {
  486. if ($overlap_color) {
  487. $overlap_color = 'green';
  488. } else {
  489. $overlap_color = 'red';
  490. }
  491. if ($missing_color) {
  492. $missing_color = 'green';
  493. } else {
  494. $missing_color = 'red';
  495. }
  496. if ($excess_color) {
  497. $excess_color = 'green';
  498. } else {
  499. $excess_color = 'red';
  500. }
  501. if (!is_numeric($final_overlap)) {
  502. $final_overlap = 0;
  503. }
  504. if (!is_numeric($final_missing)) {
  505. $final_missing = 0;
  506. }
  507. if (!is_numeric($final_excess)) {
  508. $final_excess = 0;
  509. }
  510. if ($final_excess > 100) {
  511. $final_excess = 100;
  512. }
  513. $table_resume = '
  514. <table class="data_table">
  515. <tr class="row_odd" >
  516. <td>&nbsp;</td>
  517. <td><b>'.get_lang('Requirements').'</b></td>
  518. <td><b>'.get_lang('YourAnswer').'</b></td>
  519. </tr>
  520. <tr class="row_even">
  521. <td><b>'.get_lang('Overlap').'</b></td>
  522. <td>'.get_lang('Min').' '.$threadhold1.'</td>
  523. <td>
  524. <div style="color:'.$overlap_color.'">
  525. '.(($final_overlap < 0) ? 0 : intval($final_overlap)).'
  526. </div>
  527. </td>
  528. </tr>
  529. <tr>
  530. <td><b>'.get_lang('Excess').'</b></td>
  531. <td>'.get_lang('Max').' '.$threadhold2.'</td>
  532. <td>
  533. <div style="color:'.$excess_color.'">
  534. '.(($final_excess < 0) ? 0 : intval($final_excess)).'
  535. </div>
  536. </td>
  537. </tr>
  538. <tr class="row_even">
  539. <td><b>'.get_lang('Missing').'</b></td>
  540. <td>'.get_lang('Max').' '.$threadhold3.'</td>
  541. <td>
  542. <div style="color:'.$missing_color.'">
  543. '.(($final_missing < 0) ? 0 : intval($final_missing)).'
  544. </div>
  545. </td>
  546. </tr>
  547. </table>
  548. ';
  549. if ($answerType != HOT_SPOT_DELINEATION) {
  550. $item_list = explode('@@', $destination);
  551. $try = $item_list[0];
  552. $lp = $item_list[1];
  553. $destinationid = $item_list[2];
  554. $url = $item_list[3];
  555. $table_resume = '';
  556. } else {
  557. if ($next == 0) {
  558. $try = $try_hotspot;
  559. $lp = $lp_hotspot;
  560. $destinationid = $select_question_hotspot;
  561. $url = $url_hotspot;
  562. } else {
  563. //show if no error
  564. $comment = $answerComment = $objAnswerTmp->selectComment($nbrAnswers);
  565. $answerDestination = $objAnswerTmp->selectDestination($nbrAnswers);
  566. }
  567. }
  568. echo '<h1><div style="color:#333;">'.get_lang('Feedback').'</div></h1>';
  569. if ($answerType == HOT_SPOT_DELINEATION) {
  570. if ($organs_at_risk_hit > 0) {
  571. $message = '<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />';
  572. $message .= '<p style="color:#DC0A0A;"><b>'.get_lang('OARHit').'</b></p>';
  573. } else {
  574. $message = '<p>'.get_lang('YourDelineation').'</p>';
  575. $message .= $table_resume;
  576. $message .= '<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />';
  577. }
  578. $message .= '<p>'.$comment.'</p>';
  579. echo $message;
  580. } else {
  581. echo '<p>'.$comment.'</p>';
  582. }
  583. //showing the score
  584. $queryfree = "SELECT marks from ".$TBL_TRACK_ATTEMPT."
  585. WHERE exe_id = ".intval($id)." AND question_id= ".intval($questionId);
  586. $resfree = Database::query($queryfree);
  587. $questionScore = Database::result($resfree, 0, "marks");
  588. $totalScore += $questionScore;
  589. $relPath = api_get_path(REL_PATH);
  590. echo '</table></td></tr>';
  591. echo "
  592. <tr>
  593. <td colspan=\"2\">
  594. <div id=\"hotspot-solution\"></div>
  595. <script>
  596. $(function() {
  597. new HotspotQuestion({
  598. questionId: $questionId,
  599. exerciseId: {$objExercise->id},
  600. exeId: $id,
  601. selector: '#hotspot-solution',
  602. for: 'solution',
  603. relPath: '$relPath'
  604. });
  605. });
  606. </script>
  607. </td>
  608. </tr>
  609. </table>
  610. ";
  611. }
  612. break;
  613. case ANNOTATION:
  614. $question_result = $objExercise->manage_answer(
  615. $id,
  616. $questionId,
  617. $choice,
  618. 'exercise_show',
  619. [],
  620. false,
  621. true,
  622. $show_results,
  623. $objExercise->selectPropagateNeg(),
  624. [],
  625. $showTotalScoreAndUserChoicesInLastAttempt
  626. );
  627. $questionScore = $question_result['score'];
  628. $totalScore += $question_result['score'];
  629. if ($show_results) {
  630. echo '
  631. <div id="annotation-canvas-'.$questionId.'"></div>
  632. <script>
  633. AnnotationQuestion({
  634. questionId: '.(int) $questionId.',
  635. exerciseId: '.(int) $id.',
  636. relPath: \''.$relPath.'\',
  637. courseId: '.(int) $courseInfo['real_id'].'
  638. });
  639. </script>
  640. ';
  641. }
  642. break;
  643. }
  644. if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE) {
  645. echo '</table>';
  646. }
  647. if ($show_results && $answerType != HOT_SPOT) {
  648. echo '</table>';
  649. }
  650. $comnt = null;
  651. if ($show_results) {
  652. if ($is_allowedToEdit && $locked == false && !api_is_drh() && $isCoachAllowedToEdit) {
  653. $isFeedbackAllowed = true;
  654. } elseif (!$isCoachAllowedToEdit && $allowCoachFeedbackExercises) {
  655. $isFeedbackAllowed = true;
  656. }
  657. // Boss cannot edit exercise result
  658. if ($isBossOfStudent) {
  659. $isFeedbackAllowed = false;
  660. }
  661. $marksname = '';
  662. if ($isFeedbackAllowed && $action != 'export') {
  663. $name = 'fckdiv'.$questionId;
  664. $marksname = 'marksName'.$questionId;
  665. if (in_array($answerType, [FREE_ANSWER, ORAL_EXPRESSION, ANNOTATION])) {
  666. $url_name = get_lang('EditCommentsAndMarks');
  667. } else {
  668. $url_name = get_lang('AddComments');
  669. if ($action == 'edit') {
  670. $url_name = get_lang('EditIndividualComment');
  671. }
  672. }
  673. echo '<p>';
  674. echo Display::button(
  675. 'show_ck',
  676. $url_name,
  677. [
  678. 'type' => 'button',
  679. 'class' => 'btn btn-default',
  680. 'onclick' => "showfck('".$name."', '".$marksname."');",
  681. ]
  682. );
  683. echo '</p>';
  684. echo '<div id="feedback_'.$name.'" class="show">';
  685. $comnt = Event::get_comments($id, $questionId);
  686. if (!empty($comnt)) {
  687. echo ExerciseLib::getFeedbackText($comnt);
  688. }
  689. echo ExerciseLib::getOralFeedbackAudio($id, $questionId, $student_id);
  690. echo '</div>';
  691. echo '<div id="'.$name.'" class="row hidden">';
  692. echo '<div class="col-sm-'.($allowTeacherCommentAudio ? 7 : 12).'">';
  693. $arrid[] = $questionId;
  694. $feedback_form = new FormValidator('frmcomments'.$questionId);
  695. $renderer = &$feedback_form->defaultRenderer();
  696. $renderer->setFormTemplate('<form{attributes}><div>{content}</div></form>');
  697. $renderer->setCustomElementTemplate('<div>{element}</div>');
  698. $comnt = Event::get_comments($id, $questionId);
  699. $default = ['comments_'.$questionId => $comnt];
  700. if ($useAdvancedEditor) {
  701. $feedback_form->addElement(
  702. 'html_editor',
  703. 'comments_'.$questionId,
  704. null,
  705. null,
  706. [
  707. 'ToolbarSet' => 'TestAnswerFeedback',
  708. 'Width' => '100%',
  709. 'Height' => '120',
  710. ]
  711. );
  712. } else {
  713. $feedback_form->addElement('textarea', 'comments_'.$questionId);
  714. }
  715. $feedback_form->setDefaults($default);
  716. $feedback_form->display();
  717. echo '</div>';
  718. if ($allowRecordAudio && $allowTeacherCommentAudio) {
  719. echo '<div class="col-sm-5">';
  720. echo ExerciseLib::getOralFeedbackForm($id, $questionId, $student_id);
  721. echo '</div>';
  722. }
  723. echo '</div>';
  724. } else {
  725. $comnt = Event::get_comments($id, $questionId);
  726. echo '<br />';
  727. if (!empty($comnt)) {
  728. echo '<b>'.get_lang('Feedback').'</b>';
  729. echo ExerciseLib::getFeedbackText($comnt);
  730. echo ExerciseLib::getOralFeedbackAudio($id, $questionId, $student_id);
  731. }
  732. }
  733. if ($is_allowedToEdit && $isFeedbackAllowed && $action != 'export') {
  734. if (in_array($answerType, [FREE_ANSWER, ORAL_EXPRESSION, ANNOTATION])) {
  735. $marksname = "marksName".$questionId;
  736. $arrmarks[] = $questionId;
  737. echo '<div id="'.$marksname.'" class="hidden">';
  738. // @todo use FormValidator
  739. /*$formMark = new FormValidator("marksform_'.$questionId.'", 'post');
  740. $options = [
  741. 1,
  742. 2
  743. ];
  744. $formMark->addSelect('marks', get_lang('AssignMarks'), $options);
  745. $formMark->display();*/
  746. echo '<form name="marksform_'.$questionId.'" method="post" action="">';
  747. echo get_lang('AssignMarks');
  748. echo "&nbsp;<select name='marks' id='select_marks_".$questionId."' class='selectpicker exercise_mark_select'>";
  749. $model = ExerciseLib::getCourseScoreModel();
  750. if (empty($model)) {
  751. for ($i = 0; $i <= $questionWeighting; $i++) {
  752. echo '<option value="'.$i.'" '.(($i == $questionScore) ? "selected='selected'" : '').'>'.$i.'</option>';
  753. }
  754. } else {
  755. foreach ($model['score_list'] as $item) {
  756. $i = api_number_format($item['score_to_qualify'] / 100 * $questionWeighting, 2);
  757. $model = ExerciseLib::getModelStyle($item, $i);
  758. echo '<option class = "'.$item['css_class'].'" value="'.$i.'" '.(($i == $questionScore) ? "selected='selected'" : '').'>'.$model.'</option>';
  759. }
  760. }
  761. echo '</select>';
  762. echo '</form><br /></div>';
  763. if ($questionScore == -1) {
  764. $questionScore = 0;
  765. echo ExerciseLib::getNotCorrectedYetText();
  766. }
  767. } else {
  768. $arrmarks[] = $questionId;
  769. echo '
  770. <div id="'.$marksname.'" class="hidden">
  771. <form name="marksform_'.$questionId.'" method="post" action="">
  772. <select name="marks" id="select_marks_'.$questionId.'" style="display:none;" class="exercise_mark_select">
  773. <option value="'.$questionScore.'" >'.$questionScore.'</option>
  774. </select>
  775. </form>
  776. <br/>
  777. </div>
  778. ';
  779. }
  780. } else {
  781. if ($questionScore == -1) {
  782. $questionScore = 0;
  783. }
  784. }
  785. }
  786. $my_total_score = $questionScore;
  787. $my_total_weight = $questionWeighting;
  788. $totalWeighting += $questionWeighting;
  789. $category_was_added_for_this_test = false;
  790. if (isset($objQuestionTmp->category) && !empty($objQuestionTmp->category)) {
  791. if (!isset($category_list[$objQuestionTmp->category]['score'])) {
  792. $category_list[$objQuestionTmp->category]['score'] = 0;
  793. }
  794. if (!isset($category_list[$objQuestionTmp->category]['total'])) {
  795. $category_list[$objQuestionTmp->category]['total'] = 0;
  796. }
  797. $category_list[$objQuestionTmp->category]['score'] += $my_total_score;
  798. $category_list[$objQuestionTmp->category]['total'] += $my_total_weight;
  799. $category_was_added_for_this_test = true;
  800. }
  801. if (isset($objQuestionTmp->category_list) && !empty($objQuestionTmp->category_list)) {
  802. foreach ($objQuestionTmp->category_list as $category_id) {
  803. $category_list[$category_id]['score'] += $my_total_score;
  804. $category_list[$category_id]['total'] += $my_total_weight;
  805. $category_was_added_for_this_test = true;
  806. }
  807. }
  808. // No category for this question!
  809. if (!isset($category_list['none']['score'])) {
  810. $category_list['none']['score'] = 0;
  811. }
  812. if (!isset($category_list['none']['total'])) {
  813. $category_list['none']['total'] = 0;
  814. }
  815. if ($category_was_added_for_this_test == false) {
  816. $category_list['none']['score'] += $my_total_score;
  817. $category_list['none']['total'] += $my_total_weight;
  818. }
  819. if ($objExercise->selectPropagateNeg() == 0 && $my_total_score < 0) {
  820. $my_total_score = 0;
  821. }
  822. $score = [];
  823. if ($show_results) {
  824. $scorePassed = $my_total_score >= $my_total_weight;
  825. if (function_exists('bccomp')) {
  826. $compareResult = bccomp($my_total_score, $my_total_weight, 3);
  827. $scorePassed = $compareResult === 1 || $compareResult === 0;
  828. }
  829. $score['result'] = ExerciseLib::show_score(
  830. $my_total_score,
  831. $my_total_weight,
  832. false,
  833. false
  834. );
  835. $score['pass'] = $scorePassed;
  836. $score['type'] = $answerType;
  837. $score['score'] = $my_total_score;
  838. $score['weight'] = $my_total_weight;
  839. $score['comments'] = isset($comnt) ? $comnt : null;
  840. }
  841. if (in_array($objQuestionTmp->type, [FREE_ANSWER, ORAL_EXPRESSION, ANNOTATION])) {
  842. $scoreToReview = [
  843. 'score' => $my_total_score,
  844. 'comments' => isset($comnt) ? $comnt : null,
  845. ];
  846. $check = $objQuestionTmp->isQuestionWaitingReview($scoreToReview);
  847. if ($check === false) {
  848. $countPendingQuestions++;
  849. }
  850. }
  851. unset($objAnswerTmp);
  852. $i++;
  853. $contents = ob_get_clean();
  854. $question_content = '<div class="question_row">';
  855. if ($show_results && $objQuestionTmp) {
  856. $objQuestionTmp->export = $action == 'export';
  857. // Shows question title an description
  858. $question_content .= $objQuestionTmp->return_header(
  859. $objExercise,
  860. $counter,
  861. $score
  862. );
  863. }
  864. $counter++;
  865. $question_content .= $contents;
  866. $question_content .= '</div>';
  867. $exercise_content .= Display::panel($question_content);
  868. } // end of large foreach on questions
  869. $totalScoreText = '';
  870. if ($answerType != MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY) {
  871. $pluginEvaluation = QuestionOptionsEvaluationPlugin::create();
  872. if ('true' === $pluginEvaluation->get(QuestionOptionsEvaluationPlugin::SETTING_ENABLE)) {
  873. $formula = $pluginEvaluation->getFormulaForExercise($objExercise->selectId());
  874. if (!empty($formula)) {
  875. $totalScore = $pluginEvaluation->getResultWithFormula($id, $formula);
  876. $totalWeighting = $pluginEvaluation->getMaxScore();
  877. }
  878. }
  879. }
  880. // Total score
  881. $myTotalScoreTemp = $totalScore;
  882. if ($origin != 'learnpath' || ($origin == 'learnpath' && isset($_GET['fb_type']))) {
  883. if ($show_results || $show_only_total_score || $showTotalScoreAndUserChoicesInLastAttempt) {
  884. $totalScoreText .= '<div class="question_row">';
  885. if ($objExercise->selectPropagateNeg() == 0 && $myTotalScoreTemp < 0) {
  886. $myTotalScoreTemp = 0;
  887. }
  888. if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY) {
  889. $totalScoreText .= ExerciseLib::getQuestionDiagnosisRibbon(
  890. $objExercise,
  891. $myTotalScoreTemp,
  892. $totalWeighting,
  893. true
  894. );
  895. } else {
  896. $totalScoreText .= ExerciseLib::getTotalScoreRibbon(
  897. $objExercise,
  898. $myTotalScoreTemp,
  899. $totalWeighting,
  900. true,
  901. $countPendingQuestions
  902. );
  903. }
  904. $totalScoreText .= '</div>';
  905. }
  906. }
  907. if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY) {
  908. $chartMultiAnswer = MultipleAnswerTrueFalseDegreeCertainty::displayStudentsChartResults($id, $objExercise);
  909. echo $chartMultiAnswer;
  910. }
  911. if (!empty($category_list) && ($show_results || $show_only_total_score || $showTotalScoreAndUserChoicesInLastAttempt)) {
  912. // Adding total
  913. $category_list['total'] = [
  914. 'score' => $myTotalScoreTemp,
  915. 'total' => $totalWeighting,
  916. ];
  917. echo TestCategory::get_stats_table_by_attempt(
  918. $objExercise->id,
  919. $category_list
  920. );
  921. }
  922. if (RESULT_DISABLE_RANKING == $track_exercise_info['results_disabled']) {
  923. echo Display::page_header(get_lang('Ranking'), null, 'h4');
  924. echo ExerciseLib::displayResultsInRanking(
  925. $objExercise->iId,
  926. $student_id,
  927. $courseInfo['real_id'],
  928. $sessionId
  929. );
  930. }
  931. echo $totalScoreText;
  932. echo $exercise_content;
  933. // only show "score" in bottom of page if there's exercise content
  934. if ($show_results) {
  935. echo $totalScoreText;
  936. }
  937. if ($action === 'export') {
  938. $content = ob_get_clean();
  939. // needed in order to mpdf to work
  940. ob_clean();
  941. $params = [
  942. 'filename' => api_replace_dangerous_char(
  943. $objExercise->name.' '.
  944. $user_info['complete_name'].' '.
  945. api_get_local_time()
  946. ),
  947. 'course_code' => api_get_course_id(),
  948. 'session_info' => api_get_session_info(api_get_session_id()),
  949. 'course_info' => '',
  950. 'pdf_date' => '',
  951. 'show_real_course_teachers' => false,
  952. 'show_teacher_as_myself' => false,
  953. 'orientation' => 'P',
  954. ];
  955. $pdf = new PDF('A4', $params['orientation'], $params);
  956. $pdf->html_to_pdf_with_template($content, false, false, true);
  957. exit;
  958. }
  959. if ($isFeedbackAllowed) {
  960. if (is_array($arrid) && is_array($arrmarks)) {
  961. $strids = implode(',', $arrid);
  962. $marksid = implode(',', $arrmarks);
  963. }
  964. }
  965. if ($isFeedbackAllowed && $origin != 'learnpath' && $origin != 'student_progress') {
  966. if (in_array($origin, ['tracking_course', 'user_course', 'correct_exercise_in_lp'])) {
  967. $formUrl = api_get_path(WEB_CODE_PATH).'exercise/exercise_report.php?'.api_get_cidreq().'&';
  968. $formUrl .= http_build_query([
  969. 'exerciseId' => $exercise_id,
  970. 'filter' => 2,
  971. 'comments' => 'update',
  972. 'exeid' => $id,
  973. 'origin' => $origin,
  974. 'details' => 'true',
  975. 'course' => Security::remove_XSS($_GET['cidReq']),
  976. ]);
  977. $emailForm = new FormValidator('form-email', 'post', $formUrl, '', ['id' => 'form-email']);
  978. $emailForm->addHidden('lp_item_id', $learnpath_id);
  979. $emailForm->addHidden('lp_item_view_id', $lp_item_view_id);
  980. $emailForm->addHidden('student_id', $student_id);
  981. $emailForm->addHidden('total_score', $totalScore);
  982. $emailForm->addHidden('my_exe_exo_id', $exercise_id);
  983. } else {
  984. $formUrl = api_get_path(WEB_CODE_PATH).'exercise/exercise_report.php?'.api_get_cidreq().'&';
  985. $formUrl .= http_build_query([
  986. 'exerciseId' => $exercise_id,
  987. 'filter' => 1,
  988. 'comments' => 'update',
  989. 'exeid' => $id,
  990. ]);
  991. $emailForm = new FormValidator(
  992. 'form-email',
  993. 'post',
  994. $formUrl,
  995. '',
  996. ['id' => 'form-email']
  997. );
  998. }
  999. if ($objExercise->results_disabled != RESULT_DISABLE_NO_SCORE_AND_EXPECTED_ANSWERS) {
  1000. $emailForm->addCheckBox(
  1001. 'send_notification',
  1002. get_lang('SendEmail'),
  1003. get_lang('SendEmail'),
  1004. ['onclick' => 'openEmailWrapper();']
  1005. );
  1006. $emailForm->addHtml('<div id="email_content_wrapper" style="display:none; margin-bottom: 20px;">');
  1007. $emailForm->addHtmlEditor(
  1008. 'notification_content',
  1009. get_lang('Content'),
  1010. false
  1011. );
  1012. $emailForm->addHtml('</div>');
  1013. }
  1014. if (empty($track_exercise_info['orig_lp_id']) || empty($track_exercise_info['orig_lp_item_id'])) {
  1015. // Default url
  1016. $url = api_get_path(WEB_CODE_PATH).'exercise/result.php?id='.$track_exercise_info['exe_id'].'&'.api_get_cidreq()
  1017. .'&show_headers=1&id_session='.api_get_session_id();
  1018. } else {
  1019. $url = api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?action=view&item_id='
  1020. .$track_exercise_info['orig_lp_item_id'].'&lp_id='.$track_exercise_info['orig_lp_id'].'&'.api_get_cidreq()
  1021. .'&id_session='.api_get_session_id();
  1022. }
  1023. Skill::addSkillsToUserForm(
  1024. $emailForm,
  1025. ITEM_TYPE_EXERCISE,
  1026. $exercise_id,
  1027. $student_id,
  1028. $track_exercise_info['exe_id'],
  1029. true
  1030. );
  1031. $content = ExerciseLib::getEmailNotification(
  1032. $currentUserId,
  1033. api_get_course_info(),
  1034. $track_exercise_info['title'],
  1035. $url
  1036. );
  1037. $emailForm->setDefaults(['notification_content' => $content]);
  1038. $emailForm->addButtonSend(
  1039. get_lang('CorrectTest'),
  1040. 'submit',
  1041. false,
  1042. ['onclick' => "getFCK('$strids', '$marksid')"]
  1043. );
  1044. echo $emailForm->returnForm();
  1045. }
  1046. //Came from lpstats in a lp
  1047. if ($origin == 'student_progress') {
  1048. ?>
  1049. <button type="button" class="back" onclick="window.history.go(-1);" value="<?php echo get_lang('Back'); ?>">
  1050. <?php echo get_lang('Back'); ?>
  1051. </button>
  1052. <?php
  1053. } elseif ($origin == 'myprogress') {
  1054. ?>
  1055. <button type="button" class="save"
  1056. onclick="top.location.href='../auth/my_progress.php?course=<?php echo api_get_course_id(); ?>'"
  1057. value="<?php echo get_lang('Finish'); ?>">
  1058. <?php echo get_lang('Finish'); ?>
  1059. </button>
  1060. <?php
  1061. }
  1062. if ($origin != 'learnpath') {
  1063. //we are not in learnpath tool
  1064. Display::display_footer();
  1065. } else {
  1066. if (!isset($_GET['fb_type'])) {
  1067. $lp_mode = Session::read('lp_mode');
  1068. $url = '../lp/lp_controller.php?'.api_get_cidreq().'&';
  1069. $url .= http_build_query([
  1070. 'action' => 'view',
  1071. 'lp_id' => $learnpath_id,
  1072. 'lp_item_id' => $learnpath_item_id,
  1073. 'exeId' => $id,
  1074. 'fb_type' => $feedback_type,
  1075. ]);
  1076. $href = ($lp_mode == 'fullscreen')
  1077. ? ' window.opener.location.href="'.$url.'" '
  1078. : ' top.location.href="'.$url.'" ';
  1079. echo '<script type="text/javascript">'.$href.'</script>';
  1080. // Record the results in the learning path, using the SCORM interface (API)
  1081. echo "<script>window.parent.API.void_save_asset('$totalScore', '$totalWeighting', 0, 'completed'); </script>";
  1082. echo '</body></html>';
  1083. } else {
  1084. echo Display::return_message(
  1085. get_lang('ExerciseFinished').' '.get_lang('ToContinueUseMenu'),
  1086. 'normal'
  1087. );
  1088. echo '<br />';
  1089. }
  1090. }
  1091. // Destroying the session
  1092. Session::erase('questionList');
  1093. unset($questionList);
  1094. Session::erase('exerciseResult');
  1095. unset($exerciseResult);
  1096. Session::erase('calculatedAnswerId');