From 43dc543c06594aec8a9569756fbe26378815d00d Mon Sep 17 00:00:00 2001
From: virusdefender <1670873886@qq.com>
Date: Fri, 18 Sep 2015 19:57:51 +0800
Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8F=8D=E9=A6=88?=
=?UTF-8?q?=E9=93=BE=E6=8E=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
template/src/oj_base.html | 1 +
1 file changed, 1 insertion(+)
diff --git a/template/src/oj_base.html b/template/src/oj_base.html
index 1910ff0..0d9b6fb 100644
--- a/template/src/oj_base.html
+++ b/template/src/oj_base.html
@@ -46,6 +46,7 @@
比赛
小组
关于
+ 反馈
{% if request.user.is_authenticated %}
From 18abd6a465db58b33e4cdbb3b44489a11c6bc0a0 Mon Sep 17 00:00:00 2001
From: virusdefender <1670873886@qq.com>
Date: Sat, 19 Sep 2015 15:07:31 +0800
Subject: [PATCH 2/2] =?UTF-8?q?=E8=AE=B0=E5=BD=95=E7=94=A8=E6=88=B7?=
=?UTF-8?q?=E8=BE=93=E5=87=BA=20md5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
judge/judger/client.py | 40 ++++++++++++++++++++--------------------
1 file changed, 20 insertions(+), 20 deletions(-)
diff --git a/judge/judger/client.py b/judge/judger/client.py
index a5a1f47..53164e5 100644
--- a/judge/judger/client.py
+++ b/judge/judger/client.py
@@ -98,36 +98,34 @@ class JudgeClient(object):
def _compare_output(self, test_case_id):
test_case_config = self._test_case_info["test_cases"][str(test_case_id)]
- test_case_md5 = test_case_config["output_md5"]
output_path = judger_workspace + str(test_case_id) + ".out"
try:
f = open(output_path, "rb")
except IOError:
# 文件不存在等引发的异常 返回结果错误
- return False
+ return "", False
- # 计算输出文件的md5 和之前测试用例文件的md5进行比较
- # 现在比较的是完整的文件
- md5 = hashlib.md5()
- while True:
- data = f.read(2 ** 8)
- if not data:
- break
- md5.update(data)
+ if "striped_output_md5" not in test_case_config:
+ # 计算输出文件的md5 和之前测试用例文件的md5进行比较
+ # 兼容之前没有striped_output_md5的测试用例
+ # 现在比较的是完整的文件
+ md5 = hashlib.md5()
+ while True:
+ data = f.read(2 ** 8)
+ if not data:
+ break
+ md5.update(data)
+ output_md5 = md5.hexdigest()
- if md5.hexdigest() == test_case_md5:
- return True
+ return output_md5, output_md5 == test_case_config["output_md5"]
else:
# 这时候需要去除用户输出最后的空格和换行 再去比较md5
- # 兼容之前没有striped_output_md5的测试用例
- if "striped_output_md5" not in test_case_config:
- return False
- f.seek(0)
- striped_md5 = hashlib.md5()
+ md5 = hashlib.md5()
# 比较和返回去除空格后的md5比较结果
- striped_md5.update(f.read().rstrip())
- return striped_md5.hexdigest() == test_case_config["striped_output_md5"]
+ md5.update(f.read().rstrip())
+ output_md5 = md5.hexdigest()
+ return output_md5, output_md5 == test_case_config["striped_output_md5"]
def _judge_one(self, test_case_id):
# 运行lrun程序 接收返回值
@@ -157,10 +155,12 @@ class JudgeClient(object):
return run_result
# 下面就是代码正常运行了 需要判断代码的输出是否正确
- if self._compare_output(test_case_id):
+ output_md5, r = self._compare_output(test_case_id)
+ if r:
run_result["result"] = result["accepted"]
else:
run_result["result"] = result["wrong_answer"]
+ run_result["output_md5"] = output_md5
return run_result