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