Uncaptcha.Question.3kaya

Langue: en

Version: March 2009 (fedora - 05/07/09)

Section: 3 (Bibliothèques de fonctions)

NAME

Uncaptcha::Question - A question-based filter

SYNOPSIS

Uncaptcha::Question< >
= Question(String varname,String questiontext,String questiondetail,[String] correctanswers,[String] wronganswers,Bool selectmultiple)

DESCRIPTION

This filter requires the user of the form to correctly answer a question. Obviously, the question should be set so that the intended audience of the form will always be able to answer it.

varname is the variable name that the answer will be submitted in. Any non-empty string that is not otherwise used in the form may be used.

questiontext is a short summary of the question. In general, this should be kept to 50 characters or less, due to the way most web browsers handle the legend element.

questiondetail contains further information about the question if this is necessary. If the question can be expressed entirely in the questiontext field, then leave this as the empty string.

correctanswers is a list of correct answers to the question (it will often only contain a single answer, of course)

wronganswers is a list of incorrect answers to the question. There should be more incorrect answers than correct answers, but while each incorrect answer available increases the chance that a spambot selecting random answers will fail, it also increases the length of the form and the complexity for real users.

selectmultiple changes the method used to select and check answers. If it is false , then users may only select one answer, and the check will pass if that answer is any of the correct answers. If it is true , then users may select multiple answers, and the check will only pass if all correct answers and no incorrect answers are selected.


 // in the form creation function
     enableQuestion(form,myQuestion);
     
 // in the form handler
     if (checkQuestion(myQuestion)) {
         // process form or do other checks 
     } else {
         // reject form
     }
 
 // example questions
 Question myQuestion = Question("myquestion",
          "What is the capital of Scotland?",
          "(correct answer required to submit form)",
          ["Edinburgh"],
          ["Glasgow","London","Scotland City"],
          false);
 // alternatively
 Question myQuestion = Question("myquestion",
          "Which of these are chemical elements?",
          "",
          ["Hydrogen","Tantalum","Iodine"],
          ["Cyanide","Ethane","Fire"],
          true);

Because of the way the question checking works, multiple questions can be used with the same Uncaptcha.enableQuestion(3kaya) function, provided that the questions share the following properties with the question used in the Uncaptcha.checkQuestion(3kaya) function.

- All questions have the same selectmultiple value.
- If selectmultiple is true , all questions have the same number of correct answers.

This allows easy random selection of questions to delay potential spambot analysis further.

In addition to this filter's use as a spamfilter, it can of course also be used to make online quizzes. Combine it with a Uncaptcha.Timer(3kaya) filter to increase the pressure!

AUTHORS

Kaya standard library by Edwin Brady, Chris Morris and others (kaya@kayalang.org). For further information see http://kayalang.org/

LICENSE

The Kaya standard library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (version 2.1 or any later version) as published by the Free Software Foundation.

Uncaptcha.checkQuestion(3kaya)

Uncaptcha.enableQuestion(3kaya)