--- loncom/homework/lonhomework.pm 2003/03/10 20:03:55 1.114
+++ loncom/homework/lonhomework.pm 2003/05/09 17:01:08 1.122
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Homework handler
#
-# $Id: lonhomework.pm,v 1.114 2003/03/10 20:03:55 albertel Exp $
+# $Id: lonhomework.pm,v 1.122 2003/05/09 17:01:08 albertel 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();
@@ -65,11 +66,12 @@ sub get_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'});
}
- if ( defined($ENV{'form.submitted'})) {
+ if ( defined($ENV{'form.submitted'}) &&
+ ( !defined($ENV{'form.resetdata'}))) {
return ('grade', 'web');
} else {
return ('web');
@@ -206,12 +208,15 @@ 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/) {
+ $status = 'CANNOT_ANSWER';
+ }
}
if (($status ne 'CLOSED') && ($Apache::lonhomework::type eq 'exam') &&
@@ -284,18 +289,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 {
@@ -422,7 +428,7 @@ sub editxmlmode {
my ($request,$file) = @_;
my $result;
my $problem=&Apache::lonnet::getfile($file);
- if ($problem == -1) {
+ if ($problem eq -1) {
&Apache::lonxml::error(" Unable to find $file");
$problem='';
}
@@ -478,7 +484,7 @@ sub renderpage {
foreach my $target (@targets) {
#my $t0 = [&gettimeofday()];
my $problem=&Apache::lonnet::getfile($file);
- if ($problem == -1) {
+ if ($problem eq -1) {
&Apache::lonxml::error(" Unable to find $file");
$problem='';
}
@@ -531,7 +537,7 @@ sub get_template_list {
}
}
if (@allnames && !$result) {
- $result="\n\n';
}
return $result;
@@ -599,7 +605,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; }
@@ -631,11 +636,16 @@ sub handler {
}
}
+ my ($symb) = &Apache::lonxml::whichuser();
+ &Apache::lonxml::debug('symb is '.$symb);
+ if ($ENV{'request.state'} eq "construct" || $symb eq '') {
+ if ($ENV{'form.resetdata'} eq 'Reset Submissions' ||
+ $ENV{'form.resetdata'} eq 'New Problem Variation' ) {
+ my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser();
+ &Apache::lonnet::tmpreset($symb,'',$domain,$name);
+ }
+ }
if ($ENV{'request.state'} eq "construct") {
- if ($ENV{'form.resetdata'} eq 'Reset Submissions') {
- my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser();
- &Apache::lonnet::tmpreset($symb,'',$domain,$name);
- }
if ( -e $file ) {
if (!(defined $ENV{'form.problemmode'})) {
#first visit to problem in construction space