## Forum archive 2000-2006

### Michael Gage - How to create new AnswerEvaluators

by Arnold Pizer -
Number of replies: 0
 How to create new AnswerEvaluators topic started 4/26/2003; 8:42:30 PMlast post 4/26/2003; 8:42:30 PM
Michael Gage - How to create new AnswerEvaluators
4/26/2003; 8:42:30 PM (reads: 604, responses: 0)

### How to write an Answer Evaluator factory (such as fun_cmp).

First let's define terms. An AnswerEvaluator object is an object which accepts a string (the student's answer), processes it, and then returns a 0 if the answer is incorrect or a 1 if the answer is correct. More precisely the AnswerEvaluator returns an object called an AnswerHash which contains the 0 or 1 and additional information such as error messages, hints for students and so forth. We will temporarily ignore this other information.

When you type ANS(num_cmp(3.14159)); in a PG problem the following actions take place:

num_cmp, an AnswerEvaluator factory, manufactures an AnswerEvaluator object which is specifically designed to determine if the student's answer is 3.14159, and returns a reference to that object.
The reference is placed in the answer queue (by ANS) and when the student's answer string is received, the AnswerEvaluator object checks it.

The AnswerEvaluator object is essentially a subroutine filter, but it has some extra structure which makes it easier to modify. Here is an annotated example of an AnswerEvaluator object.

The AnswerEvaluator and AnswerHash objects are defined in the file AnswerHash.pm.

Writing an answer evaluator factory (like num_cmp or fun_cmp) involves writing a subroutine which accepts an instructor's answer (or a reference to a list of answers) and then a sequence of key/value pairs that list the options for the answer evaluator. Next the instructor's answer is checked (for syntax and so forth). Options which are not explicitly listed are given default values and then the AnswerEvaluator object is constructed and returned. There is no Answer Evaluator Factory object, but there are some subroutines which standardize the process of collecting the options and which make that process easier. Here is a description of the fun_cmp answer evaluator factory. The description of the construction of the AnswerEvaluator created by fun_cmp is described in this annotated example.

Answer evaluator's are built by combining subroutines called filters. Here is a list of existing filters, the specification for a filter, and information on how to write a new filter.

Here is an example of how to modify an AnswerEvaluator after it is built.

<| Post or View Comments |>