% @header [("title", ["Roll call!"])];
val you = Init.getUserId ();
ref viewingCall = NONE;
ref showNormal = true;
if $"cmd" = "respond" then
showNormal := false;
val rol = Web.stoi ($"rol");
val code = $"code";
val rc = Roll.lookupEntry (rol, you);
if code = #code rc then
Roll.respond (rol, you);
%>
Your response has been saved. Thank you!
<%
else
%>
Incorrect code!
<%
end
elseif $"cmd" = "add" then
Group.requireGroupNum 0;
val title = $"title";
val msg = $"msg";
if title = "" then
%>
Your roll call must have a title.
<%
else
val id = Roll.addRollCall (title, msg);
viewingCall := SOME id;
%>
Roll call added!
<%
end
elseif $"mod" <> "" then
Group.requireGroupNum 0;
showNormal := false;
val rc = Roll.lookupRollCall (Web.stoi ($"mod")) %>
Modify roll call
<% elseif $"cmd" = "Save" then
Group.requireGroupNum 0;
val rc = Roll.lookupRollCall (Web.stoi ($"id"));
val title = $"title";
val msg = $"msg";
if title = "" then
%>
Your rol call must have a title.
<%
else
Roll.modRollCall {rc with title = title, msg = msg};
viewingCall := SOME (#id rc);
%>
Roll call saved.
<%
end
elseif $"del" <> "" then
Group.requireGroupNum 0;
showNormal := false;
val rc = Roll.lookupRollCall (Web.stoi ($"del")) %>
<% elseif $"cmd" = "mailall" then
Group.requireGroupNum 0;
showNormal := false;
ref first = true %>
Mail everyone!
<% elseif $"view" <> "" then
Group.requireGroupNum 0;
val id = Web.stoi ($"view");
viewingCall := SOME id
end;
if showNormal then
Group.requireGroupNum 0;
switch viewingCall of
NONE => %>