Skip to content

Commit 642acc3

Browse files
Exercise: Fix oral recording type handling & prevent duplicate feedback audio - refs #7121
1 parent f766152 commit 642acc3

File tree

3 files changed

+26
-16
lines changed

3 files changed

+26
-16
lines changed

public/main/inc/ajax/record_audio_rtc.ajax.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,22 @@
8585

8686
$em->persist($node);
8787

88+
// Force a distinct "original_name" for attempt vs feedback.
89+
// WebRTC uploads often reuse the same client filename for both recordings, which makes
90+
// attempt and feedback indistinguishable in DB. We build a stable filename from $title.
91+
$ext = (string) pathinfo((string) $originalName, PATHINFO_EXTENSION);
92+
$ext = $ext !== '' ? strtolower($ext) : 'webm';
93+
94+
$safeBaseName = $title !== '' ? $title : (string) pathinfo((string) $originalName, PATHINFO_FILENAME);
95+
$safeBaseName = api_replace_dangerous_char($safeBaseName);
96+
$safeBaseName = disable_dangerous_file($safeBaseName);
97+
98+
$forcedOriginalName = $safeBaseName.'.'.$ext;
99+
100+
// "true" => test mode, do not enforce HTTP upload checks (consistent with current behavior).
88101
$uploadedFile = new UploadedFile(
89102
$tmpName,
90-
$originalName,
103+
$forcedOriginalName,
91104
$mimeType,
92105
$errorCode,
93106
true

public/main/inc/lib/exercise_show_functions.lib.php

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -253,35 +253,32 @@ public static function display_oral_expression_answer(
253253
return;
254254
}
255255

256-
// Student recorded answer(s)
257-
// getOralFileAudio() ya NO debe incluir los ResourceNode usados en AttemptFeedback.
256+
// Student recorded answer(s).
257+
// getOralFileAudio() must NOT include ResourceNodes used by AttemptFeedback.
258258
$studentAudioHtml = ExerciseLib::getOralFileAudio($trackExerciseId, $questionId);
259259

260260
if (!empty($studentAudioHtml)) {
261261
echo $studentAudioHtml;
262262
}
263263

264-
// Optional text answer written by the student
264+
// Optional text answer written by the student.
265265
if (!empty($answer)) {
266266
echo Display::tag('p', Security::remove_XSS($answer));
267267
}
268268

269-
// Teacher correction: comments and audio feedback
269+
// Teacher correction must NOT be rendered here.
270+
// It is rendered in the feedback section (FCK) inside exercise_show.php.
271+
// We only compute these values to decide whether to show the "Not corrected yet" warning.
270272
$comment = Event::get_comments($trackExerciseId, $questionId);
273+
274+
// Use wrap=false for consistency with the feedback area.
271275
$teacherAudio = ExerciseLib::getOralFeedbackAudio(
272276
$trackExerciseId,
273-
$questionId
277+
$questionId,
278+
false
274279
);
275280

276-
if (!empty($teacherAudio)) {
277-
echo $teacherAudio;
278-
}
279-
280-
if (!empty($comment)) {
281-
echo Display::tag('p', Security::remove_XSS($comment));
282-
}
283-
284-
// Optional "not corrected yet" warning
281+
// Optional "not corrected yet" warning.
285282
if (
286283
$showAlertIfNotCorrected &&
287284
!$questionScore &&

src/CoreBundle/Security/Authorization/Voter/ResourceNodeVoter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ protected function voteOnAttribute(string $attribute, $subject, TokenInterface $
124124
$question = $questionRepo->findOneBy(['resourceNode' => $resourceNode]);
125125
if ($question) {
126126
// Check if it's a Hotspot-type question
127-
if (\in_array($question->getType(), [6, 7, 8, 20], true)) { // HOT_SPOT, HOT_SPOT_ORDER, HOT_SPOT_DELINEATION, ANNOTATION
127+
if (\in_array($question->getType(), [6, 7, 8, 20, 13], true)) { // HOT_SPOT, HOT_SPOT_ORDER, HOT_SPOT_DELINEATION, ANNOTATION
128128
$rel = $this->entityManager
129129
->getRepository(CQuizRelQuestion::class)
130130
->findOneBy(['question' => $question])

0 commit comments

Comments
 (0)