mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2024-12-28 16:12:13 +00:00
增加了题目的 model 修改几个 typo
This commit is contained in:
parent
dd7fe6ee44
commit
3ee4b57802
@ -36,3 +36,11 @@ class UserRegisterView(APIView):
|
||||
|
||||
def post(self, request):
|
||||
pass
|
||||
|
||||
|
||||
class UserChangePasswordView(APIView):
|
||||
def get(self, request):
|
||||
pass
|
||||
|
||||
def post(self, request):
|
||||
pass
|
@ -4,5 +4,9 @@ from django.db import models
|
||||
from problem.models import AbstractProblem
|
||||
|
||||
|
||||
class ContestProblem(AbstractProblem):
|
||||
class Contest(models.Model):
|
||||
pass
|
||||
|
||||
|
||||
class ContestProblem(AbstractProblem):
|
||||
contest = models.ForeignKey(Contest)
|
||||
|
@ -8,7 +8,7 @@ from settings import max_running_number, lrun_gid, lrun_uid, judger_workspace
|
||||
from language import languages
|
||||
from result import result
|
||||
from compiler import compile_
|
||||
from judge_exceptions import JudgeClientException, CompileError
|
||||
from judge_exceptions import JudgeClientError, CompileError
|
||||
from utils import parse_lrun_output
|
||||
|
||||
|
||||
@ -47,9 +47,9 @@ class JudgeClient(object):
|
||||
f = open(self._test_case_dir + "info")
|
||||
return json.loads(f.read())
|
||||
except IOError:
|
||||
raise JudgeClientException("Test case config file not found")
|
||||
raise JudgeClientError("Test case config file not found")
|
||||
except ValueError:
|
||||
raise JudgeClientException("Test case config file format error")
|
||||
raise JudgeClientError("Test case config file format error")
|
||||
|
||||
def _generate_command(self, test_case_id):
|
||||
"""
|
||||
@ -82,7 +82,7 @@ class JudgeClient(object):
|
||||
# 倒序找到MEMORY的位置
|
||||
output_start = output.rfind("MEMORY")
|
||||
if output_start == -1:
|
||||
raise JudgeClientException("Lrun result parse error")
|
||||
raise JudgeClientError("Lrun result parse error")
|
||||
# 如果不是0,说明lrun输出前面有输出,也就是程序的stderr有内容
|
||||
if output_start != 0:
|
||||
error = output[0:output_start]
|
||||
@ -118,7 +118,7 @@ class JudgeClient(object):
|
||||
command = self._generate_command(test_case_id)
|
||||
status_code, output = commands.getstatusoutput(command)
|
||||
if status_code:
|
||||
raise JudgeClientException(output)
|
||||
raise JudgeClientError(output)
|
||||
error, run_result = self._parse_lrun_output(output)
|
||||
|
||||
run_result["test_case_id"] = test_case_id
|
||||
@ -135,7 +135,7 @@ class JudgeClient(object):
|
||||
elif run_result["exceed"] in ["cpu_time", "real_time"]:
|
||||
run_result["result"] = result["time_limit_exceeded"]
|
||||
else:
|
||||
raise JudgeClientException("Error exceeded type: " + run_result["exceed"])
|
||||
raise JudgeClientError("Error exceeded type: " + run_result["exceed"])
|
||||
return run_result
|
||||
|
||||
# 下面就是代码正常运行了 需要判断代码的输出是否正确
|
||||
|
@ -2,7 +2,7 @@
|
||||
import commands
|
||||
|
||||
from settings import lrun_uid, lrun_gid
|
||||
from judge_exceptions import CompileError
|
||||
from judge_exceptions import CompileError, JudgeClientError
|
||||
from utils import parse_lrun_output
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@ def compile_(language_item, src_path, exe_path):
|
||||
output_start = output.rfind("MEMORY")
|
||||
|
||||
if output_start == -1:
|
||||
raise CompileError("Error running compiler in lrun")
|
||||
raise JudgeClientError("Error running compiler in lrun")
|
||||
|
||||
# 返回值不为0 或者 stderr中lrun的输出之前有东西
|
||||
if status or output_start:
|
||||
@ -33,5 +33,4 @@ def compile_(language_item, src_path, exe_path):
|
||||
if parse_result["exit_code"] or parse_result["term_sig"] or parse_result["siginaled"] or parse_result["exceed"]:
|
||||
raise CompileError("Compile error")
|
||||
|
||||
# 对于正常编译和超时等其他的错误
|
||||
return exe_path
|
||||
|
@ -1,9 +1,9 @@
|
||||
# coding=utf-8
|
||||
|
||||
|
||||
class JudgeClientException(Exception):
|
||||
class JudgeClientError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class CompileError(Exception):
|
||||
pass
|
||||
pass
|
@ -4,7 +4,45 @@ from django.db import models
|
||||
from account.models import User
|
||||
|
||||
|
||||
class ProblemTag(models.Model):
|
||||
pass
|
||||
|
||||
|
||||
class AbstractProblem(models.Model):
|
||||
# 标题
|
||||
title = models.CharField(max_length=50)
|
||||
# 问题描述 HTML 格式
|
||||
description = models.TextField()
|
||||
# 样例输入 可能会存储 json 格式的数据
|
||||
sample_input = models.TextField(blank=True)
|
||||
# 样例输出 同上
|
||||
sample_output = models.TextField(blank=True)
|
||||
# 测试用例id 这个id 可以用来拼接得到测试用例的文件存储位置
|
||||
test_case_id = models.CharField(max_length=40)
|
||||
# 提示
|
||||
hint = models.TextField(blank=True)
|
||||
# 创建时间
|
||||
create_time = models.DateTimeField(auth_now_add=True)
|
||||
# 最后更新时间
|
||||
last_update_time = models.DateTimeField(auto_now=True)
|
||||
# 这个题是谁创建的
|
||||
author = models.ForeignKey(User)
|
||||
# 来源
|
||||
source = models.CharField(max_length=30, blank=True)
|
||||
# 时间限制 单位是毫秒
|
||||
time_limit = models.IntegerField()
|
||||
# 内存限制 单位是MB
|
||||
memory_limit = models.IntegerField()
|
||||
# 是否可见 false的话相当于删除
|
||||
visible = models.BooleanField(default=True)
|
||||
# 总共提交数量
|
||||
total_submit_number = models.IntegerField(default=0)
|
||||
# 通过数量
|
||||
total_accepted_number = models.IntegerField(default=0)
|
||||
# 标签
|
||||
tags = models.ManyToManyField(ProblemTag, null=True)
|
||||
# 难度 0 - n
|
||||
difficulty = models.IntegerField()
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
@ -12,8 +50,3 @@ class AbstractProblem(models.Model):
|
||||
|
||||
class Problem(AbstractProblem):
|
||||
pass
|
||||
|
||||
|
||||
class Solution(models.Model):
|
||||
user = models.ForeignKey(User)
|
||||
problem = models.ForeignKey(Problem)
|
Loading…
Reference in New Issue
Block a user