All checks were successful
Deploy Quartz site to GitHub Pages / build (push) Successful in 2m29s
39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
from django.db import models
|
|
from .exam_model import Exam
|
|
from .tag_model import Tag
|
|
|
|
|
|
class Question(models.Model):
|
|
exam = models.ForeignKey(Exam, on_delete=models.CASCADE, related_name='questions', null=True, blank=True)
|
|
file_path = models.CharField(max_length=500, unique=True)
|
|
text = models.TextField()
|
|
correct_answer = models.CharField(max_length=50) # Support multi-select answers like "A,B,C"
|
|
file_mtime = models.FloatField(null=True, blank=True) # Track file modification time
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
updated_at = models.DateTimeField(auto_now=True)
|
|
tags = models.ManyToManyField(Tag, blank=True, related_name='questions')
|
|
|
|
# Question type field
|
|
question_type = models.CharField(
|
|
max_length=20,
|
|
default='mcq',
|
|
choices=[
|
|
('mcq', 'Multiple Choice'),
|
|
('scq', 'Single Choice'),
|
|
('matching', 'Matching'),
|
|
('textalternativ', 'Text Alternative'),
|
|
('textfält', 'Text Field'),
|
|
]
|
|
)
|
|
|
|
# JSON field for matching questions
|
|
matching_data = models.JSONField(
|
|
null=True,
|
|
blank=True,
|
|
help_text="JSON data for matching questions: {left_items: [...], top_items: [...], correct_pairs: [[0,1], [1,2], ...]}"
|
|
)
|
|
|
|
def __str__(self):
|
|
return self.text[:50]
|
|
|