Commit 7889b716 authored by Stephane Glondu's avatar Stephane Glondu

More min/max checks

parent c2046470
......@@ -53,6 +53,8 @@ let extractQuestion q =
numeric ".question_max" "Invalid maximum number of choices" >>= fun q_max ->
if not (q_min <= q_max) then
failwith "Minimum number of choices must be less than or equal to maximum number of choices!";
if (q_max = 0) then
failwith "Maximum number of choices must be greater than 0!";
let answers = p2##querySelectorAll (Js.string ".question_answer") in
let q_answers =
......@@ -61,6 +63,8 @@ let extractQuestion q =
let a = answers##item (i) >>= extractAnswer in
Js.Opt.get a (fun () -> failwith "extractQuestion"))
if (q_max > Array.length q_answers) then
failwith "Maximum number of choices is greater than number of choices!";
return {q_question; q_blank; q_min; q_max; q_answers}
let extractTemplate () =
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment