[LON-CAPA-cvs] cvs: loncom / lond /interface loncreatecourse.pm lonmodifycourse.pm lonpickcourse.pm /lonnet/perl lonnet.pm

raeburn lon-capa-cvs@mail.lon-capa.org
Tue, 29 Jun 2004 14:56:33 -0000


This is a MIME encoded message

--raeburn1088520993
Content-Type: text/plain

raeburn		Tue Jun 29 10:56:33 2004 EDT

  Modified files:              
    /loncom	lond 
    /loncom/lonnet/perl	lonnet.pm 
    /loncom/interface	lonmodifycourse.pm loncreatecourse.pm 
                     	lonpickcourse.pm 
  Log:
  Include institutional course code in nohist_courseids.db.
  Format of entries in nohist_courseids.db now -
  course_id = description:institutional code:last activity
  both (keys and values are escaped).
  lonnet::courseiddump now returns escaped values in hash (keys are unescaped),
  to preserve the : separator between description and institutional code.  
  
  
--raeburn1088520993
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20040629105633.txt"

Index: loncom/lond
diff -u loncom/lond:1.201 loncom/lond:1.202
--- loncom/lond:1.201	Mon Jun 21 10:08:20 2004
+++ loncom/lond	Tue Jun 29 10:56:32 2004
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # lond "LON Daemon" Server (port "LOND" 5663)
 #
-# $Id: lond,v 1.201 2004/06/21 14:08:20 matthew Exp $
+# $Id: lond,v 1.202 2004/06/29 14:56:32 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -56,7 +56,7 @@
 my $status='';
 my $lastlog='';
 
-my $VERSION='$Revision: 1.201 $'; #' stupid emacs
+my $VERSION='$Revision: 1.202 $'; #' stupid emacs
 my $remoteVERSION;
 my $currenthostid;
 my $currentdomainid;
