Skip to content

Commit

Permalink
Add Hack model
Browse files Browse the repository at this point in the history
References #12
  • Loading branch information
Xyene committed Mar 1, 2015
1 parent 4ee4e64 commit 909eaec
Showing 1 changed file with 54 additions and 1 deletion.
55 changes: 54 additions & 1 deletion judge/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ class Meta:
('AB', 'Aborted'),
)


class Submission(models.Model):
STATUS = (
('QU', 'Queued'),
Expand Down Expand Up @@ -337,6 +336,60 @@ class Meta:
)


HACK_RESULT = (
('AC', 'Successful Hack'),
('WA', 'Unsuccessful Hack'),
('TLE', 'Time Limit Exceeded'),
('MLE', 'Memory Limit Exceeded'),
('OLE', 'Output Limit Exceeded'),
('IR', 'Invalid Return'),
('RTE', 'Runtime Error'),
('CE', 'Compile Error'),
('IE', 'Internal Error'),
('AB', 'Aborted'),
)

class Hack(models.Model):
STATUS = (
('QU', 'Queued'),
('C', 'Compiled'),
('H', 'Hacking'),
('D', 'Completed'),
('IE', 'Internal Error'),
)
RESULT = HACK_RESULT
USER_DISPLAY_CODES = {
'AC': 'Successful Hack',
'WA': 'Unsuccessful Hack',
'SC': "Short Circuited",
'TLE': 'Time Limit Exceeded',
'MLE': 'Memory Limit Exceeded',
'OLE': 'Output Limit Exceeded',
'IR': 'Invalid Return',
'RTE': 'Runtime Error',
'CE': 'Compile Error',
'IE': 'Internal Error (judging server error)',
'QU': 'Queued',
'C': 'Compiled',
'G': 'Grading',
'D': 'Completed',
'AB': 'Aborted',
}

hacker = models.ForeignKey(Profile)
target_submission = models.ForeignKey(Submission)
problem = models.ForeignKey(Problem)
date = models.DateTimeField(verbose_name='Hack time', auto_now_add=True)
time = models.FloatField(verbose_name='Execution time', null=True, db_index=True)
memory = models.FloatField(verbose_name='Memory usage', null=True)
language = models.ForeignKey(Language, verbose_name='Hack language')
source = models.TextField(verbose_name='Source code', max_length=65536)
status = models.CharField(max_length=2, choices=STATUS, default='QU', db_index=True)
result = models.CharField(max_length=3, choices=HACK_RESULT, default=None, null=True,
blank=True, db_index=True)
error = models.TextField(verbose_name='Compile errors', null=True, blank=True)
feedback = models.CharField(max_length=50, verbose_name='Judging feedback', blank=True)

class SubmissionTestCase(models.Model):
RESULT = SUBMISSION_RESULT

Expand Down

0 comments on commit 909eaec

Please sign in to comment.