[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 5044 - (download) (as text) (annotate)
Thu Jun 28 01:51:27 2007 UTC (12 years, 6 months ago) by dpvc
File size: 1286 byte(s)
Use the new method to copy the String context

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

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9