@@ -2836,8 +2836,8 @@
 			my %hash;
 			if (tie(%hash,'GDBM_File',"$proname.db",&GDBM_WRCREAT(),0640)) {
 			    foreach my $pair (@pairs) {
-				my ($key,$value)=split(/=/,$pair);
-				$hash{$key}=$value.':'.$now;
+				my ($key,$descr,$inst_code)=split(/=/,$pair);
+				$hash{$key}=$descr.':'.$inst_code.':'.$now;
 			    }
 			    if (untie(%hash)) {
 				print $client "ok\n";
@@ -2872,14 +2872,19 @@
 			my %hash;
 			if (tie(%hash,'GDBM_File',"$proname.db",&GDBM_READER(),0640)) {
 			    while (my ($key,$value) = each(%hash)) {
-				my ($descr,$lasttime)=split(/\:/,$value);
+                                my ($descr,$lasttime,$inst_code);
+                                if ($value =~ m/^([^\:]*):([^\:]*):(\d+)$/) {
+				    ($descr,$inst_code,$lasttime)=($1,$2,$3);
+                                } else {
+                                    ($descr,$lasttime) = split(/\:/,$value);
+                                }
 				if ($lasttime<$since) { next; }
 				if ($description eq '.') {
-				    $qresult.=$key.'='.$descr.'&';
+				    $qresult.=$key.'='.$descr.':'.$inst_code.'&';
 				} else {
 				    my $unescapeVal = &unescape($descr);
 				    if (eval('$unescapeVal=~/\Q$description\E/i')) {
-					$qresult.="$key=$descr&";
+					$qresult.=$key.'='.$descr.':'.$inst_code.'&';
 				    }
 				}
 			    }
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.515 loncom/lonnet/perl/lonnet.pm:1.516
--- loncom/lonnet/perl/lonnet.pm:1.515	Tue Jun 29 00:30:00 2004
+++ loncom/lonnet/perl/lonnet.pm	Tue Jun 29 10:56:32 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.515 2004/06/29 04:30:00 raeburn Exp $
+# $Id: lonnet.pm,v 1.516 2004/06/29 14:56:32 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -38,7 +38,7 @@
 qw(%perlvar %hostname %homecache %badServerCache %hostip %iphost %spareid %hostdom 
    %libserv %pr %prp %metacache %packagetab %titlecache %courseresversioncache %resversioncache
    %courselogs %accesshash %userrolehash $processmarker $dumpcount 
-   %coursedombuf %coursenumbuf %coursehombuf %coursedescrbuf %courseresdatacache 
+   %coursedombuf %coursenumbuf %coursehombuf %coursedescrbuf %courseinstcodebuf %courseresdatacache 
    %userresdatacache %usectioncache %domaindescription %domain_auth_def %domain_auth_arg_def 
    %domain_lang_def %domain_city %domain_longi %domain_lati $tmpdir);
 
@@ -1395,10 +1395,12 @@
         }
         if ($courseidbuffer{$coursehombuf{$crsid}}) {
            $courseidbuffer{$coursehombuf{$crsid}}.='&'.
-			 &escape($crsid).'='.&escape($coursedescrbuf{$crsid});
+			 &escape($crsid).'='.&escape($coursedescrbuf{$crsid}).
+                         '='.&escape($courseinstcodebuf{$crsid});
         } else {
            $courseidbuffer{$coursehombuf{$crsid}}=
-			 &escape($crsid).'='.&escape($coursedescrbuf{$crsid});
+			 &escape($crsid).'='.&escape($coursedescrbuf{$crsid}).
+                         '='.&escape($courseinstcodebuf{$crsid});
         }    
     }
 #
@@ -1472,6 +1474,8 @@
        $ENV{'course.'.$ENV{'request.course.id'}.'.home'};
     $coursedescrbuf{$ENV{'request.course.id'}}=
        $ENV{'course.'.$ENV{'request.course.id'}.'.description'};
+    $courseinstcodebuf{$ENV{'request.course.id'}}=
+       $ENV{'course.'.$ENV{'request.course.id'}.'.internal.coursecode'};
     if (defined $courselogs{$ENV{'request.course.id'}}) {
 	$courselogs{$ENV{'request.course.id'}}.='&'.$what;
     } else {
@@ -1627,7 +1631,7 @@
                                $tryserver))) {
 		    my ($key,$value)=split(/\=/,$_);
                     if (($key) && ($value)) {
-		        $returnhash{&unescape($key)}=&unescape($value);
+		        $returnhash{&unescape($key)}=$value;
                     }
                 }
             }
