重构 problem 和 contest;修改测试和部分模板的结构
This commit is contained in:
116
template/src/oj/submission/my_submission.html
Normal file
116
template/src/oj/submission/my_submission.html
Normal file
@@ -0,0 +1,116 @@
|
||||
{% extends 'oj_base.html' %}
|
||||
{% block title %}
|
||||
我的提交详情
|
||||
{% endblock %}
|
||||
{% block css_block %}
|
||||
<style>
|
||||
.CodeMirror {
|
||||
height: auto;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
{% block body %}
|
||||
{% load submission %}
|
||||
<div class="container main">
|
||||
<ul class="nav nav-tabs nav-tabs-google">
|
||||
<li role="presentation">
|
||||
{% if submission.contest_id %}
|
||||
|
||||
<a href="/contest/{{ submission.contest_id }}/problem/{{ problem.id }}/">题目</a>
|
||||
|
||||
{% else %}
|
||||
<a href="/problem/{{ problem.id }}/">题目</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
|
||||
|
||||
<li role="presentation" class="active">
|
||||
{% if submission.contest_id %}
|
||||
<a href="/contest/{{ submission.contest_id }}/problem/{{ problem.id }}/submissions/">我的提交</a>
|
||||
{% else %}
|
||||
<a href="/problem/{{ problem.id }}/submissions/">我的提交</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
{% include "oj/problem/_problem_header.html" %}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<h4>运行结果 : <span class="text-{{ submission.result|translate_result_class }}">
|
||||
{{ submission.result|translate_result }}
|
||||
</span>
|
||||
</h4>
|
||||
{% ifnotequal request.user.id submission.user_id %}
|
||||
<p>作者:{{ user.username }}</p>
|
||||
{% endifnotequal %}
|
||||
{% ifequal submission.result 0 %}
|
||||
<p>时间 : {{ submission.accepted_answer_time }}ms 语言 :
|
||||
{{ submission.language|translate_language }}
|
||||
</p>
|
||||
{% endifequal %}
|
||||
{% ifequal submission.result 4 %}
|
||||
<pre>{{ submission.info }}</pre>
|
||||
{% endifequal %}
|
||||
<p>提交时间 : {{ submission.create_time }}</p>
|
||||
</div>
|
||||
</div>
|
||||
{% ifequal request.user.admin_type 2 %}
|
||||
<p>本调试信息仅超级管理员可见</p>
|
||||
{% ifequal submission.result 7 %}
|
||||
<pre>System Error: {{ submission.info }}</pre>
|
||||
{% else %}
|
||||
<pre>{{ info }}</pre>
|
||||
{% endifequal %}
|
||||
|
||||
{% endifequal %}
|
||||
|
||||
|
||||
<div id="code-field">
|
||||
<textarea id="code-editor">{{ submission.code }}</textarea>
|
||||
</div>
|
||||
{% if can_share %}
|
||||
<div id="share-code" class="col-lg-6 col-md-6">
|
||||
{% if submission.shared %}
|
||||
<button class="btn btn-warning" id="share-code-btn">取消分享</button>
|
||||
{% else %}
|
||||
<button class="btn btn-primary" id="share-code-btn">分享我的代码</button>
|
||||
{% endif %}
|
||||
<textarea class="form-control" id="share-code-textarea"
|
||||
{% if not submission.shared %}style="display: none" {% endif %}>{{ problem.title }}
|
||||
{{ request.build_absolute_uri }}</textarea>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
{% block js_block %}
|
||||
<script>
|
||||
require(["jquery", "codeMirror", "csrfToken"], function ($, codeMirror, csrfTokenHeader) {
|
||||
{% ifequal submission.language 1 %}
|
||||
var language = "text/x-csrc";
|
||||
{% else %}
|
||||
{% ifequal submission.language 2 %}
|
||||
var language = "text/x-c++src";
|
||||
{% else %}
|
||||
var language = "text/x-java";
|
||||
{% endifequal %}
|
||||
{% endifequal %}
|
||||
var codeEditor = codeMirror($("#code-editor")[0], language);
|
||||
codeEditor.setOption("readOnly", true);
|
||||
|
||||
$("#share-code-btn").click(function () {
|
||||
$.ajax({
|
||||
beforeSend: csrfTokenHeader,
|
||||
url: "/api/submission/share/",
|
||||
method: "post",
|
||||
data: {submission_id: location.href.split("/")[4]},
|
||||
success: function (data) {
|
||||
location.reload();
|
||||
}
|
||||
})
|
||||
})
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
65
template/src/oj/submission/problem_my_submissions_list.html
Normal file
65
template/src/oj/submission/problem_my_submissions_list.html
Normal file
@@ -0,0 +1,65 @@
|
||||
{% extends 'oj_base.html' %}
|
||||
{% block title %}
|
||||
我的提交列表
|
||||
{% endblock %}
|
||||
{% block body %}
|
||||
|
||||
{% load submission %}
|
||||
<div class="container main">
|
||||
<ul class="nav nav-tabs nav-tabs-google">
|
||||
{% if problem.contest_id %}
|
||||
<li role="presentation">
|
||||
<a href="/contest/{{ problem.contest.id }}/problem/{{ problem.id }}/">题目</a></li>
|
||||
<li role="presentation" class="active">
|
||||
<a href="/contest/{{ problem.contest.id }}/problem/{{ problem.id }}/submissions/">我的提交</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li role="presentation">
|
||||
<a href="/problem/{{ problem.id }}/">题目</a></li>
|
||||
<li role="presentation" class="active">
|
||||
<a href="/problem/{{ problem.id }}/submissions/">我的提交</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
{% include "oj/problem/_problem_header.html" %}
|
||||
{% if submissions %}
|
||||
<table class="table table-bordered">
|
||||
<thead>
|
||||
<tr class="" success>
|
||||
<th>#</th>
|
||||
<th>提交时间</th>
|
||||
<th>语言</th>
|
||||
<th>运行时间</th>
|
||||
<th>结果</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for item in submissions %}
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<a href="/submission/{{ item.id }}/">{{ forloop.counter }}</a>
|
||||
</th>
|
||||
<td>{{ item.create_time }}</td>
|
||||
<td>
|
||||
{{ item.language|translate_language }}
|
||||
</td>
|
||||
<td>
|
||||
{% if item.accepted_answer_time %}
|
||||
{{ item.accepted_answer_time }}ms
|
||||
{% else %}
|
||||
--
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="alert-{{ item.result|translate_result_class }}">
|
||||
<strong>{{ item.result|translate_result }}</strong>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
<p>你还没有提交该题目</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user