--- loncom/homework/response.pm 2002/10/08 18:04:04 1.65 +++ loncom/homework/response.pm 2003/02/13 23:48:27 1.69 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # various response type definitons response definition # -# $Id: response.pm,v 1.65 2002/10/08 18:04:04 bowersj2 Exp $ +# $Id: response.pm,v 1.69 2003/02/13 23:48:27 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -68,7 +68,10 @@ sub start_hintresponse { sub end_hintresponse { pop @Apache::inputtags::response; - %Apache::inputtags::params=@{pop(@Apache::inputtags::paramstack)}; + if (defined($Apache::inputtags::paramstack[-1])) { + %Apache::inputtags::params= + @{ pop(@Apache::inputtags::paramstack) }; + } return ''; } @@ -172,7 +175,7 @@ sub check_for_previous { my ($curresponse,$partid,$id) = @_; my %previous; $previous{'used'} = 0; - foreach my $key (reverse(sort(keys(%Apache::lonhomework::history)))) { + foreach my $key (sort(keys(%Apache::lonhomework::history))) { if ($key =~ /resource\.$partid\.$id\.submission/) { &Apache::lonxml::debug("Trying $key"); my $pastresponse=$Apache::lonhomework::history{$key}; @@ -183,16 +186,17 @@ sub check_for_previous { $history=$1; $previous{'award'} = $Apache::lonhomework::history{"$history:resource.$partid.$id.awarddetail"}; $previous{'last'}='0'; + push(@{ $previous{'version'} },$history); } else { $previous{'award'} = $Apache::lonhomework::history{"resource.$partid.$id.awarddetail"}; $previous{'last'}='1'; } if (! $previous{'award'} ) { $previous{'award'} = 'UNKNOWN'; } &Apache::lonxml::debug("got a match :$previous{'award'}:$previous{'used'}:"); - last; } } } + &Apache::lonhomework::showhash(%previous); return %previous; } @@ -204,6 +208,7 @@ sub handle_previous { } else { push(@Apache::inputtags::previous,'PREVIOUSLY_USED'); } + push(@Apache::inputtags::previous_version,$$previous{'version'}); } } @@ -245,7 +250,7 @@ sub end_dataresponse { my ($symb,$courseid,$domain,$name)=&Apache::lonxml::whichuser(); my $allowed=&Apache::lonnet::allowed('mgr',$courseid); if ($allowed) { - &Apache::response::setup_params('datasubmission'); + &Apache::response::setup_params('dataresponse'); my $partid = $Apache::inputtags::part; my $id = $Apache::inputtags::response['-1']; my $response = $ENV{'form.HWVAL'.$id}; @@ -293,8 +298,8 @@ sub start_responseparam { $result = &Apache::edit::rebuild_tag($token); $result.=&Apache::edit::handle_insert(); } - } elsif ($target eq 'grade' || $target eq 'answer' || - $target eq 'web' || $target eq 'tex') { + } elsif ($target eq 'grade' || $target eq 'answer' || $target eq 'web' || + $target eq 'tex' || $target eq 'analyze' ) { if ($ENV{'request.state'} eq 'construct') { my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval); my $default = &Apache::lonxml::get_param('default',$parstack,$safeeval); @@ -320,11 +325,14 @@ sub end_parameter { return $result; } +sub reset_params { + %Apache::inputtags::params=(); +} + sub setup_params { my ($tag) = @_; if ($ENV{'request.state'} eq 'construct') { return; } - %Apache::inputtags::params=(); my %paramlist=(); foreach my $key (keys(%Apache::lonnet::packagetab)) { if ($key =~ /^$tag/) {