|
|
|
@ -1,16 +1,6 @@ |
|
|
|
|
<?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. |
|
|
|
|
* |
|
|
|
|
* @todo convert queries to use Database API |
|
|
|
|
*/ |
|
|
|
|
class ExerciseShowFunctions |
|
|
|
|
{ |
|
|
|
|
/** |
|
|
|
@ -207,6 +197,7 @@ class ExerciseShowFunctions |
|
|
|
|
* @param bool $showTotalScoreAndUserChoices |
|
|
|
|
*/ |
|
|
|
|
public static function display_hotspot_answer( |
|
|
|
|
$exercise, |
|
|
|
|
$feedback_type, |
|
|
|
|
$answerId, |
|
|
|
|
$answer, |
|
|
|
@ -230,9 +221,25 @@ class ExerciseShowFunctions |
|
|
|
|
$hide_expected_answer = false; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT_NO_FEEDBACK: |
|
|
|
|
$hide_expected_answer = true; |
|
|
|
|
if ($showTotalScoreAndUserChoices) { |
|
|
|
|
$hide_expected_answer = false; |
|
|
|
|
} |
|
|
|
|
if (false === $showTotalScoreAndUserChoices && empty($studentChoice)) { |
|
|
|
|
return ''; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$hotspot_colors = [ |
|
|
|
|
if (!$hide_expected_answer |
|
|
|
|
&& !$studentChoice |
|
|
|
|
&& in_array($resultsDisabled, [RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER]) |
|
|
|
|
) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$hotspotColors = [ |
|
|
|
|
'', // $i starts from 1 on next loop (ugly fix) |
|
|
|
|
'#4271B5', |
|
|
|
|
'#FE8E16', |
|
|
|
@ -249,39 +256,38 @@ class ExerciseShowFunctions |
|
|
|
|
'#F7BDE2', |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
$content = '<table class="data_table"><tr>'; |
|
|
|
|
$content = '<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>'; |
|
|
|
|
$hotspotColors[$orderColor].'"></span>'; |
|
|
|
|
$content .= '</td>'; |
|
|
|
|
$content .= '<td class="text-left" width="25%">'; |
|
|
|
|
$content .= "$answerId - $answer"; |
|
|
|
|
$content .= '</td>'; |
|
|
|
|
if (false === $exercise->hideComment) { |
|
|
|
|
$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; |
|
|
|
|
} else { |
|
|
|
|
$content .= ' '; |
|
|
|
|
} |
|
|
|
|
$content .= '</td>'; |
|
|
|
|
if (EXERCISE_FEEDBACK_TYPE_EXAM != $feedback_type) { |
|
|
|
|
$content .= '<td class="text-left" width="60%">'; |
|
|
|
|
if ($studentChoice) { |
|
|
|
|
$content .= '<span style="font-weight: bold; color: #008000;">'.nl2br($answerComment).'</span>'; |
|
|
|
|
} else { |
|
|
|
|
$content .= ' '; |
|
|
|
|
} |
|
|
|
|
$content .= '</td>'; |
|
|
|
|
} else { |
|
|
|
|
$content .= '<td class="text-left" width="60%"> </td>'; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$content .= '</tr>'; |
|
|
|
|
|
|
|
|
|
echo $content; |
|
|
|
@ -319,6 +325,9 @@ class ExerciseShowFunctions |
|
|
|
|
$showTotalScoreAndUserChoices, |
|
|
|
|
$export = false |
|
|
|
|
) { |
|
|
|
|
if (true === $exercise->hideNoAnswer && empty($studentChoice)) { |
|
|
|
|
return ''; |
|
|
|
|
} |
|
|
|
|
if ($export) { |
|
|
|
|
$answer = strip_tags_blacklist($answer, ['title', 'head']); |
|
|
|
|
// Fix answers that contains this tags |
|
|
|
@ -356,6 +365,11 @@ class ExerciseShowFunctions |
|
|
|
|
$hide_expected_answer = false; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT_NO_FEEDBACK: |
|
|
|
|
if (false === $showTotalScoreAndUserChoices && empty($studentChoiceInt)) { |
|
|
|
|
return ''; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$icon = in_array($answerType, [UNIQUE_ANSWER, UNIQUE_ANSWER_NO_OPTION]) ? 'radio' : 'checkbox'; |
|
|
|
@ -418,6 +432,7 @@ class ExerciseShowFunctions |
|
|
|
|
$showComment = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (false === $exercise->hideComment) { |
|
|
|
|
if ($showComment) { |
|
|
|
|
echo '<td width="20%">'; |
|
|
|
|
$color = 'black'; |
|
|
|
@ -435,6 +450,7 @@ class ExerciseShowFunctions |
|
|
|
|
} else { |
|
|
|
|
echo '<td> </td>'; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
echo '</tr>'; |
|
|
|
|
} |
|
|
|
@ -486,6 +502,11 @@ class ExerciseShowFunctions |
|
|
|
|
$hide_expected_answer = false; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT_NO_FEEDBACK: |
|
|
|
|
if (false === $showTotalScoreAndUserChoices && empty($studentChoice)) { |
|
|
|
|
return ''; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$content = '<tr>'; |
|
|
|
@ -531,6 +552,7 @@ class ExerciseShowFunctions |
|
|
|
|
$content .= '</td>'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (false === $exercise->hideComment) { |
|
|
|
|
if (EXERCISE_FEEDBACK_TYPE_EXAM != $feedbackType) { |
|
|
|
|
$content .= '<td width="20%">'; |
|
|
|
|
$color = 'black'; |
|
|
|
@ -553,6 +575,7 @@ class ExerciseShowFunctions |
|
|
|
|
} |
|
|
|
|
$content .= '</td>'; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$content .= '</tr>'; |
|
|
|
|
|
|
|
|
|
echo $content; |
|
|
|
@ -645,6 +668,7 @@ class ExerciseShowFunctions |
|
|
|
|
'</div> |
|
|
|
|
</td>'; |
|
|
|
|
|
|
|
|
|
if (false === $exercise->hideComment) { |
|
|
|
|
if (EXERCISE_FEEDBACK_TYPE_EXAM != $feedbackType) { |
|
|
|
|
echo '<td width="20%">'; |
|
|
|
|
if (isset($newOptions[$studentChoice])) { |
|
|
|
@ -654,6 +678,7 @@ class ExerciseShowFunctions |
|
|
|
|
} else { |
|
|
|
|
echo '<td> </td>'; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
echo '</tr>'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -704,6 +729,11 @@ class ExerciseShowFunctions |
|
|
|
|
$hide_expected_answer = false; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT_NO_FEEDBACK: |
|
|
|
|
if (false === $showTotalScoreAndUserChoices && empty($studentChoice)) { |
|
|
|
|
return ''; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
echo '<tr>'; |
|
|
|
@ -750,13 +780,17 @@ class ExerciseShowFunctions |
|
|
|
|
echo '</td>'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (false === $exercise->hideComment) { |
|
|
|
|
if (EXERCISE_FEEDBACK_TYPE_EXAM != $feedbackType) { |
|
|
|
|
echo '<td width="20%">'; |
|
|
|
|
//@todo replace this harcoded value |
|
|
|
|
if ($studentChoice || in_array($resultsDisabled, [ |
|
|
|
|
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) { |
|
|
|
@ -770,6 +804,7 @@ class ExerciseShowFunctions |
|
|
|
|
echo '</td>'; |
|
|
|
|
} else { |
|
|
|
|
echo '<td> </td>'; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
echo '</tr>'; |
|
|
|
|
} |
|
|
|
|