Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions runtime/mued.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,11 @@ func MuEdToEvaluateFeedback(result map[string]any) []map[string]any {
}

// MuEdToPreviewFeedback wraps a legacy preview result as [{"preSubmissionFeedback": result}].
// Unwraps the nested "preview" key produced by legacy preview functions before wrapping.
func MuEdToPreviewFeedback(result map[string]any) []map[string]any {
if inner, ok := result["preview"].(map[string]any); ok {
result = inner
}
return []map[string]any{
{"preSubmissionFeedback": result},
}
Expand Down
5 changes: 3 additions & 2 deletions runtime/mued_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,9 @@ func TestMuEdToEvalFeedback(t *testing.T) {
}

func TestMuEdToPreviewFeedback(t *testing.T) {
result := map[string]any{"preview": map[string]any{"latex": "x^2"}}
inner := map[string]any{"latex": "x^2"}
result := map[string]any{"preview": inner}
fb := runtime.MuEdToPreviewFeedback(result)
require.Len(t, fb, 1)
assert.Equal(t, result, fb[0]["preSubmissionFeedback"])
assert.Equal(t, inner, fb[0]["preSubmissionFeedback"])
}
Loading