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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3334 - (download) (as text) (annotate)
Sun Jul 3 20:10:37 2005 UTC (14 years, 6 months ago) by dpvc
File size: 1243 byte(s)
Updates to allow string matches to be case-insensitive.  This is now
the default, and can be overridden in the Context by setting the
string's "caseSensitive" attribute.  e.g.:

	 Context()->strings->add("FooBar"=>{caseSensitive=>1});

would rewuire "FooBar" to be entered exactly as typed.

    1 loadMacros("Parser.pl","contextString.pl");
    2 
    3 sub _contextABCD_init {}; # don't load it again
    4 
    5 ##########################################################
    6 #
    7 #  Implements contexts for string-valued answers especially
    8 #  for matching problems (where you match against A, B, C, D,
    9 #  and so on).
   10 #
   11 #  There are two contexts defined here,
   12 #
   13 # Context("ABCD");
   14 # Context("ABCD-List");
   15 #
   16 #  The second allows the students to enter lists of strings,
   17 #  while the first does not.
   18 #
   19 #  You can add new strings to the context as needed (or remove old ones)
   20 #  via the Context()->strings->add() and Context()-strings->remove()
   21 #  methods, eg.
   22 #
   23 # Context("ABCD-List")->strings->add(E=>{},e=>{alias=>"E"});
   24 #
   25 #  Use string_cmp() to produce the answer checker(s) for your
   26 #  correct values.  Eg.
   27 #
   28 # ANS(string_cmp("A","B"));
   29 #
   30 #  when there are two answers, the first being "A" and the second being "B".
   31 #
   32 
   33 $context{ABCD} = Context("String")->copy;
   34 $context{ABCD}->strings->are(
   35  "A" => {},
   36  "B" => {},
   37  "C" => {},
   38  "D" => {},
   39 );
   40 
   41 $context{'ABCD-List'} = $context{ABCD}->copy;
   42 $context{'ABCD-List'}->operators->add(
   43   ',' => $Parser::Context::Default::fullContext->operators->get(','),
   44 );
   45 $context{'ABCD-List'}->strings->add("NONE"=>{});
   46 
   47 Context("ABCD");

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9