|  | 
|  | 1 | +from django.db import models | 
|  | 2 | +from django.contrib.auth.models import User | 
|  | 3 | + | 
|  | 4 | +'''From signup api endpoint we are expecting json response be like | 
|  | 5 | + {'user':'Gagansingh','password':#########,'choice':'Student/Professor'} | 
|  | 6 | + depending on choice we will create their student or prof model''' | 
|  | 7 | + | 
|  | 8 | + | 
|  | 9 | +class Student(models.Model): | 
|  | 10 | +	user=models.OneToOneField(User,on_delete=models.CASCADE) | 
|  | 11 | +	name=models.CharField(max_length=100,blank=True) | 
|  | 12 | +	ProfilePic=models.ImageField(upload_to='StudentProfilePic',blank=True) | 
|  | 13 | +	College_Name=models.CharField(max_length=200,blank=True) | 
|  | 14 | +	Course=models.CharField(max_length=50,blank=True) | 
|  | 15 | + | 
|  | 16 | +class Professor(models.Model): | 
|  | 17 | +	user=models.OneToOneField(User,on_delete=models.CASCADE) | 
|  | 18 | +	name=models.CharField(max_length=100,blank=True) | 
|  | 19 | +	ProfilePic=models.ImageField(upload_to='ProfessorProfilePic',blank=True) | 
|  | 20 | +	College_Name=models.CharField(max_length=200,blank=True) | 
|  | 21 | + | 
|  | 22 | +'''I'm assuming a professor can create multiple classrooms and each classroom can have  | 
|  | 23 | +multiple classroom. if a classroom is deleted, all of the assignments of that class will | 
|  | 24 | +delete automatically''' | 
|  | 25 | + | 
|  | 26 | +class ClassRoom(models.Model): | 
|  | 27 | + professor=models.ForeignKey(Professor,on_delete=models.CASCADE) | 
|  | 28 | + title=models.CharField(max_length=200,blank=False) | 
|  | 29 | + Picture=models.ImageField(upload_to='ClassMedia',blank=False) | 
|  | 30 | + student=models.ManyToManyField(Student,blank=True) | 
|  | 31 | + #because a student can join multiple classroom and each classroom can have multiple  | 
|  | 32 | + #students.For more info, refer to official docs | 
|  | 33 | + | 
|  | 34 | + | 
|  | 35 | +class Assignments(models.Model): | 
|  | 36 | + classroom=models.ForeignKey(ClassRoom,on_delete=models.CASCADE) | 
|  | 37 | + title=models.CharField(max_length=200,blank=False) | 
|  | 38 | + | 
|  | 39 | +class Questions(models.Model): | 
|  | 40 | +	assignment=models.ForeignKey(codeclassroom,on_delete=models.CASCADE) | 
|  | 41 | +	content=models.CharField(max_length=2000,blank=False) | 
|  | 42 | + | 
|  | 43 | +'''NOW i will be making a reponse model ,i.e., response of a student for a assignment | 
|  | 44 | + | 
|  | 45 | +''' | 
|  | 46 | +class Respopnse(models.Model): | 
|  | 47 | +	question=models.ForeignKey(Questions,on_delete=models.CASCADE) | 
|  | 48 | +	student=models.ForeignKey(Student,on_delete=models.CASCADE) | 
|  | 49 | +	answer=models.CharField(max_length=40000,blank=False) | 
|  | 50 | +	remark=models.CharField(max_length=500,blank=True)#this field may be filled by prof  | 
|  | 51 | +	#as remark | 
|  | 52 | + | 
|  | 53 | +### this project is built by "codeclassroom" organisation and all rights are thereby | 
|  | 54 | +#reserved.Please ask before copying this code or project | 
|  | 55 | +# happy coding!!! | 
|  | 56 | + | 
0 commit comments