--- loncom/homework/default_homework.lcpm 2011/05/21 14:50:36 1.154 +++ loncom/homework/default_homework.lcpm 2011/05/22 03:04:51 1.155 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # used by lonxml::xmlparse() as input variable $safeinit to Apache::run::run() # -# $Id: default_homework.lcpm,v 1.154 2011/05/21 14:50:36 www Exp $ +# $Id: default_homework.lcpm,v 1.155 2011/05/22 03:04:51 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1221,6 +1221,28 @@ sub stored_data { return &EXT('user.resource.resource.'.$partid.'.'.$which); } +sub wrong_bubbles { + my ($correct,$lower,$upper,$step,@given)=@_; + my @array=(); + my %hash=(); + foreach my $new (@given) { + $hash{$new}=1; + } + my $num=int(¶meter_setting('numbubbles',¤tpart())); + unless ($num) { $num=8; } + if ($num>1) { + for (my $i=0;$i<=500;$i++) { + my $new=&random($lower,$upper,$step); + if ($hash{$new}) { next; } + if (abs($new-$correct)<$step) { next; } + $hash{$new}=1; + @array=keys(%hash); + if ($#array+2>=$num) { last; } + } + } + return @array; +} + sub array_moments { my @input=@_; my (@output,$N);