From 64371e62e409568014f72fb75c48e3ef7026b232 Mon Sep 17 00:00:00 2001 From: Menci Date: Sun, 2 Jul 2017 16:16:24 +0800 Subject: [PATCH] Fix problem page error when no testdata --- views/problem.ejs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/views/problem.ejs b/views/problem.ejs index c472e4f..7ab6bb4 100644 --- a/views/problem.ejs +++ b/views/problem.ejs @@ -54,7 +54,7 @@ if (contest) { <% } %>
- 评测方式:<%= testcases.spj ? 'Special Judge' : '文本比较' %> + 评测方式:<%= testcases ? (testcases.spj ? 'Special Judge' : '文本比较') : '无测试数据' %> 题目类型:<%= { 'submit-answer': '答案提交', 'interaction': '交互', 'traditional': '传统' }[problem.type] %>
@@ -197,9 +197,11 @@ if (contest) { <% if (problem.type === 'submit-answer') { %> <% let cases = []; - for (let subtasks of testcases) { - for (let testcase of subtasks.cases) { - cases.push(testcase.answer); + if (testcases) { + for (let subtasks of testcases) { + for (let testcase of subtasks.cases) { + cases.push(testcase.answer); + } } } %> @@ -207,6 +209,7 @@ if (contest) { var cases = <%- JSON.stringify(cases) %>, currCase = 0;
+ <% if (testcases) { %>
+ <% } %>