--- loncom/lonnet/perl/lonnet.pm 2019/01/27 23:16:36 1.1403 +++ loncom/lonnet/perl/lonnet.pm 2019/01/28 21:37:03 1.1404 @@ -1,7 +1,7 @@ # The LearningOnline Network # TCP networking package # -# $Id: lonnet.pm,v 1.1403 2019/01/27 23:16:36 raeburn Exp $ +# $Id: lonnet.pm,v 1.1404 2019/01/28 21:37:03 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -4361,7 +4361,13 @@ sub bubblesheet_converter { if ((&domain($cdom) ne '') && ($fullpath =~ m{^\Q$perlvar{'lonDocRoot'}/userfiles/$cdom/\E$match_courseid/scantron_orig}) && (-e $fullpath) && (ref($config) eq 'HASH') && ($format ne '')) { - my %csvcols = %{$config}; + my (%csvcols,%csvoptions); + if (ref($config->{'fields'}) eq 'HASH') { + %csvcols = %{$config->{'fields'}}; + } + if (ref($config->{'options'}) eq 'HASH') { + %csvoptions = %{$config->{'options'}}; + } my %csvbynum = reverse(%csvcols); my %scantronconf = &get_scantron_config($format,$cdom); if (keys(%scantronconf)) { @@ -4397,7 +4403,10 @@ sub bubblesheet_converter { my %lettdig = &letter_to_digits(); my %diglett = reverse(%lettdig); my $numletts = scalar(keys(%lettdig)); + my $num = 0; while (my $line=<$fh>) { + $num ++; + next if (($num == 1) && ($csvoptions{'hdr'} == 1)); $line =~ s{[\r\n]+$}{}; my %found; my @values = split(/,/,$line); @@ -4454,8 +4463,10 @@ sub bubblesheet_converter { $found{'FirstQuestion'} .= $values[$i]; } } elsif (exists($csvbynum{$i})) { - $values[$i] =~ s/^\s+//; - if ($csvbynum{$i} eq 'PaperID') { + if ($csvoptions{'rem'}) { + $values[$i] =~ s/^\s+//; + } + if (($csvbynum{$i} eq 'PaperID') && ($csvoptions{'pad'})) { while (length($values[$i]) < $scantronconf{$maplength{$csvbynum{$i}}}) { $values[$i] = '0'.$values[$i]; }