Hello everybody.
I’m making a Django-powered (specifically, using Django REST Framework) web application that’s meant for a school. Teachers can create tests made up of multiple-choice questions and students can take such tests.
There’s a view that allows teachers to end an exam, after which it stops accepting answers. What I need to do, once the exam ends, is generate a pdf file for each of the students that took the test, showing the questions and the answers given by the student. The teacher then needs to be able to download a zip file containing all the pdf files.
The issue is that up to 200 students might take the exam at once, so generating the pdf’s will take a long time—what I’m trying to do is find a non-blocking way to schedule the task so the teacher who “closes” the exam (it’s this action that would trigger the generation of the files) doesn’t have to wait minutes on end just to get an OK from the server for the exam closure.
A much better UX would be for the system to immediately send the OK and then show a message telling the user that the pdf files’ generation is in progress.
How would I go about this? I have never done async programming in Django besides with Channels, so I have no experience with async views or with tools like Celery.
I have a feeling Celery might be the way to go, but before I jump into the overhead of learning how to use it, I’d like some guidance on whether that could be the best way to go about this.
In case it’s of any relevance, here’s the source code to the project GitHub - samul-1/js-exercise-platform
If you need any more information to better understand what I’m looking for, ask away!
Thank you to everyone who will take the time to help me.