diff --git a/config-example.json b/config-example.json index 4b636f1..6437c22 100644 --- a/config-example.json +++ b/config-example.json @@ -32,51 +32,75 @@ "languages": { "cpp": { "show": "C++", - "highlight": "cpp" + "highlight": "cpp", + "version": "GCC 5.4.0", + "editor": "c_cpp" }, "cpp11": { "show": "C++11", - "highlight": "cpp" + "highlight": "cpp", + "version": "GCC 5.4.0", + "editor": "c_cpp" }, "csharp": { "show": "C#", - "highlight": "csharp" + "highlight": "csharp", + "version": "MCS 4.6.2.0, Mono 4.6.2", + "editor": "csharp" }, "c": { "show": "C", - "highlight": "c" + "highlight": "c", + "version": "GCC 5.4.0", + "editor": "c_cpp" }, "java": { "show": "Java", - "highlight": "java" + "highlight": "java", + "version": "GCC 5.4.0", + "editor": "java" }, "pascal": { "show": "Pascal", - "highlight": "pascal" + "highlight": "pascal", + "version": "FPC 3.0.0", + "editor": "pascal" }, "python2": { "show": "Python 2", - "highlight": "python" + "highlight": "python", + "version": "CPython 2.7.12", + "editor": "python" }, "python3": { "show": "Python 3", - "highlight": "python" + "highlight": "python", + "version": "CPython 3.5.2", + "editor": "python" }, "nodejs": { "show": "Node.js", - "highlight": "js" + "highlight": "js", + "version": "7.2.1", + "editor": "javascript" }, "ruby": { "show": "Ruby", - "highlight": "ruby" + "highlight": "ruby", + "version": "2.3.1", + "editor": "ruby" }, "haskell": { "show": "Haskell", - "highlight": "haskell" + "highlight": "haskell", + "version": "GHC 7.10.3", + "editor": "haskell" }, "vbnet": { "show": "Visual Basic", - "highlight": "vbnet" + "highlight": "vbnet", + "version": "VBNC 0.0.0.5943, Mono 4.6.2", + "editor": "vbscript" } }, "notices": [ diff --git a/models/problem.js b/models/problem.js index cc9b065..51fceb3 100644 --- a/models/problem.js +++ b/models/problem.js @@ -129,23 +129,33 @@ class Problem extends Model { this.testdata_id = file.id; } - async getJudgeState(user) { + async getJudgeState(user, acFirst) { if (!user) return null; let JudgeState = syzoj.model('judge_state'); - let states = await JudgeState.query(null, { + let where = { user_id: user.id, problem_id: this.id - }, [['submit_time', 'desc']]); + }; - if (!states || states.length === 0) return null; + if (acFirst) { + where.status = 'Accepted'; - for (let x of states) { - if (x.status === 'Accepted') return x; + let state = await JudgeState.findOne({ + where: where, + order: [['submit_time', 'desc']] + }); + + if (state) return state; } - return states[0]; + if (where.status) delete where.status; + + return await JudgeState.findOne({ + where: where, + order: [['submit_time', 'desc']] + }); } getModel() { return model; } diff --git a/modules/contest.js b/modules/contest.js index d09b40b..4fd1a85 100644 --- a/modules/contest.js +++ b/modules/contest.js @@ -218,9 +218,12 @@ app.get('/contest/:id/:pid', async (req, res) => { await syzoj.utils.markdown(problem, [ 'description', 'input_format', 'output_format', 'example', 'limit_and_hint' ]); - res.render('contest_problem', { + let state = await problem.getJudgeState(res.locals.user, false); + + res.render('problem', { contest: contest, - problem: problem + problem: problem, + state: state }); } catch (e) { syzoj.log(e); diff --git a/modules/problem.js b/modules/problem.js index a38a7e1..67ca719 100644 --- a/modules/problem.js +++ b/modules/problem.js @@ -31,7 +31,7 @@ app.get('/problem', async (req, res) => { await problems.forEachAsync(async problem => { problem.allowedEdit = await problem.isAllowedEditBy(res.locals.user); - problem.judge_state = await problem.getJudgeState(res.locals.user); + problem.judge_state = await problem.getJudgeState(res.locals.user, true); }); res.render('problem_set', { @@ -64,8 +64,11 @@ app.get('/problem/:id', async (req, res) => { throw 'Permission denied'; } + let state = await problem.getJudgeState(res.locals.user, false); + res.render('problem', { - problem: problem + problem: problem, + state: state }); } catch (e) { syzoj.log(e); diff --git a/views/contest_problem.ejs b/views/contest_problem.ejs deleted file mode 100644 index 7fc4fca..0000000 --- a/views/contest_problem.ejs +++ /dev/null @@ -1,81 +0,0 @@ -<% this.title = syzoj.utils.removeTitleTag(problem.title) + ' - ' + contest.title + ' - 比赛' %> -<% include header %> -