Diff for /loncom/interface/lonparmset.pm between versions 1.175 and 1.181

version 1.175, 2004/09/10 21:29:54 version 1.181, 2005/02/02 19:23:59
Line 628  sub extractResourceInformation { Line 628  sub extractResourceInformation {
  if ($mapid eq '1') {   if ($mapid eq '1') {
     $$maptitles{$mapid}='Main Course Documents';      $$maptitles{$mapid}='Main Course Documents';
  } else {   } else {
     $$maptitles{$mapid}=      $$maptitles{$mapid}=&Apache::lonnet::gettitle(&Apache::lonnet::clutter($$mapp{$id}));
  $$bighash{'title_'.$$bighash{'ids_'.&Apache::lonnet::clutter($$mapp{$id})}};  
  }   }
  $$maptitles{$$mapp{$id}}=$$maptitles{$mapid};   $$maptitles{$$mapp{$id}}=$$maptitles{$mapid};
  $$symbp{$id}=$$mapp{$id}.   $$symbp{$id}=&Apache::lonnet::encode_symb($$mapp{$id},$resid,$srcf);
  '___'.$resid.'___'.  
     &Apache::lonnet::declutter($srcf);  
                 $$symbp{$mapid}=$$mapp{$id}.'___(all)';                  $$symbp{$mapid}=$$mapp{$id}.'___(all)';
     }      }
  }   }
