I make a web application that provides an opportunity to compete in the passage of the quiz. I want to make sure that each user loads another question, if one of them has already answered correctly. I have absolutely no idea how to make the interaction between users. I believe that a component must be created that accesses the view in order to load the page to all users, and the view before it accesses it to give a signal to change. Please suggest solutions.
1 answer
For this, you can use Websocket, in Django, use Channels https://channels.readthedocs.io/en/latest/
In short, you download the page and subscribe to the websocket channel and already through the channel you will be able to send data from the server to the client at any time. For without this, you can not change the contents of the page in the browser without a request to the server.
When someone answers, you can send the next question to the browser of another player via the channel, and then vice versa.
I tried to write the answer as simply as possible so that you would understand where to dig.
|