--- loncom/homework/lonhomework.pm 2005/08/29 19:28:43 1.218 +++ loncom/homework/lonhomework.pm 2005/11/08 21:09:08 1.221 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Homework handler # -# $Id: lonhomework.pm,v 1.218 2005/08/29 19:28:43 albertel Exp $ +# $Id: lonhomework.pm,v 1.221 2005/11/08 21:09:08 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -581,10 +581,8 @@ sub handle_save_or_undo { sub analyze_header { my ($request) = @_; - my $bodytag=''; - if ($env{'environment.remote'} eq 'off') { - $bodytag=&Apache::loncommon::bodytag(); - } + my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef, + ($env{'environment.remote'} ne 'off')); my $html=&Apache::lonxml::xmlbegin(); my $result.=$html.' '.&mt("Analyzing a problem").' @@ -615,6 +613,7 @@ sub analyze { &Apache::lonxml::debug("Analyze"); my $result; my %overall; + my %seedexample; my %allparts; my $rndseed=$env{'form.rndseed'}; &analyze_header($request); @@ -627,9 +626,10 @@ sub analyze { &Apache::lonhtmlcommon::Increment_PrgWin($request,\%prog_state, &mt('last problem')); if (&Apache::loncommon::connection_aborted($request)) { return; } + my $thisseed=$i+$rndseed; my $subresult=&Apache::lonnet::ssi($request->uri, ('grade_target' => 'analyze'), - ('rndseed' => $i+$rndseed)); + ('rndseed' => $thisseed)); (my $garbage,$subresult)=split(/_HASH_REF__/,$subresult,2); my %analyze=&Apache::lonnet::str2hash($subresult); my @parts; @@ -641,8 +641,13 @@ sub analyze { if ($analyze{$part.'.type'} eq 'numericalresponse' || $analyze{$part.'.type'} eq 'stringresponse' || $analyze{$part.'.type'} eq 'formularesponse' ) { + my $concatanswer=join("\0",@{ $analyze{$part.'.answer'} }); + if (($concatanswer eq '') || ($concatanswer=~/^\@/)) { + @{$analyze{$part.'.answer'}}=(''.&mt('Error').''); + } push( @{ $overall{$part.'.answer'} }, [@{ $analyze{$part.'.answer'} }]); + $seedexample{join("\0",@{ $analyze{$part.'.answer'}})}=$thisseed; } } } @@ -652,17 +657,18 @@ sub analyze { foreach my $part (sort(keys(%allparts))) { if (defined(@{ $overall{$part.'.answer'} })) { my $num_cols=scalar(@{ $overall{$part.'.answer'}->[0] }); - $request->print(''); + $request->print('
'.&mt('Part').' '.$part.'
'); my %frequency; foreach my $answer (sort {$a->[0] <=> $b->[0]} (@{ $overall{$part.'.answer'} })) { $frequency{join("\0",@{ $answer })}++; } - $request->print(''); + $request->print(''); foreach my $answer (sort {(split("\0",$a))[0] <=> (split("\0",$b))[0]} (keys(%frequency))) { - $request->print(''); + $request->print(''); } $request->print('
'.&mt('Part').' '.$part.'
'.&mt('Answer').''.&mt('Frequency').'
'.&mt('Answer').''.&mt('Frequency').'
(' + .&mt('click for example').')
'. - join('',split("\0",$answer)). - '('.$frequency{$answer}. - ')
'. + join('',split("\0",$answer)). + ''.$frequency{$answer}. + '
'); } else { @@ -709,10 +715,8 @@ sub editxmlmode { if ($cols > 80) { $cols = 80; } if ($cols < 70) { $cols = 70; } if ($rows < 20) { $rows = 20; } - my $bodytag=''; - if ($env{'environment.remote'} eq 'off') { - $bodytag=&Apache::loncommon::bodytag(); - } + my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef, + ($env{'environment.remote'} ne 'off')); my $html=&Apache::lonxml::xmlbegin(); $result.=$html.$bodytag. &renderpage($request,$file,['no_output_web'],1).