# Generated by Django 5.2.17 on 2026-10-09 20:50

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('exams', '0053_parentacknowledgement'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='ParentTaskCompletion',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('task_ref', models.CharField(max_length=80)),
                ('task_type', models.CharField(max_length=30)),
                ('challenge_phrase', models.CharField(blank=True, help_text='Random phrase parent must say aloud (anti-pre-record)', max_length=120)),
                ('voice_note', models.FileField(upload_to='parent_voice_notes/%Y/%m/')),
                ('voice_duration_seconds', models.PositiveSmallIntegerField(default=0)),
                ('submitted_at', models.DateTimeField(auto_now_add=True)),
                ('submitted_ip', models.GenericIPAddressField(blank=True, null=True)),
                ('status', models.CharField(choices=[('PENDING', 'Pending review'), ('CONFIRMED', 'Confirmed by teacher'), ('REJECTED', 'Rejected (fraud suspected)')], db_index=True, default='PENDING', max_length=12)),
                ('teacher_confirmed', models.BooleanField(default=False)),
                ('teacher_confirmed_at', models.DateTimeField(blank=True, null=True)),
                ('teacher_note', models.TextField(blank=True)),
                ('fraud_suspected', models.BooleanField(default=False)),
                ('student', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='parent_task_completions', to='exams.student')),
                ('teacher_confirmed_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='confirmed_parent_tasks', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'indexes': [models.Index(fields=['student', 'task_ref'], name='exams_paren_student_4c4a7c_idx'), models.Index(fields=['status', 'submitted_at'], name='exams_paren_status_3fbf91_idx')],
                'unique_together': {('student', 'task_ref')},
            },
        ),
        migrations.CreateModel(
            name='PolicyViolation',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('violation_type', models.CharField(choices=[('parent_task_fraud', "Student completed parent's task / shared parent credentials"), ('parent_creds_shared', 'Parent credentials shared with student'), ('absent_unexcused', 'Unexcused absence'), ('late', 'Late arrival'), ('handwriting_fail', 'Handwriting drill fail'), ('other', 'Other')], db_index=True, max_length=30)),
                ('detected_at', models.DateTimeField(auto_now_add=True)),
                ('evidence', models.TextField(help_text='What was observed')),
                ('warning_number', models.PositiveSmallIntegerField(default=1, help_text='1 = first warning, 2 = strike-off trigger')),
                ('points_deducted', models.SmallIntegerField(default=0)),
                ('strike_off_triggered', models.BooleanField(default=False)),
                ('notes', models.TextField(blank=True)),
                ('detected_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='detected_violations', to=settings.AUTH_USER_MODEL)),
                ('student', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='policy_violations', to='exams.student')),
            ],
            options={
                'ordering': ['-detected_at'],
                'indexes': [models.Index(fields=['student', 'violation_type'], name='exams_polic_student_2d2511_idx'), models.Index(fields=['strike_off_triggered'], name='exams_polic_strike__9d403a_idx')],
            },
        ),
    ]
