--- loncom/interface/domainprefs.pm 2019/01/27 14:39:48 1.346 +++ loncom/interface/domainprefs.pm 2019/04/01 17:24:45 1.351 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.346 2019/01/27 14:39:48 raeburn Exp $ +# $Id: domainprefs.pm,v 1.351 2019/04/01 17:24:45 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -2876,7 +2876,7 @@ function toggleLTI(form,setting,item) { radioname = 'lti_mapcrs_'+item; divid = 'lti_crsfield_'+item; } else { - radioname = 'lti_passbackformat_'+item; + radioname = 'lti_passback_'+item; divid = 'lti_passback_'+item; } var num = form.elements[radioname].length; @@ -3383,7 +3383,7 @@ sub print_contacts { } } elsif ($position eq 'middle') { @mailings = ('errormail','packagesmail','lonstatusmail','requestsmail', - 'updatesmail','idconflictsmail'); + 'updatesmail','idconflictsmail','hostipmail'); foreach my $type (@mailings) { $otheremails{$type} = ''; } @@ -3466,6 +3466,7 @@ sub print_contacts { $checked{'requestsmail'}{'adminemail'} = ' checked="checked" '; $checked{'updatesmail'}{'adminemail'} = ' checked="checked" '; $checked{'idconflictsmail'}{'adminemail'} = ' checked="checked" '; + $checked{'hostipmail'}{'adminemail'} = ' checked="checked" '; } elsif ($position eq 'bottom') { $checked{'helpdeskmail'}{'supportemail'} = ' checked="checked" '; $checked{'otherdomsmail'}{'supportemail'} = ' checked="checked" '; @@ -5272,7 +5273,6 @@ sub print_coursedefaults { mysqltables => 'Lifetime (s) of "Temporary" MySQL tables (student performance data) on homeserver', ); my %staticdefaults = ( - texengine => 'MathJax', anonsurvey_threshold => 10, uploadquota => 500, postsubmit => 60, @@ -5286,7 +5286,7 @@ sub print_coursedefaults { 'canclone' => 'none', ); @toggles = ('canuse_pdfforms','uselcmath','usejsme'); - my $deftex = $staticdefaults{'texengine'}; + my $deftex = $Apache::lonnet::deftex; if (ref($settings) eq 'HASH') { if ($settings->{'texengine'}) { if ($settings->{'texengine'} =~ /^(MathJax|mimetex|tth)$/) { @@ -6786,6 +6786,7 @@ sub contact_titles { 'requestsmail' => 'E-mail from course requests requiring approval', 'updatesmail' => 'E-mail from nightly check of LON-CAPA module integrity/updates', 'idconflictsmail' => 'E-mail from bi-nightly check for multiple users sharing same student/employee ID', + 'hostipmail' => 'E-mail from nightly check of hostname/IP network changes', 'errorthreshold' => 'Error/warning threshold for status e-mail', 'errorsysmail' => 'Error threshold for e-mail to core group', 'errorweights' => 'Weights used to compute error count', @@ -7996,14 +7997,24 @@ sub scantron_javascript { // ' checked="checked"', + pad => ' checked="checked"', + rem => ' checked="checked"', + ); + my %optionsoff = ( + hdr => '', + pad => '', + rem => '', + ); my $currcsvsty = 'none'; - my ($datatable,%csvfields,%checked,%onclick); + my ($datatable,%csvfields,%checked,%onclick,%csvoptions); my @fields = &scantroncsv_fields(); my %titles = &scantronconfig_titles(); if (ref($settings) eq 'HASH') { @@ -8209,10 +8230,21 @@ sub print_scantronconfig { $checked{'dat'} = $is_checked; } if (ref($settings->{config}->{csv}) eq 'HASH') { - %csvfields = %{$settings->{config}->{csv}}; - if (keys(%csvfields) > 0) { - $checked{'csv'} = $is_checked; - $currcsvsty = 'inline-block'; + if (ref($settings->{config}->{csv}->{fields}) eq 'HASH') { + %csvfields = %{$settings->{config}->{csv}->{fields}}; + if (keys(%csvfields) > 0) { + $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 { @@ -8229,7 +8261,7 @@ sub print_scantronconfig { my $id; if ($item eq 'csv') { $id = 'id="scantronconfcsv" '; - } + } $datatable .= ''.(' 'x3); if ($item eq 'csv') { @@ -8258,7 +8290,16 @@ sub print_scantronconfig { } $datatable .= ''; } - $datatable .= ''; + $datatable .= ''. + '
'. + ''.&mt('CSV Options').''; + foreach my $option ('hdr','pad','rem') { + $datatable .= ''.$titles{$option}.':'. + ''.(' 'x2)."\n". + '
'; + } + $datatable .= '
'; $itemcount ++; } } @@ -8271,6 +8312,9 @@ sub scantronconfig_titles { return &Apache::lonlocal::texthash( dat => 'Standard format (.dat)', csv => 'Comma separated values (.csv)', + hdr => 'Remove first line in file (contains column titles)', + pad => 'Prepend 0s to PaperID', + rem => 'Remove leading spaces (except Question Response columns)', CODE => 'CODE', ID => 'Student ID', PaperID => 'Paper ID', @@ -12993,7 +13037,7 @@ sub modify_contacts { my (%others,%to,%bcc,%includestr,%includeloc); my @contacts = ('supportemail','adminemail'); my @mailings = ('errormail','packagesmail','helpdeskmail','otherdomsmail', - 'lonstatusmail','requestsmail','updatesmail','idconflictsmail'); + 'lonstatusmail','requestsmail','updatesmail','idconflictsmail','hostipmail'); my @toggles = ('reporterrors','reportupdates','reportstatus'); my @lonstatus = ('threshold','sysmail','weights','excluded'); my ($fields,$fieldtitles,$fieldoptions,$possoptions) = &helpform_fields(); @@ -13282,6 +13326,7 @@ sub modify_contacts { $default{'lonstatusmail'} = 'adminemail'; $default{'requestsmail'} = 'adminemail'; $default{'updatesmail'} = 'adminemail'; + $default{'hostipmail'} = 'adminemail'; foreach my $item (@contacts) { if ($to{$item} ne $default{$item}) { $changes{$item} = 1; @@ -15137,18 +15182,20 @@ sub modify_scantron { if ($env{'form.scantronformat_del'}) { $confhash{'scantron'}{'scantronformat'} = ''; $changes{'scantronformat'} = 1; + } else { + $confhash{'scantron'}{'scantronformat'} = $domconfig{'scantron'}{'scantronformat'}; } } } + my @options = ('hdr','pad','rem'); my @fields = &scantroncsv_fields(); 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); if (grep(/^dat$/,@formats)) { $confhash{'scantron'}{config}{dat} = 1; $newdat = 1; } else { - $confhash{'scantron'}{config}{dat} = 0; $newdat = 0; } if (grep(/^csv$/,@formats)) { @@ -15157,21 +15204,30 @@ sub modify_scantron { if ($env{'form.scantronconfig_csv_'.$field} =~ /^(\d+)$/) { my $posscol = $1; if (($posscol < 20) && (!$bynum{$posscol})) { - $confhash{'scantron'}{config}{csv}{$field} = $posscol; + $confhash{'scantron'}{config}{csv}{fields}{$field} = $posscol; $bynum{$posscol} = $field; $newcol{$field} = $posscol; } } } + if (keys(%newcol)) { + foreach my $option (@options) { + if ($env{'form.scantroncsv_'.$option}) { + $confhash{'scantron'}{config}{csv}{options}{$option} = 1; + } + } + } } $currdat = 1; if (ref($domconfig{'scantron'}) eq 'HASH') { if (ref($domconfig{'scantron'}{'config'}) eq 'HASH') { - if (!$domconfig{'scantron'}{'config'}{'dat'}) { + unless (exists($domconfig{'scantron'}{'config'}{'dat'})) { $currdat = 0; } 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'}}; + } } } } @@ -15183,7 +15239,7 @@ sub modify_scantron { if ($currcol{$field} ne $newcol{$field}) { $changes{'config'} = 1; last; - } + } } elsif ($newcol{$field} ne '') { $changes{'config'} = 1; last; @@ -15204,21 +15260,34 @@ sub modify_scantron { $resulttext .= '
  • '.&mt('Custom bubblesheet format file ([_1]) uploaded for use with courses in this domain.',$custom).'
  • '; } } - if ($changes{'config'}) { + if ($changes{'config'}) { if (ref($confhash{'scantron'}{'config'}) eq 'HASH') { if ($confhash{'scantron'}{'config'}{'dat'}) { $resulttext .= '
  • '.&mt('Bubblesheet data upload formats includes .dat format').'
  • '; } if (ref($confhash{'scantron'}{'config'}{'csv'}) eq 'HASH') { - if (keys(%{$confhash{'scantron'}{'config'}{'csv'}})) { - '
  • '.&mt('Bubblesheet data upload formats includes .csv format, with following fields/column numbers supported:').'
  • '; } } } else { @@ -16066,7 +16135,6 @@ sub modify_coursedefaults { $defaultshash{'coursedefaults'}{$setting}{$type} = $newdef; } if ($currdef ne $newdef) { - my $staticdef; if ($item eq 'anonsurvey_threshold') { unless (($currdef eq '') && ($newdef == $staticdefaults{$item})) { $changes{$item} = 1; @@ -16082,11 +16150,12 @@ sub modify_coursedefaults { my $texengine; if ($env{'form.texengine'} =~ /^(MathJax|mimetex|tth)$/) { $texengine = $env{'form.texengine'}; - if ($defaultshash{'coursedefaults'}{'texengine'} eq '') { - unless ($texengine eq 'MathJax') { + my $currdef = $domconfig{'coursedefaults'}{'texengine'}; + if ($currdef eq '') { + unless ($texengine eq $Apache::lonnet::deftex) { $changes{'texengine'} = 1; } - } elsif ($defaultshash{'coursedefaults'}{'texengine'} ne $texengine) { + } elsif ($currdef ne $texengine) { $changes{'texengine'} = 1; } }