--- loncom/homework/response.pm 2011/09/08 01:18:15 1.225 +++ 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.225 2011/09/08 01:18:15 raeburn Exp $ +# $Id: response.pm,v 1.226 2011/09/13 21:42:58 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1003,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); } } @@ -1033,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 @@ -1041,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; }