diff --git a/README.md b/README.md index 27e0eb7..9276597 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# [PDP: Programming and Discussion Portal](https://github.com/vbsinha/pdp-judge) +# [autojudge: An Online Judge for Coding contests](https://github.com/vbsinha/pdp-judge) [![CircleCI](https://circleci.com/gh/vbsinha/pdp-judge.svg?style=svg&circle-token=779cf1772a65883845be7ded61285e17a63141de)](https://circleci.com/gh/vbsinha/pdp-judge) diff --git a/pdpjudge/__init__.py b/autojudge/__init__.py similarity index 100% rename from pdpjudge/__init__.py rename to autojudge/__init__.py diff --git a/pdpjudge/settings.py b/autojudge/settings.py similarity index 97% rename from pdpjudge/settings.py rename to autojudge/settings.py index 219167a..2aeaf45 100644 --- a/pdpjudge/settings.py +++ b/autojudge/settings.py @@ -1,5 +1,5 @@ """ -Django settings for pdpjudge project. +Django settings for autojudge project. Generated by 'django-admin startproject' using Django 2.2. @@ -57,7 +57,7 @@ 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] -ROOT_URLCONF = 'pdpjudge.urls' +ROOT_URLCONF = 'autojudge.urls' TEMPLATES = [ { @@ -77,7 +77,7 @@ }, ] -WSGI_APPLICATION = 'pdpjudge.wsgi.application' +WSGI_APPLICATION = 'autojudge.wsgi.application' # Database diff --git a/pdpjudge/urls.py b/autojudge/urls.py similarity index 96% rename from pdpjudge/urls.py rename to autojudge/urls.py index 7dbca96..84cb4a2 100644 --- a/pdpjudge/urls.py +++ b/autojudge/urls.py @@ -1,4 +1,4 @@ -"""pdpjudge URL Configuration +"""autojudge URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/2.2/topics/http/urls/ diff --git a/pdpjudge/wsgi.py b/autojudge/wsgi.py similarity index 73% rename from pdpjudge/wsgi.py rename to autojudge/wsgi.py index b795b8e..b25d1ae 100644 --- a/pdpjudge/wsgi.py +++ b/autojudge/wsgi.py @@ -1,5 +1,5 @@ """ -WSGI config for pdpjudge project. +WSGI config for autojudge project. It exposes the WSGI callable as a module-level variable named ``application``. @@ -11,6 +11,6 @@ from django.core.wsgi import get_wsgi_application -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'pdpjudge.settings') +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'autojudge.settings') application = get_wsgi_application() diff --git a/docs/source/conf.py b/docs/source/conf.py index d9ea1eb..951cc69 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -8,7 +8,7 @@ sys.path.insert(0, os.path.abspath('../..')) -os.environ["DJANGO_SETTINGS_MODULE"] = "pdpjudge.settings" +os.environ["DJANGO_SETTINGS_MODULE"] = "autojudge.settings" django.setup() # -- Project information ----------------------------------------------------- diff --git a/judge/admin.py b/judge/admin.py index bcefe22..f97f214 100644 --- a/judge/admin.py +++ b/judge/admin.py @@ -1,9 +1,8 @@ from django.contrib import admin # Register your models here. -from .models import Contest, Problem, Person -from .models import Submission, ContestPerson, TestCase, SubmissionTestCase, Comment -from .models import PersonProblemFinalScore +from .models import Contest, Problem, Person, Submission, TestCase, Comment +from .models import ContestPerson, SubmissionTestCase, PersonProblemFinalScore class ContestAdmin(admin.ModelAdmin): @@ -14,8 +13,8 @@ class ContestAdmin(admin.ModelAdmin): admin.site.register(Problem) admin.site.register(Person) admin.site.register(Submission) -admin.site.register(ContestPerson) admin.site.register(TestCase) -admin.site.register(SubmissionTestCase) admin.site.register(Comment) +admin.site.register(ContestPerson) +admin.site.register(SubmissionTestCase) admin.site.register(PersonProblemFinalScore) diff --git a/judge/handler.py b/judge/handler.py index 4985ba2..e2471b0 100644 --- a/judge/handler.py +++ b/judge/handler.py @@ -340,9 +340,9 @@ def update_poster_score(submission_id: str, new_score: int): """ try: submission = models.Submission.objects.get(pk=submission_id) - submission.final_score -= submission.ta_score - submission.ta_score = new_score - submission.final_score += submission.ta_score + submission.final_score -= submission.poster_score + submission.poster_score = new_score + submission.final_score += submission.poster_score submission.save() highest_scoring_submission = models.Submission.objects.filter( @@ -627,7 +627,8 @@ def get_submission_status(person: str, problem: str, submission): Second dictionary: Key: Submission ID - Value: :code:`(judge_score, ta_score, linter_score, final_score, timestamp, file_type)` + Value: :code:`(judge_score, poster_score, linter_score, + final_score, timestamp, file_type)` In case :attr:`submission` is not ``None``, the passed parameters :attr:`person` and :attr:`problem` are ignored and so ``None`` is accepted. @@ -654,7 +655,7 @@ def get_submission_status(person: str, problem: str, submission): score_dict = dict() for submission in sub_list: - score_dict[submission.pk] = (submission.judge_score, submission.ta_score, + score_dict[submission.pk] = (submission.judge_score, submission.poster_score, submission.linter_score, submission.final_score, submission.timestamp, submission.file_type) verdict_dict[submission.pk] = [] @@ -729,7 +730,7 @@ def get_submission_status_mini(submission: str) -> Tuple[bool, Any]: Value: :code:`(Verdict, Time_taken, Memory_taken, ispublic, message)` Tuple: - :code:`(judge_score, ta_score, linter_score, final_score, timestamp, file_type)` + :code:`(judge_score, poster_score, linter_score, final_score, timestamp, file_type)` """ try: s = models.Submission.objects.get(pk=submission) @@ -742,7 +743,7 @@ def get_submission_status_mini(submission: str) -> Tuple[bool, Any]: submission=s, testcase=testcase) verdict_dict[testcase.pk] = (st.get_verdict_display, st.time_taken, st.memory_taken, testcase.public, st.message) - score_tuple = (s.judge_score, s.ta_score, s.linter_score, s.final_score, + score_tuple = (s.judge_score, s.poster_score, s.linter_score, s.final_score, s.timestamp, s.file_type) return (True, (verdict_dict, score_tuple)) except Exception as e: diff --git a/judge/migrations/0001_initial.py b/judge/migrations/0001_initial.py index b944773..e47cd15 100644 --- a/judge/migrations/0001_initial.py +++ b/judge/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 2.2 on 2019-05-01 06:08 +# Generated by Django 2.2 on 2019-05-21 14:44 import datetime from django.db import migrations, models @@ -66,7 +66,7 @@ class Migration(migrations.Migration): ('submission_file', models.FileField(upload_to=judge.models.submission_upload_location)), ('timestamp', models.DateTimeField()), ('judge_score', models.PositiveSmallIntegerField(default=0)), - ('ta_score', models.PositiveSmallIntegerField(default=0)), + ('poster_score', models.SmallIntegerField(default=0)), ('linter_score', models.FloatField(default=0.0)), ('final_score', models.FloatField(default=0.0)), ('participant', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='judge.Person')), diff --git a/judge/models.py b/judge/models.py index d03f695..0fb6683 100644 --- a/judge/models.py +++ b/judge/models.py @@ -185,8 +185,8 @@ class Submission(models.Model): judge_score = models.PositiveSmallIntegerField(default=0) """Judge score""" - ta_score = models.SmallIntegerField(default=0) - """TA score""" + poster_score = models.SmallIntegerField(default=0) + """Poster score""" linter_score = models.FloatField(default=0.0) """Linter score""" diff --git a/judge/templates/judge/contest_persons.html b/judge/templates/judge/contest_persons.html index fdc69ac..91f7550 100644 --- a/judge/templates/judge/contest_persons.html +++ b/judge/templates/judge/contest_persons.html @@ -9,9 +9,9 @@ {% block scripts %} {% endblock %} @@ -29,13 +29,13 @@

