Diff for /loncom/interface/lonparmset.pm between versions 1.413 and 1.413.4.1

version 1.413, 2008/10/23 14:26:17 version 1.413.4.1, 2009/05/20 18:03:04
Line 46  This module sets coursewide and assessme Line 46  This module sets coursewide and assessme
   
 =over 4  =over 4
   
   =item parmval()
   
   Figure out a cascading parameter.
   
   Inputs:  $what - a parameter spec (incluse part info and name I.E. 0.weight)
            $id   - a bighash Id number
            $def  - the resource's default value   'stupid emacs
   
   Returns:  A list, the first item is the index into the remaining list of items of parm valuse that is the active one, the list consists of parm values at the 14 possible levels
   
            14- General Course
            13- Map or Folder level in course
            12- resource default
            11- map default
            10- resource level in course
            9 - General for section
            8 - Map or Folder level for section
            7 - resource level in section
            6 - General for group
            5 - Map or Folder level for group
            4 - resource level in group
            3 - General for specific student
            2 - Map or Folder level for specific student
            1 - resource level for specific student
   
   =item parmval_by_symb()
   
   =item reset_caches()
   
   =item cacheparmhash()
   
   =item parmhash()
   
   =item symbcache()
   
   =item preset_defaults()
   
   =item date_sanity_info()
   
   =item storeparm()
   
   Store a parameter by symb
   
       Takes
       - symb
       - name of parameter
       - level
       - new value
       - new type
       - username
       - userdomain
   
   =item log_parmset()
   
   =item storeparm_by_symb_inner()
   
   =item valout()
   
   Format a value for output.
   
   Inputs:  $value, $type, $editable
   
   Returns: $value, formatted for output.  If $type indicates it is a date,
   localtime($value) is returned.
   $editable will return an icon to click on
   
   =item plink()
   
   Produces a link anchor.
   
   Inputs: $type,$dis,$value,$marker,$return,$call
   
   Returns: scalar with html code for a link which will envoke the
   javascript function 'pjump'.
   
   =item page_js()
   
   =item startpage()
   
   =item print_row()
   
   =item print_td()
   
   =item print_usergroups()
   
   =item parm_control_group()
   
   =item extractResourceInformation() :
   
   Given the course data hash, extractResourceInformation extracts lots of information about the course's resources into a variety of hashes.
   
   Input: See list below:
   
   =item * B<ids> : An array that will contain all of the ids in the course.
   
   =item * B<typep> : hash, id->type, where "type" contains the extension of the file, thus, I<problem exam quiz assess survey form>.
   
   =item * B<keyp> : hash, id->key list, will contain a comma separated list of the meta-data keys available for the given id
   
   
   =item * B<allparms> : hash, name of parameter->display value (what is the display value?)
   
   =item * B<allparts> : hash, part identification->text representation of part, where the text representation is "[Part $part]"
   
   =item * B<allkeys> : hash, full key to part->display value (what's display value?)
   
   =item * B<allmaps> : hash, ???
   
   =item * B<fcat> : ???
   
   =item * B<defp> : hash, ???
   
   =item * B<mapp> : ??
   
   =item * B<symbp> : hash, id->full sym?
   
   
   
   =item isdateparm()
   
   =item parmmenu()
   
   =item partmenu()
   
   =item usermenu()
   
   =item displaymenu()
   
   =item mapmenu()
   
   =item levelmenu()
   
   =item sectionmenu()
   
   =item keysplit()
   
   =item keysinorder()
   
   =item keysinorder_bytype()
   
   =item keysindisplayorder()
   
   =item standardkeyorder()
   
   =item assessparms() :
   
   Show assessment data and parameters.  This is a large routine that should
   be simplified and shortened... someday.
   
   Inputs: $r
   
   Returns: nothing
   
   Variables used (guessed by Jeremy):
   
   =item * B<pscat>: ParameterS CATegories? ends up a list of the types of parameters that exist, e.g., tol, weight, acc, opendate, duedate, answerdate, sig, maxtries, type.
   
   =item * B<psprt>: ParameterS PaRTs? a list of the parts of a problem that we are displaying? Used to display only selected parts?
   
   =item * B<@catmarker> contains list of all possible parameters including part #s
   
   =item * B<$fullkeyp> contains the full part/id # for the extraction of proper parameters
   
   =item * B<$tempkeyp> contains part 0 only (no ids - ie, subparts)
           When storing information, store as part 0
           When requesting information, request from full part
   
   =item tablestart()
   
   =item tableend()
   
   =item extractuser()
   
   =item parse_listdata_key()
   
   =item listdata()
   
   =item date_interval_selector()
   
   =item get_date_interval_from_form()
   
   =item default_selector()
   
   =item string_selector()
   
   =item dateshift()
   
   =item newoverview()
   
   =item secgroup_lister()
   
   =item overview()
   
   =item clean_parameters()
   
   =item date_shift_one()
   
   =item date_shift_two()
   
   =item parse_key()
   
   =item check_cloners() :
   
   Checks if new users included in list of allowed cloners
   are valid users.  Replaces supplied list with
   cleaned list containing only users with valid usernames
   and domains.
   
   Inputs: $clonelist, $oldcloner
   where $clonelist is ref to array of requested cloners,
   and $oldcloner is ref to array of currently allowed
   cloners.
   
   Returns: string - comma separated list of requested
   cloners (username:domain) who do not exist in system.
   
   =item change_clone() :
   
   Modifies the list of courses a user can clone (stored
   in the user's environment.db file), called when a
   change is made to the list of users allowed to clone
   a course.
   
   Inputs: $action,$cloner
   where $action is add or drop, and $cloner is identity of
   user for whom cloning ability is to be changed in course.
   
   
   =item check_cloners()
   
   =item change_clone()
   
   =item header()
   
   Output html header for page
   
   =item print_main_menu()
   
   =item output_row()
   
   Set portfolio metadata
   
   =item order_meta_fields()
   
   =item addmetafield()
   
   =item setrestrictmeta()
   
   =item get_added_meta_fieldnames()
   
   =item get_deleted_meta_fieldnames()
   
   =item defaultsetter()
   
   =item components()
   
   =item load_parameter_names()
   
   =item parm_change_log()
   
   =item handler() :
   
   Main handler.  Calls &assessparms subroutine.
   
   
   =back
   
 =cut  =cut
   
   
 ###################################################################  ###################################################################
 ###################################################################  ###################################################################
   
Line 67  use Apache::longroup; Line 335  use Apache::longroup;
 use Apache::lonrss;  use Apache::lonrss;
 use LONCAPA qw(:DEFAULT :match);  use LONCAPA qw(:DEFAULT :match);
   
   
 ##################################################  
 ##################################################  
   
 =pod  
   
 =item parmval  
   
 Figure out a cascading parameter.  
   
 Inputs:  $what - a parameter spec (incluse part info and name I.E. 0.weight)  
          $id   - a bighash Id number  
          $def  - the resource's default value   'stupid emacs  
   
 Returns:  A list, the first item is the index into the remaining list of items of parm valuse that is the active one, the list consists of parm values at the 14 possible levels  
   
 14- General Course  
 13- Map or Folder level in course  
 12- resource default  
 11- map default  
 10- resource level in course  
 9 - General for section  
 8 - Map or Folder level for section  
 7 - resource level in section  
 6 - General for group  
 5 - Map or Folder level for group  
 4 - resource level in group  
 3 - General for specific student  
 2 - Map or Folder level for specific student  
 1 - resource level for specific student  
   
 =cut  
   
 ##################################################  
 sub parmval {  sub parmval {
     my ($what,$id,$def,$uname,$udom,$csec,$cgroup,$courseopt)=@_;      my ($what,$id,$def,$uname,$udom,$csec,$cgroup,$courseopt)=@_;
     return &parmval_by_symb($what,&symbcache($id),$def,$uname,$udom,$csec,      return &parmval_by_symb($what,&symbcache($id),$def,$uname,$udom,$csec,
Line 302  sub reset_caches { Line 536  sub reset_caches {
     }      }
 }  }
   
   
 sub preset_defaults {  sub preset_defaults {
     my $type=shift;      my $type=shift;
     if (&rulescache($type.'_action') eq 'default') {      if (&rulescache($type.'_action') eq 'default') {
Line 316  sub preset_defaults { Line 551  sub preset_defaults {
     }      }
 }  }
   
 ##################################################  
   
 sub date_sanity_info {  sub date_sanity_info {
    my $checkdate=shift;     my $checkdate=shift;
Line 371  sub storeparm { Line 605  sub storeparm {
     &storeparm_by_symb(&symbcache($sresid),$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,'',$cgroup);      &storeparm_by_symb(&symbcache($sresid),$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,'',$cgroup);
 }  }
   
 #  
 # Store a parameter by symb  
 #  
 # Takes  
 # - symb  
 # - name of parameter  
 # - level  
 # - new value  
 # - new type  
 # - username  
 # - userdomain  
 my %recstack;  my %recstack;
 sub storeparm_by_symb {  sub storeparm_by_symb {
     my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$recflag,$cgroup)=@_;      my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$recflag,$cgroup)=@_;
Line 536  sub storeparm_by_symb_inner { Line 759  sub storeparm_by_symb_inner {
     return '';      return '';
 }  }
   
 ##################################################  
 ##################################################  
   
 =pod  
   
 =item valout  
   
 Format a value for output.  
   
 Inputs:  $value, $type, $editable  
   
 Returns: $value, formatted for output.  If $type indicates it is a date,  
 localtime($value) is returned.  
 $editable will return an icon to click on  
   
 =cut  
   
 ##################################################  
 ##################################################  
 sub valout {  sub valout {
     my ($value,$type,$editable)=@_;      my ($value,$type,$editable)=@_;
     my $result = '';      my $result = '';
Line 611  sub valout { Line 815  sub valout {
     return $result;      return $result;
 }  }
   
 ##################################################  
 ##################################################  
   
 =pod  
   
 =item plink  
   
 Produces a link anchor.  
   
 Inputs: $type,$dis,$value,$marker,$return,$call  
   
 Returns: scalar with html code for a link which will envoke the   
 javascript function 'pjump'.  
   
 =cut  
   
 ##################################################  
 ##################################################  
 sub plink {  sub plink {
     my ($type,$dis,$value,$marker,$return,$call)=@_;      my ($type,$dis,$value,$marker,$return,$call)=@_;
     my $winvalue=$value;      my $winvalue=$value;
Line 643  sub plink { Line 829  sub plink {
     my ($hour,$min,$sec,$val)=&preset_defaults($parmname);      my ($hour,$min,$sec,$val)=&preset_defaults($parmname);
     unless (defined($winvalue)) { $winvalue=$val; }      unless (defined($winvalue)) { $winvalue=$val; }
     my $valout = &valout($value,$type,1);      my $valout = &valout($value,$type,1);
       my $unencmarker = $marker;
     foreach my $item (\$type, \$dis, \$winvalue, \$marker, \$return, \$call,      foreach my $item (\$type, \$dis, \$winvalue, \$marker, \$return, \$call,
       \$hour, \$min, \$sec) {        \$hour, \$min, \$sec) {
  $$item = &HTML::Entities::encode($$item,'"<>&');   $$item = &HTML::Entities::encode($$item,'"<>&');
Line 650  sub plink { Line 837  sub plink {
     }      }
     return '<table width="100%"><tr valign="top" align="right"><td><a name="'.$marker.'" /></td></tr><tr><td align="center">'.      return '<table width="100%"><tr valign="top" align="right"><td><a name="'.$marker.'" /></td></tr><tr><td align="center">'.
  '<a href="javascript:pjump('."'".$type."','".$dis."','".$winvalue."','"   '<a href="javascript:pjump('."'".$type."','".$dis."','".$winvalue."','"
     .$marker."','".$return."','".$call."','".$hour."','".$min."','".$sec."'".');">'.      .$unencmarker."','".$return."','".$call."','".$hour."','".$min."','".$sec."'".');">'.
     $valout.'</a></td></tr></table>';      $valout.'</a></td></tr></table>';
 }  }
   
Line 721  sub startpage { Line 908  sub startpage {
 $start_page  $start_page
 $breadcrumbs  $breadcrumbs
 <form method="post" action="/adm/parmset?action=settable" name="parmform">  <form method="post" action="/adm/parmset?action=settable" name="parmform">
 <input type="hidden" value='' name="pres_value" />  <input type="hidden" value="" name="pres_value" />
 <input type="hidden" value='' name="pres_type" />  <input type="hidden" value="" name="pres_type" />
 <input type="hidden" value='' name="pres_marker" />  <input type="hidden" value="" name="pres_marker" />
 <input type="hidden" value='1' name="prevvisit" />  <input type="hidden" value="1" name="prevvisit" />
 ENDHEAD  ENDHEAD
 }  }
   
Line 756  sub print_row { Line 943  sub print_row {
     my $parm=$$display{$which};      my $parm=$$display{$which};
   
     if ($parmlev eq 'full') {      if ($parmlev eq 'full') {
         $r->print('<td bgcolor='.$defbgtwo.' align="center">'          $r->print('<td style="background-color:'.$defbgtwo.';" align="center">'
                   .$$part{$which}.'</td>');                    .$$part{$which}.'</td>');
     } else {          } else {    
         $parm=~s|\[.*\]\s||g;          $parm=~s|\[.*\]\s||g;
Line 765  sub print_row { Line 952  sub print_row {
     if ($automatic) {      if ($automatic) {
  $parm.='<span class="LC_warning"><br />'.&mt('Automatically sets').' '.join(', ',split(/\:/,$automatic)).'</span>';   $parm.='<span class="LC_warning"><br />'.&mt('Automatically sets').' '.join(', ',split(/\:/,$automatic)).'</span>';
     }      }
     $r->print('<td bgcolor='.$defbgone.'>'.$parm.'</td>');      $r->print('<td>'.$parm.'</td>');
         
     my $thismarker=$which;      my $thismarker=$which;
     $thismarker=~s/^parameter\_//;      $thismarker=~s/^parameter\_//;
Line 842  sub print_row { Line 1029  sub print_row {
  }   }
   
     } # end of $parmlev if/else      } # end of $parmlev if/else
     $r->print('<td bgcolor="#CCCCFF" align="center">'.$effective_parm.'</td>');      $r->print('<td style="background-color:#CCCCFF;" align="center">'.$effective_parm.'</td>');
   
     if ($parmlev eq 'full') {      if ($parmlev eq 'full') {
         my $sessionval=&Apache::lonnet::EXT('resource.'.$$part{$which}.          my $sessionval=&Apache::lonnet::EXT('resource.'.$$part{$which}.
                                         '.'.$$name{$which},$$symbp{$rid});                                          '.'.$$name{$which},$$symbp{$rid});
         my $sessionvaltype=$typeoutpar[$result];          my $sessionvaltype=$typeoutpar[$result];
         if (!defined($sessionvaltype)) { $sessionvaltype=$$defaulttype{$which}; }          if (!defined($sessionvaltype)) { $sessionvaltype=$$defaulttype{$which}; }
         $r->print('<td bgcolor="#999999" align="center"><font color="#FFFFFF">'.          $r->print('<td style="background-color:#999999;" align="center"><font color="#FFFFFF">'.
                   &valout($sessionval,$sessionvaltype).'&nbsp;'.                    &valout($sessionval,$sessionvaltype).'&nbsp;'.
                   '</font></td>');                    '</font></td>');
     }      }
     $r->print('</tr>');  
     $r->print("\n");  
 }  }
   
 sub print_td {  sub print_td {
     my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display)=@_;      my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display)=@_;
     $r->print('<td bgcolor='.(($result==$which)?'"#AAFFAA"':$defbg).      $r->print('<td style="background-color:'.(($result==$which)?'#AAFFAA':$defbg).
               ' align="center">');                ';" align="center">');
     if ($which<11 || $which > 12) {      my $nolink = 0;
  $r->print(&plink($$typeoutpar[$which],      if ($which == 11 || $which == 12) {
  $$display{$value},$$outpar[$which],          $nolink = 1;
  $mprefix."$which",'parmform.pres','psub'));      } elsif ($mprefix =~ /availablestudent\&$/) {
           if ($which > 3) {
               $nolink = 1;
           }
       }
       if ($nolink) {
           $r->print(&valout($$outpar[$which],$$typeoutpar[$which]));
     } else {      } else {
  $r->print(&valout($$outpar[$which],$$typeoutpar[$which]));          $r->print(&plink($$typeoutpar[$which],
                            $$display{$value},$$outpar[$which],
                            $mprefix."$which",'parmform.pres','psub'));
     }      }
     $r->print('</td>'."\n");      $r->print('</td>'."\n");
 }  }
Line 886  sub print_usergroups { Line 1079  sub print_usergroups {
     my $grp_parm;      my $grp_parm;
     if (($coursereply) && ($cgroup ne $resultgroup)) {       if (($coursereply) && ($cgroup ne $resultgroup)) { 
         if ($result > 3) {          if ($result > 3) {
             $bgcolor = '"#AAFFAA"';              $bgcolor = '#AAFFAA';
             $grp_parm = &valout($coursereply,$resulttype);              $grp_parm = &valout($coursereply,$resulttype);
         }          }
         $grp_parm = &valout($coursereply,$resulttype);          $grp_parm = &valout($coursereply,$resulttype);
         $output = '<td bgcolor='.$bgcolor.' align="center">';          $output = '<td style="background-color:'.$bgcolor.';" align="center">';
         if ($resultgroup && $resultlevel) {          if ($resultgroup && $resultlevel) {
             $output .= '<small><b>'.$resultgroup.'</b> ('.$resultlevel.'): </small>'.$grp_parm;              $output .= '<small><b>'.$resultgroup.'</b> ('.$resultlevel.'): </small>'.$grp_parm;
         } else {          } else {
Line 898  sub print_usergroups { Line 1091  sub print_usergroups {
         }          }
         $output .= '</td>';          $output .= '</td>';
     } else {      } else {
         $output .= '<td bgcolor='.$bgcolor.'>&nbsp;</td>';          $output .= '<td style="background-color:'.$bgcolor.';">&nbsp;</td>';
     }      }
     return ($coursereply,$output,$grp_parm,$resultgroup);      return ($coursereply,$output,$grp_parm,$resultgroup);
 }  }
Line 927  sub parm_control_group { Line 1120  sub parm_control_group {
     return($coursereply,$resultitem,$resultgroup,$resultlevel,$resulttype);      return($coursereply,$resultitem,$resultgroup,$resultlevel,$resulttype);
 }  }
   
 =pod  
   
 =item B<extractResourceInformation>: Given the course data hash, extractResourceInformation extracts lots of information about the course's resources into a variety of hashes.  
   
 Input: See list below:  
   
 =over 4  
   
 =item B<ids>: An array that will contain all of the ids in the course.  
   
 =item B<typep>: hash, id->type, where "type" contains the extension of the file, thus, I<problem exam quiz assess survey form>.  
   
 =item B<keyp>: hash, id->key list, will contain a comma separated list of the meta-data keys available for the given id  
   
 =item B<allparms>: hash, name of parameter->display value (what is the display value?)  
   
 =item B<allparts>: hash, part identification->text representation of part, where the text representation is "[Part $part]"  
   
 =item B<allkeys>: hash, full key to part->display value (what's display value?)  
   
 =item B<allmaps>: hash, ???  
   
 =item B<fcat>: ???  
   
 =item B<defp>: hash, ???  
   
 =item B<mapp>: ??  
   
 =item B<symbp>: hash, id->full sym?  
   
 =back  
   
 =cut  
   
 sub extractResourceInformation {  sub extractResourceInformation {
     my $ids = shift;      my $ids = shift;
     my $typep = shift;      my $typep = shift;
Line 999  sub extractResourceInformation { Line 1158  sub extractResourceInformation {
 #  #
     my $name=&Apache::lonnet::metadata($srcf,$key.'.name');      my $name=&Apache::lonnet::metadata($srcf,$key.'.name');
     if (!exists($$allparms{$name}) || $$allparms{$name} =~ m/^\s*$/ ) {      if (!exists($$allparms{$name}) || $$allparms{$name} =~ m/^\s*$/ ) {
  my $display= &Apache::lonnet::metadata($srcf,$key.'.display');                  my ($display,$parmdis);
  my $parmdis = $display;                  $display = &standard_parameter_names($name);
  $parmdis =~ s/\s*\[Part.*$//g;                  if ($display eq '') {
                       $display= &Apache::lonnet::metadata($srcf,$key.'.display');
                       $parmdis = $display;
                       $parmdis =~ s/\s*\[Part.*$//g;
                   } else {
                       $parmdis = $display;
                   }
  $$allparms{$name}=$parmdis;   $$allparms{$name}=$parmdis;
  if (ref($defkeytype)) {   if (ref($defkeytype)) {
     $$defkeytype{$name}=      $$defkeytype{$name}=
Line 1127  sub parmmenu { Line 1292  sub parmmenu {
 </script>  </script>
 ENDSCRIPT  ENDSCRIPT
     $r->print();      $r->print();
     $r->print("\n<table id=\"LC_parm_overview_parm_menu\"><tr>");      $r->print("\n".'<table id="LC_parm_overview_parm_menu"><tr>');
     my $cnt=0;      my $cnt=0;
     foreach $tempkey (&keysindisplayorder($allparms,$keyorder)) {      foreach $tempkey (&keysindisplayorder($allparms,$keyorder)) {
  $r->print("\n<td><label><input type='checkbox' name='pscat' ");   $r->print("\n".'<td><label><input type="checkbox" name="pscat" ');
  $r->print('value="'.$tempkey.'"');   $r->print('value="'.$tempkey.'"');
  if ($$pscat[0] eq "all" || grep $_ eq $tempkey, @{$pscat}) {   if ($$pscat[0] eq "all" || grep $_ eq $tempkey, @{$pscat}) {
     $r->print(' checked');      $r->print(' checked="checked"');
  }   }
  $r->print('>'.($$allparms{$tempkey}=~/\S/ ? &mt($$allparms{$tempkey})          $r->print(' />'.($$allparms{$tempkey}=~/\S/ ? $$allparms{$tempkey}
                                   : &mt($tempkey))                                                    : $tempkey).
   .'</label></td>');                    '</label></td>');
   $cnt++;    $cnt++;
         if ($cnt==3) {          if ($cnt==3) {
     $r->print("</tr>\n<tr>");      $r->print("</tr>\n<tr>");
Line 1145  ENDSCRIPT Line 1310  ENDSCRIPT
  }   }
     }      }
     $r->print('</tr>'      $r->print('</tr>'
              .'<tr id=\"LC_parm_overview_parm_menu_selectors\">'               .'<tr id="LC_parm_overview_parm_menu_selectors">'
              .'<td valign="top">'               .'<td valign="top">'
              .'<fieldset><legend><b>'.&mt('Parameter Selection').'</b></legend>'               .'<fieldset><legend><b>'.&mt('Parameter Selection').'</b></legend>'
              .'<span class="LC_nobreak">'               .'<span class="LC_nobreak">'
Line 1188  ENDSCRIPT Line 1353  ENDSCRIPT
   
 sub partmenu {  sub partmenu {
     my ($r,$allparts,$psprt)=@_;      my ($r,$allparts,$psprt)=@_;
     $r->print('<select multiple name="psprt" size="8">');      $r->print('<select multiple="multiple" name="psprt" size="8">');
     $r->print('<option value="all"');      $r->print('<option value="all"');
     $r->print(' selected="selected"') unless (@{$psprt});      $r->print(' selected="selected"') unless (@{$psprt});
     $r->print('>'.&mt('All Parts').'</option>');      $r->print('>'.&mt('All Parts').'</option>');
Line 1352  sub sectionmenu { Line 1517  sub sectionmenu {
     my %sectionhash = &Apache::loncommon::get_sections();      my %sectionhash = &Apache::loncommon::get_sections();
     return if (!%sectionhash);      return if (!%sectionhash);
   
     $r->print('<select name="Section" multiple="true" size="8" >');      $r->print('<select name="Section" multiple="multiple" size="8" >');
     foreach my $s ('all',sort keys %sectionhash) {      foreach my $s ('all',sort keys %sectionhash) {
  $r->print('    <option value="'.$s.'"');   $r->print('    <option value="'.$s.'"');
  foreach (@{$selectedsections}) {   foreach (@{$selectedsections}) {
Line 1371  sub groupmenu { Line 1536  sub groupmenu {
     my %grouphash = &Apache::longroup::coursegroups();      my %grouphash = &Apache::longroup::coursegroups();
     return if (!%grouphash);      return if (!%grouphash);
   
     $r->print('<select name="Group" multiple="true" size="8" >');      $r->print('<select name="Group" multiple="multiple" size="8" >');
     foreach my $group (sort(keys(%grouphash))) {      foreach my $group (sort(keys(%grouphash))) {
  $r->print('    <option value="'.$group.'"');   $r->print('    <option value="'.$group.'"');
  foreach (@{$selectedgroups}) {   foreach (@{$selectedgroups}) {
Line 1421  sub sortmenu { Line 1586  sub sortmenu {
     my ($r,$sortorder)=@_;      my ($r,$sortorder)=@_;
     $r->print('<br /><label><input type="radio" name="sortorder" value="realmstudent"');      $r->print('<br /><label><input type="radio" name="sortorder" value="realmstudent"');
     if ($sortorder eq 'realmstudent') {      if ($sortorder eq 'realmstudent') {
        $r->print(' checked="on"');         $r->print(' checked="checked"');
     }      }
     $r->print(' />'.&mt('Sort by realm first, then student (group/section)'));      $r->print(' />'.&mt('Sort by realm first, then student (group/section)'));
     $r->print('</label><br /><label><input type="radio" name="sortorder" value="studentrealm"');      $r->print('</label><br /><label><input type="radio" name="sortorder" value="studentrealm"');
     if ($sortorder eq 'studentrealm') {      if ($sortorder eq 'studentrealm') {
        $r->print(' checked="on"');         $r->print(' checked="checked"');
     }      }
     $r->print(' />'.&mt('Sort by student (group/section) first, then realm').      $r->print(' />'.&mt('Sort by student (group/section) first, then realm').
       '</label>');        '</label>');
Line 1455  sub standardkeyorder { Line 1620  sub standardkeyorder {
             'parameter_0_discusshide' => 20);              'parameter_0_discusshide' => 20);
 }  }
   
 ##################################################  
 ##################################################  
   
 =pod  
   
 =item assessparms  
   
 Show assessment data and parameters.  This is a large routine that should  
 be simplified and shortened... someday.  
   
 Inputs: $r  
   
 Returns: nothing  
   
 Variables used (guessed by Jeremy):  
   
 =over 4  
   
 =item B<pscat>: ParameterS CATegories? ends up a list of the types of parameters that exist, e.g., tol, weight, acc, opendate, duedate, answerdate, sig, maxtries, type.  
   
 =item B<psprt>: ParameterS PaRTs? a list of the parts of a problem that we are displaying? Used to display only selected parts?  
   
 =item B<allmaps>:  
   
 =back  
   
 =cut  
   
 ##################################################  
 ##################################################  
 sub assessparms {  sub assessparms {
   
     my $r=shift;      my $r=shift;
Line 1639  sub assessparms { Line 1774  sub assessparms {
         my @values=split(/\&\&\&/,$env{'form.pres_value'});          my @values=split(/\&\&\&/,$env{'form.pres_value'});
         my @types=split(/\&\&\&/,$env{'form.pres_type'});          my @types=split(/\&\&\&/,$env{'form.pres_type'});
  for (my $i=0;$i<=$#markers;$i++) {   for (my $i=0;$i<=$#markers;$i++) {
               if ($markers[$i] =~ /^[\d.]+\&0_availablestudent\&(1|2|3)$/) {
                   my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
                   my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
                   my (@ok_slots,@fail_slots,@del_slots);
                   my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom);
                   my ($level,@all) =
                       &parmval_by_symb('0.availablestudent',$pssymb,'',$uname,$udom,
                                        $csec,$cgroup,$courseopt);
                   foreach my $slot_name (split(/:/,$values[$i])) {
                       next if ($slot_name eq '');
                       if (&update_slots($slot_name,$cdom,$cnum,$pssymb,$uname,$udom) eq 'ok') {
                           push(@ok_slots,$slot_name);
   
                       } else {
                           push(@fail_slots,$slot_name);
                       }
                   }
                   if (@ok_slots) {
                       $values[$i] = join(':',@ok_slots);
                   } else {
                       $values[$i] = '';
                   }
                   if ($all[$level] ne '') {
                       my @existing = split(/:/,$all[$level]);
                       foreach my $slot_name (@existing) {
                           if (!grep(/^\Q$slot_name\E$/,split(/:/,$values[$i]))) {
                               if (&delete_slots($slot_name,$cdom,$cnum,$uname,$udom,$pssymb) eq 'ok') {
                                   push(@del_slots,$slot_name);
                               }
                           }
                       }
                   }
               }
     $message.=&storeparm(split(/\&/,$markers[$i]),      $message.=&storeparm(split(/\&/,$markers[$i]),
  $values[$i],   $values[$i],
  $types[$i],   $types[$i],
Line 1665  sub assessparms { Line 1833  sub assessparms {
     if (!$pssymb) {      if (!$pssymb) {
         $r->print('<table border="1"><tr><td>');          $r->print('<table border="1"><tr><td>');
         &levelmenu($r,\%alllevs,$parmlev);          &levelmenu($r,\%alllevs,$parmlev);
           $r->print('</td>');
  if ($parmlev ne 'general') {   if ($parmlev ne 'general') {
             $r->print('<td>');              $r->print('<td>');
     &mapmenu($r,\%allmaps,$pschp,\%maptitles);      &mapmenu($r,\%allmaps,$pschp,\%maptitles);
     $r->print('</td>');      $r->print('</td>');
  }   }
         $r->print('</td></tr></table>');          $r->print('</tr></table>');
  &displaymenu($r,\%allparms,\%allparts,\@pscat,\@psprt,\%keyorder);   &displaymenu($r,\%allparms,\%allparts,\@pscat,\@psprt,\%keyorder);
     } else {      } else {
         my ($map,$id,$resource)=&Apache::lonnet::decode_symb($pssymb);          my ($map,$id,$resource)=&Apache::lonnet::decode_symb($pssymb);
Line 1707  sub assessparms { Line 1876  sub assessparms {
               $coursespan += 3;                $coursespan += 3;
            }              } 
               
            $r->print('<p><table border=2>');             $r->print('<p><table border="2">');
            $r->print('<tr><td colspan=5></td>');             $r->print('<tr><td colspan="5"></td>');
            $r->print('<th colspan='.($coursespan).'>'.&mt('Any User').'</th>');             $r->print('<th colspan="'.($coursespan).'">'.&mt('Any User').'</th>');
            if ($uname) {             if ($uname) {
                if (@usersgroups > 1) {                 if (@usersgroups > 1) {
                    $userspan ++;                     $userspan ++;
Line 1735  sub assessparms { Line 1904  sub assessparms {
   'fr'     => 'for Resource'    'fr'     => 'for Resource'
       );        );
            $r->print(<<ENDTABLETWO);             $r->print(<<ENDTABLETWO);
 <th rowspan=3>$lt{'pie'}</th>  <th rowspan="3">$lt{'pie'}</th>
 <th rowspan=3>$lt{'csv'}<br />($csuname $lt{'at'} $csudom)</th>  <th rowspan="3">$lt{'csv'}<br />($csuname $lt{'at'} $csudom)</th>
 </tr><tr><td colspan=5></td><th colspan=2>$lt{'ic'}</th><th colspan=2>$lt{'rl'}</th>  </tr><tr><td colspan="5"></td><th colspan="2">$lt{'ic'}</th><th colspan="2">$lt{'rl'}</th>
 <th colspan=1>$lt{'ic'}</th>  <th colspan="1">$lt{'ic'}</th>
   
 ENDTABLETWO  ENDTABLETWO
            if ($csec) {             if ($csec) {
                 $r->print("<th colspan=3>".                  $r->print('<th colspan="3">'.
   &mt("in Section")." $csec</th>");    &mt("in Section")." $csec</th>");
            }             }
            if ($cgroup) {             if ($cgroup) {
                 $r->print("<th colspan=3>".                  $r->print('<th colspan="3">'.
                           &mt("in Group")." $cgroup</th>");                            &mt("in Group")." $cgroup</th>");
            }             }
            $r->print(<<ENDTABLEHEADFOUR);             $r->print(<<ENDTABLEHEADFOUR);
Line 1787  ENDTABLEHEADFOUR Line 1956  ENDTABLEHEADFOUR
     ||      ||
     ($pssymb && $pssymb eq $symbp{$rid})) {      ($pssymb && $pssymb eq $symbp{$rid})) {
 # ------------------------------------------------------ Entry for one resource  # ------------------------------------------------------ Entry for one resource
                     if ($defbgone eq '"#E0E099"') {                      if ($defbgone eq '#E0E099') {
                         $defbgone='"#E0E0DD"';                          $defbgone='#E0E0DD';
                     } else {                      } else {
                         $defbgone='"#E0E099"';                          $defbgone='#E0E099';
                     }                      }
                     if ($defbgtwo eq '"#FFFF99"') {                      if ($defbgtwo eq '#FFFF99') {
                         $defbgtwo='"#FFFFDD"';                          $defbgtwo='#FFFFDD';
                     } else {                      } else {
                         $defbgtwo='"#FFFF99"';                          $defbgtwo='#FFFF99';
                     }                      }
                     if ($defbgthree eq '"#FFBB99"') {                      if ($defbgthree eq '#FFBB99') {
                         $defbgthree='"#FFBBDD"';                          $defbgthree='#FFBBDD';
                     } else {                      } else {
                         $defbgthree='"#FFBB99"';                          $defbgthree='#FFBB99';
                     }                      }
   
                     my $thistitle='';                      my $thistitle='';
Line 1817  ENDTABLEHEADFOUR Line 1986  ENDTABLEHEADFOUR
                         if (grep $_ eq $tempkeyp, @catmarker) {                          if (grep $_ eq $tempkeyp, @catmarker) {
                           $part{$_}=&Apache::lonnet::metadata($uri,$_.'.part');                            $part{$_}=&Apache::lonnet::metadata($uri,$_.'.part');
                           $name{$_}=&Apache::lonnet::metadata($uri,$_.'.name');                            $name{$_}=&Apache::lonnet::metadata($uri,$_.'.name');
                           $display{$_}=&Apache::lonnet::metadata($uri,$_.'.display');  
                           unless ($display{$_}) { $display{$_}=''; }                            unless ($display{$_}) { $display{$_}=''; }
                             my $parmdis=&Apache::lonnet::metadata($uri,$_.'.display');
                             if ($allparms{$name{$_}} ne '') {
                                 my $identifier;
                                 if ($parmdis =~ /(\s*\[Part.*)$/) {
                                     $identifier = $1;
                                 }
                                 $display{$_} = $allparms{$name{$_}}.$identifier;
                             } else {
                                 $display{$_} = $parmdis;
                             }
                           $display{$_}.=' ('.$name{$_}.')';                            $display{$_}.=' ('.$name{$_}.')';
                           $default{$_}=&Apache::lonnet::metadata($uri,$_);                            $default{$_}=&Apache::lonnet::metadata($uri,$_);
                           $type{$_}=&Apache::lonnet::metadata($uri,$_.'.type');                            $type{$_}=&Apache::lonnet::metadata($uri,$_.'.type');
                           $thistitle=&Apache::lonnet::metadata($uri,$_.'.title');                            $thistitle=&Apache::lonnet::metadata($uri,$_.'.title');
                         }                          }
                     }                      }
                     my $totalparms=scalar keys %name;                      my $totalparms=scalar(keys(%name));
                     if ($totalparms>0) {                      if ($totalparms>0) {
                         my $firstrow=1;                          my $firstrow=1;
  my $title=&Apache::lonnet::gettitle($symbp{$rid});   my $title=&Apache::lonnet::gettitle($symbp{$rid});
                         $r->print('<tr><td bgcolor='.$defbgone.                          $r->print('<tr><td style="background-color:'.$defbgone.';"'.
                              ' rowspan='.$totalparms.                               ' rowspan="'.$totalparms.
                              '><tt><font size=-1>'.                               '"><tt><font size="-1">'.
                              join(' / ',split(/\//,$uri)).                               join(' / ',split(/\//,$uri)).
                              '</font></tt><p><b>'.                               '</font></tt><p><b>'.
                              "<a href=\"javascript:openWindow('".                               "<a href=\"javascript:openWindow('".
Line 1844  ENDTABLEHEADFOUR Line 2022  ENDTABLEHEADFOUR
                             $r->print(' ('.$thistitle.')');                              $r->print(' ('.$thistitle.')');
                         }                          }
                         $r->print('</a></b></td>');                          $r->print('</a></b></td>');
                         $r->print('<td bgcolor='.$defbgtwo.                          $r->print('<td style="background-color:'.$defbgtwo.';"'.
                                       ' rowspan='.$totalparms.'>'.$typep{$rid}.                                        ' rowspan="'.$totalparms.'">'.$typep{$rid}.
                                       '</td>');                                        '</td>');
   
                         $r->print('<td bgcolor='.$defbgone.                          $r->print('<td style="background-color:'.$defbgone.';"'.
                                       ' rowspan='.$totalparms.                                        ' rowspan="'.$totalparms.
                                       '>'.$maptitles{$mapp{$rid}}.'</td>');                                        '">'.$maptitles{$mapp{$rid}}.'</td>');
   
                         foreach (&keysinorder_bytype(\%name,\%keyorder)) {                          foreach (&keysinorder_bytype(\%name,\%keyorder)) {
                             unless ($firstrow) {                              unless ($firstrow) {
Line 1862  ENDTABLEHEADFOUR Line 2040  ENDTABLEHEADFOUR
                                        \%type,\%display,$defbgone,$defbgtwo,                                         \%type,\%display,$defbgone,$defbgtwo,
                                        $defbgthree,$parmlev,$uname,$udom,$csec,                                         $defbgthree,$parmlev,$uname,$udom,$csec,
                                                             $cgroup,\@usersgroups);                                                              $cgroup,\@usersgroups);
                               $print('</tr>'."\n");
                         }                          }
                     }                      }
                 }                  }
Line 1871  ENDTABLEHEADFOUR Line 2050  ENDTABLEHEADFOUR
         } # end of  full          } # end of  full
 #--------------------------------------------------- Entry for parm level map  #--------------------------------------------------- Entry for parm level map
         if ($parmlev eq 'map') {          if ($parmlev eq 'map') {
             my $defbgone = '"E0E099"';              my $defbgone = 'E0E099';
             my $defbgtwo = '"FFFF99"';              my $defbgtwo = 'FFFF99';
             my $defbgthree = '"FFBB99"';              my $defbgthree = 'FFBB99';
   
             my %maplist;              my %maplist;
   
Line 1924  ENDTABLEHEADFOUR Line 2103  ENDTABLEHEADFOUR
                       if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {                        if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
                         $part{$tempkeyp}="0";                          $part{$tempkeyp}="0";
                         $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');                          $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
                         $display{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');                          my $parmdis=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
                           if ($allparms{$name{$tempkeyp}} ne '') {
                               my $identifier;
                               if ($parmdis =~ /(\s*\[Part.*)$/) {
                                   $identifier = $1;
                               }
                               $display{$tempkeyp} = $allparms{$name{$tempkeyp}}.$identifier;
                           } else {
                               $display{$tempkeyp} = $parmdis;
                           }
                         unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }                          unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
                         $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';                          $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
                         $display{$tempkeyp} =~ s/_\w+_/_0_/;                          $display{$tempkeyp} =~ s/_\w+_/_0_/;
Line 1961  ENDTABLEHEADFOUR Line 2149  ENDTABLEHEADFOUR
                              ,'<font color="red"><i>'.$coursename.'</i></font>'                               ,'<font color="red"><i>'.$coursename.'</i></font>'
                              )                               )
                          ."<br /></h4>\n"                           ."<br /></h4>\n"
                          );                   );
 #---------------------------------------------------------------- print table  #---------------------------------------------------------------- print table
                 $r->print('<p><table border="2">');                  $r->print('<p>'..&Apache::loncommon::start_data_table().
                 $r->print('<tr><th>'.&mt('Parameter Name').'</th>');                            &Apache::loncommon::start_data_table_header_row().
                 $r->print('<th>'.&mt('Default Value').'</th>');                            '<tr><th>'.&mt('Parameter Name').'</th>'.
                 $r->print('<th>'.&mt('Parameter in Effect').'</th></tr>');                            '<th>'.&mt('Default Value').'</th>'.
                             '<th>'.&mt('Parameter in Effect').'</th>'.
                             &Apache::loncommon::end_data_table_header_row());
   
         foreach (&keysinorder(\%name,\%keyorder)) {          foreach (&keysinorder(\%name,\%keyorder)) {
                     $r->print('<tr>');                      $r->print(&Apache::loncommon::start_data_table_row());
                     &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,                      &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,
                            \%type,\%display,$defbgone,$defbgtwo,$defbgthree,                             \%type,\%display,$defbgone,$defbgtwo,$defbgthree,
                            $parmlev,$uname,$udom,$csec,$cgroup);                             $parmlev,$uname,$udom,$csec,$cgroup);
                       $r->print(&Apache::loncommon::end_data_table_row());
                 }                  }
                 $r->print("</table></div>");                  $r->print(&Apache::loncommon::end_data_table().'</p></div>');
             } # end each map              } # end each map
         } # end of $parmlev eq map          } # end of $parmlev eq map
 #--------------------------------- Entry for parm level general (Course level)  #--------------------------------- Entry for parm level general (Course level)
         if ($parmlev eq 'general') {          if ($parmlev eq 'general') {
             my $defbgone = '"E0E099"';              my $defbgone = 'E0E099';
             my $defbgtwo = '"FFFF99"';              my $defbgtwo = 'FFFF99';
             my $defbgthree = '"FFBB99"';              my $defbgthree = 'FFBB99';
   
 #-------------------------------------------- for each map, gather information  #-------------------------------------------- for each map, gather information
             my $mapid="0.0";              my $mapid="0.0";
Line 2012  ENDTABLEHEADFOUR Line 2203  ENDTABLEHEADFOUR
                   if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {                    if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
                     $part{$tempkeyp}="0";                      $part{$tempkeyp}="0";
                     $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');                      $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
                     $display{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');                      my $parmdis=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
                       if ($allparms{$name{$tempkeyp}} ne '') {
                           my $identifier;
                           if ($parmdis =~ /(\s*\[Part.*)$/) {
                               $identifier = $1;
                           }
                           $display{$tempkeyp} = $allparms{$name{$tempkeyp}}.$identifier;
                       } else {
                           $display{$tempkeyp} = $parmdis;
                       }
                     unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }                      unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
                     $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';                      $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
                     $display{$tempkeyp} =~ s/_\w+_/_0_/;                      $display{$tempkeyp} =~ s/_\w+_/_0_/;
Line 2025  ENDTABLEHEADFOUR Line 2225  ENDTABLEHEADFOUR
 #---------------------------------------------------- print header information  #---------------------------------------------------- print header information
     my $setdef=&mt("Set Defaults for All Resources in Course");      my $setdef=&mt("Set Defaults for All Resources in Course");
             $r->print(<<ENDMAPONE);              $r->print(<<ENDMAPONE);
 <center><h4>$setdef  <center>
   <h4>$setdef
 <font color="red"><i>$coursename</i></font><br />  <font color="red"><i>$coursename</i></font><br />
 ENDMAPONE  ENDMAPONE
             if ($uname) {              if ($uname) {
Line 2039  ENDMAPONE Line 2240  ENDMAPONE
             if ($cgroup) {$r->print(&mt("Group")."<font color=\"red\"> <i>$cgroup</i></font>\n")};              if ($cgroup) {$r->print(&mt("Group")."<font color=\"red\"> <i>$cgroup</i></font>\n")};
             $r->print("</h4>\n");              $r->print("</h4>\n");
 #---------------------------------------------------------------- print table  #---------------------------------------------------------------- print table
             $r->print('<p><table border="2">');              $r->print('<p>'.&Apache::loncommon::start_data_table().
             $r->print('<tr><th>'.&mt('Parameter Name').'</th>');                        &Apache::loncommon::start_data_table_header_row().
             $r->print('<th>'.&mt('Default Value').'</th>');                        '<th>'.&mt('Parameter Name').'</th>'.
             $r->print('<th>'.&mt('Parameter in Effect').'</th></tr>');                        '<th>'.&mt('Default Value').'</th>'.
                         '<th>'.&mt('Parameter in Effect').'</th>'.
                         &Apache::loncommon::end_data_table_header_row());
   
     foreach (&keysinorder(\%name,\%keyorder)) {      foreach (&keysinorder(\%name,\%keyorder)) {
                 $r->print('<tr>');                  $r->print(&Apache::loncommon::start_data_table_row());
                 &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,                  &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,
                        \%type,\%display,$defbgone,$defbgtwo,$defbgthree,                         \%type,\%display,$defbgone,$defbgtwo,$defbgthree,
                                    $parmlev,$uname,$udom,$csec,$cgroup);                                     $parmlev,$uname,$udom,$csec,$cgroup);
                   $r->print(&Apache::loncommon::end_data_table_row());
             }              }
             $r->print("</table></center>");              $r->print(&Apache::loncommon::end_data_table().'</p></center>');
         } # end of $parmlev eq general          } # end of $parmlev eq general
     }      }
     $r->print('</form>'.&Apache::loncommon::end_page());      $r->print('</form>'.&Apache::loncommon::end_page());
Line 2058  ENDMAPONE Line 2262  ENDMAPONE
   
   
 ##################################################  ##################################################
 ##################################################  
   
 =pod  
   
 =item crsenv  
   
 Show and set course data and parameters.  This is a large routine that should  
 be simplified and shortened... someday.  
   
 Inputs: $r  
   
 Returns: nothing  
   
 =cut  
   
 ##################################################  
 ##################################################  
 sub crsenv {  
     my $r=shift;  
     my $setoutput='';  
   
     my $breadcrumbs =   
  &Apache::lonhtmlcommon::breadcrumbs('Edit Course Environment');  
     my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};  
     my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};  
   
     my (%crsinfo,$chome);  
   
     #  
     # Go through list of changes  
     foreach (keys %env) {  
         next if ($_!~/^form\.(.+)\_setparmval$/);  
         my $name  = $1;  
         my $value = $env{'form.'.$name.'_value'};  
         if ($name eq 'newp') {  
             $name = $env{'form.newp_name'};  
         }  
         if ($name eq 'url') {  
             $value=~s/^\/res\///;  
             my $bkuptime=time;  
             my @tmp = &Apache::lonnet::get  
                 ('environment',['url'],$dom,$crs);  
             $setoutput.=&mt('Backing up previous URL').': '.  
                 &Apache::lonnet::put  
                 ('environment',  
                  {'top level map backup '.$bkuptime => $tmp[1] },  
                  $dom,$crs).  
                      '<br />';  
         }  
         #  
         # Deal with modified default spreadsheets  
         if ($name =~ /^spreadsheet_default_(classcalc|  
                                             studentcalc|  
                                             assesscalc)$/x) {  
             my $sheettype = $1;   
             if ($sheettype eq 'classcalc') {  
                 # no need to do anything since viewing the sheet will  
                 # cause it to be updated.   
             } elsif ($sheettype eq 'studentcalc') {  
                 # expire all the student spreadsheets  
                 &Apache::lonnet::expirespread('','','studentcalc');  
             } else {  
                 # expire all the assessment spreadsheets   
                 #    this includes non-default spreadsheets, but better to  
                 #    be safe than sorry.  
                 &Apache::lonnet::expirespread('','','assesscalc');  
                 # expire all the student spreadsheets  
                 &Apache::lonnet::expirespread('','','studentcalc');  
             }  
         }  
         #  
         # Deal with the enrollment dates  
         if ($name =~ /^default_enrollment_(start|end)_date$/) {  
             $value=&Apache::lonhtmlcommon::get_date_from_form($name.'_value');  
         }  
  #  
         # Deal with the emails  
         if ($name =~ /\.email$/) {  
     foreach my $specifier (split(',',$value)) {  
  my ($user,$sections_or_groups)=  
     ($specifier=~/^([^\(]+)\(([^\)]+)\)/);  
  if (!$sections_or_groups) {  
     $user = $specifier;  
  }  
  my ($name,$domain) = split(':',$user);  
  if (!defined($user) || !defined($domain)) {  
     $setoutput.= '<br /> <span class="LC_error">'.  
  &mt("Invalid email address specified, address must be of the form username:domain what was specified was ([_1])",$user).  
  '</span>';  
     undef($value);  
  } elsif (&Apache::lonnet::homeserver($user,$domain) eq 'no_host') {  
     $setoutput.= '<br /> <span class="LC_error">'.  
  &mt("Invalid email address specified, user [_1] is unknown.",$name).  
  '</span>';  
     undef($value);  
  }  
     }  
         }  
         # Get existing cloners  
         my @oldcloner = ();  
         if ($name eq 'cloners') {  
             my %clonenames=&Apache::lonnet::dump('environment',$dom,$crs,'cloners');  
             if ($clonenames{'cloners'} =~ /,/) {  
                 @oldcloner = split/,/,$clonenames{'cloners'};  
             } else {  
                 $oldcloner[0] = $clonenames{'cloners'};  
             }  
         }  
         #  
         # Let the user know we made the changes  
         if ($name && defined($value)) {  
             my %failed_cloners;  
             if ($name eq 'cloners') {  
                 $value =~ s/\s//g;  
                 $value =~ s/^,//;  
                 $value =~ s/,$//;  
                 # check requested clones are valid users.  
                 %failed_cloners = &check_cloners(\$value,\@oldcloner);  
             }  
             my $put_result = &Apache::lonnet::put('environment',  
                                                   {$name=>$value},$dom,$crs);  
             if ($put_result eq 'ok') {  
                 $setoutput.=&mt('Set').' <b>'.$name.'</b> '.&mt('to').' <b>';  
                 if ($name =~ /^default_enrollment_(start|end)_date$/) {  
                     $setoutput .= &Apache::lonlocal::locallocaltime($value);  
                 } elsif ($name eq 'categories') {  
                     $setoutput .= $env{'form.categories_display'};  
                 } else {  
                     $setoutput .= $value;  
                 }  
                 $setoutput .= '</b>.<br />';  
                 if ($name eq 'cloners') {  
                     &change_clone($value,\@oldcloner);  
                 }  
                 # Update environment and nohist_courseids.db  
                 if (($name eq 'description') || ($name eq 'cloners') ||   
                     ($name eq 'hidefromcat') || ($name eq 'categories')) {  
                     if ($chome eq '') {  
                         %crsinfo =  
                             &Apache::lonnet::courseiddump($dom,'.',1,'.','.',  
                                                  $crs,undef,undef,'.');  
                         $chome = &Apache::lonnet::homeserver($crs,$dom);  
                     }  
                 }  
                 if ($name eq 'description' && defined($value)) {  
                     &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.description' => $value});  
                     if (ref($crsinfo{$env{'request.course.id'}}) eq 'HASH') {  
                         $crsinfo{$env{'request.course.id'}}{'description'} = $value;   
                         my $putresult =  
                             &Apache::lonnet::courseidput($dom,\%crsinfo,  
                                                          $chome,'notime');  
                     }  
                 }  
                 if (($name eq 'cloners') || ($name eq 'hidefromcat') || ($name eq 'categories')) {  
                     if (ref($crsinfo{$env{'request.course.id'}}) eq 'HASH') {  
                         &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.'.$name => $value});  
                         $crsinfo{$env{'request.course.id'}}{$name} = $value;  
                         my $putresult =  
                             &Apache::lonnet::courseidput($dom,\%crsinfo,  
                                                          $chome,'notime');  
                     }  
                 }  
             } else {  
                 $setoutput.=&mt('Unable to set').' <b>'.$name.'</b> '.&mt('to').  
     ' <b>'.$value.'</b> '.&mt('due to').' '.$put_result.'.<br />';  
             }  
             if (($name eq 'cloners') && (keys(%failed_cloners) > 0)) {  
                 $setoutput.= &mt('Unable to include').': ';  
                 my @fails;  
                 my $num = 0;  
                 if (defined($failed_cloners{'format'})) {  
                     $fails[$num] .= '<b>'.$failed_cloners{'format'}.  
                                   '</b>, '.&mt('reason').' - '.  
                                   &mt('Invalid format');  
                     $num ++;  
                 }  
                 if (defined($failed_cloners{'domain'})) {  
                     $fails[$num] .= '<b>'.$failed_cloners{'domain'}.  
                                   '</b>, '.&mt('reason').' - '.  
                                   &mt('Domain does not exist');  
                     $num ++;  
                 }  
                 if (defined($failed_cloners{'newuser'})) {  
                     $fails[$num] .= '<b>'.$failed_cloners{'newuser'}.                                   '</b>, '.&mt('reason').' - '.  
                         &mt('LON-CAPA user(s) do(es) not exist.').  
                         '.<br />'.&mt('Please ').  
                         ' <a href="/adm/createuser">'.  
                         &mt('add the user(s)').'</a>, '.  
                         &mt('and then return to the ').  
                         '<a href="/adm/parmset?action=crsenv">'.  
                         &mt('Course Parameters page').'</a> '.  
                         &mt('to add the new user(s) to the list of possible cloners');  
                 }  
                 $setoutput .= join(';&nbsp;&nbsp;',@fails).'.<br />';  
             }  
         }  
     }  
   
     my $start_table     =&Apache::loncommon::start_data_table();  
     my $start_header_row=&Apache::loncommon::start_data_table_header_row();  
     my $end_header_row  =&Apache::loncommon::end_data_table_header_row();  
 # ------------------------- Re-init course environment entries for this session  
   
     &Apache::lonnet::coursedescription($env{'request.course.id'},  
        {'freshen_cache' => 1});  
   
 # -------------------------------------------------------- Get parameters again  
   
     my %values=&Apache::lonnet::dump('environment',$dom,$crs);  
     my $SelectStyleFile=&mt('Select Style File');  
     my $SelectSpreadsheetFile=&mt('Select Spreadsheet File');  
     my $output='';  
     my $can_categorize;  
     if (! exists($values{'con_lost'})) {  
         my %descriptions=  
     ('url'            => '<b>'.&mt('Top Level Map').'</b><br />'.  
                                  '<a href="javascript:openbrowser'.  
                                  "('envform','url','sequence')\">".  
                                  &mt('Select Map').'</a><br /><span class="LC_warning"> '.  
                                  &mt('Modification may make assessment data inaccessible!').  
                                  '</span>',  
              'description'    => '<b>'.&mt('Course Description').'</b>',  
              'courseid'       => '<b>'.&mt('Course ID or number').  
                                  '</b><br />'.  
                                  '('.&mt('internal, optional').')',  
              'cloners'        => '<b>'.&mt('Users allowed to clone course').'</b><br />'  
                                 .'("<tt>'.&mt('user:domain,user:domain,*:domain').'</tt>")<br />'  
                                 .&mt('Users with active Course Coordinator role in this course are permitted to clone and need not be included.').'<br />'  
                                 .&mt('Use [_1] to allow course to be cloned by anyone in the specified domain.','"<tt>*:domain</tt>"').'<br />'  
                                 .&mt('Use [_1] to allow unrestricted cloning in all domains.','"<tt>*</tt>"'),  
              'grading'        => '<b>'.&mt('Grading').'</b><br />'.  
                                  &mt('[_1], [_2], or [_3]','"<tt>standard</tt>"','"<tt>external</tt>"','"<tt>spreadsheet</tt>"').&Apache::loncommon::help_open_topic('GradingOptions'),  
      'task_grading'   => '<b>'.&mt('Bridge Task Grading').'</b><br />'  
                                 .&mt('Instructors and TAs in sections, when grading bridge tasks, should be allowed to grade other sections.').'<br />'  
                                 .'('.&mt('[_1]: they are allowed (this is the default). [_2]: no, they can only grade their own section.','"<tt>any</tt>"','"<tt>section</tt>"').')',  
              'default_xml_style' => '<b>'.&mt('Default XML Style File').'</b><br />'.  
                     '<a href="javascript:openbrowser'.  
                     "('envform','default_xml_style'".  
                     ",'sty')\">$SelectStyleFile</a><br />",  
              'question.email' => '<b>'.&mt('Feedback Addresses for Resource Content Question').'</b><br />'  
                                 .'("<tt>'.&mt('user:domain,user:domain(section;section;...;*;...),...').'</tt>")',  
              'question.email.text' => '<b>'.&mt('Custom Text for Resource Content Question Option in Feedback').'</b>',  
              'comment.email'  => '<b>'.&mt('Feedback Addresses for Course Content Comments').'</b><br />'  
                                 .'("<tt>'.&mt('user:domain,user:domain(section;section;...;*;...),...').'</tt>")',  
              'comment.email.text' => '<b>'.&mt('Custom Text for Course Content Option in Feedback').'</b>',  
              'policy.email'   => '<b>'.&mt('Feedback Addresses for Course Policy').'</b><br />'  
                                  .'("<tt>'.&mt('user:domain,user:domain(section;section;...;*;...),...').'</tt>")',  
              'policy.email.text' => '<b>'.&mt('Custom Text for Course Policy Option in Feedback').'</b>',  
              'hideemptyrows'  => '<b>'.&mt('Hide Empty Rows in Spreadsheets').'</b><br />'  
                                 .'('.&mt('[_1] for default hiding','"<tt>yes</tt>"').')',  
              'pageseparators'  => '<b>'.&mt('Visibly Separate Items on Pages').'</b><br />'  
                                  .'('.&mt('[_1] for visible separation.','"<tt>yes</tt>"').' '  
                                  .&mt('Changes will not show until next login.').')',  
              'student_classlist_view' => '<b>'.&mt('Allow students to view classlist.').'</b><br />'  
                                         .'('.&mt('[_1]: students can view all sections. [_2]: students can only view their own section. blank or [_3] prevents student view.','"<tt>all</tt>"','"<tt>section</tt>"','"<tt>disabled</tt>"').')',  
              'student_classlist_portfiles' => '<b>'.&mt('Include link to accessible portfolio files').'</b><br />'  
                                              .'('.&mt('[_1] for link to each a listing of each student\'s files.','"<tt>yes</tt>"').')',  
              'student_classlist_opt_in' => '<b>'.&mt("Student's agreement needed for listing in student-viewable roster").'</b><br />'  
                                            .'('.&mt('[_1] to require students to opt-in to listing in the roster (on the roster page).','"<tt>yes</tt>"').')',  
              'plc.roles.denied'=> '<b>'.&mt('Disallow live chatroom use for Roles').'</b><br />'  
                                  .'('.&mt('[_1]: student, [_2]: TA, [_3]: instructor','"<tt>st</tt>"','"<tt>ta</tt>"','"<tt>in</tt>"').')<br />'  
                                  .'("<tt>'.&mt('role,role,...').'</tt>") '  
                          .Apache::loncommon::help_open_topic("Course_Disable_Discussion"),  
              'plc.users.denied' =>   
                           '<b>'.&mt('Disallow live chatroom use for Users').'</b><br />'.  
                                   '("<tt>'.&mt('user:domain,user:domain,...').'</tt>")',  
   
              'pch.roles.denied'=> '<b>'.&mt('Disallow Resource Discussion for Roles').'</b><br />'  
                                  .'('.&mt('[_1]: student, [_2]: TA, [_3]: instructor','"<tt>st</tt>"','"<tt>ta</tt>"','"<tt>in</tt>"')  
                                  .'("<tt>'.&mt('role,role,...').'</tt>") '  
                                  .Apache::loncommon::help_open_topic("Course_Disable_Discussion"),  
              'pch.users.denied' =>   
                           '<b>'.&mt('Disallow Resource Discussion for Users').'</b><br />'.  
                                  '("<tt>'.&mt('user:domain,user:domain,...').'</tt>")',  
              'spreadsheet_default_classcalc'   
                  => '<b>'.&mt('Default Course Spreadsheet').'</b> '.  
                     '<a href="javascript:openbrowser'.  
                     "('envform','spreadsheet_default_classcalc'".  
                     ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",  
              'spreadsheet_default_studentcalc'   
                  => '<b>'.&mt('Default Student Spreadsheet').'</b><br />'.  
                     '<a href="javascript:openbrowser'.  
                     "('envform','spreadsheet_default_calc'".  
                     ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",  
              'spreadsheet_default_assesscalc'   
                  => '<b>'.&mt('Default Assessment Spreadsheet').'</b> '.  
                     '<a href="javascript:openbrowser'.  
                     "('envform','spreadsheet_default_assesscalc'".  
                     ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",  
      'allow_limited_html_in_feedback'  
          => '<b>'.&mt('Allow limited HTML in discussion posts').'</b><br />'.  
             '('.&mt('Set value to [_1] to allow.','"<tt>yes</tt>"').')',  
              'allow_discussion_post_editing'  
                  => '<b>'.&mt('Allow users with specified roles to edit/delete their own discussion posts').'</b><br />'  
                    .'('.&mt('[_1]: student, [_2]: TA, [_3]: instructor','"<tt>st</tt>"','"<tt>ta</tt>"','"<tt>in</tt>"').')<br />'  
                    .'('.&mt('Set value to [_1] to allow all roles.','"<tt>yes</tt>"').')'  
                    .'("<tt>'.&mt('role:section,role:section,...').'</tt>")<br />'  
                    .'('.&mt('Example: "<tt>st:001,st:002,in,cc</tt>" would permit students in sections 001 and 002 and instructors in any section, and course coordinators to edit their own posts.').')',  
      'rndseed'  
          => '<b>'.&mt('Randomization algorithm used').'</b><br />'  
                    .'<span class="LC_error">'  
                    .&mt('Modifying this will make problems have different numbers and answers!')  
                    .'</span>',  
      'receiptalg'  
          => '<b>'.&mt('Receipt algorithm used').'</b> <br />'.  
                     &mt('This controls how receipt numbers are generated.'),  
              'suppress_tries'  
                  => '<b>'.&mt('Suppress number of tries in printing').'</b><br />'.  
                     ' ('.&mt('[_1] to suppress, anything else to not suppress','"<tt>yes</tt>"').')',  
              'problem_stream_switch'  
                  => '<b>'.&mt('Allow problems to be split over pages').'</b><br />'.  
                     ' ('.&mt('[_1] if allowed, anything else if not','"<tt>yes</tt>"').')',  
              'default_paper_size'   
                  => '<b>'.&mt('Default paper type').'</b><br />'.  
                     ' ('.&mt('supported types').': Letter [8 1/2x11 in], Legal [8 1/2x14 in],'.   
                     ' Tabloid [11x17 in], Executive [7 1/2x10 in], A2 [420x594 mm],'.   
                     ' A3 [297x420 mm], A4 [210x297 mm], A5 [148x210 mm], A6 [105x148 mm])',  
      'print_header_format'  
          => ' <b>'.&mt('Print header format').'</b><br />'  
                    .&mt('Substitutions:<br />[_1]: student name, [_2]: course id, [_3]: assignment note. Numbers after the <tt>%</tt> limit the field size.','"<tt>%n</tt>"','"<tt>%c</tt>"','"<tt>%a</tt>"'),  
              'default_enrollment_start_date' => '<b>'.&mt('Default beginning date for student access.').'</b>',  
              'default_enrollment_end_date'   => '<b>'.&mt('Default ending date for student access.').'</b>',  
              'nothideprivileged'   => '<b>'.&mt('Privileged users that should not be hidden on staff listings').'</b><br />'  
                                      .'("<tt>'.&mt('user:domain,user:domain,*:domain').'</tt>")',  
              'languages' => '<b>'.&mt('Languages used').'</b>',  
              'disable_receipt_display'  
                  => '<b>'.&mt('Disable display of problem receipts').'</b><br />'.  
                     ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',  
      'task_messages'  
          => '<b>'.&mt('Send message to student when clicking Done on Tasks').'</b><br /> ('.&mt('[_1] to send a message only to student, [_2] to send message to student and add record to user information page for instructors. Leave blank to disable.','"<tt>only_student</tt>"','"<tt>student_and_user_notes_screen</tt>"').')',  
      'disablesigfigs'  
          => '<b>'.&mt('Disable checking of Significant Figures').'</b><br />'.  
                     ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',  
      'disableexampointprint'  
          => '<b>'.&mt('Disable automatically printing point values onto exams.').'</b><br />'.  
                     ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',  
              'externalsyllabus'  
                  => '<b>'.&mt('URL of Syllabus (not using internal handler)').'</b>',  
      'tthoptions'  
          => '<b>'.&mt('Default set of options to pass to tth/m when converting tex').'</b>',  
   
      'texengine'  
          => '<b>'.&mt('Force all students in the course to use a specific math rendering engine.').'</b><br />'  
                    .'('.&mt('[_1], [_2] (Convert to Images), [_3] (TeX to HTML), or blank for student\'s preference','"<tt>jsMath</tt>"','"<tt>mimetex</tt>"','"<tt>tth</tt>"').')',  
              'timezone'  
                  => '<b>'.&mt('Timezone in which the course takes place').'</b>',  
   
              'suppress_embed_prompt'  
                  => '<b>'.&mt('Suppress prompt to upload items referenced in a web page being uploaded to portfolio, when current role is student.').'</b><br />'.  
                     ' ('.&mt('[_1] to suppress, anything else to not suppress','"<tt>yes</tt>"').')',  
              'hidefromcat'  
                  => '<b>'.&mt('Exclude from course catalog').'</b><br />'.  
                     ' ('.&mt('[_1] to exclude, anything else to include - included if assigned an institutional code, or manually catagorized','"<tt>yes</tt>"').')',  
              'categories'  
                  => '<b>'.&mt('Categorize course').'</b> <a href="javascript:catsbrowser()">'.  
                     &mt('Display Categories').'</a>',  
              'datelocale'   
                  => '<b>'.&mt('Locale used for course calendar').'</b>',  
              );  
         my @Display_Order = ('url','description','courseid','cloners');  
         (my $can_toggle_cat,$can_categorize) = &can_modify_catsettings($dom);  
         if ($can_toggle_cat) {  
             push(@Display_Order,'hidefromcat');  
         }  
         if ($can_categorize) {  
             push(@Display_Order,'categories');  
         }  
         push (@Display_Order,('grading',  
                              'externalsyllabus',  
                              'default_xml_style','pageseparators',  
                              'question.email','question.email.text','comment.email',  
                              'comment.email.text','policy.email','policy.email.text',  
                              'student_classlist_view',  
                              'student_classlist_opt_in',  
                              'student_classlist_portfiles',  
                              'plc.roles.denied','plc.users.denied',  
                              'pch.roles.denied','pch.users.denied',  
                              'allow_limited_html_in_feedback',  
                              'allow_discussion_post_editing',  
                              'languages',  
                              'timezone',  
                              'datelocale',  
      'nothideprivileged',  
                              'rndseed',  
                              'receiptalg',  
                              'problem_stream_switch',  
      'suppress_tries',  
                              'suppress_embed_prompt',  
                              'default_paper_size',  
      'print_header_format',  
                              'disable_receipt_display',  
                              'spreadsheet_default_classcalc',  
                              'spreadsheet_default_studentcalc',  
                              'spreadsheet_default_assesscalc',   
                              'hideemptyrows',  
                              'default_enrollment_start_date',  
                              'default_enrollment_end_date',  
      'tthoptions',  
      'texengine',  
      'disablesigfigs',  
      'disableexampointprint',  
      'task_messages','task_grading'));  
  foreach my $parameter (sort(keys(%values))) {  
             unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./) ||  
                     ($parameter =~ m/^selfenroll_/) || ($parameter =~ /_selfenroll$/)  
                     || ($parameter eq 'type')) {  
                 if (! $descriptions{$parameter}) {  
                     $descriptions{$parameter}=$parameter;  
                     push(@Display_Order,$parameter);  
                 }  
             }  
  }  
   
         foreach my $parameter (@Display_Order) {  
             my $description = $descriptions{$parameter};  
             # onchange is javascript to automatically check the 'Set' button.  
             my $onchange = 'onFocus="javascript:window.document.forms'.  
                 "['envform'].elements['".$parameter."_setparmval']".  
                 '.checked=true;"';  
             $output .= &Apache::loncommon::start_data_table_row().  
  '<td>'.$description.'</td>';  
             if ($parameter =~ /^default_enrollment_(start|end)_date$/) {  
                 $output .= '<td>'.  
                     &Apache::lonhtmlcommon::date_setter('envform',  
                                                         $parameter.'_value',  
                                                         $values{$parameter},  
                                                         $onchange).  
                                                         '</td>';  
             } elsif ($parameter eq 'timezone') {  
                 my $includeempty = 1;  
                 my $timezone = &Apache::lonlocal::gettimezone();  
                 $output .= '<td>'.  
                     &Apache::loncommon::select_timezone($parameter.'_value',  
                                                         $timezone,  
                                                         $onchange,$includeempty).'</td>';  
             } elsif ($parameter eq 'datelocale') {  
                 my $includeempty = 1;  
                 my $locale_obj = &Apache::lonlocal::getdatelocale();  
                 my $currdatelocale;  
                 if (ref($locale_obj)) {  
                     $currdatelocale = $locale_obj->id();  
                 }  
                 $output .= '<td>'.  
                     &Apache::loncommon::select_datelocale($parameter.'_value',  
                                                           $currdatelocale,  
                                                           $onchange,$includeempty).'</td>';   
             } elsif ($parameter eq 'categories') {  
                 my $catdisplay;  
                 if ($values{'categories'} ne '') {  
                     my @curritems = split(/\&/,$values{'categories'});  
                     foreach my $item (@curritems) {  
                         my ($name,$parent,$pos) = split(/:/,$item);  
                         $catdisplay .= &unescape($name).'&';  
                     }  
                     $catdisplay =~ s/\&$//;  
                 }   
                 $output .= '<td>'.  
                            '<input type="hidden" name="categories_value" value="'.  
                            $values{'categories'}.'" />'.  
                            '<input type="textbox" name="categories_display" value="'.  
                            $catdisplay.'" readonly="readonly" size="40" /></td>';  
             } else {  
                 $output .= '<td>'.  
                     &Apache::lonhtmlcommon::textbox($parameter.'_value',  
                                                     $values{$parameter},  
                                                     40,$onchange).'</td>';  
             }  
             $output .= '<td>'.  
                 &Apache::lonhtmlcommon::checkbox($parameter.'_setparmval').  
                 '</td>';  
             $output .= &Apache::loncommon::end_data_table_row()."\n";  
  }  
         my $onchange = 'onFocus="javascript:window.document.forms'.  
             '[\'envform\'].elements[\'newp_setparmval\']'.  
             '.checked=true;"';  
  $output.=&Apache::loncommon::start_data_table_row().  
     '<td><i>'.&mt('Create New Environment Variable').'</i><br />'.  
     '<input type="text" size=40 name="newp_name" '.  
                 $onchange.' /></td><td>'.  
             '<input type="text" size=40 name="newp_value" '.  
                 $onchange.' /></td><td>'.  
     '<input type="checkbox" name="newp_setparmval" /></td>'.  
     &Apache::loncommon::end_data_table_row()."\n";  
     }  
     my %lt=&Apache::lonlocal::texthash(  
     'par'   => 'Parameter',  
     'val'   => 'Value',  
     'set'   => 'Set?',  
     'sav'   => 'Save'  
        );  
   
     my $Parameter=&mt('Parameter');  
     my $Value=&mt('Value');  
     my $Set=&mt('Set');  
     my ($jscript,$categorize_js);  
     my $browse_js = &Apache::loncommon::browser_and_searcher_javascript('parmset');  
     if ($can_categorize) {  
         $categorize_js = <<ENDSCRIPT;  
 function catsbrowser() {  
     var catswin = null;  
     var url = '/adm/parmset?action=categorizecourse';  
     if (!catswin || catswin.closed) {  
         catswin=window.open(url,'categorieswin','height=480,width=600,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');  
     } else {  
         catswin.focus();  
     }  
 }   
 ENDSCRIPT  
     }  
     $jscript = '<script type="text/javascript" language="Javascript">'."\n".  
                $browse_js."\n".$categorize_js."\n".'</script>';  
     my $start_page =   
  &Apache::loncommon::start_page('Set Course Environment',  
        $jscript);  
     my $end_page =   
  &Apache::loncommon::end_page();  
     my $end_table=&Apache::loncommon::end_data_table();  
     $r->print(<<ENDENV);  
 $start_page  
 $breadcrumbs  
 <form method="post" action="/adm/parmset?action=crsenv" name="envform">  
 $setoutput  
 <div><input type="submit" name="crsenv" value="$lt{'sav'}" /></div>  
 $start_table  
 $start_header_row  
 <th>$lt{'par'}</th><th>$lt{'val'}</th><th>$lt{'set'}</th>  
 $end_header_row  
 $output  
 $end_table  
 <input type="submit" name="crsenv" value="$lt{'sav'}" />  
 </form>  
 $end_page  
 ENDENV  
 }  
   
 sub can_modify_catsettings {  
     my ($dom) = @_;  
     my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);  
     my ($can_toggle_cat,$can_categorize);  
     if (ref($domconf{'coursecategories'}) eq 'HASH') {  
         if ($domconf{'coursecategories'}{'togglecats'} eq 'crs') {  
             $can_toggle_cat = 1;  
         }  
         if ($domconf{'coursecategories'}{'categorize'} eq 'crs') {  
             $can_categorize = 1;  
         }  
     }  
     return ($can_toggle_cat,$can_categorize);  
 }  
   
 sub assign_course_categories {  
     my ($r) = @_;  
     my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};  
     my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};  
     my $hascats = 0;  
     my $cathash;  
     my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);  
     if (ref($domconf{'coursecategories'}) eq 'HASH') {  
         $cathash = $domconf{'coursecategories'}{'cats'};  
         if (ref($cathash) eq 'HASH') {  
             $hascats = 1;     
         }  
     }  
     my $catwin_js;  
     if ($hascats) {  
         my $alert = &mt('Use \"Save\" in the main window to save course categories');  
         $catwin_js = <<ENDSCRIPT;  
 <script type="text/javascript">  
   
 function updateCategories() {  
     var newcategories = '';  
     var unescapedcats = '';  
     if (document.chgcats.usecategory.length) {  
         for (var i=0; i<document.chgcats.usecategory.length; i++) {  
             if (document.chgcats.usecategory[i].checked == true) {  
                 newcategories = newcategories + document.chgcats.usecategory[i].value + '&';  
                 unescapedcats = unescapedcats + document.chgcats.catname[i].value + ' & ';  
             }  
         }  
         if (newcategories.length > 0) {  
             newcategories = newcategories.slice(0,-1);  
         }  
         if (unescapedcats.length > 0) {  
             unescapedcats = unescapedcats.slice(0,-3);  
         }  
     } else {  
          if (document.chgcats.usecategory.checked == true) {  
              newcategories = document.chgcats.usecategory.value;  
              unescapedcats = document.chgcats.catname.value;  
          }  
     }  
     opener.document.envform.categories_value.value = newcategories;  
     opener.document.envform.categories_display.value = unescapedcats;  
     opener.document.envform.categories_setparmval.checked = true;  
     alert("$alert");  
     self.close();  
     return;  
 }  
   
 </script>  
 ENDSCRIPT  
     } else {  
         my $onload;   
     }  
     my $start_page =  
         &Apache::loncommon::start_page('Course Categories',$catwin_js,  
                                        {'only_body'      => 1,});  
     my $end_page = &Apache::loncommon::end_page();  
     my $categoriesform = '<h3>'.&mt('Categorize Course').'</h3>';  
     if ($hascats) {  
         my %currsettings =  
             &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);  
         $categoriesform .= &mt('Assign one or more categories to this course.').'<br /><br />'.  
                                '<form name="chgcats" action="/adm/parmset" method="post">'."\n"  
                                .&Apache::loncommon::assign_categories_table($cathash,  
                                                        $currsettings{'categories'})."\n"  
                                .'<br /><input type="button" name="changes" value="'  
                                .&mt('Copy to main window').'" '  
                                .'onclick="javascript:updateCategories()" /></form><br />';  
     } else {  
         $categoriesform .= &mt('No categories defined for this domain');  
     }  
     $r->print($start_page.$categoriesform.$end_page);  
     return;  
 }  
   
 ##################################################  
 # Overview mode  # Overview mode
 ##################################################  ##################################################
 my $tableopen;  my $tableopen;
Line 2957  sub listdata { Line 2534  sub listdata {
     }      }
     if ($part ne $oldpart) {      if ($part ne $oldpart) {
  $r->print(&tableend().   $r->print(&tableend().
   "\n<span class=\"LC_parm_part\">".&mt('Part').": $part</span>");    "\n".'<span class="LC_parm_part">'.&mt('Part').": $part</span>");
  $oldpart=$part;   $oldpart=$part;
     }      }
 #  #
Line 2992  sub listdata { Line 2569  sub listdata {
  $r->print(&default_selector($thiskey,$$resourcedata{$thiskey}));   $r->print(&default_selector($thiskey,$$resourcedata{$thiskey}));
     }      }
     $r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'.      $r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'.
       $thistype.'">');        $thistype.'" />');
     $r->print('</td>'.&Apache::loncommon::end_data_table_row());      $r->print('</td>'.&Apache::loncommon::end_data_table_row());
  }   }
     }      }
Line 3300  ENDOVER Line 2877  ENDOVER
     my $foundkeys=&listdata($r,$resourcedata,$resourcedata,$sortorder);      my $foundkeys=&listdata($r,$resourcedata,$resourcedata,$sortorder);
   
     $r->print(&tableend().'<p>'.      $r->print(&tableend().'<p>'.
  ($foundkeys?'<input type="submit" value="'.&mt('Modify Parameters').'" />':&mt('There are no parameters.')).'</p></form>'.   ($foundkeys?'<input type="submit" value="'.&mt('Save').'" />':&mt('There are no parameters.')).'</p></form>'.
       &Apache::loncommon::end_page());        &Apache::loncommon::end_page());
 }  }
   
Line 3329  ENDOVER Line 2906  ENDOVER
     $r->print('<h3>'.      $r->print('<h3>'.
       &mt('These parameters refer to resources that do not exist.').        &mt('These parameters refer to resources that do not exist.').
       '</h3>'.        '</h3>'.
       '<input type="submit" value="'.&mt('Delete Checked Parameters').'" />'.'<br />'.        '<input type="submit" value="'.&mt('Delete Selected').'" />'.'<br />'.
       '<br />');        '<br />');
     $r->print(&Apache::loncommon::start_data_table().      $r->print(&Apache::loncommon::start_data_table().
       '<tr>'.        '<tr>'.
Line 3382  ENDOVER Line 2959  ENDOVER
  }   }
     }      }
     $r->print(&Apache::loncommon::end_data_table().'<p>'.      $r->print(&Apache::loncommon::end_data_table().'<p>'.
       '<input type="submit" value="'.&mt('Delete Checked Parameters').'" />'.        '<input type="submit" value="'.&mt('Delete Selected').'" />'.
       '</p></form>'.        '</p></form>'.
       &Apache::loncommon::end_page());        &Apache::loncommon::end_page());
 }  }
Line 3471  sub parse_key { Line 3048  sub parse_key {
     return %data;      return %data;
 }  }
   
 ##################################################  
 ##################################################  
   
 =pod  
   
 =item check_cloners  
   
 Checks if new users included in list of allowed cloners  
 are valid users.  Replaces supplied list with   
 cleaned list containing only users with valid usernames  
 and domains.  
   
 Inputs: $clonelist, $oldcloner   
 where $clonelist is ref to array of requested cloners,  
 and $oldcloner is ref to array of currently allowed  
 cloners.  
   
 Returns: string - comma separated list of requested  
 cloners (username:domain) who do not exist in system.  
   
 =item change_clone  
   
 Modifies the list of courses a user can clone (stored  
 in the user's environment.db file), called when a  
 change is made to the list of users allowed to clone  
 a course.  
   
 Inputs: $action,$cloner  
 where $action is add or drop, and $cloner is identity of   
 user for whom cloning ability is to be changed in course.   
   
 =cut  
   
 ##################################################  
 ##################################################  
   
 sub extract_cloners {  sub extract_cloners {
     my ($clonelist,$allowclone) = @_;      my ($clonelist,$allowclone) = @_;
     if ($clonelist =~ /,/) {      if ($clonelist =~ /,/) {
Line 3622  sub change_clone { Line 3163  sub change_clone {
 }  }
   
   
 ##################################################  
 ##################################################  
   
 =pod  
   
 =item * header  
   
 Output html header for page  
   
 =cut  
   
 ##################################################  
 ##################################################  
 sub header {  sub header {
     return &Apache::loncommon::start_page('Parameter Manager');      return &Apache::loncommon::start_page('Parameter Manager');
 }  }
 ##################################################  
 ##################################################  
 sub print_main_menu {  sub print_main_menu {
     my ($r,$parm_permission)=@_;      my ($r,$parm_permission)=@_;
     #      #
Line 3656  ENDMAINFORMHEAD Line 3183  ENDMAINFORMHEAD
     my @menu =      my @menu =
         ( { divider=>'Settings for Your Course',          ( { divider=>'Settings for Your Course',
   },    },
           { text => 'Set Course Environment',            { text => 'Edit course configuration',
     action => 'crsenv',      url => '/adm/courseprefs?origin=params',
             permission => $parm_permission,              permission => $parm_permission,
             help => 'Course_Environment',              help => 'Course_Environment',
             },              },
Line 3744  sub output_row { Line 3271  sub output_row {
     }      }
     if (!($options =~ /deleted/)) {      if (!($options =~ /deleted/)) {
         my @options= ( ['active', 'Show to student'],          my @options= ( ['active', 'Show to student'],
                     ['stuadd', 'Provide text area for students to type catalog information'],                      ['stuadd', 'Provide text area for students to type metadata'],
                     ['choices','Provide choices for students to select from']);                      ['choices','Provide choices for students to select from']);
 #   ['onlyone','Student may select only one choice']);  #   ['onlyone','Student may select only one choice']);
         if ($added_flag) {          if ($added_flag) {
Line 3769  sub output_row { Line 3296  sub output_row {
         my $single_checked;          my $single_checked;
         if ($options =~ m/onlyone/) {          if ($options =~ m/onlyone/) {
             $multiple_checked = "";              $multiple_checked = "";
             $single_checked = " CHECKED ";              $single_checked = ' checked="checked"';
         } else {          } else {
             $multiple_checked = " CHECKED ";              $multiple_checked = ' checked="checked"';
             $single_checked = "";              $single_checked = "";
         }          }
  $output .= &Apache::loncommon::continue_data_table_row();   $output .= &Apache::loncommon::continue_data_table_row();
  $output .= '<td>'.('&nbsp;' x 10).'<span class="LC_metadata">   $output .= '<td>'.('&nbsp;' x 10).'<span class="LC_metadata">
             <input type="radio" name="'.$field_name.'_onlyone" value="multiple" '.$multiple_checked .'/>              <input type="radio" name="'.$field_name.'_onlyone" value="multiple"'.$multiple_checked.' />'.
             Student may select multiple choices from list</span></td>';              &mt('Student may select multiple choices from list').'</span></td>';
  $output .= &Apache::loncommon::end_data_table_row();   $output .= &Apache::loncommon::end_data_table_row();
  $output .= &Apache::loncommon::continue_data_table_row();   $output .= &Apache::loncommon::continue_data_table_row();
  $output .= '<td>'.('&nbsp;' x 10).'<span class="LC_metadata">   $output .= '<td>'.('&nbsp;' x 10).'<span class="LC_metadata">
             <input type="radio" name="'.$field_name.'_onlyone"  value="single" '.$single_checked.'/>              <input type="radio" name="'.$field_name.'_onlyone"  value="single"'.$single_checked.' />'.
             Student may select only one choice from list</span></td>';              &mt('Student may select only one choice from list').'</span></td>';
  $output .= &Apache::loncommon::end_data_table_row();   $output .= &Apache::loncommon::end_data_table_row();
     }      }
     return ($output);      return ($output);
Line 4173  ENDINPUTDATE Line 3700  ENDINPUTDATE
  } elsif ($defkeytype{$tempkey} eq 'string_yesno') {   } elsif ($defkeytype{$tempkey} eq 'string_yesno') {
             my $yeschecked='';              my $yeschecked='';
             my $nochecked='';              my $nochecked='';
             if (&rulescache($tempkey.'_value') eq 'yes') { $yeschecked='checked="checked"'; }              if (&rulescache($tempkey.'_value') eq 'yes') { $yeschecked=' checked="checked"'; }
             if (&rulescache($tempkey.'_value') eq 'no') { $nochecked='checked="checked"'; }              if (&rulescache($tempkey.'_value') eq 'no') { $nochecked=' checked="checked"'; }
   
     $r->print(<<ENDYESNO);      $r->print(<<ENDYESNO);
 <label><input type="radio" name="$tempkey\_value" value="yes" $yeschecked /> $lt{'yes'}</label><br />  <label><input type="radio" name="$tempkey\_value" value="yes"$yeschecked /> $lt{'yes'}</label><br />
 <label><input type="radio" name="$tempkey\_value" value="no" $nochecked /> $lt{'no'}</label>  <label><input type="radio" name="$tempkey\_value" value="no"$nochecked /> $lt{'no'}</label>
 ENDYESNO  ENDYESNO
         } else {          } else {
     $r->print('<input type="text" size="20" name="'.$tempkey.'_value" value="'.&rulescache($tempkey.'_value').'" />');      $r->print('<input type="text" size="20" name="'.$tempkey.'_value" value="'.&rulescache($tempkey.'_value').'" />');
Line 4186  ENDYESNO Line 3713  ENDYESNO
         $r->print('</td>'.&Apache::loncommon::end_data_table_row());          $r->print('</td>'.&Apache::loncommon::end_data_table_row());
     }      }
     $r->print(&Apache::loncommon::end_data_table().      $r->print(&Apache::loncommon::end_data_table().
       "\n<input type='submit' name='storerules' value='".        "\n".'<input type="submit" name="storerules" value='".
       &mt('Save Rules')."' /></form>\n".        &mt('Save')."' /></form>'."\n".
       &Apache::loncommon::end_page());        &Apache::loncommon::end_page());
     return;      return;
 }  }
Line 4422  sub parm_change_log { Line 3949  sub parm_change_log {
     $r->print(&Apache::loncommon::end_page());      $r->print(&Apache::loncommon::end_page());
 }  }
   
   sub update_slots {
       my ($slot_name,$cdom,$cnum,$symb,$uname,$udom) = @_;
       my %slot=&Apache::lonnet::get_slot($slot_name);
       if (!keys(%slot)) {
           return 'error: slot does not exist';
       }
       my $max=$slot{'maxspace'};
       if (!defined($max)) { $max=99999; }
   
       my %consumed=&Apache::lonnet::dump('slot_reservations',$cdom,$cnum,
                                          "^$slot_name\0");
       my ($tmp)=%consumed;
       if ($tmp=~/^error: 2 / ) {
           return 'error: unable to determine current slot status';
       }
       my $last=0;
       foreach my $key (keys(%consumed)) {
           my $num=(split('\0',$key))[1];
           if ($num > $last) { $last=$num; }
           if ($consumed{$key}->{'name'} eq $uname.':'.$udom) {
               return 'ok';
           }
       }
   
       if (scalar(keys(%consumed)) >= $max) {
           return 'error: no space left in slot';
       }
       my $wanted=$last+1;
   
       my %reservation=('name'      => $uname.':'.$udom,
                        'timestamp' => time,
                        'symb'      => $symb);
   
       my $success=&Apache::lonnet::newput('slot_reservations',
                                           {"$slot_name\0$wanted" =>
                                                \%reservation},
                                           $cdom, $cnum);
       if ($success eq 'ok') {
           my %storehash = (
                             symb    => $symb,
                             slot    => $slot_name,
                             action  => 'reserve',
                             context => 'parameter',
                           );
           &Apache::lonnet::instructor_log('slotreservationslog',\%storehash,
                                           '',$uname,$udom,$cnum,$cdom);
   
           &Apache::lonnet::instructor_log($cdom.'_'.$cnum.'_slotlog',\%storehash,
                                           '',$uname,$udom,$uname,$udom);
       }
       return $success;
   }
   
   sub delete_slots {
       my ($slot_name,$cdom,$cnum,$uname,$udom,$symb) = @_;
       my $delresult;
       my %consumed = &Apache::lonnet::dump('slot_reservations',$cdom,
                                            $cnum, "^$slot_name\0");
       if (&Apache::lonnet::error(%consumed)) {
           return 'error: unable to determine current slot status';
       }
       my ($tmp)=%consumed;
       if ($tmp=~/^error: 2 /) {
           return 'error: unable to determine current slot status';
       }
       foreach my $key (keys(%consumed)) {
           if ($consumed{$key}->{'name'} eq $uname.':'.$udom) {
               my $num=(split('\0',$key))[1];
               my $entry = $slot_name.'\0'.$num;
               $delresult = &Apache::lonnet::del('slot_reservations',[$entry],
                                                 $cdom,$cnum);
               if ($delresult eq 'ok') {
                   my %storehash = (
                                     symb    => $symb,
                                     slot    => $slot_name,
                                     action  => 'release',
                                     context => 'parameter',
                                   );
                   &Apache::lonnet::instructor_log('slotreservationslog',\%storehash,
                                                   1,$uname,$udom,$cnum,$cdom);
                   &Apache::lonnet::instructor_log($cdom.'_'.$cnum.'_slotlog',\%storehash,
                                                   1,$uname,$udom,$uname,$udom);
               }
           }
       }
       return $delresult;
   }
   
 sub check_for_course_info {  sub check_for_course_info {
     my $navmap = Apache::lonnavmaps::navmap->new();      my $navmap = Apache::lonnavmaps::navmap->new();
     return 1 if ($navmap);      return 1 if ($navmap);
     return 0;      return 0;
 }  }
   
 ##################################################  
 ##################################################  
   
 =pod  
   
 =item * handler  
   
 Main handler.  Calls &assessparms and &crsenv subroutines.  
   
 =cut  
   
 ##################################################  
 ##################################################  
   
 sub handler {  sub handler {
     my $r=shift;      my $r=shift;
   
Line 4496  sub handler { Line 4097  sub handler {
             $r->print(&header());              $r->print(&header());
             $r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Manager'));              $r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Manager'));
             &print_main_menu($r,$parm_permission);              &print_main_menu($r,$parm_permission);
         } elsif ($env{'form.action'} eq 'crsenv' && $parm_permission) {  
             &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=crsenv',  
     text=>"Course Environment"});  
             &crsenv($r);   
         } elsif ($env{'form.action'} eq 'setoverview' && $parm_permission) {          } elsif ($env{'form.action'} eq 'setoverview' && $parm_permission) {
             &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',              &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
     text=>"Overview Mode"});      text=>"Overview Mode"});
Line 4567  sub handler { Line 4164  sub handler {
 1;  1;
 __END__  __END__
   
 =pod  
   
 =back  
   
 =cut  
   
   
   

Removed from v.1.413  
changed lines
  Added in v.1.413.4.1


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