Topic on Extension talk:ConfirmEdit

QuestyCaptcha with multiple answers?

9
Schiffy (talkcontribs)

Is it possible for a single question in QuestyCaptcha to have more than one acceptable answer? For example, is it possible to have a question such as "Fill in the blank: Blue is a ____" and allow the user to get through with both "color" and 'colour"?

Kghbln (talkcontribs)

Yes, just put the correct answers into an array:

/* ConfirmEdit */
require_once "$IP/extensions/ConfirmEdit/ConfirmEdit.php";
require_once "$IP/extensions/ConfirmEdit/QuestyCaptcha.php'; 
$wgCaptchaClass = 'QuestyCaptcha';
$arr = array (
        "A question?" => "An answer!",
        "Fill in the blank: Blue is a ..." => array(
                'colour', 'color'
                ),
        );
foreach ( $arr as $key => $value ) {
        $wgCaptchaQuestions[] = array(
        'question' => $key, 'answer' => $value
        );
}

I will add this to the docu. Cheers

Schiffy (talkcontribs)

Sorry to bother, but this doesn't seem to work as intended. I tried to add an external link to my main page, and the questions with one answer could be passed successfully, but the questions using array() are not letting me through. On a side note, my custom made "Webmaster" group should extend sysop, but I still had to give it skipcaptcha manually.

Kghbln (talkcontribs)

Yeah, this was quite irritating. After changing to "A question?" => 'An answer!', both worked nicely. However not if you use ". Obviously the answers have to be "quoted" identically. Sorry for this.

Schiffy (talkcontribs)

Well right now I'm using only ' (not ") for all the questions and all the array() bound answers), including in the foreach loop at the end ($wgCaptchaQuestions[] = array( 'question' => $key, 'answer' => $value );), and it seems to still not be working.

Kghbln (talkcontribs)

Cannot tell why it is not working for you now, but perhaps there is somebody else who sees the problem and may help. After I changed this one line in my example above everything works out fine for me.

Schiffy (talkcontribs)

Until someone else finds a reason I just removed the array answers. Thanks anyway.

72.21.231.254 (talkcontribs)

Are any letter in your answer in uppercase? I just ran into the same problem and noticed in the code that QuestyCaptcha does a strtolower() on both the user input and the stored answer of there is only one answer, but if the answers are in an array it only does a strtolower() on the user input (hence if the answer has an upper case letter the check will always fail, even if the user inputs a correct answer).

Kghbln (talkcontribs)

This would explain things and should be documented. Waiting for real life confirmation though.

Reply to "QuestyCaptcha with multiple answers?"