Browse Source

Improve ranking params UI

pull/6/head
Menci 6 years ago
parent
commit
124b9fd547
  1. 4
      modules/contest.js
  2. 2
      views/contest_edit.ejs

4
modules/contest.js

@ -83,7 +83,11 @@ app.post('/contest/:id/edit', async (req, res) => {
ranklist = contest.ranklist; ranklist = contest.ranklist;
} }
try {
ranklist.ranking_params = JSON.parse(req.body.ranking_params); ranklist.ranking_params = JSON.parse(req.body.ranking_params);
} catch (e) {
ranklist.ranking_params = {};
}
await ranklist.save(); await ranklist.save();
contest.ranklist_id = ranklist.id; contest.ranklist_id = ranklist.id;

2
views/contest_edit.ejs

@ -48,7 +48,7 @@
</div> </div>
</div> </div>
<div class="field"> <div class="field">
<label>排行参数</label> <label>排行参数(格式:<code>{ "题目 ID": 分值倍数 }</code>)</label>
<input type="text" name="ranking_params" value="<%= contest.ranklist ? JSON.stringify(contest.ranklist.ranking_params) : '' %>"> <input type="text" name="ranking_params" value="<%= contest.ranklist ? JSON.stringify(contest.ranklist.ranking_params) : '' %>">
</div> </div>
<div class="field"> <div class="field">

Loading…
Cancel
Save