View Source Claper.Polls (Claper v1.7.0)

The Polls context.

Link to this section Summary

Functions

Add an empty poll opt to a poll changeset.

Returns an %Ecto.Changeset{} for tracking poll changes.

Creates a poll.

Creates a poll_vote.

Gets a single poll and set percentages for each poll options.

Gets a single poll for a given position.

Gets a all poll_vote.

Returns the list of polls for a given presentation file.

Returns the list of polls for a given presentation file and a given position.

Remove a poll opt from a poll changeset.

Calculate percentage of all poll options for a given poll.

Link to this section Functions

Add an empty poll opt to a poll changeset.

Link to this function

change_poll(poll, attrs \\ %{})

View Source

Returns an %Ecto.Changeset{} for tracking poll changes.

examples

Examples

iex> change_poll(poll)
%Ecto.Changeset{data: %Poll{}}
Link to this function

create_poll(attrs \\ %{})

View Source

Creates a poll.

examples

Examples

iex> create_poll(%{field: value})
{:ok, %Poll{}}

iex> create_poll(%{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

create_poll_vote(attrs \\ %{})

View Source

Creates a poll_vote.

examples

Examples

iex> create_poll_vote(%{field: value})
{:ok, %PollVote{}}

iex> create_poll_vote(%{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

delete_poll(event_uuid, poll)

View Source

Deletes a poll.

examples

Examples

iex> delete_poll("123e4567-e89b-12d3-a456-426614174000", poll)
{:ok, %Poll{}}

iex> delete_poll("123e4567-e89b-12d3-a456-426614174000", poll)
{:error, %Ecto.Changeset{}}
Link to this function

disable_all(presentation_file_id, position)

View Source

Gets a single poll and set percentages for each poll options.

Raises Ecto.NoResultsError if the Poll does not exist.

examples

Examples

iex> get_poll!(123)
%Poll{}

iex> get_poll!(456)
** (Ecto.NoResultsError)
Link to this function

get_poll_current_position(presentation_file_id, position)

View Source

Gets a single poll for a given position.

examples

Examples

iex> get_poll!(123, 0)
%Poll{}
Link to this function

get_poll_vote(user_id, poll_id)

View Source

Gets a all poll_vote.

examples

Examples

iex> get_poll_vote!(321, 123)
[%PollVote{}]
Link to this function

list_polls(presentation_file_id)

View Source

Returns the list of polls for a given presentation file.

examples

Examples

iex> list_polls(123)
[%Poll{}, ...]
Link to this function

list_polls_at_position(presentation_file_id, position)

View Source

Returns the list of polls for a given presentation file and a given position.

examples

Examples

iex> list_polls_at_position(123, 0)
[%Poll{}, ...]
Link to this function

remove_poll_opt(changeset, poll_opt)

View Source

Remove a poll opt from a poll changeset.

Calculate percentage of all poll options for a given poll.

examples

Examples

iex> set_percentages(poll)
%Poll{}
Link to this function

set_status(id, presentation_file_id, position, status)

View Source
Link to this function

update_poll(event_uuid, poll, attrs)

View Source

Updates a poll.

examples

Examples

iex> update_poll("123e4567-e89b-12d3-a456-426614174000", poll, %{field: new_value})
{:ok, %Poll{}}

iex> update_poll("123e4567-e89b-12d3-a456-426614174000", poll, %{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

vote(user_id, event_uuid, poll_opts, poll_id)

View Source