Cognitive Tutor Authoring Tools 2.6 > Using the Tools > Generalizing an example-tracing tutor with formulas

5. Generalizing an example-tracing tutor with formulas

5.1. What are formulas and when are they useful?
5.2. Installing the Formula Builder
5.2.1. Windows XP
5.2.2. Mac OS X
5.3. Writing a formula
5.3.1. Referring to other links and widgets
5.3.2. Operators
5.3.3. Return types
5.3.4. Using the Formula Builder
5.3.5. Syntax-checking
5.4. Testing a formula
5.5. Formulas in hints and error feedback messages
5.6. Writing your own function

In this section, we introduce the concept and use of "formulas", powerful expressions that define the way CTAT example-tracing tutors match student input.

[Note]Note

Formulas are currently only available to Java-language tutors, or Flash tutors using the Java-based Tutoring Service.

5.1. What are formulas and when are they useful?

A formula is an expression you write for a step in an example-tracing tutor that enables the tutor to calculate a value (or set of values) it should use to test against the student's input.

Formula matching is an extension to existing matching methods. An example-tracing tutor works by comparing student-entered input to the input recorded in the steps of a behavior graph, which you create by demonstration. With the Edit Student Input Matching window, you can change this "exact" match to be more flexible: you can specify a range match (e.g., "1-10", which matches "6"), an "any" match (i.e., any input value will match), a wildcard match (e.g., "car*", which matches "cars" and "car"), or a regular expression match (e.g., "[THK]im", which matches "Tim", "Him", and "Kim"). With a formula match, the comparison is between the student-entered input and the evaluation of a formula, such as "link1.authorInput+5" (this equates to the value the author entered on Link 1 of the graph, plus 5).

A formula matcher is the most powerful type of matcher in CTAT because it can combine the values of inputs on other links, student-entered input, and the contents of interface widgets (such as text fields). Whenever you would like to evaluate correctness based on these characteristics, consider writing a formula.

Formulas are particularly useful in a few cases. When you need to specify a test (against a student action) that can only be determined at the time the student uses the tutor, a formula allows you to do so. For example, in the domain of fraction addition, you may have a set of common denominators that are valid for the current problem; but once the student uses one of those denominators in a converted fraction, he or she should use that same denominator in the other converted fractions and the unsimplified sum fraction. With a formula, you can check that the student chose a common denominator; then you can require the student to use that denominator in the other fractions.

Another benefit of formulas is that the tutor can be more general, with logic that works across similar problems (much like a cognitive tutor). Using the fraction addition example again, you might have a path in the behavior graph that represents finding and using a common denominator that is found by multiplying the two denominators of the given fractions. The formula for the links in that path of the graph would specify the product of multiplying the two denominators of the given fractions, which can be looked up by using variables that hold the value of widgets in the interface. Since the formula specifies a general logic, not hard-coded numbers, this graph is then on the way to becoming general enough to use with mass production.