# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2019-08-07 02:56
from __future__ import unicode_literals

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


class Migration(migrations.Migration):

    initial = True

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

    operations = [
        migrations.CreateModel(
            name='Option',
            fields=[
                ('id', models.CharField(default=uuid.uuid4, editable=False, max_length=40, primary_key=True, serialize=False)),
                ('body', models.TextField(max_length=1000)),
                ('order', models.CharField(blank=True, max_length=5, null=True)),
                ('is_correct', models.BooleanField(default=False)),
                ('img', models.ImageField(blank=True, null=True, upload_to='option_imgs')),
                ('error_reason', models.ManyToManyField(blank=True, to='knowledge_space.ErrorReason')),
                ('knowledge_node', models.ManyToManyField(to='knowledge_space.KnowledgeNode')),
            ],
        ),
        migrations.CreateModel(
            name='OptionStat',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('times_checked', models.IntegerField(default=0)),
                ('info', models.TextField(blank=True, max_length=1000, null=True)),
                ('option', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='stat', to='quiz.Option')),
            ],
        ),
        migrations.CreateModel(
            name='Question',
            fields=[
                ('id', models.CharField(default=uuid.uuid4, editable=False, max_length=40, primary_key=True, serialize=False)),
                ('body', models.TextField(max_length=3000)),
                ('subject', models.CharField(db_index=True, max_length=20)),
                ('question_type', models.CharField(default='multi-choice', max_length=20)),
                ('img', models.ImageField(blank=True, null=True, upload_to='question_imgs')),
                ('datetime', models.DateTimeField(auto_now_add=True, null=True)),
                ('analysis', models.TextField(blank=True, max_length=2000, null=True)),
                ('knowledge_node', models.ManyToManyField(to='knowledge_space.KnowledgeNode')),
                ('uploader', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='QuestionRecord',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('datetime', models.DateTimeField(auto_now_add=True)),
                ('option', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='question_records', to='quiz.Option')),
                ('question', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='question_records', to='quiz.Question')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='question_records', to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='QuestionStat',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('correct_rate', models.FloatField(default=0)),
                ('times_answered', models.IntegerField(default=0)),
                ('times_correct', models.IntegerField(default=0)),
                ('info', models.TextField(blank=True, max_length=1000, null=True)),
                ('question', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='stat', to='quiz.Question')),
            ],
        ),
        migrations.CreateModel(
            name='Quiz',
            fields=[
                ('id', models.CharField(default=uuid.uuid4, editable=False, max_length=40, primary_key=True, serialize=False)),
                ('subject', models.CharField(db_index=True, max_length=20)),
                ('info', models.TextField(default='{}', max_length=500)),
                ('body', models.TextField(max_length=2000)),
                ('public', models.BooleanField(default=False)),
                ('marking', models.BooleanField(default=False)),
                ('generator', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='QuizPaper',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('pdf_uri', models.CharField(max_length=150)),
                ('html_uri', models.CharField(max_length=150)),
                ('quiz', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='quiz.Quiz')),
            ],
        ),
        migrations.CreateModel(
            name='QuizRecord',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('cls', models.CharField(default='', max_length=20)),
                ('datetime', models.DateTimeField(blank=True, null=True)),
                ('info', models.TextField(blank=True, max_length=1000, null=True)),
                ('quiz', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='quiz.Quiz')),
                ('teacher', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='QuizStat',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('times_taken', models.IntegerField(default=0)),
                ('average_score', models.FloatField(default=0)),
                ('scores_uri', models.TextField(blank=True, max_length=100, null=True)),
                ('stats', models.TextField(default='', max_length=2000)),
                ('quiz_record', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='quiz.QuizRecord')),
            ],
        ),
        migrations.AddField(
            model_name='quiz',
            name='stat',
            field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='quiz.QuizStat'),
        ),
        migrations.AddField(
            model_name='option',
            name='question',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='options', to='quiz.Question'),
        ),
    ]
