mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2025-11-04 14:49:58 +08:00
修改比赛ranklist页面样式,以及计算方式,为了便于缓存,稍微修改了显示的样式
This commit is contained in:
parent
49b4068757
commit
de6ed31216
@ -356,7 +356,6 @@ def contest_list_page(request, page=1):
|
|||||||
if request.user.is_authenticated and join:
|
if request.user.is_authenticated and join:
|
||||||
contests = contests.filter(Q(contest_type__in=[1, 2]) | Q(groups__in=request.user.group_set.all())). \
|
contests = contests.filter(Q(contest_type__in=[1, 2]) | Q(groups__in=request.user.group_set.all())). \
|
||||||
filter(end_time__gt=datetime.datetime.now(), start_time__lt=datetime.datetime.now())
|
filter(end_time__gt=datetime.datetime.now(), start_time__lt=datetime.datetime.now())
|
||||||
|
|
||||||
paginator = Paginator(contests, 20)
|
paginator = Paginator(contests, 20)
|
||||||
try:
|
try:
|
||||||
current_page = paginator.page(int(page))
|
current_page = paginator.page(int(page))
|
||||||
@ -407,10 +406,21 @@ def contest_rank_page(request, contest_id):
|
|||||||
# 这个人所有的提交
|
# 这个人所有的提交
|
||||||
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)
|
||||||
result[i]["submissions"] = {}
|
result[i]["submissions"] = {}
|
||||||
for item in submissions:
|
result[i]["problems"] = []
|
||||||
result[i]["submissions"][item.problem_id] = item
|
for problem in contest_problems:
|
||||||
|
try:
|
||||||
|
status = submissions.get(problem=problem)
|
||||||
|
result[i]["problems"].append({
|
||||||
|
"first_achieved":status.first_achivevd,
|
||||||
|
"ac": status.ac,
|
||||||
|
"failed_number": status.total_submission_number,
|
||||||
|
"ac_time": status.ac_time})
|
||||||
|
if status.ac:
|
||||||
|
result[i]["problem"][-1].failed_number -= 1
|
||||||
|
except ContestSubmission.DoesNotExist:
|
||||||
|
result[i]["problems"].append({})
|
||||||
result[i]["total_ac"] = submissions.filter(ac=True).count()
|
result[i]["total_ac"] = submissions.filter(ac=True).count()
|
||||||
result[i]["user"] = User.objects.get(id=result[i]["user_id"])
|
result[i]["username"] = User.objects.get(id=result[i]["user_id"]).username
|
||||||
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"]
|
||||||
result = sorted(result, cmp=_cmp, reverse=True)
|
result = sorted(result, cmp=_cmp, reverse=True)
|
||||||
r.set("contest_rank_" + contest_id, json.dumps(list(result)))
|
r.set("contest_rank_" + contest_id, json.dumps(list(result)))
|
||||||
|
|||||||
@ -41,16 +41,33 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody class="rank">
|
||||||
{% for item in result %}
|
{% for item in result %}
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">{{ forloop.counter }}</th>
|
<th scope="row">{{ forloop.counter }}</th>
|
||||||
<td>{{ item.user.username }}</td>
|
<td>{{ item.username }}</td>
|
||||||
<td>{{ item.total_ac }} / {{ item.total_submit }}</td>
|
<td>{{ item.total_ac }} / {{ item.total_submit }}</td>
|
||||||
<td>{% if item.total_time %}{{ item.total_time }} min{% else %}--{% endif %}</td>
|
<td>{% if item.total_time %}{{ item.total_time }} min{% else %}--{% endif %}</td>
|
||||||
{% for problem in contest_problems %}
|
{% for problem in item.problem %}
|
||||||
<td class="{% submission_problem_result_class problem item.submissions %}">
|
<td class="
|
||||||
{% submission_problem problem item.submissions %}
|
{% if problem %}
|
||||||
|
{% if problem.ac %}
|
||||||
|
{% if problem.first_achieve %}
|
||||||
|
first-achieved
|
||||||
|
{% else %}
|
||||||
|
ac
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
failed
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
">
|
||||||
|
{% if problem.ac %}
|
||||||
|
{{ problem.ac_time }}min
|
||||||
|
{% endif %}
|
||||||
|
{% if problem.failed_number %}
|
||||||
|
(-{{ problem.failed_number }})
|
||||||
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user