exercise_show.php 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199
  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. $(document).on('ready', 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. $(document).on('ready', 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. // Total score
  871. $myTotalScoreTemp = $totalScore;
  872. if ($origin != 'learnpath' || ($origin == 'learnpath' && isset($_GET['fb_type']))) {
  873. if ($show_results || $show_only_total_score || $showTotalScoreAndUserChoicesInLastAttempt) {
  874. $totalScoreText .= '<div class="question_row">';
  875. if ($objExercise->selectPropagateNeg() == 0 && $myTotalScoreTemp < 0) {
  876. $myTotalScoreTemp = 0;
  877. }
  878. if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY) {
  879. $totalScoreText .= ExerciseLib::getQuestionDiagnosisRibbon(
  880. $objExercise,
  881. $myTotalScoreTemp,
  882. $totalWeighting,
  883. true
  884. );
  885. } else {
  886. $totalScoreText .= ExerciseLib::getTotalScoreRibbon(
  887. $objExercise,
  888. $myTotalScoreTemp,
  889. $totalWeighting,
  890. true,
  891. $countPendingQuestions
  892. );
  893. }
  894. $totalScoreText .= '</div>';
  895. }
  896. }
  897. if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY) {
  898. $chartMultiAnswer = MultipleAnswerTrueFalseDegreeCertainty::displayStudentsChartResults($id, $objExercise);
  899. echo $chartMultiAnswer;
  900. }
  901. if (!empty($category_list) && ($show_results || $show_only_total_score || $showTotalScoreAndUserChoicesInLastAttempt)) {
  902. // Adding total
  903. $category_list['total'] = [
  904. 'score' => $myTotalScoreTemp,
  905. 'total' => $totalWeighting,
  906. ];
  907. echo TestCategory::get_stats_table_by_attempt(
  908. $objExercise->id,
  909. $category_list
  910. );
  911. }
  912. if (RESULT_DISABLE_RANKING == $track_exercise_info['results_disabled']) {
  913. echo Display::page_header(get_lang('Ranking'), null, 'h4');
  914. echo ExerciseLib::displayResultsInRanking(
  915. $objExercise->iId,
  916. $student_id,
  917. $courseInfo['real_id'],
  918. $sessionId
  919. );
  920. }
  921. echo $totalScoreText;
  922. echo $exercise_content;
  923. // only show "score" in bottom of page if there's exercise content
  924. if ($show_results) {
  925. echo $totalScoreText;
  926. }
  927. if ($action === 'export') {
  928. $content = ob_get_clean();
  929. // needed in order to mpdf to work
  930. ob_clean();
  931. $params = [
  932. 'filename' => api_replace_dangerous_char(
  933. $objExercise->name.' '.
  934. $user_info['complete_name'].' '.
  935. api_get_local_time()
  936. ),
  937. 'course_code' => api_get_course_id(),
  938. 'session_info' => api_get_session_info(api_get_session_id()),
  939. 'course_info' => '',
  940. 'pdf_date' => '',
  941. 'show_real_course_teachers' => false,
  942. 'show_teacher_as_myself' => false,
  943. 'orientation' => 'P',
  944. ];
  945. $pdf = new PDF('A4', $params['orientation'], $params);
  946. $pdf->html_to_pdf_with_template($content, false, false, true);
  947. exit;
  948. }
  949. if ($isFeedbackAllowed) {
  950. if (is_array($arrid) && is_array($arrmarks)) {
  951. $strids = implode(',', $arrid);
  952. $marksid = implode(',', $arrmarks);
  953. }
  954. }
  955. if ($isFeedbackAllowed && $origin != 'learnpath' && $origin != 'student_progress') {
  956. if (in_array($origin, ['tracking_course', 'user_course', 'correct_exercise_in_lp'])) {
  957. $formUrl = api_get_path(WEB_CODE_PATH).'exercise/exercise_report.php?'.api_get_cidreq().'&';
  958. $formUrl .= http_build_query([
  959. 'exerciseId' => $exercise_id,
  960. 'filter' => 2,
  961. 'comments' => 'update',
  962. 'exeid' => $id,
  963. 'origin' => $origin,
  964. 'details' => 'true',
  965. 'course' => Security::remove_XSS($_GET['cidReq']),
  966. ]);
  967. $emailForm = new FormValidator('form-email', 'post', $formUrl, '', ['id' => 'form-email']);
  968. $emailForm->addHidden('lp_item_id', $learnpath_id);
  969. $emailForm->addHidden('lp_item_view_id', $lp_item_view_id);
  970. $emailForm->addHidden('student_id', $student_id);
  971. $emailForm->addHidden('total_score', $totalScore);
  972. $emailForm->addHidden('my_exe_exo_id', $exercise_id);
  973. } else {
  974. $formUrl = api_get_path(WEB_CODE_PATH).'exercise/exercise_report.php?'.api_get_cidreq().'&';
  975. $formUrl .= http_build_query([
  976. 'exerciseId' => $exercise_id,
  977. 'filter' => 1,
  978. 'comments' => 'update',
  979. 'exeid' => $id,
  980. ]);
  981. $emailForm = new FormValidator(
  982. 'form-email',
  983. 'post',
  984. $formUrl,
  985. '',
  986. ['id' => 'form-email']
  987. );
  988. }
  989. if ($objExercise->results_disabled != RESULT_DISABLE_NO_SCORE_AND_EXPECTED_ANSWERS) {
  990. $emailForm->addCheckBox(
  991. 'send_notification',
  992. get_lang('SendEmail'),
  993. get_lang('SendEmail'),
  994. ['onclick' => 'openEmailWrapper();']
  995. );
  996. $emailForm->addHtml('<div id="email_content_wrapper" style="display:none; margin-bottom: 20px;">');
  997. $emailForm->addHtmlEditor(
  998. 'notification_content',
  999. get_lang('Content'),
  1000. false
  1001. );
  1002. $emailForm->addHtml('</div>');
  1003. }
  1004. if (empty($track_exercise_info['orig_lp_id']) || empty($track_exercise_info['orig_lp_item_id'])) {
  1005. // Default url
  1006. $url = api_get_path(WEB_CODE_PATH).'exercise/result.php?id='.$track_exercise_info['exe_id'].'&'.api_get_cidreq()
  1007. .'&show_headers=1&id_session='.api_get_session_id();
  1008. } else {
  1009. $url = api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?action=view&item_id='
  1010. .$track_exercise_info['orig_lp_item_id'].'&lp_id='.$track_exercise_info['orig_lp_id'].'&'.api_get_cidreq()
  1011. .'&id_session='.api_get_session_id();
  1012. }
  1013. Skill::addSkillsToUserForm(
  1014. $emailForm,
  1015. ITEM_TYPE_EXERCISE,
  1016. $exercise_id,
  1017. $student_id,
  1018. $track_exercise_info['exe_id'],
  1019. true
  1020. );
  1021. $content = ExerciseLib::getEmailNotification(
  1022. $currentUserId,
  1023. api_get_course_info(),
  1024. $track_exercise_info['title'],
  1025. $url
  1026. );
  1027. $emailForm->setDefaults(['notification_content' => $content]);
  1028. $emailForm->addButtonSend(
  1029. get_lang('CorrectTest'),
  1030. 'submit',
  1031. false,
  1032. ['onclick' => "getFCK('$strids', '$marksid')"]
  1033. );
  1034. echo $emailForm->returnForm();
  1035. }
  1036. //Came from lpstats in a lp
  1037. if ($origin == 'student_progress') {
  1038. ?>
  1039. <button type="button" class="back" onclick="window.history.go(-1);" value="<?php echo get_lang('Back'); ?>">
  1040. <?php echo get_lang('Back'); ?>
  1041. </button>
  1042. <?php
  1043. } elseif ($origin == 'myprogress') {
  1044. ?>
  1045. <button type="button" class="save"
  1046. onclick="top.location.href='../auth/my_progress.php?course=<?php echo api_get_course_id(); ?>'"
  1047. value="<?php echo get_lang('Finish'); ?>">
  1048. <?php echo get_lang('Finish'); ?>
  1049. </button>
  1050. <?php
  1051. }
  1052. if ($origin != 'learnpath') {
  1053. //we are not in learnpath tool
  1054. Display::display_footer();
  1055. } else {
  1056. if (!isset($_GET['fb_type'])) {
  1057. $lp_mode = Session::read('lp_mode');
  1058. $url = '../lp/lp_controller.php?'.api_get_cidreq().'&';
  1059. $url .= http_build_query([
  1060. 'action' => 'view',
  1061. 'lp_id' => $learnpath_id,
  1062. 'lp_item_id' => $learnpath_item_id,
  1063. 'exeId' => $id,
  1064. 'fb_type' => $feedback_type,
  1065. ]);
  1066. $href = ($lp_mode == 'fullscreen')
  1067. ? ' window.opener.location.href="'.$url.'" '
  1068. : ' top.location.href="'.$url.'" ';
  1069. echo '<script type="text/javascript">'.$href.'</script>';
  1070. // Record the results in the learning path, using the SCORM interface (API)
  1071. echo "<script>window.parent.API.void_save_asset('$totalScore', '$totalWeighting', 0, 'completed'); </script>";
  1072. echo '</body></html>';
  1073. } else {
  1074. echo Display::return_message(
  1075. get_lang('ExerciseFinished').' '.get_lang('ToContinueUseMenu'),
  1076. 'normal'
  1077. );
  1078. echo '<br />';
  1079. }
  1080. }
  1081. // Destroying the session
  1082. Session::erase('questionList');
  1083. unset($questionList);
  1084. Session::erase('exerciseResult');
  1085. unset($exerciseResult);