Commit 8beb9ed4 authored by Stephane Glondu's avatar Stephane Glondu

Add support for blank ballots (backend)

parent aae61603
......@@ -42,11 +42,11 @@ belenios-tool mkelection $uuid $group --template $BELENIOS/demo/templates/questi
header "Simulate votes"
cat > votes.txt <<EOF
[[1,0]]
[[1,0]]
[[0,1]]
[[1,0]]
[[0,0]]
[[1,0],[1,0,0]]
[[1,0],[0,1,0]]
[[0,1],[0,0,1]]
[[1,0],[1,0,0]]
[[0,0],[0,1,0]]
EOF
paste private_creds.txt votes.txt | while read id cred vote; do
......
{"description":"Description of the election.","name":"Name of the election","questions":[{"answers":["Answer 1","Answer 2"],"min":0,"max":1,"question":"Question 1?"}],"short_name":"short_name"}
{"description":"Description of the election.","name":"Name of the election","questions":[{"answers":["Answer 1","Answer 2"],"min":0,"max":1,"question":"Question 1?"},{"answers":["Answer 1","Answer 2"],"blank":true,"min":1,"max":1,"question":"Question 2?"}]}
This diff is collapsed.
......@@ -25,6 +25,8 @@ open Platform
open Serializable_t
open Signatures
val question_length : question -> int
module MakeSimpleMonad (G : GROUP) : sig
(** {2 Monadic definitions} *)
......
......@@ -67,6 +67,7 @@ type ('a, 'b) wrapped_pubkey = {
type question = {
answers : string list <ocaml repr="array">;
?blank : bool option;
min : int;
max : int;
question : string;
......@@ -92,6 +93,7 @@ type 'a answer = {
choices : 'a ciphertext list <ocaml repr="array">;
individual_proofs : disjunctive_proof list <ocaml repr="array">;
overall_proof : disjunctive_proof;
?blank_proof : disjunctive_proof option;
}
<doc text="An answer to a question. It consists of a weight for each
choice, a proof that each of these weights is 0 or 1, and an overall
......
......@@ -46,6 +46,7 @@ let extractQuestion q =
try return (int_of_string x)
with _ -> failwith (error_msg ^ ": " ^ x ^ ".")
in
let q_blank = None in
numeric ".question_min" "Invalid minimum number of choices" >>= fun q_min ->
numeric ".question_max" "Invalid maximum number of choices" >>= fun q_max ->
if not (q_min <= q_max) then
......@@ -58,7 +59,7 @@ let extractQuestion q =
let a = answers##item (i) >>= extractAnswer in
Js.Opt.get a (fun () -> failwith "extractQuestion"))
in
return {q_question; q_min; q_max; q_answers}
return {q_question; q_blank; q_min; q_max; q_answers}
let extractTemplate () =
let t_name = get_input "election_name" in
......@@ -131,7 +132,7 @@ let rec createQuestion q =
let insert_text = document##createTextNode (Js.string "Insert") in
let insert_btn = Dom_html.createButton document in
let f _ =
let x = createQuestion {q_question=""; q_min=0; q_max=1; q_answers=[||]} in
let x = createQuestion {q_question=""; q_blank=None; q_min=0; q_max=1; q_answers=[||]} in
container##parentNode >>= fun p ->
Dom.insertBefore p x (Js.some container);
return ()
......@@ -229,7 +230,7 @@ let createTemplate template =
let b = Dom_html.createButton document in
let t = document##createTextNode (Js.string "Add a question") in
let f _ =
let x = createQuestion {q_question=""; q_min=0; q_max=1; q_answers=[||]} in
let x = createQuestion {q_question=""; q_blank=None; q_min=0; q_max=1; q_answers=[||]} in
Dom.appendChild h_questions_div x
in
b##onclick <- handler f;
......
......@@ -331,6 +331,7 @@ let create_new_election owner cred auth =
} in
let question = {
q_answers = [| "Answer 1"; "Answer 2"; "Blank" |];
q_blank = None;
q_min = 1;
q_max = 1;
q_question = "Question 1?";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment