All checks were successful
Deploy Quartz site to GitHub Pages / build (push) Successful in 2m29s
17 lines
442 B
Python
17 lines
442 B
Python
from django.shortcuts import render
|
|
from quiz.models import QuizResult
|
|
|
|
|
|
def stats(request):
|
|
results = QuizResult.objects.filter(user=request.quiz_user)
|
|
total = results.count()
|
|
correct = results.filter(is_correct=True).count()
|
|
|
|
context = {
|
|
'total': total,
|
|
'correct': correct,
|
|
'percentage': round((correct / total * 100) if total > 0 else 0, 1),
|
|
}
|
|
return render(request, 'stats.html', context)
|
|
|