--- loncom/homework/lonhomework.pm 2003/02/13 21:14:35 1.108 +++ loncom/homework/lonhomework.pm 2003/02/25 18:49:05 1.109 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Homework handler # -# $Id: lonhomework.pm,v 1.108 2003/02/13 21:14:35 albertel Exp $ +# $Id: lonhomework.pm,v 1.109 2003/02/25 18:49:05 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -339,7 +339,9 @@ sub handle_save_or_undo { sub analyze_header { my ($request) = @_; - my $result.=' + my $result.=' + Analyzing a problem +
@@ -353,6 +355,13 @@ sub analyze_header { $request->rflush(); } +sub analyze_footer { + my ($request) = @_; + my $result=''; + $request->print($result); + $request->rflush(); +} + sub analyze { my ($request,$file) = @_; &Apache::lonxml::debug("Analyze"); @@ -368,23 +377,34 @@ sub analyze { &Apache::lonxml::debug(":$subresult:"); (my $garbage,$subresult)=split(/_HASH_REF__/,$subresult,2); my %analyze=&Apache::lonnet::str2hash($subresult); + $Apache::lonxml::debug=1; &Apache::lonhomework::showhash(%analyze); + $Apache::lonxml::debug=0; my @parts = @{ $analyze{'parts'} }; foreach my $part (@parts) { if (!exists($allparts{$part})) {$allparts{$part}=1;}; - if ($analyze{$part.'.type'} eq 'numericalresponse') { + if ($analyze{$part.'.type'} eq 'numericalresponse' || + $analyze{$part.'.type'} eq 'stringresponse' || + $analyze{$part.'.type'} eq 'formularesponse' ) { push( @{ $overall{$part.'.answer'} }, [@{ $analyze{$part.'.answer'} }]); } } } foreach my $part (keys(%allparts)) { - $request->print(''); - foreach my $answer (sort {$a->[0] <=> $b->[0]} (@{ $overall{$part.'.answer'} })) { - $request->print(''); + if (defined(@{ $overall{$part.'.answer'} })) { + $request->print('
Part '.$part.'
'.join('',@{ $answer }). - '
'); + foreach my $answer (sort {$a->[0] <=> $b->[0]} (@{ $overall{$part.'.answer'} })) { + $request->print(''); + } + $request->print('
Part '.$part.'
'.join('',@{ $answer }). + '
'); + } else { + $request->print('

Part '.$part. + ' is not analyzabale at this time

'); } } + &analyze_footer($request); &Apache::lonhomework::showhash(%overall); return $result; } @@ -448,7 +468,7 @@ sub renderpage { my %mystyle; my $result = ''; - if ($target eq 'analyze') { %Apache::lonhomework::anaylze=(); } + if ($target eq 'analyze') { %Apache::lonhomework::analyze=(); } if ($target eq 'answer') { &showhash(%Apache::lonhomework::history); } if ($target eq 'web') {&Apache::lonhomework::showhashsubset(\%ENV,'^form');}