# Generated by Django 3.0.5 on 2022-11-07 05:56

from django.conf import settings
import django.contrib.postgres.fields.jsonb
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone


class Migration(migrations.Migration):

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('exam', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='AnswerDetail',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('create_time', models.DateTimeField(default=django.utils.timezone.now, help_text='创建时间', verbose_name='创建时间')),
                ('update_time', models.DateTimeField(auto_now=True, help_text='修改时间', verbose_name='修改时间')),
                ('is_deleted', models.BooleanField(default=False, help_text='删除标记', verbose_name='删除标记')),
                ('user_answer', django.contrib.postgres.fields.jsonb.JSONField(blank=True, null=True)),
                ('score', models.FloatField(default=0, verbose_name='本题得分')),
                ('is_right', models.BooleanField(default=False, verbose_name='是否正确')),
            ],
            options={
                'verbose_name': '答题记录',
                'verbose_name_plural': '答题记录',
            },
        ),
        migrations.CreateModel(
            name='Exam',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('create_time', models.DateTimeField(default=django.utils.timezone.now, help_text='创建时间', verbose_name='创建时间')),
                ('update_time', models.DateTimeField(auto_now=True, help_text='修改时间', verbose_name='修改时间')),
                ('is_deleted', models.BooleanField(default=False, help_text='删除标记', verbose_name='删除标记')),
                ('code', models.CharField(blank=True, max_length=100, null=True, unique=True, verbose_name='考试编号')),
                ('name', models.CharField(max_length=100, verbose_name='名称')),
                ('place', models.CharField(blank=True, max_length=100, null=True, verbose_name='考试地点')),
                ('open_time', models.DateTimeField(blank=True, null=True, verbose_name='开启时间')),
                ('close_time', models.DateTimeField(blank=True, null=True, verbose_name='关闭时间')),
                ('proctor_name', models.CharField(blank=True, max_length=100, null=True, verbose_name='监考人姓名')),
                ('proctor_phone', models.CharField(blank=True, max_length=100, null=True, verbose_name='监考人联系方式')),
                ('chance', models.IntegerField(default=3, verbose_name='考试机会')),
                ('create_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='exam_create_by', to=settings.AUTH_USER_MODEL, verbose_name='创建人')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='Paper',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('create_time', models.DateTimeField(default=django.utils.timezone.now, help_text='创建时间', verbose_name='创建时间')),
                ('update_time', models.DateTimeField(auto_now=True, help_text='修改时间', verbose_name='修改时间')),
                ('is_deleted', models.BooleanField(default=False, help_text='删除标记', verbose_name='删除标记')),
                ('name', models.CharField(max_length=200, verbose_name='名称')),
                ('limit', models.IntegerField(default=0, verbose_name='限时(分钟)')),
                ('total_score', models.FloatField(default=0, verbose_name='满分')),
                ('pass_score', models.FloatField(default=0, verbose_name='通过分数')),
                ('danxuan_count', models.IntegerField(default=0, verbose_name='单选数量')),
                ('danxuan_score', models.FloatField(default=2, verbose_name='单选分数')),
                ('duoxuan_count', models.IntegerField(default=0, verbose_name='多选数量')),
                ('duoxuan_score', models.FloatField(default=4, verbose_name='多选分数')),
                ('panduan_count', models.IntegerField(default=0, verbose_name='判断数量')),
                ('panduan_score', models.FloatField(default=2, verbose_name='判断分数')),
                ('create_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='paper_create_by', to=settings.AUTH_USER_MODEL, verbose_name='创建人')),
            ],
            options={
                'verbose_name': '押题卷',
                'verbose_name_plural': '押题卷',
            },
        ),
        migrations.CreateModel(
            name='PaperQuestion',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('create_time', models.DateTimeField(default=django.utils.timezone.now, help_text='创建时间', verbose_name='创建时间')),
                ('update_time', models.DateTimeField(auto_now=True, help_text='修改时间', verbose_name='修改时间')),
                ('is_deleted', models.BooleanField(default=False, help_text='删除标记', verbose_name='删除标记')),
                ('total_score', models.FloatField(default=0, verbose_name='单题满分')),
                ('sort', models.PositiveSmallIntegerField(default=1)),
                ('paper', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='exam.Paper', verbose_name='试卷')),
                ('question', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='exam.Question', verbose_name='试题')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.AddField(
            model_name='paper',
            name='questions',
            field=models.ManyToManyField(through='exam.PaperQuestion', to='exam.Question'),
        ),
        migrations.AddField(
            model_name='paper',
            name='update_by',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='paper_update_by', to=settings.AUTH_USER_MODEL, verbose_name='最后编辑人'),
        ),
        migrations.CreateModel(
            name='ExamRecord',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('create_time', models.DateTimeField(default=django.utils.timezone.now, help_text='创建时间', verbose_name='创建时间')),
                ('update_time', models.DateTimeField(auto_now=True, help_text='修改时间', verbose_name='修改时间')),
                ('is_deleted', models.BooleanField(default=False, help_text='删除标记', verbose_name='删除标记')),
                ('name', models.CharField(max_length=200, verbose_name='名称')),
                ('type', models.CharField(choices=[('自助模考', '自助模考'), ('押卷模考', '押卷模考'), ('正式考试', '正式考试')], default='自助模考', max_length=50, verbose_name='考试类型')),
                ('limit', models.IntegerField(default=0, verbose_name='限时(分钟)')),
                ('total_score', models.FloatField(default=0, verbose_name='总分')),
                ('score', models.FloatField(default=0, verbose_name='得分')),
                ('took', models.IntegerField(default=0, verbose_name='耗时(秒)')),
                ('start_time', models.DateTimeField(verbose_name='开始答题时间')),
                ('end_time', models.DateTimeField(verbose_name='结束答题时间')),
                ('is_pass', models.BooleanField(default=True, verbose_name='是否通过')),
                ('questions', django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=list, verbose_name='下发的题目列表')),
                ('create_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='examrecord_create_by', to=settings.AUTH_USER_MODEL, verbose_name='创建人')),
                ('detail', models.ManyToManyField(through='exam.AnswerDetail', to='exam.Question', verbose_name='答题记录')),
                ('exam', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='exam.Exam', verbose_name='关联的正式考试')),
                ('paper', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='exam.Paper', verbose_name='所用试卷')),
                ('update_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='examrecord_update_by', to=settings.AUTH_USER_MODEL, verbose_name='最后编辑人')),
            ],
            options={
                'verbose_name': '考试记录',
                'verbose_name_plural': '考试记录',
            },
        ),
        migrations.AddField(
            model_name='exam',
            name='paper',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='exam.Paper', verbose_name='使用的试卷'),
        ),
        migrations.AddField(
            model_name='exam',
            name='update_by',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='exam_update_by', to=settings.AUTH_USER_MODEL, verbose_name='最后编辑人'),
        ),
        migrations.AddField(
            model_name='answerdetail',
            name='examrecord',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='exam.ExamRecord'),
        ),
        migrations.AddField(
            model_name='answerdetail',
            name='question',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='exam.Question'),
        ),
    ]
