Merge branch 'dev' into virusdefender-dev
* dev: 修改后端problem中的的命名规范 前端创建题目界面增加输入描述和输出描述 后端增加输入描述与输出描述两个字段,并修改其相关的后端内容
This commit is contained in:
26
problem/migrations/0004_auto_20150813_1459.py
Normal file
26
problem/migrations/0004_auto_20150813_1459.py
Normal file
@@ -0,0 +1,26 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('problem', '0003_auto_20150810_2233'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='problem',
|
||||
name='description_input',
|
||||
field=models.CharField(default='hello', max_length=10000),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='problem',
|
||||
name='description_output',
|
||||
field=models.CharField(default='hello', max_length=10000),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
||||
24
problem/migrations/0005_auto_20150813_1807.py
Normal file
24
problem/migrations/0005_auto_20150813_1807.py
Normal file
@@ -0,0 +1,24 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('problem', '0004_auto_20150813_1459'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='problem',
|
||||
old_name='description_input',
|
||||
new_name='input_description',
|
||||
),
|
||||
migrations.RenameField(
|
||||
model_name='problem',
|
||||
old_name='description_output',
|
||||
new_name='output_description',
|
||||
),
|
||||
]
|
||||
@@ -16,6 +16,10 @@ class AbstractProblem(models.Model):
|
||||
title = models.CharField(max_length=50)
|
||||
# 问题描述 HTML 格式
|
||||
description = models.TextField()
|
||||
# 输入描述
|
||||
input_description = models.CharField(max_length=10000)
|
||||
# 输出描述
|
||||
output_description = models.CharField(max_length=10000)
|
||||
# 样例输入 可能会存储 json 格式的数据
|
||||
samples = models.TextField(blank=True)
|
||||
# 测试用例id 这个id 可以用来拼接得到测试用例的文件存储位置
|
||||
|
||||
@@ -20,6 +20,8 @@ class JSONField(serializers.Field):
|
||||
class CreateProblemSerializer(serializers.Serializer):
|
||||
title = serializers.CharField(max_length=50)
|
||||
description = serializers.CharField(max_length=10000)
|
||||
input_description = serializers.CharField(max_length=10000)
|
||||
output_description = serializers.CharField(max_length=10000)
|
||||
# [{"input": "1 1", "output": "2"}]
|
||||
samples = ProblemSampleSerializer()
|
||||
test_case_id = serializers.CharField(max_length=40)
|
||||
@@ -49,6 +51,8 @@ class EditProblemSerializer(serializers.Serializer):
|
||||
id = serializers.IntegerField()
|
||||
title = serializers.CharField(max_length=50)
|
||||
description = serializers.CharField(max_length=10000)
|
||||
input_description = serializers.CharField(max_length=10000)
|
||||
output_description = serializers.CharField(max_length=10000)
|
||||
test_case_id = serializers.CharField(max_length=40)
|
||||
source = serializers.CharField(max_length=30)
|
||||
time_limit = serializers.IntegerField()
|
||||
|
||||
@@ -17,8 +17,10 @@ class ProblemPageTest(TestCase):
|
||||
class ProblemAdminTest(APITestCase):
|
||||
def _create_data(self, problem_id, visible, tags):
|
||||
data = {"id": problem_id,
|
||||
"title": "title1",
|
||||
"description": "des1",
|
||||
"title": "title0",
|
||||
"description": "description0",
|
||||
"input_description": "input_description0",
|
||||
"output_description": "output_description0",
|
||||
"test_case_id": "1",
|
||||
"source": "source1",
|
||||
"samples": [{"input": "1 1", "output": "2"}],
|
||||
@@ -40,7 +42,9 @@ class ProblemAdminTest(APITestCase):
|
||||
ProblemTag.objects.create(name="tag1")
|
||||
ProblemTag.objects.create(name="tag2")
|
||||
self.problem = Problem.objects.create(title="title1",
|
||||
description="des1",
|
||||
description="description1",
|
||||
input_description="input1_description",
|
||||
output_description="output1_description",
|
||||
test_case_id="1",
|
||||
source="source1",
|
||||
samples=[{"input": "1 1", "output": "2"}],
|
||||
@@ -57,8 +61,10 @@ class ProblemAdminTest(APITestCase):
|
||||
self.assertEqual(response.data["code"], 1)
|
||||
|
||||
def test_release_problem_successfully(self):
|
||||
data = {"title": "title1",
|
||||
"description": "des1",
|
||||
data = {"title": "title2",
|
||||
"description": "description2",
|
||||
"input_description": "input_description2",
|
||||
"output_description": "output_description2",
|
||||
"test_case_id": "1",
|
||||
"source": "source1",
|
||||
"samples": [{"input": "1 1", "output": "2"}],
|
||||
|
||||
@@ -69,6 +69,8 @@ class ProblemAdminAPIView(APIView):
|
||||
data = serializer.data
|
||||
problem = Problem.objects.create(title=data["title"],
|
||||
description=data["description"],
|
||||
input_description=data["input_description"],
|
||||
output_description=data["output_description"],
|
||||
test_case_id=data["test_case_id"],
|
||||
source=data["source"],
|
||||
samples=json.dumps(data["samples"]),
|
||||
@@ -105,6 +107,8 @@ class ProblemAdminAPIView(APIView):
|
||||
|
||||
problem.title = data["title"]
|
||||
problem.description = data["description"]
|
||||
problem.input_description = data["input_description"]
|
||||
problem.output_description = data["output_description"]
|
||||
problem.test_case_id = data["test_case_id"]
|
||||
problem.source = data["source"]
|
||||
problem.time_limit = data["time_limit"]
|
||||
|
||||
Reference in New Issue
Block a user