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

www lon-capa-cvs@mail.lon-capa.org
Tue, 27 Aug 2002 16:49:20 -0000


www		Tue Aug 27 12:49:20 2002 EDT

  Modified files:              
    /loncom/interface	loncommon.pm lonsyllabus.pm 
  Log:
  Routines to easily get plain text names and screen names for users,
  and syllabus enhancements.
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.60 loncom/interface/loncommon.pm:1.61
--- loncom/interface/loncommon.pm:1.60	Mon Aug 26 10:32:29 2002
+++ loncom/interface/loncommon.pm	Tue Aug 27 12:49:20 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.60 2002/08/26 14:32:29 matthew Exp $
+# $Id: loncommon.pm,v 1.61 2002/08/27 16:49:20 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -931,6 +931,26 @@
 ###############################################################
 ##              End Thesaurus Functions                      ##
 ###############################################################
+
+# -------------------------------------------------------------- Plaintext name
+
+sub plainname {
+    my ($uname,$udom)=@_;
+    my %names=&Apache::lonnet::get('environment',
+                    ['firstname','middlename','lastname','generation'],
+					 $udom,$uname);
+    return $names{'firstname'}.' '.$names{'middlename'}.' '.
+	$names{'lastname'}.' '.$names{'generation'};
+}
+
+# ------------------------------------------------------------------ Screenname
+
+sub screenname {
+    my ($uname,$udom)=@_;
+    my %names=
+ &Apache::lonnet::get('environment',['screenname'],$udom,$uname);
+    return $names{'screenname'};
+}
 
 # ---------------------------------------------------------------- Language IDs
 sub languageids {
Index: loncom/interface/lonsyllabus.pm
diff -u loncom/interface/lonsyllabus.pm:1.3 loncom/interface/lonsyllabus.pm:1.4
--- loncom/interface/lonsyllabus.pm:1.3	Tue Aug 27 11:40:27 2002
+++ loncom/interface/lonsyllabus.pm	Tue Aug 27 12:49:20 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Syllabus
 #
-# $Id: lonsyllabus.pm,v 1.3 2002/08/27 15:40:27 www Exp $
+# $Id: lonsyllabus.pm,v 1.4 2002/08/27 16:49:20 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -49,7 +49,7 @@
 ENDDOCUMENT
     my (undef,undef,$cdom,$cnum)=split(/\//,$r->uri);
 # Is this even a course?
-    unless (&Apache::lonnet::homeserver($cnum,$cdom)) {
+    if (&Apache::lonnet::homeserver($cnum,$cdom) eq 'no_host') {
 	$r->print('<body>No syllabus available</body>');
         return OK;
     }
@@ -58,6 +58,8 @@
     $r->print(&Apache::loncommon::bodytag("Syllabus",'','','',$cdom));
     $r->print('<h1>'.$courseenv{'description'}.'</h1><h3>'.
               $Apache::lonnet::domaindescription{$cdom}.'</h3>');
+    my %syllabus=&Apache::lonnet::dump('syllabus',$cdom,$cnum);
+
 # This handler might be called anonymously ...
 # ----------------------------------------------------- Only if not public call
     if ($ENV{'user.environment'}) {
@@ -66,6 +68,18 @@
        if ($ENV{'request.course.id'}) {
           $allowed=&Apache::lonnet::allowed('srm',$ENV{'request.course.id'});
        }
+    }
+# ---------------------------------------------------------------- Get syllabus
+    if ($ENV{'uploaded.lastmodified'}) {
+       $r->print('<table><tr><td>Uploaded:</td><td>'.
+ &Apache::loncommon::plainname($syllabus{'uploaded.name'},
+                     $syllabus{'uploaded.domain'}).
+ '</td></tr><tr><td>Last updated</td><td>'.
+                     localtime($syllabus{'uploaded.lastmodified'}).
+                     '</td></tr></table>');
+        $r->print('<blockquote>'.$syllabus{'description'}.'</blockquote>');
+    } else {
+       $r->print('<p>No syllabus information provided.</p>');
     }
     $r->print('</body></html>');
     return OK;