Advertisement
MarkUa

Untitled

Jul 1st, 2019
512
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.06 KB | None | 0 0
  1. from django.db import models
  2.  
  3. class User(models.Model):
  4.         name = models.CharField(max_length=64,  default="no name yet", unique=True)
  5.         password = models.CharField(max_length=64,  default="no password yet")
  6.         user_email =   models.CharField(max_length=64,  null=True, blank=True ,unique=True)
  7.         user_status =  models.CharField(max_length=15,  null=True, blank=True)
  8.         passed_quizes = models.ManyToManyField('PassedQuiz', blank=True, related_name='passed_quizes')
  9.         course_subscriptions = models.ManyToManyField('Course', blank=True, related_name='course_subscriptions')
  10.  
  11.  
  12.  
  13.  
  14. class SearchTags(models.Model):
  15.         name = models.CharField(max_length=64, default="no name yet", unique=True)
  16.  
  17.  
  18.  
  19. class Course(models.Model):
  20.         name = models.CharField(max_length=64, unique=True)
  21.         search_tags = models.ManyToManyField('SearchTags', blank=True, related_name='search_tags')
  22.         description = models.CharField(max_length=500,  null=True, blank=True)
  23.         course_creator = models.ForeignKey(User, on_delete=models.CASCADE)
  24.         created_on = models.DateTimeField(auto_now_add=True)
  25.         updated_on = models.DateTimeField(auto_now=True)
  26.  
  27.  
  28.  
  29. class Lesson(models.Model):
  30.         name = models.CharField(max_length=64)
  31.         description = models.CharField(max_length=500, null=True, blank=True)
  32.         course = models.ForeignKey(Course, on_delete=models.CASCADE)
  33.         created_on = models.DateTimeField(auto_now_add=True)
  34.         updated_on = models.DateTimeField(auto_now=True)
  35.  
  36.         class Meta:
  37.                 unique_together = ("name", "course")
  38.  
  39. class Document(models.Model):
  40.     docfile = models.FileField(upload_to='documents/%Y/%m/%d')
  41.     belong_to_lesson = models.ForeignKey(Lesson, on_delete=models.CASCADE,null=True, blank=True)
  42.     created_on = models.DateTimeField(auto_now_add=True)
  43.     updated_on = models.DateTimeField(auto_now=True)
  44.  
  45. class Chat(models.Model):
  46.         course = models.OneToOneField(Course, on_delete=models.CASCADE)
  47.  
  48. class Messages(models.Model):
  49.         text = models.CharField(max_length=500)
  50.         author =  models.CharField(max_length=50)
  51.         belong_to_chat = models.ForeignKey(Chat, on_delete=models.CASCADE)
  52.         created_on = models.DateTimeField(auto_now_add=True)
  53.  
  54.  
  55.  
  56. class TestQuiz(models.Model):
  57.         title = models.CharField(max_length=64,  default="no title yet")
  58.         quiz_in_json = models.CharField(max_length=1024,  default="no title yet")
  59.         belong_to_lesson = models.ForeignKey(Lesson, on_delete=models.CASCADE,default=None)
  60.       #  questions = models.ManyToManyField('Question', blank=True, related_name='posts')
  61.  
  62.  
  63. class TestQuestion(models.Model):
  64.         title = models.CharField(max_length=64,  default="no title yet")
  65.         belong_to_quiz = models.ForeignKey(TestQuiz, on_delete=models.CASCADE)
  66.      #   variant_result_pair = models.ManyToManyField('VariantResult', blank=True, related_name='posts')
  67.  
  68.  
  69. class TestQuestionVariantResult(models.Model):
  70.         suggested_choice = models.CharField(max_length=64,  default="no title yet")
  71.         correct_choice = models.CharField(max_length=64, default="no title yet")
  72.         belong_to_question =  models.ForeignKey(TestQuestion, on_delete=models.CASCADE)
  73.  
  74.  
  75. class PassedTestQuiz(models.Model):
  76.         test_quiz = models.ForeignKey(TestQuiz, on_delete=models.CASCADE)
  77.         test_quiz_user = models.ForeignKey(User, on_delete=models.CASCADE,default=None)
  78.         test_quiz_pass_attempt = models.IntegerField(default=0)
  79.         class Meta:
  80.                 unique_together = ("test_quiz", "test_quiz_user","test_quiz_pass_attempt")
  81.        # quiz_passed_username = models.CharField(max_length=64,default=None)
  82.  
  83.  
  84.  
  85. class QuestionAnswerResult(models.Model):
  86.         question =  models.CharField(max_length=64,  default="no question yet")
  87.         answer = models.CharField(max_length=64,  default="no question yet")
  88.        # correctanswer = models.CharField(max_length=64,  default="no question yet")
  89.         belong_to_quiz = models.ForeignKey(PassedTestQuiz, on_delete=models.CASCADE,default=None)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement