--- loncom/homework/bridgetask.pm 2005/11/21 21:51:29 1.81 +++ loncom/homework/bridgetask.pm 2006/03/31 20:29:56 1.135 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # definition of tags that give a structure to a document # -# $Id: bridgetask.pm,v 1.81 2005/11/21 21:51:29 albertel Exp $ +# $Id: bridgetask.pm,v 1.135 2006/03/31 20:29:56 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -80,21 +80,28 @@ sub proctor_check_auth { } } if ($authenticated && $type eq 'Task') { + # increment version my $version= - $Apache::lonhomework::results{'resource.version'}= - ++$Apache::lonhomework::history{'resource.version'}; - $Apache::lonhomework::results{"resource.$version.checkedin"}= - $user.'@'.$domain; - $Apache::lonhomework::results{"resource.$version.checkedin.slot"}= - $slot_name; + $Apache::lonhomework::history{'resource.0.version'}; + $version++; + + #clean out all current results foreach my $key (keys(%Apache::lonhomework::history)) { if ($key=~/^resource\.0\./) { $Apache::lonhomework::results{$key}=''; } } + + #setup new version and who did it + $Apache::lonhomework::results{'resource.0.version'}=$version; + $Apache::lonhomework::results{"resource.$version.0.checkedin"}= + $user.'@'.$domain; + $Apache::lonhomework::results{"resource.$version.0.checkedin.slot"}= + $slot_name; + return 1; } elsif ($authenticated && $type eq 'problem') { - &Apache::lonxml::debug("authed #slot_name"); + &Apache::lonxml::debug("authed $slot_name"); $Apache::lonhomework::results{"resource.0.checkedin"}= $user.'@'.$domain; $Apache::lonhomework::results{"resource.0.checkedin.slot"}= @@ -109,11 +116,11 @@ sub get_version { my ($version,$previous); if ($env{'form.previousversion'} && $env{'form.previousversion'} ne 'current' && - defined($Apache::lonhomework::history{'resource.'.$env{'form.previousversion'}.'.status'})) { + defined($Apache::lonhomework::history{'resource.'.$env{'form.previousversion'}.'.0.status'})) { $version=$env{'form.previousversion'}; $previous=1; } else { - $version=$Apache::lonhomework::history{'resource.version'}; + $version=$Apache::lonhomework::history{'resource.0.version'}; $previous=0; } if (wantarray) { @@ -125,10 +132,10 @@ sub get_version { sub add_previous_version_button { my ($status)=@_; my $result; - if ($Apache::lonhomework::history{'resource.version'} eq '') { + if ($Apache::lonhomework::history{'resource.0.version'} eq '') { return ''; } - if ($Apache::lonhomework::history{'resource.version'} < 2 && + if ($Apache::lonhomework::history{'resource.0.version'} < 2 && $status ne 'NEEDS_CHECKIN') { return ''; } @@ -139,8 +146,8 @@ sub add_previous_version_button { "\n"; } my @to_show; - foreach my $test_version (1..$Apache::lonhomework::history{'resource.version'}) { - if (defined($Apache::lonhomework::history{'resource.'.$test_version.'.status'})) { + foreach my $test_version (1..$Apache::lonhomework::history{'resource.0.version'}) { + if (defined($Apache::lonhomework::history{'resource.'.$test_version.'.0.status'})) { push(@to_show,$test_version); } } @@ -148,7 +155,7 @@ sub add_previous_version_button { join("\n\n"; $list.=''; - $result.='