File:
[LON-CAPA] /
loncom /
interface /
lonpickcourse.pm
Revision
1.7:
download - view:
text,
annotated -
select for diffs
Fri Mar 28 01:53:55 2003 UTC (21 years, 4 months ago) by
www
Branches:
MAIN
CVS tags:
version_1_0_3,
version_1_0_2,
version_1_0_1,
version_1_0_0,
version_0_99_5,
version_0_99_4,
version_0_99_3,
version_0_99_2,
version_0_99_1,
version_0_99_0,
conference_2003,
HEAD
Bugfixes and enhancements on pickstudent and pickcourse.
1: # The LearningOnline Network
2: # Pick a course
3: #
4: # $Id: lonpickcourse.pm,v 1.7 2003/03/28 01:53:55 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:
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
50: # Get parameters from query string
51: &Apache::loncommon::get_unprocessed_cgi
52: ($ENV{'QUERY_STRING'},['domainfilter','descriptfilter',
53: 'sincefilter','form','cnumelement','cdomelement']);
54: # domain filter and selection
55: my $domainfilter=$ENV{'form.domainfilter'};
56: $domainfilter=~s/\W//g;
57: unless ($domainfilter) { $domainfilter=''; }
58: my $domainselectform=&Apache::loncommon::select_dom_form($domainfilter,
59: 'domainfilter',1);
60: # description filter
61: my $descriptfilter=$ENV{'form.descriptfilter'};
62: $descriptfilter=~s/[^\w\s]//g;
63: unless ($descriptfilter) { $descriptfilter=''; }
64:
65: # last course activity filter and selection
66: my $sincefilter=$ENV{'form.sincefilter'};
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'));
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++) {
86: if (slct.options[i].value==cdom) { slct.selectedIndex=i; }
87: }
88: self.close();
89: }
90: </script>
91: <form method="post">
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
97: <br />
98: Course Domain: $domainselectform
99: <br />
100: Course Description:
101: <input type="text" name="descriptfilter" size="40" value="$descriptfilter" />
102: <p><input type="submit" name="gosearch" value="Search" /></p>
103: </form>
104: <hr />
105: ENDSCRIPT
106: # ---------------------------------------------------------------- Get the data
107: if ($ENV{'form.gosearch'}) {
108: $r->print('Searching ...<br /> <br />');
109: $r->rflush();
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('.
119: "'".$cnum."','".$cdom."')".'" /> '.$courses{$_}.' ('.
120: ($Apache::lonnet::domaindescription{$cdom}?
121: $Apache::lonnet::domaindescription{$cdom}:$cdom).
122: ")<br />\n");
123: }
124: $r->print('</form>');
125: }
126: $r->print('</body></html>');
127: return OK;
128: }
129:
130: 1;
131: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>