Annotation of rat/lonratparms.pm, revision 1.29

1.1       www         1: # The LearningOnline Network with CAPA
                      2: # Set parameters inside of the RAT
                      3: #
1.29    ! www         4: # $Id: lonratparms.pm,v 1.28 2009/04/23 17:26:27 bisitz Exp $
1.8       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: #
1.20      www        28: 
1.1       www        29: package Apache::lonratparms;
                     30: 
                     31: use strict;
                     32: use Apache::Constants qw(:common);
1.15      matthew    33: use Apache::lonhtmlcommon();
1.16      www        34: use Apache::lonlocal;
1.23      albertel   35: use Apache::lonnet;
1.1       www        36: 
                     37: sub handler {
                     38:     my $r = shift;
1.16      www        39:     &Apache::loncommon::content_type($r,'text/html');
1.1       www        40:     $r->send_http_header;
                     41:     return OK if $r->header_only;
                     42: 
1.2       www        43: # Get query string for limited number of parameters
                     44: 
1.10      stredwic   45:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.11      www        46:                                             ['url','parms','resid']);
1.2       www        47: 
                     48: # ------------------------------------------------------------------- Read file
                     49: 
1.23      albertel   50:   my $uri=$env{'form.url'}.'.meta';
1.3       www        51:   
                     52:   my %content;
                     53:   my %type;
1.5       www        54:   my %display;
1.3       www        55:   my %value;
                     56:   
1.20      www        57: # ---------------------------------------------------------- Current Parameters
                     58: 
1.22      www        59:   foreach (split(/\,/,&Apache::lonnet::metadata($uri,'keys'))) {
                     60:       if ($_=~/^parameter\_/) {
                     61:          $content{$_}=&Apache::lonnet::metadata($uri,$_);
                     62:          $type{$_}=&Apache::lonnet::metadata($uri,$_.'.type');
                     63:          $display{$_}=&Apache::lonnet::metadata($uri,$_.'.display');
                     64:       }
                     65:   }
                     66: 
1.23      albertel   67:   foreach (split(/\:/,$env{'form.parms'})) {
1.20      www        68:       my ($ptype,$pname,$pvalue)=split(/\_\_\_/,$_);
1.21      www        69:       unless ($pname) { next; }
1.20      www        70:       unless ($type{$pname}) { $type{$pname}=$ptype; }
                     71:       $value{$pname}=$pvalue;
                     72:       $content{$pname}=$pvalue;
                     73:       $type{$pname}=$ptype;
                     74:       $display{$pname}=&mt('Custom Parameter');
                     75:   } 
1.3       www        76:   
                     77: # --------------------------------------------------- Print input screen header
1.15      matthew    78:     my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
1.24      albertel   79: 
1.17      www        80:     my %lt=&Apache::lonlocal::texthash('pa' => 'Parameter',
                     81: 			               'de' => 'Default',
                     82: 				       'va' => 'Value',
1.28      bisitz     83: 				       'se' => 'Set?');
1.24      albertel   84:     my $js = (<<ENDHEADER);
                     85: <script type="text/javascript">
1.7       www        86: 
1.15      matthew    87:     $pjump_def
1.7       www        88: 
                     89:     function stpr() {
                     90:         eval("document.parameters."+document.parameters.pres_marker.value+
                     91:             ".value=document.parameters.pres_value.value");
1.29    ! www        92:         modalWindow.close();
1.7       www        93:     }
                     94: 
                     95: 
1.3       www        96: function setparms() {
                     97: ENDHEADER
1.24      albertel   98:     $js .= 'var colon=""; opener.objparms['.$env{'form.resid'}.']="";';
                     99:     foreach my $key (keys(%content)) {
                    100: 	$js .= "\nif (document.parameters.def_".$key.
1.23      albertel  101:        '.checked) { opener.objparms['.$env{'form.resid'}.
1.24      albertel  102:        ']+=colon+"'.$type{$key}.
                    103:        '___'.$key.'___"+document.parameters.'.$key.'.value; colon=":"; }'; 
                    104:     }
                    105:     $js .= '
1.6       www       106:     opener.save();
1.3       www       107:     window.close();
                    108: }
                    109: </script>
1.24      albertel  110: ';
                    111:     my $start_page =
                    112: 	&Apache::loncommon::start_page('Set Resource Parameters in Map',$js);
                    113: 
                    114:     $r->print(<<ENDDOCUMENT);
                    115: $start_page
1.4       www       116: <form action="javascript:setparms();" method="post" name="parameters">
1.27      bisitz    117: <input type="hidden" value="" name="pres_value" />
                    118: <input type="hidden" value="" name="pres_type" />
                    119: <input type="hidden" value="" name="pres_marker" />
1.28      bisitz    120: <table border="2">
                    121: <tr><th>$lt{'pa'}</th><th>$lt{'de'}</th><th>$lt{'va'}</th><th>$lt{'se'}</th></tr>
1.1       www       122: ENDDOCUMENT
1.24      albertel  123: 
1.17      www       124: ###    %display=&Apache::lonlocal::texthash(%display);
1.16      www       125:     my $enter=&mt('Enter');
1.24      albertel  126:     foreach my $key (sort(keys(%content))) {
                    127:         my $cur=$content{$key};
                    128:         # Should if(defined($value{$key})) be if(exists($value{$key})) ?
                    129:         if (defined($value{$key})) { $cur=$value{$key}; };
1.9       matthew   130:         $r->print(<<"END");
1.27      bisitz    131: <tr><td><b>$display{$key}</b><br /><tt>$key</tt></td>
1.24      albertel  132: <td>&nbsp;$content{$key}</td>
1.27      bisitz    133: <td><input type="text" size="10" name="$key" value="$cur" />&nbsp;
1.24      albertel  134: <a href='javascript:pjump("$type{$key}","$display{$key}",document.parameters.$key.value,"$key","parameters.pres","stpr");'>$enter</a></td>
                    135: <td><input type="checkbox" name="def_$key" 
1.9       matthew   136: END
1.27      bisitz    137:         if ($value{$key}) { $r->print(' checked="checked"'); }
                    138:         $r->print(' /></td></tr>');
1.9       matthew   139:     }
1.24      albertel  140:     $r->print('</table><br />
1.27      bisitz    141:                <input type="submit" value="'.&mt('Set').'" /></form>'.
1.24      albertel  142: 	      &Apache::loncommon::end_page());
1.1       www       143:     return OK;
                    144: } 
                    145: 
                    146: 1;
                    147: __END__
1.7       www       148: 
1.26      jms       149: 
                    150: 
                    151: =head1 NAME
                    152: 
                    153: Apache::lonratparams
                    154: 
                    155: =head1 SYNOPSIS
                    156: 
                    157: Handler to set resource parameters inside of
                    158: the RAT based on metadata.
                    159: 
                    160: This is part of the LearningOnline Network with CAPA project
                    161: described at http://www.lon-capa.org.
                    162: 
                    163: =head1 HANDLER SUBROUTINE
                    164: 
                    165: handler()
                    166: 
                    167: =head1 OTHER SUBROUTINES
                    168: 
                    169: =over
                    170: 
                    171: =item *
                    172: 
                    173: none
                    174: 
                    175: =back
                    176: 
                    177: =cut
                    178: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>
500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.