# Generated by Django 5.2.17 on 2026-11-06 06:39

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


class Migration(migrations.Migration):

    dependencies = [
        ('exams', '0156_add_scope_to_policy_and_visibility'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.AddField(
            model_name='studentdaymission',
            name='source',
            field=models.CharField(choices=[('AUTO', 'Auto-assigned'), ('MANUAL_OVERRIDE', 'Manually overridden'), ('MANUAL_FULL', 'Fully manually assigned')], db_index=True, default='AUTO', help_text='AUTO = system assigned. MANUAL_* = teacher override.', max_length=20),
        ),
        migrations.CreateModel(
            name='QuestionAssignment',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('date', models.DateField(db_index=True, help_text='Calendar date the override applies to')),
                ('target_class', models.CharField(blank=True, db_index=True, default='', help_text='Class scope (e.g. "9"). Empty = no class restriction.', max_length=20)),
                ('target_shift', models.CharField(blank=True, db_index=True, default='', help_text='Shift scope: "morning", "evening", or empty.', max_length=10)),
                ('position', models.PositiveSmallIntegerField(help_text="Position within the day's mission (1..pace). Replaces only this slot.")),
                ('assigned_at', models.DateTimeField(auto_now_add=True)),
                ('notes', models.TextField(blank=True, default='')),
                ('is_active', models.BooleanField(db_index=True, default=True)),
                ('assigned_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='question_assignments_created', to=settings.AUTH_USER_MODEL)),
                ('question', models.ForeignKey(help_text='The question to assign at this position.', on_delete=django.db.models.deletion.CASCADE, related_name='manual_assignments', to='exams.modelquestion')),
                ('target_student', models.ForeignKey(blank=True, help_text='Specific student override. NULL = class/shift/global scope.', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='question_assignments', to='exams.student')),
            ],
            options={
                'ordering': ['-date', 'position'],
                'indexes': [models.Index(fields=['date', 'is_active'], name='exams_quest_date_690c31_idx'), models.Index(fields=['date', 'target_class', 'target_shift'], name='exams_quest_date_7f6872_idx')],
                'unique_together': {('date', 'target_student', 'target_class', 'target_shift', 'position')},
            },
        ),
    ]
