1Uncaptcha.Question(3kaya) Kaya module reference Uncaptcha.Question(3kaya)
2
3
4
6 Uncaptcha::Question - A question-based filter
7
9 Uncaptcha::Question< >
10
11
12 = Question(String varname,String questiontext,String questionde‐
13 tail,[String] correctanswers,[String] wronganswers,Bool selectmultiple)
14
16 This filter requires the user of the form to correctly answer a ques‐
17 tion. Obviously, the question should be set so that the intended audi‐
18 ence of the form will always be able to answer it.
19
20 varname is the variable name that the answer will be submitted in. Any
21 non-empty string that is not otherwise used in the form may be used.
22
23 questiontext is a short summary of the question. In general, this
24 should be kept to 50 characters or less, due to the way most web
25 browsers handle the legend element.
26
27 questiondetail contains further information about the question if this
28 is necessary. If the question can be expressed entirely in the ques‐
29 tiontext field, then leave this as the empty string.
30
31 correctanswers is a list of correct answers to the question (it will
32 often only contain a single answer, of course)
33
34 wronganswers is a list of incorrect answers to the question. There
35 should be more incorrect answers than correct answers, but while each
36 incorrect answer available increases the chance that a spambot select‐
37 ing random answers will fail, it also increases the length of the form
38 and the complexity for real users.
39
40 selectmultiple changes the method used to select and check answers. If
41 it is false , then users may only select one answer, and the check will
42 pass if that answer is any of the correct answers. If it is true , then
43 users may select multiple answers, and the check will only pass if all
44 correct answers and no incorrect answers are selected.
45
46
47 // in the form creation function
48 enableQuestion(form,myQuestion);
49
50 // in the form handler
51 if (checkQuestion(myQuestion)) {
52 // process form or do other checks
53 } else {
54 // reject form
55 }
56
57 // example questions
58 Question myQuestion = Question("myquestion",
59 "What is the capital of Scotland?",
60 "(correct answer required to submit form)",
61 ["Edinburgh"],
62 ["Glasgow","London","Scotland City"],
63 false);
64 // alternatively
65 Question myQuestion = Question("myquestion",
66 "Which of these are chemical elements?",
67 "",
68 ["Hydrogen","Tantalum","Iodine"],
69 ["Cyanide","Ethane","Fire"],
70 true);
71
72 Because of the way the question checking works, multiple questions can
73 be used with the same Uncaptcha.enableQuestion (3kaya) function, pro‐
74 vided that the questions share the following properties with the ques‐
75 tion used in the Uncaptcha.checkQuestion (3kaya) function.
76
77
78 - All questions have the same selectmultiple value.
79
80
81 - If selectmultiple is true , all questions have the same number of cor‐
82 rect answers.
83
84 This allows easy random selection of questions to delay potential spam‐
85 bot analysis further.
86
87 In addition to this filter's use as a spamfilter, it can of course also
88 be used to make online quizzes. Combine it with a Uncaptcha.Timer
89 [1m(3kaya) filter to increase the pressure!
90
92 Kaya standard library by Edwin Brady, Chris Morris and others
93 (kaya@kayalang.org). For further information see http://kayalang.org/
94
96 The Kaya standard library is free software; you can redistribute it
97 and/or modify it under the terms of the GNU Lesser General Public
98 License (version 2.1 or any later version) as published by the Free
99 Software Foundation.
100
102 Uncaptcha.checkQuestion (3kaya)
103 Uncaptcha.enableQuestion (3kaya)
104
105
106
107Kaya December 2010 Uncaptcha.Question(3kaya)