[LON-CAPA-cvs] cvs: rat / lonuserstate.pm loncom/interface londocs.pm

www lon-capa-cvs@mail.lon-capa.org
Wed, 29 Oct 2003 21:50:41 -0000


www		Wed Oct 29 16:50:41 2003 EDT

  Modified files:              
    /loncom/interface	londocs.pm 
    /rat	lonuserstate.pm 
  Log:
  Bug #531: Nail down versions of resources.
  
  Needless to say that this now causes all kinds of little nasty follow-up bugs 
  with ambiguous resources, etc., so do not use yet.
  
  
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.92 loncom/interface/londocs.pm:1.93
--- loncom/interface/londocs.pm:1.92	Wed Oct 29 16:21:55 2003
+++ loncom/interface/londocs.pm	Wed Oct 29 16:50:41 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.92 2003/10/29 21:21:55 www Exp $
+# $Id: londocs.pm,v 1.93 2003/10/29 21:50:41 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -596,14 +596,17 @@
 	$haschanged=1;
 	foreach (keys %hash) {
 	    if ($_=~/^ids\_(\/res\/.+)$/) {
-		my $src=$1;
+		$newsetversions{$1}='mostrecent';
 	    }
 	}
     } elsif ($ENV{'form.setcurrent'}) {
 	$haschanged=1;
 	foreach (keys %hash) {
 	    if ($_=~/^ids\_(\/res\/.+)$/) {
-		my $src=$1;
+		my $getvers=&Apache::lonnet::getversion($1);
+		if ($getvers>0) {
+		    $newsetversions{$1}=$getvers;
+		}
 	    }
 	}
     } elsif ($ENV{'form.setversions'}) {
@@ -714,6 +717,9 @@
 	if ($changes{$_}>$starttime) {
 	    my ($root,$extension)=($_=~/^(.*)\.(\w+)$/);
 	    my $currentversion=&Apache::lonnet::getversion($_);
+	    if ($currentversion<0) {
+		$currentversion=&mt('Could not be determined.');
+	    }
 	    my $linkurl=&Apache::lonnet::clutter($_);
 	    $r->print(
 		      '<tr><td><b>'.
@@ -725,7 +731,7 @@
 		      $currentversion.'</font></td><td><font size="+2">');
 # Used in course
 	    my $usedversion=$hash{'version_'.$linkurl};
-	    if ($usedversion) {
+	    if (($usedversion) && ($usedversion ne 'mostrecent')) {
 		$r->print($usedversion);
 	    } else {
 		$r->print($currentversion);
@@ -735,7 +741,7 @@
 	    $r->print(&Apache::loncommon::select_form($setversions{$linkurl},
 						      'set_version_'.$linkurl,
 						      ('' => '',
-						       'current' => 'most recent',
+						       'mostrecent' => 'most recent',
 						       map {$_,$_} (1..$currentversion))));
 	    $r->print('</td><td><font size="1"><ul>');
 	    my $lastold=1;
Index: rat/lonuserstate.pm
diff -u rat/lonuserstate.pm:1.64 rat/lonuserstate.pm:1.65
--- rat/lonuserstate.pm:1.64	Wed Oct 29 16:21:08 2003
+++ rat/lonuserstate.pm	Wed Oct 29 16:50:41 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Construct and maintain state and binary representation of course for user
 #
-# $Id: lonuserstate.pm,v 1.64 2003/10/29 21:21:08 www Exp $
+# $Id: lonuserstate.pm,v 1.65 2003/10/29 21:50:41 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -73,7 +73,7 @@
     my $uri=shift;
     if ($hash{'version_'.$uri}) {
 	my $version=$hash{'version_'.$uri};
-	if ($version eq 'current') { return $uri; }
+	if ($version eq 'mostrecent') { return $uri; }
 	$uri=~s/\.(\w+)$/\.$version\.$1/;
     }
     return $uri;