Merge branch '1.11.x' of github.com:chamilo/chamilo-lms into 1.11.x

pull/6061/head
Yannick Warnier 8 months ago
commit 82f4ca6a96
  1. 36
      main/exercise/exercise.class.php
  2. 2
      main/exercise/exercise_show.php
  3. 6
      main/inc/lib/exercise.lib.php
  4. 18
      main/inc/lib/exercise_show_functions.lib.php

@ -3872,8 +3872,8 @@ class Exercise
if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY) { if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY) {
$choiceTmp = $choice; $choiceTmp = $choice;
$choice = isset($choiceTmp['choice']) ? $choiceTmp['choice'] : ''; $choice = $choiceTmp['choice'] ?? '';
$choiceDegreeCertainty = isset($choiceTmp['choiceDegreeCertainty']) ? $choiceTmp['choiceDegreeCertainty'] : ''; $choiceDegreeCertainty = $choiceTmp['choiceDegreeCertainty'] ?? '';
} }
if ($answerType == FREE_ANSWER || if ($answerType == FREE_ANSWER ||
@ -3888,12 +3888,12 @@ class Exercise
$generatedFile = ''; $generatedFile = '';
if ($answerType == ORAL_EXPRESSION) { if ($answerType == ORAL_EXPRESSION) {
$exe_info = Event::get_exercise_results_by_attempt($exeId); $exe_info = Event::get_exercise_results_by_attempt($exeId);
$exe_info = isset($exe_info[$exeId]) ? $exe_info[$exeId] : null; $exe_info = $exe_info[$exeId] ?? null;
$objQuestionTmp->initFile( $objQuestionTmp->initFile(
api_get_session_id(), api_get_session_id(),
isset($exe_info['exe_user_id']) ? $exe_info['exe_user_id'] : api_get_user_id(), $exe_info['exe_user_id'] ?? api_get_user_id(),
isset($exe_info['exe_exo_id']) ? $exe_info['exe_exo_id'] : $this->iid, $exe_info['exe_exo_id'] ?? $this->iid,
isset($exe_info['exe_id']) ? $exe_info['exe_id'] : $exeId $exe_info['exe_id'] ?? $exeId
); );
// Probably this attempt came in an exercise all question by page // Probably this attempt came in an exercise all question by page
@ -4068,7 +4068,7 @@ class Exercise
$userAnsweredQuestion = !empty($choice); $userAnsweredQuestion = !empty($choice);
} }
$studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null; $studentChoice = $choice[$answerAutoId] ?? null;
if (isset($studentChoice)) { if (isset($studentChoice)) {
$correctAnswerId[] = $answerAutoId; $correctAnswerId[] = $answerAutoId;
if ($studentChoice == $answerCorrect) { if ($studentChoice == $answerCorrect) {
@ -4110,8 +4110,8 @@ class Exercise
} }
} }
$studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null; $studentChoice = $choice[$answerAutoId] ?? null;
$studentChoiceDegree = isset($choiceDegreeCertainty[$answerAutoId]) ? $choiceDegreeCertainty[$answerAutoId] : null; $studentChoiceDegree = $choiceDegreeCertainty[$answerAutoId] ?? null;
// student score update // student score update
if (!empty($studentChoice)) { if (!empty($studentChoice)) {
@ -4150,14 +4150,14 @@ class Exercise
$choice[$row['answer']] = 1; $choice[$row['answer']] = 1;
} }
$studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null; $studentChoice = $choice[$answerAutoId] ?? null;
$real_answers[$answerId] = (bool) $studentChoice; $real_answers[$answerId] = (bool) $studentChoice;
if ($studentChoice) { if ($studentChoice) {
$questionScore += $answerWeighting; $questionScore += $answerWeighting;
} }
} else { } else {
$studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null; $studentChoice = $choice[$answerAutoId] ?? null;
$real_answers[$answerId] = (bool) $studentChoice; $real_answers[$answerId] = (bool) $studentChoice;
if (isset($studentChoice) if (isset($studentChoice)
@ -4178,13 +4178,13 @@ class Exercise
while ($row = Database::fetch_array($resultans)) { while ($row = Database::fetch_array($resultans)) {
$choice[$row['answer']] = 1; $choice[$row['answer']] = 1;
} }
$studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null; $studentChoice = $choice[$answerAutoId] ?? null;
$real_answers[$answerId] = (bool) $studentChoice; $real_answers[$answerId] = (bool) $studentChoice;
if ($studentChoice) { if ($studentChoice) {
$questionScore += $answerWeighting; $questionScore += $answerWeighting;
} }
} else { } else {
$studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null; $studentChoice = $choice[$answerAutoId] ?? null;
if (isset($studentChoice)) { if (isset($studentChoice)) {
$questionScore += $answerWeighting; $questionScore += $answerWeighting;
} }
@ -4209,13 +4209,13 @@ class Exercise
$choice[$my_answer_id] = $option; $choice[$my_answer_id] = $option;
} }
} }
$studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : ''; $studentChoice = $choice[$answerAutoId] ?? '';
$real_answers[$answerId] = false; $real_answers[$answerId] = false;
if ($answerCorrect == $studentChoice) { if ($answerCorrect == $studentChoice) {
$real_answers[$answerId] = true; $real_answers[$answerId] = true;
} }
} else { } else {
$studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : ''; $studentChoice = $choice[$answerAutoId] ?? '';
$real_answers[$answerId] = false; $real_answers[$answerId] = false;
if ($answerCorrect == $studentChoice) { if ($answerCorrect == $studentChoice) {
$real_answers[$answerId] = true; $real_answers[$answerId] = true;
@ -4232,7 +4232,7 @@ class Exercise
$choice[$row['answer']] = 1; $choice[$row['answer']] = 1;
} }
$studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null; $studentChoice = $choice[$answerAutoId] ?? null;
if (1 == $answerCorrect) { if (1 == $answerCorrect) {
$real_answers[$answerId] = false; $real_answers[$answerId] = false;
if ($studentChoice) { if ($studentChoice) {
@ -4245,7 +4245,7 @@ class Exercise
} }
} }
} else { } else {
$studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null; $studentChoice = $choice[$answerAutoId] ?? null;
if (1 == $answerCorrect) { if (1 == $answerCorrect) {
$real_answers[$answerId] = false; $real_answers[$answerId] = false;
if ($studentChoice) { if ($studentChoice) {
@ -5745,7 +5745,7 @@ class Exercise
break; break;
case ORAL_EXPRESSION: case ORAL_EXPRESSION:
echo '<tr> echo '<tr>
<td valign="top">'. <td>'.
ExerciseShowFunctions::display_oral_expression_answer( ExerciseShowFunctions::display_oral_expression_answer(
$feedback_type, $feedback_type,
$choice, $choice,

@ -416,7 +416,7 @@ if ($allowRecordAudio && $allowTeacherCommentAudio) {
} }
foreach ($questionList as $questionId) { foreach ($questionList as $questionId) {
$choice = isset($exerciseResult[$questionId]) ? $exerciseResult[$questionId] : ''; $choice = $exerciseResult[$questionId] ?? '';
// destruction of the Question object // destruction of the Question object
unset($objQuestionTmp); unset($objQuestionTmp);
$questionWeighting = 0; $questionWeighting = 0;

@ -5399,7 +5399,7 @@ EOT;
$exerciseResult = Session::read('exerciseResult'); $exerciseResult = Session::read('exerciseResult');
$exerciseResultCoordinates = Session::read('exerciseResultCoordinates'); $exerciseResultCoordinates = Session::read('exerciseResultCoordinates');
$delineationResults = Session::read('hotspot_delineation_result'); $delineationResults = Session::read('hotspot_delineation_result');
$delineationResults = isset($delineationResults[$objExercise->iid]) ? $delineationResults[$objExercise->iid] : null; $delineationResults = $delineationResults[$objExercise->iid] ?? null;
} }
$countPendingQuestions = 0; $countPendingQuestions = 0;
@ -5414,8 +5414,8 @@ EOT;
$choice = null; $choice = null;
$delineationChoice = null; $delineationChoice = null;
if ($loadChoiceFromSession) { if ($loadChoiceFromSession) {
$choice = isset($exerciseResult[$questionId]) ? $exerciseResult[$questionId] : null; $choice = $exerciseResult[$questionId] ?? null;
$delineationChoice = isset($delineationResults[$questionId]) ? $delineationResults[$questionId] : null; $delineationChoice = $delineationResults[$questionId] ?? null;
} }
// We're inside *one* question. Go through each possible answer for this question // We're inside *one* question. Go through each possible answer for this question

@ -221,13 +221,19 @@ class ExerciseShowFunctions
echo '<tr><td>&nbsp;</td></tr>'; echo '<tr><td>&nbsp;</td></tr>';
} }
} else { } else {
echo '<tr>'; $text = '';
echo '<td>';
if (!empty($answer)) { if (is_array($answer) && !empty($answer['answer'])) {
echo Security::remove_XSS($answer); $text = $answer['answer'];
} elseif (!is_array($answer)) {
$text = $answer;
}
if (!empty($text)) {
echo '<tr><td>';
echo Security::remove_XSS($text);
echo '</td></tr>';
} }
echo '</td>';
echo '</tr>';
} }
} }

Loading…
Cancel
Save