version 1.131, 2008/03/06 02:20:05
|
version 1.136, 2008/06/12 00:46:52
|
Line 260 sub caparesponse_check {
|
Line 260 sub caparesponse_check {
|
|
|
sub caparesponse_check_list { |
sub caparesponse_check_list { |
my $responses=$LONCAPA::CAPAresponse_args{'response'}; |
my $responses=$LONCAPA::CAPAresponse_args{'response'}; |
# &LONCAPA_INTERNAL_DEBUG(" answer is ". |
|
# &LONCAPA_INTERNAL_Dumper($LONCAPA::CAPAresponse_answer).":\n"); |
|
# &LONCAPA_INTERNAL_DEBUG(" respons is ". |
|
# &LONCAPA_INTERNAL_Dumper($responses).":\n"); |
|
&LONCAPA_INTERNAL_DEBUG("args ".join(':',%LONCAPA::CAPAresponse_args)); |
&LONCAPA_INTERNAL_DEBUG("args ".join(':',%LONCAPA::CAPAresponse_args)); |
my $type = $LONCAPA::CAPAresponse_args{'type'}; |
my $type = $LONCAPA::CAPAresponse_args{'type'}; |
&LONCAPA_INTERNAL_DEBUG("Got type :$type:\n"); |
my $answerunit=$LONCAPA::CAPAresponse_args{'unit'}; |
|
&LONCAPA_INTERNAL_DEBUG("Got type :$type: answer unit :$answerunit:\n"); |
|
|
my $num_input_lines = |
my $num_input_lines = |
scalar(@{$LONCAPA::CAPAresponse_answer->{'answers'}}); |
scalar(@{$LONCAPA::CAPAresponse_answer->{'answers'}}); |
Line 291 sub caparesponse_check_list {
|
Line 288 sub caparesponse_check_list {
|
$responses->[$which]=[$responses->[$which]]; |
$responses->[$which]=[$responses->[$which]]; |
} |
} |
} |
} |
# &LONCAPA_INTERNAL_DEBUG(" parsed response is ". |
|
# &LONCAPA_INTERNAL_Dumper($responses).":\n"); |
|
foreach my $which (0..($num_input_lines-1)) { |
foreach my $which (0..($num_input_lines-1)) { |
my $answer_size = |
my $answer_size = |
scalar(@{$LONCAPA::CAPAresponse_answer->{'answers'}[$which]}); |
scalar(@{$LONCAPA::CAPAresponse_answer->{'answers'}[$which]}); |
Line 311 sub caparesponse_check_list {
|
Line 306 sub caparesponse_check_list {
|
if ($type eq '' || $type eq 'float') { |
if ($type eq '' || $type eq 'float') { |
#for numerical problems split off the unit |
#for numerical problems split off the unit |
# if ( $responses->[0][-1]=~ /(.*[^\s])\s+([^\s]+)/ ) { |
# if ( $responses->[0][-1]=~ /(.*[^\s])\s+([^\s]+)/ ) { |
if ( $responses->[0][-1]=~ /^([\d\.\,\s\$]*(?:(?:[xX\*]10[\^\*]*|[eE]*)[\+\-]*\d*)*(?:^|\S)\d+)([\$\s\w\^\*\/\(\)\+\-]*[^\d\.][\$\s\w\^\*\/\(\)\+\-]*)$/ ) { |
if ( $responses->[0][-1]=~ /^([\d\.\,\s\$]*(?:(?:[xX\*]10[\^\*]*|[eE]*)[\+\-]*\d*)*(?:^|\S)\d+)([\$\s\w\^\*\/\(\)\+\-]*[^\d\.\s\,][\$\s\w\^\*\/\(\)\+\-]*)$/ ) { |
$responses->[0][-1]=$1; |
$responses->[0][-1]=$1; |
$unit=&capa_formula_fix($2); |
$unit=&capa_formula_fix($2); |
&LONCAPA_INTERNAL_DEBUG("Found unit :$unit:"); |
&LONCAPA_INTERNAL_DEBUG("Found unit :$unit:"); |
Line 319 sub caparesponse_check_list {
|
Line 314 sub caparesponse_check_list {
|
} |
} |
&LONCAPA_INTERNAL_DEBUG("Final final response :$responses->[0][-1]:$unit:"); |
&LONCAPA_INTERNAL_DEBUG("Final final response :$responses->[0][-1]:$unit:"); |
$unit=~s/\s//; |
$unit=~s/\s//; |
if ($unit ne '') { |
foreach my $response (@$responses) { |
foreach my $response (@$responses) { |
foreach my $element (@$response) { |
foreach my $element (@$response) { |
$element =~ s/\s//g; |
$element =~ s/\s//g; |
my $appendunit=$unit; |
$element .= " $unit"; |
if ($unit=~/\%/) { |
} |
$element=$element/100; |
} |
$appendunit=~s/\%//; |
|
} |
|
if (($element==0) && ($unit!~/\w/) && ($answerunit=~/\w/)) { |
|
$appendunit=$answerunit; |
|
} |
|
$element .= " $appendunit"; |
|
&LONCAPA_INTERNAL_DEBUG("Made response element :$element:"); |
|
} |
} |
} |
|
|
foreach my $thisanswer (@{ $LONCAPA::CAPAresponse_answer->{'answers'} }) { |
foreach my $thisanswer (@{ $LONCAPA::CAPAresponse_answer->{'answers'} }) { |
Line 1022 sub sec {
|
Line 1024 sub sec {
|
return $sec; |
return $sec; |
} |
} |
|
|
|
sub submission { |
|
my ($partid,$responseid,$subnumber)=@_; |
|
my $sub=''; |
|
if ($subnumber) { $sub=$subnumber.':'; } |
|
return &EXT('user.resource.'.$sub.'resource.'.$partid.'.'.$responseid.'.submission'); |
|
} |
|
|
|
sub currentpart { |
|
return $external::part; |
|
} |
|
|
|
sub eval_time { |
|
my ($timestamp)=@_; |
|
unless ($timestamp) { return ''; } |
|
return &locallocaltime($timestamp); |
|
} |
|
|
sub open_date { |
sub open_date { |
my @dc = split(/\s+/,localtime(&EXT('resource.0.opendate'))); |
my ($partid)=@_; |
return '' if ($dc[0] eq "Wed" and $dc[2] == 31 and $dc[4] == 1969); |
unless ($partid) { $partid=0; } |
my @hm = split(/:/,$dc[3]); |
return &eval_time(&EXT('resource.'.$partid.'.opendate')); |
my $ampm = " am"; |
} |
if ($hm[0] > 12) { |
|
$hm[0]-=12; |
sub due_date { |
$ampm = " pm"; |
my ($partid)=@_; |
} |
unless ($partid) { $partid=0; } |
return $dc[0].', '.$dc[1].' '.$dc[2].', '.$dc[4].' at '.$hm[0].':'.$hm[1].$ampm; |
return &eval_time(&EXT('resource.'.$partid.'.duedate')); |
} |
|
|
|
sub due_date { |
|
my @dc = split(/\s+/,localtime(&EXT('resource.0.duedate'))); |
|
return '' if ($dc[0] eq "Wed" and $dc[2] == 31 and $dc[4] == 1969); |
|
my @hm = split(/:/,$dc[3]); |
|
my $ampm = " am"; |
|
if ($hm[0] > 12) { |
|
$hm[0]-=12; |
|
$ampm = " pm"; |
|
} |
|
return $dc[0].', '.$dc[1].' '.$dc[2].', '.$dc[4].' at '.$hm[0].':'.$hm[1].$ampm; |
|
} |
} |
|
|
sub answer_date { |
sub answer_date { |
my @dc = split(/\s+/,localtime(&EXT('resource.0.answerdate'))); |
my ($partid)=@_; |
return '' if ($dc[0] eq "Wed" and $dc[2] == 31 and $dc[4] == 1969); |
unless ($partid) { $partid=0; } |
my @hm = split(/:/,$dc[3]); |
return &eval_time(&EXT('resource.'.$partid.'.answerdate')); |
my $ampm = " am"; |
} |
if ($hm[0] > 12) { |
|
$hm[0]-=12; |
sub open_date_epoch { |
$ampm = " pm"; |
my ($partid)=@_; |
} |
unless ($partid) { $partid=0; } |
return $dc[0].', '.$dc[1].' '.$dc[2].', '.$dc[4].' at '.$hm[0].':'.$hm[1].$ampm; |
return &EXT('resource.'.$partid.'.opendate'); |
|
} |
|
|
|
sub due_date_epoch { |
|
my ($partid)=@_; |
|
unless ($partid) { $partid=0; } |
|
return &EXT('resource.'.$partid.'.duedate'); |
|
} |
|
|
|
sub answer_date_epoch { |
|
my ($partid)=@_; |
|
unless ($partid) { $partid=0; } |
|
return &EXT('resource.'.$partid.'.answerdate'); |
} |
} |
|
|
sub array_moments { |
sub array_moments { |