Skip to content
Snippets Groups Projects
Commit 43792500 authored by Philip Kaluđerčić's avatar Philip Kaluđerčić :u7121:
Browse files

Check if there is any correct option for each question

parent 0644ec38
No related branches found
No related tags found
No related merge requests found
......@@ -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),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment