[LON-CAPA-cvs] cvs: loncom /interface groupsort.pm

www lon-capa-cvs@mail.lon-capa.org
Fri, 10 Jun 2005 15:17:36 -0000


www		Fri Jun 10 11:17:36 2005 EDT

  Modified files:              
    /loncom/interface	groupsort.pm 
  Log:
  Reading files now
  
  
Index: loncom/interface/groupsort.pm
diff -u loncom/interface/groupsort.pm:1.34 loncom/interface/groupsort.pm:1.35
--- loncom/interface/groupsort.pm:1.34	Thu Jun  9 22:19:51 2005
+++ loncom/interface/groupsort.pm	Fri Jun 10 11:17:35 2005
@@ -2,7 +2,7 @@
 # The LON-CAPA group sort handler
 # Allows for sorting prior to import into RAT.
 #
-# $Id: groupsort.pm,v 1.34 2005/06/10 02:19:51 www Exp $
+# $Id: groupsort.pm,v 1.35 2005/06/10 15:17:35 www Exp $
 # 
 # Copyright Michigan State University Board of Trustees
 #
@@ -200,7 +200,7 @@
 # -------------------------------------------------------------- Read from file
 
 sub readfromfile {
-    my ($r,$shash,$thash)=@_;
+    my ($r,$shash,$thash,$nhash)=@_;
     my $cont=&Apache::lonnet::getfile
 	(&Apache::lonnet::filelocation('',$env{'form.readfile'}));
     if ($cont==-1) {
@@ -209,6 +209,7 @@
     } else {
         my $parser = HTML::TokeParser->new(\$cont);
         my $token;
+	my $n=1;
         while ($token = $parser->get_token) {
 	    if ($token->[0] eq 'S') {
                 if ($token->[1] eq 'resource') {
@@ -217,15 +218,18 @@
 		    } else {
 			if ($token->[2]->{'type'} eq 'zombie') { next; }
 		    }
-                    my $name=$token->[2]->{'title'};
+
 		    my $url=$token->[2]->{'src'};
+                    my $name=$token->[2]->{'title'};
 		    $name=~s/ \[\((\d+)\,(\w+)\,(\w+)\)\]$//;
 		    if ($1) {
-			$name.='<br />'.&mt('Removed by ').
+			$$nhash{$url}='<br />'.&mt('Removed by ').
 			    &Apache::loncommon::plainname($2,$3).', '.
 			    &Apache::lonlocal::locallocaltime($1);
 		    }
-		    $r->print('<br />'.$name);
+		    $$thash{$url}=$name;
+                    $$shash{$url}=$n;
+                    $n++;
 		}
 	    }
 	}
@@ -326,9 +330,10 @@
 
     my %shash; # sort order (key is resource location, value is sort order)
     my %thash; # title (key is resource location, value is title)
+    my %nhash; # notes (key is resource location);
 
     if ($env{'form.readfile'}) {
-	&readfromfile($r,\%shash,\%thash);
+	&readfromfile($r,\%shash,\%thash,\%nhash);
     } else {
 	&readfromdb($r,\%shash,\%thash);
     }