Line 1002  sub assessparms { Line 999  sub assessparms {
   
         $r->print('<tr><td colspan="3" align="center">'.&mt('Select Parameters to View').'</td></tr>');          $r->print('<tr><td colspan="3" align="center">'.&mt('Select Parameters to View').'</td></tr>');
   
         $r->print('<tr><td colspan="2"><table>');          $r->print('<tr><td colspan="2"><table><tr>');
         $r->print('<tr><td><input type="checkbox" name="pscat" value="all"');  
         $r->print(' checked') unless (@pscat);  
         $r->print('>'.&mt('All Parameters').'</td>');  
   
         my $cnt=0;          my $cnt=0;
         foreach $tempkey (sort { $allparms{$a} cmp $allparms{$b} }          foreach $tempkey (sort { $allparms{$a} cmp $allparms{$b} }
                       keys %allparms ) {                        keys %allparms ) {
             ++$cnt;              ++$cnt;
             $r->print('</tr><tr>') unless ($cnt%2);              $r->print('</tr><tr>') if ($cnt%2);
             $r->print('<td><input type="checkbox" name="pscat" ');              $r->print('<td><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');
             }              }
             $r->print('>'.$allparms{$tempkey}.'</td>');      $r->print('>'.$allparms{$tempkey}.'</td>');
    }
    $r->print('
   </tr><tr><td>
   <script type="text/javascript">
       function checkall(value, checkName) {
    for (i=0; i<document.forms.parmform.elements.length; i++) {
               ele = document.forms.parmform.elements[i];
               if (ele.name == checkName) {
                   document.forms.parmform.elements[i].checked=value;
               }
         }          }
       }
   </script>
   <input type="button" onclick="checkall(true, \'pscat\')" value="Select All" />
   </td><td>
   <input type="button" onclick="checkall(false, \'pscat\')" value="Unselect All" />
   </td>
   ');
         $r->print('</tr></table>');          $r->print('</tr></table>');
   
 #        $r->print('<tr><td>Select Parts</td><td>');  #        $r->print('<tr><td>Select Parts</td><td>');
Line 1206  ENDTABLEHEADFOUR Line 1216  ENDTABLEHEADFOUR
                     my $totalparms=scalar keys %name;                      my $totalparms=scalar keys %name;
                     if ($totalparms>0) {                      if ($totalparms>0) {
                         my $firstrow=1;                          my $firstrow=1;
  my $title=$bighash{'title_'.$rid};   my $title=&Apache::lonnet::gettitle($uri);
  $title=~s/\&colon;/:/g;  
                         $r->print('<tr><td bgcolor='.$defbgone.                          $r->print('<tr><td bgcolor='.$defbgone.
                              ' rowspan='.$totalparms.                               ' rowspan='.$totalparms.
                              '><tt><font size=-1>'.                               '><tt><font size=-1>'.
Line 1514  sub crsenv { Line 1523  sub crsenv {
         if ($name =~ /^default_enrollment_(start|end)_date$/) {          if ($name =~ /^default_enrollment_(start|end)_date$/) {
             $value=&Apache::lonhtmlcommon::get_date_from_form($name.'_value');              $value=&Apache::lonhtmlcommon::get_date_from_form($name.'_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          # Let the user know we made the changes
         if ($name && defined($value)) {          if ($name && defined($value)) {
               if ($name eq 'cloners') {
                   $value =~ s/^,//;
                   $value =~ s/,$//;
               }
             my $put_result = &Apache::lonnet::put('environment',              my $put_result = &Apache::lonnet::put('environment',
                                                   {$name=>$value},$dom,$crs);                                                    {$name=>$value},$dom,$crs);
             if ($put_result eq 'ok') {              if ($put_result eq 'ok') {
                 $setoutput.=&mt('Set').' <b>'.$name.'</b> '.&mt('to').' <b>'.$value.'</b>.<br />';                  $setoutput.=&mt('Set').' <b>'.$name.'</b> '.&mt('to').' <b>'.$value.'</b>.<br />';
                   if ($name eq 'cloners') {
                       &change_clone($value,\@oldcloner);
                   }
                   # Flush the course logs so course description is immediately updated
                   if ($name eq 'description' && defined($value)) {
                       &Apache::lonnet::flushcourselogs();
                   }
             } else {              } else {
                 $setoutput.=&mt('Unable to set').' <b>'.$name.'</b> '.&mt('to').                  $setoutput.=&mt('Unable to set').' <b>'.$name.'</b> '.&mt('to').
     ' <b>'.$value.'</b> '.&mt('due to').' '.$put_result.'.<br />';      ' <b>'.$value.'</b> '.&mt('due to').' '.$put_result.'.<br />';
Line 1549  sub crsenv { Line 1579  sub crsenv {
              'courseid'       => '<b>'.&mt('Course ID or number').               'courseid'       => '<b>'.&mt('Course ID or number').
                                  '</b><br />'.                                   '</b><br />'.
                                  '('.&mt('internal').', '.&mt('optional').')',                                   '('.&mt('internal').', '.&mt('optional').')',
                'cloners'        => '<b>'.&mt('Users allowed to clone course').'</b><br /><tt>(user:domain,user:domain)</tt><br />'.&mt('Users with active Course Coordinator role in the course automatically have the right to clone it, and can be omitted from list.'),
              'grading'        => '<b>'.&mt('Grading').'</b><br />'.               'grading'        => '<b>'.&mt('Grading').'</b><br />'.
                                  '<tt>"standard", "external", or "spreadsheet"</tt> '.&Apache::loncommon::help_open_topic('GradingOptions'),                                   '<tt>"standard", "external", or "spreadsheet"</tt> '.&Apache::loncommon::help_open_topic('GradingOptions'),
              'default_xml_style' => '<b>'.&mt('Default XML Style File').'</b> '.               'default_xml_style' => '<b>'.&mt('Default XML Style File').'</b> '.
Line 1644  sub crsenv { Line 1675  sub crsenv {
      'tthoptions'       'tthoptions'
          => '<b>'.&mt('Default set of options to pass to tth/m when converting tex').'</b>'           => '<b>'.&mt('Default set of options to pass to tth/m when converting tex').'</b>'
              );                ); 
         my @Display_Order = ('url','description','courseid','grading',          my @Display_Order = ('url','description','courseid','cloners','grading',
                              'default_xml_style','pageseparators',                               'default_xml_style','pageseparators',
                              'question.email','comment.email','policy.email',                               'question.email','comment.email','policy.email',
                              'student_classlist_view',                               'student_classlist_view',
Line 1894  ENDOVER Line 1925  ENDOVER
 }  }
   
 ##################################################  ##################################################
   ##################################################
                                                                                               
   =pod
                                                                                               
   =item change clone
                                                                                               
   Modifies the list of courses a user can clone (stored
   in the user's environemnt.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. 
                                                                                               
   Returns: 
   
   =cut
                                                                                               
   ##################################################
   ##################################################
   
   
   sub change_clone {
       my ($clonelist,$oldcloner) = @_;
       my ($uname,$udom);
       my $cnum = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
       my $cdom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
       my $clone_crs = $cnum.':'.$cdom;
       
       if ($cnum && $cdom) {
           my @allowclone = ();
           if ($clonelist =~ /,/) {
               @allowclone = split/,/,$clonelist;
           } else {
               $allowclone[0] = $clonelist;
           }
           foreach my $currclone (@allowclone) {
               if (!grep/^$currclone$/,@$oldcloner) {
                   ($uname,$udom) = split/:/,$currclone;
                   if ($uname && $udom) {
                       unless (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
                           my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
                           if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) {
                               if ($currclonecrs{'cloneable'} eq '') {
                                   $currclonecrs{'cloneable'} = $clone_crs;
                               } else {
                                   $currclonecrs{'cloneable'} .= ','.$clone_crs;
                               }
                               &Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname);
                           }
                       }
                   }
               }
           }
           foreach my $oldclone (@$oldcloner) {
               if (!grep/^$oldclone$/,@allowclone) {
                   ($uname,$udom) = split/:/,$oldclone;
                   if ($uname && $udom) {
                       unless (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
                           my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
                           my %newclonecrs = ();
                           if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) {
                               if ($currclonecrs{'cloneable'} =~ /,/) {
                                   my @currclonecrs = split/,/,$currclonecrs{'cloneable'};
                                   foreach (@currclonecrs) {
                                       unless ($_ eq $clone_crs) {
                                           $newclonecrs{'cloneable'} .= $_.',';
                                       }
                                   }
                                   $newclonecrs{'cloneable'} =~ s/,$//;
                               } else {
                                   $newclonecrs{'cloneable'} = '';
                               }
                               &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname);
                           }
                       }
                   }
               }
           }
       }
   }
   
   ##################################################
 ##################################################  ##################################################
   
 =pod  =pod

Removed from v.1.175  
changed lines
  Added in v.1.181


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