Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@ env/

[0-9]*.txt

media/testfile
media/topic
media/resource

*png
*jpg
*jpeg
*webp
tempCodeRunnerFile.py

*.sqlite3
*.exe
*.exe

22 changes: 22 additions & 0 deletions api/migrations/0022_topicaccountaccess.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 4.1.2 on 2023-05-15 07:35

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('api', '0021_collectionproblem_order_topiccollection_order_and_more'),
]

operations = [
migrations.CreateModel(
name='TopicAccountAccess',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('account', models.ForeignKey(db_column='account_id', on_delete=django.db.models.deletion.CASCADE, to='api.account')),
('topic', models.ForeignKey(db_column='topic_id', on_delete=django.db.models.deletion.CASCADE, to='api.topic')),
],
),
]
48 changes: 48 additions & 0 deletions api/migrations/0023_rename_account_id_problem_account_and_more.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Generated by Django 4.1.2 on 2023-06-17 07:25

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('api', '0022_topicaccountaccess'),
]

operations = [
migrations.RenameField(
model_name='problem',
old_name='account_id',
new_name='account',
),
migrations.RenameField(
model_name='submission',
old_name='account_id',
new_name='account',
),
migrations.RenameField(
model_name='submission',
old_name='problem_id',
new_name='problem',
),
migrations.RenameField(
model_name='testcase',
old_name='problem_id',
new_name='problem',
),
migrations.RenameField(
model_name='topic',
old_name='account_id',
new_name='account',
),
migrations.RenameField(
model_name='topicproblem',
old_name='problem_id',
new_name='problem',
),
migrations.RenameField(
model_name='topicproblem',
old_name='topic_id',
new_name='topic',
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by Django 4.1.2 on 2023-06-18 18:11

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api', '0023_rename_account_id_problem_account_and_more'),
]

operations = [
migrations.AddField(
model_name='submission',
name='max_score',
field=models.IntegerField(default=0),
),
migrations.AddField(
model_name='submission',
name='passed_ratio',
field=models.FloatField(default=0),
),
migrations.AddField(
model_name='submission',
name='score',
field=models.IntegerField(default=0),
),
migrations.RemoveField(
model_name='submission',
name='result'
),

]
14 changes: 14 additions & 0 deletions api/migrations/0025_merge_20231110_1723.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 4.1.2 on 2023-11-10 10:23

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('api', '0022_problem_submission_regex'),
('api', '0024_submission_max_score_submission_passed_ratio_and_more'),
]

operations = [
]
25 changes: 25 additions & 0 deletions api/migrations/0026_submissiontestcase.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 4.1.2 on 2023-11-10 10:51

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('api', '0025_merge_20231110_1723'),
]

operations = [
migrations.CreateModel(
name='SubmissionTestcase',
fields=[
('submission_testcase_id', models.AutoField(primary_key=True, serialize=False)),
('output', models.CharField(max_length=100000)),
('is_passed', models.BooleanField(blank=True, default=False)),
('runtime_status', models.CharField(max_length=10)),
('submission', models.ForeignKey(db_column='submission_id', on_delete=django.db.models.deletion.CASCADE, to='api.submission')),
('testcase', models.ForeignKey(db_column='testcase_id', on_delete=django.db.models.deletion.CASCADE, to='api.testcase')),
],
),
]
18 changes: 18 additions & 0 deletions api/migrations/0027_alter_submissiontestcase_output.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.1.2 on 2023-11-10 12:17

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api', '0026_submissiontestcase'),
]

operations = [
migrations.AlterField(
model_name='submissiontestcase',
name='output',
field=models.CharField(blank=True, max_length=100000, null=True),
),
]
18 changes: 18 additions & 0 deletions api/migrations/0028_alter_problem_language.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.1.2 on 2023-11-10 12:20

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api', '0027_alter_submissiontestcase_output'),
]

