From 247e7fb400b3bf5286b689810e0958e3ad9dd0f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20S=C3=B6lch?= Date: Wed, 15 Jan 2025 18:27:31 +0100 Subject: [PATCH] Text exercises: Fix an edge case with discarded Athena feedback suggestions for tutors (#10140) --- .../text-submission-assessment.component.ts | 7 ++++++ ...xt-submission-assessment.component.spec.ts | 22 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/main/webapp/app/exercises/text/assess/text-submission-assessment.component.ts b/src/main/webapp/app/exercises/text/assess/text-submission-assessment.component.ts index 6ca9dda0c7c0..5c1b740b7d24 100644 --- a/src/main/webapp/app/exercises/text/assess/text-submission-assessment.component.ts +++ b/src/main/webapp/app/exercises/text/assess/text-submission-assessment.component.ts @@ -311,6 +311,13 @@ export class TextSubmissionAssessmentComponent extends TextAssessmentBaseCompone // ("squish" the existing text block) existingBlockRef.block!.startIndex = end; newTextBlockRefs.push(existingBlockRef); + } else if (exEnd == end) { + // existing: |-----| + // to add: |----------| + // -> |-add--|ex-| + // ("squish" the new text block) + refToAdd.block!.endIndex = exStart; + newTextBlockRefs.push(existingBlockRef); } } } diff --git a/src/test/javascript/spec/component/text-submission-assessment/text-submission-assessment.component.spec.ts b/src/test/javascript/spec/component/text-submission-assessment/text-submission-assessment.component.spec.ts index c17c369af9ce..5da12b5602bf 100644 --- a/src/test/javascript/spec/component/text-submission-assessment/text-submission-assessment.component.spec.ts +++ b/src/test/javascript/spec/component/text-submission-assessment/text-submission-assessment.component.spec.ts @@ -559,6 +559,28 @@ describe('TextSubmissionAssessmentComponent', () => { [10, 15], ], }, + // Two blocks, same end index + { + input: [ + [377, 719], + [453, 719], + ], + output: [ + [377, 453], + [453, 719], + ], + }, + // Two blocks, same end index, wrong order + { + input: [ + [453, 719], + [377, 719], + ], + output: [ + [377, 453], + [453, 719], + ], + }, // Two blocks, shifted { input: [