Diff for /loncom/interface/lonparmset.pm between versions 1.122 and 1.124

version 1.122, 2003/09/04 01:09:04 version 1.124, 2003/09/05 03:47:47
Line 1666  ENDENV Line 1666  ENDENV
 }  }
 ##################################################  ##################################################
   
   my $tableopen;
   
   sub tablestart {
       if ($tableopen) {
    return '';
       } else {
    $tableopen=1;
    return '<table border="2"><tr><th>Parameter</th><th>Delete</th><th>Set to ...</th></tr>';
       }
   }
   
   sub tableend {
       if ($tableopen) {
    $tableopen=0;
    return '</table>';
       } else {
    return'';
       }
   }
   
 sub overview {  sub overview {
     my $r=shift;      my $r=shift;
     my $bodytag=&Apache::loncommon::bodytag(      my $bodytag=&Apache::loncommon::bodytag(
Line 1678  sub overview { Line 1698  sub overview {
 <title>LON-CAPA Course Environment</title>  <title>LON-CAPA Course Environment</title>
 </head>  </head>
 $bodytag  $bodytag
 <form method="post" action="/adm/parmset" name="overview">  <form method="post" action="/adm/parmset" name="overviewform">
 <input type="hidden" name="overview" value="1" />  <input type="hidden" name="overview" value="1" />
 ENDOVER  ENDOVER
   # Setting
       my %olddata=&Apache::lonnet::dump('resourcedata',$dom,$crs);
       my %newdata=();
       undef %newdata;
       my @deldata=();
       undef @deldata;
       foreach (keys %ENV) {
    if ($_=~/^form\.([a-z]+)\_(.+)$/) {
       my $cmd=$1;
       my $thiskey=$2;
       if ($cmd eq 'set') {
    my $data=$ENV{$_};
    if ($olddata{$thiskey} ne $data) { $newdata{$thiskey}=$data; }
       } elsif ($cmd eq 'del') {
    push (@deldata,$thiskey);
       } elsif ($cmd eq 'datepointer') {
    my $data=&Apache::lonhtmlcommon::get_date_from_form($ENV{$_});
    if ($olddata{$thiskey} ne $data) { $newdata{$thiskey}=$data; }
       }
    }
       }
   # Store
       &Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs);
       &Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs);
 # Read and display  # Read and display
     my %resourcedata=&Apache::lonnet::dump('resourcedata',$dom,$crs);      my %resourcedata=&Apache::lonnet::dump('resourcedata',$dom,$crs);
     my $oldsection='';      my $oldsection='';
     my $oldrealm='';      my $oldrealm='';
     my $oldpart='';      my $oldpart='';
       my $pointer=0;
       $tableopen=0;
     foreach my $thiskey (sort keys %resourcedata) {      foreach my $thiskey (sort keys %resourcedata) {
  my ($course,$middle,$part,$name)=   if ($resourcedata{$thiskey.'.type'}) {
     ($thiskey=~/^(\w+)\.(.*)\.*([\w\s]+)\.(\w+)$/);      my ($course,$middle,$part,$name)=
  unless ($name eq 'type') {   ($thiskey=~/^(\w+)\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
     my $section='All Students';      my $section='All Students';
     if ($middle=~/^\[(.*)\]\./) {      if ($middle=~/^\[(.*)\]\./) {
  $section='Group/Section: '.$1;   $section='Group/Section: '.$1;
  $middle=~s/^\[(.*)\]\.//;   $middle=~s/^\[(.*)\]\.//;
     }      }
     my $realm='All Resources';      $middle=~s/\.$//;
       my $realm='<font color="red">All Resources</font>';
     if ($middle=~/^(.+)\_\_\_\(all\)$/) {      if ($middle=~/^(.+)\_\_\_\(all\)$/) {
  $realm='Folder/Map: '.$1;   $realm='<font color="green">Folder/Map: '.&Apache::lonnet::gettitle($1).'</font>';
     } elsif ($middle) {      } elsif ($middle) {
  $realm='Resource: '.$middle;   $realm='<font color="orange">Resource: '.&Apache::lonnet::gettitle($middle).'</font>';
     }      }
     if ($section ne $oldsection) {      if ($section ne $oldsection) {
  $r->print("\n<hr /><h1>$section</h1>");   $r->print(&tableend()."\n<hr /><h1>$section</h1>");
  $oldsection=$section;   $oldsection=$section;
  $oldrealm='';   $oldrealm='';
     }      }
     if ($realm ne $oldrealm) {      if ($realm ne $oldrealm) {
  $r->print("\n<h2>$realm</h2>");   $r->print(&tableend()."\n<h2>$realm</h2>");
  $oldrealm=$realm;   $oldrealm=$realm;
  $oldpart='';   $oldpart='';
     }      }
     if ($part ne $oldpart) {      if ($part ne $oldpart) {
  $r->print("\n<h3>Part: $part</h3>");   $r->print(&tableend().
     "\n<h3><font color='blue'>Part: $part</font></h3>");
  $oldpart=$part;   $oldpart=$part;
     }      }
   #
     $r->print('<br />'.$name.': '.$thiskey.' = '.$resourcedata{$thiskey});  # Ready to print
   #
       $r->print(&tablestart().'<tr><td><b>'.$name.
         ':</b></td><td><input type="checkbox" name="del_'.
         $thiskey.'" /></td><td>');
       if ($resourcedata{$thiskey.'.type'}=~/^date/) {
    my $jskey='key_'.$pointer;
    $pointer++;
    $r->print(
     &Apache::lonhtmlcommon::date_setter('overviewform',
         $jskey,
         $resourcedata{$thiskey}).
   '<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'
     );
       } else {
    $r->print(
     '<input type="text" name="set_'.$thiskey.'" value="'.
     $resourcedata{$thiskey}.'">');
       }
       $r->print('</td></tr>');
  }   }
     }      }
     $r->print('</form></body></html>');      
       $r->print(&tableend().
         '<p><input type="submit" value="Modify Parameters" /></p></form></body></html>');
 }  }
   
 ##################################################  ##################################################

Removed from v.1.122  
changed lines
  Added in v.1.124


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>