vault backup: 2025-12-26 02:09:22
All checks were successful
Deploy Quartz site to GitHub Pages / build (push) Successful in 2m29s
All checks were successful
Deploy Quartz site to GitHub Pages / build (push) Successful in 2m29s
This commit is contained in:
26
stroma/quiz/models/quiz_result_model.py
Normal file
26
stroma/quiz/models/quiz_result_model.py
Normal file
@@ -0,0 +1,26 @@
|
||||
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 '✗'}"
|
||||
|
||||
Reference in New Issue
Block a user