[system] Repository:
ViewVC logotype

Revision 3270


Jump to revision: Previous Next
Author: dpvc
Date: Mon Jun 6 00:01:44 2005 UTC (14 years, 7 months ago)
Log Message:
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.

Changed paths:

Path Details
Directorytrunk/pg/macros/parserMultiPart.pl added

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9