Skip to content

Commit

Permalink
🐛 Fix excel import when answer is a number
Browse files Browse the repository at this point in the history
  • Loading branch information
mawoka-myblock authored Jul 14, 2024
1 parent 2bfd734 commit a723ef5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions classquiz/helpers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ async def handle_import_from_excel(data: BinaryIO, user: User) -> Quiz:
for a, answer in enumerate(answers):
if answer is None:
continue
if len(answer) > 150:
if len(str(answer)) > 150:
raise HTTPException(status_code=400, detail=f"Answer {a + 1} in Question {i + 1} is longer than 150")
if len(answers) < 2:
raise HTTPException(status_code=400, detail=f"Less than 2 answers in Question {i + 1}")
Expand All @@ -155,7 +155,7 @@ async def handle_import_from_excel(data: BinaryIO, user: User) -> Quiz:
for a, answer in enumerate(answers):
if answer is None:
continue
answers_list.append(ABCDQuizAnswer(answer=answer, right=str(a + 1) in correct_answers))
answers_list.append(ABCDQuizAnswer(answer=str(answer), right=str(a + 1) in correct_answers))

existing_question: dict | None = None
if existing_quiz is not None:
Expand Down

0 comments on commit a723ef5

Please sign in to comment.