--- loncom/homework/structuretags.pm 2005/06/03 18:17:57 1.292 +++ loncom/homework/structuretags.pm 2005/06/28 19:17:36 1.295 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # definition of tags that give a structure to a document # -# $Id: structuretags.pm,v 1.292 2005/06/03 18:17:57 raeburn Exp $ +# $Id: structuretags.pm,v 1.295 2005/06/28 19:17:36 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -373,9 +373,9 @@ sub store_aggregates { if ($Apache::lonhomework::results{'resource.'.$part.'.tries'} == 1) { $aggregate{$symb."\0".$part."\0users"} = 1; } else { - my $last_reset = &get_last_reset($symb,$cdomain,$cname,$part); + my (undef,$last_reset) = &Apache::grades::get_last_resets($symb,$env{'request.course.id'},[$part]); if ($last_reset) { - if (&get_num_tries($last_reset,$part) == 0) { + if (&Apache::grades::get_num_tries(\%Apache::lonhomework::history,$last_reset,$part) == 0) { $aggregate{$symb."\0".$part."\0users"} = 1; } } @@ -388,43 +388,6 @@ sub store_aggregates { } } -# ----------- Timestamp of last reset of aggregates -sub get_last_reset { - my ($symb,$cdomain,$cname,$part) =@_; - my $last_reset = ''; - my %resethash = &Apache::lonnet::restore($symb,'nohist_resourcetracker',$cdomain,$cname); - if ($resethash{'version'}) { - for (my $version=$resethash{'version'};$version>=1;$version--) { - if (exists($resethash{$version.':'.$part."\0".'prev_attempts'})) { - $last_reset = $resethash{$version.':timestamp'}; - last; - } - } - } - return $last_reset; -} - -# ----------- Provides number of tries since last reset of aggregates -sub get_num_tries { - my ($last_reset,$part) = @_; - my $timestamp = ''; - my $num_tries = 0; - if ($Apache::lonhomework::history{'version'}) { - for (my $version=$Apache::lonhomework::history{'version'};$version>=1;$version--) { - if (exists($Apache::lonhomework::history{$version.':resource.'.$part.'.solved'})) { - $timestamp = $Apache::lonhomework::history{$version.':timestamp'}; - if ($timestamp > $last_reset) { - $num_tries ++; - } else { - last; - } - } - } - } - return $num_tries; -} - - sub checkout_msg { my %lt=&Apache::lonlocal::texthash( 'resource'=>'The resource needs to be checked out', @@ -547,6 +510,7 @@ sub start_problem { defined($env{'form.problemtype'})) { $Apache::lonhomework::type=$env{'form.problemtype'}; } + $Apache::lonhomework::default_type = $Apache::lonhomework::type; &Apache::lonxml::debug("Found this to be of type :$Apache::ltonhomework::type:"); } if ($Apache::lonhomework::type eq '' ) { @@ -788,7 +752,8 @@ sub end_problem { } if ($target eq 'answer' && ($env{'request.state'} eq 'construct') && $env{'form.answer_output_mode'} ne 'tex') { - $result.=''; # normally we get it from xmlend, but in CSTR + $result.=&Apache::lonxml::xmlend().''; + # normally we get it from above, but in CSTR # we always show answer mode too. } } elsif ($target eq 'meta') { @@ -1297,6 +1262,7 @@ sub end_part { } pop @Apache::inputtags::status; $Apache::inputtags::part=''; + $Apache::lonhomework::type = $Apache::lonhomework::default_type; return $result; }