--- loncom/homework/lonhomework.pm 2003/03/07 23:43:21 1.113 +++ loncom/homework/lonhomework.pm 2003/04/03 20:05:21 1.118 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Homework handler # -# $Id: lonhomework.pm,v 1.113 2003/03/07 23:43:21 albertel Exp $ +# $Id: lonhomework.pm,v 1.118 2003/04/03 20:05:21 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -69,7 +69,8 @@ sub get_target { 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'); @@ -370,17 +371,23 @@ sub analyze { my %allparts; my $rndseed=$ENV{'form.rndseed'}; &analyze_header($request); + my %prog_state= + &Apache::lonhtmlcommon::Create_PrgWin($request,'Analyze Progress', + 'Getting Problem Variants', + $ENV{'form.numtoanalyze'}); for(my $i=1;$i<$ENV{'form.numtoanalyze'}+1;$i++) { + &Apache::lonhtmlcommon::Increment_PrgWin($request,\%prog_state, + 'last problem'); my $subresult=&Apache::lonnet::ssi($request->uri, ('grade_target' => 'analyze'), ('rndseed' => $i)); &Apache::lonxml::debug(":$subresult:"); (my $garbage,$subresult)=split(/_HASH_REF__/,$subresult,2); my %analyze=&Apache::lonnet::str2hash($subresult); - $Apache::lonxml::debug=1; - &Apache::lonhomework::showhash(%analyze); - $Apache::lonxml::debug=0; - my @parts = @{ $analyze{'parts'} }; + my @parts; + if (defined(@{ $analyze{'parts'} })) { + @parts=@{ $analyze{'parts'} }; + } foreach my $part (@parts) { if (!exists($allparts{$part})) {$allparts{$part}=1;}; if ($analyze{$part.'.type'} eq 'numericalresponse' || @@ -391,6 +398,8 @@ sub analyze { } } } + &Apache::lonhtmlcommon::Update_PrgWin($request,\%prog_state, + 'Analyzing Results'); foreach my $part (keys(%allparts)) { if (defined(@{ $overall{$part.'.answer'} })) { $request->print(''); @@ -404,6 +413,7 @@ sub analyze { ' is not analyzabale at this time

'); } } + &Apache::lonhtmlcommon::Close_PrgWin($request,\%prog_state); &analyze_footer($request); &Apache::lonhomework::showhash(%overall); return $result; @@ -413,7 +423,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=''; } @@ -469,7 +479,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=''; } @@ -522,7 +532,7 @@ sub get_template_list { } } if (@allnames && !$result) { - $result="\n\n'; } return $result; @@ -622,11 +632,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
Part '.$part.'