Merge "Improved the QuestyCaptcha syntax for setting questions and answers"

This commit is contained in:
jenkins-bot 2014-12-30 18:14:50 +00:00 committed by Gerrit Code Review
commit ebc4667a1b
3 changed files with 18 additions and 7 deletions

1
.gitignore vendored
View file

@ -3,3 +3,4 @@
*.kate-swp
.*.swp
.idea
.DS_Store

View file

@ -30,7 +30,15 @@ class QuestyCaptcha extends SimpleCaptcha {
function getCaptcha() {
global $wgCaptchaQuestions;
return $wgCaptchaQuestions[mt_rand( 0, count( $wgCaptchaQuestions ) - 1 )]; // pick a question, any question
//Backwards compatibility
if ( $wgCaptchaQuestions === array_values( $wgCaptchaQuestions ) ) {
return $wgCaptchaQuestions[ mt_rand( 0, count( $wgCaptchaQuestions ) - 1 ) ];
}
$question = array_rand( $wgCaptchaQuestions, 1 );
$answer = $wgCaptchaQuestions[ $question ];
return array( 'question' => $question, 'answer' => $answer );
}
function getForm() {

View file

@ -35,12 +35,14 @@ $wgCaptchaClass = 'QuestyCaptcha';
global $wgCaptchaQuestions;
$wgCaptchaQuestions = array();
// Add your questions in LocalSettings.php using this format
// $wgCaptchaQuestions[] = array( 'question' => "A question?", 'answer' => "An answer!" );
// $wgCaptchaQuestions[] = array( 'question' => 'How much wood would a woodchuck chuck if a woodchuck could chuck wood?', 'answer' => 'as much wood as...' );
// $wgCaptchaQuestions[] = array( 'question' => "What is this wiki's name?", 'answer' => "$wgSitename" );
// You can also provide several acceptable answers to a given question (the answers shall be in lowercase):
// $wgCaptchaQuestions[] = array( 'question' => "2 + 2 ?", 'answer' => array( '4', 'four' ) );
/* Add your questions in LocalSettings.php using this format
$wgCaptchaQuestions = array(
'A question?' => 'An answer!',
'What is the capital of France?' => 'Paris', //Answers are normalized to lowercase: Paris and paris are the same
'What is this wiki's name?' => $wgSitename,
'2 + 2 ?' => array( '4', 'four' ), //Questions may have many answers
);
*/
$wgMessagesDirs['QuestyCaptcha'] = __DIR__ . '/i18n/questy';
$wgExtensionMessagesFiles['QuestyCaptcha'] = $dir . '/QuestyCaptcha.i18n.php';