## Forum archive 2000-2006

### Michael Gage - Answer hash

by Arnold Pizer -
Number of replies: 0
 Answer hash topic started 5/11/2000; 1:16:22 PMlast post 6/16/2000; 11:01:39 AM
5/11/2000; 1:16:22 PM (reads: 3532, responses: 3)

Each answer evaluator accepts a single input

from a student's answer, checks it and creates a reference to a hash %ans_hash with nine required entries.

Except for "score" the entries can be empty strings, but they must be defined or error messages will be generated.

A new alternative (as of June 2000) is to use an object of type AnswerHash (defined at the end of PGanswermacros.pl). $ro_ans_hash = new AnswerHash creates a reference to this object. The object is very simple and at the moment consists only of an anonymous hash for storing the entries listed below. The advantages of using an object, is that all of the required entries are automatically initialized (even if more required entries are added at some later date). We may also add methods to this class for "AND"ing or "OR"ing two answer hashes. The output of each answer evaluator consists of a reference to a hash %ans_hash with these entries: ####$ans_hash{score} or $ro_ans_hash ->{score} a number between 0 and 1 indicating whether the answer is correct. Fractions allow the implementation partial credit for incorrect answers. ####$ans_hash{correct_ans}

The correct answer, as supplied by the instructor and then formatted.

#### $ans_hash{original_correct_ans} The original_correct answer, as supplied by the instructor. This can be viewed by the student after the answer date. If the original_correct_ans is not defined, correct_ans will be used instead. If this is given by the .pg problem as a string (e.g. "${a}cos(${b}pi/11)"), the student will see the correct answer given symbolically (e.g. 2cos(3pi/11)) which is usually much more meaningful than a numerical answer. ####$ans_hash{student_ans}

This is the student's answer, after reformatting; for example the answer might be forced to capital letters for comparison with the instructors answer. This is displayed in the section reporting the results of checking the student's answers.

#### $ans_hash{ans_message} Any error message, or hint provided by the answer evaluator. This is also displayed in the section reporting the results of checking the student's answers. ####$ans_hash{type}

A string indicating the type of answer evaluator. This helps in preprocessing the student's answer for errors. Some examples: 'number_with_units' 'function' 'frac_number' 'arith_number'

This typically shows how the student's answer was parsed. It is displayed on the preview page. For a student answer of 2sin(3x) this would be 2*sin(3*x). For string answers it is typically the same as $ans_hash{student_ans}. ####$ans_hash{preview_latex_string}

THIS IS OPTIONAL. This is latex version of the student's answer which is used to show a typeset view on the answer on the preview page. For a student answer of 2/3, this would be frac{2}{3}.

<| Post or View Comments |>

 David Etlinger - Re: Answer hash  6/13/2000; 1:29:54 PM (reads: 3053, responses: 1) looking at the code in PGanswermacros.pl, it appears that the answer evaluator doesn't actually return a hash, but a reference to a hash. If this is the case, it needs to be made explicit here. Or does this page only refer to custom answer evaluators within a problem, and not to PGanswermacros.pl? Also, \$ans_hash{ans_message} is listed twice. <| Post or View Comments |>

 Michael Gage - Re: Answer hash-fixed  6/16/2000; 11:01:39 AM (reads: 3729, responses: 0) Fixed. Every answer evaluator is supposed to return a pointer to a hash (the answer hash) or a pointer to an object of type AnswerHash <| Post or View Comments |>