Skip to content

Commit 82f4ca6

Browse files
committed
Merge branch '1.11.x' of github.com:chamilo/chamilo-lms into 1.11.x
2 parents 055273b + 46f11d3 commit 82f4ca6

File tree

4 files changed

+34
-28
lines changed

4 files changed

+34
-28
lines changed

main/exercise/exercise.class.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3872,8 +3872,8 @@ public function manage_answer(
38723872

38733873
if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY) {
38743874
$choiceTmp = $choice;
3875-
$choice = isset($choiceTmp['choice']) ? $choiceTmp['choice'] : '';
3876-
$choiceDegreeCertainty = isset($choiceTmp['choiceDegreeCertainty']) ? $choiceTmp['choiceDegreeCertainty'] : '';
3875+
$choice = $choiceTmp['choice'] ?? '';
3876+
$choiceDegreeCertainty = $choiceTmp['choiceDegreeCertainty'] ?? '';
38773877
}
38783878

38793879
if ($answerType == FREE_ANSWER ||
@@ -3888,12 +3888,12 @@ public function manage_answer(
38883888
$generatedFile = '';
38893889
if ($answerType == ORAL_EXPRESSION) {
38903890
$exe_info = Event::get_exercise_results_by_attempt($exeId);
3891-
$exe_info = isset($exe_info[$exeId]) ? $exe_info[$exeId] : null;
3891+
$exe_info = $exe_info[$exeId] ?? null;
38923892
$objQuestionTmp->initFile(
38933893
api_get_session_id(),
3894-
isset($exe_info['exe_user_id']) ? $exe_info['exe_user_id'] : api_get_user_id(),
3895-
isset($exe_info['exe_exo_id']) ? $exe_info['exe_exo_id'] : $this->iid,
3896-
isset($exe_info['exe_id']) ? $exe_info['exe_id'] : $exeId
3894+
$exe_info['exe_user_id'] ?? api_get_user_id(),
3895+
$exe_info['exe_exo_id'] ?? $this->iid,
3896+
$exe_info['exe_id'] ?? $exeId
38973897
);
38983898

38993899
// Probably this attempt came in an exercise all question by page
@@ -4068,7 +4068,7 @@ function ($answerId) use ($objAnswerTmp) {
40684068
$userAnsweredQuestion = !empty($choice);
40694069
}
40704070

4071-
$studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
4071+
$studentChoice = $choice[$answerAutoId] ?? null;
40724072
if (isset($studentChoice)) {
40734073
$correctAnswerId[] = $answerAutoId;
40744074
if ($studentChoice == $answerCorrect) {
@@ -4110,8 +4110,8 @@ function ($answerId) use ($objAnswerTmp) {
41104110
}
41114111
}
41124112

4113-
$studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
4114-
$studentChoiceDegree = isset($choiceDegreeCertainty[$answerAutoId]) ? $choiceDegreeCertainty[$answerAutoId] : null;
4113+
$studentChoice = $choice[$answerAutoId] ?? null;
4114+
$studentChoiceDegree = $choiceDegreeCertainty[$answerAutoId] ?? null;
41154115

41164116
// student score update
41174117
if (!empty($studentChoice)) {
@@ -4150,14 +4150,14 @@ function ($answerId) use ($objAnswerTmp) {
41504150
$choice[$row['answer']] = 1;
41514151
}
41524152

4153-
$studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
4153+
$studentChoice = $choice[$answerAutoId] ?? null;
41544154
$real_answers[$answerId] = (bool) $studentChoice;
41554155

41564156
if ($studentChoice) {
41574157
$questionScore += $answerWeighting;
41584158
}
41594159
} else {
4160-
$studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
4160+
$studentChoice = $choice[$answerAutoId] ?? null;
41614161
$real_answers[$answerId] = (bool) $studentChoice;
41624162

41634163
if (isset($studentChoice)
@@ -4178,13 +4178,13 @@ function ($answerId) use ($objAnswerTmp) {
41784178
while ($row = Database::fetch_array($resultans)) {
41794179
$choice[$row['answer']] = 1;
41804180
}
4181-
$studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
4181+
$studentChoice = $choice[$answerAutoId] ?? null;
41824182
$real_answers[$answerId] = (bool) $studentChoice;
41834183
if ($studentChoice) {
41844184
$questionScore += $answerWeighting;
41854185
}
41864186
} else {
4187-
$studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
4187+
$studentChoice = $choice[$answerAutoId] ?? null;
41884188
if (isset($studentChoice)) {
41894189
$questionScore += $answerWeighting;
41904190
}
@@ -4209,13 +4209,13 @@ function ($answerId) use ($objAnswerTmp) {
42094209
$choice[$my_answer_id] = $option;
42104210
}
42114211
}
4212-
$studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : '';
4212+
$studentChoice = $choice[$answerAutoId] ?? '';
42134213
$real_answers[$answerId] = false;
42144214
if ($answerCorrect == $studentChoice) {
42154215
$real_answers[$answerId] = true;
42164216
}
42174217
} else {
4218-
$studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : '';
4218+
$studentChoice = $choice[$answerAutoId] ?? '';
42194219
$real_answers[$answerId] = false;
42204220
if ($answerCorrect == $studentChoice) {
42214221
$real_answers[$answerId] = true;
@@ -4232,7 +4232,7 @@ function ($answerId) use ($objAnswerTmp) {
42324232
$choice[$row['answer']] = 1;
42334233
}
42344234

4235-
$studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
4235+
$studentChoice = $choice[$answerAutoId] ?? null;
42364236
if (1 == $answerCorrect) {
42374237
$real_answers[$answerId] = false;
42384238
if ($studentChoice) {
@@ -4245,7 +4245,7 @@ function ($answerId) use ($objAnswerTmp) {
42454245
}
42464246
}
42474247
} else {
4248-
$studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
4248+
$studentChoice = $choice[$answerAutoId] ?? null;
42494249
if (1 == $answerCorrect) {
42504250
$real_answers[$answerId] = false;
42514251
if ($studentChoice) {
@@ -5745,7 +5745,7 @@ function ($answerId) use ($objAnswerTmp) {
57455745
break;
57465746
case ORAL_EXPRESSION:
57475747
echo '<tr>
5748-
<td valign="top">'.
5748+
<td>'.
57495749
ExerciseShowFunctions::display_oral_expression_answer(
57505750
$feedback_type,
57515751
$choice,

main/exercise/exercise_show.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ function getFCK(vals, marksid) {
416416
}
417417

418418
foreach ($questionList as $questionId) {
419-
$choice = isset($exerciseResult[$questionId]) ? $exerciseResult[$questionId] : '';
419+
$choice = $exerciseResult[$questionId] ?? '';
420420
// destruction of the Question object
421421
unset($objQuestionTmp);
422422
$questionWeighting = 0;

main/inc/lib/exercise.lib.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5399,7 +5399,7 @@ public static function displayQuestionListByAttempt(
53995399
$exerciseResult = Session::read('exerciseResult');
54005400
$exerciseResultCoordinates = Session::read('exerciseResultCoordinates');
54015401
$delineationResults = Session::read('hotspot_delineation_result');
5402-
$delineationResults = isset($delineationResults[$objExercise->iid]) ? $delineationResults[$objExercise->iid] : null;
5402+
$delineationResults = $delineationResults[$objExercise->iid] ?? null;
54035403
}
54045404

54055405
$countPendingQuestions = 0;
@@ -5414,8 +5414,8 @@ public static function displayQuestionListByAttempt(
54145414
$choice = null;
54155415
$delineationChoice = null;
54165416
if ($loadChoiceFromSession) {
5417-
$choice = isset($exerciseResult[$questionId]) ? $exerciseResult[$questionId] : null;
5418-
$delineationChoice = isset($delineationResults[$questionId]) ? $delineationResults[$questionId] : null;
5417+
$choice = $exerciseResult[$questionId] ?? null;
5418+
$delineationChoice = $delineationResults[$questionId] ?? null;
54195419
}
54205420

54215421
// We're inside *one* question. Go through each possible answer for this question

main/inc/lib/exercise_show_functions.lib.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,19 @@ public static function display_oral_expression_answer(
221221
echo '<tr><td>&nbsp;</td></tr>';
222222
}
223223
} else {
224-
echo '<tr>';
225-
echo '<td>';
226-
if (!empty($answer)) {
227-
echo Security::remove_XSS($answer);
224+
$text = '';
225+
226+
if (is_array($answer) && !empty($answer['answer'])) {
227+
$text = $answer['answer'];
228+
} elseif (!is_array($answer)) {
229+
$text = $answer;
230+
}
231+
232+
if (!empty($text)) {
233+
echo '<tr><td>';
234+
echo Security::remove_XSS($text);
235+
echo '</td></tr>';
228236
}
229-
echo '</td>';
230-
echo '</tr>';
231237
}
232238
}
233239

0 commit comments

Comments
 (0)