All checks were successful
Deploy Quartz site to GitHub Pages / build (push) Successful in 2m29s
27 lines
995 B
Python
27 lines
995 B
Python
from django.db import models
|
|
from .quiz_user_model import QuizUser
|
|
from .quiz_session_model import QuizSession
|
|
from .question_model import Question
|
|
|
|
|
|
class QuizResult(models.Model):
|
|
user = models.ForeignKey(QuizUser, on_delete=models.CASCADE, related_name='results')
|
|
quiz_session = models.ForeignKey(QuizSession, on_delete=models.CASCADE, related_name='results', null=True, blank=True)
|
|
question = models.ForeignKey(Question, on_delete=models.CASCADE)
|
|
selected_answer = models.CharField(max_length=1)
|
|
is_correct = models.BooleanField()
|
|
difficulty = models.CharField(max_length=10, blank=True, null=True, choices=[
|
|
('again', 'Again'),
|
|
('hard', 'Hard'),
|
|
('good', 'Good'),
|
|
('easy', 'Easy'),
|
|
])
|
|
answered_at = models.DateTimeField(auto_now_add=True)
|
|
|
|
class Meta:
|
|
unique_together = ['user', 'question']
|
|
|
|
def __str__(self):
|
|
return f"{self.user} - {self.question.text[:30]} - {'✓' if self.is_correct else '✗'}"
|
|
|