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

View of /trunk/pg/macros/parserCustomization.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3588 - (download) (as text) (annotate)
Tue Aug 30 00:41:34 2005 UTC (14 years, 4 months ago) by dpvc
File size: 1219 byte(s)
Added a parserCustomization.pl file that is loaded whenever the
Parser.pl file is.  This can be used on a course-by-course basis to
customize features of the Parser.  Some examples are listed in the
file.

You need to be VERY careful when doing this, as this will affect ALL
problems that use the Parser.  Your changes may cause some .pg files
to fail if they rely on the default behavior that you are changing.

If you wish to override settings in one of the predefined contexts
(like "Vector"), then define $context{Vector} as a copy of
$Parser::Context::Default::context{Vector}, as in the commented out
examples.  Then Context("Vector") will use your copy rather than the
original.  If you were to change the version in
Parser::Context::Default, that would change the parser for ALL
courses, not just yours.

    1 sub _parserCustomization_init {}
    2 
    3 #
    4 #  Copy this file to your course templates directory and put any
    5 #  customization for the Parser that you want for your course
    6 #  here.  For example, you can make vectors display using
    7 #  ijk notation (and force students to use it for entering
    8 #  vectors) by uncommenting:
    9 #
   10 #    $context{Vector} = $Parser::Context::Default::context{Vector}->copy;
   11 #    $context{Vector}->flags->set(ijk=>1);
   12 #    $context{Vector}->parens->remove('<');
   13 #
   14 #  To allow vectors to be entered with parens (and displayed with
   15 #  parens) rather than angle-brakets, uncomment
   16 #
   17 #    $context{Vector} = $Parser::Context::Default::context{Vector}->copy;
   18 #    $context{Vector}->{cmpDefaults}{Vector} = {promotePoints => 1};
   19 #    $context{Vector}->lists->set(Vector=>{open=>'(', close=>')'});
   20 #
   21 #  (This actually just turns points into vectors in the answer checker
   22 #  for vectors, and displays vectors using parens rather than angle
   23 #  brakets.  The student is really still entering what the Parser
   24 #  thinks is a point, but since points get promoted automatically
   25 #  in the Value package, that should work.  But if a problem checks
   26 #  if a student's value is actually a Vector, that will not be true.)
   27 #
   28 
   29 
   30 1;

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9