This repository was archived by the owner on Sep 29, 2025. It is now read-only.
(EAI-1257) handle multiple correct and more answer options#887
Open
yakubova92 wants to merge 5 commits intomainfrom
Open
(EAI-1257) handle multiple correct and more answer options#887yakubova92 wants to merge 5 commits intomainfrom
yakubova92 wants to merge 5 commits intomainfrom
Conversation
mongodben
reviewed
Aug 29, 2025
Comment on lines
+12
to
+21
| const answers = ["A", "B", "C", "D", "E", "F"] | ||
| .map((label) => { | ||
| const isCorrect = correctAnswers.includes(label); | ||
| return { | ||
| answer: row[label], | ||
| isCorrect, | ||
| label, | ||
| }; | ||
| }) | ||
| .filter((answer) => answer.answer && answer.answer.trim() !== ""); // Remove empty answers |
Collaborator
There was a problem hiding this comment.
i think this code could be a little cleaner. rather than filtering at the end, can you slice the array of ["A", "B", "C", ...] to the correct length before running the map over it?
mongodben
reviewed
Aug 29, 2025
Comment on lines
+10
to
+11
| const handleAnswers = (row: any) => { | ||
| const correctAnswers = row.Answer.trim()?.split("") || []; |
Collaborator
There was a problem hiding this comment.
instead of passing row: any, please make sure that the input is strongly typed. you can use zod to do any validation that you need.
mongodben
reviewed
Aug 29, 2025
Comment on lines
+37
to
+38
| questionType: | ||
| row["Answer"].length > 1 ? "multipleCorrect" : "singleCorrect", |
Collaborator
There was a problem hiding this comment.
consider doing more typesafe parsing rather than checking string length (which isn't very resilient). for example, there could be an err in the spreadsheet
mongodben
reviewed
Aug 29, 2025
| row["Answer"].length > 1 ? "multipleCorrect" : "singleCorrect", | ||
| answers, | ||
| explanation: row["Reference"], | ||
| tags: row["tags"] ? row["tags"].split(",") : [], |
Collaborator
There was a problem hiding this comment.
Suggested change
| tags: row["tags"] ? row["tags"].split(",") : [], | |
| tags: row["tags"] ? row["tags"].split(",").map(t => t.trim()) : [], |
again, a bit more resilient
mongodben
suggested changes
Aug 29, 2025
Collaborator
mongodben
left a comment
There was a problem hiding this comment.
a couple small things to make code a bit more resilient
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Jira: https://jira.mongodb.org/browse/EAI-1257
Changes
Notes