[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 5556 - (download) (as text) (annotate)
Thu Oct 4 16:40:49 2007 UTC (12 years, 3 months ago) by sh002i
File size: 2240 byte(s)
added standard copyright/license header

    1 ################################################################################
    2 # WeBWorK Online Homework Delivery System
    3 # Copyright  2000-2007 The WeBWorK Project, http://openwebwork.sf.net/
    4 # $CVSHeader: webwork2/lib/WeBWorK.pm,v 1.100 2007/08/13 22:59:53 sh002i Exp $
    5 #
    6 # This program is free software; you can redistribute it and/or modify it under
    7 # the terms of either: (a) the GNU General Public License as published by the
    8 # Free Software Foundation; either version 2, or (at your option) any later
    9 # version, or (b) the "Artistic License" which comes with this package.
   10 #
   11 # This program is distributed in the hope that it will be useful, but WITHOUT
   12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   13 # FOR A PARTICULAR PURPOSE.  See either the GNU General Public License or the
   14 # Artistic License for more details.
   15 ################################################################################
   16 
   17 =head1 NAME
   18 
   19 contextABCD.pl - Contexts for matching problems.
   20 
   21 =head1 DESCRIPTION
   22 
   23 Implements contexts for string-valued answers especially
   24 for matching problems (where you match against A, B, C, D,
   25 and so on).
   26 
   27 There are two contexts defined here,
   28 
   29   Context("ABCD");
   30   Context("ABCD-List");
   31 
   32 The second allows the students to enter lists of strings,
   33 while the first does not.
   34 
   35 You can add new strings to the context as needed (or remove old ones)
   36 via the Context()->strings->add() and Context()-strings->remove()
   37 methods, eg.
   38 
   39   Context("ABCD-List")->strings->add(E=>{},e=>{alias=>"E"});
   40 
   41 Use string_cmp() to produce the answer checker(s) for your
   42 correct values.  Eg.
   43 
   44   ANS(string_cmp("A","B"));
   45 
   46 when there are two answers, the first being "A" and the second being "B".
   47 
   48 =cut
   49 
   50 loadMacros("MathObjects.pl","contextString.pl");
   51 
   52 sub _contextABCD_init {
   53   my $context = $main::context{ABCD} = Parser::Context->getCopy("String");
   54   $context->{name} = "ABCD";
   55   $context->strings->are(
   56     "A" => {},
   57     "B" => {},
   58     "C" => {},
   59     "D" => {},
   60    );
   61 
   62   $context = $main::context{'ABCD-List'} = $context->copy;
   63   $context->operators->redefine(',', from => "Full");
   64   $context->strings->add("NONE"=>{});
   65 
   66   main::Context("ABCD");  ### FIXME:  probably should make author select context explicitly
   67 }
   68 
   69 1;

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9