version 1.346, 2019/01/27 14:39:48
|
version 1.347, 2019/01/28 21:36:45
|
Line 7996 sub scantron_javascript {
|
Line 7996 sub scantron_javascript {
|
// <![CDATA[ |
// <![CDATA[ |
|
|
function toggleScantron(form) { |
function toggleScantron(form) { |
|
var csvfieldset = new Array(); |
if (document.getElementById('scantroncsv_cols')) { |
if (document.getElementById('scantroncsv_cols')) { |
var csvfieldset = document.getElementById('scantroncsv_cols'); |
csvfieldset.push(document.getElementById('scantroncsv_cols')); |
|
} |
|
if (document.getElementById('scantroncsv_options')) { |
|
csvfieldset.push(document.getElementById('scantroncsv_options')); |
|
} |
|
if (csvfieldset.length) { |
if (document.getElementById('scantronconfcsv')) { |
if (document.getElementById('scantronconfcsv')) { |
var scantroncsv = document.getElementById('scantronconfcsv'); |
var scantroncsv = document.getElementById('scantronconfcsv'); |
if (scantroncsv.checked) { |
if (scantroncsv.checked) { |
csvfieldset.style.display = 'inline-block'; |
for (var i=0; i<csvfieldset.length; i++) { |
|
csvfieldset[i].style.display = 'block'; |
|
} |
} else { |
} else { |
csvfieldset.style.display = 'none'; |
for (var i=0; i<csvfieldset.length; i++) { |
|
csvfieldset[i].style.display = 'none'; |
|
} |
var csvselects = document.getElementsByClassName('scantronconfig_csv'); |
var csvselects = document.getElementsByClassName('scantronconfig_csv'); |
if (csvselects.length) { |
if (csvselects.length) { |
for (var j=0; j<csvselects.length; j++) { |
for (var j=0; j<csvselects.length; j++) { |
Line 8199 sub print_scantronconfig {
|
Line 8209 sub print_scantronconfig {
|
my ($dom,$settings,$rowtotal) = @_; |
my ($dom,$settings,$rowtotal) = @_; |
my $itemcount = 2; |
my $itemcount = 2; |
my $is_checked = ' checked="checked"'; |
my $is_checked = ' checked="checked"'; |
|
my %optionson = ( |
|
hdr => ' checked="checked"', |
|
pad => ' checked="checked"', |
|
rem => ' checked="checked"', |
|
); |
|
my %optionsoff = ( |
|
hdr => '', |
|
pad => '', |
|
rem => '', |
|
); |
my $currcsvsty = 'none'; |
my $currcsvsty = 'none'; |
my ($datatable,%csvfields,%checked,%onclick); |
my ($datatable,%csvfields,%checked,%onclick,%csvoptions); |
my @fields = &scantroncsv_fields(); |
my @fields = &scantroncsv_fields(); |
my %titles = &scantronconfig_titles(); |
my %titles = &scantronconfig_titles(); |
if (ref($settings) eq 'HASH') { |
if (ref($settings) eq 'HASH') { |
Line 8209 sub print_scantronconfig {
|
Line 8229 sub print_scantronconfig {
|
$checked{'dat'} = $is_checked; |
$checked{'dat'} = $is_checked; |
} |
} |
if (ref($settings->{config}->{csv}) eq 'HASH') { |
if (ref($settings->{config}->{csv}) eq 'HASH') { |
%csvfields = %{$settings->{config}->{csv}}; |
if (ref($settings->{config}->{csv}->{fields}) eq 'HASH') { |
if (keys(%csvfields) > 0) { |
%csvfields = %{$settings->{config}->{csv}->{fields}}; |
$checked{'csv'} = $is_checked; |
if (keys(%csvfields) > 0) { |
$currcsvsty = 'inline-block'; |
$checked{'csv'} = $is_checked; |
|
$currcsvsty = 'block'; |
|
} |
|
} |
|
if (ref($settings->{config}->{csv}->{options}) eq 'HASH') { |
|
%csvoptions = %{$settings->{config}->{csv}->{options}}; |
|
foreach my $option (keys(%optionson)) { |
|
unless ($csvoptions{$option}) { |
|
$optionsoff{$option} = $optionson{$option}; |
|
$optionson{$option} = ''; |
|
} |
|
} |
} |
} |
} |
} |
} else { |
} else { |
Line 8229 sub print_scantronconfig {
|
Line 8260 sub print_scantronconfig {
|
my $id; |
my $id; |
if ($item eq 'csv') { |
if ($item eq 'csv') { |
$id = 'id="scantronconfcsv" '; |
$id = 'id="scantronconfcsv" '; |
} |
} |
$datatable .= '<label><input type="checkbox" name="scantronconfig" '.$id.'value="'.$item.'"'.$checked{$item}.$onclick{$item}.' />'. |
$datatable .= '<label><input type="checkbox" name="scantronconfig" '.$id.'value="'.$item.'"'.$checked{$item}.$onclick{$item}.' />'. |
$titles{$item}.'</label>'.(' 'x3); |
$titles{$item}.'</label>'.(' 'x3); |
if ($item eq 'csv') { |
if ($item eq 'csv') { |
Line 8258 sub print_scantronconfig {
|
Line 8289 sub print_scantronconfig {
|
} |
} |
$datatable .= '</select></td></tr>'; |
$datatable .= '</select></td></tr>'; |
} |
} |
$datatable .= '</table></fieldset>'; |
$datatable .= '</table></fieldset>'. |
|
'<fieldset style="display:'.$currcsvsty.'" id="scantroncsv_options">'. |
|
'<legend>'.&mt('CSV Options').'</legend>'; |
|
foreach my $option ('hdr','pad','rem') { |
|
$datatable .= '<span class="LC_nobreak">'.$titles{$option}.':'. |
|
'<label><input type="radio" name="scantroncsv_'.$option.'" value="1"'.$optionson{$option}.' />'. |
|
&mt('Yes').'</label>'.(' 'x2)."\n". |
|
'<label><input type="radio" name="scantroncsv_'.$option.'" value="0"'.$optionsoff{$option}.' />'.&mt('No').'</label></span><br />'; |
|
} |
|
$datatable .= '</fieldset>'; |
$itemcount ++; |
$itemcount ++; |
} |
} |
} |
} |
Line 8271 sub scantronconfig_titles {
|
Line 8311 sub scantronconfig_titles {
|
return &Apache::lonlocal::texthash( |
return &Apache::lonlocal::texthash( |
dat => 'Standard format (.dat)', |
dat => 'Standard format (.dat)', |
csv => 'Comma separated values (.csv)', |
csv => 'Comma separated values (.csv)', |
|
hdr => 'Remove first line in file (contains column titles)', |
|
pad => 'Prepend 0s to PaperID', |
|
rem => 'Remove leading spaces (except Q columns)', |
CODE => 'CODE', |
CODE => 'CODE', |
ID => 'Student ID', |
ID => 'Student ID', |
PaperID => 'Paper ID', |
PaperID => 'Paper ID', |
Line 15137 sub modify_scantron {
|
Line 15180 sub modify_scantron {
|
if ($env{'form.scantronformat_del'}) { |
if ($env{'form.scantronformat_del'}) { |
$confhash{'scantron'}{'scantronformat'} = ''; |
$confhash{'scantron'}{'scantronformat'} = ''; |
$changes{'scantronformat'} = 1; |
$changes{'scantronformat'} = 1; |
|
} else { |
|
$confhash{'scantron'}{'scantronformat'} = $domconfig{'scantron'}{'scantronformat'}; |
} |
} |
} |
} |
} |
} |
|
my @options = ('hdr','pad','rem'); |
my @fields = &scantroncsv_fields(); |
my @fields = &scantroncsv_fields(); |
my %titles = &scantronconfig_titles(); |
my %titles = &scantronconfig_titles(); |
my @formats = &Apache::loncommon::get_env_multiple('form.scantronformat'); |
my @formats = &Apache::loncommon::get_env_multiple('form.scantronconfig'); |
my ($newdat,$currdat,%newcol,%currcol); |
my ($newdat,$currdat,%newcol,%currcol); |
if (grep(/^dat$/,@formats)) { |
if (grep(/^dat$/,@formats)) { |
$confhash{'scantron'}{config}{dat} = 1; |
$confhash{'scantron'}{config}{dat} = 1; |
$newdat = 1; |
$newdat = 1; |
} else { |
} else { |
$confhash{'scantron'}{config}{dat} = 0; |
|
$newdat = 0; |
$newdat = 0; |
} |
} |
if (grep(/^csv$/,@formats)) { |
if (grep(/^csv$/,@formats)) { |
Line 15157 sub modify_scantron {
|
Line 15202 sub modify_scantron {
|
if ($env{'form.scantronconfig_csv_'.$field} =~ /^(\d+)$/) { |
if ($env{'form.scantronconfig_csv_'.$field} =~ /^(\d+)$/) { |
my $posscol = $1; |
my $posscol = $1; |
if (($posscol < 20) && (!$bynum{$posscol})) { |
if (($posscol < 20) && (!$bynum{$posscol})) { |
$confhash{'scantron'}{config}{csv}{$field} = $posscol; |
$confhash{'scantron'}{config}{csv}{fields}{$field} = $posscol; |
$bynum{$posscol} = $field; |
$bynum{$posscol} = $field; |
$newcol{$field} = $posscol; |
$newcol{$field} = $posscol; |
} |
} |
} |
} |
} |
} |
|
if (keys(%newcol)) { |
|
foreach my $option (@options) { |
|
if ($env{'form.scantroncsv_'.$option}) { |
|
$confhash{'scantron'}{config}{csv}{options}{$option} = 1; |
|
} |
|
} |
|
} |
} |
} |
$currdat = 1; |
$currdat = 1; |
if (ref($domconfig{'scantron'}) eq 'HASH') { |
if (ref($domconfig{'scantron'}) eq 'HASH') { |
if (ref($domconfig{'scantron'}{'config'}) eq 'HASH') { |
if (ref($domconfig{'scantron'}{'config'}) eq 'HASH') { |
if (!$domconfig{'scantron'}{'config'}{'dat'}) { |
unless (exists($domconfig{'scantron'}{'config'}{'dat'})) { |
$currdat = 0; |
$currdat = 0; |
} |
} |
if (ref($domconfig{'scantron'}{'config'}{'csv'}) eq 'HASH') { |
if (ref($domconfig{'scantron'}{'config'}{'csv'}) eq 'HASH') { |
%currcol = %{$domconfig{'scantron'}{'config'}{'csv'}}; |
if (ref($domconfig{'scantron'}{'config'}{'csv'}{'fields'}) eq 'HASH') { |
|
%currcol = %{$domconfig{'scantron'}{'config'}{'csv'}{'fields'}}; |
|
} |
} |
} |
} |
} |
} |
} |
Line 15183 sub modify_scantron {
|
Line 15237 sub modify_scantron {
|
if ($currcol{$field} ne $newcol{$field}) { |
if ($currcol{$field} ne $newcol{$field}) { |
$changes{'config'} = 1; |
$changes{'config'} = 1; |
last; |
last; |
} |
} |
} elsif ($newcol{$field} ne '') { |
} elsif ($newcol{$field} ne '') { |
$changes{'config'} = 1; |
$changes{'config'} = 1; |
last; |
last; |
Line 15204 sub modify_scantron {
|
Line 15258 sub modify_scantron {
|
$resulttext .= '<li>'.&mt('Custom bubblesheet format file ([_1]) uploaded for use with courses in this domain.',$custom).'</li>'; |
$resulttext .= '<li>'.&mt('Custom bubblesheet format file ([_1]) uploaded for use with courses in this domain.',$custom).'</li>'; |
} |
} |
} |
} |
if ($changes{'config'}) { |
if ($changes{'config'}) { |
if (ref($confhash{'scantron'}{'config'}) eq 'HASH') { |
if (ref($confhash{'scantron'}{'config'}) eq 'HASH') { |
if ($confhash{'scantron'}{'config'}{'dat'}) { |
if ($confhash{'scantron'}{'config'}{'dat'}) { |
$resulttext .= '<li>'.&mt('Bubblesheet data upload formats includes .dat format').'</li>'; |
$resulttext .= '<li>'.&mt('Bubblesheet data upload formats includes .dat format').'</li>'; |
} |
} |
if (ref($confhash{'scantron'}{'config'}{'csv'}) eq 'HASH') { |
if (ref($confhash{'scantron'}{'config'}{'csv'}) eq 'HASH') { |
if (keys(%{$confhash{'scantron'}{'config'}{'csv'}})) { |
if (ref($confhash{'scantron'}{'config'}{'csv'}{'fields'}) eq 'HASH') { |
'<li>'.&mt('Bubblesheet data upload formats includes .csv format, with following fields/column numbers supported:').'<ul>'; |
if (keys(%{$confhash{'scantron'}{'config'}{'csv'}{'fields'}})) { |
foreach my $field (@fields) { |
$resulttext .= '<li>'.&mt('Bubblesheet data upload formats includes .csv format, with following fields/column numbers supported:').'<ul>'; |
if ($confhash{'scantron'}{'config'}{'csv'}{$field} ne '') { |
foreach my $field (@fields) { |
my $showcol = $confhash{'scantron'}{'config'}{'csv'}{$field} + 1; |
if ($confhash{'scantron'}{'config'}{'csv'}{'fields'}{$field} ne '') { |
$resulttext .= '<li>'.$titles{$field}.': '.$showcol.'</li>'; |
my $showcol = $confhash{'scantron'}{'config'}{'csv'}{'fields'}{$field} + 1; |
|
$resulttext .= '<li>'.$titles{$field}.': '.$showcol.'</li>'; |
|
} |
|
} |
|
$resulttext .= '</ul></li>'; |
|
if (ref($confhash{'scantron'}{'config'}{'csv'}{'options'}) eq 'HASH') { |
|
if (keys(%{$confhash{'scantron'}{'config'}{'csv'}{'options'}})) { |
|
$resulttext .= '<li>'.&mt('Bubblesheet data upload formats includes .csv format, with following options:').'<ul>'; |
|
foreach my $option (@options) { |
|
if ($confhash{'scantron'}{'config'}{'csv'}{'options'}{$option} ne '') { |
|
$resulttext .= '<li>'.$titles{$option}.'</li>'; |
|
} |
|
} |
|
$resulttext .= '</ul></li>'; |
|
} |
} |
} |
} |
} |
$resulttext .= '</ul></li>'; |
|
} |
} |
} |
} |
} else { |
} else { |