[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 5392 - (download) (as text) (annotate)
Sun Aug 19 21:50:23 2007 UTC (12 years, 6 months ago) by dpvc
File size: 1345 byte(s)
Move the context creation to the _init routine so that modifications
to main:: occur at initialization time, not when the file is loaded.

    1 loadMacros("MathObjects.pl","contextString.pl");
    2 
    3 =head1 DESCRIPTION
    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 =cut
   34 
   35 sub _contextABCD_init {
   36   my $context = $main::context{ABCD} = Parser::Context->getCopy("String");
   37   $context->strings->are(
   38     "A" => {},
   39     "B" => {},
   40     "C" => {},
   41     "D" => {},
   42    );
   43 
   44   $context = $main::context{'ABCD-List'} = $context->copy;
   45   $context->operators->redefine(',', from => "Full");
   46   $context->strings->add("NONE"=>{});
   47 
   48   main::Context("ABCD");  ### FIXME:  probably should make author select context explicitly
   49 }
   50 
   51 1;

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9