Walkthrough 1: Quizzes

In this walkthrough, we will help you to design a quiz for students for your geometry class.

 

Designing Question 1. 

Let's start off with a softball question, "What is the area of a square with side 5 inches?". You could model this question in a worksheet in multitude of ways as follows (starting off from a blank worksheet). In the following, we outline one way of doing so.

 

In this scenario, you start by typing in the question. Then you add a text field for your students to type in an answer. 

(A text field can be inserted by clicking through Insert > Form Element > Input Text in the Worksheet Editor's menu bar.)

 

 

Q1: The area of a square with side 5 in. is   in. x in.

 

 

To make the quiz engaging you may want to add in real time feedback. For example, you may want the question to be colored colored blue in case the correct answer (i.e. 25) is typed in, otherwise you may want the question to be colored red. You can embed this behavior in his worksheet using Worksheet Rules through the following simple steps.

  1. Convert text input and the question text into Worksheet cells. In order to do, assign 'Id's to the text input and the paragraph containing the question by opening up the correspond editing dialogs.

    The dialogs for an element in the Worksheet can be accessed by clicking on the corresponding element, and subsequently clicking on the element's tags e.g. p or input in the bottom bar of the Worksheet Editor. Note that the editing dialog for the text input can also be accessed when inserting the text input, or by double clicking the text input.

    In this example, let's set the 'Id' of the text input as 'answer1' (without the quotes), and 'Id' of the paragraph containg the question as 'question1' (without the quotes).

    In order to trigger a change to the Worksheet when content of the text input 'answer1' is changed, check the option 'Refresh Worksheet on change' in the dialog for 'answer1'.
     
  2. Describe the behavior of the Worksheet cell using rules. To do so, open up the Rule Editor by clicking through View > Rule Editor in the menu bar.
     
  3. Add in the rules
    style(question1, color, blue) :- value(answer1, 25)
    style(question1, color, red) :- ~value(answer1, 25)
    The first rule reads as: If value of the Worksheet cell - answer - is 25, then set the color of the cell to blue.
    Similary, the seond rule reads as: If value of the Worksheet cell - answer - is not (denoted as ~) 25, then set the color of the cell to red.
     
  4. Save the rules, and then, preview the Worksheet by clicking through View > Preview Worksheet in the Worksheet menu bar.

 

Designing Question 2 (with multiple choices). 

Let's move on to a multiple-choice question. In this section, we will explore a way of encoding such questions by inserting checkboxes (click through Insert > Form Element > Checkbox in the Worksheet menu bar).

 

First, type in the question text. For example: A triangle with three equal sides is: (select all options that apply).

 

Then, insert the relevant answer checkboxes, and convert these checkboxes and the paragraph containg the question text to Worksheet cells as previously described, i.e., by assigning an 'Id' to the paragraph containing the question and each of four checkboxes. In addition, check the option 'Refresh Worksheet on change' for the checkboxes. In this example, we use the Ids: acute, isosceles, equilateral, and scalene for the checkboxes and 'question2' for the paragraph containing the question text.

 

Q2: A triangle with three equal sides is: (select all options that apply)

Acute Iscosceles Equilateral Scalene 

 

Similar to Question 1, suppose you want the question text to be colored blue if all correct options (i.e. acute, isosceles, and equilateral) are selected, otherwise red. In order to do so, open up the rule editor, and add the following rules.

 

style(question2, color, blue) :- value(acute, true) & value(isosceles, true) & 
               value(equilateral, true) & ~value(scalene, true)
style(question2, color, red) :- ~style(question2, color, blue)

 

The first rule reads as: If the value of acute is true, and the value of isosceles is true, and the value of equilateral is true, and the value of scalene is not true, then the color of question2 is blue. The second rule reads as: If the color of question2 is not blue, then the color of question2 is red

 

Note that: checking the checkbox, say acute, sets its value to true. Similarly, unchecking the checkbox, sets its value to false.

 

Again, save the rules, and then, preview the Worksheet by clicking through View > Preview Worksheet in the Worksheet menu bar.

 

The quiz so far, that we have designed is as follows: 

 


 

Q1: The area of a square with side 5 in. is   in. x in.

 

Q2: A triangle with three equal sides is: (select all options that apply)

Acute Iscosceles Equilateral Scalene 

 


 

Computing the Quiz Score.

Suppose that you want to compute the total score based on the responses. Each question, if correctly answered, adds a score of 5 to the total. If a question is incorrectly answered, no score is added to the total. One way to embed the total score is through the following steps:

 

  1. Insert a text input, and convert it to a Worksheet cell with the Id 'total'. Note that the total score is never typed in; rather, always computed based on responses to question. To emphasize this behavior, make the text field read only by checking the option 'Disable Widget' for 'total'.
  2. Open the rule editor, and type in the following rules.
    attribute(total, value, 10) :- style(question1, color, blue)& style(question2, color, blue)
    attribute(total, value, 5) :- style(question1, color, blue) & ~style(question2, color, blue)
    attribute(total, value, 5) :- ~style(question1, color, blue) & style(question2, color, blue)
    attribute(total, value, 0) :- ~style(question1, color, blue) & ~style(question2, color, blue)
    In the above rules, we compute the total score based on the number of questions that are colored blue. We note that the above set of rules are merely one of many ways to compute the total score.

    The first rule reads as: set value of total to 10 if both questions are colored blue. The second and third rules read as: set value of total to 5 if one question is colored blue and the other is not colored blue. Finally, the fourth rule reads as: set value of total to 0 if both questions are not colored blue.
  3. Save the rules, and then, preview the Worksheet by clicking through View > Preview Worksheet in the Worksheet menu bar.

 

The quiz so far, that we have designed is as follows: 

 


 

Q1: The area of a square with side 5 in. is   in. x in.

 

Q2: A triangle with three equal sides is: (select all options that apply)

Acute Iscosceles Equilateral Scalene 

 

Total: 

 


 

Towards a compact encoding of the total score.

Consider a scenario where you have a large number of questions in your quiz - say 20. In this scenario, if you use the rules as described in the previous section to compute the total score, then you'll end up with 220 rules, which is not all pleasant to write! 

 

An alternative is to encode desired behavior using a compact set of rules by leveraging Variables, and Aggregate Operators as follows.

attribute(total, value, T) :- countofall(X, style(X, color, blue), C) & times(C, 5, T)

The above rule reads as follows: set the value of total to T, where T = 5 * C, and C is the number of constants that can be substituted for X such that color of the element X is blue.