# coding=utf-8

from django.db import models
from django.utils import timezone
from django.conf import settings

from apps.examination.exam.models import ExamAnswerLog
from apps.examination.examquestion.models import ExamQuestion

class ErrorBook(models.Model):
    question = models.ForeignKey(ExamQuestion, verbose_name=u"试题", on_delete=models.PROTECT)
    create_user = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name=u'答题人', editable=False, on_delete=models.PROTECT)
    last_answer_log = models.ForeignKey(ExamAnswerLog, verbose_name=u"最后答题记录", on_delete=models.PROTECT)
    last_time = models.DateTimeField(verbose_name=u"最后出错时间", default=timezone.now)
    wrong_count = models.IntegerField(verbose_name=u'出错次数', default=0, editable=False)

    class Meta:
        db_table = "practise_error_book"
        ordering = ['-id']
        verbose_name = u"错题集"
        default_permissions = ()