@@ -3491,7 +3495,7 @@
 # ---------------------------------------------------------- Make/modify course
 
 sub createcourse {
-    my ($udom,$description,$url,$course_server,$nonstandard)=@_;
+    my ($udom,$description,$url,$course_server,$nonstandard,$inst_code)=@_;
     $url=&declutter($url);
     my $cid='';
     unless (&allowed('ccc',$udom)) {
@@ -3524,9 +3528,9 @@
 	return 'error: no such course';
     }
 # ----------------------------------------------------------------- Course made
-# log existance
-    &courseidput($udom,&escape($udom.'_'.$uname).'='.&escape($description),
-                 $uhome);
+# log existence
+    &courseidput($udom,&escape($udom.'_'.$uname).'='.&escape($description).
+                 '='.&escape($inst_code),$uhome);
     &flushcourselogs();
 # set toplevel url
     my $topurl=$url;
Index: loncom/interface/lonmodifycourse.pm
diff -u loncom/interface/lonmodifycourse.pm:1.9 loncom/interface/lonmodifycourse.pm:1.10
--- loncom/interface/lonmodifycourse.pm:1.9	Thu Jun 17 14:31:24 2004
+++ loncom/interface/lonmodifycourse.pm	Tue Jun 29 10:56:32 2004
@@ -100,7 +100,11 @@
             unless ($code =~m/^___\d+$/) {  $showcode = $code; }
             if ($item =~ m/^($dom)_(\w+)$/) {
                 $crs = $2;
-                $description = $courseIDs{$item};
+                if ($courseIDs{$item} =~ /^([^:]*):/) {
+                    $description = &Apache::lonnet::unescape($1);
+                } else {   
+                    $description = &Apache::lonnet::unescape($courseIDs{$item});
+                }
 # Get course owner
                 my %settings = &Apache::lonnet::get('environment',['internal.courseowner'],$dom,$crs);
                 if ( defined($settings{'internal.courseowner'}) ) {
@@ -517,6 +521,8 @@
         $newattr{'coursecode'}=$ENV{'form.coursecode'};
         unless ( $newattr{'coursecode'} eq $currattr{'coursecode'} ) {
             $changecode = 1;
+            my $courseid_entry = &Apache::lonnet::escape($dom.'_'.$crs).'='.&Apache::lonnet::escape($description).'='.&Apache::lonnet::escape($ENV{'form.coursecode'});
+            &Apache::lonnet::courseidput($dom,$courseid_entry,&Apache::lonnet::homeserver($crs,$dom));
         }
     }
 
Index: loncom/interface/loncreatecourse.pm
diff -u loncom/interface/loncreatecourse.pm:1.60 loncom/interface/loncreatecourse.pm:1.61
--- loncom/interface/loncreatecourse.pm:1.60	Thu Jun 17 14:31:24 2004
+++ loncom/interface/loncreatecourse.pm	Tue Jun 29 10:56:32 2004
@@ -1,7 +1,7 @@
 #meserver The LearningOnline Network
 # Create a course
 #
-# $Id: loncreatecourse.pm,v 1.60 2004/06/17 18:31:24 raeburn Exp $
+# $Id: loncreatecourse.pm,v 1.61 2004/06/29 14:56:32 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -531,7 +531,8 @@
     my $courseid=&Apache::lonnet::createcourse($ENV{'request.role.domain'},
                                                $cdescr,$curl,
                                                $ENV{'form.course_home'},
-                                               $ENV{'form.nonstandard'});
+                                               $ENV{'form.nonstandard'},
+                                               $ENV{'form.crscode'});
 
     # Note: The testing routines depend on this being output; see 
     # Utils::Course. This needs to at least be output as a comment
Index: loncom/interface/lonpickcourse.pm
diff -u loncom/interface/lonpickcourse.pm:1.16 loncom/interface/lonpickcourse.pm:1.17
--- loncom/interface/lonpickcourse.pm:1.16	Fri May  7 17:51:30 2004
+++ loncom/interface/lonpickcourse.pm	Tue Jun 29 10:56:32 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Pick a course
 #
-# $Id: lonpickcourse.pm,v 1.16 2004/05/07 21:51:30 albertel Exp $
+# $Id: lonpickcourse.pm,v 1.17 2004/06/29 14:56:32 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -131,15 +131,21 @@
 	$r->print('<form>');
 	my %by_descrip;
 	foreach my $course (keys %courses) {
-	    $by_descrip{lc($courses{$course})}=$course;
+            my $descr;
+            if ($courses{$course} =~ m/^([^:]*):/) {
+                $descr = &Apache::lonnet::unescape($1);
+            } else {
+                $descr = &Apache::lonnet::unescape($courses{$course});
+            }
+            $by_descrip{lc($descr)}=$course;
 	}
 	foreach my $description (sort(keys(%by_descrip))) {
 	    my $course=$by_descrip{$description};
-	    my $cleandesc=&HTML::Entities::encode($courses{$course},'<>&"');
+	    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."')".'" /> '.$courses{$course}.' ('.
+		  "'".$cnum."','".$cdom."','".$cleandesc."')".'" /> '.$description.' ('.
 		  ($Apache::lonnet::domaindescription{$cdom}?
                    $Apache::lonnet::domaindescription{$cdom}:$cdom).
                  ")<br />\n");

--raeburn1088520993--