|
|
|
|
@ -23,18 +23,19 @@ class StudentWorkView(APIView): |
|
|
|
|
@staticmethod |
|
|
|
|
def get(request, teacher_token): |
|
|
|
|
client_status = request.GET.get('status', 'in_progress') |
|
|
|
|
client_max_body = 50 |
|
|
|
|
last_id = request.GET.get('last_id', 0) |
|
|
|
|
server_status = Q(status='fail') if \ |
|
|
|
|
client_status == 'not_done' else Q(status='wait') if client_status == 'in_progress' else Q(status='done') |
|
|
|
|
client_status == 'not_done' else Q(status='wait') if client_status == 'in_progress'\ |
|
|
|
|
else Q(status='done') |
|
|
|
|
if request.user.is_authenticated() and request.user.groups.filter(name__in=['teachers', 'admin']).exists(): |
|
|
|
|
try: |
|
|
|
|
progress_lessons = ProgressLesson.objects.filter( |
|
|
|
|
~Q(progress__user__out_key=teacher_token), |
|
|
|
|
~Q(comment_tokens__len=0), |
|
|
|
|
server_status, |
|
|
|
|
checker__out_key=teacher_token, |
|
|
|
|
id__gt=last_id |
|
|
|
|
)[:client_max_body] |
|
|
|
|
id__gt=last_id, |
|
|
|
|
)[last_id:50] |
|
|
|
|
return Response([ProgressLessonSerializer(i).data for i in progress_lessons], status=200) |
|
|
|
|
except ValidationError: |
|
|
|
|
return Response("Bad request", status=400) |
|
|
|
|
|