From 34c5adc1a51fb7efae016512a819cb2770ad2fa3 Mon Sep 17 00:00:00 2001 From: Mawoka Date: Thu, 9 Jun 2022 16:09:22 +0200 Subject: [PATCH] :bug: Fixed Result-Export-Function --- classquiz/helpers.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/classquiz/helpers.py b/classquiz/helpers.py index c662373..1cc131d 100644 --- a/classquiz/helpers.py +++ b/classquiz/helpers.py @@ -31,13 +31,17 @@ async def generate_spreadsheet(quiz_results: dict, quiz: Quiz, with_images: bool answer_data = quiz_results[str(i)] worksheet.write(i + 1, 0, question["question"]) worksheet.write(i + 1, 1, question["time"]) - if with_images and question["image"] != "" or question["image"] is not None: + + try: async with ClientSession() as session, session.get(question["image"]) as response: + print("OK!!!!") img_data = BytesIO(await response.read()) worksheet.insert_image(i + 1, 2, question["image"], {"image_data": img_data}) image = Image.open(img_data) worksheet.set_row(i + 1, image.height) worksheet.set_column(2, 2, image.width) + except TypeError: + pass answer_amount = len(answer_data) correct_answers = 0 wrong_answers = 0