exercise_show.php 44 KB

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