Total Complexity | 173 |
Total Lines | 989 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Complex classes like ExerciseShowFunctions often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use ExerciseShowFunctions, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
5 | class ExerciseShowFunctions |
||
6 | { |
||
7 | /** |
||
8 | * Shows the answer to a fill-in-the-blanks question, as HTML. |
||
9 | * |
||
10 | * @param Exercise $exercise |
||
11 | * @param int $feedbackType |
||
12 | * @param string $answer |
||
13 | * @param int $id Exercise ID |
||
14 | * @param int $questionId Question ID |
||
15 | * @param int $resultsDisabled |
||
16 | * @param string $originalStudentAnswer |
||
17 | * @param bool $showTotalScoreAndUserChoices |
||
18 | */ |
||
19 | public static function display_fill_in_blanks_answer( |
||
45 | } |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * Shows the answer to a calculated question, as HTML. |
||
50 | * |
||
51 | * @param Exercise $exercise |
||
52 | * @param string Answer text |
||
53 | * @param int Exercise ID |
||
54 | * @param int Question ID |
||
55 | */ |
||
56 | public static function display_calculated_answer( |
||
57 | $exercise, |
||
58 | $feedback_type, |
||
59 | $answer, |
||
60 | $id, |
||
61 | $questionId, |
||
62 | $resultsDisabled, |
||
63 | $showTotalScoreAndUserChoices, |
||
64 | $expectedChoice = '', |
||
65 | $choice = '', |
||
66 | $status = '' |
||
67 | ) { |
||
68 | $answer = explode(':::', $answer); |
||
69 | $answer = $answer[0]; |
||
70 | if ($exercise->showExpectedChoice()) { |
||
71 | if (empty($id)) { |
||
72 | echo '<tr><td>'.Security::remove_XSS($answer).'</td>'; |
||
73 | echo '<td>'.Security::remove_XSS($choice).'</td>'; |
||
74 | if ($exercise->showExpectedChoiceColumn()) { |
||
75 | echo '<td>'.Security::remove_XSS($expectedChoice).'</td>'; |
||
76 | } |
||
77 | |||
78 | echo '<td>'.Security::remove_XSS($status).'</td>'; |
||
79 | echo '</tr>'; |
||
80 | } else { |
||
81 | echo '<tr><td>'; |
||
82 | echo Security::remove_XSS($answer); |
||
83 | echo '</td><td>'; |
||
84 | echo Security::remove_XSS($choice); |
||
85 | echo '</td>'; |
||
86 | if ($exercise->showExpectedChoiceColumn()) { |
||
87 | echo '<td>'; |
||
88 | echo Security::remove_XSS($expectedChoice); |
||
89 | echo '</td>'; |
||
90 | } |
||
91 | echo '<td>'; |
||
92 | echo Security::remove_XSS($status); |
||
93 | echo '</td>'; |
||
94 | echo '</tr>'; |
||
95 | } |
||
96 | } else { |
||
97 | if (empty($id)) { |
||
98 | echo '<tr><td>'.Security::remove_XSS($answer).'</td></tr>'; |
||
99 | } else { |
||
100 | echo '<tr><td>'; |
||
101 | echo Security::remove_XSS($answer); |
||
102 | echo '</tr>'; |
||
103 | } |
||
104 | } |
||
105 | } |
||
106 | |||
107 | /** |
||
108 | * Shows the answer to an upload question. |
||
109 | * |
||
110 | * @param float|null $questionScore Only used to check if > 0 |
||
111 | * @param int $resultsDisabled Unused |
||
112 | */ |
||
113 | public static function displayUploadAnswer( |
||
114 | string $feedbackType, |
||
115 | string $answer, |
||
116 | int $exeId, |
||
117 | int $questionId, |
||
118 | $questionScore = null, |
||
119 | $resultsDisabled = 0 |
||
120 | ) { |
||
121 | if (!empty($answer)) { |
||
122 | $exeInfo = Event::get_exercise_results_by_attempt($exeId); |
||
|
|||
123 | if (empty($exeInfo)) { |
||
124 | global $exercise_stat_info; |
||
125 | $userId = $exercise_stat_info['exe_user_id']; |
||
126 | } else { |
||
127 | $userId = $exeInfo[$exeId]['exe_user_id']; |
||
128 | } |
||
129 | $userWebpath = UserManager::getUserPathById($userId, 'web').'my_files'.'/upload_answer/'.$exeId.'/'.$questionId.'/'; |
||
130 | $filesNames = explode('|', $answer); |
||
131 | echo '<tr><td>'; |
||
132 | foreach ($filesNames as $filename) { |
||
133 | $filename = Security::remove_XSS($filename); |
||
134 | echo '<p><a href="'.$userWebpath.$filename.'" target="_blank">'.$filename.'</a></p>'; |
||
135 | } |
||
136 | echo '</td></tr>'; |
||
137 | } |
||
138 | |||
139 | if (EXERCISE_FEEDBACK_TYPE_EXAM != $feedbackType) { |
||
140 | $comments = Event::get_comments($exeId, $questionId); |
||
141 | if ($questionScore > 0 || !empty($comments)) { |
||
142 | } else { |
||
143 | echo '<tr>'; |
||
144 | echo Display::tag('td', ExerciseLib::getNotCorrectedYetText()); |
||
145 | echo '</tr>'; |
||
146 | } |
||
147 | } |
||
148 | } |
||
149 | |||
150 | /** |
||
151 | * Shows the answer to a free-answer question, as HTML. |
||
152 | * |
||
153 | * @param string Answer text |
||
154 | * @param int Exercise ID |
||
155 | * @param int Question ID |
||
156 | */ |
||
157 | public static function display_free_answer( |
||
179 | } |
||
180 | } |
||
181 | } |
||
182 | |||
183 | /** |
||
184 | * @param $feedback_type |
||
185 | * @param $answer |
||
186 | * @param $id |
||
187 | * @param $questionId |
||
188 | * @param null $fileUrl |
||
189 | * @param int $resultsDisabled |
||
190 | * @param int $questionScore |
||
191 | */ |
||
192 | public static function display_oral_expression_answer( |
||
193 | $feedback_type, |
||
194 | $answer, |
||
195 | $id, |
||
196 | $questionId, |
||
197 | $fileUrl = null, |
||
198 | $resultsDisabled = 0, |
||
199 | $questionScore = 0 |
||
200 | ) { |
||
201 | if (isset($fileUrl)) { |
||
202 | echo ' |
||
203 | <tr> |
||
204 | <td><audio src="'.$fileUrl.'" controls></audio></td> |
||
205 | </tr> |
||
206 | '; |
||
207 | } |
||
208 | |||
209 | if (empty($id)) { |
||
210 | echo '<tr>'; |
||
211 | if (!empty($answer) && ($answer != basename($fileUrl))) { |
||
212 | echo Display::tag('td', Security::remove_XSS($answer), ['width' => '55%']); |
||
213 | } |
||
214 | echo '</tr>'; |
||
215 | if (!$questionScore && EXERCISE_FEEDBACK_TYPE_EXAM != $feedback_type) { |
||
216 | echo '<tr>'; |
||
217 | echo Display::tag('td', ExerciseLib::getNotCorrectedYetText(), ['width' => '45%']); |
||
218 | echo '</tr>'; |
||
219 | } else { |
||
220 | echo '<tr><td> </td></tr>'; |
||
221 | } |
||
222 | } else { |
||
223 | echo '<tr>'; |
||
224 | echo '<td>'; |
||
225 | if (!empty($answer)) { |
||
226 | echo Security::remove_XSS($answer); |
||
227 | } |
||
228 | echo '</td>'; |
||
229 | echo '</tr>'; |
||
230 | } |
||
231 | } |
||
232 | |||
233 | /** |
||
234 | * Displays the answer to a hotspot question. |
||
235 | * |
||
236 | * @param int $feedback_type |
||
237 | * @param int $answerId |
||
238 | * @param string $answer |
||
239 | * @param string $studentChoice |
||
240 | * @param string $answerComment |
||
241 | * @param int $resultsDisabled |
||
242 | * @param int $orderColor |
||
243 | * @param bool $showTotalScoreAndUserChoices |
||
244 | */ |
||
245 | public static function display_hotspot_answer( |
||
343 | } |
||
344 | |||
345 | public static function displayMultipleAnswerDropdown( |
||
346 | Exercise $exercise, |
||
347 | Answer $answer, |
||
348 | array $correctAnswers, |
||
349 | array $studentChoices, |
||
350 | bool $showTotalScoreAndUserChoices = true |
||
351 | ): string { |
||
352 | if (true === $exercise->hideNoAnswer && empty($studentChoices)) { |
||
353 | return ''; |
||
354 | } |
||
355 | |||
356 | $studentChoices = array_filter( |
||
357 | $studentChoices, |
||
358 | function ($studentAnswerId) { |
||
359 | return -1 !== (int) $studentAnswerId; |
||
360 | } |
||
361 | ); |
||
362 | |||
363 | $allChoices = array_unique( |
||
364 | array_merge($correctAnswers, $studentChoices) |
||
365 | ); |
||
366 | sort($allChoices); |
||
367 | |||
368 | $checkboxOn = Display::return_icon('checkbox_on.png', null, null, ICON_SIZE_TINY); |
||
369 | $checkboxOff = Display::return_icon('checkbox_off.png', null, null, ICON_SIZE_TINY); |
||
370 | |||
371 | $labelSuccess = Display::label(get_lang('Correct'), 'success'); |
||
372 | $labelIncorrect = Display::label(get_lang('Incorrect'), 'danger'); |
||
373 | |||
374 | $html = ''; |
||
375 | |||
376 | foreach ($allChoices as $choice) { |
||
377 | $isStudentAnswer = in_array($choice, $studentChoices); |
||
378 | $isCorrectAnswer = $isStudentAnswer && in_array($choice, $correctAnswers); |
||
379 | $answerPosition = array_search($choice, $answer->iid); |
||
380 | |||
381 | $hideExpectedAnswer = false; |
||
382 | |||
383 | switch ($exercise->selectResultsDisabled()) { |
||
384 | case RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER: |
||
385 | $hideExpectedAnswer = true; |
||
386 | |||
387 | if (!$isCorrectAnswer && empty($studentChoices)) { |
||
388 | continue 2; |
||
389 | } |
||
390 | break; |
||
391 | case RESULT_DISABLE_SHOW_SCORE_ONLY: |
||
392 | if (0 == $exercise->getFeedbackType()) { |
||
393 | $hideExpectedAnswer = true; |
||
394 | } |
||
395 | break; |
||
396 | case RESULT_DISABLE_DONT_SHOW_SCORE_ONLY_IF_USER_FINISHES_ATTEMPTS_SHOW_ALWAYS_FEEDBACK: |
||
397 | case RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT: |
||
398 | $hideExpectedAnswer = true; |
||
399 | if ($showTotalScoreAndUserChoices) { |
||
400 | $hideExpectedAnswer = false; |
||
401 | } |
||
402 | break; |
||
403 | case RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT_NO_FEEDBACK: |
||
404 | if (false === $showTotalScoreAndUserChoices && empty($studentChoices)) { |
||
405 | continue 2; |
||
406 | } |
||
407 | break; |
||
408 | } |
||
409 | |||
410 | $studentAnswerClass = ''; |
||
411 | |||
412 | if ($isCorrectAnswer |
||
413 | && in_array( |
||
414 | $exercise->selectResultsDisabled(), |
||
415 | [ |
||
416 | RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER, |
||
417 | RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS_AND_RANKING, |
||
418 | ] |
||
419 | ) |
||
420 | ) { |
||
421 | $studentAnswerClass = 'success'; |
||
422 | } |
||
423 | |||
424 | $html .= '<tr class="'.$studentAnswerClass.'">'; |
||
425 | $html .= '<td class="text-center">'.($isStudentAnswer ? $checkboxOn : $checkboxOff).'</td>'; |
||
426 | |||
427 | if ($exercise->showExpectedChoiceColumn()) { |
||
428 | $html .= '<td class="text-center">'; |
||
429 | |||
430 | if ($hideExpectedAnswer) { |
||
431 | $html .= '<span class="text-muted">—</span>'; |
||
432 | } else { |
||
433 | $html .= $isCorrectAnswer ? $checkboxOn : $checkboxOff; |
||
434 | } |
||
435 | |||
436 | $html .= '</td>'; |
||
437 | } |
||
438 | |||
439 | $answerText = $answer->answer[$answerPosition] ?? get_lang('None'); |
||
440 | |||
441 | if ($exercise->export) { |
||
442 | $answerText = strip_tags_blacklist($answerText, ['title', 'head']); |
||
443 | // Fix answers that contains this tags |
||
444 | $tags = ['<html>', '</html>', '<body>', '</body>']; |
||
445 | $answerText = str_replace($tags, '', $answerText); |
||
446 | } |
||
447 | |||
448 | $html .= '<td>'.Security::remove_XSS($answerText).'</td>'; |
||
449 | |||
450 | if ($exercise->showExpectedChoice()) { |
||
451 | $html .= '<td class="text-center">'.($isCorrectAnswer ? $labelSuccess : $labelIncorrect).'</td>'; |
||
452 | } |
||
453 | |||
454 | $html .= '</tr>'; |
||
455 | } |
||
456 | |||
457 | return $html; |
||
458 | } |
||
459 | |||
460 | /** |
||
461 | * Display the answers to a multiple choice question. |
||
462 | * |
||
463 | * @param Exercise $exercise |
||
464 | * @param int $feedbackType Feedback type |
||
465 | * @param int $answerType Answer type |
||
466 | * @param int $studentChoice Student choice |
||
467 | * @param string $answer Textual answer |
||
468 | * @param string $answerComment Comment on answer |
||
469 | * @param string $answerCorrect Correct answer comment |
||
470 | * @param int $id Exercise ID |
||
471 | * @param int $questionId Question ID |
||
472 | * @param bool $ans Whether to show the answer comment or not |
||
473 | * @param bool $resultsDisabled |
||
474 | * @param bool $showTotalScoreAndUserChoices |
||
475 | * @param bool $export |
||
476 | */ |
||
477 | public static function display_unique_or_multiple_answer( |
||
478 | $exercise, |
||
479 | $feedbackType, |
||
480 | $answerType, |
||
481 | $studentChoice, |
||
482 | $answer, |
||
483 | $answerComment, |
||
484 | $answerCorrect, |
||
485 | $id, |
||
486 | $questionId, |
||
487 | $ans, |
||
488 | $resultsDisabled, |
||
489 | $showTotalScoreAndUserChoices, |
||
490 | $export = false |
||
491 | ) { |
||
492 | if (true === $exercise->hideNoAnswer && empty($studentChoice)) { |
||
493 | return ''; |
||
494 | } |
||
495 | if ($export) { |
||
496 | $answer = strip_tags_blacklist($answer, ['title', 'head']); |
||
497 | // Fix answers that contains this tags |
||
498 | $tags = [ |
||
499 | '<html>', |
||
500 | '</html>', |
||
501 | '<body>', |
||
502 | '</body>', |
||
503 | ]; |
||
504 | $answer = str_replace($tags, '', $answer); |
||
505 | } |
||
506 | |||
507 | $studentChoiceInt = (int) $studentChoice; |
||
508 | $answerCorrectChoice = (int) $answerCorrect; |
||
509 | |||
510 | $hide_expected_answer = false; |
||
511 | $showComment = false; |
||
512 | switch ($resultsDisabled) { |
||
513 | case RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER: |
||
514 | $hide_expected_answer = true; |
||
515 | $showComment = true; |
||
516 | if (!$answerCorrect && empty($studentChoice)) { |
||
517 | return ''; |
||
518 | } |
||
519 | break; |
||
520 | case RESULT_DISABLE_SHOW_SCORE_ONLY: |
||
521 | if (0 == $feedbackType) { |
||
522 | $hide_expected_answer = true; |
||
523 | } |
||
524 | break; |
||
525 | case RESULT_DISABLE_DONT_SHOW_SCORE_ONLY_IF_USER_FINISHES_ATTEMPTS_SHOW_ALWAYS_FEEDBACK: |
||
526 | case RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT: |
||
527 | $hide_expected_answer = true; |
||
528 | if ($showTotalScoreAndUserChoices) { |
||
529 | $hide_expected_answer = false; |
||
530 | } |
||
531 | break; |
||
532 | case RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT_NO_FEEDBACK: |
||
533 | if (false === $showTotalScoreAndUserChoices && empty($studentChoiceInt)) { |
||
534 | return ''; |
||
535 | } |
||
536 | break; |
||
537 | } |
||
538 | |||
539 | $icon = in_array($answerType, [UNIQUE_ANSWER, UNIQUE_ANSWER_NO_OPTION]) ? 'radio' : 'checkbox'; |
||
540 | $icon .= $studentChoice ? '_on' : '_off'; |
||
541 | $icon .= '.png'; |
||
542 | $iconAnswer = in_array($answerType, [UNIQUE_ANSWER, UNIQUE_ANSWER_NO_OPTION]) ? 'radio' : 'checkbox'; |
||
543 | $iconAnswer .= $answerCorrect ? '_on' : '_off'; |
||
544 | $iconAnswer .= '.png'; |
||
545 | |||
546 | $studentChoiceClass = ''; |
||
547 | if (in_array( |
||
548 | $resultsDisabled, |
||
549 | [ |
||
550 | RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER, |
||
551 | RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS_AND_RANKING, |
||
552 | ] |
||
553 | ) |
||
554 | ) { |
||
555 | if ($answerCorrect) { |
||
556 | $studentChoiceClass = 'success'; |
||
557 | } |
||
558 | } |
||
559 | |||
560 | echo '<tr class="'.$studentChoiceClass.'">'; |
||
561 | |||
562 | echo '<td width="5%">'; |
||
563 | echo Display::return_icon($icon, null, null, ICON_SIZE_TINY); |
||
564 | echo '</td>'; |
||
565 | if ($exercise->showExpectedChoiceColumn()) { |
||
566 | if (false === $hide_expected_answer) { |
||
567 | echo '<td width="5%">'; |
||
568 | echo Display::return_icon($iconAnswer, null, null, ICON_SIZE_TINY); |
||
569 | echo '</td>'; |
||
570 | } else { |
||
571 | echo '<td width="5%">'; |
||
572 | echo '-'; |
||
573 | echo '</td>'; |
||
574 | } |
||
575 | } |
||
576 | |||
577 | echo '<td width="40%">'; |
||
578 | echo Security::remove_XSS($answer); |
||
579 | echo '</td>'; |
||
580 | |||
581 | if ($exercise->showExpectedChoice()) { |
||
582 | $status = Display::label(get_lang('Incorrect'), 'danger'); |
||
583 | if ($answerCorrect || ($answerCorrect && $studentChoiceInt === $answerCorrectChoice)) { |
||
584 | $status = Display::label(get_lang('Correct'), 'success'); |
||
585 | } |
||
586 | echo '<td width="20%">'; |
||
587 | // Show only status for the selected student answer BT#16256 |
||
588 | if ($studentChoice) { |
||
589 | echo $status; |
||
590 | } |
||
591 | |||
592 | echo '</td>'; |
||
593 | } |
||
594 | |||
595 | if (EXERCISE_FEEDBACK_TYPE_EXAM != $feedbackType) { |
||
596 | $showComment = true; |
||
597 | } |
||
598 | |||
599 | if (false === $exercise->hideComment) { |
||
600 | if ($showComment) { |
||
601 | echo '<td width="20%">'; |
||
602 | $color = 'black'; |
||
603 | if ($answerCorrect) { |
||
604 | $color = 'green'; |
||
605 | } |
||
606 | if ($hide_expected_answer) { |
||
607 | $color = ''; |
||
608 | } |
||
609 | $comment = '<span style="font-weight: bold; color: '.$color.';">'. |
||
610 | Security::remove_XSS($answerComment). |
||
611 | '</span>'; |
||
612 | echo $comment; |
||
613 | echo '</td>'; |
||
614 | } else { |
||
615 | echo '<td> </td>'; |
||
616 | } |
||
617 | } |
||
618 | |||
619 | echo '</tr>'; |
||
620 | } |
||
621 | |||
622 | /** |
||
623 | * Display the answers to a multiple choice question. |
||
624 | * |
||
625 | * @param Exercise $exercise |
||
626 | * @param int Answer type |
||
627 | * @param int Student choice |
||
628 | * @param string Textual answer |
||
629 | * @param string Comment on answer |
||
630 | * @param string Correct answer comment |
||
631 | * @param int Exercise ID |
||
632 | * @param int Question ID |
||
633 | * @param bool Whether to show the answer comment or not |
||
634 | */ |
||
635 | public static function display_multiple_answer_true_false( |
||
636 | $exercise, |
||
637 | $feedbackType, |
||
638 | $answerType, |
||
639 | $studentChoice, |
||
640 | $answer, |
||
641 | $answerComment, |
||
642 | $answerCorrect, |
||
643 | $id, |
||
644 | $questionId, |
||
645 | $ans, |
||
646 | $resultsDisabled, |
||
647 | $showTotalScoreAndUserChoices |
||
648 | ) { |
||
649 | $hide_expected_answer = false; |
||
650 | $hideStudentChoice = false; |
||
651 | switch ($resultsDisabled) { |
||
652 | //case RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS_AND_RANKING: |
||
653 | case RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER: |
||
654 | $hideStudentChoice = false; |
||
655 | $hide_expected_answer = true; |
||
656 | break; |
||
657 | case RESULT_DISABLE_SHOW_SCORE_ONLY: |
||
658 | if (0 == $feedbackType) { |
||
659 | $hide_expected_answer = true; |
||
660 | } |
||
661 | break; |
||
662 | case RESULT_DISABLE_DONT_SHOW_SCORE_ONLY_IF_USER_FINISHES_ATTEMPTS_SHOW_ALWAYS_FEEDBACK: |
||
663 | case RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT: |
||
664 | $hide_expected_answer = true; |
||
665 | if ($showTotalScoreAndUserChoices) { |
||
666 | $hide_expected_answer = false; |
||
667 | } |
||
668 | break; |
||
669 | case RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT_NO_FEEDBACK: |
||
670 | if (false === $showTotalScoreAndUserChoices && empty($studentChoice)) { |
||
671 | return ''; |
||
672 | } |
||
673 | break; |
||
674 | } |
||
675 | |||
676 | $content = '<tr>'; |
||
677 | if (false === $hideStudentChoice) { |
||
678 | $content .= '<td width="5%">'; |
||
679 | $course_id = api_get_course_int_id(); |
||
680 | $new_options = Question::readQuestionOption($questionId, $course_id); |
||
681 | // Your choice |
||
682 | if (isset($new_options[$studentChoice])) { |
||
683 | $content .= get_lang($new_options[$studentChoice]['name']); |
||
684 | } else { |
||
685 | $content .= '-'; |
||
686 | } |
||
687 | $content .= '</td>'; |
||
688 | } |
||
689 | |||
690 | // Expected choice |
||
691 | if ($exercise->showExpectedChoiceColumn()) { |
||
692 | if (!$hide_expected_answer) { |
||
693 | $content .= '<td width="5%">'; |
||
694 | if (isset($new_options[$answerCorrect])) { |
||
695 | $content .= get_lang($new_options[$answerCorrect]['name']); |
||
696 | } else { |
||
697 | $content .= '-'; |
||
698 | } |
||
699 | $content .= '</td>'; |
||
700 | } |
||
701 | } |
||
702 | |||
703 | $content .= '<td width="40%">'; |
||
704 | $content .= Security::remove_XSS($answer); |
||
705 | $content .= '</td>'; |
||
706 | |||
707 | if ($exercise->showExpectedChoice()) { |
||
708 | $status = Display::label(get_lang('Incorrect'), 'danger'); |
||
709 | if (isset($new_options[$studentChoice])) { |
||
710 | if ($studentChoice == $answerCorrect) { |
||
711 | $status = Display::label(get_lang('Correct'), 'success'); |
||
712 | } |
||
713 | } |
||
714 | $content .= '<td width="20%">'; |
||
715 | $content .= $status; |
||
716 | $content .= '</td>'; |
||
717 | } |
||
718 | |||
719 | if (false === $exercise->hideComment) { |
||
720 | if (EXERCISE_FEEDBACK_TYPE_EXAM != $feedbackType) { |
||
721 | $content .= '<td width="20%">'; |
||
722 | $color = 'black'; |
||
723 | if (isset($new_options[$studentChoice]) || in_array( |
||
724 | $exercise->results_disabled, |
||
725 | [ |
||
726 | RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER, |
||
727 | RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS_AND_RANKING, |
||
728 | ] |
||
729 | ) |
||
730 | ) { |
||
731 | if ($studentChoice == $answerCorrect) { |
||
732 | $color = 'green'; |
||
733 | } |
||
734 | |||
735 | if ($hide_expected_answer) { |
||
736 | $color = ''; |
||
737 | } |
||
738 | $content .= '<span style="font-weight: bold; color: '.$color.';">'.Security::remove_XSS(nl2br($answerComment)).'</span>'; |
||
739 | } |
||
740 | $content .= '</td>'; |
||
741 | } |
||
742 | } |
||
743 | $content .= '</tr>'; |
||
744 | |||
745 | echo $content; |
||
746 | } |
||
747 | |||
748 | /** |
||
749 | * Display the answers to a multiple choice question. |
||
750 | * |
||
751 | * @param Exercise $exercise |
||
752 | * @param int $feedbackType |
||
753 | * @param int $studentChoice |
||
754 | * @param int $studentChoiceDegree |
||
755 | * @param string $answer |
||
756 | * @param string $answerComment |
||
757 | * @param int $answerCorrect |
||
758 | * @param int $questionId |
||
759 | * @param bool $inResultsDisabled |
||
760 | */ |
||
761 | public static function displayMultipleAnswerTrueFalseDegreeCertainty( |
||
762 | $exercise, |
||
763 | $feedbackType, |
||
764 | $studentChoice, |
||
765 | $studentChoiceDegree, |
||
766 | $answer, |
||
767 | $answerComment, |
||
768 | $answerCorrect, |
||
769 | $questionId, |
||
770 | $inResultsDisabled |
||
771 | ) { |
||
772 | $hideExpectedAnswer = false; |
||
773 | if (0 == $feedbackType && 2 == $inResultsDisabled) { |
||
774 | $hideExpectedAnswer = true; |
||
775 | } |
||
776 | |||
777 | echo '<tr><td width="5%">'; |
||
778 | $question = new MultipleAnswerTrueFalseDegreeCertainty(); |
||
779 | $courseId = api_get_course_int_id(); |
||
780 | $newOptions = Question::readQuestionOption($questionId, $courseId); |
||
781 | |||
782 | // Your choice |
||
783 | if (isset($newOptions[$studentChoice])) { |
||
784 | echo get_lang($newOptions[$studentChoice]['name']); |
||
785 | } else { |
||
786 | echo '-'; |
||
787 | } |
||
788 | echo '</td>'; |
||
789 | |||
790 | // Expected choice |
||
791 | if ($exercise->showExpectedChoiceColumn()) { |
||
792 | echo '<td width="5%">'; |
||
793 | if (!$hideExpectedAnswer) { |
||
794 | if (isset($newOptions[$answerCorrect])) { |
||
795 | echo get_lang($newOptions[$answerCorrect]['name']); |
||
796 | } else { |
||
797 | echo '-'; |
||
798 | } |
||
799 | } else { |
||
800 | echo '-'; |
||
801 | } |
||
802 | echo '</td>'; |
||
803 | } |
||
804 | |||
805 | echo '<td width="20%">'; |
||
806 | echo Security::remove_XSS($answer); |
||
807 | echo '</td><td width="5%" style="text-align:center;">'; |
||
808 | if (isset($newOptions[$studentChoiceDegree])) { |
||
809 | echo $newOptions[$studentChoiceDegree]['name']; |
||
810 | } |
||
811 | echo '</td>'; |
||
812 | |||
813 | $position = isset($newOptions[$studentChoiceDegree]) ? $newOptions[$studentChoiceDegree]['position'] : ''; |
||
814 | $degreeInfo = $question->getResponseDegreeInfo( |
||
815 | $studentChoice, |
||
816 | $answerCorrect, |
||
817 | $position |
||
818 | ); |
||
819 | |||
820 | $degreeInfo['color'] = isset($degreeInfo['color']) ? $degreeInfo['color'] : ''; |
||
821 | $degreeInfo['background-color'] = isset($degreeInfo['background-color']) ? $degreeInfo['background-color'] : ''; |
||
822 | $degreeInfo['description'] = isset($degreeInfo['description']) ? $degreeInfo['description'] : ''; |
||
823 | $degreeInfo['label'] = isset($degreeInfo['label']) ? $degreeInfo['label'] : ''; |
||
824 | |||
825 | echo ' |
||
826 | <td width="15%"> |
||
827 | <div style="text-align:center;color: '.$degreeInfo['color'].'; |
||
828 | background-color: '.$degreeInfo['background-color'].'; |
||
829 | line-height:30px;height:30px;width: 100%;margin:auto;" |
||
830 | title="'.$degreeInfo['description'].'">'. |
||
831 | nl2br($degreeInfo['label']). |
||
832 | '</div> |
||
833 | </td>'; |
||
834 | |||
835 | if (false === $exercise->hideComment) { |
||
836 | if (EXERCISE_FEEDBACK_TYPE_EXAM != $feedbackType) { |
||
837 | echo '<td width="20%">'; |
||
838 | if (isset($newOptions[$studentChoice])) { |
||
839 | echo '<span style="font-weight: bold; color: black;">'.nl2br($answerComment).'</span>'; |
||
840 | } |
||
841 | echo '</td>'; |
||
842 | } else { |
||
843 | echo '<td> </td>'; |
||
844 | } |
||
845 | } |
||
846 | |||
847 | echo '</tr>'; |
||
848 | } |
||
849 | |||
850 | /** |
||
851 | * Display the answers to a multiple choice question. |
||
852 | * |
||
853 | * @param Exercise $exercise |
||
854 | * @param int Answer type |
||
855 | * @param int Student choice |
||
856 | * @param string Textual answer |
||
857 | * @param string Comment on answer |
||
858 | * @param string Correct answer comment |
||
859 | * @param int Exercise ID |
||
860 | * @param int Question ID |
||
861 | * @param bool Whether to show the answer comment or not |
||
862 | */ |
||
863 | public static function display_multiple_answer_combination_true_false( |
||
974 | } |
||
975 | |||
976 | /** |
||
977 | * @param int $feedbackType |
||
978 | * @param int $exeId |
||
979 | * @param int $questionId |
||
980 | * @param null $questionScore |
||
981 | * @param int $resultsDisabled |
||
982 | */ |
||
983 | public static function displayAnnotationAnswer( |
||
994 | } |
||
995 | } |
||
996 | } |
||
997 | } |
||
998 |
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.