1: # The LearningOnline Network
2: # Pick a course
3: #
4: # $Id: lonpickcourse.pm,v 1.8 2003/09/22 00:48:32 www Exp $
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: use Apache::lonlocal;
37:
38: sub handler {
39: my $r = shift;
40: &Apache::loncommon::content_type($r,'text/html');
41: $r->send_http_header;
42: return OK if $r->header_only;
43:
44: # ------------------------------------------------------------ Print the screen
45: $r->print(<<ENDDOCUMENT);
46: <html>
47: <head>
48: <title>The LearningOnline Network with CAPA</title>
49: </head>
50: ENDDOCUMENT
51: # Get parameters from query string
52: &Apache::loncommon::get_unprocessed_cgi
53: ($ENV{'QUERY_STRING'},['domainfilter','descriptfilter',
54: 'sincefilter','form','cnumelement','cdomelement']);
55: # domain filter and selection
56: my $domainfilter=$ENV{'form.domainfilter'};
57: $domainfilter=~s/\W//g;
58: unless ($domainfilter) { $domainfilter=''; }
59: my $domainselectform=&Apache::loncommon::select_dom_form($domainfilter,
60: 'domainfilter',1);
61: # description filter
62: my $descriptfilter=$ENV{'form.descriptfilter'};
63: $descriptfilter=~s/[^\w\s]//g;
64: unless ($descriptfilter) { $descriptfilter=''; }
65:
66: # last course activity filter and selection
67: my $sincefilter=$ENV{'form.sincefilter'};
68: $sincefilter=~s/[^\d-]//g;
69: unless ($sincefilter) { $sincefilter=-1; }
70: my $sincefilterform=&Apache::loncommon::select_form($sincefilter,
71: 'sincefilter',('-1'=>'',
72: '86400' => 'today',
73: '604800' => 'last week',
74: '2592000' => 'last month',
75: '7776000' => 'last three months',
76: '15552000' => 'last six months',
77: '31104000' => 'last year'));
78:
79: $r->print(&Apache::loncommon::bodytag("Selecting a Course"));
80: my %lt=&Apache::lonlocal::texthash(
81: 'cac' => 'Course Activity',
82: 'cde' => 'Course Description',
83: 'cdo' => 'Course Domain');
84: $r->print(<<ENDSCRIPT);
85: <script>
86: function gochoose(cname,cdom) {
87: opener.document.$ENV{'form.form'}.$ENV{'form.cnumelement'}.value=cname;
88: var slct=opener.document.$ENV{'form.form'}.$ENV{'form.cdomelement'};
89: var i;
90: for (i=0;i<slct.length;i++) {
91: if (slct.options[i].value==cdom) { slct.selectedIndex=i; }
92: }
93: self.close();
94: }
95: </script>
96: <form method="post">
97: <input type="hidden" name="cnumelement" value="$ENV{'form.cnumelement'}" />
98: <input type="hidden" name="cdomelement" value="$ENV{'form.cdomelement'}" />
99: <input type="hidden" name="form" value="$ENV{'form.form'}" />
100:
101: $lt{'cac'}: $sincefilterform
102: <br />
103: $lt{'cdo'}: $domainselectform
104: <br />
105: $lt{'cde'}:
106: <input type="text" name="descriptfilter" size="40" value="$descriptfilter" />
107: <p><input type="submit" name="gosearch" value="Search" /></p>
108: </form>
109: <hr />
110: ENDSCRIPT
111: # ---------------------------------------------------------------- Get the data
112: if ($ENV{'form.gosearch'}) {
113: $r->print(&mt('Searching').' ...<br /> <br />');
114: $r->rflush();
115: unless ($descriptfilter) { $descriptfilter='.'; }
116: my $timefilter=($sincefilter==-1?1:time-$sincefilter);
117: my %courses=
118: &Apache::lonnet::courseiddump
119: ($domainfilter,$descriptfilter,$timefilter);
120: $r->print('<form>');
121: foreach (keys %courses) {
122: my ($cdom,$cnum)=split(/\_/,$_);
123: $r->print('<input type="button" value="Select" onClick="gochoose('.
124: "'".$cnum."','".$cdom."')".'" /> '.$courses{$_}.' ('.
125: ($Apache::lonnet::domaindescription{$cdom}?
126: $Apache::lonnet::domaindescription{$cdom}:$cdom).
127: ")<br />\n");
128: }
129: $r->print('</form>');
130: }
131: $r->print('</body></html>');
132: return OK;
133: }
134:
135: 1;
136: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>