Diff for /loncom/interface/lonprintout.pm between versions 1.386 and 1.389

version 1.386, 2005/08/16 10:25:15 version 1.389, 2005/08/29 10:06:52
Line 1 Line 1
 #  The LearningOnline Network  # The LearningOnline Network
 # Printout  # Printout
 #  #
 # $Id$  # $Id$
Line 87  sub letters_to_num { Line 87  sub letters_to_num {
 sub is_valid_numeric_code {  sub is_valid_numeric_code {
     my ($value, $num_digits) = @_;      my ($value, $num_digits) = @_;
     #   Remove leading/trailing whitespace;      #   Remove leading/trailing whitespace;
     $value =~ s/^\s*//;      $value =~ s/^\s*//g;
     $value =~ s/\s*$//;      $value =~ s/\s*$//g;
           
     #  All digits?      #  All digits?
     if ($value =~ /^[0-9]+$/) {      if ($value !~ /^[0-9]+$/) {
  return "Numeric code $value has invalid characters - must only be digits";   return "Numeric code $value has invalid characters - must only be digits";
     }      }
     if (length($value) != $num_digits) {      if (length($value) != $num_digits) {
Line 1363  ENDPART Line 1363  ENDPART
  my $code_name=$helper->{'VARS'}->{'ANON_CODE_STORAGE_NAME'};   my $code_name=$helper->{'VARS'}->{'ANON_CODE_STORAGE_NAME'};
  my $old_name=$helper->{'VARS'}->{'REUSE_OLD_CODES'};   my $old_name=$helper->{'VARS'}->{'REUSE_OLD_CODES'};
  my $single_code = $helper->{'VARS'}->{'SINGLE_CODE'};   my $single_code = $helper->{'VARS'}->{'SINGLE_CODE'};
    my $selected_code = $helper->{'VARS'}->{'CODE_SELECTED_FROM_LIST'};
   
  my $code_option=$helper->{'VARS'}->{'CODE_OPTION'};   my $code_option=$helper->{'VARS'}->{'CODE_OPTION'};
  open(FH,$Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab');   open(FH,$Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab');
  my ($code_type,$code_length)=('letter',6);   my ($code_type,$code_length)=('letter',6);
Line 1384  ENDPART Line 1386  ENDPART
      $code_type=$result{"type\0$old_name"};       $code_type=$result{"type\0$old_name"};
      @allcodes=split(',',$result{$old_name});       @allcodes=split(',',$result{$old_name});
      $num_todo=scalar(@allcodes);       $num_todo=scalar(@allcodes);
    } elsif ($selected_code) { # Selection value is always numeric.
        $num_todo = 1;
        @allcodes = ($selected_code);
  } elsif ($single_code) {   } elsif ($single_code) {
   
        $num_todo    = 1; # Unconditionally one code to do.
      # If an alpha code have to convert to numbers so it can be       # If an alpha code have to convert to numbers so it can be
      # converted back to letters again :-)       # converted back to letters again :-)
      #       #
      if ($code_type ne 'number') {       if ($code_type ne 'number') {
  $single_code = &letters_to_num($single_code);   $single_code = &letters_to_num($single_code);
  $num_todo    = 1;  
      }       }
      @allcodes = ($single_code);       @allcodes = ($single_code);
  } else {   } else {
Line 2088  CHOOSE_STUDENTS Line 2093  CHOOSE_STUDENTS
     if ($name =~ /^type\0/) { next; }      if ($name =~ /^type\0/) { next; }
     $namechoice.='<choice computer="'.$name.'">'.$name.'</choice>';      $namechoice.='<choice computer="'.$name.'">'.$name.'</choice>';
  }   }
   
   
           my %all_codes = &Apache::lonnet::get('CODEs',
        \@names, $cdom,$cnum);
    my %code_values;
    my @all_code_array;
    foreach my $key (keys %all_codes) {
       %code_values = &Apache::grades::get_codes($key, $cdom, $cnum);
       foreach my $key (keys %code_values) {
    push (@all_code_array, "$key");
       }
    }
   
    my $code_selection = "<choice></choice>\n";
    foreach my $code (sort {uc($a) cmp uc($b)} @all_code_array) {
       my $choice  = $code;
       if ($code =~ /^[A-Z]+$/) { # Alpha code
    $choice = &letters_to_num($code);
       }
       $code_selection .= '   <choice computer="'.$choice.'">'.$code."</choice>\n";
    }
  open(FH,$Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab');   open(FH,$Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab');
  my $codechoice='';   my $codechoice='';
  foreach my $line (<FH>) {   foreach my $line (<FH>) {
Line 2110  CHOOSE_STUDENTS Line 2136  CHOOSE_STUDENTS
        <validator>         <validator>
  if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) < 1) &&   if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) < 1) &&
     !\$helper->{'VARS'}{'REUSE_OLD_CODES'}                &&      !\$helper->{'VARS'}{'REUSE_OLD_CODES'}                &&
             !\$helper->{'VARS'}{'SINGLE_CODE'}) {              !\$helper->{'VARS'}{'SINGLE_CODE'}                    &&
       !\$helper->{'VARS'}{'CODE_SELECTED_FROM_LIST'}) {
     return "You need to specify the number of assignments to print";      return "You need to specify the number of assignments to print";
  }   }
  return undef;   return undef;
