mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2024-09-21 08:23:20 +00:00
update utils.py
添加了把比赛题目添加到前台题目列表的脚本工具
This commit is contained in:
parent
f1684323f2
commit
3f570f0b33
@ -1,6 +1,6 @@
|
||||
import django
|
||||
from contest.models import *
|
||||
|
||||
from problem.models import *
|
||||
django.setup()
|
||||
|
||||
|
||||
@ -27,3 +27,39 @@ def add_exist_problem_to_contest(problems, contest_id):
|
||||
memory_limit=problem.memory_limit)
|
||||
i += 1
|
||||
return
|
||||
|
||||
def add_contest_problem_to_problem(contest_id):
|
||||
try:
|
||||
contest = Contest.objects.get(pk=contest_id)
|
||||
except Contest.DoesNotExist:
|
||||
print "Contest Doesn't Exist!"
|
||||
return
|
||||
#Get all problems in this contest
|
||||
problems = ContestProblem.objects.filter(contest=contest)
|
||||
|
||||
#get a tag
|
||||
try:
|
||||
tag = ProblemTag.objects.get(name=contest.title)
|
||||
except ProblemTag.DoesNotExist:
|
||||
tag = ProblemTag.objects.create(name=tag)
|
||||
|
||||
#for each problem
|
||||
for problem in problems:
|
||||
print "Add problem to problem list:"
|
||||
print problem.title
|
||||
p = Problem(title=problem.title,
|
||||
description=problem.description,
|
||||
input_description=problem.input_description,
|
||||
output_description=problem.output_description,
|
||||
samples=problem.samples,
|
||||
test_case_id=problem.test_case_id,
|
||||
hint=problem.hint,
|
||||
created_by=problem.created_by,
|
||||
time_limit=problem.time_limit,
|
||||
memory_limit=problem.memory_limit,
|
||||
visible = False,
|
||||
difficulty = 0,
|
||||
source = contest.title)
|
||||
p.tags.add(tag)
|
||||
p.save()
|
||||
return
|
Loading…
Reference in New Issue
Block a user