2016-01-31 16:17:37 +01:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2016-02-09 19:51:05 +01:00
|
|
|
import uuid
|
|
|
|
|
2016-01-31 16:17:37 +01:00
|
|
|
from django.db import models
|
2016-02-09 19:51:05 +01:00
|
|
|
from django.db.models.signals import post_init, pre_init
|
2016-01-31 16:17:37 +01:00
|
|
|
|
2016-01-31 18:19:45 +01:00
|
|
|
|
|
|
|
class Setting(models.Model):
|
|
|
|
title = models.CharField(max_length=100, null=True)
|
|
|
|
message = models.TextField(null=True)
|
|
|
|
footer = models.TextField(null=True)
|
2016-01-31 21:18:13 +01:00
|
|
|
button_solution = models.CharField(max_length=100, null=True)
|
2016-01-31 18:19:45 +01:00
|
|
|
active = models.BooleanField(unique=True, default=False)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.title
|
|
|
|
|
|
|
|
|
|
|
|
class Question(models.Model):
|
|
|
|
id = models.AutoField(primary_key=True)
|
|
|
|
title = models.CharField(max_length=100, null=True)
|
|
|
|
text = models.TextField(null=True)
|
|
|
|
explanation = models.TextField(null=True)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.title
|
|
|
|
|
|
|
|
|
|
|
|
class Option(models.Model):
|
|
|
|
text = models.CharField(max_length=100, null=True)
|
|
|
|
correct = models.BooleanField(null=False, default=False)
|
|
|
|
question = models.ForeignKey(Question, on_delete=models.CASCADE, null=False)
|
|
|
|
|
|
|
|
def __str__(self):
|
2016-02-09 19:51:05 +01:00
|
|
|
return self.text
|
|
|
|
|
|
|
|
|
|
|
|
class User(models.Model):
|
|
|
|
token = models.CharField(max_length=32, null=True)
|
|
|
|
name = models.CharField(max_length=100, null=False)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
|
|
|
|
class UserAnswer(models.Model):
|
|
|
|
user = models.ForeignKey(User, on_delete=models.CASCADE, null=False)
|
|
|
|
questionId = models.ForeignKey(Question, on_delete=models.CASCADE, null=False)
|
2016-02-09 20:46:04 +01:00
|
|
|
answers = models.CharField(max_length=100, null=True)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return str(self.user) + " - " + str(self.questionId)
|
2016-02-09 19:51:05 +01:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
unique_together = (('user', 'questionId'),)
|