# Question Types

The types of Questions currently supported by the Lesson module are:

1. Multichoice This is the default question type. Multichoice questions are popular questions where the student is asked to choose one answer from a set of alternatives. The correct answer takes the student further into the lesson, the wrong answers do not. The wrong answers are sometimes called the "distractors" and the utility of these questions often rely more on the quality of the distractors than either the questions themselves or their correct answers.

   Each answer can optionally have a response. If no response is entered for an answer then the default response "That's the Correct Answer" or "That's the Wrong Answer" is shown to the student.

   It is possible to have more than one correct answer to a multichoice question. The different correct answers may give the student different responses and jump to different (forward) pages in the lesson but do not vary in their grades, (that is, some answers are not more correct than others, at least in terms of grade.) It is possible for all the answers to be correct and they might take the student to different (forward) parts of the lesson depending on which one is chosen.

   There is variant of Multichoice questions called "Multichoice Multianswer" questions. These require the student to select all the correct answers from the set of answers. The question may or may not tell the student how many correct answers there are. For example "Which of the following were US Presidents?" does not, while "Select the two US presidents from the following list." does. The actual number of correct answers can be from one up to the number of choices. (A Multichoice Multianswer question with one correct answer is different from a Multichoice question as the former allows the student the possibility of choosing more than one answer while the latter does not.)

   Again the correct answers are flagged using forward jumps, the wrong answers by same page or backward jumps. When there is more than one correct answer the jumps should all go to the same page, similarly with the wrong answers. If that is not the case a warning is given on the teacher's view of the lesson. The correct response, if required, should be given on the first correct answer and the wrong response, if required, should be on the first wrong answer. Responses on the other answers are ignored (without warning).

2. Short Answer

   The student is prompted for a short piece of text. This is checked against one or more answers. Answers can be either correct or wrong. Each answer can optionally have a response. If no response is entered for an answer then the default response "That's the Correct Answer" or "That's the Wrong Answer" is shown to the student. If the text entered does not match any of the answers the question is wrong and the student is shown the default wrong response.

   There are two different comparison systems available for the Short Answer type of question: the simple system is used by default; the "Regular Expressions" system is used if the "Use Regular Expressions" option box is checked.

   - Simple analysis

     In this (default) system of analysis, the comparisons ignore the case of the text. The asterisk (*) character can be used in answers as a "wild card" character. It stands for any number of characters (including no characters at all). For example, the answer "Long*" will match "longer", "longest" and "long". If one of the answers is just "*" (a single *) this answer will match anything, it is normally used as the last "catch-all" answer. The matching process goes through the answers in the order they appear on the screen. Once a match is found the process stops and the corresponding result (and response, if present) is returned. So, if for example the answers are Longest, Long* and * (in that order), the input "longer" will match the second answer and, in this case, the third answer, although a match, is ignored.

     If an asterisk (*) is actually needed in an answer, it should be entered as \*, backslash asterisk.

   - Regular Expressions analysis

     This system gives you access to a more powerful but more complicated system for analysing the student's answers. For a complete introduction to Regular Expressions, see these sites regular-expressions tutorial or rezeau.org.

     ### Correct answer matching a regular expression pattern

     It is not possible to give complete examples of the vast possibilities offered by this system, and the following are just some possibilities.

     Example 1. Suppose your question is "What are the colors of the French flag?". In the Answer 1 frame you type this regular expression: "it’s blue, white(,| and) red/i". This will match any of those four student answers:

     - it’s blue, white, red
     - it’s blue, white and red
     - It’s blue, white, red
     - It’s blue, white and red

     Please note that by default a regular expression match is case sensitive; to make the match case insensitive you must add the /i parameter right at the end of your expression.

     Example 2. Question: "What is blue, or red, or yellow?". Answer: "(|it's )a colou?r". This will match:

     - a colour
     - a color
     - it's a colour
     - it's a color

     Notes.- The beginning of this regular expression "(|it's )" will match either nothing or "it's " (i.e. "it's" followed by a space). The ? (question-mark) means: preceding character zero or one time; it is used here to match British English as well as US spelling.

     Example 3. Question: "Name an animal whose name is made of 3 letters and the middle letter is the vowel a". Answer: "[bcr]at". This will match: bat, cat and rat.

     ### Detecting missing required words or character strings

     Regular expressions alone cannot detect absent character strings, so you have to add a little code in your Answer to take care of this. Any Teacher Answer which begins with a double hyphen will analyze the student’s answer to find out whether the following string is present or absent. If present, the analysis continues to the next question; if absent, the analysis stops and the relevant Response message is displayed.

     Example 4.

     - Answer 2: --.*blue.*/i
     - student answer: "it's red and white"
     - Response 2: The color of the sky is missing!
     - Jump 2: this page

     Here, the . (dot) stands for “any character” and the * (asterisk) means “preceding special character repeated any number of times”. The Answer2 regular expression above means: check whether the character string "blue", preceded with anything and followed by anything is absent from the student's answer. Please note that the use of the asterisk is different in the Simple analysis system and in the Regular Expressions system.

     Example 5. Question: "Name an animal whose name is made of 3 letters and the middle letter is the vowel a". Teacher Answer: "--[b|c|r]". Response: "Your answer should start with one of these letters: b, c or r"

     ### Detecting unwanted (incorrect) words or character strings

     You may want to detect, in the student's answer, the presence of one or several words which should be not be there (because they are wrong) and to single them out with a specific response. Just start your teacher Answer by a double plus sign (++).

     Example 6.

     - Answer 3: ++(yellow|black|orange|green|black|pink)/i
     - student answer: "it's blue, orange and white"
     - Response 3: One or more colors are wrong!
     - Jump 3: this page

     If any of these (wrong) colors is detected in the student’s answer, then the negative feedback message (Response 3) will be displayed and the wrong strings will be colored red (or the color of the .incorrect class if it exists in a CSS stylesheet of your active theme).

     Example 7. Question: "Name an animal whose name is made of 3 letters and the middle letter is the vowel a". Teacher Answer: "++hat". Response: "You might wear one made of an animal's skin, but a hat can't be considered as an animal."

     ### Escaping special characters

     If you need to use characters which are part of the regular expressions set of special characters, you need to "escape" them (i.e. precede them with a backslash). E.g. if you want to accept the answer "My computer cost 1000$", you must write the regular expression as "My computer cost 1000\$". The special characters which must be escaped are .^$*()[]+?|

