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

www lon-capa-cvs@mail.lon-capa.org
Thu, 27 Mar 2003 02:05:44 -0000


www		Wed Mar 26 21:05:44 2003 EDT

  Modified files:              
    /loncom/interface	lonpickcourse.pm 
  Log:
  Appears to work now, except somehow for the plaintext domain descriptions.
  The "course activity" filter could not yet be tested, since all activity
  would still be within one day.
  
  
Index: loncom/interface/lonpickcourse.pm
diff -u loncom/interface/lonpickcourse.pm:1.4 loncom/interface/lonpickcourse.pm:1.5
--- loncom/interface/lonpickcourse.pm:1.4	Wed Mar 26 14:34:42 2003
+++ loncom/interface/lonpickcourse.pm	Wed Mar 26 21:05:43 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Pick a course
 #
-# $Id: lonpickcourse.pm,v 1.4 2003/03/26 19:34:42 www Exp $
+# $Id: lonpickcourse.pm,v 1.5 2003/03/27 02:05:43 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -47,22 +47,33 @@
 <title>The LearningOnline Network with CAPA</title>
 </head>
 ENDDOCUMENT
-
-
+# Get parameters from query string
     &Apache::loncommon::get_unprocessed_cgi
         ($ENV{'QUERY_STRING'},['domainfilter','descriptfilter',
                  'sincefilter','form','cnumelement','cdomelement']);
+# domain filter and selection
     my $domainfilter=$ENV{'form.domainfilter'};
     $domainfilter=~s/\W//g;
     unless ($domainfilter) { $domainfilter=''; }
     my $domainselectform=&Apache::loncommon::select_dom_form($domainfilter,
                                                           'domainfilter',1);
+# description filter
     my $descriptfilter=$ENV{'form.descriptfilter'};
     $descriptfilter=~s/[^\w\s]//g;
     unless ($descriptfilter) { $descriptfilter=''; }
+
+# last course activity filter and selection
     my $sincefilter=$ENV{'form.sincefilter'};
-    $sincefilter=~s/\D//g;
-    unless ($sincefilter) { $sincefilter=0; }
+    $sincefilter=~s/[^\d-]//g;
+    unless ($sincefilter) { $sincefilter=-1; }
+    my $sincefilterform=&Apache::loncommon::select_form($sincefilter,
+       'sincefilter',('-1'=>'',
+                      '86400' => 'today',
+                      '604800' => 'last week',
+                      '2592000' => 'last month',
+                      '7776000' => 'last three months',
+                      '15552000' => 'last six months',
+                      '31104000' => 'last year'));
        
     $r->print(&Apache::loncommon::bodytag("Selecting a Course"));
     $r->print(<<ENDSCRIPT);
@@ -78,29 +89,40 @@
 }
 </script>
 <form method="post">
+<input type="hidden" name="cnumelement" value="$ENV{'form.cnumelement'}" />
+<input type="hidden" name="cdomelement" value="$ENV{'form.cdomelement'}" />
+<input type="hidden" name="form" value="$ENV{'form.form'}" />
+
+Course Activity: $sincefilterform
 <br />
 Course Domain: $domainselectform
 <br />
 Course Description:
 <input type="text" name="descriptfilter" size="40" value="$descriptfilter" />
-<input type="submit" name="gosearch" value="Search" />
+<p><input type="submit" name="gosearch" value="Search" /></p>
 </form>
-
+<hr />
 ENDSCRIPT
     $r->rflush();
 # ---------------------------------------------------------------- Get the data
-    unless ($descriptfilter) { $descriptfilter='.'; }
-    my %courses=
-     &Apache::lonnet::courseiddump($domainfilter,$descriptfilter,$sincefilter);
-    $r->print('<form>');
-    foreach (keys %courses) {
-        my ($cdom,$cnum)=split(/\_/,$_);
-	$r->print('<input type="button" value="Select" onClick="gochoose('.
+    if ($ENV{'form.gosearch'}) {
+	unless ($descriptfilter) { $descriptfilter='.'; }
+        my $timefilter=($sincefilter==-1?1:time-$sincefilter);
+	my %courses=
+	    &Apache::lonnet::courseiddump
+	    ($domainfilter,$descriptfilter,$timefilter);
+	$r->print('<form>');
+	foreach (keys %courses) {
+	    my ($cdom,$cnum)=split(/\_/,$_);
+	    $r->print('<input type="button" value="Select" onClick="gochoose('.
 		  "'".$cnum."','".$cdom."')".'" /> '.$courses{$_}.' ('.
 		  ($Apache::lonnet::domaindescription{$cdom}?
-                   $Apache::lonnet::domaindescription{$cdom}:$cdom).')<br />');
+                   $Apache::lonnet::domaindescription{$cdom}:$cdom).
+                 ")<br />\n");
+	}
+        $r->print('</form>');
     }
-    $r->print('</form></body></html>');
+    $r->print('</body></html>');
     return OK;
 }