operations = [
migrations.AlterField(
model_name='problem',
name='language',
field=models.CharField(max_length=15),
),
]
32 changes: 23 additions & 9 deletions api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class Account(models.Model):

class Problem(models.Model):
problem_id = models.AutoField(primary_key=True)
account_id = models.ForeignKey(Account,on_delete=models.CASCADE,db_column="account_id")
language = models.CharField(max_length=10,choices=ProgrammingLanguage.choices,default=ProgrammingLanguage.PYTHON)
account = models.ForeignKey(Account,on_delete=models.CASCADE,db_column="account_id")
language = models.CharField(max_length=15) # ,choices=ProgrammingLanguage.choices,default=ProgrammingLanguage.PYTHON)
title = models.CharField(max_length=50)
description = models.CharField(max_length=10000)
solution = models.CharField(max_length=20000)
Expand All @@ -39,18 +39,20 @@ class Problem(models.Model):

class Testcase(models.Model):
testcase_id = models.AutoField(primary_key=True)
problem_id = models.ForeignKey(Problem,on_delete=models.CASCADE,db_column="problem_id")
problem = models.ForeignKey(Problem,on_delete=models.CASCADE,db_column="problem_id")
input = models.CharField(max_length=100000)
output = models.CharField(max_length=100000)

class Submission(models.Model):
submission_id = models.AutoField(primary_key=True)
problem_id = models.ForeignKey(Problem,on_delete=models.CASCADE,db_column="problem_id")
account_id = models.ForeignKey(Account,on_delete=models.CASCADE,db_column="account_id")
problem = models.ForeignKey(Problem,on_delete=models.CASCADE,db_column="problem_id")
account = models.ForeignKey(Account,on_delete=models.CASCADE,db_column="account_id")
submission_code = models.CharField(max_length=20000)
result = models.CharField(max_length=100)
is_passed = models.BooleanField()
date = models.DateTimeField(default=timezone.now)
score = models.IntegerField(default=0)
max_score = models.IntegerField(default=0)
passed_ratio = models.FloatField(default=0)

class Collection(models.Model):
collection_id = models.AutoField(primary_key=True)
Expand All @@ -62,7 +64,7 @@ class Collection(models.Model):

class Topic(models.Model):
topic_id = models.AutoField(primary_key=True)
account_id = models.ForeignKey(Account,on_delete=models.CASCADE,db_column="account_id")
account = models.ForeignKey(Account,on_delete=models.CASCADE,db_column="account_id")
name = models.CharField(max_length=100)
description = models.CharField(max_length=1000,null=True,blank=True,default=None)
image_url = models.ImageField(upload_to='topic/',null=True,blank=True,default=None)
Expand All @@ -81,5 +83,17 @@ class CollectionProblem(models.Model):

# Doesn't use anymore
class TopicProblem(models.Model):
topic_id = models.ForeignKey(Topic,on_delete=models.CASCADE,db_column="topic_id")
problem_id = models.ForeignKey(Problem,on_delete=models.CASCADE,db_column="problem_id")
topic = models.ForeignKey(Topic,on_delete=models.CASCADE,db_column="topic_id")
problem = models.ForeignKey(Problem,on_delete=models.CASCADE,db_column="problem_id")

class TopicAccountAccess(models.Model):
topic = models.ForeignKey(Topic,on_delete=models.CASCADE,db_column="topic_id")
account = models.ForeignKey(Account,on_delete=models.CASCADE,db_column="account_id")

class SubmissionTestcase(models.Model):
submission_testcase_id = models.AutoField(primary_key=True)
submission = models.ForeignKey(Submission,on_delete=models.CASCADE,db_column="submission_id")
testcase = models.ForeignKey(Testcase,on_delete=models.CASCADE,db_column="testcase_id")
output = models.CharField(max_length=100000,blank=True,null=True)
is_passed = models.BooleanField(default=False,blank=True)
runtime_status = models.CharField(max_length=10)
Loading