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

raeburn lon-capa-cvs@mail.lon-capa.org
Thu, 27 Jan 2005 19:20:56 -0000


raeburn		Thu Jan 27 14:20:56 2005 EDT

  Modified files:              
    /loncom/interface	lonpickcourse.pm 
  Log:
  Fix bug 3806.
  
  
Index: loncom/interface/lonpickcourse.pm
diff -u loncom/interface/lonpickcourse.pm:1.23 loncom/interface/lonpickcourse.pm:1.24
--- loncom/interface/lonpickcourse.pm:1.23	Tue Dec 28 00:55:11 2004
+++ loncom/interface/lonpickcourse.pm	Thu Jan 27 14:20:55 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Pick a course
 #
-# $Id: lonpickcourse.pm,v 1.23 2004/12/28 05:55:11 raeburn Exp $
+# $Id: lonpickcourse.pm,v 1.24 2005/01/27 19:20:55 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -225,18 +225,31 @@
             } else {
                 $descr = &Apache::lonnet::unescape($courses{$course});
             }
-            $by_descrip{lc($descr)}=$course;
+            my $description = lc($descr);
+            if (exists($by_descrip{$description})) {
+                push @{$by_descrip{$description}}, ($course);
+            } else {
+                @{$by_descrip{$description}} = ($course);
+            }
 	}
 	foreach my $description (sort(keys(%by_descrip))) {
-	    my $course=$by_descrip{$description};
-	    my $cleandesc=&HTML::Entities::encode($description,'<>&"');
-	    $cleandesc=~s/'/\\'/g;
-	    my ($cdom,$cnum)=split(/\_/,$course);
-	    $r->print('<input type="button" value="Select" onClick="gochoose('.
-		  "'".$cnum."','".$cdom."','".$cleandesc."')".'" /> '.$description.' ('.
-		  ($Apache::lonnet::domaindescription{$cdom}?
-                   $Apache::lonnet::domaindescription{$cdom}:$cdom).
-                 ")<br />\n");
+            foreach my $course (@{$by_descrip{$description}}) {
+	        my $cleandesc=&HTML::Entities::encode($description,'<>&"');
+	        $cleandesc=~s/'/\\'/g;
+	        my ($cdom,$cnum)=split(/\_/,$course);
+                my ($descr,$instcode,$owner) = split/:/,$courses{$course};
+	        $r->print('<input type="button" value="Select" onClick="gochoose('.
+		      "'".$cnum."','".$cdom."','".$cleandesc."')".'" /> '.$description.' ('.
+		      ($Apache::lonnet::domaindescription{$cdom}?
+                       $Apache::lonnet::domaindescription{$cdom}:$cdom).")");
+                unless ($instcode eq '') {
+                    $r->print(" - ".&Apache::lonnet::unescape($instcode));
+                }
+                unless ($owner eq '') {
+                    $r->print(", owner - ".&Apache::lonnet::unescape($owner));
+                }
+                $r->print("<br />\n");
+            }
 	}
 	if (!%courses) { $r->print(&mt('None found')); }
         $r->print('<input type="hidden" name="form" value="'.$ENV{'form.form'}.'" />'."\n".