Bonfire.Poll.Votes (Bonfire v1.0.1-social-alpha.28)

View Source

Summary

Functions

ap_receive_activity(creator, activity, ap_object)

by_voter(subject, opts \\ [])

calculate_average_base_score(total, num_voters)

Returns the average base score (rounded) for a choice.

Examples

iex> Bonfire.Poll.Votes.calculate_average_base_score(3, 2)
2

iex> Bonfire.Poll.Votes.calculate_average_base_score(nil, 2)
nil

iex> Bonfire.Poll.Votes.calculate_average_base_score(0, 0)
0

calculate_if_visible(choice, poll, opts \\ [])

Returns votes count or weighted total for a choice, only if poll voting is closed or owned by current user.

For weighted_multiple polls, returns the sum of weights for all votes on the choice. For other formats, returns the count of votes. Returns nil if results are not visible.

calculate_total(votes, weighting, sum \\ 0)

Sums the weights of all votes for a choice.

Examples

iex> Bonfire.Poll.Votes.calculate_total([%{vote_weight: 2}, %{vote_weight: 1}], 1)
3

iex> Bonfire.Poll.Votes.calculate_total([%{vote_weight: -1}, %{vote_weight: 2}], 2)
3

count(filters \\ [], opts \\ [])

federation_module()

Callback implementation for Bonfire.Federate.ActivityPub.FederationModules.federation_module/0.

for_choice(choice, opts \\ [])

get(subject, object, opts \\ [])

get!(subject, object, opts \\ [])

get_average_emoji(total, num_voters, question, scores \\ scores())

list(filters \\ [], opts \\ [])

query(filters, opts)

query_module()

Callback implementation for Bonfire.Common.ContextModule.query_module/0.

register_vote_choice(voter, question, choice, opts \\ [])

results_visible?(choice, poll, opts \\ [])

Returns true a choice only if poll voting is closed or owned by current user

schema_module()

Callback implementation for Bonfire.Common.ContextModule.schema_module/0.

scores()

send_vote_activity(voter, question, registered_votes, opts)

vote(voter, question, choices, opts \\ [])