--- loncom/interface/domainprefs.pm 2012/12/20 02:58:05 1.160.6.10
+++ loncom/interface/domainprefs.pm 2013/03/01 21:17:24 1.160.6.16
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.160.6.10 2012/12/20 02:58:05 raeburn Exp $
+# $Id: domainprefs.pm,v 1.160.6.16 2013/03/01 21:17:24 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -45,7 +45,7 @@ described at http://www.lon-capa.org.
=head1 OVERVIEW
Each institution using LON-CAPA will typically have a single domain designated
-for use by individuals affliated with the institution. Accordingly, each domain
+for use by individuals affiliated with the institution. Accordingly, each domain
may define a default set of logos and a color scheme which can be used to "brand"
the LON-CAPA instance. In addition, an institution will typically have a language
and timezone which are used for the majority of courses.
@@ -210,13 +210,13 @@ sub handler {
'quotas','autoenroll','autoupdate','autocreate',
'directorysrch','usercreation','usermodification',
'contacts','defaults','scantron','coursecategories',
- 'serverstatuses','requestcourses','usersessions',
- 'loadbalancing','requestauthor'],$dom);
+ 'serverstatuses','requestcourses','coursedefaults',
+ 'usersessions','loadbalancing','requestauthor'],$dom);
my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll',
'autoupdate','autocreate','directorysrch','contacts',
'usercreation','usermodification','scantron',
'requestcourses','requestauthor','coursecategories',
- 'serverstatuses','usersessions');
+ 'serverstatuses','coursedefaults','usersessions');
my %existing;
if (ref($domconfig{'loadbalancing'}) eq 'HASH') {
%existing = %{$domconfig{'loadbalancing'}};
@@ -353,6 +353,12 @@ sub handler {
col3 => 'Specific IPs',
}],
},
+ 'coursedefaults' =>
+ {text => 'Course/Community defaults',
+ help => 'Domain_Configuration_Course_Defaults',
+ header => [{col1 => 'Defaults which can be overridden for each course by a DC',
+ col2 => 'Value',},],
+ },
'usersessions' =>
{text => 'User session hosting/offloading',
help => 'Domain_Configuration_User_Sessions',
@@ -368,7 +374,7 @@ sub handler {
help => 'Domain_Configuration_Load_Balancing',
header => [{col1 => 'Balancers',
col2 => 'Default destinations',
- col3 => 'User affliation',
+ col3 => 'User affiliation',
col4 => 'Overrides'},
],
},
@@ -384,16 +390,19 @@ sub handler {
col2 => 'Value'}],
};
}
+
my @roles = ('student','coordinator','author','admin');
my @actions = &Apache::loncommon::get_env_multiple('form.actions');
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"javascript:changePage(document.$phase,'pickactions')",
text=>"Settings to display/modify"});
my $confname = $dom.'-domainconfig';
+
if ($phase eq 'process') {
&Apache::lonconfigsettings::make_changes($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname,\@roles);
} elsif ($phase eq 'display') {
- my $js = &recaptcha_js();
+ my $js = &recaptcha_js().
+ &credits_js();
if ((keys(%servers) > 1) || (keys(%existing) > 0)) {
my ($othertitle,$usertypes,$types) =
&Apache::loncommon::sorted_inst_types($dom);
@@ -405,6 +414,34 @@ sub handler {
}
&Apache::lonconfigsettings::display_settings($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname,$js);
} else {
+# check if domconfig user exists for the domain.
+ my $servadm = $r->dir_config('lonAdmEMail');
+ my ($configuserok,$author_ok,$switchserver) =
+ &config_check($dom,$confname,$servadm);
+ unless ($configuserok eq 'ok') {
+ &Apache::lonconfigsettings::print_header($r,$phase,$context);
+ $r->print(&mt('The domain configuration user "[_1]" has yet to be created.',
+ $confname).
+ ' '
+ );
+ if ($switchserver) {
+ $r->print(&mt('Ordinarily, that domain configuration user is created when the ./UPDATE script is run to install LON-CAPA for the first time.').
+ ' '.
+ &mt('However, that does not apply when new domains are added to a multi-domain server, and ./UPDATE has not been run recently.').
+ ' '.
+ &mt('The "[_1]" user can be created automatically when a Domain Coordinator visits the web-based "Set domain configuration" screen, in a session hosted on the primary library server.',$confname).
+ ' '.
+ &mt('To do that now, use the following link: [_1]',$switchserver)
+ );
+ } else {
+ $r->print(&mt('To create that user from the command line run the ./UPDATE script found in the top level directory of the extracted LON-CAPA tarball.').
+ ' '.
+ &mt('Once that is done, you will be able to use the web-based "Set domain configuration" to configure the domain')
+ );
+ }
+ $r->print(&Apache::loncommon::end_page());
+ return OK;
+ }
if (keys(%domconfig) == 0) {
my $primarylibserv = &Apache::lonnet::domain($dom,'primary');
my @ids=&Apache::lonnet::current_machine_ids();
@@ -483,6 +520,8 @@ sub process_changes {
$output = &modify_quotas($dom,$action,%domconfig);
} elsif ($action eq 'requestauthor') {
$output = &modify_quotas($dom,$action,%domconfig);
+ } elsif ($action eq 'coursedefaults') {
+ $output = &modify_coursedefaults($dom,%domconfig);
} elsif ($action eq 'usersessions') {
$output = &modify_usersessions($dom,%domconfig);
} elsif ($action eq 'loadbalancing') {
@@ -641,8 +680,6 @@ sub print_config_box {
'.&mt($item->{'header'}->[2]->{'col2'}).' '.
&print_usersessions('bottom',$dom,$settings,\$rowtotal);
$rowtotal ++;
- } elsif ($action eq 'coursedefaults') {
- $output .= &print_coursedefaults('bottom',$dom,$settings,\$rowtotal);
} elsif ($action eq 'rolecolors') {
$output .= &print_rolecolors($phase,'coordinator',$dom,$confname,$settings,\$rowtotal).'
@@ -739,6 +776,8 @@ sub print_config_box {
$output .= &print_helpsettings($dom,$confname,$settings,\$rowtotal);
} elsif ($action eq 'loadbalancing') {
$output .= &print_loadbalancing($dom,$settings,\$rowtotal);
+ } elsif ($action eq 'coursedefaults') {
+ $output .= &print_coursedefaults('bottom',$dom,$settings,\$rowtotal);
}
}
$output .= '
@@ -781,7 +820,7 @@ sub print_login {
''.
''.$choices{'directlogin'}.
' ';
- foreach my $hostid (keys(%servers)) {
+ foreach my $hostid (sort(keys(%servers))) {
next if ($servers{$hostid} eq $servers{$lonhost});
my $selected = '';
if (ref($disallowed{$lonhost}) eq 'HASH') {
@@ -824,10 +863,11 @@ sub print_login {
} elsif ($caller eq 'page') {
my %defaultchecked = (
'coursecatalog' => 'on',
+ 'helpdesk' => 'on',
'adminmail' => 'off',
'newuser' => 'off',
);
- my @toggles = ('coursecatalog','adminmail','newuser');
+ my @toggles = ('coursecatalog','adminmail','helpdesk','newuser');
my (%checkedon,%checkedoff);
foreach my $item (@toggles) {
if ($defaultchecked{$item} eq 'on') {
@@ -1043,6 +1083,7 @@ sub login_choices {
&Apache::lonlocal::texthash (
coursecatalog => 'Display Course/Community Catalog link?',
adminmail => "Display Administrator's E-mail Address?",
+ helpdesk => 'Display "Contact Helpdesk" link',
disallowlogin => "Login page requests redirected",
hostid => "Server",
server => "Redirect to:",
@@ -1310,6 +1351,7 @@ sub display_color_options {
}
$datatable .= ''.
'';
+
foreach my $item (@{$bgs}) {
$datatable .= '';
my $color = $designs->{'bgs'}{$item} ? $designs->{'bgs'}{$item} : $defaults->{'bgs'}{$item};
@@ -1346,7 +1388,6 @@ sub display_color_options {
}
$datatable .= ' ';
-
}
$$rowtotal += $itemcount;
return $datatable;
@@ -1866,35 +1907,16 @@ sub print_quotas {
sub print_requestmail {
my ($dom,$action,$settings,$rowtotal) = @_;
- my ($now,$datatable,%dompersonnel,@domcoord,@currapproval,$rows);
+ my ($now,$datatable,%currapp,$rows);
$now = time;
- $rows = 0;
- %dompersonnel = &Apache::lonnet::get_domain_roles($dom,['dc'],$now,$now);
- foreach my $server (keys(%dompersonnel)) {
- foreach my $user (sort(keys(%{$dompersonnel{$server}}))) {
- my ($trole,$uname,$udom,$runame,$rudom,$rsec) = split(/:/,$user);
- if (!grep(/^$uname:$udom$/,@domcoord)) {
- push(@domcoord,$uname.':'.$udom);
- }
- }
- }
if (ref($settings) eq 'HASH') {
if (ref($settings->{'notify'}) eq 'HASH') {
if ($settings->{'notify'}{'approval'} ne '') {
- @currapproval = split(',',$settings->{'notify'}{'approval'});
+ map {$currapp{$_}=1;} split(/,/,$settings->{'notify'}{'approval'});
}
}
}
- if (@currapproval) {
- foreach my $dc (@currapproval) {
- unless (grep(/^\Q$dc\E$/,@domcoord)) {
- push(@domcoord,$dc);
- }
- }
- }
- @domcoord = sort(@domcoord);
- my $numinrow = 4;
- my $numdc = @domcoord;
+ my $numinrow = 2;
my $css_class = 'class="LC_odd_row"';
my $text;
if ($action eq 'requestcourses') {
@@ -1905,42 +1927,12 @@ sub print_requestmail {
$datatable = ' '.
' '.$text.' '.
' ';
- if (@domcoord > 0) {
- $datatable .= '';
+ my ($numdc,$table,$rows) = &active_dc_picker($dom,$numinrow,'checkbox',
+ 'reqapprovalnotify',%currapp);
+ if ($numdc > 0) {
+ $datatable .= $table;
} else {
$datatable .= &mt('There are no active Domain Coordinators');
- $rows ++;
}
$datatable .=' ';
$$rowtotal += $rows;
@@ -2095,8 +2087,7 @@ sub print_autoupdate {
sub print_autocreate {
my ($dom,$settings,$rowtotal) = @_;
- my (%createon,%createoff);
- my $curr_dc;
+ my (%createon,%createoff,%currhash);
my @types = ('xml','req');
if (ref($settings) eq 'HASH') {
foreach my $item (@types) {
@@ -2109,7 +2100,9 @@ sub print_autocreate {
}
}
}
- $curr_dc = $settings->{'xmldc'};
+ if ($settings->{'xmldc'} ne '') {
+ $currhash{$settings->{'xmldc'}} = 1;
+ }
} else {
foreach my $item (@types) {
$createoff{$item} = ' checked="checked" ';
@@ -2117,6 +2110,7 @@ sub print_autocreate {
}
}
$$rowtotal += 2;
+ my $numinrow = 2;
my $datatable=''.
''.&mt('Create pending official courses from XML files').' '.
''.
@@ -2131,15 +2125,16 @@ sub print_autocreate {
$createon{'req'}.' value="1" />'.&mt('Yes').' '.
' '.&mt('No').' ';
- my ($numdc,$dctable) = &active_dc_picker($dom,$curr_dc);
+ my ($numdc,$dctable,$rows) = &active_dc_picker($dom,$numinrow,'radio',
+ 'autocreate_xmldc',%currhash);
if ($numdc > 1) {
$datatable .= ' '.
&mt('Course creation processed as: (choose Dom. Coord.)').
' '.$dctable.' ';
- $$rowtotal ++ ;
} else {
$datatable .= $dctable.'';
}
+ $$rowtotal += $rows;
return $datatable;
}
@@ -2262,7 +2257,7 @@ sub print_contacts {
my @contacts = ('adminemail','supportemail');
my (%checked,%to,%otheremails,%bccemails);
my @mailings = ('errormail','packagesmail','lonstatusmail','helpdeskmail',
- 'requestsmail');
+ 'requestsmail','updatesmail');
foreach my $type (@mailings) {
$otheremails{$type} = '';
}
@@ -2298,6 +2293,7 @@ sub print_contacts {
$checked{'helpdeskmail'}{'supportemail'} = ' checked="checked" ';
$checked{'lonstatusmail'}{'adminemail'} = ' checked="checked" ';
$checked{'requestsmail'}{'adminemail'} = ' checked="checked" ';
+ $checked{'updatesmail'}{'adminemail'} = ' checked="checked" ';
}
my ($titles,$short_titles) = &contact_titles();
my $rownum = 0;
@@ -2357,7 +2353,8 @@ sub print_helpsettings {
}
sub radiobutton_prefs {
- my ($settings,$toggles,$defaultchecked,$choices,$itemcount) = @_;
+ my ($settings,$toggles,$defaultchecked,$choices,$itemcount,$onclick,
+ $additional) = @_;
return unless ((ref($toggles) eq 'ARRAY') && (ref($defaultchecked) eq 'HASH') &&
(ref($choices) eq 'HASH'));
@@ -2383,17 +2380,22 @@ sub radiobutton_prefs {
}
}
}
+ if ($onclick) {
+ $onclick = ' onclick="'.$onclick.'"';
+ }
foreach my $item (@{$toggles}) {
$css_class = $itemcount%2?' class="LC_odd_row"':'';
$datatable .=
- ''.$choices->{$item}.
+ ''.
+ ''.$choices->{$item}.
' '.
''.
' '.&mt('Yes').
+ $item.'" '.$checkedon{$item}.' value="1"'.$onclick.' />'.&mt('Yes').
' '.&mt('No').' '.
- ' '.
+ $checkedoff{$item}.' value="0"'.$onclick.' />'.&mt('No').''.
+ ''.$additional.
+ ''.
' ';
$itemcount ++;
}
@@ -2402,28 +2404,31 @@ sub radiobutton_prefs {
sub print_coursedefaults {
my ($position,$dom,$settings,$rowtotal) = @_;
- my ($css_class,$datatable);
+ my ($css_class,$datatable,%checkedon,%checkedoff,%defaultchecked,@toggles);
my $itemcount = 1;
+ my %choices = &Apache::lonlocal::texthash (
+ canuse_pdfforms => 'Course/Community users can create/upload PDF forms',
+ anonsurvey_threshold => 'Responder count needed before showing submissions for anonymous surveys',
+ coursecredits => 'Credits can be specified for courses',
+ );
if ($position eq 'top') {
- my (%checkedon,%checkedoff,%choices,%defaultchecked,@toggles);
- %choices =
- &Apache::lonlocal::texthash (
- canuse_pdfforms => 'Course/Community users can create/upload PDF forms',
- );
%defaultchecked = ('canuse_pdfforms' => 'off');
- @toggles = ('canuse_pdfforms',);
+ @toggles = ('canuse_pdfforms');
($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked,
\%choices,$itemcount);
- $$rowtotal += $itemcount;
} else {
$css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
- my %choices =
- &Apache::lonlocal::texthash (
- anonsurvey_threshold => 'Responder count needed before showing submissions for anonymous surveys',
- );
- my $currdefresponder;
+ my ($currdefresponder,$def_official_credits,$def_unofficial_credits);
+ my $currusecredits = 0;
if (ref($settings) eq 'HASH') {
$currdefresponder = $settings->{'anonsurvey_threshold'};
+ if (ref($settings->{'coursecredits'}) eq 'HASH') {
+ $def_official_credits = $settings->{'coursecredits'}->{'official'};
+ $def_unofficial_credits = $settings->{'coursecredits'}->{'unofficial'};
+ if (($def_official_credits ne '') || ($def_unofficial_credits ne '')) {
+ $currusecredits = 1;
+ }
+ }
}
if (!$currdefresponder) {
$currdefresponder = 10;
@@ -2431,13 +2436,41 @@ sub print_coursedefaults {
$currdefresponder = 1;
}
$datatable .=
- ''.$choices{'anonsurvey_threshold'}.
+ ''.
+ $choices{'anonsurvey_threshold'}.
' '.
''.
' '.
- ' ';
+ ' '."\n";
+ $itemcount ++;
+ my $onclick = 'toggleCredits(this.form);';
+ my $display = 'none';
+ if ($currusecredits) {
+ $display = 'block';
+ }
+ my $additional = ''.
+ ''.
+ &mt('Default credits for official courses [_1]',
+ ' ').
+ ' '.
+ ''.
+ &mt('Default credits for unofficial courses [_1]',
+ ' ').
+ '
'."\n";
+ %defaultchecked = ('coursecredits' => 'off');
+ @toggles = ('coursecredits');
+ my $current = {
+ 'coursecredits' => $currusecredits,
+ };
+ (my $table,$itemcount) =
+ &radiobutton_prefs($current,\@toggles,\%defaultchecked,
+ \%choices,$itemcount,$onclick,$additional);
+ $datatable .= $table;
}
+ $$rowtotal += $itemcount;
return $datatable;
}
@@ -2728,7 +2761,10 @@ sub spares_row {
$css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
$datatable .= '
- '.$server.' when busy, offloads to: '."\n";
+ '.
+ &mt('[_1] when busy, offloads to:'
+ ,''.$server.' ').
+ "\n";
my (%current,%canselect);
my @choices =
&possible_newspares($server,$spareid->{$server},$serverhomes,$altids);
@@ -2977,7 +3013,6 @@ sub print_loadbalancing {
' ';
}
}
- my $cssidx = $balnum%2;
$datatable .= ' '.
&loadbalancing_rules($dom,$intdom,$currrules{$lonhost},
$othertitle,$usertypes,$types,\%servers,
@@ -3186,6 +3221,7 @@ sub contact_titles {
'helpdeskmail' => 'Helpdesk requests to be e-mailed to',
'lonstatusmail' => 'E-mail from nightly status check (warnings/errors)',
'requestsmail' => 'E-mail from course requests requiring approval',
+ 'updatesmail' => 'E-mail from nightly check of LON-CAPA module integrity/updates',
);
my %short_titles = &Apache::lonlocal::texthash (
adminemail => 'Admin E-mail address',
@@ -4148,7 +4184,7 @@ sub print_serverstatuses {
sub serverstatus_pages {
return ('userstatus','lonstatus','loncron','server-status','codeversions',
- 'clusterstatus','metadata_keywords','metadata_harvest',
+ 'checksums','clusterstatus','metadata_keywords','metadata_harvest',
'takeoffline','takeonline','showenv','toggledebug','ping','domconf');
}
@@ -4603,6 +4639,7 @@ sub modify_login {
%curr_loginvia,%loginhash,@currlangs,@newlangs,$addedfile,%title,@offon);
%title = ( coursecatalog => 'Display course catalog',
adminmail => 'Display administrator E-mail address',
+ helpdesk => 'Display "Contact Helpdesk" link',
newuser => 'Link for visitors to create a user account',
loginheader => 'Log-in box header');
@offon = ('off','on');
@@ -4615,7 +4652,7 @@ sub modify_login {
}
($errors,%colchanges) = &modify_colors($r,$dom,$confname,['login'],
\%domconfig,\%loginhash);
- my @toggles = ('coursecatalog','adminmail','newuser');
+ my @toggles = ('coursecatalog','adminmail','helpdesk','newuser');
foreach my $item (@toggles) {
$loginhash{login}{$item} = $env{'form.'.$item};
}
@@ -4803,9 +4840,10 @@ sub modify_login {
my $putresult = &Apache::lonnet::put_dom('configuration',\%loginhash,
$dom);
if ($putresult eq 'ok') {
- my @toggles = ('coursecatalog','adminmail','newuser');
+ my @toggles = ('coursecatalog','adminmail','helpdesk','newuser');
my %defaultchecked = (
'coursecatalog' => 'on',
+ 'helpdesk' => 'on',
'adminmail' => 'off',
'newuser' => 'off',
);
@@ -5550,7 +5588,7 @@ sub write_metadata {
print $logfile "\nWrite metadata file for ".$targetdir.'/'.$file;
my $mfh;
if (open($mfh,'>'.$targetdir.'/'.$file.'.meta')) {
- foreach (sort keys %metadatafields) {
+ foreach (sort(keys(%metadatafields))) {
unless ($_=~/\./) {
my $unikey=$_;
$unikey=~/^([A-Za-z]+)/;
@@ -5634,7 +5672,7 @@ sub check_switchserver {
my @ids=&Apache::lonnet::current_machine_ids();
foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
if (!$allowed) {
- $switchserver=''.&mt('Switch Server').' ';
+ $switchserver=''.&mt('Switch Server').' ';
}
return $switchserver;
}
@@ -6281,13 +6319,16 @@ sub modify_autocreate {
foreach my $item (@types) {
if ($changes{$item}) {
my $newtxt = $offon[$newvals{$item}];
- $resulttext .= ''.&mt("$title{$item} set to [_1]$newtxt [_2]",'',' ').' ';
+ $resulttext .= ''.
+ &mt("$title{$item} set to [_1]$newtxt [_2]",
+ '',' ').
+ ' ';
}
}
if ($changes{'xmldc'}) {
my ($dcname,$dcdom) = split(':',$newvals{'xmldc'});
my $newtxt = &Apache::loncommon::plainname($dcname,$dcdom);
- $resulttext .= ''.&mt("$title{'xmldc'} set to [_1]$newtxt [_2]",'',' ').' ';
+ $resulttext .= ''.&mt("$title{'xmldc'} set to [_1]",''.$newtxt.' ').' ';
}
$resulttext .= '';
} else {
@@ -6433,7 +6474,11 @@ sub modify_directorysrch {
} else {
$chgtext =~ s/\; $//;
}
- $resulttext .= ''.&mt("Users from domain '[_1] ' permitted to search the institutional directory set to: [_2]",$dom,$chgtext).' ';
+ $resulttext .=
+ ''.
+ &mt("Users from domain '[_1]' permitted to search the institutional directory set to: [_2]",
+ ''.$dom.' ',$chgtext).
+ ' ';
}
}
}
@@ -6461,7 +6506,7 @@ sub modify_directorysrch {
}
}
$chgtext =~ s/\; $//;
- $resulttext .= ''.&mt("$title{'searchtypes'} set to: \"[_1]\"",$chgtext).' ';
+ $resulttext .= ''.&mt($title{'searchtypes'}.' set to: "[_1]"',$chgtext).' ';
}
$resulttext .= '';
} else {
@@ -6485,7 +6530,7 @@ sub modify_contacts {
my (%others,%to,%bcc);
my @contacts = ('supportemail','adminemail');
my @mailings = ('errormail','packagesmail','helpdeskmail','lonstatusmail',
- 'requestsmail');
+ 'requestsmail','updatesmail');
foreach my $type (@mailings) {
@{$newsetting{$type}} =
&Apache::loncommon::get_env_multiple('form.'.$type);
@@ -6541,6 +6586,7 @@ sub modify_contacts {
$default{'helpdeskmail'} = 'supportemail';
$default{'lonstatusmail'} = 'adminemail';
$default{'requestsmail'} = 'adminemail';
+ $default{'updatesmail'} = 'adminemail';
foreach my $item (@contacts) {
if ($to{$item} ne $default{$item}) {
$changes{$item} = 1;
@@ -7783,7 +7829,6 @@ sub modify_coursedefaults {
my ($dom,%domconfig) = @_;
my ($resulttext,$errors,%changes,%defaultshash);
my %defaultchecked = ('canuse_pdfforms' => 'off');
- my @offon = ('off','on');
my @toggles = ('canuse_pdfforms');
$defaultshash{'coursedefaults'} = {};
@@ -7800,7 +7845,7 @@ sub modify_coursedefaults {
if (($domconfig{'coursedefaults'}{$item} eq '') &&
($env{'form.'.$item} eq '0')) {
$changes{$item} = 1;
- } elsif ($domconfig{'coursdefaults'}{$item} ne $env{'form.'.$item}) {
+ } elsif ($domconfig{'coursedefaults'}{$item} ne $env{'form.'.$item}) {
$changes{$item} = 1;
}
} elsif ($defaultchecked{$item} eq 'off') {
@@ -7825,14 +7870,42 @@ sub modify_coursedefaults {
$changes{'anonsurvey_threshold'} = 1;
}
}
+ my $officialcreds = $env{'form.official_credits'};
+ $officialcreds =~ s/^[^\d\.]//g;
+ my $unofficialcreds = $env{'form.unofficial_credits'};
+ $unofficialcreds =~ s/^[^\d\.]//g;
+ if (ref($domconfig{'coursedefaults'}{'coursecredits'} ne 'HASH') &&
+ ($env{'form.coursecredits'} eq '1')) {
+ $changes{'coursecredits'} = 1;
+ } else {
+ if (($domconfig{'coursedefaults'}{'coursecredits'}{'official'} ne $officialcreds) ||
+ ($domconfig{'coursedefaults'}{'coursecredits'}{'unofficial'} ne $unofficialcreds)) {
+ $changes{'coursecredits'} = 1;
+ }
+ }
+ $defaultshash{'coursedefaults'}{'coursecredits'} = {
+ official => $officialcreds,
+ unofficial => $unofficialcreds,
+ }
}
my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash,
$dom);
if ($putresult eq 'ok') {
+ my %domdefaults;
if (keys(%changes) > 0) {
- if ($changes{'canuse_pdfforms'}) {
- my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
- $domdefaults{'canuse_pdfforms'}=$defaultshash{'coursedefaults'}{'canuse_pdfforms'};
+ if (($changes{'canuse_pdfforms'}) || ($changes{'coursecredits'})) {
+ %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
+ if ($changes{'canuse_pdfforms'}) {
+ $domdefaults{'canuse_pdfforms'}=$defaultshash{'coursedefaults'}{'canuse_pdfforms'};
+ }
+ if ($changes{'coursecredits'}) {
+ if (ref($defaultshash{'coursedefaults'}{'coursecredits'}) eq 'HASH') {
+ $domdefaults{'officialcredits'} =
+ $defaultshash{'coursedefaults'}{'coursecredits'}{'official'};
+ $domdefaults{'unofficialcredits'} =
+ $defaultshash{'coursedefaults'}{'coursecredits'}{'unofficial'};
+ }
+ }
my $cachetime = 24*60*60;
&Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
}
@@ -7846,6 +7919,21 @@ sub modify_coursedefaults {
}
} elsif ($item eq 'anonsurvey_threshold') {
$resulttext .= ''.&mt('Responder count required for display of anonymous survey submissions set to [_1].',$defaultshash{'coursedefaults'}{'anonsurvey_threshold'}).' ';
+ } elsif ($item eq 'coursecredits') {
+ if (ref($defaultshash{'coursedefaults'}{'coursecredits'}) eq 'HASH') {
+ if (($domdefaults{'officialcredits'} eq '') &&
+ ($domdefaults{'unofficialcredits'} eq '')) {
+ $resulttext .= ''.&mt('Student credits not in use for courses in this domain').' ';
+ } else {
+ $resulttext .= ''.&mt('Student credits can be set per course by a Domain Coordinator, with the following defaults applying:').''.
+ ''.&mt('Official courses: [_1]',$defaultshash{'coursedefaults'}{'coursecredits'}{'official'}).' '.
+ ''.&mt('Unofficial courses: [_1]',$defaultshash{'coursedefaults'}{'coursecredits'}{'unofficial'}).' '.
+ ' '.
+ ' ';
+ }
+ } else {
+ $resulttext .= ''.&mt('Student credits not in use for courses in this domain').' ';
+ }
}
}
$resulttext .= '';
@@ -8370,72 +8458,94 @@ sub recurse_cat_deletes {
sub get_active_dcs {
my ($dom) = @_;
- my %dompersonnel = &Apache::lonnet::get_domain_roles($dom,['dc']);
+ my $now = time;
+ my %dompersonnel = &Apache::lonnet::get_domain_roles($dom,['dc'],$now,$now);
my %domcoords;
my $numdcs = 0;
- my $now = time;
foreach my $server (keys(%dompersonnel)) {
foreach my $user (sort(keys(%{$dompersonnel{$server}}))) {
my ($trole,$uname,$udom,$runame,$rudom,$rsec) = split(/:/,$user);
- my ($end,$start) = split(':',$dompersonnel{$server}{$user});
- if (($end eq '') || ($end == 0) || ($end > $now)) {
- if ($start <= $now) {
- $domcoords{$uname.':'.$udom} = $dompersonnel{$server}{$user};
- }
- }
+ $domcoords{$uname.':'.$udom} = $dompersonnel{$server}{$user};
}
}
return %domcoords;
}
sub active_dc_picker {
- my ($dom,$curr_dc) = @_;
+ my ($dom,$numinrow,$inputtype,$name,%currhash) = @_;
my %domcoords = &get_active_dcs($dom);
- my @dcs = sort(keys(%domcoords));
- my $numdcs = scalar(@dcs);
- my $datatable;
- my $numinrow = 2;
+ my @domcoord = keys(%domcoords);
+ if (keys(%currhash)) {
+ foreach my $dc (keys(%currhash)) {
+ unless (exists($domcoords{$dc})) {
+ push(@domcoord,$dc);
+ }
+ }
+ }
+ @domcoord = sort(@domcoord);
+ my $numdcs = scalar(@domcoord);
+ my $rows = 0;
+ my $table;
if ($numdcs > 1) {
- $datatable = '';
- for (my $i=0; $i<@dcs; $i++) {
+ $table = '';
- } elsif (@dcs) {
- $datatable .= ' ';
+ $table .= '
';
+ } elsif ($numdcs == 1) {
+ if ($inputtype eq 'radio') {
+ $table .= ' ';
+ } else {
+ my $check;
+ if (exists($currhash{$domcoord[0]})) {
+ $check = ' checked="checked"';
+ }
+ $table .= ' ';
+ $rows ++;
+ }
}
- return ($numdcs,$datatable);
+ return ($numdcs,$table,$rows);
}
sub usersession_titles {
@@ -8955,6 +9065,40 @@ function updateCaptcha(caller,context) {
}
}
return;
+}
+
+// ]]>
+
+
+END
+
+}
+
+sub credits_js {
+ return <<"END";
+
+