Merge branch 'dev' of https://git.coding.net/virusdefender/qduoj into dev
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
# coding=utf-8
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.test import TestCase
|
||||
|
||||
from rest_framework.test import APITestCase, APIClient
|
||||
|
||||
@@ -87,3 +88,27 @@ class AnnouncementAPITest(APITestCase):
|
||||
self.assertEqual(response.data["code"], 0)
|
||||
for item in response.data["data"]:
|
||||
self.assertEqual(item["visible"], True)
|
||||
|
||||
|
||||
class AnnouncementPageTest(TestCase):
|
||||
def setUp(self):
|
||||
user = User.objects.create(username="test")
|
||||
user.set_password("testaa")
|
||||
user.save()
|
||||
Announcement.objects.create(title="aa",
|
||||
content="AA",
|
||||
created_by=User.objects.get(username="test"),
|
||||
visible=True)
|
||||
|
||||
Announcement.objects.create(title="bb",
|
||||
content="BB",
|
||||
created_by=User.objects.get(username="test"),
|
||||
visible=False)
|
||||
|
||||
def test_success_announcement(self):
|
||||
response = self.client.get('/announcement/1/')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_announcement_does_not_exist(self):
|
||||
response = self.client.get('/announcement/3/')
|
||||
self.assertTemplateUsed(response, "utils/error.html")
|
||||
|
||||
@@ -5,7 +5,7 @@ from account.models import User
|
||||
|
||||
|
||||
class Group(models.Model):
|
||||
name = models.CharField(max_length=30)
|
||||
name = models.CharField(max_length=30, unique=True)
|
||||
description = models.TextField()
|
||||
create_time = models.DateTimeField(auto_now_add=True)
|
||||
admin = models.ForeignKey(User, related_name="my_groups")
|
||||
@@ -26,10 +26,11 @@ class UserGroupRelation(models.Model):
|
||||
|
||||
class Meta:
|
||||
db_table = "user_group_relation"
|
||||
unique_together = ("group", "user")
|
||||
|
||||
|
||||
class JoinGroupRequest(models.Model):
|
||||
group = models.ForeignKey(User)
|
||||
group = models.ForeignKey(Group)
|
||||
user = models.ForeignKey(User, related_name="my_join_group_requests")
|
||||
message = models.TextField()
|
||||
create_time = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
202
group/tests.py
202
group/tests.py
@@ -1,3 +1,201 @@
|
||||
from django.test import TestCase
|
||||
# coding=utf-8
|
||||
import json
|
||||
|
||||
# Create your tests here.
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
from rest_framework.test import APITestCase, APIClient
|
||||
|
||||
from account.models import User, REGULAR_USER, ADMIN, SUPER_ADMIN
|
||||
from group.models import Group, UserGroupRelation, JoinGroupRequest
|
||||
|
||||
|
||||
class GroupAPITest(APITestCase):
|
||||
pass
|
||||
|
||||
|
||||
class GroupAdminAPITest(APITestCase):
|
||||
def _create_group(self, name, join_group_setting):
|
||||
group = Group.objects.create(name=name, description="des0",
|
||||
join_group_setting=join_group_setting, visible=True,
|
||||
admin=self.user)
|
||||
return group
|
||||
|
||||
def setUp(self):
|
||||
self.client = APIClient()
|
||||
self.url = reverse('group_admin_api')
|
||||
self.user = User.objects.create(username="test", admin_type=SUPER_ADMIN)
|
||||
self.user.set_password("testaa")
|
||||
self.user.save()
|
||||
self.group = self._create_group("group1", 0)
|
||||
self.client.login(username="test", password="testaa")
|
||||
|
||||
# 以下是创建小组的测试
|
||||
def test_invalid_format(self):
|
||||
data = {"name": "group1"}
|
||||
response = self.client.post(self.url, data=data)
|
||||
self.assertEqual(response.data["code"], 1)
|
||||
|
||||
def test_create_group_successfully(self):
|
||||
data = {"name": "group0", "description": "des0", "join_group_setting": "1"}
|
||||
response = self.client.post(self.url, data=data)
|
||||
self.assertEqual(response.data["code"], 0)
|
||||
|
||||
def test_group_already_exists(self):
|
||||
data = {"name": "group1", "description": "des0", "join_group_setting": "1"}
|
||||
response = self.client.post(self.url, data=data)
|
||||
self.assertEqual(response.data, {"code": 1, "data": u"小组名已经存在"})
|
||||
|
||||
# 以下是修改小组的测试
|
||||
def test_put_invalid_data(self):
|
||||
data = {"name": "group1"}
|
||||
response = self.client.put(self.url, data=data)
|
||||
self.assertEqual(response.data["code"], 1)
|
||||
|
||||
def test_edit_group_does_not_exist(self):
|
||||
data = {"group_id": self.group.id + 1, "name": "group0", "description": "des0",
|
||||
"join_group_setting": 2}
|
||||
response = self.client.put(self.url, data=data)
|
||||
self.assertEqual(response.data, {"code": 1, "data": u"小组不存在"})
|
||||
|
||||
def test_edit_group_successfully(self):
|
||||
data = {"group_id": self.group.id, "name": "group0", "description": "des0",
|
||||
"join_group_setting": 2}
|
||||
response = self.client.put(self.url, data=data)
|
||||
self.assertEqual(response.data["code"], 0)
|
||||
self.assertEqual(response.data["data"]["name"], "group0")
|
||||
self.assertEqual(response.data["data"]["join_group_setting"], 2)
|
||||
|
||||
def test_edit_group_exists(self):
|
||||
group = self._create_group("group2", 1)
|
||||
data = {"group_id": group.id, "name": "group1", "description": "des0",
|
||||
"join_group_setting": 0}
|
||||
response = self.client.put(self.url, data=data)
|
||||
self.assertEqual(response.data, {"code": 1, "data": u"小组名已经存在"})
|
||||
|
||||
# 以下是查询小组列表或者是单个小组时的测试
|
||||
def test_select_group_does_not_exist(self):
|
||||
data = {"group_id": self.group.id + 1}
|
||||
response = self.client.get(self.url, data=data)
|
||||
self.assertEqual(response.data, {"code": 1, "data": u"小组不存在"})
|
||||
|
||||
def test_select_group_successfully(self):
|
||||
data = {"group_id": self.group.id}
|
||||
response = self.client.get(self.url, data=data)
|
||||
self.assertEqual(response.data["code"], 0)
|
||||
|
||||
def test_success_get_all_groups(self):
|
||||
self.assertEqual(self.client.get(self.url).data["code"], 0)
|
||||
|
||||
|
||||
class GroupMemberAdminAPITest(APITestCase):
|
||||
def setUp(self):
|
||||
self.client = APIClient()
|
||||
self.url = reverse('group_member_admin_api')
|
||||
self.user = User.objects.create(username="test", admin_type=SUPER_ADMIN)
|
||||
self.user.set_password("testaa")
|
||||
self.user.save()
|
||||
self.user1 = User.objects.create(username="member1", admin_type=REGULAR_USER)
|
||||
self.user1.set_password("testxx")
|
||||
self.user1.save()
|
||||
self.client.login(username="test", password="testaa")
|
||||
self.group = Group.objects.create(name="group1", description="des1",
|
||||
join_group_setting="1", visible="True",
|
||||
admin=self.user)
|
||||
UserGroupRelation.objects.create(group=self.group, user=self.user1)
|
||||
|
||||
# 以下是查询小组成员的测试
|
||||
def test_missing_parameter(self):
|
||||
self.assertEqual(self.client.get(self.url).data, {"code": 1, "data": u"参数错误"})
|
||||
|
||||
def test_group_does_not_exist(self):
|
||||
data = {"group_id": self.group.id + 1}
|
||||
response = self.client.get(self.url, data=data)
|
||||
self.assertEqual(response.data, {"code": 1, "data": u"小组不存在"})
|
||||
|
||||
def test_get_member_list_successfully(self):
|
||||
data = {"group_id": self.group.id}
|
||||
response = self.client.get(self.url, data=data)
|
||||
self.assertEqual(response.data["code"], 0)
|
||||
|
||||
# 以下是删除小组成员的测试
|
||||
def test_invalid_format(self):
|
||||
data = {"members": [self.user1.id]}
|
||||
response = self.client.put(self.url, data=json.dumps(data), content_type="application/json")
|
||||
self.assertEqual(response.data["code"], 1)
|
||||
|
||||
def test_del_group_does_not_exist(self):
|
||||
data = {"group_id": self.group.id + 1, "members": [self.user1.id]}
|
||||
response = self.client.put(self.url, data=json.dumps(data), content_type="application/json")
|
||||
self.assertEqual(response.data, {"code": 1, "data": u"小组不存在"})
|
||||
|
||||
def test_success_del_members(self):
|
||||
data = {"group_id": self.group.id, "members": [self.user1.id]}
|
||||
response = self.client.put(self.url, data=json.dumps(data), content_type="application/json")
|
||||
self.assertEqual(response.data, {"code": 0, "data": u"删除成功"})
|
||||
try:
|
||||
UserGroupRelation.objects.get(group=self.group, user=self.user1)
|
||||
raise AssertionError()
|
||||
except UserGroupRelation.DoesNotExist:
|
||||
pass
|
||||
|
||||
|
||||
class JoinGroupAPITest(APITestCase):
|
||||
def _create_group(self, name, join_group_setting):
|
||||
group = Group.objects.create(name=name, description="des0",
|
||||
join_group_setting=join_group_setting, visible="True",
|
||||
admin=self.user)
|
||||
return group
|
||||
|
||||
def setUp(self):
|
||||
self.client = APIClient()
|
||||
self.url = reverse('group_join_admin_api')
|
||||
self.user = User.objects.create(username="test", admin_type=SUPER_ADMIN)
|
||||
self.user.set_password("testaa")
|
||||
self.user.save()
|
||||
self.client.login(username="test", password="testaa")
|
||||
self.group = self._create_group("group0", 0)
|
||||
|
||||
# 以下是用户要加入某个小组的测试
|
||||
def test_invalid_format(self):
|
||||
data = {"message": "message1"}
|
||||
response = self.client.post(self.url, data=data)
|
||||
self.assertEqual(response.data["code"], 1)
|
||||
|
||||
def test_group_does_not_exist(self):
|
||||
data = {"group_id": self.group.id + 1, "message": "message1"}
|
||||
response = self.client.post(self.url, data=data)
|
||||
self.assertEqual(response.data, {"code": 1, "data": u"小组不存在"})
|
||||
|
||||
def test_join0(self):
|
||||
data = {"group_id": self.group.id, "message": "message0"}
|
||||
response = self.client.post(self.url, data=data)
|
||||
self.assertEqual(response.data, {"code": 0, "data": u"你已经成功的加入该小组"})
|
||||
|
||||
# 再加入一遍 已经是小组成员了
|
||||
data = {"group_id": self.group.id, "message": "message0"}
|
||||
response = self.client.post(self.url, data=data)
|
||||
self.assertEqual(response.data, {"code": 1, "data": u"你已经是小组成员了"})
|
||||
|
||||
def test_success_join1(self):
|
||||
group = self._create_group("group1", 1)
|
||||
data = {"group_id": group.id, "message": "message1"}
|
||||
response = self.client.post(self.url, data=data)
|
||||
self.assertEqual(response.data, {"code": 0, "data": u"申请提交成功,请等待审核"})
|
||||
try:
|
||||
JoinGroupRequest.objects.get(user=self.user, group=group, status=False)
|
||||
except JoinGroupRequest.DoesNotExist:
|
||||
raise AssertionError()
|
||||
|
||||
def test_success_join2(self):
|
||||
group = self._create_group("group2", 2)
|
||||
data = {"group_id": group.id, "message": "message2"}
|
||||
response = self.client.post(self.url, data=data)
|
||||
self.assertEqual(response.data, {"code": 1, "data": u"该小组不允许任何人加入"})
|
||||
|
||||
# 以下是搜索小组的测试
|
||||
def test_error_get_data(self):
|
||||
self.assertEqual(self.client.get(self.url).data["code"], 1)
|
||||
|
||||
def test_query_by_keyword(self):
|
||||
response = self.client.get(self.url + "?keyword=group0")
|
||||
self.assertEqual(response.data["code"], 0)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# coding=utf-8
|
||||
from django.shortcuts import render
|
||||
from django.db import IntegrityError
|
||||
|
||||
from rest_framework.views import APIView
|
||||
|
||||
@@ -48,10 +49,13 @@ class GroupAdminAPIView(APIView, GroupAPIViewBase):
|
||||
serializer = CreateGroupSerializer(data=request.data)
|
||||
if serializer.is_valid():
|
||||
data = serializer.data
|
||||
group = Group.objects.create(name=data["name"],
|
||||
description=data["description"],
|
||||
join_group_setting=data["join_group_setting"],
|
||||
admin=request.user)
|
||||
try:
|
||||
group = Group.objects.create(name=data["name"],
|
||||
description=data["description"],
|
||||
join_group_setting=data["join_group_setting"],
|
||||
admin=request.user)
|
||||
except IntegrityError:
|
||||
return error_response(u"小组名已经存在")
|
||||
return success_response(GroupSerializer(group).data)
|
||||
else:
|
||||
return serializer_invalid_response(serializer)
|
||||
@@ -70,10 +74,14 @@ class GroupAdminAPIView(APIView, GroupAPIViewBase):
|
||||
group = self.get_group(request, data["group_id"])
|
||||
except Group.DoesNotExist:
|
||||
return error_response(u"小组不存在")
|
||||
group.name = data["name"]
|
||||
group.description = data["description"]
|
||||
group.join_group_setting = data["join_group_setting"]
|
||||
group.save()
|
||||
try:
|
||||
group.name = data["name"]
|
||||
group.description = data["description"]
|
||||
group.join_group_setting = data["join_group_setting"]
|
||||
group.save()
|
||||
except IntegrityError:
|
||||
return error_response(u"小组名已经存在")
|
||||
|
||||
return success_response(GroupSerializer(group).data)
|
||||
else:
|
||||
return serializer_invalid_response(serializer)
|
||||
@@ -133,7 +141,11 @@ class GroupMemberAdminAPIView(APIView, GroupAPIViewBase):
|
||||
|
||||
|
||||
def join_group(user, group):
|
||||
return UserGroupRelation.objects.create(user=user, group=group)
|
||||
try:
|
||||
UserGroupRelation.objects.create(user=user, group=group)
|
||||
return True
|
||||
except IntegrityError:
|
||||
return False
|
||||
|
||||
|
||||
class JoinGroupAPIView(APIView):
|
||||
@@ -149,12 +161,15 @@ class JoinGroupAPIView(APIView):
|
||||
data = serializer.data
|
||||
try:
|
||||
group = Group.objects.get(id=data["group_id"])
|
||||
except Group.DesoNotExist:
|
||||
except Group.DoesNotExist:
|
||||
return error_response(u"小组不存在")
|
||||
if group.join_group_setting == 0:
|
||||
join_group(request.user, group)
|
||||
return success_response(u"你已经成功的加入该小组")
|
||||
if join_group(request.user, group):
|
||||
return success_response(u"你已经成功的加入该小组")
|
||||
else:
|
||||
return error_response(u"你已经是小组成员了")
|
||||
elif group.join_group_setting == 1:
|
||||
JoinGroupRequest.objects.create(user=request.user, group=group, message=data["message"])
|
||||
return success_response(u"申请提交成功,请等待审核")
|
||||
elif group.join_group_setting == 2:
|
||||
return error_response(u"该小组不允许任何人加入")
|
||||
|
||||
12
judge/tests/c/cpu_time_timeout.c
Normal file
12
judge/tests/c/cpu_time_timeout.c
Normal file
@@ -0,0 +1,12 @@
|
||||
#include <stdio.h>
|
||||
int main()
|
||||
{
|
||||
int a = 0;
|
||||
int i = 0;
|
||||
for(i = 0; i < 9999999999;i++)
|
||||
{
|
||||
a += i;
|
||||
}
|
||||
printf("%d", a);
|
||||
return 0;
|
||||
}
|
||||
6
judge/tests/c/real_time_timeout.c
Normal file
6
judge/tests/c/real_time_timeout.c
Normal file
@@ -0,0 +1,6 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
int main()
|
||||
{
|
||||
|
||||
}
|
||||
8
judge/tests/c/success.c
Normal file
8
judge/tests/c/success.c
Normal file
@@ -0,0 +1,8 @@
|
||||
# include <stdio.h>
|
||||
int main()
|
||||
{
|
||||
int a, b;
|
||||
scanf("%d %d", &a, &b);
|
||||
printf("%d", a + b);
|
||||
return 0;
|
||||
}
|
||||
@@ -7,7 +7,7 @@ from account.views import (UserLoginAPIView, UsernameCheckAPIView, UserRegisterA
|
||||
UserChangePasswordAPIView, EmailCheckAPIView,
|
||||
UserAPIView, UserAdminAPIView)
|
||||
from announcement.views import AnnouncementAPIView, AnnouncementAdminAPIView
|
||||
from group.views import GroupAdminAPIView
|
||||
from group.views import GroupAdminAPIView, GroupMemberAdminAPIView, JoinGroupAPIView
|
||||
from admin.views import AdminTemplateView
|
||||
|
||||
from problem.views import ProblemAdminAPIView
|
||||
@@ -39,7 +39,11 @@ urlpatterns = [
|
||||
url(r'^problems/$', TemplateView.as_view(template_name="oj/problem/problem_list.html"), name="problem_list_page"),
|
||||
url(r'^admin/template/(?P<template_dir>\w+)/(?P<template_name>\w+).html', AdminTemplateView.as_view(), name="admin_template"),
|
||||
url(r'^api/admin/group/$', GroupAdminAPIView.as_view(), name="group_admin_api"),
|
||||
url(r'^api/admin/group_member/$', GroupMemberAdminAPIView.as_view(), name="group_member_admin_api"),
|
||||
url(r'^api/admin/group_join/$', JoinGroupAPIView.as_view(), name="group_join_admin_api"),
|
||||
url(r'^api/admin/problem/$', ProblemAdminAPIView.as_view(), name="problem_admin_api"),
|
||||
url(r'^api/admin/test_case_upload/$', TestCaseUploadAPIView.as_view(), name="test_case_upload_api"),
|
||||
url(r'^api/admin/tag/$', ProblemTagAdminAPIView.as_view(), name="problem_tag_admin_api"),
|
||||
url(r'^problem/(?P<problem_id>\d+)/my_solutions/', "problem.views.problem_my_solutions_list_page", name="problem_my_solutions_page"),
|
||||
url(r'^my_solution/(?P<solution_id>\d+)/$', "problem.views.my_solution", name="my_solution_page"),
|
||||
]
|
||||
|
||||
19
problem/migrations/0003_auto_20150810_2233.py
Normal file
19
problem/migrations/0003_auto_20150810_2233.py
Normal file
@@ -0,0 +1,19 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('problem', '0002_remove_problemtag_description'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='problem',
|
||||
old_name='sample',
|
||||
new_name='samples',
|
||||
),
|
||||
]
|
||||
@@ -6,7 +6,6 @@ from account.models import User
|
||||
|
||||
class ProblemTag(models.Model):
|
||||
name = models.CharField(max_length=30)
|
||||
# description = models.CharField(max_length=50)
|
||||
|
||||
class Meta:
|
||||
db_table = "problem_tag"
|
||||
@@ -18,7 +17,7 @@ class AbstractProblem(models.Model):
|
||||
# 问题描述 HTML 格式
|
||||
description = models.TextField()
|
||||
# 样例输入 可能会存储 json 格式的数据
|
||||
sample = models.TextField(blank=True)
|
||||
samples = models.TextField(blank=True)
|
||||
# 测试用例id 这个id 可以用来拼接得到测试用例的文件存储位置
|
||||
test_case_id = models.CharField(max_length=40)
|
||||
# 提示
|
||||
|
||||
@@ -14,7 +14,6 @@ class ProblemSampleSerializer(serializers.ListField):
|
||||
|
||||
class JSONField(serializers.Field):
|
||||
def to_representation(self, value):
|
||||
print value, type(value)
|
||||
return json.loads(value)
|
||||
|
||||
|
||||
@@ -22,18 +21,18 @@ class CreateProblemSerializer(serializers.Serializer):
|
||||
title = serializers.CharField(max_length=50)
|
||||
description = serializers.CharField(max_length=10000)
|
||||
# [{"input": "1 1", "output": "2"}]
|
||||
sample = ProblemSampleSerializer()
|
||||
samples = ProblemSampleSerializer()
|
||||
test_case_id = serializers.CharField(max_length=40)
|
||||
source = serializers.CharField(max_length=30, required=False, default=None)
|
||||
time_limit = serializers.IntegerField()
|
||||
memory_limit = serializers.IntegerField()
|
||||
difficulty = serializers.IntegerField()
|
||||
tags = serializers.ListField(child=serializers.IntegerField())
|
||||
tags = serializers.ListField(child=serializers.CharField(max_length=10))
|
||||
hint = serializers.CharField(max_length=3000, required=False, default=None)
|
||||
|
||||
|
||||
class ProblemSerializer(serializers.ModelSerializer):
|
||||
sample = JSONField()
|
||||
samples = JSONField()
|
||||
|
||||
class UserSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
@@ -56,7 +55,7 @@ class EditProblemSerializer(serializers.Serializer):
|
||||
memory_limit = serializers.IntegerField()
|
||||
difficulty = serializers.IntegerField()
|
||||
tags = serializers.ListField(child=serializers.IntegerField())
|
||||
sample = ProblemSampleSerializer()
|
||||
samples = ProblemSampleSerializer()
|
||||
hint = serializers.CharField(max_length=10000)
|
||||
visible = serializers.BooleanField()
|
||||
|
||||
|
||||
@@ -29,12 +29,12 @@ class ProblemAdminTest(APITestCase):
|
||||
|
||||
def test_success_problem(self):
|
||||
self.client.login(username="test", password="testaa")
|
||||
ProblemTag.objects.create(name="tag1", description="destag1")
|
||||
ProblemTag.objects.create(name="tag1")
|
||||
data = {"title": "title1",
|
||||
"description": "des1",
|
||||
"test_case_id": "1",
|
||||
"source": "source1",
|
||||
"sample": [{"input": "1 1", "output": "2"}],
|
||||
"samples": [{"input": "1 1", "output": "2"}],
|
||||
"time_limit": "100",
|
||||
"memory_limit": "1000",
|
||||
"difficulty": "1",
|
||||
@@ -52,13 +52,13 @@ class ProblemAdminTest(APITestCase):
|
||||
|
||||
def test_problem_does_not_exist(self):
|
||||
self.client.login(username="test", password="testaa")
|
||||
ProblemTag.objects.create(name="tag1", description="destag1")
|
||||
ProblemTag.objects.create(name="tag1")
|
||||
tags = ProblemTag.objects.filter(id__in=[1])
|
||||
problem = Problem.objects.create(title="title1",
|
||||
description="des1",
|
||||
test_case_id="1",
|
||||
source="source1",
|
||||
sample=[{"input": "1 1", "output": "2"}],
|
||||
samples=[{"input": "1 1", "output": "2"}],
|
||||
time_limit=100,
|
||||
memory_limit=1000,
|
||||
difficulty=1,
|
||||
@@ -70,7 +70,7 @@ class ProblemAdminTest(APITestCase):
|
||||
"description": "des1",
|
||||
"test_case_id": "1",
|
||||
"source": "source1",
|
||||
"sample": [{"input": "1 1", "output": "2"}],
|
||||
"samples": [{"input": "1 1", "output": "2"}],
|
||||
"time_limit": "100",
|
||||
"memory_limit": "1000",
|
||||
"difficulty": "1",
|
||||
@@ -82,14 +82,14 @@ class ProblemAdminTest(APITestCase):
|
||||
def test_success_edit_problem(self):
|
||||
self.client.login(username="test", password="testaa")
|
||||
self.client.login(username="test", password="testaa")
|
||||
ProblemTag.objects.create(name="tag1", description="destag1")
|
||||
ProblemTag.objects.create(name="tag2", description="destag2")
|
||||
ProblemTag.objects.create(name="tag1")
|
||||
ProblemTag.objects.create(name="tag2")
|
||||
tags = ProblemTag.objects.filter(id__in=[1])
|
||||
problem0 = Problem.objects.create(title="title1",
|
||||
description="des1",
|
||||
test_case_id="1",
|
||||
source="source1",
|
||||
sample=[{"input": "1 1", "output": "2"}],
|
||||
samples=[{"input": "1 1", "output": "2"}],
|
||||
time_limit=100,
|
||||
memory_limit=1000,
|
||||
difficulty=1,
|
||||
@@ -101,7 +101,7 @@ class ProblemAdminTest(APITestCase):
|
||||
"description": "des1",
|
||||
"test_case_id": "1",
|
||||
"source": "source1",
|
||||
"sample": [{"input": "1 1", "output": "2"}],
|
||||
"samples": [{"input": "1 1", "output": "2"}],
|
||||
"time_limit": "100",
|
||||
"memory_limit": "1000",
|
||||
"difficulty": "1",
|
||||
|
||||
@@ -34,6 +34,7 @@ class ProblemTagAdminAPIView(APIView):
|
||||
return error_response(serializer)
|
||||
|
||||
def get(self, request):
|
||||
return success_response(ProblemTagSerializer(ProblemTag.objects.all(), many=True).data)
|
||||
keyword = request.GET.get("keyword", None)
|
||||
if not keyword:
|
||||
return error_response(u"参数错误")
|
||||
@@ -44,8 +45,20 @@ class ProblemTagAdminAPIView(APIView):
|
||||
|
||||
|
||||
def problem_page(request, problem_id):
|
||||
# todo
|
||||
return render(request, "oj/problem/problem.html")
|
||||
try:
|
||||
problem = Problem.objects.get(id=problem_id)
|
||||
except Problem.DoesNotExist:
|
||||
return render(request, "utils/error.html", {"error": u"题目不存在"})
|
||||
return render(request, "oj/problem/problem.html", {"problem": problem, "samples": json.loads(problem.samples)})
|
||||
|
||||
|
||||
def problem_my_solutions_list_page(request, problem_id):
|
||||
return render(request, "oj/problem/my_solutions_list.html")
|
||||
|
||||
|
||||
def my_solution(request, solution_id):
|
||||
return render(request, "oj/problem/my_solution.html")
|
||||
|
||||
|
||||
|
||||
class ProblemAdminAPIView(APIView):
|
||||
@@ -63,15 +76,19 @@ class ProblemAdminAPIView(APIView):
|
||||
description=data["description"],
|
||||
test_case_id=data["test_case_id"],
|
||||
source=data["source"],
|
||||
sample=json.dumps(data["sample"]),
|
||||
samples=json.dumps(data["samples"]),
|
||||
time_limit=data["time_limit"],
|
||||
memory_limit=data["memory_limit"],
|
||||
difficulty=data["difficulty"],
|
||||
created_by=request.user,
|
||||
hint=data["hint"])
|
||||
|
||||
tags = ProblemTag.objects.filter(id__in=data["tags"])
|
||||
problem.tags.add(*tags)
|
||||
for tag in data["tags"]:
|
||||
try:
|
||||
tag = ProblemTag.objects.get(name=tag)
|
||||
except ProblemTag.DoesNotExist:
|
||||
tag = ProblemTag.objects.create(name=tag)
|
||||
problem.tags.add(tag)
|
||||
return success_response(ProblemSerializer(problem).data)
|
||||
else:
|
||||
return serializer_invalid_response(serializer)
|
||||
@@ -98,7 +115,7 @@ class ProblemAdminAPIView(APIView):
|
||||
problem.time_limit = data["time_limit"]
|
||||
problem.memory_limit = data["memory_limit"]
|
||||
problem.difficulty = data["difficulty"]
|
||||
problem.sample = json.dumps(data["sample"])
|
||||
problem.samples = json.dumps(data["samples"])
|
||||
problem.hint = data["hint"]
|
||||
problem.visible = data["visible"]
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
@import url("simditor/simditor.css");
|
||||
@import url("webuploader/webuploader.css");
|
||||
@import url("datetime_picker/bootstrap-datetimepicker.css");
|
||||
@import url("tagEditor/jquery.tag-editor.css");
|
||||
|
||||
#loading-gif{
|
||||
width: 40px;
|
||||
|
||||
@@ -64,18 +64,15 @@ require(["jquery", "avalon", "editor", "uploader", "bs_alert", "csrf", "tagEdito
|
||||
})
|
||||
.on("success.form.fv", function (e) {
|
||||
e.preventDefault();
|
||||
if (vm.test_case_id == '')
|
||||
{
|
||||
if (vm.test_case_id == '') {
|
||||
bs_alert("你还没有上传测试数据!");
|
||||
return;
|
||||
}
|
||||
if (vm.description == '')
|
||||
{
|
||||
if (vm.description == '') {
|
||||
bs_alert("题目描述不能为空!");
|
||||
return;
|
||||
}
|
||||
if (vm.hint == '')
|
||||
{
|
||||
if (vm.hint == '') {
|
||||
bs_alert("提示不能为空!");
|
||||
return;
|
||||
}
|
||||
@@ -88,33 +85,30 @@ require(["jquery", "avalon", "editor", "uploader", "bs_alert", "csrf", "tagEdito
|
||||
test_case_id: vm.test_case_id,
|
||||
hint: vm.hint,
|
||||
source: vm.source,
|
||||
tags: [],
|
||||
tags: $("#tags").tagEditor("getTags")[0].tags,
|
||||
difficulty: vm.difficulty
|
||||
};
|
||||
if (vm.samples.length == 0)
|
||||
{
|
||||
if (vm.samples.length == 0) {
|
||||
bs_alert("请至少添加一组样例!");
|
||||
return;
|
||||
}
|
||||
var tags = $("#tags").tagEditor("getTags")[0].tags;
|
||||
if (tags.length == 0)
|
||||
{
|
||||
|
||||
if (tags.length == 0) {
|
||||
bs_alert("请至少添加一个标签,这将有利于用户发现你的题目!");
|
||||
return;
|
||||
}
|
||||
for (key in vm.samples.length) {
|
||||
ajaxData.samples.push({input: vm.samples[key].input, output: vm.samples[key].output});
|
||||
|
||||
for (var i = 0; i < vm.samples.$model.length; i++) {
|
||||
ajaxData.samples.push({input: vm.samples.$model[i].input, output: vm.samples.$model[i].output});
|
||||
}
|
||||
for (key in tags) {
|
||||
ajaxData.tags.push(tags[key].tag);
|
||||
}
|
||||
console.log(ajaxData);
|
||||
|
||||
$.ajax({
|
||||
beforeSend: csrfHeader,
|
||||
url: "/api/admin/problem/",
|
||||
dataType: "json",
|
||||
data:ajaxData,
|
||||
data: JSON.stringify(ajaxData),
|
||||
method: "post",
|
||||
contentType: "application/json",
|
||||
success: function (data) {
|
||||
if (!data.code) {
|
||||
bs_alert("successful!");
|
||||
@@ -188,8 +182,8 @@ require(["jquery", "avalon", "editor", "uploader", "bs_alert", "csrf", "tagEdito
|
||||
if (!data.code) {
|
||||
tagList = data.data;
|
||||
completeList = [];
|
||||
for (key in tagList) {
|
||||
completeList.push(tagList[key].name);
|
||||
for (var i = 0; i < tagList.length; i++) {
|
||||
completeList.push(tagList[i].name);
|
||||
}
|
||||
$("#tags").tagEditor({
|
||||
autocomplete: {
|
||||
|
||||
@@ -22,10 +22,12 @@ require(["jquery", "code_mirror"], function ($, code_mirror) {
|
||||
setTimeout(
|
||||
function () {
|
||||
$("#a").animate({opacity: '1'})
|
||||
}
|
||||
,
|
||||
3);
|
||||
}, 3);
|
||||
});
|
||||
|
||||
$("#show-more-btn").click(function(){
|
||||
$(".hide").attr("class", "problem-section");
|
||||
$("#show-more-btn").hide();
|
||||
})
|
||||
|
||||
});
|
||||
@@ -12,7 +12,7 @@ var require = {
|
||||
validation: "utils/validation",
|
||||
code_mirror: "utils/code_mirror",
|
||||
bs_alert: "utils/bs_alert",
|
||||
submit_code: "app/oj/problem/submit_code",
|
||||
problem: "app/oj/problem/problem",
|
||||
contest: "app/admin/contest/contest",
|
||||
csrf: "utils/csrf",
|
||||
admin: "app/admin/admin",
|
||||
|
||||
@@ -1,98 +1,109 @@
|
||||
<div ms-controller="add_problem" class="col-md-9">
|
||||
<form id="add-problem-form">
|
||||
<div class="col-md-12">
|
||||
<div class="form-group col-md-6">
|
||||
<label>题目标题</label>
|
||||
<input type="text" name="title" class="form-control" ms-duplex="title">
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label>来源</label>
|
||||
<input type="text" name="source" class="form-control" ms-duplex="source">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>题目描述</label>
|
||||
<textarea id="problemDescription" placeholder="这里输入内容" autofocus ms-duplex="description"></textarea>
|
||||
<small ms-visible="description==''" style="color:red">请填写题目描述</small>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>提示</label>
|
||||
<textarea id="hint" placeholder="这里输入内容" ms-duplex="hint"></textarea>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<div class="form-group"><label>时间限制(ms)</label>
|
||||
<input type="number" name="cpu" class="form-control" ms-duplex="cpu">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="form-group"><label>内存限制(MB)</label>
|
||||
<input type="number" name="memory" class="form-control" ms-duplex="memory">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="form-group"><label>难度</label>
|
||||
<input type="number" name="difficulty" class="form-control" ms-duplex="difficulty">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3 form-group">
|
||||
<label>前台是否可见</label><br>
|
||||
<label><input type="checkbox" ms-duplex-checked="visible">
|
||||
<small> 可见</small>
|
||||
</label>
|
||||
</div>
|
||||
<div id="tag" class="col-md-12">
|
||||
<label>标签</label><br>
|
||||
<input type="text" id="tags">
|
||||
</div>
|
||||
<div class="col-md-12"><br>
|
||||
<label>样例</label>
|
||||
<a href="javascript:void(0)" class="btn btn-primary btn-sm" ms-click="add_sample()">添加</a>
|
||||
<div class="form-group col-md-12">
|
||||
<label>题目标题</label>
|
||||
<input type="text" name="title" class="form-control" ms-duplex="title">
|
||||
</div>
|
||||
|
||||
<div class="sample">
|
||||
<div class="panel panel-default sample-panel" ms-repeat-sample="samples">
|
||||
<div class="panel-heading">
|
||||
<span class="panel-title">样例{{$index + 1}}</span>
|
||||
<a href="javascript:void(0)" class="btn btn-primary btn-sm"
|
||||
ms-click="toggle_sample(sample)">
|
||||
{{getBtnContent(sample)}}
|
||||
</a>
|
||||
<a href="javascript:void(0)" class="btn btn-danger btn-sm"
|
||||
ms-click="del_sample(sample)">
|
||||
删除
|
||||
</a>
|
||||
</div>
|
||||
<div class="panel-body row" ms-visible="sample.visible">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label>样例输入</label>
|
||||
<textarea class="form-control" rows="5" ms-duplex="sample.input"></textarea>
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label>题目描述</label>
|
||||
<textarea id="problemDescription" placeholder="这里输入内容" autofocus ms-duplex="description"></textarea>
|
||||
<small ms-visible="description==''" style="color:red">请填写题目描述</small>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-md-3">
|
||||
<div class="form-group"><label>时间限制(ms)</label>
|
||||
<input type="number" name="cpu" class="form-control" ms-duplex="cpu">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="form-group"><label>内存限制(MB)</label>
|
||||
<input type="number" name="memory" class="form-control" ms-duplex="memory">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="form-group"><label>难度</label>
|
||||
<input type="number" name="difficulty" class="form-control" ms-duplex="difficulty">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3 form-group">
|
||||
<label>前台是否可见</label><br>
|
||||
<label><input type="checkbox" ms-duplex-checked="visible">
|
||||
<small> 可见</small>
|
||||
</label>
|
||||
</div>
|
||||
<div id="tag" class="col-md-12">
|
||||
<label>标签</label><br>
|
||||
<input type="text" id="tags">
|
||||
</div>
|
||||
<div class="col-md-12"><br>
|
||||
<label>样例</label>
|
||||
<a href="javascript:void(0)" class="btn btn-primary btn-sm" ms-click="add_sample()">添加</a>
|
||||
|
||||
<div class="sample">
|
||||
<div class="panel panel-default sample-panel" ms-repeat-sample="samples">
|
||||
<div class="panel-heading">
|
||||
<span class="panel-title">样例{{$index + 1}}</span>
|
||||
<a href="javascript:void(0)" class="btn btn-primary btn-sm"
|
||||
ms-click="toggle_sample(sample)">
|
||||
{{ getBtnContent(sample)}}
|
||||
</a>
|
||||
<a href="javascript:void(0)" class="btn btn-danger btn-sm"
|
||||
ms-click="del_sample(sample)">
|
||||
删除
|
||||
</a>
|
||||
</div>
|
||||
<div class="panel-body row" ms-visible="sample.visible">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label>样例输入</label>
|
||||
<textarea class="form-control" rows="5" ms-duplex="sample.input"></textarea>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label>样例输出</label>
|
||||
<textarea class="form-control" rows="5" ms-duplex="sample.output"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label>样例输出</label>
|
||||
<textarea class="form-control" rows="5" ms-duplex="sample.output"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12"><br>
|
||||
<label>测试数据</label><br>
|
||||
<small class="text-info">请将所有测试用例打包在一个文件中上传,所有文件要在压缩包的根目录,且输入输出文件名要以从1开始连续数字标识要对应例如:<br>
|
||||
1.in 1.out 2.in 2.out</small>
|
||||
<table class="table table-striped" ms-visible="uploadSuccess">
|
||||
<tr><td>编号</td><td>输入文件名</td><td>输出文件名</td></tr>
|
||||
<tr ms-repeat="testCaseList"><td>{{$index}}</td><td>{{el.input}}</td><td>{{el.output}}</td></tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<div id="testCaseFile">选择文件</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12"><br>
|
||||
<label>测试数据</label><br>
|
||||
<small class="text-info">请将所有测试用例打包在一个文件中上传,所有文件要在压缩包的根目录,且输入输出文件名要以从1开始连续数字标识要对应例如:<br>
|
||||
1.in 1.out 2.in 2.out
|
||||
</small>
|
||||
<table class="table table-striped" ms-visible="uploadSuccess">
|
||||
<tr>
|
||||
<td>编号</td>
|
||||
<td>输入文件名</td>
|
||||
<td>输出文件名</td>
|
||||
</tr>
|
||||
<tr ms-repeat="testCaseList">
|
||||
<td>{{$index + 1}}</td>
|
||||
<td>{{ el.input }}</td>
|
||||
<td>{{ el.output }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<div id="testCaseFile">选择文件</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label>提示</label>
|
||||
<textarea id="hint" placeholder="这里输入内容" ms-duplex="hint"></textarea>
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label>来源</label>
|
||||
<input type="text" name="source" class="form-control" ms-duplex="source">
|
||||
</div>
|
||||
|
||||
<div class="col-md-12">
|
||||
<input type="submit" class="btn btn-success btn-lg" value="发布题目" id="submitBtn">
|
||||
</div>
|
||||
@@ -100,4 +111,3 @@
|
||||
</div>
|
||||
|
||||
<script src="/static/js/app/admin/problem/add_problem.js"></script>
|
||||
<link href="/static/css/tagEditor/jquery.tag-editor.css" rel="stylesheet">
|
||||
31
template/oj/problem/my_solution.html
Normal file
31
template/oj/problem/my_solution.html
Normal file
@@ -0,0 +1,31 @@
|
||||
{% extends 'oj_base.html' %}
|
||||
|
||||
{% block body %}
|
||||
|
||||
<div class="container main">
|
||||
<ul class="nav nav-tabs nav-tabs-google">
|
||||
<li role="presentation">
|
||||
<a href="problem.html">题目</a></li>
|
||||
<li role="presentation" class="active"><a href="my_solutions_list.html">我的提交</a></li>
|
||||
<li role="presentation"><a href="#">讨论</a></li>
|
||||
</ul>
|
||||
<h2 class="text-center">Battle Over Cities - Hard Version</h2>
|
||||
<p class="text-muted text-center">cpu: 1000ms 内存: 256M</p>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<h4>运行结果:<span class="text-success">Accepted</span></h4>
|
||||
<p>cpu: 1000ms 内存: 256M 语言:python</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="code-field">
|
||||
<textarea id="code-editor">
|
||||
#include <stdio.h>
|
||||
int main()
|
||||
{
|
||||
printf("Hello world");
|
||||
return 0;
|
||||
}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
53
template/oj/problem/my_solutions_list.html
Normal file
53
template/oj/problem/my_solutions_list.html
Normal file
@@ -0,0 +1,53 @@
|
||||
{% extends 'oj_base.html' %}
|
||||
|
||||
{% block body %}
|
||||
|
||||
<div class="container main">
|
||||
<ul class="nav nav-tabs nav-tabs-google">
|
||||
<li role="presentation">
|
||||
<a href="/problem/1/">题目</a></li>
|
||||
<li role="presentation" class="active"><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>
|
||||
<table class="table table-bordered">
|
||||
<thead>
|
||||
<tr class=""success>
|
||||
<th>#</th>
|
||||
<th>提交时间</th>
|
||||
<th>结果</th>
|
||||
<th>运行时间</th>
|
||||
<th>运行内存</th>
|
||||
<th>语言</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="warning">
|
||||
<th scope="row">1</th>
|
||||
<td>1</td>
|
||||
<td>Error Format</td>
|
||||
<td>3</td>
|
||||
<td>3</td>
|
||||
<td>3</td>
|
||||
</tr>
|
||||
<tr class="danger">
|
||||
<th scope="row">2</th>
|
||||
<td>Wrong</td>
|
||||
<td>Wrong Answer</td>
|
||||
<td>@fat</td>
|
||||
<td>3</td>
|
||||
<td>3</td>
|
||||
</tr>
|
||||
<tr class="success">
|
||||
<th scope="row">3</th>
|
||||
<td>Larry</td>
|
||||
<td>Accepted</td>
|
||||
<td>@twitter</td>
|
||||
<td>3</td>
|
||||
<td>3</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -1,93 +1,115 @@
|
||||
{% extends 'oj_base.html' %}
|
||||
|
||||
{% block body %}
|
||||
<div class="container main">
|
||||
<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>
|
||||
<div class="container main">
|
||||
<ul class="nav nav-tabs nav-tabs-google">
|
||||
<li role="presentation" class="active">
|
||||
<a href="problem.html">题目</a></li>
|
||||
<li role="presentation"><a href="/problem/1/my_solutions/">我的提交</a></li>
|
||||
</ul>
|
||||
<h2 class="text-center">{{ problem.title }}</h2>
|
||||
|
||||
<p class="text-muted text-center">cpu: 1000ms 内存: 256M</p>
|
||||
<p class="text-muted text-center">发布时间: {{ problem.create_time }} CPU: {{ problem.time_limit }}ms 内存: {{ problem.memory_limit }}M</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 class="problem-section">
|
||||
<label class="problem-label">描述</label>
|
||||
|
||||
</div>
|
||||
<hr>
|
||||
<div class="result">
|
||||
<div class="alert alert-success" role="alert" id="a" style="opacity: 0">
|
||||
<div class="alert-link">
|
||||
Accepted! 时间:378ms 内存: 35m
|
||||
<a href="#">查看详情</a>
|
||||
<p class="problem-detail">{{ problem.description|safe }}</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>
|
||||
{% for item in samples %}
|
||||
<div class="problem-section">
|
||||
<label class="problem-label">样例输入1</label>
|
||||
<pre>
|
||||
{{ item.input }}</pre>
|
||||
|
||||
</div>
|
||||
<div class="problem-section">
|
||||
|
||||
<label class="problem-label">样例输出1</label>
|
||||
<pre>
|
||||
{{ item.output }}</pre>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<div>
|
||||
<button type="button" id="show-more-btn" class="btn btn-info btn-sm">查看隐藏信息</button>
|
||||
</div>
|
||||
{% if problem.hind %}
|
||||
<div class="problem-section hide">
|
||||
<label class="problem-label">提示</label>
|
||||
|
||||
<p class="problem-detail">{{ problem.hint|safe }}</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="problem-section hide">
|
||||
<label class="problem-label">标签</label>
|
||||
|
||||
<p class="problem-detail">
|
||||
{% for tag in problem.tags.all %}
|
||||
<span class="label label-success">{{ tag.name }}</span>
|
||||
{% endfor %}
|
||||
</p>
|
||||
</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 class="alert alert-danger" role="alert">
|
||||
<div class="alert-link">Wrong Answer!</div>
|
||||
|
||||
<div id="code-field">
|
||||
<label class="problem-label">提交代码</label>
|
||||
<textarea id="code-editor"></textarea>
|
||||
</div>
|
||||
<div class="alert alert-danger" role="alert">
|
||||
<div class="alert-link">Compile Error!</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>
|
||||
<div class="alert alert-warning" role="alert">
|
||||
<div class="alert-link">Error Format!</div>
|
||||
<hr>
|
||||
<div class="result">
|
||||
<div class="alert alert-success" role="alert" id="a" style="opacity: 0">
|
||||
<div class="alert-link">
|
||||
Accepted! 时间:378ms 内存: 35m
|
||||
<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>
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% block js_block %}
|
||||
<script src="/static/js/app/oj/problem/submit_code.js"></script>
|
||||
<script src="/static/js/app/oj/problem/problem.js"></script>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user