The process of writing Jess functions is explained in detail in Chapter 4, "Defining Functions in Jess" of the official Jess manual. In this section, we'll cover writing Jess functions that interface with the unique features of CTAT cognitive tutors. This section presumes you're familiar with Jess syntax and simple Jess functions.
A matcher function is a function that compares observed student input to a predicted value in a unique way. As described in Section 3.2.1, “Input Matching”, CTAT provides a number of basic matcher functions for use in Jess rules. If none of the existing functions perform matching in the desired way, you may want to write a new matcher function.
A matcher function in CTAT has a few characteristics. First,
it should return a boolean value (true or false). This is so the
(predict) function, which calls it, can itself
return a boolean value. Second, the matcher function should consider
both the predicted input (specified in the predict function) and
student's input, both of which are provided as arguments to the
matcher function. The example function below illustrates both of
these characteristics:
Example 2.3. Example matcher function
(deffunction equal-with-precision (?predictedInput ?studentInput) (< (abs (- ?predictedInput ?studentInput)) 0.02) ) ... (predict newTextField DONT-CARE 2 equal-with-precision)
In this function, equal-with-precision,
the student's input is first subtracted from the predicted input. If
the absolute value of the resulting number is less than .02, the
function returns true; otherwise, it returns false. The predict
function is then used to see if the rule's predicted value ("2") is
equal (within .02) to the student's value.
![]() | Note |
|---|---|
To reference the matcher function, the function must be defined in either the wmeTypes.clp file or production rules file before the matcher is called. |
To evaluate the result of a function in a production rule, use
the Jess function eval:
Example 2.4. Evaluating the sum of two values and passing the result to (predict)
(deffunction sum (?a ?b) (+ ?a ?b) ) ... (predict-observable-action ?cell-name "UpdateTable" (eval sum 2 3) )
In this example, the result of adding '2' and '3' is passed
as an argument to the
(predict-observable-action) function. When
the rule containing this call to (predict) is
activated, CTAT determines if the selection (the value of
?cell-name), action ('UpdateTable'), and input ('5', the sum of
'2' and '3') match the student's selection, action, and input
exactly.