Skip to content

Commit a723ef5

Browse files
🐛 Fix excel import when answer is a number
1 parent 2bfd734 commit a723ef5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

classquiz/helpers/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ async def handle_import_from_excel(data: BinaryIO, user: User) -> Quiz:
146146
for a, answer in enumerate(answers):
147147
if answer is None:
148148
continue
149-
if len(answer) > 150:
149+
if len(str(answer)) > 150:
150150
raise HTTPException(status_code=400, detail=f"Answer {a + 1} in Question {i + 1} is longer than 150")
151151
if len(answers) < 2:
152152
raise HTTPException(status_code=400, detail=f"Less than 2 answers in Question {i + 1}")
@@ -155,7 +155,7 @@ async def handle_import_from_excel(data: BinaryIO, user: User) -> Quiz:
155155
for a, answer in enumerate(answers):
156156
if answer is None:
157157
continue
158-
answers_list.append(ABCDQuizAnswer(answer=answer, right=str(a + 1) in correct_answers))
158+
answers_list.append(ABCDQuizAnswer(answer=str(answer), right=str(a + 1) in correct_answers))
159159

160160
existing_question: dict | None = None
161161
if existing_quiz is not None:

0 commit comments

Comments
 (0)