mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2025-11-04 14:49:58 +08:00
修改用户题目 ac 状态的存储方式
This commit is contained in:
parent
7eea999277
commit
44d094f19c
@ -334,18 +334,6 @@ def contest_problems_list_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")
|
||||||
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:
|
|
||||||
if state[item.id]:
|
|
||||||
item.state = 1
|
|
||||||
else:
|
|
||||||
item.state = 2
|
|
||||||
else:
|
|
||||||
item.state = 0
|
|
||||||
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,
|
||||||
"contest": {"id": contest_id}})
|
"contest": {"id": contest_id}})
|
||||||
|
|
||||||
|
|||||||
@ -82,5 +82,10 @@ class MessageQueue(object):
|
|||||||
contest_problem.total_accepted_number += 1
|
contest_problem.total_accepted_number += 1
|
||||||
contest_problem.save()
|
contest_problem.save()
|
||||||
|
|
||||||
|
problems_status = user.problems_status
|
||||||
|
problems_status["contest_problems"][str(contest_problem.id)] = 1
|
||||||
|
user.problems_status = problems_status
|
||||||
|
user.save()
|
||||||
|
|
||||||
logger.debug("Start message queue")
|
logger.debug("Start message queue")
|
||||||
MessageQueue().listen_task()
|
MessageQueue().listen_task()
|
||||||
|
|||||||
@ -305,15 +305,11 @@ def problem_list_page(request, page=1):
|
|||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if request.user.is_authenticated():
|
|
||||||
problems_status = json.loads(request.user.problems_status)
|
|
||||||
else:
|
|
||||||
problems_status = {}
|
|
||||||
# 右侧标签列表 按照关联的题目的数量排序 排除题目数量为0的
|
# 右侧标签列表 按照关联的题目的数量排序 排除题目数量为0的
|
||||||
tags = ProblemTag.objects.annotate(problem_number=Count("problem")).filter(problem_number__gt=0).order_by("-problem_number")
|
tags = ProblemTag.objects.annotate(problem_number=Count("problem")).filter(problem_number__gt=0).order_by("-problem_number")
|
||||||
|
|
||||||
return render(request, "oj/problem/problem_list.html",
|
return render(request, "oj/problem/problem_list.html",
|
||||||
{"problems": current_page, "page": int(page),
|
{"problems": current_page, "page": int(page),
|
||||||
"previous_page": previous_page, "next_page": next_page,
|
"previous_page": previous_page, "next_page": next_page,
|
||||||
"keyword": keyword, "tag": tag_text,"problems_status": problems_status,
|
"keyword": keyword, "tag": tag_text,
|
||||||
"tags": tags, "difficulty_order": difficulty_order})
|
"tags": tags, "difficulty_order": difficulty_order})
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user