oioioi.rankings.controllers

Module Contents

Classes

RankingMixinForContestController

ContestController mixin that sets up rankings app.

RankingController

Ranking system uses two types of keys: "partial key"s and "full key"s.

DefaultRankingController

Ranking system uses two types of keys: "partial key"s and "full key"s.

Functions

update_rankings_with_user_callback(sender, user, **kwargs)

Attributes

oioioi.rankings.controllers.CONTEST_RANKING_KEY = c[source]
class oioioi.rankings.controllers.RankingMixinForContestController[source]

Bases: object

ContestController mixin that sets up rankings app.

ranking_controller()[source]

Return the actual RankingController for the contest.

update_user_results(user, problem_instance, *args, **kwargs)[source]
class oioioi.rankings.controllers.RankingController(contest)[source]

Bases: oioioi.base.utils.RegisteredSubclassesBase, oioioi.base.utils.ObjectWithMixins

Ranking system uses two types of keys: “partial key”s and “full key”s. Please note that full keys are abbreviated in the code as “key”s.

A pair (request, partial_key) should allow to build a full key, while a partial_key can always be extracted from the full key. partial keys identify the rounds to display and are used everywhere outside controllers and rankingsd (e.g. in views and urls). However, the actual ranking contents can depend on many other factors, like user permissions. This was the reason for introduction of full keys, which are always sufficient to choose the right data for serialization and display.

modules_with_subclasses = ['controllers'][source]
abstract = True[source]
PERMISSION_CHECKERS[source]
get_partial_key(key)[source]

Extracts partial key from a full key.

replace_partial_key(key, new_partial)[source]

Replaces partial key in a full key

get_full_key(request, partial_key)[source]

Returns a full key associated with request and partial_key

_key_permission(key)[source]

Returns a permission level associated with given full key

is_admin_key(key)[source]

Returns true if a given full key corresponds to users with administrative permissions.

abstract available_rankings(request)[source]

Returns a list of available rankings.

Each ranking is a pair (key, description).

can_search_for_users()[source]

Determines if in this ranking, searching for users is enabled.

abstract find_user_position(request, partial_key, user)[source]

Returns user’s position in the ranking. User should be an object of class User, not a string with username.

If user is not in the ranking, None is returned.

get_rendered_ranking(request, partial_key)[source]

Retrieves ranking generated by rankingsd.

You should never override this function. It will be responsible for communication with rankingsd and use render_ranking for actual HTML generation. Feel free to override render_ranking to customize its logic.

If the ranking is still being generated, or the user requested an invalid page, displays an appropriate message.

get_serialized_ranking(key)[source]
build_ranking(key)[source]

Serializes data and renders html for given key.

Results are processed using serialize_ranking, and then as many pages as needed are rendered. Returns a tuple containing serialized data and a list of strings, that are html code of ranking pages.

_fake_request(page)[source]

Creates a fake request used to render ranking.

Pagination engine requires access to request object, so it can extract page number from GET parameters.

abstract _render_ranking_page(key, data, page)[source]
abstract render_ranking_to_csv(request, partial_key)[source]
abstract serialize_ranking(key)[source]

Returns some data (representing ranking). This data will be used by render_ranking() to generate the html code.

class oioioi.rankings.controllers.DefaultRankingController(contest)[source]

Bases: RankingController

Ranking system uses two types of keys: “partial key”s and “full key”s. Please note that full keys are abbreviated in the code as “key”s.

A pair (request, partial_key) should allow to build a full key, while a partial_key can always be extracted from the full key. partial keys identify the rounds to display and are used everywhere outside controllers and rankingsd (e.g. in views and urls). However, the actual ranking contents can depend on many other factors, like user permissions. This was the reason for introduction of full keys, which are always sufficient to choose the right data for serialization and display.

description[source]
_iter_rounds(can_see_all, timestamp, partial_key, request=None)[source]
_rounds_for_ranking(request, partial_key=CONTEST_RANKING_KEY)[source]
_rounds_for_key(key)[source]
available_rankings(request)[source]

Returns a list of available rankings.

Each ranking is a pair (key, description).

can_search_for_users()[source]

Determines if in this ranking, searching for users is enabled.

find_user_position(request, partial_key, user)[source]

Returns user’s position in the ranking. User should be an object of class User, not a string with username.

If user is not in the ranking, None is returned.

_render_ranking_page(key, data, page)[source]
_get_csv_header(key, data)[source]
_get_csv_row(key, row)[source]
render_ranking_to_csv(request, partial_key)[source]
filter_users_for_ranking(key, queryset)[source]
_filter_pis_for_ranking(partial_key, queryset)[source]
_allow_zero_score()[source]
_get_users_results(pis, results, rounds, users)[source]
_assign_places(data, extractor)[source]

Assigns places to the serialized ranking data.

Extractor should return values by which users should be ordered in the ranking. Users with the same place should have same value returned.

_is_problem_statement_visible(key, pi, timestamp)[source]
_get_pis_with_visibility(key, pis)[source]
serialize_ranking(key)[source]

Returns some data (representing ranking). This data will be used by render_ranking() to generate the html code.

oioioi.rankings.controllers.update_rankings_with_user_callback(sender, user, **kwargs)[source]