diff --git a/backend/app/urls.py b/backend/app/urls.py index ec03c9a7..96f420d2 100644 --- a/backend/app/urls.py +++ b/backend/app/urls.py @@ -18,7 +18,7 @@ path('', index , name='index_page'), path('profile/', view_profile, name='view_profile'), path('profile/update/', update_profile, name='update_profile'), - path('quiz/', quiz_views.get_quiz, name="get_quiz"), + path('quiz//', quiz_views.get_quiz, name="get_quiz"), path('feed/quiz/', quiz_views.view_quizzes, name="feed_quiz"), path('quiz/create/', quiz_views.create_quiz, name="create_quiz"), path('quiz/question/', quiz_views.get_question, name="get_question"), diff --git a/backend/app/views_directory/quiz_views.py b/backend/app/views_directory/quiz_views.py index 2915374a..7c405560 100644 --- a/backend/app/views_directory/quiz_views.py +++ b/backend/app/views_directory/quiz_views.py @@ -230,8 +230,10 @@ def get_question(request): def get_quiz(request, quiz_id): quiz = get_object_or_404(Quiz, id=quiz_id) serializer = QuizSerializer(quiz, context = {'request': request}) - - return Response(serializer.data, status=status.HTTP_200_OK) + data = {'quiz': serializer.data} + data['is_solved'] = QuizProgress.objects.filter(quiz=quiz, user=request.user, completed=True).exists() + data['quiz_result_id'] = QuizResults.objects.filter(quiz=quiz, user=request.user).order_by('-id').first().id if data['is_solved'] else None + return Response(data, status=status.HTTP_200_OK)