Commit 818dc296 authored by Julien Palard's avatar Julien Palard
Browse files

FIX: Exercises check were cached in consumers.

parent 2c41b352
......@@ -17,13 +17,11 @@ pip install -r requirements.txt
./manage.py runserver
```
Install and run a redis server.
You'll maybe need a moulinette running too, currently in the
for_django branch of the moulinette, install firejail, and start it using:
./server.py http://127.0.0.1:8000/api/ --verbose --auth staff_login:staff_password
To also run the moulinette, you'll need to install `firejail` and `redis` then run:
```
celery -A hkis worker
```
## Translations
......
"""Run using:
celery -A hkis worker
"""
import asyncio
from functools import partial
from random import choice
......
......@@ -29,8 +29,10 @@ def db_store_correction(answer, is_valid, message):
@database_sync_to_async
def db_create_answer(exercise: Exercise, user: User, source_code):
answer = exercise.answers.create(source_code=source_code, user=user)
def db_create_answer(exercise_id: int, user_id: int, source_code):
answer = Exercise.objects.get(pk=exercise_id).answers.create(
source_code=source_code, user_id=user_id
)
return answer.id, answer.exercise.check
......@@ -119,7 +121,7 @@ class ExerciseConsumer(AsyncJsonWebsocketConsumer):
async def answer(self, answer):
self.log("Receive answer from browser")
answer_id, exercise_check = await db_create_answer(
self.exercise, self.scope["user"], answer["source_code"]
self.exercise.id, self.scope["user"].id, answer["source_code"]
)
self.log("Send answer to moulinette")
is_valid, message = await check_answer(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment