Skip to content

Commit 133a407

Browse files
authored
Unwrap nested "preview" key in MuEdToPreviewFeedback for proper wrapping (#27)
1 parent cdab472 commit 133a407

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

runtime/mued.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,11 @@ func MuEdToEvaluateFeedback(result map[string]any) []map[string]any {
192192
}
193193

194194
// MuEdToPreviewFeedback wraps a legacy preview result as [{"preSubmissionFeedback": result}].
195+
// Unwraps the nested "preview" key produced by legacy preview functions before wrapping.
195196
func MuEdToPreviewFeedback(result map[string]any) []map[string]any {
197+
if inner, ok := result["preview"].(map[string]any); ok {
198+
result = inner
199+
}
196200
return []map[string]any{
197201
{"preSubmissionFeedback": result},
198202
}

runtime/mued_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,9 @@ func TestMuEdToEvalFeedback(t *testing.T) {
271271
}
272272

273273
func TestMuEdToPreviewFeedback(t *testing.T) {
274-
result := map[string]any{"preview": map[string]any{"latex": "x^2"}}
274+
inner := map[string]any{"latex": "x^2"}
275+
result := map[string]any{"preview": inner}
275276
fb := runtime.MuEdToPreviewFeedback(result)
276277
require.Len(t, fb, 1)
277-
assert.Equal(t, result, fb[0]["preSubmissionFeedback"])
278+
assert.Equal(t, inner, fb[0]["preSubmissionFeedback"])
278279
}

0 commit comments

Comments
 (0)