修改了比赛题目列表中表示题目状态的标识(AC/正在进行/没开始)
This commit is contained in:
@@ -323,11 +323,24 @@ def contest_problems_list_page(request, contest_id):
|
|||||||
比赛所有题目的列表页
|
比赛所有题目的列表页
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
contest_problems = ContestProblem.objects.filter(contest=Contest.objects.get(id=contest_id)).order_by("sort_index")
|
contest = Contest.objects.get(id=contest_id)
|
||||||
except Contest.DoesNotExist:
|
except Contest.DoesNotExist:
|
||||||
return error_page(request, u"比赛题目不存在")
|
return error_page(request, u"比赛不存在")
|
||||||
|
|
||||||
|
contest_problems = ContestProblem.objects.filter(contest=contest).order_by("sort_index")
|
||||||
|
submissions = ContestSubmission.objects.filter(user=request.user, contest=contest)
|
||||||
|
state = {}
|
||||||
|
for item in submissions:
|
||||||
|
state[item.problem_id] = item.ac
|
||||||
|
for item in contest_problems:
|
||||||
|
if item.id in state:
|
||||||
|
item.ac = state[item.id].ac
|
||||||
|
else:
|
||||||
|
item.ac = 0
|
||||||
|
|
||||||
# 右侧的公告列表
|
# 右侧的公告列表
|
||||||
announcements = Announcement.objects.filter(is_global=True, visible=True).order_by("-create_time")
|
announcements = Announcement.objects.filter(is_global=True, visible=True).order_by("-create_time")
|
||||||
|
|
||||||
return render(request, "oj/contest/contest_problems_list.html", {"contest_problems": contest_problems,
|
return render(request, "oj/contest/contest_problems_list.html", {"contest_problems": contest_problems,
|
||||||
"announcements": announcements,
|
"announcements": announcements,
|
||||||
"contest": {"id": contest_id}})
|
"contest": {"id": contest_id}})
|
||||||
@@ -379,7 +392,6 @@ def contest_list_page(request, page=1):
|
|||||||
"join": join})
|
"join": join})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def _cmp(x, y):
|
def _cmp(x, y):
|
||||||
if x["total_ac"] > y["total_ac"]:
|
if x["total_ac"] > y["total_ac"]:
|
||||||
return 1
|
return 1
|
||||||
@@ -396,7 +408,8 @@ def _cmp(x, y):
|
|||||||
def contest_rank_page(request, contest_id):
|
def contest_rank_page(request, contest_id):
|
||||||
contest = Contest.objects.get(id=contest_id)
|
contest = Contest.objects.get(id=contest_id)
|
||||||
contest_problems = ContestProblem.objects.filter(contest=contest).order_by("sort_index")
|
contest_problems = ContestProblem.objects.filter(contest=contest).order_by("sort_index")
|
||||||
result = ContestSubmission.objects.filter(contest=contest).values("user_id").annotate(total_submit=Sum("total_submission_number"))
|
result = ContestSubmission.objects.filter(contest=contest).values("user_id").annotate(
|
||||||
|
total_submit=Sum("total_submission_number"))
|
||||||
for i in range(0, len(result)):
|
for i in range(0, len(result)):
|
||||||
# 这个人所有的提交
|
# 这个人所有的提交
|
||||||
submissions = ContestSubmission.objects.filter(user_id=result[i]["user_id"], contest_id=contest_id)
|
submissions = ContestSubmission.objects.filter(user_id=result[i]["user_id"], contest_id=contest_id)
|
||||||
@@ -407,11 +420,6 @@ def contest_rank_page(request, contest_id):
|
|||||||
result[i]["user"] = User.objects.get(id=result[i]["user_id"])
|
result[i]["user"] = User.objects.get(id=result[i]["user_id"])
|
||||||
result[i]["total_time"] = submissions.filter(ac=True).aggregate(total_time=Sum("total_time"))["total_time"]
|
result[i]["total_time"] = submissions.filter(ac=True).aggregate(total_time=Sum("total_time"))["total_time"]
|
||||||
|
|
||||||
|
|
||||||
return render(request, "oj/contest/contest_rank.html",
|
return render(request, "oj/contest/contest_rank.html",
|
||||||
{"contest": contest, "contest_problems": contest_problems, "result": sorted(result, cmp=_cmp, reverse=True)})
|
{"contest": contest, "contest_problems": contest_problems,
|
||||||
|
"result": sorted(result, cmp=_cmp, reverse=True)})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,22 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
{% for item in contest_problems %}
|
{% for item in contest_problems %}
|
||||||
<tr>
|
<tr>
|
||||||
<th><span class="glyphicon glyphicon-ok ac-flag"></span></th>
|
<th>
|
||||||
|
|
||||||
|
<span class="glyphicon
|
||||||
|
{% if item.ac %}
|
||||||
|
{% ifequal item.ac 1%}
|
||||||
|
glyphicon-ok ac-flag
|
||||||
|
{% else %}
|
||||||
|
glyphicon-arrow-right ac-flag
|
||||||
|
{% endifequal %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"></span>
|
||||||
|
|
||||||
|
</th>
|
||||||
<th scope="row">
|
<th scope="row">
|
||||||
<a href="/contest/{{ item.contest.id }}/problem/{{ item.id }}/" target="_blank">{{ item.sort_index }}</a>
|
<a href="/contest/{{ item.contest.id }}/problem/{{ item.id }}/" target="_blank">{{ item.sort_index }}</a>
|
||||||
</th>
|
</th>
|
||||||
|
|||||||
Reference in New Issue
Block a user