Package bosco :: Module ranking :: Class Ranking
[hide private]
[frames] | no frames]

Class Ranking

source code

object --+
         |
        Ranking

A Ranking objects combines a scoreing strategy, a validation strategy and a rankable object (course or category) and computes a ranking. The Ranking object is an interable object, which means you can use it much like a list. It returns a new iterator on every call to __iter__. The order of the ranking is defined by the scoreing strategy. Strategy has the be a subclass of AbstractScoreing compatible with the RankableItem objects of this Rankable. The ranking is generated in lowest first order. Reverse rankings are possible.

The iterator returns dictionaries with the keys 'rank', 'scoreing', 'validation', 'item'.

Rankings are lazyly computed, but not updated unless you eihter call the update mehtod or iterate over them.

Instance Methods [hide private]
 
__init__(self, rankable, event, scoreing_class=None, validator_class=None, scoreing_args=None, validator_args=None, reverse=False)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
__iter__(self)
Iterating over the ranking automatically updates the ranking.
source code
 
__getitem__(self, key) source code
 
rank(self, item)
Returns: Rank of this item
source code
 
score(self, item)
Returns: Score of this item
source code
 
info(self, item)
Return information dict for one item
source code
 
member_count(self) source code
 
completed_count(self) source code
 
_update_ranking_list(self) source code
 
_update_ranking_dict(self) source code
 
update(self)
Update the ranking.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, rankable, event, scoreing_class=None, validator_class=None, scoreing_args=None, validator_args=None, reverse=False)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

__iter__(self)

source code 

Iterating over the ranking automatically updates the ranking. This is mainly for backwards compatibility.

rank(self, item)

source code 
Parameters:
  • item - Item ranked in this ranking
Returns:
Rank of this item

score(self, item)

source code 
Parameters:
  • item - Item ranked in this ranking
Returns:
Score of this item

info(self, item)

source code 

Return information dict for one item

Parameters:
  • item - Item ranked in this ranking
Returns:
dict with all information about this item (same as when iterating over the ranking)

member_count(self)

source code 
Decorators:
  • @property

completed_count(self)

source code 
Decorators:
  • @property

update(self)

source code 

Update the ranking. Rankings are not updated automatically.