[LON-CAPA-cvs] cvs: loncom /interface lonsyllabus.pm /lonnet/perl lonnet.pm

www lon-capa-cvs@mail.lon-capa.org
Tue, 25 Mar 2003 19:18:40 -0000


www		Tue Mar 25 14:18:40 2003 EDT

  Modified files:              
    /loncom/interface	lonsyllabus.pm 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  First use of reverse role association
  
  
Index: loncom/interface/lonsyllabus.pm
diff -u loncom/interface/lonsyllabus.pm:1.16 loncom/interface/lonsyllabus.pm:1.17
--- loncom/interface/lonsyllabus.pm:1.16	Mon Mar 10 09:20:07 2003
+++ loncom/interface/lonsyllabus.pm	Tue Mar 25 14:18:40 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Syllabus
 #
-# $Id: lonsyllabus.pm,v 1.16 2003/03/10 14:20:07 www Exp $
+# $Id: lonsyllabus.pm,v 1.17 2003/03/25 19:18:40 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -92,6 +92,22 @@
        ("Syllabus",$forcestudent,$addentries,'',$cdom,$ENV{'form.register'}));
     $r->print('<h1>'.$courseenv{'description'}.'</h1><h3>'.
               $Apache::lonnet::domaindescription{$cdom}.'</h3>');
+
+# -------------------------------------------------------- Get course personnel
+    my %coursepersonnel=&Apache::lonnet::get_course_adv_roles($cdom.'/'.$cnum);
+    $r->print('<table border="2">');
+    foreach (keys %coursepersonnel) {
+	$r->print('<tr><td>'.$_.'</td><td>');
+        foreach (split(/\,/,$coursepersonnel{$_})) {
+	    my ($puname,$pudom)=split(/\:/,$_);
+	    $r->print(' '.&Apache::loncommon::aboutmewrapper(
+                          &Apache::loncommon::plainname($puname,
+                          $pudom),$puname,$pudom));
+	}
+        $r->print('</td></tr>');
+    }
+    $r->print('</table>');
+# ---------------------------------------------------------- Load syllabus info
     my %syllabus=&Apache::lonnet::dump('syllabus',$cdom,$cnum);
     my $allowed=0;
 
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.350 loncom/lonnet/perl/lonnet.pm:1.351
--- loncom/lonnet/perl/lonnet.pm:1.350	Mon Mar 24 14:57:35 2003
+++ loncom/lonnet/perl/lonnet.pm	Tue Mar 25 14:18:40 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.350 2003/03/24 19:57:35 www Exp $
+# $Id: lonnet.pm,v 1.351 2003/03/25 19:18:40 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1057,10 +1057,10 @@
     &logthis('Flushing role logs');
     foreach (keys %userrolehash) {
         my $entry=$_;
-        my ($role,$uname,$udom,$runame,$rudom)=
+        my ($role,$uname,$udom,$runame,$rudom,$rsec)=
 	    split(/\:/,$entry);
         if (&Apache::lonnet::put('nohist_userroles',
-                { $role.':'.$uname.':'.$udom => $userrolehash{$entry} },
+             { $role.':'.$uname.':'.$udom.':'.$rsec => $userrolehash{$entry} },
                 $rudom,$runame) eq 'ok') {
 	    delete $userrolehash{$entry};
         }
@@ -1124,7 +1124,32 @@
          {$trole.':'.$username.':'.$domain.':'.$runame.':'.$rudom.':'.$rsec}
                     =$tend.':'.$tstart;
    }
-}    
+}
+
+sub get_course_adv_roles {
+    my $cid=shift;
+    $cid=$ENV{'request.course.id'} unless (defined($cid));
+    my %coursehash=&coursedescription($cid);
+    my %returnhash=();
+    my %dumphash=
+            &dump('nohist_userroles',$coursehash{'domain'},$coursehash{'num'});
+    my $now=time;
+    foreach (keys %dumphash) {
+	my ($tend,$tstart)=split(/\:/,$dumphash{$_});
+        if (($tstart) && ($tstart<0)) { next; }
+        if (($tend) && ($tend<$now)) { next; }
+        if (($tstart) && ($now<$tstart)) { next; }
+        my ($role,$username,$domain,$section)=split(/\:/,$_);
+        my $key=&plaintext($role);
+        if ($section) { $key.=' (Sec/Grp '.$section.')'; }
+        if ($returnhash{$key}) {
+	    $returnhash{$key}.=','.$username.':'.$domain;
+        } else {
+            $returnhash{$key}=$username.':'.$domain;
+        }
+    }
+    return sort %returnhash;
+}
 # ----------------------------------------------------------- Check out an item
 
 sub checkout {