Merge branch 'Alex' into develop
This commit is contained in:
commit
f99d7463a9
6 files changed
+156
-217
No files matched your search
@@ -55,8 +55,12 @@ class GetTests(generics.ListAPIView):
|
||||
return status_filters.get(status, Test.objects.none()).order_by('dateend')
|
||||
|
||||
def set_attemps_number(self, user, tests):
|
||||
test_ids = [test.id for test in tests]
|
||||
attempt_counts = TestAttempt.objects.filter(user=user, test__id__in=test_ids).values('test').annotate(count=Count('test'))
|
||||
attempt_counts = {item['test']: item['count'] for item in attempt_counts}
|
||||
|
||||
for test in tests:
|
||||
test.attemps_number = get_attempt_count(user=user, test=test)
|
||||
test.attemps_number = test.attemps_number - attempt_counts.get(test.id, 0)
|
||||
|
||||
class TestDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||
queryset = Test.objects.all()
|
||||
|
||||
Reference in new issue
Block a user