--- loncom/homework/grades.pm 2019/01/27 23:16:25 1.755 +++ loncom/homework/grades.pm 2019/02/06 05:46:51 1.758 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.755 2019/01/27 23:16:25 raeburn Exp $ +# $Id: grades.pm,v 1.758 2019/02/06 05:46:51 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -5902,7 +5902,6 @@ sub scantron_selectphase { $r->print('
'); - my $default_form_data=&defaultFormData($symb); my $cdom= $env{'course.'.$env{'request.course.id'}.'.domain'}; my $cnum= $env{'course.'.$env{'request.course.id'}.'.num'}; my $alertmsg = &mt('Please use the browse button to select a file from your local directory.'); @@ -5915,7 +5914,7 @@ sub scantron_selectphase { return false; } formname.submit(); - }'.$formatjs)); + }'."\n".$formatjs)); $r->print('
'.$default_form_data.' @@ -9099,20 +9098,23 @@ 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)) { @@ -9125,7 +9127,7 @@ function toggleScantab(form) { if (chosen == 'dat') { document.getElementById(divid).style.display = 'none'; } else if (chosen == 'csv') { - document.getElementById(divid).style.display = 'inline-block'; + document.getElementById(divid).style.display = 'block'; } } } @@ -9135,22 +9137,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('Bubblesheet type'); + $formatoptions = &scantron_scantab(); + } } } } @@ -9192,15 +9197,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; + } } } } @@ -11016,7 +11025,7 @@ Side Effects: None. $r - Apache request object $i - number of the current scanline $scan_record - hash ref as returned from &scantron_parse_scanline() - $scan_config - hash ref as returned from &get_scantron_config() + $scan_config - hash ref as returned from &Apache::lonnet::get_scantron_config() $line - full contents of the current scanline $error - error condition, valid values are 'incorrectCODE', 'duplicateCODE',