{{ type }}s

{% endif %}
-
{% csrf_token %}{{ form }}
+
{% csrf_token %}{{ form }}
{% for person in persons %}
{{ person }} {% if permission %} - + {% endif %}
{% empty %} diff --git a/judge/templates/judge/submission_detail.html b/judge/templates/judge/submission_detail.html index 6b8f485..224eb0b 100644 --- a/judge/templates/judge/submission_detail.html +++ b/judge/templates/judge/submission_detail.html @@ -90,7 +90,7 @@ {% if problem.contest.enable_poster_score %} Poster Score - {{ ta_score }} + {{ poster_score }} {% endif %} {% if problem.contest.enable_linter_score %} diff --git a/judge/urls.py b/judge/urls.py index 9fae9b4..038db27 100644 --- a/judge/urls.py +++ b/judge/urls.py @@ -3,22 +3,36 @@ from django.contrib.auth.views import LoginView, LogoutView from . import views +from . import apps -app_name = 'judge' +app_name = apps.JudgeConfig.name handler404 = views.handler404 handler500 = views.handler500 urlpatterns = [ + # General-purpose paths path('', views.index, name='index'), path('login/', LoginView.as_view(), name='login'), path('logout/', LogoutView.as_view(), name='logout'), path('auth/', include('social_django.urls', namespace='social')), + + # Contest-specific paths path('contest/new/', views.new_contest, name='new_contest'), path('contest//', views.contest_detail, name='contest_detail'), path('contest//scores/', views.contest_scores_csv, name='contest_scores_csv'), path('contest//delete/', views.delete_contest, name='delete_contest'), path('contest//problem/new/', views.new_problem, name='new_problem'), + path('contest//poster/new/', + views.add_poster, name='contest_add_poster'), + path('contest//participant/new/', + views.add_participant, name='contest_add_participant'), + path('contest//posters/', + views.get_posters, name='get_posters'), + path('contest//participants/', + views.get_participants, name='get_participants'), + + # Problem-specific paths path('problem//', views.problem_detail, name='problem_detail'), path('problem//delete/', views.delete_problem, name='delete_problem'), path('problem//starting-code/', @@ -29,18 +43,12 @@ views.problem_test_script, name='problem_test_script'), path('problem/default-scripts//', views.problem_default_script, name='problem_default_script'), - path('contest//poster/new/', - views.add_poster, name='contest_add_poster'), - path('contest//participant/new/', - views.add_participant, name='contest_add_participant'), - path('contest//posters/', - views.get_posters, name='get_posters'), - path('contest//participants/', - views.get_participants, name='get_participants'), path('problem//edit/', views.edit_problem, name='edit_problem'), path('problem//submissions/', views.problem_submissions, name='problem_submissions'), + + # Submission-specific paths path('submission//', views.submission_detail, name='submission_detail'), path('submission//download/', diff --git a/judge/views.py b/judge/views.py index c0a7361..d4bc179 100644 --- a/judge/views.py +++ b/judge/views.py @@ -616,13 +616,13 @@ def submission_detail(request, submission_id: str): if not status: form.add_error(None, err) else: - form = AddPosterScoreForm(initial={'score': submission.ta_score}) + form = AddPosterScoreForm(initial={'score': submission.poster_score}) context['form'] = form status, msg = handler.get_submission_status_mini(submission_id) if status: context['test_results'] = msg[0] context['judge_score'] = msg[1][0] - context['ta_score'] = msg[1][1] + context['poster_score'] = msg[1][1] context['linter_score'] = msg[1][2] context['final_score'] = msg[1][3] context['timestamp'] = msg[1][4] diff --git a/manage.py b/manage.py index 0b3bb55..2c37aff 100755 --- a/manage.py +++ b/manage.py @@ -5,7 +5,7 @@ def main(): - os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'pdpjudge.settings') + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'autojudge.settings') try: from django.core.management import execute_from_command_line except ImportError as exc: diff --git a/submission_watcher_saver.py b/submission_watcher_saver.py index d815c6e..381eb54 100644 --- a/submission_watcher_saver.py +++ b/submission_watcher_saver.py @@ -6,7 +6,7 @@ from subprocess import call from typing import List, Any -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pdpjudge.settings") +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "autojudge.settings") django.setup() from judge import models, handler # noqa: E402 @@ -15,7 +15,7 @@ TMP_DIRECTORY = 'tmp' MONITOR_DIRECTORY = os.path.join(CONTENT_DIRECTORY, TMP_DIRECTORY) DOCKER_VERSION = '1' -DOCKER_IMAGE_NAME = 'pdp_docker_{}'.format(DOCKER_VERSION) +DOCKER_IMAGE_NAME = 'autojudge_docker_{}'.format(DOCKER_VERSION) LS: List[Any] = [] REFRESH_LS_TRIGGER = 10 @@ -78,7 +78,7 @@ def saver(sub_id): quiet=True) checker.check_all() s.linter_score = _compute_lint_score(checker.report) - current_final_score = s.judge_score + s.ta_score + s.linter_score + current_final_score = s.judge_score + s.poster_score + s.linter_score penalty_multiplier = 1.0 # If the submission crosses soft deadline