Browse Source

Improve ranking params UI

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

6
modules/contest.js

@ -83,7 +83,11 @@ app.post('/contest/:id/edit', async (req, res) => {
ranklist = contest.ranklist; ranklist = contest.ranklist;
} }
ranklist.ranking_params = JSON.parse(req.body.ranking_params); try {
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