# Generated by Django 5.2.17 on 2026-10-07 09:37

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


class Migration(migrations.Migration):

    dependencies = [
        ('exams', '0022_kc_key_terms_prerequisites'),
    ]

    operations = [
        migrations.CreateModel(
            name='RPSItem',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('kc_code', models.CharField(blank=True, db_index=True, max_length=30)),
                ('first_seen_at', models.DateTimeField(auto_now_add=True)),
                ('last_attempted_at', models.DateTimeField(blank=True, null=True)),
                ('next_due_at', models.DateField(db_index=True)),
                ('current_interval_days', models.PositiveSmallIntegerField(default=1)),
                ('current_ease', models.FloatField(default=2.5)),
                ('consecutive_correct', models.PositiveSmallIntegerField(default=0)),
                ('lapsed_count', models.PositiveSmallIntegerField(default=0)),
                ('mastery_state', models.CharField(choices=[('LEARNING', 'Learning'), ('REVIEWING', 'Reviewing'), ('GRADUATED', 'Graduated')], db_index=True, default='LEARNING', max_length=12)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('model_question', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='rps_items', to='exams.modelquestion')),
                ('student', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='rps_items', to='exams.student')),
            ],
        ),
        migrations.CreateModel(
            name='RPSAttempt',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('attempted_at', models.DateTimeField(db_index=True)),
                ('latency_ms', models.PositiveIntegerField(blank=True, null=True)),
                ('response_kind', models.CharField(choices=[('PAPER_TEST', 'Paper test (ingested)'), ('TYPED', 'Typed answer (reserved)'), ('SELF_REPORT', 'Self-report (reserved)'), ('MCQ', 'MCQ (reserved)'), ('ORAL_TEACHER', 'Teacher-oral (reserved)')], default='PAPER_TEST', max_length=16)),
                ('outcome', models.CharField(choices=[('CORRECT', 'Correct'), ('PARTIAL', 'Partial'), ('WRONG', 'Wrong'), ('SKIPPED', 'Skipped')], max_length=8)),
                ('source', models.CharField(choices=[('INGEST_PIPELINE', 'Ingest pipeline'), ('TEACHER_PORTAL', 'Teacher portal')], default='INGEST_PIPELINE', max_length=16)),
                ('note', models.TextField(blank=True)),
                ('reported_at', models.DateTimeField(auto_now_add=True)),
                ('exam', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='rps_attempts', to='exams.exam')),
                ('submission', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='rps_attempts', to='exams.submission')),
                ('item', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='attempts', to='exams.rpsitem')),
            ],
        ),
        migrations.CreateModel(
            name='RPSSchedule',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('day', models.DateField(db_index=True)),
                ('cap_items', models.PositiveSmallIntegerField()),
                ('produced_count', models.PositiveSmallIntegerField(default=0)),
                ('item_ids', models.JSONField(blank=True, default=list)),
                ('produced_at', models.DateTimeField(auto_now_add=True)),
                ('student', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='rps_schedules', to='exams.student')),
            ],
        ),
        migrations.AddIndex(
            model_name='rpsitem',
            index=models.Index(fields=['student', 'next_due_at'], name='exams_rpsit_student_0f8e6d_idx'),
        ),
        migrations.AddIndex(
            model_name='rpsitem',
            index=models.Index(fields=['student', 'mastery_state'], name='exams_rpsit_student_0f0ad0_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='rpsitem',
            unique_together={('student', 'model_question')},
        ),
        migrations.AddIndex(
            model_name='rpsattempt',
            index=models.Index(fields=['item', 'attempted_at'], name='exams_rpsat_item_id_45772d_idx'),
        ),
        migrations.AddIndex(
            model_name='rpsattempt',
            index=models.Index(fields=['outcome'], name='exams_rpsat_outcome_75a6bd_idx'),
        ),
        migrations.AddIndex(
            model_name='rpsschedule',
            index=models.Index(fields=['day'], name='exams_rpssc_day_d16c7c_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='rpsschedule',
            unique_together={('student', 'day')},
        ),
    ]
