Annotation of loncom/interface/lonpickcourse.pm, revision 1.7

1.1       www         1: # The LearningOnline Network
                      2: # Pick a course
                      3: #
1.7     ! www         4: # $Id: lonpickcourse.pm,v 1.6 2003/03/27 20:56:30 www Exp $
1.1       www         5: #
                      6: # Copyright Michigan State University Board of Trustees
                      7: #
                      8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                      9: #
                     10: # LON-CAPA is free software; you can redistribute it and/or modify
                     11: # it under the terms of the GNU General Public License as published by
                     12: # the Free Software Foundation; either version 2 of the License, or
                     13: # (at your option) any later version.
                     14: #
                     15: # LON-CAPA is distributed in the hope that it will be useful,
                     16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     18: # GNU General Public License for more details.
                     19: #
                     20: # You should have received a copy of the GNU General Public License
                     21: # along with LON-CAPA; if not, write to the Free Software
                     22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     23: #
                     24: # /home/httpd/html/adm/gpl.txt
                     25: #
                     26: # http://www.lon-capa.org/
                     27: #
                     28: 
                     29: package Apache::lonpickcourse;
                     30: 
                     31: use strict;
                     32: use Apache::Constants qw(:common);
                     33: use Apache::loncommon;
                     34: use Apache::loncoursedata;
                     35: use Apache::lonnet;
                     36: 
                     37: sub handler {
                     38:     my $r = shift;
                     39:     $r->content_type('text/html');
                     40:     $r->send_http_header;
                     41:     return OK if $r->header_only;
                     42: 
                     43: # ------------------------------------------------------------ Print the screen
                     44:     $r->print(<<ENDDOCUMENT);
                     45: <html>
                     46: <head>
                     47: <title>The LearningOnline Network with CAPA</title>
                     48: </head>
                     49: ENDDOCUMENT
1.5       www        50: # Get parameters from query string
1.1       www        51:     &Apache::loncommon::get_unprocessed_cgi
                     52:         ($ENV{'QUERY_STRING'},['domainfilter','descriptfilter',
                     53:                  'sincefilter','form','cnumelement','cdomelement']);
1.5       www        54: # domain filter and selection
1.1       www        55:     my $domainfilter=$ENV{'form.domainfilter'};
                     56:     $domainfilter=~s/\W//g;
1.4       www        57:     unless ($domainfilter) { $domainfilter=''; }
                     58:     my $domainselectform=&Apache::loncommon::select_dom_form($domainfilter,
                     59:                                                           'domainfilter',1);
1.5       www        60: # description filter
1.1       www        61:     my $descriptfilter=$ENV{'form.descriptfilter'};
1.4       www        62:     $descriptfilter=~s/[^\w\s]//g;
                     63:     unless ($descriptfilter) { $descriptfilter=''; }
1.5       www        64: 
                     65: # last course activity filter and selection
1.1       www        66:     my $sincefilter=$ENV{'form.sincefilter'};
1.5       www        67:     $sincefilter=~s/[^\d-]//g;
                     68:     unless ($sincefilter) { $sincefilter=-1; }
                     69:     my $sincefilterform=&Apache::loncommon::select_form($sincefilter,
                     70:        'sincefilter',('-1'=>'',
                     71:                       '86400' => 'today',
                     72:                       '604800' => 'last week',
                     73:                       '2592000' => 'last month',
                     74:                       '7776000' => 'last three months',
                     75:                       '15552000' => 'last six months',
                     76:                       '31104000' => 'last year'));
1.1       www        77:        
                     78:     $r->print(&Apache::loncommon::bodytag("Selecting a Course"));
                     79:     $r->print(<<ENDSCRIPT);
                     80: <script>
                     81: function gochoose(cname,cdom) {
                     82:     opener.document.$ENV{'form.form'}.$ENV{'form.cnumelement'}.value=cname;
                     83:     var slct=opener.document.$ENV{'form.form'}.$ENV{'form.cdomelement'};
                     84:     var i;
                     85:     for (i=0;i<slct.length;i++) {
1.7     ! www        86:         if (slct.options[i].value==cdom) { slct.selectedIndex=i; }
1.1       www        87:     }
                     88:     self.close();
                     89: }
                     90: </script>
1.4       www        91: <form method="post">
1.5       www        92: <input type="hidden" name="cnumelement" value="$ENV{'form.cnumelement'}" />
                     93: <input type="hidden" name="cdomelement" value="$ENV{'form.cdomelement'}" />
                     94: <input type="hidden" name="form" value="$ENV{'form.form'}" />
                     95: 
                     96: Course Activity: $sincefilterform
1.4       www        97: <br />
                     98: Course Domain: $domainselectform
                     99: <br />
                    100: Course Description:
                    101: <input type="text" name="descriptfilter" size="40" value="$descriptfilter" />
1.5       www       102: <p><input type="submit" name="gosearch" value="Search" /></p>
1.4       www       103: </form>
1.5       www       104: <hr />
1.1       www       105: ENDSCRIPT
1.2       www       106: # ---------------------------------------------------------------- Get the data
1.5       www       107:     if ($ENV{'form.gosearch'}) {
1.6       www       108:         $r->print('Searching ...<br />&nbsp;<br />');
                    109:         $r->rflush();
1.5       www       110: 	unless ($descriptfilter) { $descriptfilter='.'; }
                    111:         my $timefilter=($sincefilter==-1?1:time-$sincefilter);
                    112: 	my %courses=
                    113: 	    &Apache::lonnet::courseiddump
                    114: 	    ($domainfilter,$descriptfilter,$timefilter);
                    115: 	$r->print('<form>');
                    116: 	foreach (keys %courses) {
                    117: 	    my ($cdom,$cnum)=split(/\_/,$_);
                    118: 	    $r->print('<input type="button" value="Select" onClick="gochoose('.
1.3       www       119: 		  "'".$cnum."','".$cdom."')".'" /> '.$courses{$_}.' ('.
                    120: 		  ($Apache::lonnet::domaindescription{$cdom}?
1.5       www       121:                    $Apache::lonnet::domaindescription{$cdom}:$cdom).
                    122:                  ")<br />\n");
                    123: 	}
                    124:         $r->print('</form>');
1.2       www       125:     }
1.5       www       126:     $r->print('</body></html>');
1.1       www       127:     return OK;
                    128: } 
                    129: 
                    130: 1;
                    131: __END__

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>