--- loncom/interface/domainprefs.pm 2016/02/18 21:30:33 1.268 +++ loncom/interface/domainprefs.pm 2016/04/02 04:30:19 1.271 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.268 2016/02/18 21:30:33 raeburn Exp $ +# $Id: domainprefs.pm,v 1.271 2016/04/02 04:30:19 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -103,8 +103,8 @@ $datatable - HTML containing form eleme In the case of course requests, radio buttons are displayed for each institutional affiliate type (and also default, and _LC_adv) for each of the course types -(official, unofficial, community, and textbook). In each case the radio buttons -allow the selection of one of four values: +(official, unofficial, community, textbook, and placement). +In each case the radio buttons allow the selection of one of four values: 0, approval, validate, autolimit=N (where N is blank, or a positive integer). which have the following effects: @@ -1724,7 +1724,7 @@ sub print_quotas { my $typecount = 0; my ($css_class,%titles); if ($context eq 'requestcourses') { - @usertools = ('official','unofficial','community','textbook'); + @usertools = ('official','unofficial','community','textbook','placement'); @options =('norequest','approval','validate','autolimit'); %validations = &Apache::lonnet::auto_courserequest_checks($dom); %titles = &courserequest_titles(); @@ -2176,7 +2176,7 @@ sub print_studentcode { my ($settings,$rowtotal) = @_; my $rownum = 0; my ($output,%current); - my @crstypes = ('official','unofficial','community','textbook'); + my @crstypes = ('official','unofficial','community','textbook','placement'); if (ref($settings) eq 'HASH') { if (ref($settings->{'uniquecode'}) eq 'HASH') { foreach my $type (@crstypes) { @@ -3403,7 +3403,7 @@ sub print_coursedefaults { my ($currdefresponder,%defcredits,%curruploadquota,%deftimeout); my $currusecredits = 0; my $postsubmitclient = 1; - my @types = ('official','unofficial','community','textbook'); + my @types = ('official','unofficial','community','textbook','placement'); if (ref($settings) eq 'HASH') { $currdefresponder = $settings->{'anonsurvey_threshold'}; if (ref($settings->{'uploadquota'}) eq 'HASH') { @@ -3537,7 +3537,7 @@ sub print_selfenrollment { my ($position,$dom,$settings,$rowtotal) = @_; my ($css_class,$datatable); my $itemcount = 1; - my @types = ('official','unofficial','community','textbook'); + my @types = ('official','unofficial','community','textbook','placement'); if (($position eq 'top') || ($position eq 'middle')) { my ($rowsref,$titlesref) = &Apache::lonuserutils::get_selfenroll_titles(); my %descs = &Apache::lonuserutils::selfenroll_default_descs(); @@ -4556,6 +4556,7 @@ sub tool_titles { unofficial => 'Unofficial courses', community => 'Communities', textbook => 'Textbook courses', + placement => 'Placement tests', ); return %titles; } @@ -4566,6 +4567,7 @@ sub courserequest_titles { unofficial => 'Unofficial', community => 'Communities', textbook => 'Textbook', + placement => 'Placement tests', norequest => 'Not allowed', approval => 'Approval by Dom. Coord.', validate => 'With validation', @@ -4955,7 +4957,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') { @@ -4973,6 +4976,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'}; @@ -5006,7 +5014,11 @@ sub captcha_choice { $currpub.'" size="40" />
'."\n". ''.$privtext.' '."\n". ''."\n". + $currpriv.'" size="40" />
'. + ''.$vertext.' '."\n". + '
'. + ''."\n". ''; return $output; } @@ -6791,6 +6803,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}]").'
  • '; } @@ -7578,7 +7597,7 @@ sub modify_quotas { $context = $action; } if ($context eq 'requestcourses') { - @usertools = ('official','unofficial','community','textbook'); + @usertools = ('official','unofficial','community','textbook','placement'); @options =('norequest','approval','validate','autolimit'); %validations = &Apache::lonnet::auto_courserequest_checks($dom); %titles = &courserequest_titles(); @@ -7627,7 +7646,7 @@ sub modify_quotas { my @approvalnotify = &Apache::loncommon::get_env_multiple('form.'.$context.'notifyapproval'); @approvalnotify = sort(@approvalnotify); $confhash{'notify'}{'approval'} = join(',',@approvalnotify); - my @crstypes = ('official','unofficial','community','textbook'); + my @crstypes = ('official','unofficial','community','textbook','placement'); my @hasuniquecode = &Apache::loncommon::get_env_multiple('form.uniquecode'); foreach my $type (@hasuniquecode) { if (grep(/^\Q$type\E$/,@crstypes)) { @@ -9482,7 +9501,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}; @@ -9706,6 +9726,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}; @@ -10035,6 +10056,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'}; @@ -10196,6 +10218,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') { @@ -10316,7 +10342,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'}; @@ -10326,6 +10352,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'}; @@ -10337,6 +10369,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') { @@ -11235,8 +11284,8 @@ sub modify_coursedefaults { ); my @toggles = ('canuse_pdfforms','uselcmath','usejsme'); my @numbers = ('anonsurvey_threshold','uploadquota_official','uploadquota_unofficial', - 'uploadquota_community','uploadquota_textbook'); - my @types = ('official','unofficial','community','textbook'); + 'uploadquota_community','uploadquota_textbook','uploadquota_placement'); + my @types = ('official','unofficial','community','textbook','placement'); my %staticdefaults = ( anonsurvey_threshold => 10, uploadquota => 500, @@ -11499,7 +11548,7 @@ sub modify_coursedefaults { '
  • '.&mt('Official courses: [_1] MB',''.$defaultshash{'coursedefaults'}{'uploadquota'}{'official'}.'').'
  • '. '
  • '.&mt('Unofficial courses: [_1] MB',''.$defaultshash{'coursedefaults'}{'uploadquota'}{'unofficial'}.'').'
  • '. '
  • '.&mt('Textbook courses: [_1] MB',''.$defaultshash{'coursedefaults'}{'uploadquota'}{'textbook'}.'').'
  • '. - + '
  • '.&mt('Placement tests: [_1] MB',''.$defaultshash{'coursedefaults'}{'uploadquota'}{'placement'}.'').'
  • '. '
  • '.&mt('Communities: [_1] MB',''.$defaultshash{'coursedefaults'}{'uploadquota'}{'community'}.'').'
  • '. ''. ''; @@ -11535,6 +11584,8 @@ sub modify_coursedefaults { $resulttext .= &mt('Unofficial courses'); } elsif ($type eq 'textbook') { $resulttext .= &mt('Textbook courses'); + } elsif ($type eq 'placement') { + $resulttext .= &mt('Placement tests'); } $resulttext .= ' -- '.$display.''; } @@ -11586,7 +11637,7 @@ sub modify_coursedefaults { sub modify_selfenrollment { my ($dom,$lastactref,%domconfig) = @_; my ($resulttext,$errors,%changes,%selfenrollhash,%ordered); - my @types = ('official','unofficial','community','textbook'); + my @types = ('official','unofficial','community','textbook','placement'); my %titles = &tool_titles(); my %descs = &Apache::lonuserutils::selfenroll_default_descs(); ($ordered{'admin'},my $titlesref) = &Apache::lonuserutils::get_selfenroll_titles(); @@ -13024,6 +13075,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 { @@ -13044,6 +13097,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'; @@ -13052,11 +13115,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; @@ -13122,6 +13190,7 @@ sub captcha_phrases { original => 'original (CAPTCHA)', recaptcha => 'successor (ReCAPTCHA)', notused => 'unused', + ver => 'ReCAPTCHA version (1 or 2)', ); }