from django.db import models class Exam(models.Model): code = models.CharField(max_length=32) credits = models.IntegerField(default=0) employee_only = models.BooleanField(default=False) published = models.BooleanField(default=False) certificate_short_name = models.CharField( max_length=255, null=True, blank=True, help_text="The short name of the certificate type to issue when the exam is passed", ) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) class Meta: db_table = "exams" def to_frontend_detail(self) -> dict: return { "id": self.id, "code": self.code, "credits": self.credits, "employee_only": self.employee_only, "variants": [ v.to_frontend_detail() for v in self.variants.all() ], }