Uncaptcha::Question
Constructors
- Question(String varname,String questiontext,String questiondetail,[String] correctanswers,[String] wronganswers,Bool selectmultiple)
Usage
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 enableQuestion function, provided that the questions share the following properties with the question used in the checkQuestion function.
- All questions have the same
selectmultiplevalue. - If
selectmultipleistrue, 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 Timer filter to increase the pressure!