3. True/False The answer to this type of question only has two options, true or false. The student is prompted to choose which is the correct option. This type of question is basically a Multichoice question with just two choices.

4. Matching These are quite powerful and flexible questions. They consist of a list of names or statements which must be correctly matched against other list of names or statements. For example "Match the Capital with the Country" with the two lists Japan, Canada, Italy and Tokyo, Ottawa, Rome. It is possible to have repeated entries in one of the lists but care should be taken to make the repeats identical. For example "Identify the type of these creatures" with the lists Sparrow, Cow, Ant, Dog and Bird, Animal, Insect, Animal.

   When creating this type of question the items for the first list go into the Answer boxes and items for the second list go into the Response boxes. Once created a more sensible labeling scheme is shown. When the student successfully matches the items the jump on the first answer is used. An unsuccessful answer jumps to the page on the second answer. The question does not support custom responses, the student is told how many matches are correct or if all the matches are correct.

   Unlike the Multichoice question where the choices are shown in a random order, the first list of items is not shuffled but shown in the same order as entered. This allows for "Ordered" questions to be constructed. Consider the question " Put the following into the order they were born, the earliest first" with the lists 1., 2., 3., 4. and Longfellow, Lawrence, Lowell, Larkin. The second list is shuffled before being used in the question, of course.

5. Numerical This type of question requires a number as the answer. In it's simplest form it requires just one answer to be specified. For example "What is 2 plus 2?" with the answer 4 given a forward jump. However, it is better to specify a range because the internal rounding of numerical values can make single numeric comparisons rather hit or miss. Thus, if the question were "What is 10 divided by 3" it would be necessary to give the answer as "Minimum:Maximum", that is two values separated by a colon (:). Thus if 3.33:3.34 is given as the acceptable range for the answer, then the answers 3.33, 3.333, 3.3333... would all be taken as correct answers. "Wrong" answers would include 3.3 (less than the minimum) and 3.4 (greater than the maximum).

   More than one correct answer is allowed and the answers can be either single or pair of values. Note that the order in which the answers are tested is Answer 1, Answer 2... so some care needs to taken if the desired response is to appear. For example the question "When was Larkin born?" could have the single value of 1922, the exact answer, and the pair of values 1920:1929, the 20's, as the less exact answer.The order in which these values should be tested is, obviously, 1922 then 1920:1929. The first answer might have the response "That's exactly right" while the other answer's response might be "That's close, you've got the right decade"

   Wrong answers can be given but depending on their actual range, care should be taken to place them after the correct answers. For example in adding the wrong answer 3:4 to the "10 divided by 3" question it needs to come after the correct answer. That is the answers are ordered 3.33:3.34 (the "correct" answer) then 3:4 (the "wrong" answer, but not wildly wrong answer!).