vault backup: 2025-12-22 01:20:48
All checks were successful
Deploy Quartz site to GitHub Pages / build (push) Successful in 1m51s
All checks were successful
Deploy Quartz site to GitHub Pages / build (push) Successful in 1m51s
This commit is contained in:
@@ -7,7 +7,7 @@ from .models import Question, QuizResult
|
||||
|
||||
def index(request):
|
||||
total_questions = Question.objects.count()
|
||||
answered_count = QuizResult.objects.filter(user=request.user).count()
|
||||
answered_count = QuizResult.objects.filter(user=request.quiz_user).count()
|
||||
|
||||
context = {
|
||||
'total_questions': total_questions,
|
||||
@@ -17,7 +17,7 @@ def index(request):
|
||||
|
||||
|
||||
def get_next_question(request):
|
||||
answered_ids = QuizResult.objects.filter(user=request.user).values_list('question_id', flat=True)
|
||||
answered_ids = QuizResult.objects.filter(user=request.quiz_user).values_list('question_id', flat=True)
|
||||
next_question = Question.objects.exclude(id__in=answered_ids).first()
|
||||
|
||||
if not next_question:
|
||||
@@ -42,7 +42,7 @@ def submit_answer(request):
|
||||
is_correct = selected_answer == question.correct_answer
|
||||
|
||||
QuizResult.objects.update_or_create(
|
||||
user=request.user,
|
||||
user=request.quiz_user,
|
||||
question=question,
|
||||
defaults={
|
||||
'selected_answer': selected_answer,
|
||||
@@ -54,7 +54,7 @@ def submit_answer(request):
|
||||
|
||||
|
||||
def stats(request):
|
||||
results = QuizResult.objects.filter(user=request.user)
|
||||
results = QuizResult.objects.filter(user=request.quiz_user)
|
||||
total = results.count()
|
||||
correct = results.filter(is_correct=True).count()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user