--- rat/lonratparms.pm	2005/04/07 06:56:27	1.23
+++ rat/lonratparms.pm	2008/11/20 15:19:05	1.26
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Set parameters inside of the RAT
 #
-# $Id: lonratparms.pm,v 1.23 2005/04/07 06:56:27 albertel Exp $
+# $Id: lonratparms.pm,v 1.26 2008/11/20 15:19:05 jms Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -76,17 +76,13 @@ sub handler {
   
 # --------------------------------------------------- Print input screen header
     my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
-    my $bodytag=&Apache::loncommon::bodytag('Set Resource Parameters in Map');
+
     my %lt=&Apache::lonlocal::texthash('pa' => 'Parameter',
 			               'de' => 'Default',
 				       'va' => 'Value',
 				       'se' => 'Set');
- 
-    $r->print(<<ENDHEADER);
-<html>
-<head>
-<title>The LearningOnline Network with CAPA</title>
-<script language="JavaScript">
+    my $js = (<<ENDHEADER);
+<script type="text/javascript">
 
     function pclose() {
         parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
@@ -105,20 +101,24 @@ sub handler {
 
 function setparms() {
 ENDHEADER
-    $r->print('var colon=""; opener.objparms['.$env{'form.resid'}.']="";');
-    map {
-       $r->print("\nif (document.parameters.def_".$_.
+    $js .= 'var colon=""; opener.objparms['.$env{'form.resid'}.']="";';
+    foreach my $key (keys(%content)) {
+	$js .= "\nif (document.parameters.def_".$key.
        '.checked) { opener.objparms['.$env{'form.resid'}.
-       ']+=colon+"'.$type{$_}.
-       '___'.$_.'___"+document.parameters.'.$_.'.value; colon=":"; }'); 
-    } keys %content;
-    $r->print(<<ENDDOCUMENT);
+       ']+=colon+"'.$type{$key}.
+       '___'.$key.'___"+document.parameters.'.$key.'.value; colon=":"; }'; 
+    }
+    $js .= '
     opener.save();
     window.close();
 }
 </script>
-</head>
-$bodytag
+';
+    my $start_page =
+	&Apache::loncommon::start_page('Set Resource Parameters in Map',$js);
+
+    $r->print(<<ENDDOCUMENT);
+$start_page
 <form action="javascript:setparms();" method="post" name="parameters">
 <input type="hidden" value='' name="pres_value">
 <input type="hidden" value='' name="pres_type">
@@ -126,27 +126,59 @@ $bodytag
 <table border=2>
 <tr><th>$lt{'pa'}</th><th>$lt{'de'}</th><th>$lt{'va'}</th><th>$lt{'se'}?</th></tr>
 ENDDOCUMENT
+
 ###    %display=&Apache::lonlocal::texthash(%display);
     my $enter=&mt('Enter');
-    foreach (sort(keys(%content))) {
-        my $cur=$content{$_};
-        # Should if(defined($value{$_})) be if(exists($value{$_})) ?
-        if (defined($value{$_})) { $cur=$value{$_}; };
+    foreach my $key (sort(keys(%content))) {
+        my $cur=$content{$key};
+        # Should if(defined($value{$key})) be if(exists($value{$key})) ?
+        if (defined($value{$key})) { $cur=$value{$key}; };
         $r->print(<<"END");
-<tr><td><b>$display{$_}</b><br><tt>$_</tt></td>
-<td>&nbsp;$content{$_}</td>
-<td><input type="text" size="10" name="$_" value="$cur">&nbsp;
-<a href='javascript:pjump("$type{$_}","$display{$_}",document.parameters.$_.value,"$_","parameters.pres","stpr");'>$enter</a></td>
-<td><input type="checkbox" name="def_$_" 
+<tr><td><b>$display{$key}</b><br><tt>$key</tt></td>
+<td>&nbsp;$content{$key}</td>
+<td><input type="text" size="10" name="$key" value="$cur">&nbsp;
+<a href='javascript:pjump("$type{$key}","$display{$key}",document.parameters.$key.value,"$key","parameters.pres","stpr");'>$enter</a></td>
+<td><input type="checkbox" name="def_$key" 
 END
-        if ($value{$_}) { $r->print(' checked'); }
+        if ($value{$key}) { $r->print(' checked'); }
         $r->print('></td></tr>');
     }
-    $r->print(
-        '</table><br><input type="submit" value="'.&mt('Set').'"></form></body></html>');
+    $r->print('</table><br />
+               <input type="submit" value="'.&mt('Set').'"></form>'.
+	      &Apache::loncommon::end_page());
     return OK;
 } 
 
 1;
 __END__
 
+
+
+=head1 NAME
+
+Apache::lonratparams
+
+=head1 SYNOPSIS
+
+Handler to set resource parameters inside of
+the RAT based on metadata.
+
+This is part of the LearningOnline Network with CAPA project
+described at http://www.lon-capa.org.
+
+=head1 HANDLER SUBROUTINE
+
+handler()
+
+=head1 OTHER SUBROUTINES
+
+=over
+
+=item *
+
+none
+
+=back
+
+=cut
+