File:
[LON-CAPA] /
rat /
lonratparms.pm
Revision
1.19:
download - view:
text,
annotated -
select for diffs
Thu Oct 23 21:01:54 2003 UTC (20 years, 10 months ago) by
albertel
Branches:
MAIN
CVS tags:
version_1_1_X,
version_1_1_3,
version_1_1_2,
version_1_1_1,
version_1_1_0,
version_1_0_99_3,
version_1_0_99_2,
version_1_0_99_1,
version_1_0_99,
HEAD
- takes care of more of BUG#55
- added new parameter to packages .tab and away to associate parameters with only part 0
- map level parameters work again
1: # The LearningOnline Network with CAPA
2: # Set parameters inside of the RAT
3: #
4: # $Id: lonratparms.pm,v 1.19 2003/10/23 21:01:54 albertel 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: # (Search Catalog
29: #
30: # (Internal Server Error Handler
31: #
32: # (Login Screen
33: # 5/21/99,5/22,5/25,5/26,5/31,6/2,6/10,7/12,7/14,
34: # 1/14/00,5/29,5/30,6/1,6/29,7/1,11/9 Gerd Kortemeyer)
35: #
36: # 3/1/1 Gerd Kortemeyer)
37: #
38: # 3/1 Gerd Kortemeyer)
39: #
40: # 03/03/01,06/15,06/25,06/26,06/30,07/02,07/03,07/04 Gerd Kortemeyer
41: # 03/11/02 Matthew Hall
42: #
43: package Apache::lonratparms;
44:
45: use strict;
46: use Apache::Constants qw(:common);
47: use Apache::lonhtmlcommon();
48: use Apache::lonlocal;
49:
50: sub handler {
51: my $r = shift;
52: &Apache::loncommon::content_type($r,'text/html');
53: $r->send_http_header;
54: return OK if $r->header_only;
55:
56: # Get query string for limited number of parameters
57:
58: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
59: ['url','parms','resid']);
60:
61: # ------------------------------------------------------------------- Read file
62:
63: my $uri=$ENV{'form.url'}.'.meta';
64:
65: my %content;
66: my %type;
67: my %display;
68: my %value;
69:
70: foreach (split(/\,/,&Apache::lonnet::metadata($uri,'keys'))) {
71: if ($_=~/^parameter\_/) {
72: $content{$_}=&Apache::lonnet::metadata($uri,$_);
73: $type{$_}=&Apache::lonnet::metadata($uri,$_.'.type');
74: $display{$_}=&Apache::lonnet::metadata($uri,$_.'.display');
75: }
76: }
77:
78: # -------------------------------------- Additional parms for certain resources
79:
80: if ($uri=~/\.(sequence|page)\.meta$/) {
81: $content{'parameter_randompick'}='';
82: $type{'parameter_randompick'}='int_pos';
83: $display{'parameter_randompick'}='Randomly pick number of resources';
84:
85: $content{'parameter_randompickseed'}='';
86: $type{'parameter_randompickseed'}='int_pos';
87: $display{'parameter_randompickseed'}=
88: 'Random seed for randomly picking number of resources (optional, only set if you know what you are doing)';
89: } else {
90: $content{'parameter_mapalias'}='';
91: $type{'parameter_mapalias'}='string';
92: $display{'parameter_mapalias'}='Resource alias name for conditions';
93: }
94: # ---------------------------------------------------------- Current Parameters
95:
96: foreach (split(/\:/,$ENV{'form.parms'})) {
97: my ($ptype,$pname,$pvalue)=split(/\_\_\_/,$_);
98: unless ($type{$pname}) { $type{$pname}=$ptype; }
99: $value{$pname}=$pvalue;
100: }
101:
102: # --------------------------------------------------- Print input screen header
103: my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
104: my $bodytag=&Apache::loncommon::bodytag('Set Resource Parameters in Map');
105: my %lt=&Apache::lonlocal::texthash('pa' => 'Parameter',
106: 'de' => 'Default',
107: 'va' => 'Value',
108: 'se' => 'Set');
109:
110: $r->print(<<ENDHEADER);
111: <html>
112: <head>
113: <title>The LearningOnline Network with CAPA</title>
114: <script language="JavaScript">
115:
116: function pclose() {
117: parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
118: "height=350,width=350,scrollbars=no,menubar=no");
119: parmwin.close();
120: }
121:
122: $pjump_def
123:
124: function stpr() {
125: eval("document.parameters."+document.parameters.pres_marker.value+
126: ".value=document.parameters.pres_value.value");
127: pclose();
128: }
129:
130:
131: function setparms() {
132: ENDHEADER
133: $r->print('var colon=""; opener.objparms['.$ENV{'form.resid'}.']="";');
134: map {
135: $r->print("\nif (document.parameters.def_".$_.
136: '.checked) { opener.objparms['.$ENV{'form.resid'}.
137: ']+=colon+"'.$type{$_}.
138: '___'.$_.'___"+document.parameters.'.$_.'.value; colon=":"; }');
139: } keys %content;
140: $r->print(<<ENDDOCUMENT);
141: opener.save();
142: window.close();
143: }
144: </script>
145: </head>
146: $bodytag
147: <form action="javascript:setparms();" method="post" name="parameters">
148: <input type="hidden" value='' name="pres_value">
149: <input type="hidden" value='' name="pres_type">
150: <input type="hidden" value='' name="pres_marker">
151: <table border=2>
152: <tr><th>$lt{'pa'}</th><th>$lt{'de'}</th><th>$lt{'va'}</th><th>$lt{'se'}?</th></tr>
153: ENDDOCUMENT
154: ### %display=&Apache::lonlocal::texthash(%display);
155: my $enter=&mt('Enter');
156: foreach (sort(keys(%content))) {
157: my $cur=$content{$_};
158: # Should if(defined($value{$_})) be if(exists($value{$_})) ?
159: if (defined($value{$_})) { $cur=$value{$_}; };
160: $r->print(<<"END");
161: <tr><td><b>$display{$_}</b><br><tt>$_</tt></td>
162: <td> $content{$_}</td>
163: <td><input type="text" size="10" name="$_" value="$cur">
164: <a href='javascript:pjump("$type{$_}","$display{$_}",document.parameters.$_.value,"$_","parameters.pres","stpr");'>$enter</a></td>
165: <td><input type="checkbox" name="def_$_"
166: END
167: if ($value{$_}) { $r->print(' checked'); }
168: $r->print('></td></tr>');
169: }
170: $r->print(
171: '</table><br><input type="submit" value="'.&mt('Set').'"></form></body></html>');
172: return OK;
173: }
174:
175: 1;
176: __END__
177:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>