version 1.221, 2010/12/19 00:44:09
|
version 1.227, 2011/11/14 03:08:01
|
Line 179 sub setrandomnumber {
|
Line 179 sub setrandomnumber {
|
} else { |
} else { |
($rndmod,$rndmod2)=&Apache::lonnet::digest("$id1,$id2"); |
($rndmod,$rndmod2)=&Apache::lonnet::digest("$id1,$id2"); |
} |
} |
|
$Apache::lonhomework::results{'resource.'.$id1.'.rawrndseed'}=$rndseed; |
if ($rndseed =~/([,:])/) { |
if ($rndseed =~/([,:])/) { |
my $char=$1; |
my $char=$1; |
use integer; |
use integer; |
Line 196 sub setrandomnumber {
|
Line 196 sub setrandomnumber {
|
} |
} |
} |
} |
&Apache::lonxml::debug("randseed $rndmod $rndseed"); |
&Apache::lonxml::debug("randseed $rndmod $rndseed"); |
|
$Apache::lonhomework::results{'resource.'.$id1.'.rndseed'}=$rndseed; |
&Apache::lonnet::setup_random_from_rndseed($rndseed); |
&Apache::lonnet::setup_random_from_rndseed($rndseed); |
return ''; |
return ''; |
} |
} |
Line 321 sub check_for_previous {
|
Line 322 sub check_for_previous {
|
next if (($questiontype eq 'randomizetry') && |
next if (($questiontype eq 'randomizetry') && |
($curr_rndseed ne $Apache::lonhomework::history{"$history:resource.$partid.rndseed"})); |
($curr_rndseed ne $Apache::lonhomework::history{"$history:resource.$partid.rndseed"})); |
push (@{$previous{'versionci'}},$history); |
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; |
$previous{'usedci'} = 1; |
} |
} |
} |
} |
Line 493 sub end_customresponse {
|
Line 494 sub end_customresponse {
|
} |
} |
if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' || |
if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' || |
$target eq 'tex' || $target eq 'analyze') { |
$target eq 'tex' || $target eq 'analyze') { |
&Apache::lonxml::increment_counter(&Apache::response::repetition(), |
my $repetition = &repetition(); |
"$part.$id"); |
&Apache::lonxml::increment_counter($repetition,"$part.$id"); |
if ($target eq 'analyze') { |
if ($target eq 'analyze') { |
$Apache::lonhomework::analyze{"$part.$id.type"} = 'customresponse'; |
$Apache::lonhomework::analyze{"$part.$id.type"} = 'customresponse'; |
&Apache::lonhomework::set_bubble_lines(); |
&Apache::lonhomework::set_bubble_lines(); |
Line 1002 sub getresponse {
|
Line 1003 sub getresponse {
|
$Apache::lonhomework::results{"resource.$part.$id.scantron"}.= |
$Apache::lonhomework::results{"resource.$part.$id.scantron"}.= |
$response; |
$response; |
if ($resulttype ne 'letter') { |
if ($resulttype ne 'letter') { |
if ($resulttype eq 'A is 1') { |
$response = $let_to_num{$response}; |
$response = $let_to_num{$response}+1; |
if ($resulttype eq 'A is 1') { |
} else { |
if ($response ne "") { |
$response = $let_to_num{$response}; |
$response = $response+1; |
|
} |
} |
} |
if ($response ne "") { |
if ($response ne "") { |
$response += $line * $bubbles_per_line; |
$response += $line * $bubbles_per_line; |
} |
} |
} else { |
} else { |
if ($response ne "") { |
if ($response ne "") { |
|
my $raw = $response; |
$response = chr(ord($response) + $line * $bubbles_per_line); |
$response = chr(ord($response) + $line * $bubbles_per_line); |
} |
} |
} |
} |
Line 1031 sub getresponse {
|
Line 1034 sub getresponse {
|
|
|
=item &repetition(); |
=item &repetition(); |
|
|
Returns the number of lines that are required to encode the weight. |
In scalar context: |
(Currently expects that there are 10 bubbles per line) |
|
|
returns: the number of lines that are required to encode the weight. |
|
(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. |
|
|
|
In array context: |
|
|
|
returns: number of lines required to encode weight, and bubbles/line. |
|
|
=cut |
=cut |
|
|
Line 1040 sub repetition {
|
Line 1052 sub repetition {
|
my $id = $Apache::inputtags::part; |
my $id = $Apache::inputtags::part; |
my $weight = &Apache::lonnet::EXT("resource.$id.weight"); |
my $weight = &Apache::lonnet::EXT("resource.$id.weight"); |
if (!defined($weight) || ($weight eq '')) { $weight=1; } |
if (!defined($weight) || ($weight eq '')) { $weight=1; } |
my $repetition = int($weight/10); |
my $bubbles_per_row; |
if ($weight % 10 != 0) { $repetition++; } |
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 $denominator = $bubbles_per_row; |
|
if (($env{'form.scantron_lastbubblepoints'} == 0) && |
|
($bubbles_per_row > 1)) { |
|
$denominator = $bubbles_per_row - 1; |
|
} |
|
my $repetition = int($weight/$denominator); |
|
if ($weight % $denominator != 0) { $repetition++; } |
|
if (wantarray) { |
|
return ($repetition,$bubbles_per_row); |
|
} |
return $repetition; |
return $repetition; |
|
|
} |
} |
|
|
=pod |
=pod |
Line 1072 Arguments
|
Line 1100 Arguments
|
sub scored_response { |
sub scored_response { |
my ($part,$id)=@_; |
my ($part,$id)=@_; |
my $repetition=&repetition(); |
my $repetition=&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 $score=0; |
my $score=0; |
for (my $i=0;$i<$repetition;$i++) { |
for (my $i=0;$i<$repetition;$i++) { |
# A is 1, B is 2, etc. (get response return 0-9 and then we add 1) |
# A is 1, B is 2, etc. |
my $increase=&Apache::response::getresponse($i+1); |
my $increase=&Apache::response::getresponse($i+1); |
if ($increase ne '') { $score+=$increase+1; } |
unless (($increase == $bubbles_per_row-1) && |
|
($env{'form.scantron_lastbubblepoints'} == 0)) { |
|
# (get response return 0-9 and then we add 1) |
|
if ($increase ne '') { |
|
$score+=$increase+1; |
|
} |
|
} |
} |
} |
my $weight = &Apache::lonnet::EXT("resource.$part.weight"); |
my $weight = &Apache::lonnet::EXT("resource.$part.weight"); |
if (!defined($weight) || $weight eq '' || $weight eq 0) { $weight = 1; } |
if (!defined($weight) || $weight eq '' || $weight eq 0) { $weight = 1; } |
Line 1140 sub whichorder {
|
Line 1181 sub whichorder {
|
|
|
sub show_answer { |
sub show_answer { |
my $part = $Apache::inputtags::part; |
my $part = $Apache::inputtags::part; |
my $award = $Apache::lonhomework::history{"resource.$part.solved"}; |
my $award = $Apache::lonhomework::history{"resource.$part.awarded"}; |
my $status = $Apache::inputtags::status[-1]; |
my $status = $Apache::inputtags::status[-1]; |
return ( ($award =~ /^correct/ |
return ( ($award ==1 |
&& &Apache::lonhomework::show_problem_status()) |
&& &Apache::lonhomework::show_problem_status()) |
|| $status eq "SHOW_ANSWER"); |
|| $status eq "SHOW_ANSWER"); |
} |
} |