[system] / trunk / pg / macros / parserMultiPart.pl Repository:
ViewVC logotype

Log of /trunk/pg/macros/parserMultiPart.pl

Parent Directory Parent Directory


Links to HEAD: (view) (download) (as text) (annotate)
Sticky Revision:

Revision 3371 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Tue Jul 12 22:39:56 2005 UTC (14 years, 7 months ago) by dpvc
File length: 14077 byte(s)
Diff to previous 3270
Make error messages potentially localizable (by making them use
sprintf-style strings rather than variable subtitution).

Revision 3270 - (view) (download) (as text) (annotate) - [select for diffs]
Added Mon Jun 6 00:01:44 2005 UTC (14 years, 8 months ago) by dpvc
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.

  Diffs between and
  Type of Diff should be a

Sort log by:

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9