--- loncom/homework/lonhomework.pm 2005/07/13 19:48:07 1.213 +++ 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.213 2005/07/13 19:48:07 albertel Exp $ +# $Id: lonhomework.pm,v 1.221 2005/11/08 21:09:08 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -183,7 +183,10 @@ sub proctor_checked_in { $Apache::lonxml::browse=''; sub check_ip_acc { my ($acc)=@_; - if (!defined($acc) || $acc =~ /^\s*$/) { return 1; } + &Apache::lonxml::debug("acc is $acc"); + if (!defined($acc) || $acc =~ /^\s*$/ || $acc =~/^\s*no\s*$/i) { + return 1; + } my $allowed=0; my $ip=$ENV{'REMOTE_ADDR'}; my $name; @@ -578,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").' @@ -612,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); @@ -624,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; @@ -638,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; } } } @@ -649,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 { @@ -668,7 +677,7 @@ sub analyze { } } if (scalar(keys(%allparts)) == 0 ) { - $request->print('

'.&mt('Found no analyzable respones in this problem, currently only Numerical, Formula and String response styles are supported.').'

'); + $request->print('

'.&mt('Found no analyzable responses in this problem, currently only Numerical, Formula and String response styles are supported.').'

'); } &Apache::lonhtmlcommon::Close_PrgWin($request,\%prog_state); &analyze_footer($request); @@ -706,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). @@ -773,7 +780,7 @@ sub renderpage { my $result = &Apache::lonxml::xmlparse($request, $target, $problem, &setup_vars($target),%mystyle); undef($Apache::lonhomework::parsing_a_problem); - if (!$output) { $result = '';&Apache::lonxml::message_location().'c'; } + if (!$output) { $result = ''; } #$request->print("Result follows:"); if ($target eq 'modified') { &handle_save_or_undo($request,\$problem,\$result);