--- loncom/interface/domainprefs.pm 2016/08/05 20:12:25 1.160.6.67
+++ loncom/interface/domainprefs.pm 2016/09/18 19:22:48 1.160.6.71
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.160.6.67 2016/08/05 20:12:25 raeburn Exp $
+# $Id: domainprefs.pm,v 1.160.6.71 2016/09/18 19:22:48 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2398,7 +2398,7 @@ ENDSCRIPT
sub print_autoenroll {
my ($dom,$settings,$rowtotal) = @_;
my $autorun = &Apache::lonnet::auto_run(undef,$dom),
- my ($defdom,$runon,$runoff,$coownerson,$coownersoff);
+ my ($defdom,$runon,$runoff,$coownerson,$coownersoff,$failsafe);
if (ref($settings) eq 'HASH') {
if (exists($settings->{'run'})) {
if ($settings->{'run'} eq '0') {
@@ -2432,6 +2432,9 @@ sub print_autoenroll {
if (exists($settings->{'sender_domain'})) {
$defdom = $settings->{'sender_domain'};
}
+ if (exists($settings->{'autofailsafe'})) {
+ $failsafe = $settings->{'autofailsafe'};
+ }
} else {
if ($autorun) {
$runon = ' checked="checked" ';
@@ -2467,8 +2470,12 @@ sub print_autoenroll {
$coownerson.' value="1" />'.&mt('Yes').' '.
''.
- '';
- $$rowtotal += 3;
+ '
'.
+ ''.&mt('Failsafe for no drops when institutional data missing').' | '.
+ ''.
+ ' |
';
+ $$rowtotal += 4;
return $datatable;
}
@@ -2892,11 +2899,13 @@ sub print_coursedefaults {
usejsme => 'Molecule editor uses JSME (HTML5) in place of JME (Java)',
postsubmit => 'Disable submit button/keypress following student submission',
canclone => "People who may clone a course (besides course's owner and coordinators)",
+ mysqltables => 'Lifetime (s) of "Temporary" MySQL tables (student performance data) on homeserver',
);
my %staticdefaults = (
anonsurvey_threshold => 10,
uploadquota => 500,
postsubmit => 60,
+ mysqltables => 172800,
);
if ($position eq 'top') {
%defaultchecked = (
@@ -2980,7 +2989,7 @@ sub print_coursedefaults {
$itemcount ++;
} else {
$css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
- my ($currdefresponder,%defcredits,%curruploadquota,%deftimeout);
+ my ($currdefresponder,%defcredits,%curruploadquota,%deftimeout,%currmysql);
my $currusecredits = 0;
my $postsubmitclient = 1;
my @types = ('official','unofficial','community','textbook');
@@ -3024,6 +3033,15 @@ sub print_coursedefaults {
$deftimeout{$type} = $staticdefaults{'postsubmit'};
}
}
+ if (ref($settings->{'mysqltables'}) eq 'HASH') {
+ foreach my $type (keys(%{$settings->{'mysqltables'}})) {
+ $currmysql{$type} = $settings->{'mysqltables'}{$type};
+ }
+ } else {
+ foreach my $type (@types) {
+ $currmysql{$type} = $staticdefaults{'mysqltables'};
+ }
+ }
} else {
foreach my $type (@types) {
$deftimeout{$type} = $staticdefaults{'postsubmit'};
@@ -3101,13 +3119,27 @@ sub print_coursedefaults {
$additional .= ''."\n";
%defaultchecked = ('postsubmit' => 'on');
@toggles = ('postsubmit');
- my $current = {
- 'postsubmit' => $postsubmitclient,
- };
+ $current = {
+ 'postsubmit' => $postsubmitclient,
+ };
($table,$itemcount) =
&radiobutton_prefs($current,\@toggles,\%defaultchecked,
\%choices,$itemcount,$onclick,$additional,'left');
$datatable .= $table;
+ $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
+ $datatable .= ''.
+ $choices{'mysqltables'}.
+ ' | '.
+ ''.
+ ' |
'."\n";
+ $itemcount ++;
+
}
$$rowtotal += $itemcount;
return $datatable;
@@ -4535,7 +4567,8 @@ sub email_as_username {
sub captcha_choice {
my ($context,$settings,$itemcount) = @_;
- my ($keyentry,$currpub,$currpriv,%checked,$rowname,$pubtext,$privtext);
+ my ($keyentry,$currpub,$currpriv,%checked,$rowname,$pubtext,$privtext,
+ $vertext,$currver);
my %lt = &captcha_phrases();
$keyentry = 'hidden';
if ($context eq 'cancreate') {
@@ -4553,6 +4586,11 @@ sub captcha_choice {
$pubtext = $lt{'pub'};
$privtext = $lt{'priv'};
$keyentry = 'text';
+ $vertext = $lt{'ver'};
+ $currver = $settings->{'recaptchaversion'};
+ if ($currver ne '2') {
+ $currver = 1;
+ }
}
if (ref($settings->{'recaptchakeys'}) eq 'HASH') {
$currpub = $settings->{'recaptchakeys'}{'public'};
@@ -4586,7 +4624,11 @@ sub captcha_choice {
$currpub.'" size="40" />
'."\n".
''.$privtext.' '."\n".
''."\n".
+ $currpriv.'" size="40" />
'.
+ ''.$vertext.' '."\n".
+ '
'.
+ ''."\n".
'';
return $output;
}
@@ -6373,6 +6415,13 @@ sub modify_login {
$chgtxt .= '';
$resulttext .= ''.$chgtxt.'';
}
+ } elsif ($item eq 'recaptchaversion') {
+ if (ref($loginhash{'login'}) eq 'HASH') {
+ if ($loginhash{'login'}{'captcha'} eq 'recaptcha') {
+ $resulttext .= ''.&mt('ReCAPTCHA for helpdesk form set to version [_1]',$loginhash{'login'}{'recaptchaversion'}).
+ '';
+ }
+ }
} else {
$resulttext .= ''.&mt("$title{$item} set to $offon[$env{'form.'.$item}]").'';
}
@@ -7885,7 +7934,8 @@ sub modify_autoenroll {
my $autorun = &Apache::lonnet::auto_run(undef,$dom),
my %title = ( run => 'Auto-enrollment active',
sender => 'Sender for notification messages',
- coowners => 'Automatic assignment of co-ownership to instructors of record (institutional data)');
+ coowners => 'Automatic assignment of co-ownership to instructors of record (institutional data)',
+ failsafe => 'Failsafe for no drops if institutional data missing for a section');
my @offon = ('off','on');
my $sender_uname = $env{'form.sender_uname'};
my $sender_domain = $env{'form.sender_domain'};
@@ -7895,11 +7945,17 @@ sub modify_autoenroll {
$sender_domain = '';
}
my $coowners = $env{'form.autoassign_coowners'};
+ my $failsafe = $env{'form.autoenroll_failsafe'};
+ $failsafe =~ s{^\s+|\s+$}{}g;
+ if ($failsafe =~ /\D/) {
+ undef($failsafe);
+ }
my %autoenrollhash = (
autoenroll => { 'run' => $env{'form.autoenroll_run'},
'sender_uname' => $sender_uname,
'sender_domain' => $sender_domain,
'co-owners' => $coowners,
+ 'autofailsafe' => $failsafe,
}
);
my $putresult = &Apache::lonnet::put_dom('configuration',\%autoenrollhash,
@@ -7926,7 +7982,10 @@ sub modify_autoenroll {
}
} elsif ($coowners) {
$changes{'coowners'} = 1;
- }
+ }
+ if ($currautoenroll{'autofailsafe'} ne $failsafe) {
+ $changes{'autofailsafe'} = 1;
+ }
if (keys(%changes) > 0) {
$resulttext = &mt('Changes made:').'';
if ($changes{'run'}) {
@@ -7946,6 +8005,17 @@ sub modify_autoenroll {
$lastactref->{'domainconfig'} = 1;
}
}
+ if ($changes{'autofailsafe'}) {
+ if ($failsafe ne '') {
+ $resulttext .= '- '.&mt("$title{'failsafe'} set to [_1]",$failsafe).'
';
+ } else {
+ $resulttext .= '- '.&mt("$title{'failsafe'} deleted");
+ }
+ &Apache::lonnet::get_domain_defaults($dom,1);
+ if (ref($lastactref) eq 'HASH') {
+ $lastactref->{'domdefaults'} = 1;
+ }
+ }
$resulttext .= '
';
} else {
$resulttext = &mt('No changes made to auto-enrollment settings');
@@ -8573,7 +8643,8 @@ sub modify_usercreation {
if (ref($domconfig{'usercreation'}{$key}) eq 'HASH') {
foreach my $item (keys(%{$domconfig{'usercreation'}{$key}})) {
if (($item eq 'selfcreate') || ($item eq 'statustocreate') ||
- ($item eq 'captcha') || ($item eq 'recaptchakeys')) {
+ ($item eq 'captcha') || ($item eq 'recaptchakeys') ||
+ ($item eq 'recaptchaversion')) {
$save_usercreate{$key}{$item} = $domconfig{'usercreation'}{$key}{$item};
} else {
$curr_usercreation{$key}{$item} = $domconfig{'usercreation'}{$key}{$item};
@@ -8797,6 +8868,7 @@ sub modify_selfcreation {
foreach my $item (keys(%{$domconfig{'usercreation'}{$key}})) {
if (($item eq 'selfcreate') || ($item eq 'statustocreate') ||
($item eq 'captcha') || ($item eq 'recaptchakeys') ||
+ ($item eq 'recaptchaversion') ||
($item eq 'emailusername') || ($item eq 'notify') ||
($item eq 'selfcreateprocessing') || ($item eq 'shibenv')) {
$curr_usercreation{$key}{$item} = $domconfig{'usercreation'}{$key}{$item};
@@ -9126,6 +9198,7 @@ sub modify_selfcreation {
#
$save_usercreate{'cancreate'}{'captcha'} = $savecaptcha{'captcha'};
$save_usercreate{'cancreate'}{'recaptchakeys'} = $savecaptcha{'recaptchakeys'};
+ $save_usercreate{'cancreate'}{'recaptchaversion'} = $savecaptcha{'recaptchaversion'};
$save_usercreate{'cancreate'}{'selfcreate'} = $cancreate{'selfcreate'};
if (ref($cancreate{'notify'}) eq 'HASH') {
$save_usercreate{'cancreate'}{'notify'} = $cancreate{'notify'};
@@ -9287,6 +9360,10 @@ sub modify_selfcreation {
$chgtext .= ''.&mt('Private key set to [_1]',$pubkey).'';
}
$chgtext .= '';
+ } elsif ($type eq 'recaptchaversion') {
+ if ($savecaptcha{'captcha'} eq 'recaptcha') {
+ $chgtext .= &mt('ReCAPTCHA set to version [_1]',$savecaptcha{$type});
+ }
} elsif ($type eq 'emailusername') {
if (ref($cancreate{'emailusername'}) eq 'HASH') {
if (ref($types) eq 'ARRAY') {
@@ -9407,7 +9484,7 @@ sub process_captcha {
$changes->{'captcha'} = 1;
}
}
- my ($newpub,$newpriv,$currpub,$currpriv);
+ my ($newpub,$newpriv,$currpub,$currpriv,$newversion,$currversion);
if ($newsettings->{'captcha'} eq 'recaptcha') {
$newpub = $env{'form.'.$container.'_recaptchapub'};
$newpriv = $env{'form.'.$container.'_recaptchapriv'};
@@ -9417,6 +9494,12 @@ sub process_captcha {
public => $newpub,
private => $newpriv,
};
+ $newversion = $env{'form.'.$container.'_recaptchaversion'};
+ $newversion =~ s/\D//g;
+ if ($newversion ne '2') {
+ $newversion = 1;
+ }
+ $newsettings->{'recaptchaversion'} = $newversion;
}
if (ref($current->{'recaptchakeys'}) eq 'HASH') {
$currpub = $current->{'recaptchakeys'}{'public'};
@@ -9428,6 +9511,23 @@ sub process_captcha {
}
}
}
+ if ($current->{'captcha'} eq 'recaptcha') {
+ $currversion = $current->{'recaptchaversion'};
+ if ($currversion ne '2') {
+ $currversion = 1;
+ }
+ }
+ if ($currversion ne $newversion) {
+ if ($container eq 'cancreate') {
+ if (ref($changes->{'cancreate'}) eq 'ARRAY') {
+ push(@{$changes->{'cancreate'}},'recaptchaversion');
+ } elsif (!defined($changes->{'cancreate'})) {
+ $changes->{'cancreate'} = ['recaptchaversion'];
+ }
+ } else {
+ $changes->{'recaptchaversion'} = 1;
+ }
+ }
if (($newpub ne $currpub) || ($newpriv ne $currpriv)) {
if ($container eq 'cancreate') {
if (ref($changes->{'cancreate'}) eq 'ARRAY') {
@@ -10325,12 +10425,14 @@ sub modify_coursedefaults {
);
my @toggles = ('uselcmath','usejsme');
my @numbers = ('anonsurvey_threshold','uploadquota_official','uploadquota_unofficial',
- 'uploadquota_community','uploadquota_textbook');
+ 'uploadquota_community','uploadquota_textbook','mysqltables_official',
+ 'mysqltables_unofficial','mysqltables_community','mysqltables_textbook');
my @types = ('official','unofficial','community','textbook');
my %staticdefaults = (
anonsurvey_threshold => 10,
uploadquota => 500,
postsubmit => 60,
+ mysqltables => 172800,
);
$defaultshash{'coursedefaults'} = {};
@@ -10371,12 +10473,12 @@ sub modify_coursedefaults {
}
$defaultshash{'coursedefaults'}{$item} = $newdef;
} else {
- my ($type) = ($item =~ /^\Quploadquota_\E(\w+)$/);
- if (ref($domconfig{'coursedefaults'}{'uploadquota'}) eq 'HASH') {
- $currdef = $domconfig{'coursedefaults'}{'uploadquota'}{$type};
+ my ($setting,$type) = ($item =~ /^(uploadquota|mysqltables)_(\w+)$/);
+ if (ref($domconfig{'coursedefaults'}{$setting}) eq 'HASH') {
+ $currdef = $domconfig{'coursedefaults'}{$setting}{$type};
}
$newdef =~ s/[^\w.\-]//g;
- $defaultshash{'coursedefaults'}{'uploadquota'}{$type} = $newdef;
+ $defaultshash{'coursedefaults'}{$setting}{$type} = $newdef;
}
if ($currdef ne $newdef) {
my $staticdef;
@@ -10384,9 +10486,10 @@ sub modify_coursedefaults {
unless (($currdef eq '') && ($newdef == $staticdefaults{$item})) {
$changes{$item} = 1;
}
- } else {
- unless (($currdef eq '') && ($newdef == $staticdefaults{'uploadquota'})) {
- $changes{'uploadquota'} = 1;
+ } elsif ($item =~ /^(uploadquota|mysqltables)_/) {
+ my $setting = $1;
+ unless (($currdef eq '') && ($newdef == $staticdefaults{$setting})) {
+ $changes{$setting} = 1;
}
}
}
@@ -10511,7 +10614,7 @@ sub modify_coursedefaults {
my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
if (($changes{'uploadquota'}) || ($changes{'postsubmit'}) ||
($changes{'coursecredits'}) || ($changes{'uselcmath'}) || ($changes{'usejsme'}) ||
- ($changes{'canclone'})) {
+ ($changes{'canclone'}) || ($changes{'mysqltables'})) {
foreach my $item ('uselcmath','usejsme') {
if ($changes{$item}) {
$domdefaults{$item}=$defaultshash{'coursedefaults'}{$item};
@@ -10590,6 +10693,18 @@ sub modify_coursedefaults {
} else {
$resulttext .= ''.&mt('Default quota for content uploaded via Course Editor remains default: [_1] MB',$staticdefaults{'uploadquota'}).'';
}
+ } elsif ($item eq 'mysqltables') {
+ if (ref($defaultshash{'coursedefaults'}{'mysqltables'}) eq 'HASH') {
+ $resulttext .= ''.&mt('Lifetime of "Temporary" MySQL tables (student performance data) on homeserver').''.
+ '- '.&mt('Official courses: [_1] s',''.$defaultshash{'coursedefaults'}{'mysqltables'}{'official'}.'').'
'.
+ '- '.&mt('Unofficial courses: [_1] s',''.$defaultshash{'coursedefaults'}{'mysqltables'}{'unofficial'}.'').'
'.
+ '- '.&mt('Textbook courses: [_1] s',''.$defaultshash{'coursedefaults'}{'mysqltables'}{'textbook'}.'').'
'.
+ '- '.&mt('Communities: [_1] s',''.$defaultshash{'coursedefaults'}{'mysqltables'}{'community'}.'').'
'.
+ '
'.
+ '';
+ } else {
+ $resulttext .= ''.&mt('Lifetime of "Temporary" MySQL tables (student performance data) on homeserver remains default: [_1] s',$staticdefaults{'uploadquota'}).'';
+ }
} elsif ($item eq 'postsubmit') {
if ($domdefaults{'postsubmit'} eq 'off') {
$resulttext .= ''.&mt('Submit button(s) remain enabled on page after student makes submission.');
@@ -12108,6 +12223,8 @@ function updateCaptcha(caller,context) {
var pubitem;
var privtext;
var pubtext;
+ var versionitem;
+ var versiontext;
if (document.getElementById(context+'_recaptchapub')) {
pubitem = document.getElementById(context+'_recaptchapub');
} else {
@@ -12128,6 +12245,16 @@ function updateCaptcha(caller,context) {
} else {
return;
}
+ if (document.getElementById(context+'_recaptchaversion')) {
+ versionitem = document.getElementById(context+'_recaptchaversion');
+ } else {
+ return;
+ }
+ if (document.getElementById(context+'_recaptchavertxt')) {
+ versiontext = document.getElementById(context+'_recaptchavertxt');
+ } else {
+ return;
+ }
if (caller.checked) {
if (caller.value == 'recaptcha') {
pubitem.type = 'text';
@@ -12136,11 +12263,16 @@ function updateCaptcha(caller,context) {
privitem.size = '40';
pubtext.innerHTML = "$lt{'pub'}";
privtext.innerHTML = "$lt{'priv'}";
+ versionitem.type = 'text';
+ versionitem.size = '3';
+ versiontext.innerHTML = "$lt{'ver'}";
} else {
pubitem.type = 'hidden';
privitem.type = 'hidden';
+ versionitem.type = 'hidden';
pubtext.innerHTML = '';
privtext.innerHTML = '';
+ versiontext.innerHTML = '';
}
}
return;
@@ -12206,6 +12338,7 @@ sub captcha_phrases {
original => 'original (CAPTCHA)',
recaptcha => 'successor (ReCAPTCHA)',
notused => 'unused',
+ ver => 'ReCAPTCHA version (1 or 2)',
);
}