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