| Total Complexity | 193 |
| Total Lines | 1094 |
| Duplicated Lines | 0 % |
| Changes | 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 |
||
| 8 | class ExerciseShowFunctions |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * Shows the answer to a fill-in-the-blanks question, as HTML. |
||
| 12 | * |
||
| 13 | * @param Exercise $exercise |
||
| 14 | * @param int $feedbackType |
||
| 15 | * @param string $answer |
||
| 16 | * @param int $id Exercise ID |
||
| 17 | * @param int $questionId Question ID |
||
| 18 | * @param int $resultsDisabled |
||
| 19 | * @param bool $showTotalScoreAndUserChoices |
||
| 20 | * @param string $originalStudentAnswer |
||
| 21 | */ |
||
| 22 | public static function display_fill_in_blanks_answer( |
||
| 48 | } |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * Shows the answer to a calculated question, as HTML. |
||
| 53 | * |
||
| 54 | * @param Exercise $exercise |
||
| 55 | * @param string Answer text |
||
| 56 | * @param int Exercise ID |
||
| 57 | * @param int Question ID |
||
| 58 | */ |
||
| 59 | public static function display_calculated_answer( |
||
| 104 | } |
||
| 105 | } |
||
| 106 | } |
||
| 107 | |||
| 108 | /** |
||
| 109 | * Display the uploaded files for an exercise question, using Tailwind-based markup. |
||
| 110 | * |
||
| 111 | * This method now relies on getUploadAnswerFiles() which already resolves |
||
| 112 | * ResourceNode → ResourceFile → public URL. |
||
| 113 | * |
||
| 114 | * @param string $feedbackType |
||
| 115 | * @param string $answer |
||
| 116 | * @param int $exeId |
||
| 117 | * @param int $questionId |
||
| 118 | * @param mixed $questionScore |
||
| 119 | * @param int $resultsDisabled |
||
| 120 | * |
||
| 121 | * @return void |
||
| 122 | */ |
||
| 123 | public static function displayUploadAnswer( |
||
| 190 | } |
||
| 191 | } |
||
| 192 | } |
||
| 193 | |||
| 194 | /** |
||
| 195 | * Shows the answer to a free-answer question, as HTML. |
||
| 196 | * |
||
| 197 | * @param string Answer text |
||
| 198 | * @param int Exercise ID |
||
| 199 | * @param int Question ID |
||
| 200 | */ |
||
| 201 | public static function display_free_answer( |
||
| 223 | } |
||
| 224 | } |
||
| 225 | } |
||
| 226 | |||
| 227 | /** |
||
| 228 | * Display oral expression answer: student audio, text answer, and correction status. |
||
| 229 | * |
||
| 230 | * @param string $feedback_type |
||
| 231 | * @param string $answer |
||
| 232 | * @param int $trackExerciseId |
||
| 233 | * @param int $questionId |
||
| 234 | * @param int $resultsDisabled |
||
| 235 | * @param float $questionScore |
||
| 236 | * @param bool $showAlertIfNotCorrected |
||
| 237 | * |
||
| 238 | * @return void |
||
| 239 | */ |
||
| 240 | public static function display_oral_expression_answer( |
||
| 290 | } |
||
| 291 | } |
||
| 292 | |||
| 293 | /** |
||
| 294 | * Displays the answer to a hotspot question. |
||
| 295 | * |
||
| 296 | * @param int $feedback_type |
||
| 297 | * @param int $answerId |
||
| 298 | * @param string $answer |
||
| 299 | * @param string $studentChoice |
||
| 300 | * @param string $answerComment |
||
| 301 | * @param int $resultsDisabled |
||
| 302 | * @param int $orderColor |
||
| 303 | * @param bool $showTotalScoreAndUserChoices |
||
| 304 | */ |
||
| 305 | public static function display_hotspot_answer( |
||
| 306 | $exercise, |
||
| 307 | $feedback_type, |
||
| 308 | $answerId, |
||
| 309 | $answer, |
||
| 310 | $studentChoice, |
||
| 311 | $answerComment, |
||
| 312 | $resultsDisabled, |
||
| 313 | $orderColor, |
||
| 314 | $showTotalScoreAndUserChoices |
||
| 315 | ) { |
||
| 316 | $hide_expected_answer = false; |
||
| 317 | switch ($resultsDisabled) { |
||
| 318 | case RESULT_DISABLE_SHOW_SCORE_ONLY: |
||
| 319 | if (0 == $feedback_type) { |
||
| 320 | $hide_expected_answer = true; |
||
| 321 | } |
||
| 322 | break; |
||
| 323 | case RESULT_DISABLE_DONT_SHOW_SCORE_ONLY_IF_USER_FINISHES_ATTEMPTS_SHOW_ALWAYS_FEEDBACK: |
||
| 324 | case RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT: |
||
| 325 | $hide_expected_answer = true; |
||
| 326 | if ($showTotalScoreAndUserChoices) { |
||
| 327 | $hide_expected_answer = false; |
||
| 328 | } |
||
| 329 | break; |
||
| 330 | case RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT_NO_FEEDBACK: |
||
| 331 | $hide_expected_answer = true; |
||
| 332 | if ($showTotalScoreAndUserChoices) { |
||
| 333 | $hide_expected_answer = false; |
||
| 334 | } |
||
| 335 | if (false === $showTotalScoreAndUserChoices && empty($studentChoice)) { |
||
| 336 | return ''; |
||
| 337 | } |
||
| 338 | break; |
||
| 339 | } |
||
| 340 | |||
| 341 | if (!$hide_expected_answer |
||
| 342 | && !$studentChoice |
||
| 343 | && in_array($resultsDisabled, [RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER]) |
||
| 344 | ) { |
||
| 345 | return; |
||
| 346 | } |
||
| 347 | |||
| 348 | $hotspotColors = [ |
||
| 349 | '', // $i starts from 1 on next loop (ugly fix) |
||
| 350 | '#4271B5', |
||
| 351 | '#FE8E16', |
||
| 352 | '#45C7F0', |
||
| 353 | '#BCD631', |
||
| 354 | '#D63173', |
||
| 355 | '#D7D7D7', |
||
| 356 | '#90AFDD', |
||
| 357 | '#AF8640', |
||
| 358 | '#4F9242', |
||
| 359 | '#F4EB24', |
||
| 360 | '#ED2024', |
||
| 361 | '#3B3B3B', |
||
| 362 | '#F7BDE2', |
||
| 363 | ]; |
||
| 364 | |||
| 365 | $content = '<tr>'; |
||
| 366 | $content .= '<td class="text-center" width="5%">'; |
||
| 367 | $content .= '<span class="fa fa-square fa-fw fa-2x" aria-hidden="true" style="color:'. |
||
| 368 | $hotspotColors[$orderColor].'"></span>'; |
||
| 369 | $content .= '</td>'; |
||
| 370 | $content .= '<td class="text-left" width="25%">'; |
||
| 371 | $content .= "$answerId - $answer"; |
||
| 372 | $content .= '</td>'; |
||
| 373 | if (false === $exercise->hideComment) { |
||
| 374 | $content .= '<td class="text-left" width="10%">'; |
||
| 375 | if (!$hide_expected_answer) { |
||
| 376 | $status = Display::label(get_lang('Incorrect'), 'danger'); |
||
| 377 | if ($studentChoice) { |
||
| 378 | $status = Display::label(get_lang('Correct'), 'success'); |
||
| 379 | } |
||
| 380 | $content .= $status; |
||
| 381 | } else { |
||
| 382 | $content .= ' '; |
||
| 383 | } |
||
| 384 | $content .= '</td>'; |
||
| 385 | if (EXERCISE_FEEDBACK_TYPE_EXAM != $feedback_type) { |
||
| 386 | $content .= '<td class="text-left" width="60%">'; |
||
| 387 | if ($studentChoice) { |
||
| 388 | $content .= '<span style="font-weight: bold; color: #008000;">'.nl2br($answerComment).'</span>'; |
||
| 389 | } else { |
||
| 390 | $content .= ' '; |
||
| 391 | } |
||
| 392 | $content .= '</td>'; |
||
| 393 | } else { |
||
| 394 | $content .= '<td class="text-left" width="60%"> </td>'; |
||
| 395 | } |
||
| 396 | } |
||
| 397 | $content .= '</tr>'; |
||
| 398 | |||
| 399 | echo $content; |
||
| 400 | } |
||
| 401 | |||
| 402 | /** |
||
| 403 | * Display the answers to a multiple choice question. |
||
| 404 | * |
||
| 405 | * @param Exercise $exercise |
||
| 406 | * @param int $feedbackType Feedback type |
||
| 407 | * @param int $answerType Answer type |
||
| 408 | * @param int $studentChoice Student choice |
||
| 409 | * @param string $answer Textual answer |
||
| 410 | * @param string $answerComment Comment on answer |
||
| 411 | * @param string $answerCorrect Correct answer comment |
||
| 412 | * @param int $id Exercise ID |
||
| 413 | * @param int $questionId Question ID |
||
| 414 | * @param bool $ans Whether to show the answer comment or not |
||
| 415 | * @param bool $resultsDisabled |
||
| 416 | * @param bool $showTotalScoreAndUserChoices |
||
| 417 | * @param bool $export |
||
| 418 | */ |
||
| 419 | public static function display_unique_or_multiple_answer( |
||
| 420 | $exercise, |
||
| 421 | $feedbackType, |
||
| 422 | $answerType, |
||
| 423 | $studentChoice, |
||
| 424 | $answer, |
||
| 425 | $answerComment, |
||
| 426 | $answerCorrect, |
||
| 427 | $id, |
||
| 428 | $questionId, |
||
| 429 | $ans, |
||
| 430 | $resultsDisabled, |
||
| 431 | $showTotalScoreAndUserChoices, |
||
| 432 | $export = false |
||
| 433 | ) { |
||
| 434 | if (true === $exercise->hideNoAnswer && empty($studentChoice)) { |
||
| 435 | return ''; |
||
| 436 | } |
||
| 437 | if ($export) { |
||
| 438 | $answer = strip_tags_blacklist($answer, ['title', 'head']); |
||
| 439 | // Fix answers that contains this tags |
||
| 440 | $tags = [ |
||
| 441 | '<html>', |
||
| 442 | '</html>', |
||
| 443 | '<body>', |
||
| 444 | '</body>', |
||
| 445 | ]; |
||
| 446 | $answer = str_replace($tags, '', $answer); |
||
| 447 | } |
||
| 448 | |||
| 449 | $studentChoiceInt = (int) $studentChoice; |
||
| 450 | $answerCorrectChoice = (int) $answerCorrect; |
||
| 451 | $hide_expected_answer = false; |
||
| 452 | $showComment = false; |
||
| 453 | switch ($resultsDisabled) { |
||
| 454 | case RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER: |
||
| 455 | $hide_expected_answer = true; |
||
| 456 | $showComment = true; |
||
| 457 | if (!$answerCorrect && empty($studentChoice)) { |
||
| 458 | return ''; |
||
| 459 | } |
||
| 460 | break; |
||
| 461 | case RESULT_DISABLE_SHOW_SCORE_ONLY: |
||
| 462 | if (0 == $feedbackType) { |
||
| 463 | $hide_expected_answer = true; |
||
| 464 | } |
||
| 465 | break; |
||
| 466 | case RESULT_DISABLE_DONT_SHOW_SCORE_ONLY_IF_USER_FINISHES_ATTEMPTS_SHOW_ALWAYS_FEEDBACK: |
||
| 467 | case RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT: |
||
| 468 | $hide_expected_answer = true; |
||
| 469 | if ($showTotalScoreAndUserChoices) { |
||
| 470 | $hide_expected_answer = false; |
||
| 471 | } |
||
| 472 | break; |
||
| 473 | case RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT_NO_FEEDBACK: |
||
| 474 | if (false === $showTotalScoreAndUserChoices && empty($studentChoiceInt)) { |
||
| 475 | return ''; |
||
| 476 | } |
||
| 477 | break; |
||
| 478 | } |
||
| 479 | |||
| 480 | if (in_array($answerType, [UNIQUE_ANSWER, UNIQUE_ANSWER_NO_OPTION])) { |
||
| 481 | if ($studentChoice) { |
||
| 482 | $icon = StateIcon::RADIOBOX_MARKED; |
||
| 483 | } else { |
||
| 484 | $icon = StateIcon::RADIOBOX_BLANK; |
||
| 485 | } |
||
| 486 | } else { |
||
| 487 | if ($studentChoice) { |
||
| 488 | $icon = StateIcon::CHECKBOX_MARKED; |
||
| 489 | } else { |
||
| 490 | $icon = StateIcon::CHECKBOX_BLANK; |
||
| 491 | } |
||
| 492 | } |
||
| 493 | if (in_array($answerType, [UNIQUE_ANSWER, UNIQUE_ANSWER_NO_OPTION])) { |
||
| 494 | if ($answerCorrect) { |
||
| 495 | $iconAnswer = StateIcon::RADIOBOX_MARKED; |
||
| 496 | } else { |
||
| 497 | $iconAnswer = StateIcon::RADIOBOX_BLANK; |
||
| 498 | } |
||
| 499 | } else { |
||
| 500 | if ($answerCorrect) { |
||
| 501 | $iconAnswer = StateIcon::CHECKBOX_MARKED; |
||
| 502 | } else { |
||
| 503 | $iconAnswer = StateIcon::CHECKBOX_BLANK; |
||
| 504 | } |
||
| 505 | |||
| 506 | } |
||
| 507 | |||
| 508 | $studentChoiceClass = ''; |
||
| 509 | if (in_array( |
||
| 510 | $resultsDisabled, |
||
| 511 | [ |
||
| 512 | RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER, |
||
| 513 | RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS_AND_RANKING, |
||
| 514 | ] |
||
| 515 | ) |
||
| 516 | ) { |
||
| 517 | if ($answerCorrect) { |
||
| 518 | $studentChoiceClass = 'success'; |
||
| 519 | } |
||
| 520 | } |
||
| 521 | |||
| 522 | echo '<tr class="'.$studentChoiceClass.'">'; |
||
| 523 | |||
| 524 | echo '<td style="width:5%">'; |
||
| 525 | echo Display::getMdiIcon($icon, 'ch-tool-icon', null, ICON_SIZE_TINY); |
||
| 526 | echo '</td>'; |
||
| 527 | if ($exercise->showExpectedChoiceColumn()) { |
||
| 528 | if (false === $hide_expected_answer) { |
||
| 529 | echo '<td style="width:5%">'; |
||
| 530 | echo Display::getMdiIcon($iconAnswer, 'ch-tool-icon', null, ICON_SIZE_TINY); |
||
| 531 | echo '</td>'; |
||
| 532 | } else { |
||
| 533 | echo '<td style="width:5%">'; |
||
| 534 | echo '-'; |
||
| 535 | echo '</td>'; |
||
| 536 | } |
||
| 537 | } |
||
| 538 | |||
| 539 | echo '<td style="width:40%">'; |
||
| 540 | echo $answer; |
||
| 541 | echo '</td>'; |
||
| 542 | |||
| 543 | if ($exercise->showExpectedChoice()) { |
||
| 544 | $status = Display::label(get_lang('Incorrect'), 'danger'); |
||
| 545 | if ($answerCorrect || ($answerCorrect && $studentChoiceInt === $answerCorrectChoice)) { |
||
| 546 | $status = Display::label(get_lang('Correct'), 'success'); |
||
| 547 | } |
||
| 548 | echo '<td class="text-center">'; |
||
| 549 | // Show only status for the selected student answer BT#16256 |
||
| 550 | if ($studentChoice) { |
||
| 551 | echo $status; |
||
| 552 | } |
||
| 553 | |||
| 554 | echo '</td>'; |
||
| 555 | } |
||
| 556 | |||
| 557 | if (EXERCISE_FEEDBACK_TYPE_EXAM != $feedbackType) { |
||
| 558 | $showComment = true; |
||
| 559 | } |
||
| 560 | |||
| 561 | if (false === $exercise->hideComment) { |
||
| 562 | if ($showComment) { |
||
| 563 | echo '<td style="width:20%">'; |
||
| 564 | $color = 'black'; |
||
| 565 | if ($answerCorrect) { |
||
| 566 | $color = 'green'; |
||
| 567 | } |
||
| 568 | if ($hide_expected_answer) { |
||
| 569 | $color = ''; |
||
| 570 | } |
||
| 571 | $comment = '<span style="font-weight: bold; color: '.$color.';">'. |
||
| 572 | Security::remove_XSS($answerComment). |
||
| 573 | '</span>'; |
||
| 574 | echo $comment; |
||
| 575 | echo '</td>'; |
||
| 576 | } else { |
||
| 577 | echo '<td> </td>'; |
||
| 578 | } |
||
| 579 | } |
||
| 580 | |||
| 581 | echo '</tr>'; |
||
| 582 | } |
||
| 583 | |||
| 584 | /** |
||
| 585 | * Display the answers to a multiple choice question. |
||
| 586 | * |
||
| 587 | * @param Exercise $exercise |
||
| 588 | * @param int $feedbackType Feedback type |
||
| 589 | * @param int $answerType Answer type |
||
| 590 | * @param int $studentChoice Student choice |
||
| 591 | * @param string $answer Textual answer |
||
| 592 | * @param string $answerComment Comment on answer |
||
| 593 | * @param string $answerCorrect Correct answer comment |
||
| 594 | * @param int $id Exercise ID |
||
| 595 | * @param int $questionId Question ID |
||
| 596 | * @param bool $ans Whether to show the answer comment or not |
||
| 597 | * @param int $resultsDisabled |
||
| 598 | * @param bool $showTotalScoreAndUserChoices |
||
| 599 | */ |
||
| 600 | public static function display_multiple_answer_true_false( |
||
| 601 | $exercise, |
||
| 602 | $feedbackType, |
||
| 603 | $answerType, |
||
| 604 | $studentChoice, |
||
| 605 | $answer, |
||
| 606 | $answerComment, |
||
| 607 | $answerCorrect, |
||
| 608 | $id, |
||
| 609 | $questionId, |
||
| 610 | $ans, |
||
| 611 | $resultsDisabled, |
||
| 612 | $showTotalScoreAndUserChoices |
||
| 613 | ) { |
||
| 614 | $hide_expected_answer = false; |
||
| 615 | $hideStudentChoice = false; |
||
| 616 | switch ($resultsDisabled) { |
||
| 617 | //case RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS_AND_RANKING: |
||
| 618 | case RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER: |
||
| 619 | $hideStudentChoice = false; |
||
| 620 | $hide_expected_answer = true; |
||
| 621 | break; |
||
| 622 | case RESULT_DISABLE_SHOW_SCORE_ONLY: |
||
| 623 | if (0 == $feedbackType) { |
||
| 624 | $hide_expected_answer = true; |
||
| 625 | } |
||
| 626 | break; |
||
| 627 | case RESULT_DISABLE_DONT_SHOW_SCORE_ONLY_IF_USER_FINISHES_ATTEMPTS_SHOW_ALWAYS_FEEDBACK: |
||
| 628 | case RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT: |
||
| 629 | $hide_expected_answer = true; |
||
| 630 | if ($showTotalScoreAndUserChoices) { |
||
| 631 | $hide_expected_answer = false; |
||
| 632 | } |
||
| 633 | break; |
||
| 634 | case RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT_NO_FEEDBACK: |
||
| 635 | if (false === $showTotalScoreAndUserChoices && empty($studentChoice)) { |
||
| 636 | return ''; |
||
| 637 | } |
||
| 638 | break; |
||
| 639 | } |
||
| 640 | |||
| 641 | $content = '<tr>'; |
||
| 642 | if (false === $hideStudentChoice) { |
||
| 643 | $content .= '<td width="5%">'; |
||
| 644 | $course_id = api_get_course_int_id(); |
||
| 645 | $new_options = []; |
||
| 646 | $originOptions = Question::readQuestionOption($questionId); |
||
| 647 | |||
| 648 | if (!empty($originOptions)) { |
||
| 649 | foreach ($originOptions as $item) { |
||
| 650 | $new_options[$item['iid']] = $item; |
||
| 651 | } |
||
| 652 | } |
||
| 653 | |||
| 654 | // Your choice |
||
| 655 | if (isset($new_options[$studentChoice])) { |
||
| 656 | $content .= get_lang($new_options[$studentChoice]['title']); |
||
| 657 | } else { |
||
| 658 | $content .= '-'; |
||
| 659 | } |
||
| 660 | $content .= '</td>'; |
||
| 661 | } |
||
| 662 | |||
| 663 | // Expected choice |
||
| 664 | if ($exercise->showExpectedChoiceColumn()) { |
||
| 665 | if (!$hide_expected_answer) { |
||
| 666 | $content .= '<td width="5%">'; |
||
| 667 | if (isset($new_options[$answerCorrect])) { |
||
| 668 | $content .= get_lang($new_options[$answerCorrect]['title']); |
||
| 669 | } else { |
||
| 670 | $content .= '-'; |
||
| 671 | } |
||
| 672 | $content .= '</td>'; |
||
| 673 | } |
||
| 674 | } |
||
| 675 | |||
| 676 | $content .= '<td width="40%">'; |
||
| 677 | $content .= $answer; |
||
| 678 | $content .= '</td>'; |
||
| 679 | |||
| 680 | if ($exercise->showExpectedChoice()) { |
||
| 681 | $status = Display::label(get_lang('Incorrect'), 'danger'); |
||
| 682 | if (isset($new_options[$studentChoice])) { |
||
| 683 | if ($studentChoice == $answerCorrect) { |
||
| 684 | $status = Display::label(get_lang('Correct'), 'success'); |
||
| 685 | } |
||
| 686 | } |
||
| 687 | $content .= '<td class="text-center">'; |
||
| 688 | $content .= $status; |
||
| 689 | $content .= '</td>'; |
||
| 690 | } |
||
| 691 | |||
| 692 | if (false === $exercise->hideComment) { |
||
| 693 | if (EXERCISE_FEEDBACK_TYPE_EXAM != $feedbackType) { |
||
| 694 | $content .= '<td width="20%">'; |
||
| 695 | $color = 'black'; |
||
| 696 | if (isset($new_options[$studentChoice]) || in_array( |
||
| 697 | $exercise->results_disabled, |
||
| 698 | [ |
||
| 699 | RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER, |
||
| 700 | RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS_AND_RANKING, |
||
| 701 | ] |
||
| 702 | ) |
||
| 703 | ) { |
||
| 704 | if ($studentChoice == $answerCorrect) { |
||
| 705 | $color = 'green'; |
||
| 706 | } |
||
| 707 | |||
| 708 | if ($hide_expected_answer) { |
||
| 709 | $color = ''; |
||
| 710 | } |
||
| 711 | $content .= '<span style="font-weight: bold; color: '.$color.';">'.nl2br($answerComment).'</span>'; |
||
| 712 | } |
||
| 713 | $content .= '</td>'; |
||
| 714 | } |
||
| 715 | } |
||
| 716 | $content .= '</tr>'; |
||
| 717 | |||
| 718 | echo $content; |
||
| 719 | } |
||
| 720 | |||
| 721 | /** |
||
| 722 | * Display the answers to a multiple choice question. |
||
| 723 | * |
||
| 724 | * @param Exercise $exercise |
||
| 725 | * @param int $feedbackType |
||
| 726 | * @param int $studentChoice |
||
| 727 | * @param int $studentChoiceDegree |
||
| 728 | * @param string $answer |
||
| 729 | * @param string $answerComment |
||
| 730 | * @param int $answerCorrect |
||
| 731 | * @param int $questionId |
||
| 732 | * @param bool $inResultsDisabled |
||
| 733 | */ |
||
| 734 | public static function displayMultipleAnswerTrueFalseDegreeCertainty( |
||
| 735 | $exercise, |
||
| 736 | $feedbackType, |
||
| 737 | $studentChoice, |
||
| 738 | $studentChoiceDegree, |
||
| 739 | $answer, |
||
| 740 | $answerComment, |
||
| 741 | $answerCorrect, |
||
| 742 | $questionId, |
||
| 743 | $inResultsDisabled |
||
| 744 | ) { |
||
| 745 | $hideExpectedAnswer = false; |
||
| 746 | if (0 == $feedbackType && 2 == $inResultsDisabled) { |
||
| 747 | $hideExpectedAnswer = true; |
||
| 748 | } |
||
| 749 | |||
| 750 | echo '<tr><td width="5%">'; |
||
| 751 | $question = new MultipleAnswerTrueFalseDegreeCertainty(); |
||
| 752 | $courseId = api_get_course_int_id(); |
||
| 753 | $newOptions = Question::readQuestionOption($questionId, $courseId); |
||
| 754 | |||
| 755 | // Your choice |
||
| 756 | if (isset($newOptions[$studentChoice])) { |
||
| 757 | echo get_lang($newOptions[$studentChoice]['name']); |
||
| 758 | } else { |
||
| 759 | echo '-'; |
||
| 760 | } |
||
| 761 | echo '</td>'; |
||
| 762 | |||
| 763 | // Expected choice |
||
| 764 | if ($exercise->showExpectedChoiceColumn()) { |
||
| 765 | echo '<td width="5%">'; |
||
| 766 | if (!$hideExpectedAnswer) { |
||
| 767 | if (isset($newOptions[$answerCorrect])) { |
||
| 768 | echo get_lang($newOptions[$answerCorrect]['name']); |
||
| 769 | } else { |
||
| 770 | echo '-'; |
||
| 771 | } |
||
| 772 | } else { |
||
| 773 | echo '-'; |
||
| 774 | } |
||
| 775 | echo '</td>'; |
||
| 776 | } |
||
| 777 | |||
| 778 | echo '<td width="20%">'; |
||
| 779 | echo $answer; |
||
| 780 | echo '</td><td width="5%" style="text-align:center;">'; |
||
| 781 | if (isset($newOptions[$studentChoiceDegree])) { |
||
| 782 | echo $newOptions[$studentChoiceDegree]['name']; |
||
| 783 | } |
||
| 784 | echo '</td>'; |
||
| 785 | |||
| 786 | $position = isset($newOptions[$studentChoiceDegree]) ? $newOptions[$studentChoiceDegree]['position'] : ''; |
||
| 787 | $degreeInfo = $question->getResponseDegreeInfo( |
||
| 788 | $studentChoice, |
||
| 789 | $answerCorrect, |
||
| 790 | $position |
||
| 791 | ); |
||
| 792 | |||
| 793 | $degreeInfo['color'] = isset($degreeInfo['color']) ? $degreeInfo['color'] : ''; |
||
| 794 | $degreeInfo['background-color'] = isset($degreeInfo['background-color']) ? $degreeInfo['background-color'] : ''; |
||
| 795 | $degreeInfo['description'] = isset($degreeInfo['description']) ? $degreeInfo['description'] : ''; |
||
| 796 | $degreeInfo['label'] = isset($degreeInfo['label']) ? $degreeInfo['label'] : ''; |
||
| 797 | |||
| 798 | echo ' |
||
| 799 | <td width="15%"> |
||
| 800 | <div style="text-align:center;color: '.$degreeInfo['color'].'; |
||
| 801 | background-color: '.$degreeInfo['background-color'].'; |
||
| 802 | line-height:30px;height:30px;width: 100%;margin:auto;" |
||
| 803 | title="'.$degreeInfo['description'].'">'. |
||
| 804 | nl2br($degreeInfo['label']). |
||
| 805 | '</div> |
||
| 806 | </td>'; |
||
| 807 | |||
| 808 | if (false === $exercise->hideComment) { |
||
| 809 | if (EXERCISE_FEEDBACK_TYPE_EXAM != $feedbackType) { |
||
| 810 | echo '<td width="20%">'; |
||
| 811 | if (isset($newOptions[$studentChoice])) { |
||
| 812 | echo '<span style="font-weight: bold; color: black;">'.nl2br($answerComment).'</span>'; |
||
| 813 | } |
||
| 814 | echo '</td>'; |
||
| 815 | } else { |
||
| 816 | echo '<td> </td>'; |
||
| 817 | } |
||
| 818 | } |
||
| 819 | echo '</tr>'; |
||
| 820 | } |
||
| 821 | |||
| 822 | /** |
||
| 823 | * Display the answers to a multiple choice question. |
||
| 824 | * |
||
| 825 | * @param Exercise $exercise |
||
| 826 | * @param int Answer type |
||
| 827 | * @param int Student choice |
||
| 828 | * @param string Textual answer |
||
| 829 | * @param string Comment on answer |
||
| 830 | * @param string Correct answer comment |
||
| 831 | * @param int Exercise ID |
||
| 832 | * @param int Question ID |
||
| 833 | * @param bool Whether to show the answer comment or not |
||
| 834 | */ |
||
| 835 | public static function display_multiple_answer_combination_true_false( |
||
| 947 | } |
||
| 948 | |||
| 949 | /** |
||
| 950 | * @param int $feedbackType |
||
| 951 | * @param int $exeId |
||
| 952 | * @param int $questionId |
||
| 953 | * @param null $questionScore |
||
| 954 | * @param int $resultsDisabled |
||
| 955 | */ |
||
| 956 | public static function displayAnnotationAnswer( |
||
| 967 | } |
||
| 968 | } |
||
| 969 | } |
||
| 970 | |||
| 971 | /** |
||
| 972 | * Displays the answers for a Multiple Answer Dropdown question (result view). |
||
| 973 | * Renders a row per choice, showing: student choice, expected choice (if allowed), |
||
| 974 | * the textual answer, and status (Correct/Incorrect). |
||
| 975 | * |
||
| 976 | * Returned string contains <tr>...</tr> rows to be echoed in the answer table. |
||
| 977 | */ |
||
| 978 | public static function displayMultipleAnswerDropdown( |
||
| 1102 | } |
||
| 1103 | } |
||
| 1104 |
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.