Browse Source

Add VB and C++11 support

pull/6/head
Menci 8 years ago
parent
commit
cdce7f8de1
  1. 32
      config-example.json
  2. 4
      modules/judge.js
  3. 1
      modules/problem.js
  4. 4
      views/contest_problem.ejs
  5. 2
      views/judge_detail_item.ejs
  6. 2
      views/judge_state_item.ejs
  7. 4
      views/submit.ejs

32
config-example.json

@ -29,12 +29,32 @@
"contest": 10,
"edit_contest_problem_list": 10
},
"languages": [
"C++",
"C#",
"C",
"Pascal"
],
"languages": {
"cpp": {
"show": "C++",
"highlight": "cpp"
},
"cpp11": {
"show": "C++11",
"highlight": "cpp"
},
"csharp": {
"show": "C#",
"highlight": "csharp"
},
"c": {
"show": "C",
"highlight": "c"
},
"pascal": {
"show": "Pascal",
"highlight": "pascal"
},
"vbnet": {
"show": "Visual Basic",
"highlight": "vbnet"
}
},
"notices": [
{
"type": "// article",

4
modules/judge.js

@ -75,7 +75,7 @@ app.get('/judge_detail/:id', async (req, res) => {
let id = parseInt(req.params.id);
let judge = await JudgeState.fromID(id);
judge.code = await syzoj.utils.highlight(judge.code, judge.language);
judge.code = await syzoj.utils.highlight(judge.code, syzoj.config.languages[judge.language].highlight);
if (judge.result.compiler_output) judge.result.compiler_output = syzoj.utils.ansiToHTML(judge.result.compiler_output);
judge.allowedSeeResult = await judge.isAllowedSeeResultBy(res.locals.user);
judge.allowedSeeCode = await judge.isAllowedSeeCodeBy(res.locals.user);
@ -96,7 +96,7 @@ app.get('/judge_detail/:id/ajax', async (req, res) => {
let id = parseInt(req.params.id);
let judge = await JudgeState.fromID(id);
judge.code = await syzoj.utils.highlight(judge.code, judge.language);
judge.code = await syzoj.utils.highlight(judge.code, syzoj.config.languages[judge.language].highlight);
if (judge.result.compiler_output) judge.result.compiler_output = syzoj.utils.ansiToHTML(judge.result.compiler_output);
judge.allowedSeeResult = await judge.isAllowedSeeResultBy(res.locals.user);
judge.allowedSeeCode = await judge.isAllowedSeeCodeBy(res.locals.user);

1
modules/problem.js

@ -208,6 +208,7 @@ app.post('/submit/:id', async (req, res) => {
let problem = await Problem.fromID(id);
if (!problem) throw 'No such problem.';
if (!syzoj.config.languages[req.body.language]) throw 'No such language.'
if (!res.locals.user) throw 'Please login.';
if (!await problem.isAllowedUseBy(res.locals.user)) throw 'Permission denied.';

4
views/contest_problem.ejs

@ -63,8 +63,8 @@
<div class="field">
<label for="doc-select-1">选择语言</label>
<select class="ui fluid dropdown" name="language" id="doc-select-1">
<% for (lang of syzoj.config.languages) { %>
<option value="<%= lang %>"><%= lang %></option>
<% for (lang in syzoj.config.languages) { %>
<option value="<%= lang %>"><%= syzoj.config.languages[lang].show %></option>
<% } %>
</select>
</div>

2
views/judge_detail_item.ejs

@ -25,7 +25,7 @@
<td class="score score_<%= parseInt(judge.result.score / 10) || 0 %>"><%= judge.result.score %></td>
<td><%= judge.result.total_time %> ms</td>
<td><%= judge.result.max_memory %> KiB</td>
<td><%= judge.language %></td>
<td><%= syzoj.config.languages[judge.language].show %></td>
<% } else { %>
<td>隐藏</td>
<td>隐藏</td>

2
views/judge_state_item.ejs

@ -11,7 +11,7 @@
<td><a href="<%= syzoj.utils.makeUrl(['judge_detail', judge.id]) %>"><span class="score score_<%= parseInt(judge.result.score / 10) || 0 %>"><%= judge.result.score %></span></a></td>
<td><%= judge.result.total_time %> ms</td>
<td><%= judge.result.max_memory %> KiB</td>
<td><%= judge.language %></td>
<td><%= syzoj.config.languages[judge.language].show %></td>
<% } else { %>
<td>隐藏</td>
<td>隐藏</td>

4
views/submit.ejs

@ -6,8 +6,8 @@
<div class="field">
<label for="doc-select-1">选择语言</label>
<select class="ui fluid dropdown" id="doc-select-1" name="language">
<% for (lang of syzoj.config.languages) { %>
<option value="<%= lang %>"><%= lang %></option>
<% for (lang in syzoj.config.languages) { %>
<option value="<%= lang %>"><%= syzoj.config.languages[lang].show %></option>
<% } %>
</select>
</div>

Loading…
Cancel
Save