--- loncom/homework/lonhomework.pm 2005/06/06 01:21:53 1.211 +++ loncom/homework/lonhomework.pm 2005/08/29 19:28:43 1.218 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Homework handler # -# $Id: lonhomework.pm,v 1.211 2005/06/06 01:21:53 albertel Exp $ +# $Id: lonhomework.pm,v 1.218 2005/08/29 19:28:43 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; @@ -320,6 +323,9 @@ sub check_access { &Apache::lonxml::debug("checking for part :$id:"); &Apache::lonxml::debug("time:".time); + my ($symb)=&Apache::lonxml::whichuser(); + &Apache::lonxml::debug("symb:".$symb); + #if ($env{'request.state'} ne "construct" && $symb ne '') { if ($env{'request.state'} ne "construct") { my $allowed=&check_ip_acc(&Apache::lonnet::EXT("resource.$id.acc")); if (!$allowed && ($Apache::lonhomework::browse ne 'F')) { @@ -372,7 +378,8 @@ sub check_access { $datemsg = &mt("was due on")." $lastdate".&mt(", and answers will be available on")." $date"; } } - if ($status eq 'CAN_ANSWER') { + if ($status eq 'CAN_ANSWER' || + (($Apache::lonhomework::browse eq 'F') && ($status eq 'CLOSED'))) { #check #tries, and if correct. my $tries = $Apache::lonhomework::history{"resource.$id.tries"}; my $maxtries = &Apache::lonnet::EXT("resource.$id.maxtries"); @@ -664,7 +671,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); @@ -707,7 +714,9 @@ sub editxmlmode { $bodytag=&Apache::loncommon::bodytag(); } my $html=&Apache::lonxml::xmlbegin(); - $result.=$html.$bodytag.&Apache::lonxml::message_location().' + $result.=$html.$bodytag. + &renderpage($request,$file,['no_output_web'],1). + &Apache::lonxml::message_location().'
'. &Apache::structuretags::remember_problem_state().' @@ -733,7 +742,7 @@ sub editxmlmode { # Render the page in whatever target desired. # sub renderpage { - my ($request,$file,$targets) = @_; + my ($request,$file,$targets,$return_string) = @_; my @targets = @{$targets || [&get_target()]}; &Apache::lonhomework::showhashsubset(\%env,'form.'); @@ -767,7 +776,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(); } + if (!$output) { $result = ''; } #$request->print("Result follows:"); if ($target eq 'modified') { &handle_save_or_undo($request,\$problem,\$result); @@ -788,9 +797,13 @@ sub renderpage { #$request->print(":Result ends"); #my $td=&tv_interval($t0); } - &Apache::lonxml::add_messages(\$overall_result); - $request->print($overall_result); - $request->rflush(); + if (!$return_string) { + &Apache::lonxml::add_messages(\$overall_result); + $request->print($overall_result); + $request->rflush(); + } else { + return $overall_result; + } } # with no arg it returns a HTML