Skip to content

Commit

Permalink
Rename project (#65)
Browse files Browse the repository at this point in the history
* Rename project

* Rename pdpjudge folder to autojudge

* ta_score --> poster_score
  • Loading branch information
vishwakftw authored and vbsinha committed May 21, 2019
1 parent 522de0d commit a57a79f
Show file tree
Hide file tree
Showing 16 changed files with 52 additions and 44 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions pdpjudge/settings.py → autojudge/settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Django settings for pdpjudge project.
Django settings for autojudge project.
Generated by 'django-admin startproject' using Django 2.2.
Expand Down Expand Up @@ -57,7 +57,7 @@
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'pdpjudge.urls'
ROOT_URLCONF = 'autojudge.urls'

TEMPLATES = [
{
Expand All @@ -77,7 +77,7 @@
},
]

WSGI_APPLICATION = 'pdpjudge.wsgi.application'
WSGI_APPLICATION = 'autojudge.wsgi.application'


# Database
Expand Down
2 changes: 1 addition & 1 deletion pdpjudge/urls.py → autojudge/urls.py
Original file line number Diff line number Diff line change
@@ -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/
Expand Down
4 changes: 2 additions & 2 deletions pdpjudge/wsgi.py → autojudge/wsgi.py
Original file line number Diff line number Diff line change
@@ -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``.
Expand All @@ -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()
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 -----------------------------------------------------
Expand Down
9 changes: 4 additions & 5 deletions judge/admin.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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)
15 changes: 8 additions & 7 deletions judge/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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.
Expand All @@ -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] = []
Expand Down Expand Up @@ -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)
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions judge/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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')),
Expand Down
4 changes: 2 additions & 2 deletions judge/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
8 changes: 4 additions & 4 deletions judge/templates/judge/contest_persons.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

{% block scripts %}
<script>
$('.pdp-delete-person').click(function (){
$('.autojudge-delete-person').click(function (){
$('#id_email').val($(this).attr('data-email'))
$('#pdp-delete-form').submit();
$('#autojudge-delete-form').submit();
})
</script>
{% endblock %}
Expand All @@ -29,13 +29,13 @@ <h2 class="d-inline">{{ type }}s</h2>
{% endif %}
</div>
<div class="col-12">
<form method="POST" id="pdp-delete-form">{% csrf_token %}{{ form }}</form>
<form method="POST" id="autojudge-delete-form">{% csrf_token %}{{ form }}</form>
<div class="list-group">
{% for person in persons %}
<div class="list-group-item">
<span>{{ person }}</span>
{% if permission %}
<button class="btn btn-danger float-right pdp-delete-person" data-email="{{ person }}"><i class="fas fa-trash"></i></button>
<button class="btn btn-danger float-right autojudge-delete-person" data-email="{{ person }}"><i class="fas fa-trash"></i></button>
{% endif %}
</div>
{% empty %}
Expand Down
2 changes: 1 addition & 1 deletion judge/templates/judge/submission_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
{% if problem.contest.enable_poster_score %}
<tr>
<th>Poster Score</th>
<td>{{ ta_score }}</td>
<td>{{ poster_score }}</td>
</tr>
{% endif %}
{% if problem.contest.enable_linter_score %}
Expand Down
26 changes: 17 additions & 9 deletions judge/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/<int:contest_id>/', views.contest_detail, name='contest_detail'),
path('contest/<int:contest_id>/scores/', views.contest_scores_csv, name='contest_scores_csv'),
path('contest/<int:contest_id>/delete/', views.delete_contest, name='delete_contest'),
path('contest/<int:contest_id>/problem/new/',
views.new_problem, name='new_problem'),
path('contest/<int:contest_id>/poster/new/',
views.add_poster, name='contest_add_poster'),
path('contest/<int:contest_id>/participant/new/',
views.add_participant, name='contest_add_participant'),
path('contest/<int:contest_id>/posters/',
views.get_posters, name='get_posters'),
path('contest/<int:contest_id>/participants/',
views.get_participants, name='get_participants'),

# Problem-specific paths
path('problem/<str:problem_id>/', views.problem_detail, name='problem_detail'),
path('problem/<str:problem_id>/delete/', views.delete_problem, name='delete_problem'),
path('problem/<str:problem_id>/starting-code/',
Expand All @@ -29,18 +43,12 @@
views.problem_test_script, name='problem_test_script'),
path('problem/default-scripts/<str:script_name>/',
views.problem_default_script, name='problem_default_script'),
path('contest/<int:contest_id>/poster/new/',
views.add_poster, name='contest_add_poster'),
path('contest/<int:contest_id>/participant/new/',
views.add_participant, name='contest_add_participant'),
path('contest/<int:contest_id>/posters/',
views.get_posters, name='get_posters'),
path('contest/<int:contest_id>/participants/',
views.get_participants, name='get_participants'),
path('problem/<str:problem_id>/edit/',
views.edit_problem, name='edit_problem'),
path('problem/<str:problem_id>/submissions/',
views.problem_submissions, name='problem_submissions'),

# Submission-specific paths
path('submission/<str:submission_id>/',
views.submission_detail, name='submission_detail'),
path('submission/<str:submission_id>/download/',
Expand Down
4 changes: 2 additions & 2 deletions judge/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions submission_watcher_saver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a57a79f

Please sign in to comment.