-
Notifications
You must be signed in to change notification settings - Fork 6
/
models.py
executable file
·63 lines (50 loc) · 2.73 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from django.db import models
from django.contrib.auth.models import User
NO_OF_QUESTIONS = 6
class UserProfile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
totalScore = models.IntegerField(default=0)
email1 = models.EmailField(default='[email protected]')
email2 = models.EmailField(default='[email protected]')
phone1 = models.CharField(max_length=10)
phone2 = models.CharField(max_length=10)
name1 = models.CharField(max_length=100)
name2 = models.CharField(max_length=100, null=True)
junior = models.BooleanField(default=True) # True if Junior(FE) else False if Senior(SE,TE,BE)
latestSubTime = models.TimeField(default='00:00')
timer = models.TimeField(default='00:00')
choice = models.CharField(max_length=5, default='cpp') # for the extension the code C or CPP or python
qid = models.IntegerField(default=0) # will store the current question id
flag = models.BooleanField(default=False) # Flag for instruction Page
lang = models.CharField(max_length=3,default='cpp') # will store the current question lang
def __str__(self):
return self.user.username
class Question(models.Model):
titleQue = models.CharField(max_length=50)
question = models.CharField(max_length=5000)
totalSub = models.IntegerField(default=0)
totalSuccessfulSub = models.IntegerField(default=0)
accuracy = models.IntegerField(default=0) # accuracy = total Successful submission / total Submission
def __str__(self):
return self.titleQue + '-' + self.question
def IDNumber(self):
return self.pk
class MultipleQues(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
que = models.ForeignKey(Question, on_delete=models.CASCADE)
scoreQuestion = models.IntegerField(default=0)
attempts = models.IntegerField(default=0)
class Submission(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
que = models.ForeignKey(Question, on_delete=models.CASCADE)
code = models.CharField(max_length=1000)
attempt = models.IntegerField(default=0) # Current Attempt
out = models.IntegerField(default=0)
subStatus = models.CharField(default='NA', max_length=5) # four type of submission status(WA, PASS, TLE, CTE)
subTime = models.CharField(default='', max_length=50)
subScore = models.IntegerField(default=0)
correctTestCases = models.IntegerField(default=0)
TestCasesPercentage = models.IntegerField(default=0)
# (TestCasesPercentage = correctTestCases / NO_OF_QUESTIONS) * 100
def __str__(self):
return self.user.username + ' - ' + self.que.titleQue