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

Annotation of /trunk/pg/macros/contextTF.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5556 - (view) (download) (as text)

1 : sh002i 5556 ################################################################################
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 : sh002i 5551 =head1 NAME
18 : dpvc 2824
19 : sh002i 5551 contextTF.pl - Imlements contexts for true/false problems.
20 : gage 4997
21 : sh002i 5551 =head1 DESCRIPTION
22 : dpvc 2824
23 : sh002i 5551 Implements contexts for string-valued answers especially
24 :     for matching problems (where you match against T and F).
25 :    
26 : sh002i 5555 Context("TF");
27 : sh002i 5551
28 :     You can add new strings to the context as needed (or remove old ones)
29 :     via the Context()->strings->add() and Context()-strings->remove()
30 :     methods.
31 :    
32 :     Use:
33 :    
34 : sh002i 5555 ANS(string_cmp("T","F"));
35 : sh002i 5551
36 :     when there are two answers, the first being "T" and the second being "F".
37 :    
38 : gage 4997 =cut
39 :    
40 : sh002i 5551 loadMacros("MathObjects.pl","contextString.pl");
41 :    
42 : dpvc 5392 sub _contextTF_init {
43 : dpvc 2824
44 : dpvc 5392 my $context = $main::context{TF} = Parser::Context->getCopy("String");
45 : dpvc 5441 $context->{name} = "TF";
46 : dpvc 5392 $context->strings->are(
47 :     "T" => {value => 1},
48 :     "F" => {value => 0},
49 :     "True" => {alias => "T"},
50 :     "False" => {alias => "F"},
51 :     );
52 : dpvc 2824
53 : dpvc 5392 main::Context("TF"); ### FIXME: probably should require author to set this explicitly
54 :     }
55 :    
56 : dpvc 5373 1;

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9