--- loncom/homework/optionresponse.pm 2004/03/25 16:55:16 1.105
+++ loncom/homework/optionresponse.pm 2004/04/16 22:25:13 1.106
@@ -1,7 +1,7 @@
# LearningOnline Network with CAPA
# option list style responses
#
-# $Id: optionresponse.pm,v 1.105 2004/03/25 16:55:16 albertel Exp $
+# $Id: optionresponse.pm,v 1.106 2004/04/16 22:25:13 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -284,6 +284,27 @@ sub displayanswers {
return $result;
}
+sub check_for_invalid {
+ my ($names,$options) = @_;
+ my %bad_names;
+ foreach my $name (@{ $names }) {
+ my $value=$Apache::response::foilgroup{$name.'.value'};
+ my $found=0;
+ foreach my $option (@{ $options }) {
+ if ($value eq $option) { $found=1; }
+ }
+ if (!$found) { $bad_names{$name}=$value; }
+ }
+ if (%bad_names) {
+ my $error=&mt('The question can not be gotten correct, '.
+ 'the following foils in the <optionresponse> '.
+ 'have invalid correct options').'
'.
+ join('
',(map { $_=&mt("[_1] with value [_2]",$_,$bad_names{$_}) } (keys(%bad_names)))).
+ "";
+ &Apache::lonxml::error($error);
+ }
+}
+
sub displayfoils {
my ($target,$max,$randomize,@opt)=@_;
if (!defined(@{ $Apache::response::foilgroup{'names'} })) {return;}
@@ -295,6 +316,7 @@ sub displayfoils {
my $displayoptionintex=1;
my @alphabet = ('A'..'Z');
my @whichopt = &whichfoils($max,$randomize);
+ &check_for_invalid(\@whichopt,\@opt);
my $part=$Apache::inputtags::part;
my $id=$Apache::inputtags::response[-1];
my $break;