--- loncom/interface/domainprefs.pm 2008/06/30 15:56:23 1.59 +++ loncom/interface/domainprefs.pm 2008/07/06 22:14:46 1.60 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.59 2008/06/30 15:56:23 bisitz Exp $ +# $Id: domainprefs.pm,v 1.60 2008/07/06 22:14:46 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1847,7 +1847,8 @@ sub defaults_titles { sub print_scantronformat { my ($r,$dom,$confname,$settings,$rowtotal) = @_; my $itemcount = 1; - my ($datatable,$css_class,$scantronurl,$is_custom,%error,%scantronurls); + my ($datatable,$css_class,$scantronurl,$is_custom,%error,%scantronurls, + %confhash); my $switchserver = &check_switchserver($dom,$confname); my %lt = &Apache::lonlocal::texthash ( default => 'Default scantron format file error', @@ -1874,23 +1875,52 @@ sub print_scantronformat { ); my %md5chk; foreach my $type (keys(%legacyfile)) { - $md5chk{$type} = split(/ /,`md5sum $legacyfile{$type}`); - chop($md5chk{$type}); + ($md5chk{$type}) = split(/ /,`md5sum $legacyfile{$type}`); + chomp($md5chk{$type}); } if ($md5chk{'default'} ne $md5chk{'custom'}) { foreach my $type (keys(%legacyfile)) { - ($scantronurls{$type},$error{$type}) = + ($scantronurls{$type},my $error) = &legacy_scantronformat($r,$dom,$confname, $type,$legacyfile{$type}, $scantronurls{$type}, $scantronfiles{$type}); + if ($error ne '') { + $error{$type} = $error; + } + } + if (keys(%error) == 0) { + $is_custom = 1; + $confhash{'scantron'}{'scantronformat'} = + $scantronurls{'custom'}; + my $putresult = + &Apache::lonnet::put_dom('configuration', + \%confhash,$dom); + if ($putresult ne 'ok') { + $error{'custom'} = + ''. + &mt('An error occurred updating the domain configuration: [_1]',$putresult).''; + } } } else { - ($scantronurls{'default'},$error{'default'}) = + ($scantronurls{'default'},my $error) = &legacy_scantronformat($r,$dom,$confname, 'default',$legacyfile{'default'}, $scantronurls{'default'}, $scantronfiles{'default'}); + if ($error eq '') { + $confhash{'scantron'}{'scantronformat'} = ''; + my $putresult = + &Apache::lonnet::put_dom('configuration', + \%confhash,$dom); + if ($putresult ne 'ok') { + $error{'default'} = + ''. + &mt('An error occurred updating the domain configuration: [_1]',$putresult).''; + } + } else { + $error{'default'} = $error; + } } } } @@ -1911,7 +1941,11 @@ sub print_scantronformat { $scantronurl = $scantronurls{'default'}; } } else { - $scantronurl = $scantronurls{'default'}; + if ($is_custom) { + $scantronurl = $scantronurls{'custom'}; + } else { + $scantronurl = $scantronurls{'default'}; + } } $css_class = $itemcount%2?' class="LC_odd_row"':''; $datatable .= ''; @@ -1923,14 +1957,26 @@ sub print_scantronformat { } else { $datatable = &mt('File unavailable for display'); } - $datatable .= ''.&mt('Upload:').'
'; + $datatable .= ''; + if (keys(%error) == 0) { + $datatable .= ''; + if (!$switchserver) { + $datatable .= &mt('Upload:').'
'; + } + } else { + my $errorstr; + foreach my $key (sort(keys(%error))) { + $errorstr .= $lt{$key}.': '.$error{$key}.'
'; + } + $datatable .= ''.$errorstr; + } } else { if (keys(%error) > 0) { my $errorstr; foreach my $key (sort(keys(%error))) { $errorstr .= $lt{$key}.': '.$error{$key}.'
'; } - $datatable .= ''.$errorstr.''; + $datatable .= ''.$errorstr.' '; } elsif ($scantronurl) { $datatable .= '' .&mt('Custom scantron format file').'' .'