--- loncom/interface/domainprefs.pm 2008/06/24 15:01:23 1.56
+++ 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.56 2008/06/24 15:01:23 bisitz Exp $
+# $Id: domainprefs.pm,v 1.60 2008/07/06 22:14:46 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -62,7 +62,7 @@ sub handler {
}
&Apache::lonhtmlcommon::clear_breadcrumbs();
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['phase']);
+ ['phase','actions']);
my $phase = 'pickactions';
if ( exists($env{'form.phase'}) ) {
$phase = $env{'form.phase'};
@@ -162,9 +162,11 @@ sub handler {
'coursecategories' =>
{ text => 'Cataloging of courses',
help => 'Domain_Course_Catalog',
- header => [ {col1 => 'Categories',
- col2 => '',
- }],
+ header => [{col1 => 'Category settings',
+ col2 => '',},
+ {col1 => 'Categories',
+ col2 => '',
+ }],
}
);
my @roles = ('student','coordinator','author','admin');
@@ -386,15 +388,16 @@ sub print_config_box {
# ');
$rowtotal ++;
if (($action eq 'autoupdate') || ($action eq 'rolecolors') ||
- ($action eq 'usercreation') || ($action eq 'usermodification')) {
+ ($action eq 'usercreation') || ($action eq 'usermodification') ||
+ ($action eq 'coursecategories')) {
my $colspan = ($action eq 'rolecolors')?' colspan="2"':'';
$output .= '
- '.$item->{'header'}->[0]->{'col1'}.' |
- '.$item->{'header'}->[0]->{'col2'}.' |
+ '.&mt($item->{'header'}->[0]->{'col1'}).' |
+ '.&mt($item->{'header'}->[0]->{'col2'}).' |
';
$rowtotal ++;
if ($action eq 'autoupdate') {
@@ -403,6 +406,8 @@ sub print_config_box {
$output .= &print_usercreation('top',$dom,$settings,\$rowtotal);
} elsif ($action eq 'usermodification') {
$output .= &print_usermodification('top',$dom,$settings,\$rowtotal);
+ } elsif ($action eq 'coursecategories') {
+ $output .= &print_coursecategories('top',$dom,$item,$settings,\$rowtotal);
} else {
$output .= &print_rolecolors($phase,'student',$dom,$confname,$settings,\$rowtotal);
}
@@ -414,8 +419,10 @@ sub print_config_box {
- '.$item->{'header'}->[1]->{'col1'}.' |
- '.$item->{'header'}->[1]->{'col2'}.' |
+ '.&mt($item->{'header'}->[1]->{'col1'}).' | ';
+ my $colspan = ($action eq 'coursecategories')?' colspan="2"':'';
+ $output .= '
+ '.&mt($item->{'header'}->[1]->{'col2'}).' |
';
$rowtotal ++;
if ($action eq 'autoupdate') {
@@ -429,12 +436,14 @@ sub print_config_box {
- '.$item->{'header'}->[2]->{'col1'}.' |
- '.$item->{'header'}->[2]->{'col2'}.' | '.
+ '.&mt($item->{'header'}->[2]->{'col1'}).' |
+ '.&mt($item->{'header'}->[2]->{'col2'}).' | '.
&print_usercreation('bottom',$dom,$settings,\$rowtotal);
$rowtotal ++;
} elsif ($action eq 'usermodification') {
$output .= &print_usermodification('bottom',$dom,$settings,\$rowtotal);
+ } elsif ($action eq 'coursecategories') {
+ $output .= &print_coursecategories('bottom',$dom,$item,$settings,\$rowtotal);
} else {
$output .= &print_rolecolors($phase,'coordinator',$dom,$confname,$settings,\$rowtotal).'
@@ -444,8 +453,8 @@ sub print_config_box {
|
- '.$item->{'header'}->[2]->{'col1'}.' |
- '.$item->{'header'}->[2]->{'col2'}.' |
+ '.&mt($item->{'header'}->[2]->{'col1'}).' |
+ '.&mt($item->{'header'}->[2]->{'col2'}).' |
'.
&print_rolecolors($phase,'author',$dom,$confname,$settings,\$rowtotal).'
@@ -455,8 +464,8 @@ sub print_config_box {
|
- '.$item->{'header'}->[3]->{'col1'}.' |
- '.$item->{'header'}->[3]->{'col2'}.' |
+ '.&mt($item->{'header'}->[3]->{'col1'}).' |
+ '.&mt($item->{'header'}->[3]->{'col2'}).' |
'.
&print_rolecolors($phase,'admin',$dom,$confname,$settings,\$rowtotal);
$rowtotal += 2;
@@ -469,14 +478,13 @@ sub print_config_box {
';
if (($action eq 'login') || ($action eq 'directorysrch')) {
$output .= '
- '.$item->{'header'}->[0]->{'col1'}.' | ';
+ '.&mt($item->{'header'}->[0]->{'col1'}).' | ';
} else {
$output .= '
- '.$item->{'header'}->[0]->{'col1'}.' | ';
+ '.&mt($item->{'header'}->[0]->{'col1'}).' | ';
}
- my $colspan = ($action eq 'coursecategories')?' colspan="2"':'';
$output .= '
- '.$item->{'header'}->[0]->{'col2'}.' |
+ '.&mt($item->{'header'}->[0]->{'col2'}).' |
';
$rowtotal ++;
if ($action eq 'login') {
@@ -493,8 +501,6 @@ sub print_config_box {
$output .= &print_defaults($dom,\$rowtotal);
} elsif ($action eq 'scantron') {
$output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal);
- } elsif ($action eq 'coursecategories'){
- $output .= &print_coursecategories($dom,$item,$settings,\$rowtotal);
}
}
$output .= '
@@ -1841,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',
@@ -1868,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;
+ }
}
}
}
@@ -1905,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 .= '';
@@ -1917,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').''
.' 'set from "Parameters" (Course)',
+ );
$resulttext = &mt('Changes made:').'';
- if (keys(%deletions) > 0) {
- $resulttext .= '- '.&mt('Deleted categories:').'
';
- foreach my $predeltrail (sort {$a <=> $b } (keys(%sort_by_deltrail))) {
- $resulttext .= '- '.$predeltrails[$predeltrail].'
';
- }
- $resulttext .= ' ';
+ if ($changes{'togglecats'}) {
+ $resulttext .= '- '.&mt("$title{'togglecats'} $level{$env{'form.togglecats'}}").'
';
}
- if (keys(%reorderings) > 0) {
- my %sort_by_trail;
- $resulttext .= '- '.&mt('Reordered categories:').'
';
- foreach my $key (keys(%reorderings)) {
- if ($allitems{$key} ne '') {
- $sort_by_trail{$allitems{$key}} = $trails[$allitems{$key}];
- }
- }
- foreach my $trail (sort {$a <=> $b } (keys(%sort_by_trail))) {
- $resulttext .= '- '.$trails[$trail].'
';
- }
- $resulttext .= ' ';
+ if ($changes{'categorize'}) {
+ $resulttext .= '- '.&mt("$title{'categorize'} $level{$env{'form.categorize'}}").'
';
}
- if (keys(%adds) > 0) {
- my %sort_by_trail;
- $resulttext .= '- '.&mt('Added categories:').'
';
- foreach my $key (keys(%adds)) {
- if ($allitems{$key} ne '') {
- $sort_by_trail{$allitems{$key}} = $trails[$allitems{$key}];
+ if ((keys(%deletions) > 0) || (keys(%reorderings) > 0) || (keys(%adds) > 0)) {
+ my $cathash;
+ if (ref($domconfig{'coursecategories'}) eq 'HASH') {
+ $cathash = $domconfig{'coursecategories'}{'cats'};
+ } else {
+ $cathash = {};
+ }
+ my (@cats,@trails,%allitems);
+ &Apache::loncommon::extract_categories($cathash,\@cats,\@trails,\%allitems);
+ if (keys(%deletions) > 0) {
+ $resulttext .= '- '.&mt('Deleted categories:').'
';
+ foreach my $predeltrail (sort {$a <=> $b } (keys(%sort_by_deltrail))) {
+ $resulttext .= '- '.$predeltrails[$predeltrail].'
';
+ }
+ $resulttext .= ' ';
+ }
+ if (keys(%reorderings) > 0) {
+ my %sort_by_trail;
+ $resulttext .= '- '.&mt('Reordered categories:').'
';
+ foreach my $key (keys(%reorderings)) {
+ if ($allitems{$key} ne '') {
+ $sort_by_trail{$allitems{$key}} = $trails[$allitems{$key}];
+ }
+ }
+ foreach my $trail (sort {$a <=> $b } (keys(%sort_by_trail))) {
+ $resulttext .= '- '.$trails[$trail].'
';
}
+ $resulttext .= ' ';
}
- foreach my $trail (sort {$a <=> $b } (keys(%sort_by_trail))) {
- $resulttext .= '- '.$trails[$trail].'
';
+ if (keys(%adds) > 0) {
+ my %sort_by_trail;
+ $resulttext .= '- '.&mt('Added categories:').'
';
+ foreach my $key (keys(%adds)) {
+ if ($allitems{$key} ne '') {
+ $sort_by_trail{$allitems{$key}} = $trails[$allitems{$key}];
+ }
+ }
+ foreach my $trail (sort {$a <=> $b } (keys(%sort_by_trail))) {
+ $resulttext .= '- '.$trails[$trail].'
';
+ }
+ $resulttext .= ' ';
}
- $resulttext .= ' ';
}
$resulttext .= ' ';
} else {
$resulttext = ''.
- &mt('An error occurred: [_1]',$putresult).'';
+ &mt('An error occurred: [_1]',$putresult).'';
}
} else {
$resulttext = &mt('No changes made to course categories');
| | | |