123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801 |
- <?php
- /* See license terms in /license.txt */
- /**
- * EVENTS LIBRARY.
- *
- * This is the events library for Chamilo.
- * Functions of this library are used to record informations when some kind
- * of event occur. Each event has his own types of informations then each event
- * use its own function.
- *
- * @package chamilo.library
- *
- * @todo convert queries to use Database API
- */
- /**
- * Class.
- *
- * @package chamilo.library
- */
- class ExerciseShowFunctions
- {
- /**
- * Shows the answer to a fill-in-the-blanks question, as HTML.
- *
- * @param Exercise $exercise
- * @param int $feedbackType
- * @param string $answer
- * @param int $id Exercise ID
- * @param int $questionId Question ID
- * @param int $resultsDisabled
- * @param string $originalStudentAnswer
- * @param bool $showTotalScoreAndUserChoices
- */
- public static function display_fill_in_blanks_answer(
- $exercise,
- $feedbackType,
- $answer,
- $id,
- $questionId,
- $resultsDisabled,
- $originalStudentAnswer = '',
- $showTotalScoreAndUserChoices
- ) {
- $answerHTML = FillBlanks::getHtmlDisplayForAnswer(
- $answer,
- $feedbackType,
- $resultsDisabled,
- $showTotalScoreAndUserChoices
- );
- if (empty($id)) {
- echo '<tr><td>';
- echo Security::remove_XSS($answerHTML, COURSEMANAGERLOWSECURITY);
- echo '</td></tr>';
- } else {
- echo '<tr><td>';
- echo Security::remove_XSS($answerHTML, COURSEMANAGERLOWSECURITY);
- echo '</td>';
- echo '</tr>';
- }
- }
- /**
- * Shows the answer to a calculated question, as HTML.
- *
- * @param Exercise $exercise
- * @param string Answer text
- * @param int Exercise ID
- * @param int Question ID
- */
- public static function display_calculated_answer(
- $exercise,
- $feedback_type,
- $answer,
- $id,
- $questionId,
- $resultsDisabled,
- $showTotalScoreAndUserChoices,
- $expectedChoice = '',
- $choice = '',
- $status = ''
- ) {
- if ($exercise->showExpectedChoice()) {
- if (empty($id)) {
- echo '<tr><td>'.Security::remove_XSS($answer).'</td>';
- echo '<td>'.Security::remove_XSS($choice).'</td>';
- if ($exercise->showExpectedChoiceColumn()) {
- echo '<td>'.Security::remove_XSS($expectedChoice).'</td>';
- }
- echo '<td>'.Security::remove_XSS($status).'</td>';
- echo '</tr>';
- } else {
- echo '<tr><td>';
- echo Security::remove_XSS($answer);
- echo '</td><td>';
- echo Security::remove_XSS($choice);
- echo '</td>';
- if ($exercise->showExpectedChoiceColumn()) {
- echo '<td>';
- echo Security::remove_XSS($expectedChoice);
- echo '</td>';
- }
- echo '<td>';
- echo Security::remove_XSS($status);
- echo '</td>';
- echo '</tr>';
- }
- } else {
- if (empty($id)) {
- echo '<tr><td>'.Security::remove_XSS($answer).'</td></tr>';
- } else {
- echo '<tr><td>';
- echo Security::remove_XSS($answer);
- echo '</tr>';
- }
- }
- }
- /**
- * Shows the answer to a free-answer question, as HTML.
- *
- * @param string Answer text
- * @param int Exercise ID
- * @param int Question ID
- */
- public static function display_free_answer(
- $feedback_type,
- $answer,
- $exe_id,
- $questionId,
- $questionScore = null,
- $resultsDisabled = 0
- ) {
- $comments = Event::get_comments($exe_id, $questionId);
- if (!empty($answer)) {
- echo '<tr><td>';
- echo Security::remove_XSS($answer);
- echo '</td></tr>';
- }
- if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
- if ($questionScore > 0 || !empty($comments)) {
- } else {
- echo '<tr>';
- echo Display::tag('td', ExerciseLib::getNotCorrectedYetText());
- echo '</tr>';
- }
- }
- }
- /**
- * @param $feedback_type
- * @param $answer
- * @param $id
- * @param $questionId
- * @param null $fileUrl
- * @param int $resultsDisabled
- * @param int $questionScore
- */
- public static function display_oral_expression_answer(
- $feedback_type,
- $answer,
- $id,
- $questionId,
- $fileUrl = null,
- $resultsDisabled = 0,
- $questionScore = 0
- ) {
- if (isset($fileUrl)) {
- echo '
- <tr>
- <td><audio src="'.$fileUrl.'" controls></audio></td>
- </tr>
- ';
- }
- if (empty($id)) {
- echo '<tr>';
- if (!empty($answer)) {
- echo Display::tag('td', Security::remove_XSS($answer), ['width' => '55%']);
- }
- echo '</tr>';
- if (!$questionScore && $feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
- echo '<tr>';
- echo Display::tag('td', ExerciseLib::getNotCorrectedYetText(), ['width' => '45%']);
- echo '</tr>';
- } else {
- echo '<tr><td> </td></tr>';
- }
- } else {
- echo '<tr>';
- echo '<td>';
- if (!empty($answer)) {
- echo Security::remove_XSS($answer);
- }
- echo '</td>';
- echo '</tr>';
- }
- }
- /**
- * Displays the answer to a hotspot question.
- *
- * @param int $feedback_type
- * @param int $answerId
- * @param string $answer
- * @param string $studentChoice
- * @param string $answerComment
- * @param int $resultsDisabled
- * @param int $orderColor
- * @param bool $showTotalScoreAndUserChoices
- */
- public static function display_hotspot_answer(
- $feedback_type,
- $answerId,
- $answer,
- $studentChoice,
- $answerComment,
- $resultsDisabled,
- $orderColor,
- $showTotalScoreAndUserChoices
- ) {
- $hide_expected_answer = false;
- switch ($resultsDisabled) {
- case RESULT_DISABLE_SHOW_SCORE_ONLY:
- if ($feedback_type == 0) {
- $hide_expected_answer = true;
- }
- break;
- case RESULT_DISABLE_DONT_SHOW_SCORE_ONLY_IF_USER_FINISHES_ATTEMPTS_SHOW_ALWAYS_FEEDBACK:
- case RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT:
- $hide_expected_answer = true;
- if ($showTotalScoreAndUserChoices) {
- $hide_expected_answer = false;
- }
- break;
- }
- $hotspot_colors = [
- '', // $i starts from 1 on next loop (ugly fix)
- '#4271B5',
- '#FE8E16',
- '#45C7F0',
- '#BCD631',
- '#D63173',
- '#D7D7D7',
- '#90AFDD',
- '#AF8640',
- '#4F9242',
- '#F4EB24',
- '#ED2024',
- '#3B3B3B',
- '#F7BDE2',
- ];
- $content = '<table class="data_table"><tr>';
- $content .= '<td class="text-center" width="5%">';
- $content .= '<span class="fa fa-square fa-fw fa-2x" aria-hidden="true" style="color:'.
- $hotspot_colors[$orderColor].'"></span>';
- $content .= '</td>';
- $content .= '<td class="text-left" width="25%">';
- $content .= "$answerId - $answer";
- $content .= '</td>';
- $content .= '<td class="text-left" width="10%">';
- if (!$hide_expected_answer) {
- $status = Display::label(get_lang('Incorrect'), 'danger');
- if ($studentChoice) {
- $status = Display::label(get_lang('Correct'), 'success');
- } else {
- if (in_array($resultsDisabled, [
- RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER,
- ])
- ) {
- return '';
- }
- }
- $content .= $status;
- }
- $content .= '</td>';
- if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
- $content .= '<td class="text-left" width="60%">';
- if ($studentChoice) {
- $content .= '<span style="font-weight: bold; color: #008000;">'.nl2br($answerComment).'</span>';
- }
- $content .= '</td>';
- } else {
- $content .= '<td class="text-left" width="60%"> </td>';
- }
- $content .= '</tr>';
- echo $content;
- }
- /**
- * Display the answers to a multiple choice question.
- *
- * @param Exercise $exercise
- * @param int $feedbackType Feedback type
- * @param int $answerType Answer type
- * @param int $studentChoice Student choice
- * @param string $answer Textual answer
- * @param string $answerComment Comment on answer
- * @param string $answerCorrect Correct answer comment
- * @param int $id Exercise ID
- * @param int $questionId Question ID
- * @param bool $ans Whether to show the answer comment or not
- * @param bool $resultsDisabled
- * @param bool $showTotalScoreAndUserChoices
- * @param bool $export
- */
- public static function display_unique_or_multiple_answer(
- $exercise,
- $feedbackType,
- $answerType,
- $studentChoice,
- $answer,
- $answerComment,
- $answerCorrect,
- $id,
- $questionId,
- $ans,
- $resultsDisabled,
- $showTotalScoreAndUserChoices,
- $export = false
- ) {
- if ($export) {
- $answer = strip_tags_blacklist($answer, ['title', 'head']);
- // Fix answers that contains this tags
- $tags = [
- '<html>',
- '</html>',
- '<body>',
- '</body>',
- ];
- $answer = str_replace($tags, '', $answer);
- }
- $studentChoiceInt = (int) $studentChoice;
- $answerCorrectChoice = (int) $answerCorrect;
- $hide_expected_answer = false;
- $showComment = false;
- switch ($resultsDisabled) {
- case RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER:
- $hide_expected_answer = true;
- $showComment = true;
- if (!$answerCorrect && empty($studentChoice)) {
- return '';
- }
- break;
- case RESULT_DISABLE_SHOW_SCORE_ONLY:
- if ($feedbackType == 0) {
- $hide_expected_answer = true;
- }
- break;
- case RESULT_DISABLE_DONT_SHOW_SCORE_ONLY_IF_USER_FINISHES_ATTEMPTS_SHOW_ALWAYS_FEEDBACK:
- case RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT:
- $hide_expected_answer = true;
- if ($showTotalScoreAndUserChoices) {
- $hide_expected_answer = false;
- }
- break;
- }
- $icon = in_array($answerType, [UNIQUE_ANSWER, UNIQUE_ANSWER_NO_OPTION]) ? 'radio' : 'checkbox';
- $icon .= $studentChoice ? '_on' : '_off';
- $icon .= '.png';
- $iconAnswer = in_array($answerType, [UNIQUE_ANSWER, UNIQUE_ANSWER_NO_OPTION]) ? 'radio' : 'checkbox';
- $iconAnswer .= $answerCorrect ? '_on' : '_off';
- $iconAnswer .= '.png';
- $studentChoiceClass = '';
- if (in_array(
- $resultsDisabled,
- [
- RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER,
- RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS_AND_RANKING,
- ]
- )
- ) {
- if ($answerCorrect) {
- $studentChoiceClass = 'success';
- }
- }
- echo '<tr class="'.$studentChoiceClass.'">';
- echo '<td width="5%">';
- echo Display::return_icon($icon, null, null, ICON_SIZE_TINY);
- echo '</td>';
- if ($exercise->showExpectedChoiceColumn()) {
- if ($hide_expected_answer === false) {
- echo '<td width="5%">';
- echo Display::return_icon($iconAnswer, null, null, ICON_SIZE_TINY);
- echo '</td>';
- } else {
- echo '<td width="5%">';
- echo '-';
- echo '</td>';
- }
- }
- echo '<td width="40%">';
- echo $answer;
- echo '</td>';
- if ($exercise->showExpectedChoice()) {
- $status = Display::label(get_lang('Incorrect'), 'danger');
- if ($answerCorrect || ($answerCorrect && $studentChoiceInt === $answerCorrectChoice)) {
- $status = Display::label(get_lang('Correct'), 'success');
- }
- echo '<td width="20%">';
- echo $status;
- echo '</td>';
- }
- if ($feedbackType != EXERCISE_FEEDBACK_TYPE_EXAM) {
- $showComment = true;
- }
- if ($showComment) {
- echo '<td width="20%">';
- $color = 'black';
- if ($answerCorrect) {
- $color = 'green';
- }
- if ($hide_expected_answer) {
- $color = '';
- }
- $comment = '<span style="font-weight: bold; color: '.$color.';">'.
- Security::remove_XSS($answerComment).
- '</span>';
- echo $comment;
- echo '</td>';
- } else {
- echo '<td> </td>';
- }
- echo '</tr>';
- }
- /**
- * Display the answers to a multiple choice question.
- *
- * @param Exercise $exercise
- * @param int Answer type
- * @param int Student choice
- * @param string Textual answer
- * @param string Comment on answer
- * @param string Correct answer comment
- * @param int Exercise ID
- * @param int Question ID
- * @param bool Whether to show the answer comment or not
- */
- public static function display_multiple_answer_true_false(
- $exercise,
- $feedbackType,
- $answerType,
- $studentChoice,
- $answer,
- $answerComment,
- $answerCorrect,
- $id,
- $questionId,
- $ans,
- $resultsDisabled,
- $showTotalScoreAndUserChoices
- ) {
- $hide_expected_answer = false;
- $hideStudentChoice = false;
- switch ($resultsDisabled) {
- //case RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS_AND_RANKING:
- case RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER:
- $hideStudentChoice = false;
- $hide_expected_answer = true;
- break;
- case RESULT_DISABLE_SHOW_SCORE_ONLY:
- if ($feedbackType == 0) {
- $hide_expected_answer = true;
- }
- break;
- case RESULT_DISABLE_DONT_SHOW_SCORE_ONLY_IF_USER_FINISHES_ATTEMPTS_SHOW_ALWAYS_FEEDBACK:
- case RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT:
- $hide_expected_answer = true;
- if ($showTotalScoreAndUserChoices) {
- $hide_expected_answer = false;
- }
- break;
- }
- $content = '<tr>';
- if ($hideStudentChoice === false) {
- $content .= '<td width="5%">';
- $course_id = api_get_course_int_id();
- $new_options = Question::readQuestionOption($questionId, $course_id);
- // Your choice
- if (isset($new_options[$studentChoice])) {
- $content .= get_lang($new_options[$studentChoice]['name']);
- } else {
- $content .= '-';
- }
- $content .= '</td>';
- }
- // Expected choice
- if ($exercise->showExpectedChoiceColumn()) {
- if (!$hide_expected_answer) {
- $content .= '<td width="5%">';
- if (isset($new_options[$answerCorrect])) {
- $content .= get_lang($new_options[$answerCorrect]['name']);
- } else {
- $content .= '-';
- }
- $content .= '</td>';
- }
- }
- $content .= '<td width="40%">';
- $content .= $answer;
- $content .= '</td>';
- if ($exercise->showExpectedChoice()) {
- $status = Display::label(get_lang('Incorrect'), 'danger');
- if (isset($new_options[$studentChoice])) {
- if ($studentChoice == $answerCorrect) {
- $status = Display::label(get_lang('Correct'), 'success');
- }
- }
- $content .= '<td width="20%">';
- $content .= $status;
- $content .= '</td>';
- }
- if ($feedbackType != EXERCISE_FEEDBACK_TYPE_EXAM) {
- $content .= '<td width="20%">';
- $color = 'black';
- if (isset($new_options[$studentChoice]) || in_array(
- $exercise->results_disabled,
- [
- RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER,
- RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS_AND_RANKING,
- ]
- )
- ) {
- if ($studentChoice == $answerCorrect) {
- $color = 'green';
- }
- if ($hide_expected_answer) {
- $color = '';
- }
- $content .= '<span style="font-weight: bold; color: '.$color.';">'.nl2br($answerComment).'</span>';
- }
- $content .= '</td>';
- }
- $content .= '</tr>';
- echo $content;
- }
- /**
- * Display the answers to a multiple choice question.
- *
- * @param Exercise $exercise
- * @param int $feedbackType
- * @param int $studentChoice
- * @param int $studentChoiceDegree
- * @param string $answer
- * @param string $answerComment
- * @param int $answerCorrect
- * @param int $questionId
- * @param bool $inResultsDisabled
- */
- public static function displayMultipleAnswerTrueFalseDegreeCertainty(
- $exercise,
- $feedbackType,
- $studentChoice,
- $studentChoiceDegree,
- $answer,
- $answerComment,
- $answerCorrect,
- $questionId,
- $inResultsDisabled
- ) {
- $hideExpectedAnswer = false;
- if ($feedbackType == 0 && $inResultsDisabled == 2) {
- $hideExpectedAnswer = true;
- }
- echo '<tr><td width="5%">';
- $question = new MultipleAnswerTrueFalseDegreeCertainty();
- $courseId = api_get_course_int_id();
- $newOptions = Question::readQuestionOption($questionId, $courseId);
- // Your choice
- if (isset($newOptions[$studentChoice])) {
- echo get_lang($newOptions[$studentChoice]['name']);
- } else {
- echo '-';
- }
- echo '</td>';
- // Expected choice
- if ($exercise->showExpectedChoiceColumn()) {
- echo '<td width="5%">';
- if (!$hideExpectedAnswer) {
- if (isset($newOptions[$answerCorrect])) {
- echo get_lang($newOptions[$answerCorrect]['name']);
- } else {
- echo '-';
- }
- } else {
- echo '-';
- }
- echo '</td>';
- }
- echo '<td width="20%">';
- echo $answer;
- echo '</td><td width="5%" style="text-align:center;">';
- if (isset($newOptions[$studentChoiceDegree])) {
- echo $newOptions[$studentChoiceDegree]['name'];
- }
- echo '</td>';
- $position = isset($newOptions[$studentChoiceDegree]) ? $newOptions[$studentChoiceDegree]['position'] : '';
- $degreeInfo = $question->getResponseDegreeInfo(
- $studentChoice,
- $answerCorrect,
- $position
- );
- $degreeInfo['color'] = isset($degreeInfo['color']) ? $degreeInfo['color'] : '';
- $degreeInfo['background-color'] = isset($degreeInfo['background-color']) ? $degreeInfo['background-color'] : '';
- $degreeInfo['description'] = isset($degreeInfo['description']) ? $degreeInfo['description'] : '';
- $degreeInfo['label'] = isset($degreeInfo['label']) ? $degreeInfo['label'] : '';
- echo '
- <td width="15%">
- <div style="text-align:center;color: '.$degreeInfo['color'].';
- background-color: '.$degreeInfo['background-color'].';
- line-height:30px;height:30px;width: 100%;margin:auto;"
- title="'.$degreeInfo['description'].'">'.
- nl2br($degreeInfo['label']).
- '</div>
- </td>';
- if ($feedbackType != EXERCISE_FEEDBACK_TYPE_EXAM) {
- echo '<td width="20%">';
- if (isset($newOptions[$studentChoice])) {
- echo '<span style="font-weight: bold; color: black;">'.nl2br($answerComment).'</span>';
- }
- echo '</td>';
- } else {
- echo '<td> </td>';
- }
- echo '</tr>';
- }
- /**
- * Display the answers to a multiple choice question.
- *
- * @param Exercise $exercise
- * @param int Answer type
- * @param int Student choice
- * @param string Textual answer
- * @param string Comment on answer
- * @param string Correct answer comment
- * @param int Exercise ID
- * @param int Question ID
- * @param bool Whether to show the answer comment or not
- */
- public static function display_multiple_answer_combination_true_false(
- $exercise,
- $feedbackType,
- $answerType,
- $studentChoice,
- $answer,
- $answerComment,
- $answerCorrect,
- $id,
- $questionId,
- $ans,
- $resultsDisabled,
- $showTotalScoreAndUserChoices
- ) {
- $hide_expected_answer = false;
- $hideStudentChoice = false;
- switch ($resultsDisabled) {
- case RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS_AND_RANKING:
- case RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER:
- $hideStudentChoice = true;
- $hide_expected_answer = true;
- break;
- case RESULT_DISABLE_SHOW_SCORE_ONLY:
- if ($feedbackType == 0) {
- $hide_expected_answer = true;
- }
- break;
- case RESULT_DISABLE_DONT_SHOW_SCORE_ONLY_IF_USER_FINISHES_ATTEMPTS_SHOW_ALWAYS_FEEDBACK:
- case RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT:
- $hide_expected_answer = true;
- if ($showTotalScoreAndUserChoices) {
- $hide_expected_answer = false;
- }
- break;
- }
- echo '<tr>';
- if ($hideStudentChoice === false) {
- echo '<td width="5%">';
- // Your choice
- $question = new MultipleAnswerCombinationTrueFalse();
- if (isset($question->options[$studentChoice])) {
- echo $question->options[$studentChoice];
- } else {
- echo $question->options[2];
- }
- echo '</td>';
- }
- // Expected choice
- if ($exercise->showExpectedChoiceColumn()) {
- if (!$hide_expected_answer) {
- echo '<td width="5%">';
- if (isset($question->options[$answerCorrect])) {
- echo $question->options[$answerCorrect];
- } else {
- echo $question->options[2];
- }
- echo '</td>';
- }
- }
- echo '<td width="40%">';
- echo $answer;
- echo '</td>';
- if ($exercise->showExpectedChoice()) {
- $status = '';
- if (isset($studentChoice)) {
- $status = Display::label(get_lang('Incorrect'), 'danger');
- if ($studentChoice == $answerCorrect) {
- $status = Display::label(get_lang('Correct'), 'success');
- }
- }
- echo '<td width="20%">';
- echo $status;
- echo '</td>';
- }
- if ($feedbackType != EXERCISE_FEEDBACK_TYPE_EXAM) {
- echo '<td width="20%">';
- //@todo replace this harcoded value
- if ($studentChoice || in_array($resultsDisabled, [
- RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER,
- RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS_AND_RANKING,
- ])
- ) {
- $color = 'black';
- if ($studentChoice == $answerCorrect) {
- $color = 'green';
- }
- if ($hide_expected_answer) {
- $color = '';
- }
- echo '<span style="font-weight: bold; color: '.$color.';">'.nl2br($answerComment).'</span>';
- }
- echo '</td>';
- } else {
- echo '<td> </td>';
- }
- echo '</tr>';
- }
- /**
- * @param int $feedbackType
- * @param int $exeId
- * @param int $questionId
- * @param null $questionScore
- * @param int $resultsDisabled
- */
- public static function displayAnnotationAnswer(
- $feedbackType,
- $exeId,
- $questionId,
- $questionScore = null,
- $resultsDisabled = 0
- ) {
- $comments = Event::get_comments($exeId, $questionId);
- if ($feedbackType != EXERCISE_FEEDBACK_TYPE_EXAM) {
- if ($questionScore <= 0 && empty($comments)) {
- echo '<br />'.ExerciseLib::getNotCorrectedYetText();
- }
- }
- }
- }
|