Skip to content

Add speaker standings and metrics by score criterion - #2901

Open
TrudeauOkech wants to merge 5 commits into
TabbycatDebate:developfrom
TrudeauOkech:criterion-speaker-standings
Open

Add speaker standings and metrics by score criterion#2901
TrudeauOkech wants to merge 5 commits into
TabbycatDebate:developfrom
TrudeauOkech:criterion-speaker-standings

Conversation

@TrudeauOkech

Copy link
Copy Markdown
Contributor

Fixes #2900

Adds "total for X" and "average for X" metrics for each score criterion, so speakers can be ranked by e.g. Style in a WSDC tournament. Criteria are per-tournament rows, so their annotator classes are built per tournament and keyed by criterion seq.

Also adds a standings page per criterion, admin and public, the latter gated on a new criterion_tabs_released preference.
With criteria configured the speech score is derived from them and set_score() is a no-op, so simulated ballots produced all-zero scores.

@tienne-B tienne-B left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would this work with reply vs substantive criteria, and could you explain how the API now handles criteria scores? How could users get an API endpoint with the received criteria scores per round?

@TrudeauOkech

Copy link
Copy Markdown
Contributor Author

Criteria only aggregate over the speeches they apply to ie get_position_filter() mirrors applies_to_position(), and the per-round columns use the same filter.

One case your question turned up: the criterion tab was inheriting its eligibility filter from the substantive standings view, so it ranked on standings_missed_debates, which counts substantive speeches. In WSDC the reply comes from one of the substantive speakers. Reply-only criteria now use standings_missed_replies/replies_count.

@TrudeauOkech

Copy link
Copy Markdown
Contributor Author

On the API, each criterion adds criterion_avg_<seq> and criterion_total_<seq>, which work in metrics and extra_metrics:

GET /api/v1/tournaments/<slug>/standings/speakers?metrics=criterion_avg_1

Per-round criteria scores aren't available anywhere at the moment. BallotSerializer accepts criteria on write and speakers_as_dicts() emits a criteria key, but on read that value is criteria_scores[side][pos] — a dict keyed by ScoreCriterion — while CriteriaSerializer expects objects with .criterion/.score. With no criteria defined a ballot GET returns 200 and just leaves the key out; with criteria it 500s on 'DebateSide' object has no attribute 'pk'.

This PR doesn't touch either file, so it's not from here, but making the read path emit [{"criterion": <url>, "score": n}, ...] is what would actually get you per-round scores. I'm thinking of doing it in a separate PR.

Comment thread tabbycat/options/forms.py

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the new metrics do show in the preference fields; however, trying to save them results in a ValidationError like "criterion_avg_1 is not a valid choice".

Comment on lines +301 to +307
def get_position_filter(self, round):
"""Mirrors ScoreCriterion.applies_to_position()."""
if self.criterion.speech_type == ScoreCriterion.SpeechType.REPLY:
return Q(speakerscore__position=round.tournament.reply_position)
if self.criterion.speech_type == ScoreCriterion.SpeechType.SUBSTANTIVE:
return Q(speakerscore__position__lte=round.tournament.last_substantive_position)
return Q()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the metrics for reply are fixed and don't have a setting to customize, I don't think we need to worry about reply speeches actually.

Q(speakerscore__position__lte=round.tournament.last_substantive_position)

should always be applied (or based on what page is being viewed, between reply or substantive standings, so that it works with SpeechType.ALL)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create standings for speakers per criteria

2 participants