X-Git-Url: https://git.hcoop.net/hcoop/portal.git/blobdiff_plain/e68ddb8014e01a51952aa8077fa1e85c4a1fa014..56dbfc3052067bd1e3fa086e08cb96d783762ad6:/poll.mlt diff --git a/poll.mlt b/poll.mlt index 19e1eba..3abe588 100644 --- a/poll.mlt +++ b/poll.mlt @@ -16,6 +16,55 @@ if $"cmd" = "list" then <% end +elseif $"vote" <> "" then + showNormal := false; + val id = Web.stoi ($"vote"); + val poll = Poll.lookupPoll id %> + + + + + + + + +
Poll#: <% id %>
Title: <% Web.html (#title poll) %>
Start: <% Web.html (#starts poll) %>
End: <% Web.html (#ends poll) %>
Votes/person: <% #votes poll %>
Description: <% Web.htmlNl (#descr poll) %>
+ +

Choices

+ +
+ +<% val choices = Poll.listChoicesWithMyVotes id; +if #votes poll = 1 then %> + +<% end +foreach (you, cho) in choices do %> + +<% end %>

+ +
+ +<% elseif $"vote2" <> "" then + val id = Web.stoi ($"vote2"); + val poll = Poll.lookupPoll id; + editingPoll := SOME id; + + val votes = case Web.getMultiParam "v" of + [""] => [] + | v => map Web.stoi v; + + if length votes > #votes poll then + %>

You can't vote for that many different choices!

<% + elseif not (Poll.noDupes votes) then + %>

You can't vote multiple times for the same choice!

<% + else + Poll.vote (Init.getUserId (), id, votes) + %>

Thanks for voting!

+<% end + elseif $"cmd" = "add" then val title = $"title"; val starts = $"starts"; @@ -149,6 +198,43 @@ elseif $"delChoice" <> "" then editingPoll := SOME (#id poll) %>

"<% Web.html (#descr cho) %>" deleted!

+<% elseif $"report" <> "" then + showNormal := false; + val id = Web.stoi ($"report"); + + val poll = Poll.lookupPoll id; + val canModify = Poll.canModify poll %> + +

Vote Report

+ + + + + + + + +
Poll#: <% id %>
Title: <% Web.html (#title poll) %>
Start: <% Web.html (#starts poll) %>
End: <% Web.html (#ends poll) %>
Votes/person: <% #votes poll %>
Description: <% Web.htmlNl (#descr poll) %>
+ +


+ + + +<% foreach (_, total, cho) in Poll.listChoicesWithVotes id do %> + <% +end %> +
Votes Choice Voters
<% total %> <% Web.html (#descr cho) %> +<% ref first = true; + foreach user in Poll.listVoters (#id cho) do + if first then + first := false + else + %>, <% + end + %><% #name user %><% + end + %>
+ <% elseif $"id" <> "" then editingPoll := SOME (Web.stoi ($"id")) @@ -156,29 +242,47 @@ end %> <% switch editingPoll of SOME id => - val pol = Poll.lookupPoll id; - val canModify = Poll.canModify pol %> + val poll = Poll.lookupPoll id; + val canModify = Poll.canModify poll %> <% if canModify then %><% end %> - - - - - + + + + +
Edit poll data
Poll#: <% id %>
Title: <% Web.html (#title pol) %>
Start: <% Web.html (#starts pol) %>
End: <% Web.html (#ends pol) %>
Votes/person: <% #votes pol %>
Description: <% Web.htmlNl (#descr pol) %>
Title: <% Web.html (#title poll) %>
Start: <% Web.html (#starts poll) %>
End: <% Web.html (#ends poll) %>
Votes/person: <% #votes poll %>
Description: <% Web.htmlNl (#descr poll) %>
-

Choices

+

Choices<% if Poll.takingVotes poll then %>(Vote!)<% end %>

+ +<% if Poll.takingVotes poll then %> + + +<% foreach (you, total, cho) in Poll.listChoicesWithVotes id do %> + + + +<% if canModify then %> + +<% end %> +<% end %> +
You Total
<% if you then %>X<% end %><% total %><% Web.html (#descr cho) %>(<% #seq cho %>) +[Modify] +[Delete]
-<% foreach cho in Poll.listChoices id do %> +Vote Report +<% else +foreach cho in Poll.listChoices id do %>
  • <% Web.html (#descr cho) %> <% if canModify then %> (<% #seq cho %>) [Modify] [Delete] <% end %>
  • -<% end %> +<% end +end %> <% if canModify then %>