Skip to content

Commit

Permalink
Ranking (#513)
Browse files Browse the repository at this point in the history
  • Loading branch information
masnn0 authored Jun 26, 2020
1 parent 3348b72 commit ea46551
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 1 deletion.
17 changes: 17 additions & 0 deletions vj4/handler/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from vj4.model.adaptor import setting
from vj4.util import misc
from vj4.util import options
from vj4.util import pagination
from vj4.util import validator
from vj4.handler import base

Expand Down Expand Up @@ -253,3 +254,19 @@ async def get(self, *, q: str, exact_match: bool=False):
for i in range(len(udocs)):
self.modify_udoc(udocs, i)
self.json(udocs)


@app.route('/ranking', 'domain_ranking')
class RankHandler(base.Handler):
USERS_PER_PAGE = 100

@base.require_priv(builtin.PRIV_USER_PROFILE)
@base.get_argument
@base.route_argument
@base.sanitize
async def get(self, *, page: int=1):
dudocs, dupcount, _ = await pagination.paginate(
domain.get_multi_user(domain_id=self.domain_id, rp={'$gt': 0.0}).sort([('rank', 1)]),
page, self.USERS_PER_PAGE)
udict = await user.get_dict(dudoc['uid'] for dudoc in dudocs)
self.render('domain_ranking.html', page=page, dupcount=dupcount, dudocs=dudocs, udict=udict)
1 change: 1 addition & 0 deletions vj4/locale/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ user_lostpass: Lost Password
user_register: Register
home_domain_create: Create Domain
domain_main: Main
domain_ranking: Ranking
domain_manage: Domain Manage
domain_manage_dashboard: Dashboard
domain_manage_discussion: Discussion Nodes
Expand Down
3 changes: 2 additions & 1 deletion vj4/locale/zh_CN.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ Create Domain: 创建域
Properties: 属性
Access Control: 访问控制
domain_main: 首页
domain_ranking: 排名
domain_manage: 管理域
domain_manage_dashboard: 概况
domain_manage_discussion: 讨论节点
Expand Down Expand Up @@ -792,4 +793,4 @@ What's this?: 这是什么?
About test data: 关于测试数据
With this feature, you can copy problems that you can view from a domain to some other domain. Their title, content, tags and categories will be copied. However, their test data are not copied directly.: 您可以通过这个功能将某域下您能查看的题目复制到其它域中,题目的标题、描述、标签与分类将被复制过来。但是测试数据不会被直接复制。
Instead of copying the test data directly, the test data of the copied problems will be linked to the test data of the source problems (called the source test data). Thus, the copied problems can observe the changes in the source test data. The permissions of the test data of the copied problems follow the source test data, e.g., you still might not download them but the judges can. By uploading some new test data, the link will be broken and the new test data will be used.: 虽然测试数据不会被复制,但是系统会将题目的测试数据链接到原题。因此在原题的数据被改动的时候,复制后的题目的数据也会同时改动。链接后的测试数据的权限以原题为准,比如您可能依旧无法下载数据,但是评测机可以。在题目设置页面中可以通过上传新的测试数据的方式,这个数据链接会被删除,以后将使用您的新测试数据。
This message will be presented to those whose submissions are accepted.: 这条消息将会被展示给通过此题的用户。
This message will be presented to those whose submissions are accepted.: 这条消息将会被展示给通过此题的用户。
20 changes: 20 additions & 0 deletions vj4/ui/pages/domain_ranking.page.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.page--domain_ranking
.col--rank
width: rem(90px)
border-right: 1px solid $table-border-color
text-align: center

.col--user
width: rem(260px)
border-right: 1px solid $table-border-color

.col--rp
width: rem(80px)
border-right: 1px solid $table-border-color
text-align: center

.col--accept
width: rem(80px)
border-right: 1px solid $table-border-color
text-align: center

47 changes: 47 additions & 0 deletions vj4/ui/templates/domain_ranking.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{% extends "layout/basic.html" %}
{% import "components/paginator.html" as paginator with context %}
{% import "components/nothing.html" as nothing with context %}
{% block content %}
<div class="row">
<div class="medium-12 columns">
<div class="section">
<div class="section__body no-padding">
<div data-fragment-id="ranking">
{% if not dudocs %}
{{ nothing.render('Sorry, there is no user in this domain.') }}
{% else %}
<table class="data-table">
<colgroup>
<col class="col--rank">
<col class="col--user">
<col class="col--info">
</colgroup>
<thead>
<tr>
<th class="col--rank">{{ _('Rank') }}</th>
<th class="col--user">{{ _('User') }}</th>
<th class="col--rp">{{ _('RP') }}</th>
<th class="col--accept">{{ _('Accepted') }}</th>
<th class="col--bio">{{ _('Bio') }}</th>
</tr>
</thead>
<tbody>
{% for dudoc in dudocs %}
<tr>
<td class="col--rank">{{ dudoc['rank'] }}</td>
<td class="col--user">{{ user.render_inline(udict[dudoc['uid']], dudoc=dudoc) }}</td>
<td class="col--rp">{{ dudoc['rp']|default(0.0)|round(2) }}</td>
<td class="col--accept">{{ dudoc['num_accept']|default(0) }}</td>
<td class="col--bio">{{ udict[dudoc['uid']]['bio']|default('')|markdown }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{{ paginator.render(page, dupcount) }}
{% endif %}
</div>
</div>
</div>
</div>
</div>
{% endblock %}
3 changes: 3 additions & 0 deletions vj4/ui/templates/partials/nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
{% if handler.has_perm(vj4.model.builtin.PERM_VIEW_HOMEWORK) %}
{{ nav_item('homework_main', 'homework') }}
{% endif %}
{% if handler.has_priv(vj4.model.builtin.PRIV_USER_PROFILE) %}
{{ nav_item('domain_ranking', 'domain_ranking') }}
{% endif %}
{% if handler.has_perm(vj4.model.builtin.PERM_EDIT_DESCRIPTION) or handler.has_perm(vj4.model.builtin.PERM_EDIT_PERM) %}
{{ nav_item('domain_manage', 'domain_manage') }}
{% endif %}
Expand Down

0 comments on commit ea46551

Please sign in to comment.