Diff for /loncom/interface/lonparmset.pm between versions 1.549 and 1.553

version 1.549, 2015/04/28 13:12:46 version 1.553, 2015/08/28 22:44:59
Line 1076  sub ipacc_boxes_js  { Line 1076  sub ipacc_boxes_js  {
         e.preventDefault();          e.preventDefault();
         var identifier = \$(this).closest("div").attr("id");          var identifier = \$(this).closest("div").attr("id");
         identifier = identifier.replace(ipaccRegExp,'');          identifier = identifier.replace(ipaccRegExp,'');
         \$(this).closest('div').find('.LC_string_ipacc_inner').append('<div><input type="text" name="setip'+identifier+'"/><a href="#" class="LC_remove_ipacc">$remove</a></div>');          \$(this).closest('div').find('.LC_string_ipacc_inner').append('<div><input type="text" name="setip'+identifier+'" /><a href="#" class="LC_remove_ipacc">$remove</a></div>');
     });      });
   
     \$(wrapper).delegate(".LC_remove_ipacc","click", function(e){      \$(wrapper).delegate(".LC_remove_ipacc","click", function(e){
Line 1138  ENDHEAD Line 1138  ENDHEAD
   
 sub print_row {  sub print_row {
     my ($r,$which,$part,$name,$symbp,$rid,$default,$defaulttype,$display,$defbgone,      my ($r,$which,$part,$name,$symbp,$rid,$default,$defaulttype,$display,$defbgone,
     $defbgtwo,$defbgthree,$parmlev,$uname,$udom,$csec,$cgroup,$usersgroups)=@_;      $defbgtwo,$defbgthree,$parmlev,$uname,$udom,$csec,$cgroup,$usersgroups,$noeditgrp)=@_;
     my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};      my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
     my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};      my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
     my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom);      my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom);
   
 # get the values for the parameter in cascading order  # get the values for the parameter in cascading order
 # empty levels will remain empty  # empty levels will remain empty
     my ($result,@outpar)=&parmval($$part{$which}.'.'.$$name{$which},      my ($result,@outpar)=&parmval($$part{$which}.'.'.$$name{$which},
Line 1184  sub print_row { Line 1185  sub print_row {
         if ($uname) {          if ($uname) {
             &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);              &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
         } elsif ($cgroup) {          } elsif ($cgroup) {
             &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);              &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp);
         } elsif ($csec) {          } elsif ($csec) {
             &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);              &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
         } else {          } else {
Line 1195  sub print_row { Line 1196  sub print_row {
         if ($uname) {          if ($uname) {
             &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);              &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
         } elsif ($cgroup) {          } elsif ($cgroup) {
             &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);              &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp);
         } elsif ($csec) {          } elsif ($csec) {
             &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);              &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
         } else {          } else {
Line 1232  sub print_row { Line 1233  sub print_row {
         }          }
   
         if ($cgroup) {          if ($cgroup) {
             &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);              &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp);
             &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);              &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp);
             &print_td($r,4,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);              &print_td($r,4,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp);
         }          }
   
         if ($uname) {          if ($uname) {
Line 1263  sub print_row { Line 1264  sub print_row {
 }  }
   
 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,$noeditgrp)=@_;
     $r->print('<td style="background-color:'.(($result==$which)?'#AAFFAA':$defbg).      $r->print('<td style="background-color:'.(($result==$which)?'#AAFFAA':$defbg).
               ';" align="center">');                ';" align="center">');
     my $nolink = 0;      my $nolink = 0;
     if ($which == 11 || $which == 12) {      if ($which == 11 || $which == 12) {
         $nolink = 1;          $nolink = 1;
       } elsif (($env{'request.course.sec'} ne '') && ($which > 9)) {
           $nolink = 1;
       } elsif ($which == 4 || $which ==  5 || $which == 6) {
           if ($noeditgrp) {
               $nolink = 1;
           }
     } elsif ($mprefix =~ /availablestudent\&$/) {      } elsif ($mprefix =~ /availablestudent\&$/) {
         if ($which > 3) {          if ($which > 3) {
             $nolink = 1;              $nolink = 1;
Line 1754  sub partmenu { Line 1761  sub partmenu {
 }  }
   
 sub usermenu {  sub usermenu {
     my ($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,$usersgroups)=@_;      my ($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,$usersgroups,$pssymb)=@_;
     my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '.      my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '.
         &Apache::loncommon::selectstudent_link('parmform','uname','udom');          &Apache::loncommon::selectstudent_link('parmform','uname','udom');
     my $selscript=&Apache::loncommon::studentbrowser_javascript();      my $selscript=&Apache::loncommon::studentbrowser_javascript();
Line 1763  sub usermenu { Line 1770  sub usermenu {
     my %sectionhash = &Apache::loncommon::get_sections();      my %sectionhash = &Apache::loncommon::get_sections();
   
     my $groups;      my $groups;
     my %grouphash = &Apache::longroup::coursegroups();      my %grouphash;
       if (($pssymb) || &Apache::lonnet::allowed('mdg',$env{'request.course.id'})) {
           %grouphash = &Apache::longroup::coursegroups();
       } elsif ($env{'request.course.groups'} ne '') {
           map { $grouphash{$_} = 1; } split(/,/,$env{'request.course.groups'});
       }
   
     my $g_s_header='';      my $g_s_header='';
     my $g_s_footer='';      my $g_s_footer='';
   
     if (%sectionhash) {      my $currsec = $env{'request.course.sec'};
       if ($currsec) {
           $sections=&mt('Section:').' '.$currsec;
           if (%grouphash) {
               $sections .= ';'.('&nbsp;' x2);
           }
       } elsif (%sectionhash && $currsec eq '') {
         $sections=&mt('Section:').' <select name="csec"';          $sections=&mt('Section:').' <select name="csec"';
         if (%grouphash && $parmlev ne 'full') {          if (%grouphash && $parmlev ne 'full') {
             $sections .= qq| onchange="group_or_section('csec')" |;              $sections .= qq| onchange="group_or_section('csec')" |;
Line 1782  sub usermenu { Line 1800  sub usermenu {
         $sections.='</select>';          $sections.='</select>';
     }      }
   
     if (%sectionhash && %grouphash && $parmlev ne 'full') {      if (%sectionhash && %grouphash && $parmlev ne 'full' && $currsec eq '') {
         $sections .= '&nbsp;'.&mt('or').'&nbsp;';          $sections .= '&nbsp;'.&mt('or').'&nbsp;';
         $sections .= qq|          $sections .= qq|
 <script type="text/javascript">  <script type="text/javascript">
Line 1801  function group_or_section(caller) { Line 1819  function group_or_section(caller) {
 // ]]>  // ]]>
 </script>  </script>
 |;  |;
     } else {      } elsif ($currsec eq '') {
         $sections .= qq|          $sections .= qq|
 <script type="text/javascript">  <script type="text/javascript">
 // <![CDATA[  // <![CDATA[
Line 1815  function group_or_section(caller) { Line 1833  function group_or_section(caller) {
   
     if (%grouphash) {      if (%grouphash) {
         $groups=&mt('Group:').' <select name="cgroup"';          $groups=&mt('Group:').' <select name="cgroup"';
         if (%sectionhash && $env{'form.action'} eq 'settable') {          if (%sectionhash && $env{'form.action'} eq 'settable' && $currsec eq '') {
             $groups .= qq| onchange="group_or_section('cgroup')" |;              $groups .= qq| onchange="group_or_section('cgroup')" |;
         }          }
         $groups .= '>';          $groups .= '>';
Line 2040  sub levelmenu { Line 2058  sub levelmenu {
   
   
 sub sectionmenu {  sub sectionmenu {
     my ($r,$selectedsections)=@_;      my ($selectedsections)=@_;
     my %sectionhash = &Apache::loncommon::get_sections();      my %sectionhash = &Apache::loncommon::get_sections();
     return if (!%sectionhash);      return '' if (!%sectionhash);
   
     $r->print('<select name="Section" multiple="multiple" size="8">');      my (@possibles,$disabled);
     foreach my $s ('all',sort(keys(%sectionhash))) {      if ($env{'request.course.sec'} ne '') {
         $r->print('    <option value="'.$s.'"');          @possibles = ($env{'request.course.sec'});
         foreach my $sec (@{$selectedsections}) {          $selectedsections = [$env{'request.course.sec'}];
             if ($s eq $sec) {          $disabled = ' disabled="disabled"';
                 $r->print(' selected="selected"');      } else {
                 last;          @possibles = ('all',sort(keys(%sectionhash)));
             }      }
       my $output = '<select name="Section" multiple="multiple" size="8"'.$disabled.'>';
       foreach my $s (@possibles) {
           $output .= '    <option value="'.$s.'"';
           if ((@{$selectedsections}) && (grep(/^\Q$s\E$/,@{$selectedsections}))) {  
               $output .= ' selected="selected"';
         }          }
         $r->print('>'.$s."</option>\n");          $output .= '>'."$s</option>\n";
     }      }
     $r->print("</select>\n");      $output .= "</select>\n";
       return $output;
 }  }
   
 sub groupmenu {  sub groupmenu {
     my ($r,$selectedgroups)=@_;      my ($selectedgroups)=@_;
     my %grouphash = &Apache::longroup::coursegroups();      my %grouphash;
     return if (!%grouphash);      if (&Apache::lonnet::allowed('mdg',$env{'request.course.id'})) {
           %grouphash = &Apache::longroup::coursegroups();
       } elsif ($env{'request.course.groups'} ne '') {
            map { $grouphash{$_} = 1; } split(/,/,$env{'request.course.groups'});
       }
       return '' if (!%grouphash);
   
     $r->print('<select name="Group" multiple="multiple" size="8">');      my $output = '<select name="Group" multiple="multiple" size="8">';
     foreach my $group (sort(keys(%grouphash))) {      foreach my $group (sort(keys(%grouphash))) {
         $r->print('    <option value="'.$group.'"');          $output .= '    <option value="'.$group.'"';
         foreach my $grp (@{$selectedgroups}) {          if ((@{$selectedgroups}) && (grep(/^\Q$group\E$/,\@{$selectedgroups}))) {
             if ($group eq $grp) {              $output .=  ' selected="selected"';
                 $r->print(' selected="selected"');  
                 last;  
             }  
         }          }
         $r->print('>'.$group."</option>\n");          $output .= '>'."$group</option>\n";
     }      }
     $r->print("</select>\n");      $output .= "</select>\n";
       return $output;
 }  }
   
   
 sub keysplit {  sub keysplit {
     my $keyp=shift;      my $keyp=shift;
     return (split(/\,/,$keyp));      return (split(/\,/,$keyp));
Line 2197  sub assessparms { Line 2223  sub assessparms {
     my $message='';      my $message='';
   
     $csec=$env{'form.csec'};      $csec=$env{'form.csec'};
       if ($env{'request.course.sec'} ne '') {
           $csec = $env{'request.course.sec'};    
       }
   
   # Check group privs.
     $cgroup=$env{'form.cgroup'};      $cgroup=$env{'form.cgroup'};
       my $noeditgrp; 
       if ($cgroup ne '') {
           unless (&Apache::lonnet::allowed('mdg',$env{'request.course.id'})) {
               if (($env{'request.course.groups'} eq '') || 
                   (!grep(/^\Q$cgroup\E$/,split(/,/,$env{'request.course.groups'})))) {
                   $noeditgrp = 1;
               }
           }
       }
   
     if      ($udom=$env{'form.udom'}) {      if      ($udom=$env{'form.udom'}) {
     } elsif ($udom=$env{'request.role.domain'}) {      } elsif ($udom=$env{'request.role.domain'}) {
Line 2323  sub assessparms { Line 2363  sub assessparms {
         my $now = time;          my $now = time;
         for (my $i=0;$i<=$#markers;$i++) {          for (my $i=0;$i<=$#markers;$i++) {
             my ($needsrelease,$needsnewer,$name);              my ($needsrelease,$needsnewer,$name);
               if (($env{'request.course.sec'} ne '') && ($markers[$i] =~ /\&(7|8|9)$/)) {
                   next if ($csec ne $env{'request.course.sec'});
               }
               if ($markers[$i] =~ /\&(6|5|4)$/) {
                   next if ($noeditgrp);
               } 
             if ($markers[$i] =~ /^[\d.]+\&0_availablestudent\&(1|2|3)$/) {              if ($markers[$i] =~ /^[\d.]+\&0_availablestudent\&(1|2|3)$/) {
                 my (@ok_slots,@fail_slots,@del_slots);                  my (@ok_slots,@fail_slots,@del_slots);
                 my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom);                  my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom);
Line 2486  ENDPARMSELSCRIPT Line 2532  ENDPARMSELSCRIPT
         # Step 3          # Step 3
         $r->print(&Apache::lonhtmlcommon::topic_bar(3,&mt('User Specification (optional)'),'parmstep3'));          $r->print(&Apache::lonhtmlcommon::topic_bar(3,&mt('User Specification (optional)'),'parmstep3'));
         $r->print(&Apache::lonhtmlcommon::start_pick_box());          $r->print(&Apache::lonhtmlcommon::start_pick_box());
         &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups);          &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups,$pssymb);
         $r->print(&Apache::lonhtmlcommon::row_closure(1));          $r->print(&Apache::lonhtmlcommon::row_closure(1));
         $r->print(&Apache::lonhtmlcommon::end_pick_box());          $r->print(&Apache::lonhtmlcommon::end_pick_box());
   
Line 2518  ENDPARMSELSCRIPT Line 2564  ENDPARMSELSCRIPT
                   '<br />');                    '<br />');
         $r->print(&Apache::lonhtmlcommon::topic_bar('',&mt('Additional Display Specification (optional)')));          $r->print(&Apache::lonhtmlcommon::topic_bar('',&mt('Additional Display Specification (optional)')));
         $r->print(&Apache::lonhtmlcommon::start_pick_box());          $r->print(&Apache::lonhtmlcommon::start_pick_box());
         &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups);          &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups,$pssymb);
         $r->print(&Apache::lonhtmlcommon::row_closure(1));          $r->print(&Apache::lonhtmlcommon::row_closure(1));
         $r->print(&Apache::lonhtmlcommon::end_pick_box());          $r->print(&Apache::lonhtmlcommon::end_pick_box());
         $r->print('<p>'          $r->print('<p>'
Line 2730  ENDTABLEHEADFOUR Line 2776  ENDTABLEHEADFOUR
                             &print_row($r,$item,\%part,\%name,\%symbp,$rid,\%default,                              &print_row($r,$item,\%part,\%name,\%symbp,$rid,\%default,
                                        \%type,\%display,$defbgone,$defbgtwo,                                         \%type,\%display,$defbgone,$defbgtwo,
                                        $defbgthree,$parmlev,$uname,$udom,$csec,                                         $defbgthree,$parmlev,$uname,$udom,$csec,
                                                             $cgroup,\@usersgroups);                                         $cgroup,\@usersgroups,$noeditgrp);
                         }                          }
                     }                      }
                 }                  }
Line 2852  ENDTABLEHEADFOUR Line 2898  ENDTABLEHEADFOUR
                     $r->print(&Apache::loncommon::start_data_table_row());                      $r->print(&Apache::loncommon::start_data_table_row());
                     &print_row($r,$item,\%part,\%name,\%symbp,$mapid,\%default,                      &print_row($r,$item,\%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,'',$noeditgrp);
                 }                  }
                 $r->print(&Apache::loncommon::end_data_table().'</p>'                  $r->print(&Apache::loncommon::end_data_table().'</p>'
                          .'</div>'                           .'</div>'
Line 2942  ENDMAPONE Line 2988  ENDMAPONE
                 $r->print(&Apache::loncommon::start_data_table_row());                  $r->print(&Apache::loncommon::start_data_table_row());
                 &print_row($r,$item,\%part,\%name,\%symbp,$mapid,\%default,                  &print_row($r,$item,\%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,'',$noeditgrp);
             }              }
             $r->print(&Apache::loncommon::end_data_table()              $r->print(&Apache::loncommon::end_data_table()
                      .'</p>'                       .'</p>'
Line 2961  ENDMAPONE Line 3007  ENDMAPONE
 my $tableopen;  my $tableopen;
   
 sub tablestart {  sub tablestart {
       my ($readonly) = @_;
     if ($tableopen) {      if ($tableopen) {
     return '';          return '';
     } else {      } else {
     $tableopen=1;          $tableopen=1;
     return &Apache::loncommon::start_data_table().'<tr><th>'.&mt('Parameter').'</th><th>'.          my $output = &Apache::loncommon::start_data_table().'<tr><th>'.&mt('Parameter').'</th>';
         &mt('Delete').'</th><th>'.&mt('Set to ...').'</th></tr>';          if ($readonly) {
               $output .= '<th>'.&mt('Current value').'</th>';
           } else {
               $output .= '<th>'.&mt('Delete').'</th><th>'.&mt('Set to ...').'</th>';
           }
           $output .= '</tr>';
           return $output;
     }      }
 }  }
   
Line 2999  sub readdata { Line 3052  sub readdata {
             }              }
         }          }
     }      }
     return $resourcedata;      if (wantarray) {
           return ($resourcedata,$classlist);
       } else {
           return $resourcedata;
       }
 }  }
   
   
Line 3195  sub parse_listdata_key { Line 3252  sub parse_listdata_key {
 }  }
   
 sub listdata {  sub listdata {
     my ($r,$resourcedata,$listdata,$sortorder)=@_;      my ($r,$resourcedata,$listdata,$sortorder,$caller,$classlist)=@_;
       
 # Start list output  # Start list output
   
     my $oldsection='';      my $oldsection='';
Line 3206  sub listdata { Line 3264  sub listdata {
     my $foundkeys=0;      my $foundkeys=0;
     my %keyorder=&standardkeyorder();      my %keyorder=&standardkeyorder();
   
       my ($secidx,%grouphash);
       if (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) {
           $secidx = &Apache::loncoursedata::CL_SECTION();
           if (&Apache::lonnet::allowed('mdg',$env{'request.course.id'})) {
               %grouphash = &Apache::longroup::coursegroups();
           } elsif ($env{'request.course.groups'} ne '') {
               map { $grouphash{$_} = 1; } split(/,/,$env{'request.course.groups'});
           }
       }
   
     foreach my $thiskey (sort {      foreach my $thiskey (sort {
     my ($astudent,$ares,$apart,$aparm) = &parse_listdata_key($a,$listdata);      my ($astudent,$ares,$apart,$aparm) = &parse_listdata_key($a,$listdata);
     my ($bstudent,$bres,$bpart,$bparm) = &parse_listdata_key($b,$listdata);      my ($bstudent,$bres,$bpart,$bparm) = &parse_listdata_key($b,$listdata);
Line 3247  sub listdata { Line 3315  sub listdata {
     $result;      $result;
     } keys(%{$listdata})) {      } keys(%{$listdata})) {
   
       my $readonly;
     if ($$listdata{$thiskey.'.type'}) {      if ($$listdata{$thiskey.'.type'}) {
             my $thistype=$$listdata{$thiskey.'.type'};          my $thistype=$$listdata{$thiskey.'.type'};
             if ($$resourcedata{$thiskey.'.type'}) {          if ($$resourcedata{$thiskey.'.type'}) {
         $thistype=$$resourcedata{$thiskey.'.type'};              $thistype=$$resourcedata{$thiskey.'.type'};
         }          }
         my ($middle,$part,$name)=          my ($middle,$part,$name)=
         ($thiskey=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);          ($thiskey=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
         my $section=&mt('All Students');          my $section=&mt('All Students');
         if ($middle=~/^\[(.*)\]/) {          if ($middle=~/^\[(.*)\]/) {
         my $issection=$1;              my $issection=$1;
         if ($issection=~/^useropt\:($match_username)\:($match_domain)/) {              if ($issection=~/^useropt\:($match_username)\:($match_domain)/) {
             $section=&mt('User').": ".&Apache::loncommon::plainname($1,$2);                  my ($stuname,$studom) = ($1,$2);
         } else {                  if (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) {
             $section=&mt('Group/Section').': '.$issection;                      if (ref($classlist) eq 'HASH') {
         }                          if (ref($classlist->{$stuname.':'.$studom}) eq 'ARRAY') {
         $middle=~s/^\[(.*)\]//;                              next unless ($classlist->{$stuname.':'.$studom}->[$secidx] eq $env{'request.course.sec'}); 
                           }
                       }
                   }
                   $section=&mt('User').": ".&Apache::loncommon::plainname($stuname,$studom);
               } else {
                   if (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) {
                       if (exists($grouphash{$issection})) {
                           $section=&mt('Group').': '.$issection;
                       } elsif ($issection eq $env{'request.course.sec'}) {
                           $section = &mt('Section').': '.$issection;
                       } else {
                           next; 
                       }
                   } else {
                       $section=&mt('Group/Section').': '.$issection;
                   }
               }
               $middle=~s/^\[(.*)\]//;
           } elsif (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) {
               $readonly = 1;
         }          }
         $middle=~s/\.+$//;          $middle=~s/\.+$//;
         $middle=~s/^\.+//;          $middle=~s/^\.+//;
Line 3305  sub listdata { Line 3394  sub listdata {
 # Ready to print  # Ready to print
 #  #
             my $parmitem = &standard_parameter_names($name);              my $parmitem = &standard_parameter_names($name);
         $r->print(&tablestart().          $r->print(&tablestart($readonly).
               &Apache::loncommon::start_data_table_row().                &Apache::loncommon::start_data_table_row().
               '<td><b>'.&mt($parmitem).                '<td><b>'.&mt($parmitem).
               '</b></td><td><input type="checkbox" name="del_'.                '</b></td>');
               $thiskey.'" /></td><td>');          unless ($readonly) {
               $r->print('<td><input type="checkbox" name="del_'.
                         $thiskey.'" /></td>');
           }
           $r->print('<td>');
         $foundkeys++;          $foundkeys++;
         if (&isdateparm($thistype)) {          if (&isdateparm($thistype)) {
         my $jskey='key_'.$pointer;              my $jskey='key_'.$pointer;
         $pointer++;              my $state;
         $r->print(              $pointer++;
               &Apache::lonhtmlcommon::date_setter('parmform',              if ($readonly) {
                                   $jskey,                  $state = 'disabled';
                               $$resourcedata{$thiskey},              }
                                   '',1,'','').              $r->print(
                   &Apache::lonhtmlcommon::date_setter('parmform',
                                                       $jskey,
                                                       $$resourcedata{$thiskey},
                                                       '',1,$state));
               unless  ($readonly) {
                   $r->print(
 '<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'.  '<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'.
 (($$resourcedata{$thiskey}!=0)?'<span class="LC_nobreak"><a href="/adm/parmset?&action=dateshift1&timebase='.$$resourcedata{$thiskey}.'">'.  (($$resourcedata{$thiskey}!=0)?'<span class="LC_nobreak"><a href="/adm/parmset?&action=dateshift1&timebase='.$$resourcedata{$thiskey}.'">'.
 &mt('Shift all dates based on this date').'</a></span>':'').  &mt('Shift all dates based on this date').'</a></span>':'').
 &date_sanity_info($$resourcedata{$thiskey})  &date_sanity_info($$resourcedata{$thiskey})
               );                  );
               }
         } elsif ($thistype eq 'date_interval') {          } elsif ($thistype eq 'date_interval') {
         $r->print(&date_interval_selector($thiskey,              $r->print(&date_interval_selector($thiskey,
                           $$resourcedata{$thiskey}));                        $$resourcedata{$thiskey},$readonly));
         } elsif ($thistype =~ m/^string/) {          } elsif ($thistype =~ m/^string/) {
         $r->print(&string_selector($thistype,$thiskey,              $r->print(&string_selector($thistype,$thiskey,
                        $$resourcedata{$thiskey},$name));                        $$resourcedata{$thiskey},$name,$readonly));
         } else {          } else {
         $r->print(&default_selector($thiskey,$$resourcedata{$thiskey}));              $r->print(&default_selector($thiskey,$$resourcedata{$thiskey},$readonly));
           }
           unless ($readonly) {
               $r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'.
                         $thistype.'" />');
         }          }
         $r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'.  
               $thistype.'" />');  
         $r->print('</td>'.&Apache::loncommon::end_data_table_row());          $r->print('</td>'.&Apache::loncommon::end_data_table_row());
     }      }
     }      }
Line 3343  sub listdata { Line 3445  sub listdata {
   
   
 sub date_interval_selector {  sub date_interval_selector {
     my ($thiskey, $showval) = @_;      my ($thiskey, $showval, $readonly) = @_;
     my $result;      my $result;
     foreach my $which (['days', 86400, 31],      foreach my $which (['days', 86400, 31],
                ['hours', 3600, 23],                 ['hours', 3600, 23],
Line 3355  sub date_interval_selector { Line 3457  sub date_interval_selector {
     my %select = ((map {$_ => $_} (0..$max)),      my %select = ((map {$_ => $_} (0..$max)),
               'select_form_order' => [0..$max]);                'select_form_order' => [0..$max]);
     $result .= &Apache::loncommon::select_form($amount,$name.'_'.$thiskey,      $result .= &Apache::loncommon::select_form($amount,$name.'_'.$thiskey,
                            \%select);                             \%select,'',$readonly);
     $result .= ' '.&mt($name);      $result .= ' '.&mt($name);
     }      }
     $result .= '<input type="hidden" name="dateinterval_'.$thiskey.'" />';      unless ($readonly) {
           $result .= '<input type="hidden" name="dateinterval_'.$thiskey.'" />';
       }
     return $result;      return $result;
   
 }  }
Line 3380  sub get_date_interval_from_form { Line 3484  sub get_date_interval_from_form {
   
   
 sub default_selector {  sub default_selector {
     my ($thiskey, $showval) = @_;      my ($thiskey, $showval, $readonly) = @_;
     return '<input type="text" name="set_'.$thiskey.'" value="'.$showval.'" />';      my $disabled;
       if ($readonly) {
           $disabled = ' disabled="disabled"';
       }
       return '<input type="text" name="set_'.$thiskey.'" value="'.$showval.'"'.$disabled.' />';
 }  }
   
 sub string_ip_selector {  sub string_ip_selector {
     my ($thiskey, $showval) = @_;      my ($thiskey, $showval, $readonly) = @_;
     my %access = (      my %access = (
                    allow => [],                     allow => [],
                    deny  => [],                     deny  => [],
Line 3411  sub string_ip_selector { Line 3519  sub string_ip_selector {
     if (!@{$access{'deny'}}) {      if (!@{$access{'deny'}}) {
         @{$access{'deny'}} = ('');          @{$access{'deny'}} = ('');
     }      }
       my ($disabled,$addmore);
       if ($disabled) {
           $disabled=' disabled="disabled"';
       } else {
           $addmore = "\n".'<button class="LC_add_ipacc_button">'.&mt('Add more').'</button>';
       }
     my $output = '<input type="hidden" name="set_'.$thiskey.'" />      my $output = '<input type="hidden" name="set_'.$thiskey.'" />
 <table><tr><th>'.&mt('Allow from').'</th><th>'.&mt('Deny from').'</th></tr><tr>';  <table><tr><th>'.&mt('Allow from').'</th><th>'.&mt('Deny from').'</th></tr><tr>';
     foreach my $acctype ('allow','deny') {      foreach my $acctype ('allow','deny') {
Line 3420  sub string_ip_selector { Line 3534  sub string_ip_selector {
   <div class="LC_string_ipacc_inner">'."\n";    <div class="LC_string_ipacc_inner">'."\n";
         my $num = 0;          my $num = 0;
         foreach my $curr (@{$access{$acctype}}) {          foreach my $curr (@{$access{$acctype}}) {
             $output .= '<div><input type="text" name="setip'.$acctype.'_'.$thiskey.'" value="'.$curr.'">';              $output .= '<div><input type="text" name="setip'.$acctype.'_'.$thiskey.'" value="'.$curr.'"'.$disabled.' />';
             if ($num > 0) {              if ($num > 0) {
                 $output .= '<a href="#" class="LC_remove_ipacc">'.&mt('Remove').'</a>';                   $output .= '<a href="#" class="LC_remove_ipacc">'.&mt('Remove').'</a>'; 
             }              }
Line 3428  sub string_ip_selector { Line 3542  sub string_ip_selector {
             $num ++;              $num ++;
         }          }
         $output .= '          $output .= '
   </div>    </div>'.$addmore.'
 <button class="LC_add_ipacc_button">'.&mt('Add more').'</button>  
 </div>  </div>
 </td>';  </td>';
    }     }
Line 3515  sub get_stringtype { Line 3628  sub get_stringtype {
 }  }
   
 sub string_selector {  sub string_selector {
     my ($thistype, $thiskey, $showval, $name) = @_;      my ($thistype, $thiskey, $showval, $name, $readonly) = @_;
   
     if (!exists($strings{$thistype})) {      if (!exists($strings{$thistype})) {
         return &default_selector($thiskey,$showval);          return &default_selector($thiskey,$showval,$readonly);
     }      }
   
     my %skiptype;      my %skiptype;
Line 3563  sub string_selector { Line 3676  sub string_selector {
     }      }
   
     if ($thistype eq 'string_ip') {      if ($thistype eq 'string_ip') {
         return &string_ip_selector($thiskey,$showval);           return &string_ip_selector($thiskey,$showval,$readonly); 
     }      }
   
     my $result;      my ($result,$disabled);
   
       if ($readonly) {
           $disabled = ' disabled="disabled"';
       }
     my $numinrow = 3;      my $numinrow = 3;
     if ($thistype eq 'string_problemstatus') {      if ($thistype eq 'string_problemstatus') {
         $numinrow = 2;          $numinrow = 2;
Line 3631  sub string_selector { Line 3748  sub string_selector {
                     foreach my $reltype ('corrchkd','corrunchkd','incorrchkd','incorrunchkd') {                      foreach my $reltype ('corrchkd','corrunchkd','incorrchkd','incorrunchkd') {
                         $add .= '<tr><td>&nbsp;</td><td>'.$relatives{$reltype}.'</td>'."\n".                          $add .= '<tr><td>&nbsp;</td><td>'.$relatives{$reltype}.'</td>'."\n".
                                 '<td><input type="text" name="settext_'.$thiskey.'"'.                                  '<td><input type="text" name="settext_'.$thiskey.'"'.
                                 ' value="'.$textval{$reltype}.'" size="3" />'.                                  ' value="'.$textval{$reltype}.'" size="3"'.$disabled.' />'.
                                 '</td></tr>';                                  '</td></tr>';
                     }                      }
                     $add .= '</table></div>'."\n";                      $add .= '</table></div>'."\n";
Line 3642  sub string_selector { Line 3759  sub string_selector {
             $result .= '<td class="LC_left_item"'.$colspan.'>'.              $result .= '<td class="LC_left_item"'.$colspan.'>'.
                        '<span class="LC_nobreak"><label>'.                         '<span class="LC_nobreak"><label>'.
                        '<input type="radio" name="set_'.$thiskey.                         '<input type="radio" name="set_'.$thiskey.
                        '" value="'.$name.'"'.$onchange.$css_class;                         '" value="'.$name.'"'.$onchange.$css_class.$disabled;
             if ($showval eq $name) {              if ($showval eq $name) {
                 $result .= ' checked="checked"';                  $result .= ' checked="checked"';
             }              }
Line 3775  sub newoverview { Line 3892  sub newoverview {
 </script>  </script>
 ';  ';
   
 #FIXME need onload  
     my $start_page = &Apache::loncommon::start_page('Set Parameters',$js,      my $start_page = &Apache::loncommon::start_page('Set Parameters',$js,
                                                     {'add_entries' => \%loaditems,});                                                      {'add_entries' => \%loaditems,});
     my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview');      my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview');
Line 3819  ENDOVER Line 3935  ENDOVER
             @selected_sections = ('all');              @selected_sections = ('all');
         }          }
     }      }
       if ($env{'request.course.sec'} ne '') {
           @selected_sections = ($env{'request.course.sec'});
       }
     my @selected_groups =      my @selected_groups =
         &Apache::loncommon::get_env_multiple('form.Group');          &Apache::loncommon::get_env_multiple('form.Group');
   
Line 3858  ENDOVER Line 3977  ENDOVER
     &displaymenu($r,\%allparms,\@pscat,\%keyorder);      &displaymenu($r,\%allparms,\@pscat,\%keyorder);
     $r->print(&Apache::lonhtmlcommon::start_pick_box());      $r->print(&Apache::lonhtmlcommon::start_pick_box());
     $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parts to View')));      $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parts to View')));
       my $sectionselector = &sectionmenu(\@selected_sections);
       my $groupselector = &groupmenu(\@selected_groups);
     $r->print('<table>'.      $r->print('<table>'.
               '<tr><th>'.&mt('Parts').'</th><th>'.&mt('Section(s)').                '<tr><th>'.&mt('Parts').'</th>');
               '</th><th>'.&mt('Group(s)').'</th></tr><tr><td>');      if ($sectionselector) {
           $r->print('<th>'.&mt('Section(s)').'</th>');
       }
       if ($groupselector) {
           $r->print('<th>'.&mt('Group(s)').'</th>');
       }
       $r->print('</tr><tr><td>');
     &partmenu($r,\%allparts,\@psprt);      &partmenu($r,\%allparts,\@psprt);
     $r->print('</td><td>');      $r->print('</td>');
     &sectionmenu($r,\@selected_sections);      if ($sectionselector) { 
     $r->print('</td><td>');          $r->print('<td>'.$sectionselector.'</td>');
     &groupmenu($r,\@selected_groups);      }
     $r->print('</td></tr></table>');      if ($groupselector) {
     #$r->print('</td></tr></table>');          $r->print('<td>'.$groupselector.'</td>');
       }
       $r->print('</tr></table>');
     $r->print(&Apache::lonhtmlcommon::row_closure(1));      $r->print(&Apache::lonhtmlcommon::row_closure(1));
     $r->print(&Apache::lonhtmlcommon::end_pick_box());      $r->print(&Apache::lonhtmlcommon::end_pick_box());
     $r->print('</div></div>');      $r->print('</div></div>');
Line 3901  ENDOVER Line 4030  ENDOVER
   
 # List data  # List data
   
         &listdata($r,$resourcedata,$listdata,$sortorder);          &listdata($r,$resourcedata,$listdata,$sortorder,'newoverview');
     }      }
 #FIXME  
     $r->print(&tableend().      $r->print(&tableend().
          ((($env{'form.store'}) || ($env{'form.dis'}))?'<p><input type="submit" name="store" value="'.&mt('Save').'" /></p>':'').           ((($env{'form.store'}) || ($env{'form.dis'}))?'<p><input type="submit" name="store" value="'.&mt('Save').'" /></p>':'').
           '</form>');            '</form>');
Line 3976  sub overview { Line 4104  sub overview {
   
 # Read modified data  # Read modified data
   
     my $resourcedata=&readdata($crs,$dom);      my ($resourcedata,$classlist)=&readdata($crs,$dom);
   
   
     my $sortorder=$env{'form.sortorder'};      my $sortorder=$env{'form.sortorder'};
Line 3985  sub overview { Line 4113  sub overview {
   
 # List data  # List data
   
     my $foundkeys=&listdata($r,$resourcedata,$resourcedata,$sortorder);      my $foundkeys=&listdata($r,$resourcedata,$resourcedata,$sortorder,'overview',$classlist);
 #FIXME  
     $r->print(&tableend().'<p>'.      $r->print(&tableend().'<p>'.
     ($foundkeys?'<input type="submit" value="'.&mt('Save').'" />':'<span class="LC_info">'.&mt('There are no parameters.').'</span>').'</p></form>'.      ($foundkeys?'<input type="submit" value="'.&mt('Save').'" />':'<span class="LC_info">'.&mt('There are no parameters.').'</span>').'</p></form>'.
           &Apache::loncommon::end_page());            &Apache::loncommon::end_page());
Line 4940  sub parm_change_log { Line 5067  sub parm_change_log {
                 !exists($parmlog{$id}{'logentry'}{$changed.'.type'}));                  !exists($parmlog{$id}{'logentry'}{$changed.'.type'}));
             my ($realm,$section,$parmname,$part,$what,$middle,$uname,$udom,$issection,$realmdescription)=              my ($realm,$section,$parmname,$part,$what,$middle,$uname,$udom,$issection,$realmdescription)=
         &components($changed,$parmlog{$id}{'uname'},$parmlog{$id}{'udom'},undef,undef,$typeflag);          &components($changed,$parmlog{$id}{'uname'},$parmlog{$id}{'udom'},undef,undef,$typeflag);
           if ($env{'request.course.sec'} ne '') {
               next if (($issection ne '') && ($issection ne $env{'request.course.sec'}));
               if ($uname ne '') {
                   my $stusection = &Apache::lonnet::getsection($uname,$udom,$env{'request.course.id'});
                   next if (($stusection ne '-1') && ($stusection ne $env{'request.course.sec'})); 
               }
           }
         if ($env{'form.displayfilter'} eq 'currentfolder') {          if ($env{'form.displayfilter'} eq 'currentfolder') {
         if ($folder) {          if ($folder) {
             if ($middle!~/^\Q$folder\E/) { next; }              if ($middle!~/^\Q$folder\E/) { next; }

Removed from v.1.549  
changed lines
  Added in v.1.553


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