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

raeburn raeburn@source.lon-capa.org
Mon, 28 Sep 2009 19:13:37 -0000


raeburn		Mon Sep 28 19:13:37 2009 EDT

  Modified files:              
    /loncom	lond 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - Store creation date, creator, and creation context in nohist_courseids.db file.
  - Include additional filters to filter courses by creation date and creation context when retrieving information from nohist_courseids.db.
  
  
Index: loncom/lond
diff -u loncom/lond:1.426 loncom/lond:1.427
--- loncom/lond:1.426	Sun Sep 13 03:13:21 2009
+++ loncom/lond	Mon Sep 28 19:13:32 2009
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # lond "LON Daemon" Server (port "LOND" 5663)
 #
-# $Id: lond,v 1.426 2009/09/13 03:13:21 raeburn Exp $
+# $Id: lond,v 1.427 2009/09/28 19:13:32 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -59,7 +59,7 @@
 my $status='';
 my $lastlog='';
 
-my $VERSION='$Revision: 1.426 $'; #' stupid emacs
+my $VERSION='$Revision: 1.427 $'; #' stupid emacs
 my $remoteVERSION;
 my $currenthostid="default";
 my $currentdomainid;
@@ -3693,12 +3693,15 @@
 #                 caller -  if set to 'coursecatalog', courses set to be hidden
 #                           from course catalog will be excluded from results (unless
 #                           overridden by "showhidden".
-#                 cloner - escaped username:domain of course cloner (if picking course to# 
+#                 cloner - escaped username:domain of course cloner (if picking course to
 #                          clone).
 #                 cc_clone_list - escaped comma separated list of courses for which 
 #                                 course cloner has active CC role (and so can clone
 #                                 automatically).
-#                 cloneonly - filter by courses for which cloner has rights to clone. 
+#                 cloneonly - filter by courses for which cloner has rights to clone.
+#                 createdbefore - include courses for which creation date preceeded this date.
+#                 createdafter - include courses for which creation date followed this date.
+#                 creationcontext - include courses created in specified context 
 #
 #     $client  - The socket open on the client.
 # Returns:
@@ -3711,7 +3714,8 @@
 
     my ($udom,$since,$description,$instcodefilter,$ownerfilter,$coursefilter,
         $typefilter,$regexp_ok,$rtn_as_hash,$selfenrollonly,$catfilter,$showhidden,
-        $caller,$cloner,$cc_clone_list,$cloneonly) =split(/:/,$tail);
+        $caller,$cloner,$cc_clone_list,$cloneonly,$createdbefore,$createdafter,
+        $creationcontext) =split(/:/,$tail);
     my $now = time;
     my ($cloneruname,$clonerudom,%cc_clone);
     if (defined($description)) {
@@ -3769,6 +3773,21 @@
             $cc_clone{$clonedom.'_'.$clonenum} = 1;
         } 
     }
