Spaces:
Sleeping
Sleeping
| from tortoise import fields, models | |
| class AdminAuditLog(models.Model): | |
| id = fields.IntField(pk=True) | |
| admin = fields.ForeignKeyField( | |
| "models.User", related_name="admin_audit_logs", null=True | |
| ) | |
| action = fields.CharField(max_length=120) | |
| entity_type = fields.CharField(max_length=80, null=True) | |
| entity_id = fields.CharField(max_length=120, null=True) | |
| details = fields.JSONField(null=True) | |
| created_at = fields.DatetimeField(auto_now_add=True) | |
| class Meta: | |
| table = "admin_audit_logs" | |
| ordering = ["-created_at"] | |
| class LearningArticle(models.Model): | |
| id = fields.IntField(pk=True) | |
| title = fields.CharField(max_length=200) | |
| slug = fields.CharField(max_length=220, unique=True) | |
| category = fields.CharField(max_length=80) | |
| summary = fields.TextField(null=True) | |
| content = fields.TextField() | |
| difficulty = fields.CharField(max_length=30, default="beginner") | |
| status = fields.CharField(max_length=20, default="draft") | |
| sort_order = fields.IntField(default=0) | |
| created_by = fields.ForeignKeyField( | |
| "models.User", related_name="learning_articles", null=True | |
| ) | |
| created_at = fields.DatetimeField(auto_now_add=True) | |
| updated_at = fields.DatetimeField(auto_now=True) | |
| class Meta: | |
| table = "learning_articles" | |
| ordering = ["sort_order", "-updated_at"] | |
| class LearningQuiz(models.Model): | |
| id = fields.IntField(pk=True) | |
| article = fields.ForeignKeyField( | |
| "models.LearningArticle", related_name="quizzes", null=True | |
| ) | |
| title = fields.CharField(max_length=200) | |
| slug = fields.CharField(max_length=220, unique=True) | |
| category = fields.CharField(max_length=80) | |
| description = fields.TextField(null=True) | |
| difficulty = fields.CharField(max_length=30, default="beginner") | |
| passing_score = fields.IntField(default=70) | |
| status = fields.CharField(max_length=20, default="draft") | |
| created_at = fields.DatetimeField(auto_now_add=True) | |
| updated_at = fields.DatetimeField(auto_now=True) | |
| class Meta: | |
| table = "learning_quizzes" | |
| ordering = ["category", "difficulty", "title"] | |
| class LearningQuizQuestion(models.Model): | |
| id = fields.IntField(pk=True) | |
| quiz = fields.ForeignKeyField("models.LearningQuiz", related_name="questions") | |
| question_type = fields.CharField(max_length=40, default="scenario") | |
| prompt = fields.TextField() | |
| scenario = fields.TextField(null=True) | |
| life_situation = fields.TextField(null=True) | |
| calculation_notes = fields.TextField(null=True) | |
| options = fields.JSONField(null=True) | |
| correct_answer = fields.JSONField(null=True) | |
| explanation = fields.TextField(null=True) | |
| points = fields.IntField(default=1) | |
| sort_order = fields.IntField(default=0) | |
| class Meta: | |
| table = "learning_quiz_questions" | |
| ordering = ["sort_order", "id"] | |
| class LearningQuizAttempt(models.Model): | |
| id = fields.IntField(pk=True) | |
| user = fields.ForeignKeyField("models.User", related_name="quiz_attempts") | |
| quiz = fields.ForeignKeyField("models.LearningQuiz", related_name="attempts") | |
| score = fields.DecimalField(max_digits=6, decimal_places=2) | |
| passed = fields.BooleanField(default=False) | |
| answers = fields.JSONField(null=True) | |
| feedback = fields.JSONField(null=True) | |
| created_at = fields.DatetimeField(auto_now_add=True) | |
| class Meta: | |
| table = "learning_quiz_attempts" | |
| ordering = ["-created_at"] | |
| class AdminSupportNote(models.Model): | |
| id = fields.IntField(pk=True) | |
| user = fields.ForeignKeyField("models.User", related_name="admin_support_notes") | |
| admin = fields.ForeignKeyField( | |
| "models.User", related_name="created_support_notes", null=True | |
| ) | |
| note = fields.TextField() | |
| created_at = fields.DatetimeField(auto_now_add=True) | |
| class Meta: | |
| table = "admin_support_notes" | |
| ordering = ["-created_at"] | |