修复sample空格被吃掉的问题;

修复test_id 不对应的问题
This commit is contained in:
zema1 2017-11-13 21:29:27 +08:00
parent 727fbf48d8
commit ffd5943492
3 changed files with 8 additions and 4 deletions

View File

@ -2,6 +2,7 @@ from django.utils.timezone import now
from django.core.cache import cache
from utils.api import APIView, validate_serializer
from utils.constants import CacheKey
from utils.shortcuts import datetime2str
from account.decorators import login_required, check_contest_permission
from utils.constants import ContestRuleType, ContestStatus
@ -31,9 +32,11 @@ class ContestAPI(APIView):
return self.error("Invalid parameter, id is required")
try:
contest = Contest.objects.get(id=id)
return self.success(ContestSerializer(contest).data)
except Contest.DoesNotExist:
return self.error("Contest does not exist")
data = ContestSerializer(contest).data
data["now"] = datetime2str(now())
return self.success(data)
class ContestListAPI(APIView):

View File

@ -124,12 +124,13 @@ class JudgeDispatcher(object):
if not service_url:
service_url = settings.DEFAULT_JUDGE_SERVER_SERVICE_URL
resp = self._request(urljoin(service_url, "/judge"), data=data)
self.submission.info = resp
if resp["err"]:
self.submission.result = JudgeStatus.COMPILE_ERROR
self.submission.statistic_info["err_info"] = resp["data"]
self.submission.statistic_info["score"] = 0
else:
resp["data"].sort(key=lambda x: int(x["test_case"]))
self.submission.info = resp
self._compute_statistic_info(resp["data"])
error_test_case = list(filter(lambda case: case["result"] != 0, resp["data"]))
# ACM模式下,多个测试点全部正确则AC否则取第一个错误的测试点的状态

View File

@ -12,8 +12,8 @@ class TestCaseUploadForm(forms.Form):
class CreateSampleSerializer(serializers.Serializer):
input = serializers.CharField()
output = serializers.CharField()
input = serializers.CharField(trim_whitespace=False)
output = serializers.CharField(trim_whitespace=False)
class CreateTestCaseScoreSerializer(serializers.Serializer):