--- loncom/homework/response.pm 2011/03/07 19:42:21 1.222 +++ loncom/homework/response.pm 2011/09/13 21:42:58 1.226 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # various response type definitons response definition # -# $Id: response.pm,v 1.222 2011/03/07 19:42:21 www Exp $ +# $Id: response.pm,v 1.226 2011/09/13 21:42:58 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -179,7 +179,7 @@ sub setrandomnumber { } else { ($rndmod,$rndmod2)=&Apache::lonnet::digest("$id1,$id2"); } - + $Apache::lonhomework::results{'resource.'.$id1.'.rawrndseed'}=$rndseed; if ($rndseed =~/([,:])/) { my $char=$1; use integer; @@ -196,6 +196,7 @@ sub setrandomnumber { } } &Apache::lonxml::debug("randseed $rndmod $rndseed"); + $Apache::lonhomework::results{'resource.'.$id1.'.rndseed'}=$rndseed; &Apache::lonnet::setup_random_from_rndseed($rndseed); return ''; } @@ -321,7 +322,7 @@ sub check_for_previous { next if (($questiontype eq 'randomizetry') && ($curr_rndseed ne $Apache::lonhomework::history{"$history:resource.$partid.rndseed"})); push (@{$previous{'versionci'}},$history); - $previous{'awardci'} = $Apache::lonhomework::history{"resource.$partid.$id.awarddetail"}; + $previous{'awardci'} = $Apache::lonhomework::history{"$history:resource.$partid.$id.awarddetail"}; $previous{'usedci'} = 1; } } @@ -1002,16 +1003,18 @@ sub getresponse { $Apache::lonhomework::results{"resource.$part.$id.scantron"}.= $response; if ($resulttype ne 'letter') { - if ($resulttype eq 'A is 1') { - $response = $let_to_num{$response}+1; - } else { - $response = $let_to_num{$response}; + $response = $let_to_num{$response}; + if ($resulttype eq 'A is 1') { + if ($response ne "") { + $response = $response+1; + } } if ($response ne "") { $response += $line * $bubbles_per_line; } } else { if ($response ne "") { + my $raw = $response; $response = chr(ord($response) + $line * $bubbles_per_line); } } @@ -1032,7 +1035,10 @@ sub getresponse { =item &repetition(); Returns the number of lines that are required to encode the weight. -(Currently expects that there are 10 bubbles per line) +(Default is for 10 bubbles per bubblesheet item; other (integer) +values can be specified by using a custom Bubblesheet format file +with an eighteenth entry (BubblesPerRow) set to the integer +appropriate for the bubblesheets which will be used to assign weights. =cut @@ -1040,8 +1046,15 @@ sub repetition { my $id = $Apache::inputtags::part; my $weight = &Apache::lonnet::EXT("resource.$id.weight"); if (!defined($weight) || ($weight eq '')) { $weight=1; } - my $repetition = int($weight/10); - if ($weight % 10 != 0) { $repetition++; } + my $bubbles_per_row; + if (($env{'form.bubbles_per_row'} =~ /^\d+$/) && + ($env{'form.bubbles_per_row'} > 0)) { + $bubbles_per_row = $env{'form.bubbles_per_row'}; + } else { + $bubbles_per_row = 10; + } + my $repetition = int($weight/$bubbles_per_row); + if ($weight % $bubbles_per_row != 0) { $repetition++; } return $repetition; }