+    if (defined($createdbefore)) {
+        $createdbefore = &unescape($createdbefore);
+    } else {
+       $createdbefore = 0;
+    }
+    if (defined($createdafter)) {
+        $createdafter = &unescape($createdafter);
+    } else {
+        $createdafter = 0;
+    }
+    if (defined($creationcontext)) {
+        $creationcontext = &unescape($creationcontext);
+    } else {
+        $creationcontext = '.';
+    }
     
     my $unpack = 1;
     if ($description eq '.' && $instcodefilter eq '.' && $coursefilter eq '.' && 
@@ -3781,7 +3800,8 @@
     if ($hashref) {
 	while (my ($key,$value) = each(%$hashref)) {
             my ($unesc_key,$lasttime_key,$lasttime,$is_hash,%val,
-                %unesc_val,$selfenroll_end,$selfenroll_types);
+                %unesc_val,$selfenroll_end,$selfenroll_types,$created,
+                $context);
             $unesc_key = &unescape($key);
             if ($unesc_key =~ /^lasttime:/) {
                 next;
@@ -3832,15 +3852,28 @@
                     $unesc_val{'owner'} = $items->{'owner'};
                     $unesc_val{'type'} = $items->{'type'};
                     $unesc_val{'cloners'} = $items->{'cloners'};
+                    $unesc_val{'created'} = $items->{'created'};
+                    $unesc_val{'context'} = $items->{'context'};
                 }
                 $selfenroll_types = $items->{'selfenroll_types'};
                 $selfenroll_end = $items->{'selfenroll_end_date'};
+                $created = $items->{'created'};
+                $context = $items->{'context'};
                 if ($selfenrollonly) {
                     next if (!$selfenroll_types);
                     if (($selfenroll_end > 0) && ($selfenroll_end <= $now)) {
                         next;
                     }
                 }
+                if ($creationcontext ne '.') {
+                    next if (($context ne '') && ($context ne $creationcontext));  
+                }
+                if ($createdbefore > 0) {
+                    next if (($created eq '') || ($created > $createdbefore));   
+                }
+                if ($createdafter > 0) {
+                    next if (($created eq '') || ($created <= $createdafter)); 
+                }
                 if ($catfilter ne '') {
                     next if ($items->{'categories'} eq '');
                     my @categories = split('&',$items->{'categories'}); 
@@ -3863,6 +3896,8 @@
             } else {
                 next if ($catfilter ne '');
                 next if ($selfenrollonly);
+                next if ($createdbefore || $createdafter);
+                next if ($creationcontext ne '.');
                 if ((defined($clonerudom)) && (defined($cloneruname)))  {
                     if ($cc_clone{$unesc_key}) {
                         $canclone = 1;
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1028 loncom/lonnet/perl/lonnet.pm:1.1029
--- loncom/lonnet/perl/lonnet.pm:1.1028	Wed Sep 16 05:59:49 2009
+++ loncom/lonnet/perl/lonnet.pm	Mon Sep 28 19:13:37 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.1028 2009/09/16 05:59:49 raeburn Exp $
+# $Id: lonnet.pm,v 1.1029 2009/09/28 19:13:37 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3027,7 +3027,8 @@
 sub courseiddump {
     my ($domfilter,$descfilter,$sincefilter,$instcodefilter,$ownerfilter,
         $coursefilter,$hostidflag,$hostidref,$typefilter,$regexp_ok,
-        $selfenrollonly,$catfilter,$showhidden,$caller,$cloner,$cc_clone,$cloneonly)=@_;
+        $selfenrollonly,$catfilter,$showhidden,$caller,$cloner,$cc_clone,
+        $cloneonly,$createdbefore,$createdafter,$creationcontext)=@_;
     my $as_hash = 1;
     my %returnhash;
     if (!$domfilter) { $domfilter=''; }
@@ -3047,7 +3048,9 @@
                          ':'.&escape($regexp_ok).':'.$as_hash.':'.
                          &escape($selfenrollonly).':'.&escape($catfilter).':'.
                          $showhidden.':'.$caller.':'.&escape($cloner).':'.
-                         &escape($cc_clone).':'.$cloneonly,$tryserver);
+                         &escape($cc_clone).':'.$cloneonly.':'.
+                         &escape($createdbefore).':'.&escape($createdafter).':'.
+                         &escape($creationcontext),$tryserver);
                 my @pairs=split(/\&/,$rep);
                 foreach my $item (@pairs) {
                     my ($key,$value)=split(/\=/,$item,2);
@@ -6507,12 +6510,17 @@
     }
 # ----------------------------------------------------------------- Course made
 # log existence
+    my $now = time;
     my $newcourse = {
                     $udom.'_'.$uname => {
                                      description => $description,
                                      inst_code   => $inst_code,
                                      owner       => $course_owner,
                                      type        => $crstype,
+                                     creator     => $env{'user.name'}.':'.
+                                                    $env{'user.domain'},
+                                     created     => $now,
+                                     context     => $context,
                                                 },
                     };
     &courseidput($udom,$newcourse,$uhome,'notime');