View Source Claper.Polls (Claper v1.4.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.
Deletes a poll.
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.
Updates a poll.
Link to this section Functions
Add an empty poll opt to a poll changeset.
Returns an %Ecto.Changeset{}
for tracking poll changes.
examples
Examples
iex> change_poll(poll)
%Ecto.Changeset{data: %Poll{}}
Creates a poll.
examples
Examples
iex> create_poll(%{field: value})
{:ok, %Poll{}}
iex> create_poll(%{field: bad_value})
{:error, %Ecto.Changeset{}}
Creates a poll_vote.
examples
Examples
iex> create_poll_vote(%{field: value})
{:ok, %PollVote{}}
iex> create_poll_vote(%{field: bad_value})
{:error, %Ecto.Changeset{}}
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{}}
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)
Gets a single poll for a given position.
examples
Examples
iex> get_poll!(123, 0)
%Poll{}
Gets a all poll_vote.
examples
Examples
iex> get_poll_vote!(321, 123)
[%PollVote{}]
Returns the list of polls for a given presentation file.
examples
Examples
iex> list_polls(123)
[%Poll{}, ...]
Returns the list of polls for a given presentation file and a given position.
examples
Examples
iex> list_polls_at_position(123, 0)
[%Poll{}, ...]
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{}
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{}}