Links to HEAD: | (view) (download) (as text) (annotate) |

Sticky Revision: |

Revision

Added

File length: 14075 byte(s)

This file implements a Multi-Part parser object that allows you to tie several input blanks to a single answer checker that can compare the student's answers in several blanks in order to determine which are correct. For example: $mp = MultiPart("x^2",1,-1)->with( singleResult => 1, checker => sub { my ($correct,$student,$self) = @_; # get the parameters my ($f,$x1,$x2) = @{$student}; # extract the student answers Value::Error("Function can't be the identity") if ($f == 'x'); Value::Error("Function can't be constant") if ($f->isConstant); return $f->eval(x=>$x1) == $f->eval(x=>$x2); }, ); . BEGIN_TEXT \(f(x)\) = \{$mp->ans_rule(20)\} produces the same value at \(x\) = \{$mp->ans_rule(10)\} as it does at \(x\) = \{$mp->ans_rule(10)\}. END_TEXT ANS($mp->cmp); This produces three answer blanks all tied to the same checker, which is supplied by the user when the MultiPart is specified. This one checks if two inputs to a function provide the same output. The answer blanks can each produce a separate row in the results area at the top of the page, or they con be combined into a single row, as in this case. The checker routine can provide error messages for individual parts via the setMessage() method, or for the problem as a whole, as above. Finally, the ans_array() method can be used to produce answer blanks for individual entries for those objects that support such arrays. See the documentation at the top of the file for additional details.

This form allows you to request diffs between any two revisions of this file. For each of the two "sides" of the diff, enter a numeric revision.

aubreyja at gmail dot com | ViewVC Help |

Powered by ViewVC 1.0.9 |