components.Score

class components.Score(answers=0, correct=0, member=None)

Bases: object

A single score count. Scores are comparable, i.e. score_1 == score_2 if and only if the answers and correct attributes are equal. Moreover, scores can be evaluated as boolean, where bool(score) == True if answers is greater than zero. Finally, scores are ordered: score_1 < score_2, if score_1 has a smaller ratio than score_2, or, if the ratios coincide, has fewer recorded answers.

Parameters
  • answers (int) – The number of answers that were given. Defaults to zero.

  • correct (int) – The number of answers that were correct. Defaults to zero.

  • member (Member) – The member this score is associated with.

property answers: int

The number of answers that were given.

Return type

int

property correct: int

The number of answers that were correct.

Return type

int

property ratio: float

The ratio of given and correct answers in percentage with two decimal places.

Return type

float