增加问题展示页面和相关静态文件

This commit is contained in:
virusdefender 2015-08-02 08:50:19 +08:00
parent f80d10917f
commit cac9ac91f6
10 changed files with 135 additions and 35 deletions

View File

@ -1,3 +1,6 @@
# coding=utf-8
from django.test import TestCase
# Create your tests here.
class ProblemPageTest(TestCase):
pass

View File

@ -1,3 +1,7 @@
# coding=utf-8
from django.shortcuts import render
# Create your views here.
def problem_page(request, problem_id):
# todo
return render(request, "problem/problem.html")

View File

@ -16,5 +16,6 @@ urlpatterns = [
url(r'^login/$', TemplateView.as_view(template_name="account/login.html"), name="user_login_page"),
url(r'^api/login/$', UserLoginAPIView.as_view(), name="login_api"),
url(r'^api/login/$', UserLoginAPIView.as_view(), name="user_login_api"),
url(r'^problem/(?P<problem_id>\d+)/$', "problem.views.problem_page", name="problem_page"),
]

View File

@ -1,5 +1,6 @@
@import url("bootstrap/bootstrap.min.css");
@import url("bootstrap/todc-bootstrap.min.css");
@import url("codeMirror/codemirror.css");
html, body {
height: 100%;
}

View File

@ -1,3 +1,3 @@
require(["bootstrap", "login"]);
require(["bootstrap", "login", "submit_code"]);

View File

@ -0,0 +1,31 @@
require(["jquery", "code_mirror"], function ($, code_mirror) {
var code_editor = code_mirror($("#code-editor")[0], "text/x-csrc");
$("#language-selector").change(function () {
var language = $("#language-selector").val();
var language_types = {c: "text/x-csrc", cpp: "text/x-c++src", java: "text/x-java"};
code_editor.setOption("mode", language_types[language]);
});
function show_loading() {
$("#submit-code-button").attr("disabled", "disabled");
$("#loading-gif").show();
}
function hide_loading() {
$("#submit-code-button").removeAttr("disabled");
$("#loading-gif").hide();
}
$("#submit-code-button").click(function () {
show_loading();
setTimeout(
function () {
$("#a").animate({opacity: '1'})
}
,
3);
})
});

View File

@ -1,32 +0,0 @@
require(["../../config"], function (config) {
require(["jquery", "avalon", "code_mirror"], function ($, avalon, code_mirror) {
var code_editor = code_mirror($("#code-editor")[0], "text/x-csrc");
$("#language-selector").change(function () {
var language = $("#language-selector").val();
var language_types = {c: "text/x-csrc", cpp: "text/x-c++src", java: "text/x-java"};
code_editor.setOption("mode", language_types[language]);
});
function show_loading(){
$("#submit-code-button").attr("disabled", "disabled");
$("#loading-gif").show();
}
function hide_loading(){
$("#submit-code-button").removeAttr("disabled");
$("#loading-gif").hide();
}
$("#submit-code-button").click(function () {
show_loading();
setTimeout(
function(){
$("#a").animate({opacity:'1'})}
,
3);
})
});
});

View File

@ -15,6 +15,7 @@
login: "app/account/login",
oj: "app/oj",
"bs_alert": "utils/bs_alert",
submit_code: "app/problem/submit_code",
//formValidation 不要在代码中单独使用而是使用和修改utils/validation
base: "lib/formValidation/base",

View File

@ -14,6 +14,7 @@ var require = {
login: "app/account/login",
oj: "app/oj",
"bs_alert": "utils/bs_alert",
submit_code: "app/problem/submit_code",
//formValidation 不要在代码中单独使用而是使用和修改utils/validation

View File

@ -0,0 +1,90 @@
{% extends 'oj_base.html' %}
{% block body %}
<div class="container">
<ul class="nav nav-tabs nav-tabs-google">
<li role="presentation" class="active">
<a href="problem.html">题目</a></li>
<li role="presentation"><a href="my_solutions_list.html">我的提交</a></li>
</ul>
<h2 class="text-center">Battle Over Cities - Hard Version</h2>
<p class="text-muted text-center">cpu: 1000ms 内存: 256M</p>
<div>
<div class="problem-section">
<label class="problem-label">描述</label>
<p class="problem-detail"> n的阶乘定义为n!=1*2*3*……*n 如3!=6
n!通常最后会有很多0如5!=120 最后有一个0现在统计n!去除末尾的0后最后k位是多少</p>
</div>
<div class="problem-section">
<label class="problem-label">输入</label>
<p class="problem-detail">第一行包括两个数n,k</p>
</div>
<div class="problem-section">
<label class="problem-label">输出</label>
<p class="problem-detail">第一行包括两个数n,k</p>
</div>
<div class="problem-section">
<label class="problem-label">样例输入</label>
<pre title="双击可以复制哦~">
1 2 3 4 5 6 7
1 2 3 4 5 6 7</pre>
</div>
<div class="problem-section">
<label class="problem-label">样例输出</label>
<pre>
1 2 3 4 5 6 7</pre>
</div>
<div>
<label>选择语言</label>
<div>
<label class="radio-inline">
<input type="radio" name="inlineRadioOptions" value="c" checked> c (gcc 4.8)
</label>
<label class="radio-inline">
<input type="radio" name="inlineRadioOptions" value="cpp"> c++ (g++ 4.3)
</label>
<label class="radio-inline">
<input type="radio" name="inlineRadioOptions" value="java"> Java (jre 1.7)
</label>
</div>
</div>
<div id="code-field">
<label class="problem-label">提交代码</label>
<textarea id="code-editor"></textarea>
</div>
<hr>
<div id="submit-code">
<button type="button" class="btn btn-primary" id="submit-code-button">
提交代码
</button>
<img src="/static/img/loading.gif" id="loading-gif">
</div>
<hr>
<div class="result">
<div class="alert alert-success" role="alert" id="a" style="opacity: 0">
<div class="alert-link">
Accepted!&nbsp;&nbsp;时间:378ms 内存: 35m&nbsp;&nbsp;
<a href="#">查看详情</a>
</div>
</div>
<div class="alert alert-danger" role="alert">
<div class="alert-link">Wrong Answer!</div>
</div>
<div class="alert alert-danger" role="alert">
<div class="alert-link">Compile Error!</div>
</div>
<div class="alert alert-warning" role="alert">
<div class="alert-link">Error Format!</div>
</div>
</div>
</div>
</div>
{% endblock %}