--- loncom/interface/domainprefs.pm 2015/03/11 15:56:36 1.160.6.56 +++ loncom/interface/domainprefs.pm 2015/05/12 00:20:42 1.160.6.63 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.160.6.56 2015/03/11 15:56:36 raeburn Exp $ +# $Id: domainprefs.pm,v 1.160.6.63 2015/05/12 00:20:42 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -414,7 +414,9 @@ sub handler { 'coursedefaults' => {text => 'Course/Community defaults', help => 'Domain_Configuration_Course_Defaults', - header => [{col1 => 'Defaults which can be overridden for each course by a DC', + header => [{col1 => 'Defaults which can be overridden in each course by a CC', + col2 => 'Value',}, + {col1 => 'Defaults which can be overridden for each course by a DC', col2 => 'Value',},], print => \&print_coursedefaults, modify => \&modify_coursedefaults, @@ -670,7 +672,7 @@ sub print_config_box { '; $rowtotal ++; if (($action eq 'autoupdate') || ($action eq 'usercreation') || ($action eq 'selfcreation') || - ($action eq 'usermodification') || ($action eq 'defaults') || + ($action eq 'usermodification') || ($action eq 'defaults') || ($action eq 'coursedefaults') || ($action eq 'selfenrollment') || ($action eq 'usersessions')) { $output .= $item->{'print'}->('top',$dom,$settings,\$rowtotal); } elsif ($action eq 'coursecategories') { @@ -725,7 +727,8 @@ sub print_config_box { $output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal); } $rowtotal ++; - } elsif (($action eq 'usermodification') || ($action eq 'defaults')) { + } elsif (($action eq 'usermodification') || ($action eq 'coursedefaults') || + ($action eq 'defaults')) { $output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal); } elsif ($action eq 'login') { if ($numheaders == 4) { @@ -889,8 +892,6 @@ sub print_config_box { $output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal); } elsif ($action eq 'helpsettings') { $output .= &print_helpsettings($dom,$confname,$settings,\$rowtotal); - } elsif ($action eq 'coursedefaults') { - $output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal); } } $output .= ' @@ -2825,7 +2826,7 @@ sub print_helpsettings { sub radiobutton_prefs { my ($settings,$toggles,$defaultchecked,$choices,$itemcount,$onclick, - $additional) = @_; + $additional,$align) = @_; return unless ((ref($toggles) eq 'ARRAY') && (ref($defaultchecked) eq 'HASH') && (ref($choices) eq 'HASH')); @@ -2859,8 +2860,14 @@ sub radiobutton_prefs { $datatable .= ''. ''.$choices->{$item}. - ''. - ''. + ''; + if ($align eq 'left') { + $datatable .= ''; + } else { + $datatable .= ''; + } + $datatable .= + ''. ' '. + ''. ' '.&mt('(new)'). ''. &mt('Name displayed:'). @@ -5234,7 +5303,7 @@ sub serverstatus_pages { return ('userstatus','lonstatus','loncron','server-status','codeversions', 'checksums','clusterstatus','metadata_keywords','metadata_harvest', 'takeoffline','takeonline','showenv','toggledebug','ping','domconf', - 'uniquecodes','diskusage'); + 'uniquecodes','diskusage','coursecatalog'); } sub defaults_javascript { @@ -10156,14 +10225,18 @@ sub modify_helpsettings { sub modify_coursedefaults { my ($dom,$lastactref,%domconfig) = @_; my ($resulttext,$errors,%changes,%defaultshash); - my %defaultchecked = ('canuse_pdfforms' => 'off'); - my @toggles = ('canuse_pdfforms'); + my %defaultchecked = ( + 'uselcmath' => 'on', + 'usejsme' => 'on' + ); + my @toggles = ('uselcmath','usejsme'); my @numbers = ('anonsurvey_threshold','uploadquota_official','uploadquota_unofficial', 'uploadquota_community','uploadquota_textbook'); my @types = ('official','unofficial','community','textbook'); my %staticdefaults = ( anonsurvey_threshold => 10, uploadquota => 500, + postsubmit => 60, ); $defaultshash{'coursedefaults'} = {}; @@ -10225,26 +10298,81 @@ sub modify_coursedefaults { } } - my $officialcreds = $env{'form.official_credits'}; - $officialcreds =~ s/[^\d.]+//g; - my $unofficialcreds = $env{'form.unofficial_credits'}; - $unofficialcreds =~ s/[^\d.]+//g; - my $textbookcreds = $env{'form.textbook_credits'}; - $textbookcreds =~ 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) || - ($domconfig{'coursedefaults'}{'coursecredits'}{'textbook'} ne $textbookcreds)) { - $changes{'coursecredits'} = 1; - } - } - $defaultshash{'coursedefaults'}{'coursecredits'} = { - official => $officialcreds, - unofficial => $unofficialcreds, - textbook => $textbookcreds, + my %credits; + foreach my $type (@types) { + unless ($type eq 'community') { + $credits{$type} = $env{'form.'.$type.'_credits'}; + $credits{$type} =~ s/[^\d.]+//g; + } + } + if ((ref($domconfig{'coursedefaults'}{'coursecredits'}) ne 'HASH') && + ($env{'form.coursecredits'} eq '1')) { + $changes{'coursecredits'} = 1; + foreach my $type (keys(%credits)) { + $defaultshash{'coursedefaults'}{'coursecredits'}{$type} = $credits{$type}; + } + } else { + if ($env{'form.coursecredits'} eq '1') { + foreach my $type (@types) { + unless ($type eq 'community') { + if ($domconfig{'coursedefaults'}{'coursecredits'}{$type} ne $credits{$type}) { + $changes{'coursecredits'} = 1; + } + $defaultshash{'coursedefaults'}{'coursecredits'}{$type} = $credits{$type}; + } + } + } elsif (ref($domconfig{'coursedefaults'}{'coursecredits'}) eq 'HASH') { + foreach my $type (@types) { + unless ($type eq 'community') { + if ($domconfig{'coursedefaults'}{'coursecredits'}{$type}) { + $changes{'coursecredits'} = 1; + last; + } + } + } + } + } + if ($env{'form.postsubmit'} eq '1') { + $defaultshash{'coursedefaults'}{'postsubmit'}{'client'} = 'on'; + my %currtimeout; + if (ref($domconfig{'coursedefaults'}{'postsubmit'}) eq 'HASH') { + if ($domconfig{'coursedefaults'}{'postsubmit'}{'client'} eq 'off') { + $changes{'postsubmit'} = 1; + } + if (ref($domconfig{'coursedefaults'}{'postsubmit'}{'timeout'}) eq 'HASH') { + %currtimeout = %{$domconfig{'coursedefaults'}{'postsubmit'}{'timeout'}}; + } + } else { + $changes{'postsubmit'} = 1; + } + foreach my $type (@types) { + my $timeout = $env{'form.'.$type.'_timeout'}; + $timeout =~ s/\D//g; + if ($timeout == $staticdefaults{'postsubmit'}) { + $timeout = ''; + } elsif (($timeout eq '') || ($timeout =~ /^0+$/)) { + $timeout = '0'; + } + unless ($timeout eq '') { + $defaultshash{'coursedefaults'}{'postsubmit'}{'timeout'}{$type} = $timeout; + } + if (exists($currtimeout{$type})) { + if ($timeout ne $currtimeout{$type}) { + $changes{'postsubmit'} = 1; + } + } elsif ($timeout ne '') { + $changes{'postsubmit'} = 1; + } + } + } else { + $defaultshash{'coursedefaults'}{'postsubmit'}{'client'} = 'off'; + if (ref($domconfig{'coursedefaults'}{'postsubmit'}) eq 'HASH') { + if ($domconfig{'coursedefaults'}{'postsubmit'}{'client'} eq 'on') { + $changes{'postsubmit'} = 1; + } + } else { + $changes{'postsubmit'} = 1; + } } } my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash, @@ -10252,19 +10380,30 @@ sub modify_coursedefaults { if ($putresult eq 'ok') { if (keys(%changes) > 0) { my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1); - if (($changes{'canuse_pdfforms'}) || ($changes{'coursecredits'}) || - ($changes{'uploadquota'})) { - if ($changes{'canuse_pdfforms'}) { - $domdefaults{'canuse_pdfforms'}=$defaultshash{'coursedefaults'}{'canuse_pdfforms'}; + if (($changes{'uploadquota'}) || ($changes{'postsubmit'}) || + ($changes{'coursecredits'}) || ($changes{'uselcmath'}) || ($changes{'usejsme'})) { + foreach my $item ('uselcmath','usejsme') { + if ($changes{$item}) { + $domdefaults{$item}=$defaultshash{'coursedefaults'}{$item}; + } } if ($changes{'coursecredits'}) { if (ref($defaultshash{'coursedefaults'}{'coursecredits'}) eq 'HASH') { - $domdefaults{'officialcredits'} = - $defaultshash{'coursedefaults'}{'coursecredits'}{'official'}; - $domdefaults{'unofficialcredits'} = - $defaultshash{'coursedefaults'}{'coursecredits'}{'unofficial'}; - $domdefaults{'textbookcredits'} = - $domdefaults{'coursedefaults'}{'coursecredits'}{'textbook'}; + foreach my $type (keys(%{$defaultshash{'coursedefaults'}{'coursecredits'}})) { + $domdefaults{$type.'credits'} = + $defaultshash{'coursedefaults'}{'coursecredits'}{$type}; + } + } + } + if ($changes{'postsubmit'}) { + if (ref($defaultshash{'coursedefaults'}{'postsubmit'}) eq 'HASH') { + $domdefaults{'postsubmit'} = $defaultshash{'coursedefaults'}{'postsubmit'}{'client'}; + if (ref($defaultshash{'coursedefaults'}{'postsubmit'}{'timeout'}) eq 'HASH') { + foreach my $type (keys(%{$defaultshash{'coursedefaults'}{'postsubmit'}{'timeout'}})) { + $domdefaults{$type.'postsubtimeout'} = + $defaultshash{'coursedefaults'}{'postsubmit'}{'timeout'}{$type}; + } + } } } if ($changes{'uploadquota'}) { @@ -10282,11 +10421,17 @@ sub modify_coursedefaults { } $resulttext = &mt('Changes made:').''; } } + if ($changes{'offloadnow'}) { + if (ref($defaultshash{'usersessions'}{'offloadnow'}) eq 'HASH') { + if (keys(%{$defaultshash{'usersessions'}{'offloadnow'}}) > 0) { + $resulttext .= '
  • '.&mt('Switch active users on next access, for server(s):').'
      '; + foreach my $lonhost (sort(keys(%{$defaultshash{'usersessions'}{'offloadnow'}}))) { + $resulttext .= '
    • '.$lonhost.'
    • '; + } + $resulttext .= '
    '; + } else { + $resulttext .= '
  • '.&mt('No servers now set to switch active users on next access.'); + } + } else { + $resulttext .= '
  • '.&mt('No servers now set to switch active users on next access.').'
  • '; + } + } $resulttext .= ''; } else { $resulttext = $nochgmsg; @@ -11779,6 +12013,9 @@ function toggleDisplay(domForm,caller) { if (caller == 'emailoptions') { optionsElement = domForm.cancreate_email; } + if (caller == 'studentsubmission') { + optionsElement = domForm.postsubmit; + } if (optionsElement.length) { var currval; for (var i=0; i 1) { + if (keys(%servers)) { foreach my $server (keys(%servers)) { next if ($thismachine{$server}); my @cached;