You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

143 lines
6.2 KiB

<% this.title = contest.id ? '编辑比赛' : '新建比赛' %>
<% include header %>
<% include monaco-editor %>
<div class="padding">
<form action="<%= syzoj.utils.makeUrl(['contest', contest.id, 'edit']) %>" method="post">
<div class="ui form">
<div class="field">
<label>比赛名称</label>
<input type="text" name="title" value="<%= contest.title %>">
</div>
<div class="field">
<label>比赛描述</label>
</div>
</div>
<div id="subtitle" class="editor editor-with-border" style="height: 100px; width: 100%; margin-bottom: 1em; ">
<%- this.showLoadingEditor(); %>
</div>
<input type="hidden" name="subtitle">
<div class="ui form">
<div class="field">
<label>试题列表</label>
<select class="ui fluid search dropdown" multiple="" id="search_problems" name="problems">
<% for (let problem of problems) { %>
<option value="<%= problem.id %>" selected>#<%= problem.id %>. <%= problem.title %></option>
<% } %>
</select>
</div>
<div class="field">
<label>比赛管理员</label>
<select class="ui fluid search dropdown" multiple="" id="search_admins" name="admins">
<% for (let admin of admins) { %>
<option value="<%= admin.id %>" selected><%= admin.username %></option>
<% } %>
</select>
</div>
<div class="inline fields">
<label>赛制</label>
<div class="field">
<div class="ui radio checkbox">
<input <% if (contest.id) { %>disabled <% } %>type="radio" name="type" id="type-noi" value="noi"<% if (contest.type === 'noi') { %> checked="checked"<% } %>>
<label for="type-noi">NOI</label>
</div>
</div>
<div class="field">
<div class="ui radio checkbox">
<input <% if (contest.id) { %>disabled <% } %>type="radio" name="type" id="type-ioi" value="ioi"<% if (contest.type === 'ioi') { %> checked="checked"<% } %>>
<label for="type-ioi">IOI</label>
</div>
</div>
<div class="field">
<div class="ui radio checkbox">
<input <% if (contest.id) { %>disabled <% } %>type="radio" name="type" id="type-acm" value="acm"<% if (contest.type === 'acm') { %> checked="checked"<% } %>>
<label for="type-acm">ICPC</label>
</div>
</div>
</div>
<div class="field">
<label>排行参数(格式:<code>{ "题目 ID": 分值倍数 }</code>)</label>
<input type="text" name="ranking_params" value="<%= contest.ranklist ? JSON.stringify(contest.ranklist.ranking_params) : '' %>">
</div>
<div class="field">
<label>比赛公告</label>
</div>
</div>
<div id="information" class="editor editor-with-border" style="height: 100px; width: 100%; margin-bottom: 1em; ">
<%- this.showLoadingEditor(); %>
</div>
<input type="hidden" name="information">
<div class="ui form">
<div class="field">
<label>开始时间</label>
<input type="text" name="start_time" value="<%= syzoj.utils.formatDate(contest.start_time || syzoj.utils.getCurrentDate()) %>">
</div>
<div class="field">
<label>结束时间</label>
<input type="text" name="end_time" value="<%= syzoj.utils.formatDate(contest.end_time || syzoj.utils.getCurrentDate()) %>">
</div>
<div class="inline field">
<label class="ui header">公开</label>
<div class="ui toggle checkbox">
<input type="checkbox"<% if (contest.is_public) { %> checked<% } %> name="is_public">
<label><span style="visibility: hidden; "> </span></label>
</div>
</div>
<div class="inline field">
<label class="ui header">隐藏统计信息</label>
<div class="ui toggle checkbox">
<input type="checkbox"<% if (contest.hide_statistics) { %> checked<% } %> name="hide_statistics">
<label><span style="visibility: hidden; "> </span></label>
</div>
</div>
<div style="text-align: center; "><button type="submit" class="ui labeled icon blue button"><i class="ui edit icon"></i>提交</button></div>
</div>
</form>
<script>
var editors = {
subtitle: { defaultValue: <%- serializejs(contest.subtitle) %> },
information: { defaultValue: <%- serializejs(contest.information) %> }
};
window.onEditorLoaded(function () {
for (var name in editors) {
var editor = editors[name];
var editorElement = document.getElementById(name);
var input = document.getElementsByName(name)[0];
editor.editor = window.createMarkdownEditor(editorElement, editor.defaultValue, input);
}
});
$(function () {
$('#search_admins')
.dropdown({
debug: true,
apiSettings: {
url: '/api/v2/search/users/{query}',
onResponse: function (response) {
var a = $('#search_admins').val().map(function (x) { return parseInt(x) });
if (response.results) {
response.results = response.results.filter(function(x){ return !a.includes(parseInt(x.value))});
}
return response;
},
cache: false
}
});
$('#search_problems')
.dropdown({
debug: true,
apiSettings: {
url: '/api/v2/search/problems/{query}',
onResponse: function (response) {
var a = $('#search_problems').val().map(function (x) { return parseInt(x) });
if (response.results) {
response.results = response.results.filter(function(x) {return !a.includes(parseInt(x.value));});
}
return response;
},
cache: false
}
});
});
</script>
<% include footer %>