diff --git a/lib/flick_web/live/ballots/viewer_live.ex b/lib/flick_web/live/ballots/viewer_live.ex index 773939d..eb9dcfb 100644 --- a/lib/flick_web/live/ballots/viewer_live.ex +++ b/lib/flick_web/live/ballots/viewer_live.ex @@ -30,7 +30,8 @@ defmodule FlickWeb.Ballots.ViewerLive do defp assign_votes(socket) do %{ballot: ballot} = socket.assigns votes = RankedVoting.list_votes_for_ballot_id(ballot.id) - assign(socket, votes: votes) + vote_report = RankedVoting.get_vote_report(ballot.id) + assign(socket, votes: votes, vote_report: vote_report) end @impl Phoenix.LiveView @@ -151,13 +152,17 @@ defmodule FlickWeb.Ballots.ViewerLive do <% end %> -
+

Vote Results

-

A table showing the tallied vote results would go here.

+
    + <%= for %{points: points, value: answer} <- @vote_report do %> +
  1. <%= answer %>: <%= points %> points
  2. + <% end %> +
-
-

Votes (Add Total Count)

+
+

Votes (<%= length(@votes) %>)

<.table id="votes" rows={@votes} row_id={&"vote-row-#{&1.id}"}> @@ -197,19 +202,19 @@ defmodule FlickWeb.Ballots.ViewerLive do - <:col :let={vote} :if={show_answer(@ballot, 0)} label="First Preference"> + <:col :let={vote} :if={show_answer(@ballot, 0)} label="First Preference (5pts)"> <%= answer_at_index(vote, 0) %> - <:col :let={vote} :if={show_answer(@ballot, 1)} label="Second Preference"> + <:col :let={vote} :if={show_answer(@ballot, 1)} label="Second Preference (4pts)"> <%= answer_at_index(vote, 1) %> - <:col :let={vote} :if={show_answer(@ballot, 2)} label="Third Preference"> + <:col :let={vote} :if={show_answer(@ballot, 2)} label="Third Preference (3pts)"> <%= answer_at_index(vote, 2) %> - <:col :let={vote} :if={show_answer(@ballot, 3)} label="Fourth Preference"> + <:col :let={vote} :if={show_answer(@ballot, 3)} label="Fourth Preference (2pts)"> <%= answer_at_index(vote, 3) %> - <:col :let={vote} :if={show_answer(@ballot, 4)} label="Fifth Preference"> + <:col :let={vote} :if={show_answer(@ballot, 4)} label="Fifth Preference (1pt)"> <%= answer_at_index(vote, 4) %>