[LON-CAPA-cvs] cvs: loncom(version_2_12_X) /interface domainprefs.pm
raeburn
raeburn at source.lon-capa.org
Fri Jan 9 17:18:40 EST 2026
raeburn Fri Jan 9 22:18:40 2026 EDT
Modified files: (Branch: version_2_12_X)
/loncom/interface domainprefs.pm
Log:
- For 2.12
Backport 1.453, 1.454, 1.455, 1.456.
-------------- next part --------------
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.447.2.7 loncom/interface/domainprefs.pm:1.447.2.8
--- loncom/interface/domainprefs.pm:1.447.2.7 Tue May 13 07:22:47 2025
+++ loncom/interface/domainprefs.pm Fri Jan 9 22:18:40 2026
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.447.2.7 2025/05/13 07:22:47 raeburn Exp $
+# $Id: domainprefs.pm,v 1.447.2.8 2026/01/09 22:18:40 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2645,6 +2645,9 @@
}
} else {
my $checked = 'checked="checked" ';
+ if ($item eq 'timezone') {
+ $checked = '';
+ }
if (ref($settings) eq 'HASH') {
if (ref($settings->{$item}) eq 'HASH') {
if ($settings->{$item}->{'default'} == 0) {
@@ -2776,6 +2779,9 @@
}
} else {
my $checked = 'checked="checked" ';
+ if ($item eq 'timezone') {
+ $checked = '';
+ }
if (ref($settings) eq 'HASH') {
if (ref($settings->{$item}) eq 'HASH') {
if ($settings->{$item}->{'_LC_adv'} == 0) {
@@ -10418,10 +10424,14 @@
sub captcha_choice {
my ($context,$settings,$itemcount,$customcss,$rowstyle) = @_;
- my ($keyentry,$currpub,$currpriv,%checked,$rowname,$pubtext,$privtext,
- $vertext,$currver);
+ my ($currpub,$currpriv,$currtype,$currver,%checked,$rowname,
+ $dispprov,$dispver,$dispkeys,$threshold,$threshtext,$threshentry);
my %lt = &captcha_phrases();
- $keyentry = 'hidden';
+ $threshtext = '';
+ $threshentry = 'hidden';
+ $dispkeys = 'none';
+ $dispprov = 'none';
+ $dispver = 'none';
my $colspan=2;
if ($context eq 'cancreate') {
$rowname = &mt('CAPTCHA validation');
@@ -10437,14 +10447,24 @@
} else {
$checked{'original'} = ' checked="checked"';
}
- if ($settings->{'captcha'} eq 'recaptcha') {
- $pubtext = $lt{'pub'};
- $privtext = $lt{'priv'};
- $keyentry = 'text';
- $vertext = $lt{'ver'};
- $currver = $settings->{'recaptchaversion'};
- if ($currver ne '2') {
- $currver = 1;
+ if (($settings->{'captcha'} eq 'recaptcha') ||
+ ($settings->{'captcha'} eq 'hcaptcha') ||
+ ($settings->{'captcha'} eq 'turnstile')) {
+ $checked{'successor'} = ' checked="checked"';
+ $currtype = $settings->{'captcha'};
+ $dispkeys = 'block';
+ $dispprov = 'block';
+ if ($settings->{'captcha'} eq 'recaptcha') {
+ $dispver = 'block';
+ $currver = $settings->{'recaptchaversion'};
+ if ($currver eq '1') {
+ $currver = 2;
+ }
+ if ($currver eq '3') {
+ $threshold = $settings->{'captchathreshold'};
+ $threshtext = $lt{'threshold'};
+ $threshentry = 'text';
+ }
}
}
if (ref($settings->{'recaptchakeys'}) eq 'HASH') {
@@ -10470,32 +10490,61 @@
}
my $output = '<tr'.$css_class.'>'.
'<td class="LC_left_item">'.$rowname.'</td><td class="LC_left_item" colspan="'.$colspan.'">'."\n".
- '<table><tr><td>'."\n";
- foreach my $option ('original','recaptcha','notused') {
+ '<table><tr><td><fieldset class="LC_captcha"><legend>'.$lt{'captcha'}.'</legend>'."\n";
+ foreach my $option ('original','successor','notused') {
$output .= '<span class="LC_nobreak"><label><input type="radio" name="'.$context.'_captcha" value="'.
- $option.'" '.$checked{$option}.' onchange="javascript:updateCaptcha('."this,'$context'".');" />'.
+ $option.'" '.$checked{$option}.' onchange="javascript:updateCaptcha('."'captcha','$context',this.form".');" />'.
$lt{$option}.'</label></span>';
unless ($option eq 'notused') {
$output .= (' 'x2)."\n";
}
}
#
-# Note: If reCAPTCHA is to be used for LON-CAPA servers in a domain, a domain coordinator should visit:
-# https://www.google.com/recaptcha and generate a Public and Private key. For domains with multiple
-# servers a single key pair will be used for all servers, so the internet domain (e.g., yourcollege.edu)
-# specified for use with the key should be broad enough to accommodate all servers in the LON-CAPA domain.
+# Note: If reCaptcha is to be used for LON-CAPA servers in a domain, a domain coordinator should visit:
+# https://cloud.google.com/security/products/recaptcha and generate a site key and secret key. For domains
+# with multiple servers a single key pair will be used for all servers, so the internet domain
+# (e.g., yourcollege.edu) specified for use with the key should be broad enough to accommodate all servers
+# in the LON-CAPA domain. If a change is made from using reCaptcha v2 to using v3, then a new pair
+# needs to be generated via the Google Cloud dashboard.
+#
+# Similarly, if hCaptcha is to be used, a site key and secret key will need to be generated by adding a
+# new site at https://dashboard.hcaptcha.com/, and if Turnstile is to be used a site key and secret key
+# will need to be created by visiting https://dash.cloudflare.com and adding a new Turnstile widget.
#
- $output .= '</td></tr>'."\n".
+ $output .= '</fieldset></td></tr>'."\n".
'<tr><td class="LC_zero_height">'."\n".
- '<span class="LC_nobreak"><span id="'.$context.'_recaptchapubtxt">'.$pubtext.'</span> '."\n".
- '<input type="'.$keyentry.'" id="'.$context.'_recaptchapub" name="'.$context.'_recaptchapub" value="'.
- $currpub.'" size="40" /></span><br />'."\n".
- '<span class="LC_nobreak"><span id="'.$context.'_recaptchaprivtxt">'.$privtext.'</span> '."\n".
- '<input type="'.$keyentry.'" id="'.$context.'_recaptchapriv" name="'.$context.'_recaptchapriv" value="'.
- $currpriv.'" size="40" /></span><br />'.
- '<span class="LC_nobreak"><span id="'.$context.'_recaptchavertxt">'.$vertext.'</span> '."\n".
- '<input type="'.$keyentry.'" id="'.$context.'_recaptchaversion" name="'.$context.'_recaptchaversion" value="'.
- $currver.'" size="3" /></span><br />'.
+ '<fieldset class="LC_captcha" id="'.$context.'_recaptchatype" style="display:'.$dispprov.'">'.
+ '<legend>'.$lt{'type'}.'</legend>'."\n";
+ foreach my $type ('recaptcha','hcaptcha','turnstile') {
+ my $provider = $lt{$type};
+ my $checked;
+ if ($currtype eq $type) {
+ $checked = ' checked="checked"';
+ }
+ $output .= '<label><input type="radio" name="'.$context.'_captchaprovider" value="'.$type.'"'.$checked.' onchange="javascript:updateCaptchaProv('."'captchaprovider','$context',this.form".');" />'.$provider.'</label> ';
+ }
+ $output .= '</fieldset><br />'.
+ '<fieldset class="LC_captcha" id="'.$context.'_recaptchaver" style="display:'.$dispver.'"><legend>'.$lt{'ver'}.'</legend>'."\n".
+ '<span class="LC_nobreak">';
+ foreach my $poss ('2','3') {
+ my $checked;
+ if ($currver eq $poss) {
+ $checked = ' checked="checked"'
+ }
+ $output .= '<label><input type="radio" name="'.$context.'_recaptchaversion" value="'.$poss.'"'.$checked.' onchange="javascript:updateRecapVer('."'recaptchaversion','$context',this.form".');" />'.$poss.'</label> ';
+ }
+ $output .= '<span class="LC_nobreak">'.
+ '<span id="'.$context.'_recaptchathrtxt">'.$threshtext.'</span>'."\n".
+ ' <input id="'.$context.'_recaptchathresh" type="'.$threshentry.'" size="3"'.
+ ' name="'.$context.'_captchathreshold" value="'.$threshold.'" /></span></span>'."\n".
+ '</fieldset><br />'.
+ '<fieldset class="LC_captcha" id="'.$context.'_recaptchakeys" style="display:'.$dispkeys.'"><legend>'.$lt{'keys'}.'</legend>'."\n".
+ '<span class="LC_nobreak">'.$lt{'pub'}.': '.
+ '<input type="text" name="'.$context.'_recaptchapub" value="'.$currpub.'" size="40" />'.
+ '</span><br />'."\n".
+ '<span class="LC_nobreak">'.$lt{'priv'}.': '.
+ '<input type="text" name="'.$context.'_recaptchapriv" value="'.$currpriv.'" size="40" /></span>'."\n".
+ '</fieldset><br />'."\n".
'</td></tr></table>'."\n".
'</td></tr>';
return $output;
@@ -12962,16 +13011,16 @@
$pubkey = $loginhash{'login'}{$item}{'public'};
$privkey = $loginhash{'login'}{$item}{'private'};
}
- my $chgtxt .= &mt('ReCAPTCHA keys changes').'<ul>';
+ my $chgtxt .= &mt('CAPTCHA keys changes').'<ul>';
if (!$pubkey) {
- $chgtxt .= '<li>'.&mt('Public key deleted').'</li>';
+ $chgtxt .= '<li>'.&mt('Site key deleted').'</li>';
} else {
- $chgtxt .= '<li>'.&mt('Public key set to [_1]',$pubkey).'</li>';
+ $chgtxt .= '<li>'.&mt('Site key set to [_1]',$pubkey).'</li>';
}
if (!$privkey) {
- $chgtxt .= '<li>'.&mt('Private key deleted').'</li>';
+ $chgtxt .= '<li>'.&mt('Secret key deleted').'</li>';
} else {
- $chgtxt .= '<li>'.&mt('Private key set to [_1]',$privkey).'</li>';
+ $chgtxt .= '<li>'.&mt('Secret key set to [_1]',$privkey).'</li>';
}
$chgtxt .= '</ul>';
$resulttext .= '<li>'.$chgtxt.'</li>';
@@ -12979,7 +13028,15 @@
} elsif ($item eq 'recaptchaversion') {
if (ref($loginhash{'login'}) eq 'HASH') {
if ($loginhash{'login'}{'captcha'} eq 'recaptcha') {
- $resulttext .= '<li>'.&mt('ReCAPTCHA for helpdesk form set to version [_1]',$loginhash{'login'}{'recaptchaversion'}).
+ $resulttext .= '<li>'.&mt('reCaptcha for helpdesk form set to version [_1]',$loginhash{'login'}{'recaptchaversion'}).
+ '</li>';
+ }
+ }
+ } elsif ($item eq 'captchathreshold') {
+ if (ref($loginhash{'login'}) eq 'HASH') {
+ if (($loginhash{'login'}{'captcha'} eq 'recaptcha') &&
+ ($loginhash{'login'}{'recaptchaversion'} eq '3')) {
+ $resulttext .= '<li>'.&mt('reCaptcha for helpdesk form rejection threshold set to [_1]',$loginhash{'login'}{'captchathreshold'}).
'</li>';
}
}
@@ -14499,6 +14556,10 @@
if ($confhash{$item}{$type} ne $unset) {
$changes{$item}{$type} = 1;
}
+ } elsif ($item eq 'timezone') {
+ if ($confhash{$item}{$type}) {
+ $changes{$item}{$type} = 1;
+ }
} else {
if (!$confhash{$item}{$type}) {
$changes{$item}{$type} = 1;
@@ -14514,6 +14575,10 @@
if ($confhash{$type} ne $unset) {
$changes{$type} = 1;
}
+ } elsif ($item eq 'timezone') {
+ if ($confhash{$item}{$type}) {
+ $changes{$item}{$type} = 1;
+ }
} else {
if (!$confhash{$item}{$type}) {
$changes{$item}{$type} = 1;
@@ -15816,7 +15881,7 @@
$errors .= '<li>'.$proterror.'</li>';
}
- my (%delsuggested,%suggids, at suggested);;
+ my (%delsuggested,%suggids, at suggested);
if (ref($currltisec{'suggested'}) eq 'HASH') {
my $maxnum = $env{'form.linkprot_suggested_maxnum'};
my @todelete = &Apache::loncommon::get_env_multiple('form.linkprot_suggested_del');
@@ -18291,11 +18356,30 @@
if ($confighash{'passwords'}{'captcha'} eq 'original') {
$resulttext .= '<li>'.&mt('CAPTCHA validation set to use: original CAPTCHA').'</li>';
} elsif ($confighash{'passwords'}{'captcha'} eq 'recaptcha') {
- $resulttext .= '<li>'.&mt('CAPTCHA validation set to use: reCAPTCHA').' '.
- &mt('version: [_1]',$confighash{'passwords'}{'recaptchaversion'}).'<br />';
+ $resulttext .= '<li>'.&mt('CAPTCHA validation set to use: reCaptcha').' '.
+ &mt('version: [_1]',$confighash{'passwords'}{'recaptchaversion'});
+ if ($confighash{'passwords'}{'recaptchaversion'} eq '3') {
+ $resulttext .= ' '.&mt('rejection threshold set to [_1]',
+ $confighash{'passwords'}{'captchathreshold'});
+ }
+ $resulttext .= '<br />';
if (ref($confighash{'passwords'}{'recaptchakeys'}) eq 'HASH') {
- $resulttext .= &mt('Public key: [_1]',$confighash{'passwords'}{'recaptchakeys'}{'public'}).'</br>'.
- &mt('Private key: [_1]',$confighash{'passwords'}{'recaptchakeys'}{'private'}).'</li>';
+ $resulttext .= &mt('Site key: [_1]',$confighash{'passwords'}{'recaptchakeys'}{'public'}).'</br>'.
+ &mt('Secret key: [_1]',$confighash{'passwords'}{'recaptchakeys'}{'private'}).'</li>';
+ }
+ } elsif (($confighash{'passwords'}{'captcha'} eq 'hcaptcha') ||
+ ($confighash{'passwords'}{'captcha'} eq 'turnstile')) {
+ my %captchas = &captcha_phrases();
+ if ($captchas{$confighash{'passwords'}{'captcha'}}) {
+ $resulttext .= '<li>'.&mt('CAPTCHA validation set to use: [_1]',
+ $captchas{$confighash{'passwords'}{'captcha'}}).
+ '<br />';
+ if (ref($confighash{'passwords'}{'recaptchakeys'}) eq 'HASH') {
+ $resulttext .= &mt('Site key: [_1]',$confighash{'passwords'}{'recaptchakeys'}{'public'}).'</br>'.
+ &mt('Secret key: [_1]',$confighash{'passwords'}{'recaptchakeys'}{'private'}).'</li>';
+ }
+ } else {
+ $resulttext .= &mt('CAPTCHA validation set to use unknown type.');
}
} else {
$resulttext .= '<li>'.&mt('No CAPTCHA validation').'</li>';
@@ -19211,7 +19295,12 @@
#
$save_usercreate{'cancreate'}{'captcha'} = $savecaptcha{'captcha'};
$save_usercreate{'cancreate'}{'recaptchakeys'} = $savecaptcha{'recaptchakeys'};
- $save_usercreate{'cancreate'}{'recaptchaversion'} = $savecaptcha{'recaptchaversion'};
+ if ($savecaptcha{'captcha'} eq 'recaptcha') {
+ $save_usercreate{'cancreate'}{'recaptchaversion'} = $savecaptcha{'recaptchaversion'};
+ if ($savecaptcha{'recaptchaversion'} eq '3') {
+ $save_usercreate{'cancreate'}{'captchathreshold'} = $savecaptcha{'captchathreshold'};
+ }
+ }
$save_usercreate{'cancreate'}{'selfcreate'} = $cancreate{'selfcreate'};
if (ref($cancreate{'notify'}) eq 'HASH') {
$save_usercreate{'cancreate'}{'notify'} = $cancreate{'notify'};
@@ -19482,21 +19571,25 @@
$pubkey = $savecaptcha{$type}{'public'};
$privkey = $savecaptcha{$type}{'private'};
}
- $chgtext .= &mt('ReCAPTCHA keys changes').'<ul>';
+ $chgtext .= &mt('CAPTCHA keys changes').'<ul>';
if (!$pubkey) {
- $chgtext .= '<li>'.&mt('Public key deleted').'</li>';
+ $chgtext .= '<li>'.&mt('Site key deleted').'</li>';
} else {
- $chgtext .= '<li>'.&mt('Public key set to [_1]',$pubkey).'</li>';
+ $chgtext .= '<li>'.&mt('Site key set to [_1]',$pubkey).'</li>';
}
if (!$privkey) {
- $chgtext .= '<li>'.&mt('Private key deleted').'</li>';
+ $chgtext .= '<li>'.&mt('Secret key deleted').'</li>';
} else {
- $chgtext .= '<li>'.&mt('Private key set to [_1]',$pubkey).'</li>';
+ $chgtext .= '<li>'.&mt('Secret key set to [_1]',$pubkey).'</li>';
}
$chgtext .= '</ul>';
} elsif ($type eq 'recaptchaversion') {
if ($savecaptcha{'captcha'} eq 'recaptcha') {
- $chgtext .= &mt('ReCAPTCHA set to version [_1]',$savecaptcha{$type});
+ $chgtext .= &mt('reCaptcha set to version [_1]',$savecaptcha{$type});
+ }
+ } elsif ($type eq 'captchathreshold') {
+ if (($savecaptcha{'captcha'} eq 'recaptcha') && ($savecaptcha{'recaptchaversion'} eq '3')) {
+ $chgtext .= &mt('reCaptcha v3 rejection threshold set to [_1]',$savecaptcha{$type});
}
} elsif ($type eq 'emailusername') {
if (ref($cancreate{'emailusername'}) eq 'HASH') {
@@ -19648,9 +19741,18 @@
my ($container,$changes,$newsettings,$currsettings) = @_;
return unless ((ref($changes) eq 'HASH') && (ref($newsettings) eq 'HASH'));
$newsettings->{'captcha'} = $env{'form.'.$container.'_captcha'};
- unless ($newsettings->{'captcha'} eq 'recaptcha' || $newsettings->{'captcha'} eq 'notused') {
+ unless (($newsettings->{'captcha'} eq 'successor') ||
+ ($newsettings->{'captcha'} eq 'notused')) {
$newsettings->{'captcha'} = 'original';
}
+ if ($newsettings->{'captcha'} eq 'successor') {
+ $newsettings->{'captcha'} = $env{'form.'.$container.'_captchaprovider'};
+ unless (($newsettings->{'captcha'} eq 'recaptcha') ||
+ ($newsettings->{'captcha'} eq 'hcaptcha') ||
+ ($newsettings->{'captcha'} eq 'turnstile')) {
+ $newsettings->{'captcha'} = 'original';
+ }
+ }
my %current;
if (ref($currsettings) eq 'HASH') {
%current = %{$currsettings};
@@ -19668,8 +19770,11 @@
$changes->{'captcha'} = 1;
}
}
- my ($newpub,$newpriv,$currpub,$currpriv,$newversion,$currversion);
- if ($newsettings->{'captcha'} eq 'recaptcha') {
+ my ($newpub,$newpriv,$currpub,$currpriv,$newversion,$currversion,
+ $newthreshold,$currthreshold);
+ if (($newsettings->{'captcha'} eq 'recaptcha') ||
+ ($newsettings->{'captcha'} eq 'hcaptcha') ||
+ ($newsettings->{'captcha'} eq 'turnstile')) {
$newpub = $env{'form.'.$container.'_recaptchapub'};
$newpriv = $env{'form.'.$container.'_recaptchapriv'};
$newpub =~ s/[^\w\-]//g;
@@ -19678,17 +19783,30 @@
public => $newpub,
private => $newpriv,
};
- $newversion = $env{'form.'.$container.'_recaptchaversion'};
- $newversion =~ s/\D//g;
- if ($newversion ne '2') {
- $newversion = 1;
+ if ($newsettings->{'captcha'} eq 'recaptcha') {
+ $newversion = $env{'form.'.$container.'_recaptchaversion'};
+ $newversion =~ s/\D//g;
+ if ($newversion eq '3') {
+ $newthreshold = $env{'form.'.$container.'_captchathreshold'};
+ $newthreshold =~ s/^\s+|\s+$//g;
+ unless (($newthreshold =~ /^\d(|\.\d*)$/) ||
+ ($newthreshold =~ /^\.\d+$/) &&
+ ($newthreshold >= 0.0) && ($newthreshold <= 1.0)) {
+ $newthreshold = 0.5;
+ }
+ $newsettings->{'captchathreshold'} = $newthreshold;
+ } else {
+ $newversion = 2;
+ }
+ $newsettings->{'recaptchaversion'} = $newversion;
}
- $newsettings->{'recaptchaversion'} = $newversion;
}
if (ref($current{'recaptchakeys'}) eq 'HASH') {
$currpub = $current{'recaptchakeys'}{'public'};
$currpriv = $current{'recaptchakeys'}{'private'};
- unless ($newsettings->{'captcha'} eq 'recaptcha') {
+ unless (($newsettings->{'captcha'} eq 'recaptcha') ||
+ ($newsettings->{'captcha'} eq 'hcaptcha') ||
+ ($newsettings->{'captcha'} eq 'turnstile')) {
$newsettings->{'recaptchakeys'} = {
public => '',
private => '',
@@ -19697,9 +19815,12 @@
}
if ($current{'captcha'} eq 'recaptcha') {
$currversion = $current{'recaptchaversion'};
- if ($currversion ne '2') {
+ if (($currversion ne '2') && ($currversion ne '3')) {
$currversion = 1;
}
+ if ($currversion eq '3') {
+ $currthreshold = $current{'captchathreshold'};
+ }
}
if ($currversion ne $newversion) {
if ($container eq 'cancreate') {
@@ -19727,6 +19848,22 @@
$changes->{'recaptchakeys'} = 1;
}
}
+ if (($newsettings->{'captcha'} eq 'recaptcha') && ($current{'captcha'} eq 'recaptcha') &&
+ ($newsettings->{'recaptchaversion'} eq '3') && ($currversion eq '3')) {
+ if ($newsettings->{'captchathreshold'} ne $currthreshold) {
+ if ($container eq 'cancreate') {
+ if (ref($changes->{'cancreate'}) eq 'ARRAY') {
+ push(@{$changes->{'cancreate'}},'captchathreshold');
+ } elsif (!defined($changes->{'cancreate'})) {
+ $changes->{'cancreate'} = ['captchathreshold'];
+ }
+ } elsif ($container eq 'passwords') {
+ $changes->{'reset'} = 1;
+ } else {
+ $changes->{'captchathreshold'} = 1;
+ }
+ }
+ }
return;
}
@@ -23873,64 +24010,92 @@
<script type="text/javascript">
// <![CDATA[
-function updateCaptcha(caller,context) {
- var privitem;
- var pubitem;
- var privtext;
- var pubtext;
- var versionitem;
- var versiontext;
- if (document.getElementById(context+'_recaptchapub')) {
- pubitem = document.getElementById(context+'_recaptchapub');
+function updateCaptcha(radio,context,form) {
+ var keysitem;
+ var typeitem;
+ var veritem;
+ if (document.getElementById(context+'_recaptchakeys')) {
+ keysitem = document.getElementById(context+'_recaptchakeys');
} else {
return;
}
- if (document.getElementById(context+'_recaptchapriv')) {
- privitem = document.getElementById(context+'_recaptchapriv');
+ if (document.getElementById(context+'_recaptchatype')) {
+ typeitem = document.getElementById(context+'_recaptchatype');
} else {
return;
}
- if (document.getElementById(context+'_recaptchapubtxt')) {
- pubtext = document.getElementById(context+'_recaptchapubtxt');
+ if (document.getElementById(context+'_recaptchaver')) {
+ veritem = document.getElementById(context+'_recaptchaver');
} else {
return;
}
- if (document.getElementById(context+'_recaptchaprivtxt')) {
- privtext = document.getElementById(context+'_recaptchaprivtxt');
+ if (form.elements[context+'_'+radio].length) {
+ for (var i=0; i<form.elements[context+'_'+radio].length; i++) {
+ if (form.elements[context+'_'+radio][i].checked) {
+ if (form.elements[context+'_'+radio][i].value == 'successor') {
+ keysitem.style.display='block';
+ typeitem.style.display='block';
+ updateCaptchaProv('captchaprovider',context,form);
+ } else {
+ keysitem.style.display='none';
+ typeitem.style.display='none';
+ veritem.style.display='none';
+ }
+ break;
+ }
+ }
+ }
+ return;
+}
+
+function updateCaptchaProv(radio,context,form) {
+ var veritem;
+ if (document.getElementById(context+'_recaptchaver')) {
+ veritem = document.getElementById(context+'_recaptchaver');
} else {
return;
}
- if (document.getElementById(context+'_recaptchaversion')) {
- versionitem = document.getElementById(context+'_recaptchaversion');
+ veritem.style.display = 'none';
+ if (form.elements[context+'_'+radio].length) {
+ for (var i=0; i<form.elements[context+'_'+radio].length; i++) {
+ if (form.elements[context+'_'+radio][i].checked) {
+ if (form.elements[context+'_'+radio][i].value == 'recaptcha') {
+ veritem.style.display = 'block';
+ updateRecapVer('recaptchaversion',context,form);
+ }
+ }
+ break;
+ }
+ }
+}
+
+function updateRecapVer(radio,context,form) {
+ var threshtxtitem;
+ if (document.getElementById(context+'_recaptchathrtxt')) {
+ threshtxtitem = document.getElementById(context+'_recaptchathrtxt');
} else {
return;
}
- if (document.getElementById(context+'_recaptchavertxt')) {
- versiontext = document.getElementById(context+'_recaptchavertxt');
+ var thresholditem;
+ if (document.getElementById(context+'_recaptchathresh')) {
+ thresholditem = document.getElementById(context+'_recaptchathresh');
} else {
return;
}
- if (caller.checked) {
- if (caller.value == 'recaptcha') {
- pubitem.type = 'text';
- privitem.type = 'text';
- pubitem.size = '40';
- 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 = '';
+ thresholditem.type = 'hidden';
+ threshtxtitem.innerHTML = "";
+ if (form.elements[context+'_'+radio].length) {
+ for (var i=0; i<form.elements[context+'_'+radio].length; i++) {
+ if (form.elements[context+'_'+radio][i].checked) {
+ if (form.elements[context+'_'+radio][i].value == '3') {
+ thresholditem.type = 'text';
+ thresholditem.size = '3';
+ threshtxtitem.innerHTML = "$lt{'threshold'}";
+ }
+ break;
+ }
}
}
- return;
}
// ]]>
@@ -23994,12 +24159,19 @@
sub captcha_phrases {
return &Apache::lonlocal::texthash (
- priv => 'Private key',
- pub => 'Public key',
- original => 'original (CAPTCHA)',
- recaptcha => 'successor (ReCAPTCHA)',
+ captcha => 'Captcha validation',
+ keys => 'Keys',
+ priv => 'Secret',
+ pub => 'Site',
+ original => 'original (perl module)',
+ successor => 'third party',
notused => 'unused',
- ver => 'ReCAPTCHA version (1 or 2)',
+ type => 'Provider',
+ recaptcha => 'reCaptcha',
+ hcaptcha => 'hCaptcha',
+ turnstile => 'Turnstile',
+ ver => 'reCaptcha version (2 or 3)',
+ threshold => '-- reject if score below:',
);
}
More information about the LON-CAPA-cvs
mailing list