--- loncom/homework/lonhomework.pm 2003/04/03 20:05:21 1.118 +++ loncom/homework/lonhomework.pm 2003/05/13 01:56:32 1.126 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Homework handler # -# $Id: lonhomework.pm,v 1.118 2003/04/03 20:05:21 albertel Exp $ +# $Id: lonhomework.pm,v 1.126 2003/05/13 01:56:32 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -50,6 +50,7 @@ use Apache::essayresponse(); use Apache::externalresponse(); use Apache::rankresponse(); use Apache::matchresponse(); +#use Apache::chemresponse(); use Apache::Constants qw(:common); use HTML::Entities(); use Apache::loncommon(); @@ -60,12 +61,13 @@ BEGIN { } sub get_target { - if ( $ENV{'request.state'} eq "published") { + if (($ENV{'request.state'} eq "published") || + ($ENV{'request.state'} eq "uploaded")) { if ( defined($ENV{'form.grade_target'} ) && ($ENV{'form.grade_target'} eq 'tex')) { return ($ENV{'form.grade_target'}); } elsif ( defined($ENV{'form.grade_target'} ) - && ($Apache::lonhomework::viewgrades == 'F' )) { + && ($Apache::lonhomework::viewgrades eq 'F' )) { return ($ENV{'form.grade_target'}); } @@ -207,12 +209,16 @@ sub check_access { $datemsg = "was due on $lastdate, and answers will be available on $date"; } if ($status eq 'CAN_ANSWER') { - #check #tries + #check #tries, and if correct. my $tries = $Apache::lonhomework::history{"resource.$id.tries"}; my $maxtries = &Apache::lonnet::EXT("resource.$id.maxtries"); if ( $tries eq '' ) { $tries = '0'; } if ( $maxtries eq '' ) { $maxtries = '2'; } if ($tries >= $maxtries) { $status = 'CANNOT_ANSWER'; } + if($Apache::lonhomework::history{"resource.$id.solved"}=~/^correct/ + && lc($Apache::lonhomework::problemstatus) ne 'no') { + $status = 'CANNOT_ANSWER'; + } } if (($status ne 'CLOSED') && ($Apache::lonhomework::type eq 'exam') && @@ -285,18 +291,19 @@ sub setuppermissions { } sub setupheader { - my $request=$_[0]; - if ($ENV{'browser.mathml'}) { - $request->content_type('text/xml'); - } else { - $request->content_type('text/html'); - } - if (!$Apache::lonxml::debug && ($ENV{'REQUEST_METHOD'} eq 'GET')) { - &Apache::loncommon::no_cache($request); - } - $request->send_http_header; - return OK if $request->header_only; - return '' + my $request=$_[0]; + if ($ENV{'browser.mathml'}) { + $request->content_type('text/xml'); + } else { + $request->content_type('text/html'); + } + $request->content_encoding('UTF-8'); + if (!$Apache::lonxml::debug && ($ENV{'REQUEST_METHOD'} eq 'GET')) { + &Apache::loncommon::no_cache($request); + } + $request->send_http_header; + return OK if $request->header_only; + return '' } sub handle_save_or_undo { @@ -600,7 +607,6 @@ sub handler { #my $t0 = [&gettimeofday()]; my $request=$_[0]; -# if ( $ENV{'user.name'} eq 'albertel' ) {$Apache::lonxml::debug=1;} $Apache::lonxml::debug=$ENV{'user.debug'}; if (&setupheader($request)) { return OK; }