Line 2121  CHOOSE_STUDENTS Line 2148  CHOOSE_STUDENTS
     <string variable="SINGLE_CODE" size="10" defaultvalue="zzzz">      <string variable="SINGLE_CODE" size="10" defaultvalue="zzzz">
         <validator>          <validator>
    if(!\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}           &&     if(!\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}           &&
       !\$helper->{'VARS'}{'REUSE_OLD_CODES'}) {        !\$helper->{'VARS'}{'REUSE_OLD_CODES'}                 &&
         !\$helper->{'VARS'}{'CODE_SELECTED_FROM_LIST'}) {
       return &Apache::lonprintout::is_code_valid(\$helper->{'VARS'}{'SINGLE_CODE'},        return &Apache::lonprintout::is_code_valid(\$helper->{'VARS'}{'SINGLE_CODE'},
       \$helper->{'VARS'}{'CODE_OPTION'});        \$helper->{'VARS'}{'CODE_OPTION'});
    } else {     } else {
Line 2130  CHOOSE_STUDENTS Line 2158  CHOOSE_STUDENTS
         </validator>          </validator>
     </string>      </string>
     <message></td></tr><tr><td></message>      <message></td></tr><tr><td></message>
       <message><b>Choose single code from list</b></message>
       <message></td><td></message>
       <dropdown variable="CODE_SELECTED_FROM_LIST" multichoice="0" allowempty="0">
       $code_selection
       </dropdown>
       <message></td></tr><tr><td></message>
     <message><b>Names to store the CODEs under for later:</b></message>      <message><b>Names to store the CODEs under for later:</b></message>
     <message></td><td></message>      <message></td><td></message>
     <string variable="ANON_CODE_STORAGE_NAME" maxlength="50" size="20" />      <string variable="ANON_CODE_STORAGE_NAME" maxlength="50" size="20" />
Line 2197  CHOOSE_STUDENTS1 Line 2231  CHOOSE_STUDENTS1
        <validator>         <validator>
  if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) < 1) &&   if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) < 1) &&
     !\$helper->{'VARS'}{'REUSE_OLD_CODES'}                &&      !\$helper->{'VARS'}{'REUSE_OLD_CODES'}                &&
     !\$helper->{'VARS'}{'SINGLE_CODE'}) {      !\$helper->{'VARS'}{'SINGLE_CODE'}                   &&
       !\$helper->{'VARS'}{'CODE_SELECTED_FROM_LIST'}) {
     return "You need to specify the number of assignments to print";      return "You need to specify the number of assignments to print";
  }   }
  return undef;   return undef;
Line 2208  CHOOSE_STUDENTS1 Line 2243  CHOOSE_STUDENTS1
     <string variable="SINGLE_CODE" size="10" defaultvalue="zzzz">      <string variable="SINGLE_CODE" size="10" defaultvalue="zzzz">
         <validator>          <validator>
    if(!\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}           &&     if(!\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}           &&
       !\$helper->{'VARS'}{'REUSE_OLD_CODES'}) {        !\$helper->{'VARS'}{'REUSE_OLD_CODES'}                 &&
         !\$helper->{'VARS'}{'CODE_SELECTED_FROM_LIST'}) {
       return &Apache::lonprintout::is_code_valid(\$helper->{'VARS'}{'SINGLE_CODE'},        return &Apache::lonprintout::is_code_valid(\$helper->{'VARS'}{'SINGLE_CODE'},
       \$helper->{'VARS'}{'CODE_OPTION'});        \$helper->{'VARS'}{'CODE_OPTION'});
    } else {     } else {
Line 2217  CHOOSE_STUDENTS1 Line 2253  CHOOSE_STUDENTS1
         </validator>          </validator>
     </string>      </string>
     <message></td></tr><tr><td></message>      <message></td></tr><tr><td></message>
       <message><b>Choose single code from list</b></message>
       <message></td><td></message>
       <dropdown variable="CODE_SELECTED_FROM_LIST" multichoice="0" allowempty="0">
       $code_selection
       </dropdown>
       <message></td></tr><tr><td></message>
     <message><b>Names to store the CODEs under for later:</b></message>      <message><b>Names to store the CODEs under for later:</b></message>
     <message></td><td></message>      <message></td><td></message>
     <string variable="ANON_CODE_STORAGE_NAME" maxlength="50" size="20" />      <string variable="ANON_CODE_STORAGE_NAME" maxlength="50" size="20" />

Removed from v.1.386  
changed lines
  Added in v.1.389


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