diff --git a/gen.pl b/gen.pl index d22b529671e7baad6ba4c175ce8fe9b9b61225bf..50b85e03665869efc7655597b2e4e445cf846eb5 100755 --- a/gen.pl +++ b/gen.pl @@ -31,7 +31,7 @@ sub md { # pipe through $markdown sub add { return unless %last_option; - if (defined $last_option{"comment"}) { + if ($last_option{"comment"}) { $last_option{"comment"} = md($last_option{"comment"}); } @@ -44,9 +44,19 @@ while (<>) { } elsif (/^.$/) { add(); - die "end of block without a question at line $.\n" + die "end of block without a question at line $ARGV:$.\n" unless defined $question; + my $any = 0; + foreach my $opt (@options) { + # unless (defined $opt->{"correct"}) { + # die "undefined \"$question\" ($ARGV:$.)\n"; + # } + $any = 1 if (not (defined $opt->{"correct"})) or ($opt->{"correct"} eq JSON::true); + } + die "no correct option at \"$question\" ($ARGV)\n" + unless $any; + my %ent = ( "question" => md($question),