testingView
This commit is contained in:
1 parent
153a910b6a
commit
6153c02732
2 files changed
+30
No files matched your search
@@ -204,6 +204,35 @@ class TestCreate(APIView):
|
||||
# test['test_name'] = test_names[test['id']]
|
||||
# return Response(serializer)
|
||||
|
||||
class TestingView(generics.ListCreateAPIView):
|
||||
"""API for testing."""
|
||||
queryset = Testing.objects.all()
|
||||
serializer_class = TestingSeriaizer
|
||||
pagination_class = None
|
||||
|
||||
def post(self, request):
|
||||
"""create testing"""
|
||||
try:
|
||||
testing = Testing.objects.create(
|
||||
user=User.objects.get(request.data["user_id"]),
|
||||
test=Test.objects.get(request.data["test_id"]),
|
||||
completion_date=request.data["completion_date"],
|
||||
test_passed=False,
|
||||
)
|
||||
|
||||
return Response(
|
||||
{"status": "success", "message": "Testing created successfully."},
|
||||
status=200,
|
||||
)
|
||||
except ValueError as e:
|
||||
|
||||
return Response({"status": "error", "message": str(e)}, status=400)
|
||||
|
||||
except DatabaseError as e:
|
||||
print(e)
|
||||
return Response({"status": "error", "message": str(e)}, status=400)
|
||||
|
||||
|
||||
class TestResultView(generics.ListCreateAPIView):
|
||||
"""API for getting and saving user test results."""
|
||||
queryset = TestResult.objects.all()
|
||||
|
||||
Reference in new issue
Block a user