[system] / trunk / webwork / system / courseScripts / PGbasicmacros.pl Repository:
ViewVC logotype

Diff of /trunk/webwork/system/courseScripts/PGbasicmacros.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 26 Revision 27
21 21
22# this is equivalent to use strict, but can be used within the Safe compartment. 22# this is equivalent to use strict, but can be used within the Safe compartment.
23BEGIN{ 23BEGIN{
24 be_strict; 24 be_strict;
25} 25}
26sub _PGbasicmacros_export {
27 my @EXPORT = ( '&NAMED_ANS_RULE', '&NAMED_ANS_RULE_OPTION',
28 '&NAMED_ANS_RULE_EXTENSION', '&ANS_RULE', '&NAMED_ANS_BOX', '&ANS_BOX',
29 '&NAMED_ANS_RADIO', '&NAMED_ANS_RADIO_OPTION',
30 '&NAMED_ANS_RADIO_BUTTONS', '&ANS_RADIO', '&ANS_RADIO_OPTION',
31 '&ANS_RADIO_BUTTONS', '&NAMED_ANS_CHECKBOX',
32 '&NAMED_ANS_CHECKBOX_OPTION', '&NAMED_ANS_CHECKBOX_BUTTONS',
33 '&ANS_CHECKBOX', '&ANS_CHECKBOX_OPTION', '&ANS_CHECKBOX_BUTTONS',
34 '&ans_rule', '&ans_rule_extension', '&ans_radio_buttons',
35 '&ans_checkbox', '&tex_ans_rule', '&tex_ans_rule_extension', '&ans_box',
36 '&checkbox', '&NAMED_POP_UP_LIST', '&pop_up_list', '&solution',
37 '&SOLUTION', '&hint', '&HINT', '&random', '&non_zero_random', '&SRAND',
38 '&TEX', '&M3', '&MODES', '&_PGbasicmacros_export',
39 '&_PGbasicmacros_initialize', '&ALPHABET', '&PAR', '&BR', '&LQ', '&RQ',
40 '&BM', '&EM', '&BDM', '&EDM', '&LTS', '&GTS', '&LTE', '&GTE',
41 '&BEGIN_ONE_COLUMN', '&END_ONE_COLUMN', '&SOLUTION_HEADING',
42 '&HINT_HEADING', '&US', '&SPACE', '&BBOLD', '&EBOLD', '&HR', '&LBRACE',
43 '&RBRACE', '&LB', '&RB', '&DOLLAR', '&PERCENT', '&CARET', '&PI', '&E',
44 '&ev_substring', '&safe_ev', '&old_safe_ev', '&FEQ', '&math_ev3',
45 '&display_math_ev3', '&EV2', '&EV3', '&beginproblem',
46 '&protect_underbar', '&OL', '&htmlLink', '&appletLink', '&spf', '&sspf',
47 '&lex_sort', '&num_sort', '&begintable', '&endtable', '&row', '&image',
48 '&images', '&caption', '&captions', '&imageRow', '&display_options2',
49 '&_PGbasicmacros_init','&test'
50 );
51 @EXPORT;
52}
53my $displayMode=$main::displayMode;
26 54
55my ($PAR,
56 $BR,
57 $LQ,
58 $RQ,
59 $BM,
60 $EM,
61 $BDM,
62 $EDM,
63 $LTS,
64 $GTS,
65 $LTE,
66 $GTE,
67 $BEGIN_ONE_COLUMN,
68 $END_ONE_COLUMN,
69 $SOL,
70 $HINT,
71 $US,
72 $SPACE,
73 $BBOLD,
74 $EBOLD,
75 $HR,
76 $LBRACE,
77 $RBRACE,
78 $LB,
79 $RB,
80 $DOLLAR,
81 $PERCENT,
82 $CARET,
83 $PI,
84 $E,
85 @ALPHABET,
86 );
87_PGbasicmacros_init();
88sub _PGbasicmacros_init {
89 PG_restricted_eval( <<'EOF');
90 $main::PAR = PAR();
91 $main::BR = BR();
92 $main::LQ = LQ();
93 $main::RQ = RQ();
94 $main::BM = BM();
95 $main::EM = EM();
96 $main::BDM = BDM();
97 $main::EDM = EDM();
98 $main::LTS = LTS();
99 $main::GTS = GTS();
100 $main::LTE = LTE();
101 $main::GTE = GTE();
102 $main::BEGIN_ONE_COLUMN = BEGIN_ONE_COLUMN();
103 $main::END_ONE_COLUMN = END_ONE_COLUMN();
104 $main::SOL = SOLUTION_HEADING();
105 $main::HINT = HINT_HEADING();
106 $main::US = US();
107 $main::SPACE = SPACE();
108 $main::BBOLD = BBOLD();
109 $main::EBOLD = EBOLD();
110 $main::HR = HR();
111 $main::LBRACE = LBRACE();
112 $main::RBRACE = RBRACE();
113 $main::LB = LB();
114 $main::RB = RB();
115 $main::DOLLAR = DOLLAR();
116 $main::PERCENT = PERCENT();
117 $main::CARET = CARET();
118 $main::PI = PI();
119 $main::E = E();
120 @main::ALPHABET = ('A'..'ZZ');
121
122 $PAR = PAR();
123 $BR = BR();
124 $LQ = LQ();
125 $RQ = RQ();
126 $BM = BM();
127 $EM = EM();
128 $BDM = BDM();
129 $EDM = EDM();
130 $LTS = LTS();
131 $GTS = GTS();
132 $LTE = LTE();
133 $GTE = GTE();
134 $BEGIN_ONE_COLUMN = BEGIN_ONE_COLUMN();
135 $END_ONE_COLUMN = END_ONE_COLUMN();
136 $SOL = SOLUTION_HEADING();
137 $HINT = HINT_HEADING();
138 $US = US();
139 $SPACE = SPACE();
140 $BBOLD = BBOLD();
141 $EBOLD = EBOLD();
142 $HR = HR();
143 $LBRACE = LBRACE();
144 $RBRACE = RBRACE();
145 $LB = LB();
146 $RB = RB();
147 $DOLLAR = DOLLAR();
148 $PERCENT = PERCENT();
149 $CARET = CARET();
150 $PI = PI();
151 $E = E();
152 @ALPHABET = ('A'..'ZZ');
153
154 $displayMode =$main::displayMode;
155EOF
156
157}
158sub test {
159 "PI is $PI $BR displayMode is $displayMode";
160}
27_PGbasicmacros_init(); # initialize constants 161#_PGbasicmacros_init(); # initialize constants
28 162
29=head2 Answer blank macros: 163=head2 Answer blank macros:
30 164
31These produce answer blanks of various sizes or pop up lists or radio answer buttons. 165These produce answer blanks of various sizes or pop up lists or radio answer buttons.
32The names for the answer blanks are 166The names for the answer blanks are
407} 541}
408sub ans_radio_buttons { 542sub ans_radio_buttons {
409 my $name = NEW_ANS_NAME(++$main::ans_rule_count); 543 my $name = NEW_ANS_NAME(++$main::ans_rule_count);
410 my @radio_buttons = NAMED_ANS_RADIO_BUTTONS($name, @_); 544 my @radio_buttons = NAMED_ANS_RADIO_BUTTONS($name, @_);
411 545
412 if ($main::displayMode eq 'TeX') { 546 if ($displayMode eq 'TeX') {
413 $radio_buttons[0] = "\n\\begin{itemize}\n" . $radio_buttons[0]; 547 $radio_buttons[0] = "\n\\begin{itemize}\n" . $radio_buttons[0];
414 $radio_buttons[$#radio_buttons] .= "\n\\end{itemize}\n"; 548 $radio_buttons[$#radio_buttons] .= "\n\\end{itemize}\n";
415 } 549 }
416 550
417 (wantarray) ? @radio_buttons: join(" ", @radio_buttons); 551 (wantarray) ? @radio_buttons: join(" ", @radio_buttons);
573 707
574 708
575sub solution { 709sub solution {
576 my @in = @_; 710 my @in = @_;
577 my $out = ''; 711 my $out = '';
578 $main::solutionExists =1; 712 PG_restricted_eval('$main::solutionExists =1');
579 if ($envir{'inputs_ref'}->{'ShowSol'}) { 713 if ($envir{'inputs_ref'}->{'ShowSol'}) {
580 my %inlist; 714 my %inlist;
581 grep($inlist{$_}++,@{ $envir{'PRINT_FILE_NAMES_FOR'} }); 715 grep($inlist{$_}++,@{ $envir{'PRINT_FILE_NAMES_FOR'} });
582 if ( defined($inlist{$main::studentLogin}) and ($inlist{$main::studentLogin} > 0) ) { 716 if ( defined($inlist{$main::studentLogin}) and ($inlist{$main::studentLogin} > 0) ) {
583 $out = join(' ',@in); 717 $out = join(' ',@in);
741 die " ERROR in using MODES: 'HTML' option not defined for HTML_tth"; 875 die " ERROR in using MODES: 'HTML' option not defined for HTML_tth";
742 876
743 } 877 }
744 878
745 # trap undefined errors 879 # trap undefined errors
746 die "ERROR in defining MODES: Can't find |$main::displayMode| among 880 die "ERROR in defining MODES: Can't find |$displayMode| among
747 available options:" . join(" ", keys(%options) ) . "\n\n"; 881 available options:" . join(" ", keys(%options) )
882 . " file " . __FILE__ ." line " . __LINE__."\n\n";
748 883
749} 884}
750 885
751 886
752# end display macros 887# end display macros
787 $E E() the number e 922 $E E() the number e
788 923
789=cut 924=cut
790 925
791 926
792sub _PGbasicmacros_init {
793 $main::PAR = PAR();
794 $main::BR = BR();
795 $main::LQ = LQ();
796 $main::RQ = RQ();
797 $main::BM = BM();
798 $main::EM = EM();
799 $main::BDM = BDM();
800 $main::EDM = EDM();
801 $main::LTS = LTS();
802 $main::GTS = GTS();
803 $main::LTE = LTE();
804 $main::GTE = GTE();
805 $main::BEGIN_ONE_COLUMN = BEGIN_ONE_COLUMN();
806 $main::END_ONE_COLUMN = END_ONE_COLUMN();
807 $main::SOL = SOLUTION_HEADING();
808 $main::HINT = HINT_HEADING();
809 $main::US = US();
810 $main::SPACE = SPACE();
811 $main::BBOLD = BBOLD();
812 $main::EBOLD = EBOLD();
813 $main::HR = HR();
814 $main::LBRACE = LBRACE();
815 $main::RBRACE = RBRACE();
816 $main::LB = LB();
817 $main::RB = RB();
818 $main::DOLLAR = DOLLAR();
819 $main::PERCENT = PERCENT();
820 $main::CARET = CARET();
821 $main::PI = PI();
822 $main::E = E();
823 @main::ALPHABET = ('A'..'ZZ');
824}
825 927
826# A utility variable. Notice that "B"=$ALPHABET[1] and 928# A utility variable. Notice that "B"=$ALPHABET[1] and
827# "ABCD"=@ALPHABET[0..3]. 929# "ABCD"=@ALPHABET[0..3].
828 930
829sub ALPHABET { 931sub ALPHABET {

Legend:
Removed from v.26  
changed lines
  Added in v.27

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9