--- loncom/homework/grades.pm 2019/01/27 14:39:55 1.754 +++ loncom/homework/grades.pm 2019/01/28 21:36:53 1.756 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.754 2019/01/27 14:39:55 raeburn Exp $ +# $Id: grades.pm,v 1.756 2019/01/28 21:36:53 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -5915,7 +5915,7 @@ sub scantron_selectphase { return false; } formname.submit(); - }'.$formatjs)); + }'."\n".$formatjs)); $r->print('
'.$default_form_data.' @@ -8684,7 +8684,7 @@ SCANTRONFORM return ''; # Dunno why the other returns return '' rather than just returning. } - my %lettdig = &letter_to_digits(); + my %lettdig = &Apache::lonnet::letter_to_digits(); my $numletts = scalar(keys(%lettdig)); my %orderedforcode; @@ -9099,20 +9099,21 @@ END if (keys(%{$domconfig{'scantron'}{'config'}}) > 1) { if (($domconfig{'scantron'}{'config'}{'dat'}) && (ref($domconfig{'scantron'}{'config'}{'csv'}) eq 'HASH')) { - if (keys(%{$domconfig{'scantron'}{'config'}{'csv'}})) { - my ($onclick,$formatextra,$singleline); - my @lines = &Apache::lonnet::get_scantronformat_file(); - my $count = 0; - foreach my $line (@lines) { - next if ($line =~ /^#/); - $singleline = $line; - $count ++; - } - if ($count > 1) { - $formatextra = ''; - $onclick = ' onclick="toggleScantab(this.form);"'; - $formatjs = <<"END"; + if (ref($domconfig{'scantron'}{'config'}{'csv'}{'fields'}) eq 'HASH') { + if (keys(%{$domconfig{'scantron'}{'config'}{'csv'}{'fields'}})) { + my ($onclick,$formatextra,$singleline); + my @lines = &Apache::lonnet::get_scantronformat_file(); + my $count = 0; + foreach my $line (@lines) { + next if ($line =~ /^#/); + $singleline = $line; + $count ++; + } + if ($count > 1) { + $formatextra = ''; + $onclick = ' onclick="toggleScantab(this.form);"'; + $formatjs = <<"END"; function toggleScantab(form) { var divid = 'bubbletype'; if (document.getElementById(divid)) { @@ -9135,22 +9136,25 @@ function toggleScantab(form) { } END - } elsif ($count == 1) { - my $formatname = (split(/:/,$singleline,2))[0]; - $formatextra = ''; + } elsif ($count == 1) { + my $formatname = (split(/:/,$singleline,2))[0]; + $formatextra = ''; + } + $formattitle = &mt('File format'); + $formatoptions = ''.(' 'x2). + ''.$formatextra; } - $formattitle = &mt('File format'); - $formatoptions = ''.(' 'x2). - ''.$formatextra; } } } elsif (keys(%{$domconfig{'scantron'}{'config'}}) == 1) { - if (keys(%{$domconfig{'scantron'}{'config'}{'csv'}})) { - $formattitle = &mt('Format of bubblesheet data file:'); - $formatoptions = &scantron_scantab(); + if (ref($domconfig{'scantron'}{'config'}{'csv'}{'fields'}) eq 'HASH') { + if (keys(%{$domconfig{'scantron'}{'config'}{'csv'}{'fields'}})) { + $formattitle = &mt('Format of bubblesheet data file:'); + $formatoptions = &scantron_scantab(); + } } } } @@ -9192,15 +9196,19 @@ sub scantron_upload_scantron_data_save { if (@possibles > 1) { if ($env{'form.fileformat'} eq 'csv') { if (ref($domconfig{'scantron'}{'config'}{'csv'}) eq 'HASH') { - if (keys(%{$domconfig{'scantron'}{'config'}{'csv'}}) > 1) { - $is_csv = 1; + if (ref($domconfig{'scantron'}{'config'}{'csv'}{'fields'}) eq 'HASH') { + if (keys(%{$domconfig{'scantron'}{'config'}{'csv'}{'fields'}}) > 1) { + $is_csv = 1; + } } } } } elsif (@possibles == 1) { if (ref($domconfig{'scantron'}{'config'}{'csv'}) eq 'HASH') { - if (keys(%{$domconfig{'scantron'}{'config'}{'csv'}}) > 1) { - $is_csv = 1; + if (ref($domconfig{'scantron'}{'config'}{'csv'}{'fields'}) eq 'HASH') { + if (keys(%{$domconfig{'scantron'}{'config'}{'csv'}{'fields'}}) > 1) { + $is_csv = 1; + } } } } @@ -9396,7 +9404,7 @@ sub checkscantron_results { my ($r,$symb) = @_; if (!$symb) {return '';} my $cid = $env{'request.course.id'}; - my %lettdig = &letter_to_digits(); + my %lettdig = &Apache::lonnet::letter_to_digits(); my $numletts = scalar(keys(%lettdig)); my $cnum = $env{'course.'.$cid.'.num'}; my $cdom = $env{'course.'.$cid.'.domain'}; @@ -9727,22 +9735,6 @@ sub verify_scantron_grading { return ($counter,$record); } -sub letter_to_digits { - my %lettdig = ( - A => 1, - B => 2, - C => 3, - D => 4, - E => 5, - F => 6, - G => 7, - H => 8, - I => 9, - J => 0, - ); - return %lettdig; -} - #-------- end of section for handling grading scantron forms ------- #