From: Sam H. v. a. <we...@ma...> - 2008-05-03 17:58:51
|
Log Message: ----------- markup for ww-symbol-map Modified Files: -------------- pg/macros: IO.pl LinearProgramming.pl MathObjects.pl PG.pl PGanswermacros.pl PGasu.pl PGauxiliaryFunctions.pl Parser.pl dangerousMacros.pl extraAnswerEvaluators.pl Revision Data ------------- Index: PGauxiliaryFunctions.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/PGauxiliaryFunctions.pl,v retrieving revision 1.10 retrieving revision 1.11 diff -Lmacros/PGauxiliaryFunctions.pl -Lmacros/PGauxiliaryFunctions.pl -u -r1.10 -r1.11 --- macros/PGauxiliaryFunctions.pl +++ macros/PGauxiliaryFunctions.pl @@ -11,6 +11,7 @@ =cut +# ^uses loadMacros loadMacros("PGcommonFunctions.pl"); =head3 @@ -34,14 +35,17 @@ =cut +# ^function step sub step { # heavyside function (1 or x>0) my $x = shift; ($x > 0 ) ? 1 : 0; } +# ^function ceil sub ceil { my $x = shift; - floor(-$x); } +# ^function floor sub floor { my $input = shift; my $out = int $input; @@ -49,6 +53,7 @@ $out; } +# ^function max sub max { my $maxVal = shift; @@ -62,6 +67,7 @@ } +# ^function min sub min { my $minVal = shift; @@ -77,6 +83,8 @@ #round added 6/12/2000 by David Etlinger. Edited by AKP 3-6-03 +# ^function round +# ^uses Round sub round { my $input = shift; my $out = Round($input); @@ -90,6 +98,8 @@ } # Round contributed bt Mark Schmitt 3-6-03 +# ^function Round +# ^uses Round sub Round { if (@_ == 1) { $_[0] > 0 ? int $_[0] + 0.5 : int $_[0] - 0.5} elsif (@_ == 2) { $_[0] > 0 ? Round($_[0]*10**$_[1])/10**$_[1] :Round($_[0]*10**$_[1])/10**$_[1]} @@ -97,6 +107,7 @@ #least common multiple #VS 6/29/2000 +# ^function lcm sub lcm { my $a = shift; my $b = shift; @@ -124,7 +135,7 @@ # greatest common factor # takes in two scalar values and uses the Euclidean Algorithm to return the gcf #VS 6/29/2000 - +# ^function gcf sub gcf { my $a = abs(shift); # absolute values because this will yield the same gcd, my $b = abs(shift); # but allows use of the mod operation @@ -164,12 +175,15 @@ #greatest common factor. #same as gcf, but both names are sufficiently common names +# ^function gcd +# ^uses gcf sub gcd { return gcf($_[0], $_[1]); } #returns 1 for a prime number, else 0 #VS 6/30/2000 +# ^function isPrime sub isPrime { my $num = shift; return 1 if ($num == 2 or $num == 3); @@ -180,6 +194,8 @@ #reduces a fraction, returning an array containing ($numerator, $denominator) #VS 7/10/2000 +# ^function reduce +# ^uses gcd sub reduce { my $num = shift; @@ -203,6 +219,7 @@ # Usage: preformat($scalar, "quoted string"); # Example: preformat(-1, "\pi") returns "-\pi" # VS 8/1/2000 - slight adaption of code from T. Shemanske of Dartmouth College +# ^function preformat sub preformat { my $num = shift; my $obj = shift; @@ -217,7 +234,8 @@ } #factorial - +# ^function fact +# ^uses P sub fact { P($_[0], $_[0]); } Index: IO.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/IO.pl,v retrieving revision 1.8 retrieving revision 1.9 diff -Lmacros/IO.pl -Lmacros/IO.pl -u -r1.8 -r1.9 --- macros/IO.pl +++ macros/IO.pl @@ -24,7 +24,10 @@ =cut +# ^function _IO_init sub _IO_init {} + +# ^function _IO_export sub _IO_export { return ( '&send_mail_to', @@ -46,6 +49,12 @@ =cut # send_mail_to($user_address,'subject'=>$subject,'body'=>$body) +# ^function send_mail_to +# ^uses $envir{mailSmtpServer} +# ^uses $envir{mailSmtpSender} +# ^uses $REMOTE_HOST +# ^uses $REMOTE_ADDR +# ^uses Net::SMTP::new sub send_mail_to { my $user_address = shift; # user must be an instructor my %options = @_; @@ -111,6 +120,8 @@ =cut +# ^function getCourseTempDirectory +# ^user $envir{tempDirectory} sub getCourseTempDirectory { return $envir{tempDirectory}; } @@ -130,6 +141,9 @@ # A very useful macro for making sure that all of the directories to a file have been constructed. +# ^function surePathToTmpFile +# ^uses getCourseTempDirectory +# ^uses createDirectory sub surePathToTmpFile { # constructs intermediate directories if needed beginning at ${Global::htmlDirectory}tmp/ # the input path must be either the full path, or the path relative to this tmp sub directory Index: LinearProgramming.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/LinearProgramming.pl,v retrieving revision 1.2 retrieving revision 1.3 diff -Lmacros/LinearProgramming.pl -Lmacros/LinearProgramming.pl -u -r1.2 -r1.3 --- macros/LinearProgramming.pl +++ macros/LinearProgramming.pl @@ -73,6 +73,7 @@ # perform a pivot operation # lp_pivot([[1,2,3],...,[4,5,6]], row, col, fractionmode) # row and col indecies start at 0 +# ^function lp_pivot sub lp_pivot { my $a_ref = shift; my $row = shift; @@ -125,6 +126,7 @@ # Find pivot column for standard part +# ^function lp_pivot_element sub lp_pivot_element { my $a_ref = shift; my $fracmode = shift; @@ -200,6 +202,10 @@ # lp_solve([[1,2,3],[4,5,6]]) # It returns a triple of the final tableau, a code to say if we # succeeded, and the number of pivots +# ^function lp_solve +# ^uses set_default_options +# ^uses lp_pivot_element +# ^uses lp_pivot sub lp_solve { my $a_ref_orig = shift; my %opts = @_; @@ -251,6 +257,8 @@ # The variable is specified by column number, with 0 for P, 1 for x_1, # and so on +# ^function lp_current_value +# ^uses Fraction::new sub lp_current_value { my $col = shift; my $aref = shift; @@ -300,11 +308,14 @@ =cut # Display a tableau in math mode +# ^function lp_display_mm +# ^uses lp_display sub lp_display_mm { lp_display(@_, force_tex=>1); } # Make a copy of a tableau +# ^function lp_clone sub lp_clone { my $a1_ref = shift; my $a_ref = []; # make a copy to modify @@ -342,6 +353,9 @@ =cut # Display a tableau +# ^function lp_display +# ^uses lp_clone +# ^uses display_matrix sub lp_display { my $a1_ref = shift; my %opts = @_; Index: PGanswermacros.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/PGanswermacros.pl,v retrieving revision 1.66 retrieving revision 1.67 diff -Lmacros/PGanswermacros.pl -Lmacros/PGanswermacros.pl -u -r1.66 -r1.67 --- macros/PGanswermacros.pl +++ macros/PGanswermacros.pl @@ -130,17 +130,33 @@ =cut +# ^uses be_strict BEGIN { be_strict() } # Until we get the PG cacheing business sorted out, we need to use # PG_restricted_eval to get the correct values for some(?) PG environment # variables. We do this once here and place the values in lexicals for later # access. + +# ^variable $BR my $BR; +# ^variable $functLLimitDefault my $functLLimitDefault; +# ^variable $functULimitDefault my $functULimitDefault; +# ^variable $functVarDefault my $functVarDefault; +# ^variable $useBaseTenLog my $useBaseTenLog; + +# ^function _PGanswermacros_init +# ^uses loadMacros +# ^uses PG_restricted_eval +# ^uses $BR +# ^uses $envir{functLLimitDefault} +# ^uses $envir{functULimitDefault} +# ^uses $envir{functVarDefault} +# ^uses $envir{useBaseTenLog} sub _PGanswermacros_init { loadMacros('PGnumericevaluators.pl'); # even if these files are already loaded they need to be initialized. loadMacros('PGfunctionevaluators.pl'); @@ -152,7 +168,6 @@ $functULimitDefault = PG_restricted_eval(q/$envir{functULimitDefault}/); $functVarDefault = PG_restricted_eval(q/$envir{functVarDefault}/); $useBaseTenLog = PG_restricted_eval(q/$envir{useBaseTenLog}/); - } =head1 MACROS @@ -190,6 +205,8 @@ ## one or more variable names -- (var1, var2) ## OUT: an array of variable names +# ^function get_var_array +# ^uses $functVarDefault sub get_var_array { my $in = shift @_; my @out; @@ -237,6 +254,9 @@ ## an array of limits -- (llim,ulim) ## OUT: an array of array references -- ([llim,ulim], [llim,ulim]) or ([llim,ulim]) +# ^function get_limits_array +# ^uses $functLLimitDefault +# ^uses $functULimitDefault sub get_limits_array { my $in = shift @_; my @out; @@ -281,6 +301,7 @@ # simple subroutine to display an error message when # function compares are called with invalid parameters +# ^function function_invalid_params sub function_invalid_params { my $correctEqn = shift @_; my $error_response = sub { @@ -291,6 +312,7 @@ return $error_response; } +# ^function clean_up_error_msg sub clean_up_error_msg { my $msg = $_[0]; $msg =~ s/^\[[^\]]*\][^:]*://; @@ -306,6 +328,8 @@ #format must be of a form suitable for sprintf (e.g. '%0.5g'), #with the exception that a '#' at the end of the string #will cause trailing zeros in the decimal part to be removed +# ^function prfmt +# ^uses is_a_number sub prfmt { my($number,$format) = @_; # attention, the order of format and number are reversed my $out; @@ -386,7 +410,11 @@ =cut - +# ^function compare_numbers +# ^uses PG_answer_eval +# ^uses clean_up_error_msg +# ^uses prfmt +# ^uses is_a_number sub compare_numbers { my ($rh_ans, %options) = @_; my ($inVal,$PG_eval_errors,$PG_full_error_report) = PG_answer_eval($rh_ans->{student_ans}); @@ -430,6 +458,10 @@ =cut +# ^function std_num_filter +# ^uses math_constants +# ^uses PG_answer_eval +# ^uses clean_up_error_msg sub std_num_filter { my $rh_ans = shift; my %options = @_; @@ -464,6 +496,11 @@ =cut +# ^function std_num_array_filter +# ^uses set_default_options +# ^uses AnswerHash::new +# ^uses check_syntax +# ^uses std_num_filter sub std_num_array_filter { my $rh_ans= shift; my %options = @_; @@ -506,6 +543,13 @@ =cut +# ^function function_from_string2 +# ^uses assign_option_aliases +# ^uses set_default_options +# ^uses math_constants +# ^uses PG_restricted_eval +# ^uses PG_answer_eval +# ^uses clean_up_error_msg sub function_from_string2 { my $rh_ans = shift; my %options = @_; @@ -594,7 +638,8 @@ =cut - +# ^function is_zero_array +# ^uses is_a_number sub is_zero_array { my $rh_ans = shift; my %options = @_; @@ -678,6 +723,11 @@ # ) # # returns a list of coefficients +# ^function best_approx_parameters +# ^uses set_default_options +# ^uses pretty_print +# ^uses Matrix::new +# ^uses is_a_number sub best_approx_parameters { my $rh_ans = shift; my %options = @_; @@ -822,6 +872,9 @@ =cut +# ^function calculate_difference_vector +# ^uses assign_option_aliases +# ^uses set_default_options sub calculate_difference_vector { my $rh_ans = shift; my %options = @_; @@ -910,6 +963,10 @@ =cut +# ^function fix_answers_for_display +# ^uses evaluatesToNumber +# ^uses AnswerHash::new +# ^uses check_syntax sub fix_answers_for_display { my ($rh_ans, %options) = @_; if ( $rh_ans->{answerIsString} ==1) { @@ -934,6 +991,10 @@ =cut +# ^function evaluatesToNumber +# ^uses is_a_numeric_expression +# ^uses PG_answer_eval +# ^uses prfmt sub evaluatesToNumber { my ($rh_ans, %options) = @_; if (is_a_numeric_expression($rh_ans->{student_ans})) { @@ -952,6 +1013,8 @@ =cut +# ^function is_a_numeric_expression +# ^uses PG_answer_eval sub is_a_numeric_expression { my $testString = shift; my $is_a_numeric_expression = 0; @@ -968,6 +1031,7 @@ =cut +# ^function is_a_number sub is_a_number { my ($num,%options) = @_; my $process_ans_hash = ( ref( $num ) eq 'AnswerHash' ) ? 1 : 0 ; @@ -1005,6 +1069,7 @@ =cut +# ^function is_a_fraction sub is_a_fraction { my ($num,%options) = @_; my $process_ans_hash = ( ref( $num ) eq 'AnswerHash' ) ? 1 : 0 ; @@ -1043,6 +1108,7 @@ pi, which for the tangent function, were equivalent values. This method allows for this. =cut +# ^function phase_pi sub phase_pi { my ($num,%options) = @_; my $process_ans_hash = ( ref( $num ) eq 'AnswerHash' ) ? 1 : 0 ; @@ -1064,6 +1130,7 @@ =cut +# ^function is_an_arithmetic_expression sub is_an_arithmetic_expression { my ($num,%options) = @_; my $process_ans_hash = ( ref( $num ) eq 'AnswerHash' ) ? 1 : 0 ; @@ -1107,6 +1174,7 @@ =cut +# ^function math_constants sub math_constants { my($in,%options) = @_; my $rh_ans; @@ -1141,6 +1209,7 @@ =cut +# ^function is_array sub is_array { my $rh_ans = shift; # return if the result is an array @@ -1162,6 +1231,10 @@ =cut +# ^function check_syntax +# ^uses assign_option_aliases +# ^uses set_default_options +# ^uses AlgParserWithImplicitExpand::new sub check_syntax { my $rh_ans = shift; my %options = @_; @@ -1212,6 +1285,9 @@ =cut +# ^function check_strings +# ^uses str_filters +# ^uses str_cmp sub check_strings { my ($rh_ans, %options) = @_; @@ -1285,6 +1361,11 @@ =cut +# ^function check_units +# ^uses str_filters +# ^uses Units::evaluate_units +# ^uses clean_up_error_msg +# ^uses prfmt sub check_units { my ($rh_ans, %options) = @_; my %correct_units = %{$rh_ans-> {rh_correct_units}}; @@ -1373,7 +1454,7 @@ =cut - +# ^function assign_option_aliases sub assign_option_aliases { my $rh_options = shift; warn "The first entry to set_default_options must be a reference to the option hash" unless ref($rh_options) eq 'HASH'; @@ -1425,6 +1506,8 @@ =cut +# ^function set_default_options +# ^uses pretty_print sub set_default_options { my $rh_options = shift; warn "The first entry to set_default_options must be a reference to the option hash" unless ref($rh_options) eq 'HASH'; @@ -1451,6 +1534,9 @@ ##################################### # This is a model for plug-in problem graders ##################################### +# ^function install_problem_grader +# ^uses PG_restricted_eval +# ^uses %PG_FLAGS{PROBLEM_GRADER_TO_USE} sub install_problem_grader { my $rf_problem_grader = shift; my $rh_flags = PG_restricted_eval(q!\\%main::PG_FLAGS!); @@ -1469,6 +1555,7 @@ =cut +# ^function std_problem_grader sub std_problem_grader { my $rh_evaluated_answers = shift; my $rh_problem_state = shift; @@ -1568,6 +1655,7 @@ +# ^function std_problem_grader2 sub std_problem_grader2 { my $rh_evaluated_answers = shift; my $rh_problem_state = shift; @@ -1665,7 +1753,7 @@ =cut - +# ^function avg_problem_grader sub avg_problem_grader { my $rh_evaluated_answers = shift; my $rh_problem_state = shift; @@ -1739,6 +1827,9 @@ =cut +# ^function pretty_print +# ^uses lex_sort +# ^uses pretty_print sub pretty_print { my $r_input = shift; my $out = ''; @@ -1768,6 +1859,4 @@ $out; } - - 1; Index: MathObjects.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/MathObjects.pl,v retrieving revision 1.8 retrieving revision 1.9 diff -Lmacros/MathObjects.pl -Lmacros/MathObjects.pl -u -r1.8 -r1.9 --- macros/MathObjects.pl +++ macros/MathObjects.pl @@ -32,6 +32,7 @@ =cut +# ^uses loadMacros loadMacros("Parser.pl"); 1; Index: PGasu.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/PGasu.pl,v retrieving revision 1.7 retrieving revision 1.8 diff -Lmacros/PGasu.pl -Lmacros/PGasu.pl -u -r1.7 -r1.8 --- macros/PGasu.pl +++ macros/PGasu.pl @@ -30,6 +30,9 @@ =cut +# ^function auto_right +# ^uses AnswerEvaluator::new +# ^uses auto_right_checker sub auto_right { my $cmt = shift; my %params = @_; @@ -48,6 +51,7 @@ # used in auto_right above +# ^function auto_right_checker sub auto_right_checker { my $ans = shift; $ans->score(1); @@ -68,7 +72,10 @@ =cut - +# ^function no_decs +# ^uses must_have_filter +# ^uses raw_student_answer_filter +# ^uses catch_errors_filter sub no_decs { my ($old_evaluator) = @_; @@ -89,6 +96,10 @@ =cut +# ^function must_include +# ^uses must_have_filter +# ^uses raw_student_answer_filter +# ^uses catch_errors_filter sub must_include { my ($old_evaluator) = shift; my $muststr = shift; @@ -109,6 +120,10 @@ =cut +# ^function no_trig_fun +# ^uses fun_cmp +# ^uses must_have_filter +# ^uses catch_errors_filter sub no_trig_fun { my ($ans) = shift; my $new_eval = fun_cmp($ans); @@ -130,6 +145,10 @@ =cut +# ^function no_trig +# ^uses num_cmp +# ^uses must_have_filter +# ^uses catch_errors_filter sub no_trig { my ($ans) = shift; my $new_eval = num_cmp($ans); @@ -151,6 +170,10 @@ =cut +# ^function exact_no_trig +# ^uses num_cmp +# ^uses no_decs +# ^uses must_have_filter sub exact_no_trig { my ($ans) = shift; my $old_eval = num_cmp($ans); @@ -186,6 +209,7 @@ # First argument is the string to have, or not have # Second argument is optional, and tells us whether yes or no # Third argument is the error message to produce (if any). +# ^function must_have_filter sub must_have_filter { my $str = shift; my $yesno = shift; @@ -241,6 +265,7 @@ =cut +# ^function catch_errors_filter sub catch_errors_filter { my ($rh_ans) = shift; if ($rh_ans->catch_error('SYNTAX') ) { @@ -260,7 +285,7 @@ =cut - +# ^function raw_student_answer_filter sub raw_student_answer_filter { my ($rh_ans) = shift; # warn "answer was ".$rh_ans->{student_ans}; @@ -277,7 +302,8 @@ =cut - +# ^function no_decimal_list +# ^uses number_list_cmp sub no_decimal_list { my ($ans) = shift; my (%jopts) = @_; @@ -311,7 +337,8 @@ =cut - +# ^function no_decimals +# ^uses std_num_cmp sub no_decimals { my ($ans) = shift; my (%jopts) = @_; @@ -347,7 +374,7 @@ # Wrapper for an answer evaluator which can also supply comments - +# ^function with_comments sub with_comments { my ($old_evaluator, $cmt) = @_; @@ -394,7 +421,7 @@ # [answer_evaluator, partial credit factor, comment] # it applies evaluators from the list until it hits one with positive credit, # weights it by the partial credit factor, and throws in its comment - +# ^function pc_evaluator sub pc_evaluator { my @ev_list; if(ref($_[0]) ne 'ARRAY') { @@ -451,6 +478,9 @@ =cut +# ^function weighted_partial_grader +# ^uses $ENV{grader_message} +# ^uses $ENV{partial_weights} sub weighted_partial_grader { my $rh_evaluated_answers = shift; my $rh_problem_state = shift; Index: Parser.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/Parser.pl,v retrieving revision 1.14 retrieving revision 1.15 diff -Lmacros/Parser.pl -Lmacros/Parser.pl -u -r1.14 -r1.15 --- macros/Parser.pl +++ macros/Parser.pl @@ -25,6 +25,8 @@ ## Set up the functions needed by the Parser. ## +# ^uses $Parser::installed +# ^uses $Value::installed if (!$Parser::installed) { die "\n************************************************************\n" . "* This problem requires the Parser.pm package, which doesn't\n". @@ -40,6 +42,7 @@ "************************************************************\n\n" } +# ^uses loadMacros loadMacros("Value.pl"); loadMacros("PGcommonFunctions.pl"); @@ -54,6 +57,8 @@ =cut +# ^function Formula +# ^uses Value::Package sub Formula {Value->Package("Formula()")->new(@_)} =head2 Compute @@ -79,6 +84,8 @@ =cut +# ^function Compute +# ^uses Formula sub Compute { my $string = shift; my $formula = Formula($string); @@ -105,8 +112,13 @@ =cut +# ^function Context +# ^uses Parser::Context::current +# ^uses %context sub Context {Parser::Context->current(\%context,@_)} +# ^variable %context %context = (); # Locally defined contexts, including 'current' context +# ^uses Context Context(); # Initialize context (for persistent mod_perl) ########################################################################### @@ -114,27 +126,64 @@ # stubs for trigonometric functions # +# ^package Ignore package Ignore; ## let PGauxiliaryFunctions.pl do these +# ^#function sin +# ^#uses Parser::Function::call #sub sin {Parser::Function->call('sin',@_)} # Let overload handle it +# ^#function cos +# ^#uses Parser::Function::call #sub cos {Parser::Function->call('cos',@_)} # Let overload handle it +# ^function tan +# ^uses Parser::Function::call sub tan {Parser::Function->call('tan',@_)} +# ^function sec +# ^uses Parser::Function::call sub sec {Parser::Function->call('sec',@_)} +# ^function csc +# ^uses Parser::Function::call sub csc {Parser::Function->call('csc',@_)} +# ^function cot +# ^uses Parser::Function::call sub cot {Parser::Function->call('cot',@_)} +# ^function asin +# ^uses Parser::Function::call sub asin {Parser::Function->call('asin',@_)} +# ^function acos +# ^uses Parser::Function::call sub acos {Parser::Function->call('acos',@_)} +# ^function atan +# ^uses Parser::Function::call sub atan {Parser::Function->call('atan',@_)} +# ^function asec +# ^uses Parser::Function::call sub asec {Parser::Function->call('asec',@_)} +# ^function acsc +# ^uses Parser::Function::call sub acsc {Parser::Function->call('acsc',@_)} +# ^function acot +# ^uses Parser::Function::call sub acot {Parser::Function->call('acot',@_)} +# ^function arcsin +# ^uses Parser::Function::call sub arcsin {Parser::Function->call('asin',@_)} +# ^function arccos +# ^uses Parser::Function::call sub arccos {Parser::Function->call('acos',@_)} +# ^function arctan +# ^uses Parser::Function::call sub arctan {Parser::Function->call('atan',@_)} +# ^function arcsec +# ^uses Parser::Function::call sub arcsec {Parser::Function->call('asec',@_)} +# ^function arccsc +# ^uses Parser::Function::call sub arccsc {Parser::Function->call('acsc',@_)} +# ^function arccot +# ^uses Parser::Function::call sub arccot {Parser::Function->call('acot',@_)} ########################################################################### @@ -142,25 +191,61 @@ # stubs for hyperbolic functions # +# ^function sinh +# ^uses Parser::Function::call sub sinh {Parser::Function->call('sinh',@_)} +# ^function cosh +# ^uses Parser::Function::call sub cosh {Parser::Function->call('cosh',@_)} +# ^function tanh +# ^uses Parser::Function::call sub tanh {Parser::Function->call('tanh',@_)} +# ^function sech +# ^uses Parser::Function::call sub sech {Parser::Function->call('sech',@_)} +# ^function csch +# ^uses Parser::Function::call sub csch {Parser::Function->call('csch',@_)} +# ^function coth +# ^uses Parser::Function::call sub coth {Parser::Function->call('coth',@_)} +# ^function asinh +# ^uses Parser::Function::call sub asinh {Parser::Function->call('asinh',@_)} +# ^function acosh +# ^uses Parser::Function::call sub acosh {Parser::Function->call('acosh',@_)} +# ^function atanh +# ^uses Parser::Function::call sub atanh {Parser::Function->call('atanh',@_)} +# ^function asech +# ^uses Parser::Function::call sub asech {Parser::Function->call('asech',@_)} +# ^function acsch +# ^uses Parser::Function::call sub acsch {Parser::Function->call('acsch',@_)} +# ^function acoth +# ^uses Parser::Function::call sub acoth {Parser::Function->call('acoth',@_)} +# ^function arcsinh +# ^uses Parser::Function::call sub arcsinh {Parser::Function->call('asinh',@_)} +# ^function arccosh +# ^uses Parser::Function::call sub arccosh {Parser::Function->call('acosh',@_)} +# ^function arctanh +# ^uses Parser::Function::call sub arctanh {Parser::Function->call('atanh',@_)} +# ^function arcsech +# ^uses Parser::Function::call sub arcsech {Parser::Function->call('asech',@_)} +# ^function arccsch +# ^uses Parser::Function::call sub arccsch {Parser::Function->call('acsch',@_)} +# ^function arccoth +# ^uses Parser::Function::call sub arccoth {Parser::Function->call('acoth',@_)} ########################################################################### @@ -168,20 +253,43 @@ # stubs for numeric functions # +# ^#function log +# ^#uses Parser::Function::call #sub log {Parser::Function->call('log',@_)} # Let overload handle it +# ^function log10 +# ^uses Parser::Function::call sub log10 {Parser::Function->call('log10',@_)} +# ^#function exp +# ^#uses Parser::Function::call #sub exp {Parser::Function->call('exp',@_)} # Let overload handle it +# ^#function sqrt +# ^#uses Parser::Function::call #sub sqrt {Parser::Function->call('sqrt',@_)} # Let overload handle it +# ^#function abs +# ^#uses Parser::Function::call #sub abs {Parser::Function->call('abs',@_)} # Let overload handle it +# ^function int +# ^uses Parser::Function::call sub int {Parser::Function->call('int',@_)} +# ^function sgn +# ^uses Parser::Function::call sub sgn {Parser::Function->call('sgn',@_)} +# ^function ln +# ^uses Parser::Function::call sub ln {Parser::Function->call('log',@_)} +# ^function logten +# ^uses Parser::Function::call sub logten {Parser::Function->call('log10',@_)} +# ^package main package main; ## back to main +# ^function log10 +# ^uses Parser::Function::call sub log10 {Parser::Function->call('log10',@_)} +# ^function Factorial +# ^uses Parser::UOP::factorial::call sub Factorial {Parser::UOP::factorial->call(@_)} ########################################################################### @@ -189,6 +297,8 @@ # stubs for special functions # +# ^#function atan2 +# ^#usesParser::Function::call #sub atan2 {Parser::Function->call('atan2',@_)} # Let overload handle it ########################################################################### @@ -196,10 +306,20 @@ # stubs for numeric functions # +# ^function arg +# ^uses Parser::Function::call sub arg {Parser::Function->call('arg',@_)} +# ^function mod +# ^uses Parser::Function::call sub mod {Parser::Function->call('mod',@_)} +# ^function Re +# ^uses Parser::Function::call sub Re {Parser::Function->call('Re',@_)} +# ^function Im +# ^uses Parser::Function::call sub Im {Parser::Function->call('Im',@_)} +# ^function conj +# ^uses Parser::Function::call sub conj {Parser::Function->call('conj',@_)} ########################################################################### @@ -207,7 +327,11 @@ # stubs for vector functions # +# ^function norm +# ^uses Parser::Function::call sub norm {Parser::Function->call('norm',@_)} +# ^function unit +# ^uses Parser::Function::call sub unit {Parser::Function->call('unit',@_)} # @@ -219,10 +343,13 @@ ########################################################################### +# ^variable $_parser_loaded $_parser_loaded = 1; # use this to tell if Parser.pl is loaded +# ^function _Parser_init sub _Parser_init {}; # don't let loadMacros load it again +# ^uses loadMacros loadMacros("parserCustomization.pl"); ########################################################################### Index: dangerousMacros.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/dangerousMacros.pl,v retrieving revision 1.50 retrieving revision 1.51 diff -Lmacros/dangerousMacros.pl -Lmacros/dangerousMacros.pl -u -r1.50 -r1.51 --- macros/dangerousMacros.pl +++ macros/dangerousMacros.pl @@ -97,19 +97,37 @@ } +# ^variable $debugON my $debugON = 0; # grab read only variables from the current safe compartment +# ^variable $macrosPath my ($macrosPath, + # ^variable $pwd $pwd, + # ^variable $appletPath $appletPath, + # ^variable $server_root_url $server_root_url, + # ^variable $templateDirectory $templateDirectory, + # ^variable $scriptDirectory $scriptDirectory, + # ^variable $externalTTHPath $externalTTHPath, ); +# ^function _dangerousMacros_init +# ^uses %envir +# ^uses $macrosPath +# ^uses $pwd +# ^uses $appletPath +# ^uses $server_root_url +# ^uses $templateDirectory +# ^uses $scriptDirectory +# ^uses $externalTTHPath +# ^uses $debugON sub _dangerousMacros_init { #use envir instead of local variables? # will allow easy addition of new directories -- is this too liberal? do some pg directories need to be protected? $macrosPath = eval('$main::envir{pgDirectories}{macrosPath}'); @@ -128,6 +146,7 @@ warn eval(q! "dangerousmacros.pl: The envir variable $main::{envir} is".join(" ",%main::envir)!) if $debugON; } +# ^function _dangerousMacros_export sub _dangerousMacros_export { my @EXPORT= ( '&_dangerousMacros_init', @@ -205,7 +224,11 @@ # A kludge using require works around this problem - +# ^function loadMacros +# ^uses time_it +# ^uses $debugON +# ^uses $externalTTHPath +# ^uses findMacroFile sub loadMacros { my @files = @_; my $fileName; @@ -316,6 +339,10 @@ # # Look for a macro file in the directories specified in the macros path # + +# ^function findMacroFile +# ^uses $macrosPath +# ^uses $pwd sub findMacroFile { my $fileName = shift; my $filePath; @@ -326,6 +353,9 @@ } return; # no file found } + +# ^function check_url +# ^uses %envir sub check_url { my $url = shift; return undef if $url =~ /;/; # make sure we can't get a second command in the url @@ -339,8 +369,13 @@ return ($response) ? 0 : 1; # 0 indicates success, 256 is failure possibly more checks can be made } - +# ^variable %appletCodebaseLocations our %appletCodebaseLocations = (); +# ^function findAppletCodebase +# ^uses %appletCodebaseLocations +# ^uses $appletPath +# ^uses $server_root_url +# ^uses check_url sub findAppletCodebase { my $fileName = shift; # probably the name of a jar file return $appletCodebaseLocations{$fileName} #check cache first @@ -360,6 +395,10 @@ return "Error: $fileName not found at ". join(", ", @{$appletPath} ); # no file found } # errors in compiling macros is not always being reported. +# ^function compile_file +# ^uses @__eval__ +# ^uses PG_restricted_eval +# ^uses $__files__ sub compile_file { my $filePath = shift; warn "loading $filePath" if $debugON; @@ -402,14 +441,14 @@ =cut -# Global variables used: -# $main::tmp_file_permission, -# $main::numericalGroupID - -#Global macros used: -# &convertPath -# &surePathToTmpFile - +# ^function insertGraph +# ^uses $WWPlot::use_png +# ^uses convertPath +# ^uses surePathToTmpFile +# ^uses PG_restricted_eval +# ^uses $refreshCachedImages +# ^uses $templateDirectory +# ^uses %envir sub insertGraph { # Convert the image to GIF and print it on standard output my $graph = shift; @@ -462,20 +501,21 @@ =cut -# This file allows the tth display. -# Global variables: -# ${main::templateDirectory}tthPreamble.tex # location of any preamble TeX commands for tth -# ${main::templateDirectory} -# ${main::scriptDirectory}tth # path to tth application -# Global macros: -# None - # the contents of this file will not change during problem compilation it # only needs to be read once. however, the contents of the file may change, # and indeed the file refered to may change, between rendering passes. thus, # we need to keep track of the file name and the mtime as well. +# ^variable $tthPreambleFile +# ^variable $tthPreambleMtime +# ^variable $tthPreambleContents my ($tthPreambleFile, $tthPreambleMtime, $tthPreambleContents); +# ^function tth +# ^uses $templateDirectory +# ^uses $envir{externalTTHPath} +# ^uses $tthPreambleFile +# ^uses $tthPreambleMtime +# ^uses $tthPreambleContents sub tth { my $inputString = shift; @@ -538,6 +578,7 @@ } # possible solution to the tth font problem? Works only for iCab. +# ^function symbolConvert sub symbolConvert { my $string = shift; $string =~ s/\x5C/\\/g; #\ 92 \ @@ -576,8 +617,21 @@ =cut +# ^variable $math2imgCount my $math2imgCount = 0; +# ^function math2img +# ^uses $math2imgCount +# ^uses $envir{templateDirectory} +# ^uses $envir{fileName} +# ^uses $envir{studentLogin} +# ^uses $envir{setNumber} +# ^uses $envir{probNum} +# ^uses $envir{tempURL} +# ^uses $envir{refreshMath2img} +# ^uses $envir{dvipngTempDir} +# ^uses $envir{externalLaTeXPath} +# ^uses $envir{externalDvipngPath} sub math2img { my $tex = shift; my $mode = shift; @@ -624,6 +678,7 @@ =cut # copied from IO.pm for backward compatibility with WeBWorK1.8; +# ^function dvipng sub dvipng($$$$$) { my ( $wd, # working directory, for latex and dvipng garbage @@ -819,32 +874,28 @@ # Alias does not do any garbage collection, so files and alias may accumulate and # need to be removed manually or by a reaper daemon. - -# Global variables used: -# $main::fileName # the full path to the current problem template file -# $main::htmlDirectory -# $main::htmlURL -# $main::tempDirectory -# $main::tempURL -# $main::studentLogin -# $main::psvnNumber -# $main::setNumber -# $main::probNum -# $main::displayMode - -# Global macros used -# gif2eps An external file called by system -# surePathToTmpFile -# convertPath -# directoryFromPath - - # This subroutine has commands which will not work on non-UNIX environments. # system("cat $gifSourceFile | /usr/math/bin/giftopnm | /usr/math/bin/pnmdepth 1 | /usr/math/bin/pnmtops -noturn>$adr_output") && - -# local constants $User, $psvn $setNumber $probNum $displayMode - +# ^function alias +# ^uses %envir +# ^uses $envir{fileName} +# ^uses $envir{htmlDirectory} +# ^uses $envir{htmlURL} +# ^uses $envir{tempDirectory} +# ^uses $envir{tempURL} +# ^uses $envir{studentLogin} +# ^uses $envir{psvnNumber} +# ^uses $envir{setNumber} +# ^uses $envir{probNum} +# ^uses $envir{displayMode} +# ^uses $envir{externalGif2EpsPath} +# ^uses $envir{externalPng2EpsPath} +# ^uses &surePathToTmpFile +# ^uses &convertPath +# ^uses &directoryFromPath +# ^uses &fileFromPath +# ^uses $envir{texDisposition} sub alias { # input is a path to the original auxiliary file my $envir = eval(q!\%main::envir!); # get the current root environment @@ -1241,6 +1292,15 @@ =cut +# ^function sourceAlias +# ^uses PG_restricted_eval +# ^uses %envir +# ^uses $envir{inputs_ref} +# ^uses $envir{psvn} +# ^uses $envir{probNum} +# ^uses $envir{displayMode} +# ^uses $envir{courseName} +# ^uses $envir{sessionKey} sub sourceAlias { my $path_to_file = shift; my $envir = PG_restricted_eval(q!\%main::envir!); @@ -1262,24 +1322,38 @@ # Some constants that can be used in perl experssions # +# ^function i +# ^uses $_parser_loaded +# ^uses &Complex::i +# ^uses &Value::Package sub i () { # check if Parser.pl is loaded, otherwise use Complex package if (!eval(q!$main::_parser_loaded!)) {return Complex::i} return Value->Package("Formula")->new('i')->eval; } +# ^function j +# ^uses $_parser_loaded +# ^uses &Value::Package sub j () { if (!eval(q!$main::_parser_loaded!)) {return 'j'} Value->Package("Formula")->new('j')->eval; } +# ^function k +# ^uses $_parser_loaded +# ^uses &Value::Package sub k () { if (!eval(q!$main::_parser_loaded!)) {return 'k'} Value->Package("Formula")->new('k')->eval; } +# ^function pi +# ^uses &Value::Package sub pi () {Value->Package("Formula")->new('pi')->eval} +# ^function Infinity +# ^uses &Value::Package sub Infinity () {Value->Package("Infinity")->new()} 1; Index: PG.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/PG.pl,v retrieving revision 1.35 retrieving revision 1.36 diff -Lmacros/PG.pl -Lmacros/PG.pl -u -r1.35 -r1.36 --- macros/PG.pl +++ macros/PG.pl @@ -107,8 +107,18 @@ # Private variables for the PG.pl file. -my ($STRINGforOUTPUT, $STRINGforHEADER_TEXT, @PG_ANSWERS, @PG_UNLABELED_ANSWERS); -my %PG_ANSWERS_HASH ; +# ^variable $STRINGforOUTPUT +my $STRINGforOUTPUT; +# ^variable $STRINGforHEADER_TEXT +my $STRINGforHEADER_TEXT; +# ^variable @PG_ANSWERS +my @PG_ANSWERS; +# ^variable @PG_UNLABELED_ANSWERS +my @PG_UNLABELED_ANSWERS; +# ^variable %PG_ANSWERS_HASH +my %PG_ANSWERS_HASH; + +# ^variable $PG_STOP_FLAG our $PG_STOP_FLAG; # my variables are unreliable if two DOCUMENTS were to be called before an ENDDOCUMENT @@ -143,6 +153,32 @@ =cut +# ^function DOCUMENT +# ^uses $STRINGforOUTPUT +# ^uses $STRINGforHEADER_TEXT +# ^uses @PG_ANSWERS +# ^uses $PG_STOP_FLAG +# ^uses @PG_UNLABELED_ANSWERS +# ^uses %PG_ANSWERS_HASH +# ^uses @PG_ANSWER_ENTRY_ORDER +# ^uses $ANSWER_PREFIX +# ^uses %PG_FLAGS +# ^uses $showPartialCorrectAnswers +# ^uses $showHints +# ^uses $solutionExists +# ^uses $hintExists +# ^uses $pgComment +# ^uses %gifs_created +# ^uses %envir +# ^uses $refSubmittedAnswers +# ^uses @submittedAnswers +# ^uses $PG_original_problemSeed +# ^uses $problemSeed +# ^uses $PG_random_generator +# ^uses $ans_rule_count +# ^uses $QUIZ_PREFIX +# (Also creates a package scalar named after each key in %envir containing a copy of the corresponding value.) +# ^uses &PGrandom::new sub DOCUMENT { $STRINGforOUTPUT =""; @@ -262,6 +298,8 @@ =cut +# ^function HEADER_TEXT +# ^uses $STRINGforHEADER_TEXT sub HEADER_TEXT { my @in = @_; $STRINGforHEADER_TEXT .= join(" ",@in); @@ -290,6 +328,9 @@ =cut +# ^function TEXT +# ^uses $PG_STOP_FLAG +# ^uses $STRINGforOUTPUT sub TEXT { return "" if $PG_STOP_FLAG; my @in = @_; @@ -313,6 +354,9 @@ =cut +# ^function ANS +# ^uses $PG_STOP_FLAG +# ^uses @PG_ANSWERS sub ANS{ return "" if $PG_STOP_FLAG; my @in = @_; @@ -336,6 +380,8 @@ =cut +# ^function LABELED_ANS +# ^uses &NAMED_ANS sub LABELED_ANS { &NAMED_ANS; } @@ -346,6 +392,8 @@ =cut +# ^function NAMED_ANS +# ^uses $PG_STOP_FLAG sub NAMED_ANS{ return "" if $PG_STOP_FLAG; my @in = @_; @@ -369,6 +417,8 @@ =cut +# ^function STOP_RENDERING +# ^uses $PG_STOP_FLAG sub STOP_RENDERING { $PG_STOP_FLAG=1; ""; @@ -383,6 +433,8 @@ =cut +# ^function RESUME_RENDERING +# ^uses $PG_STOP_FLAG sub RESUME_RENDERING { $PG_STOP_FLAG=0; ""; @@ -484,6 +536,10 @@ =cut +# ^function ENDDOCUMENT +# ^uses @PG_UNLABELED_ANSWERS +# ^uses %PG_ANSWERS_HASH +# ^uses @PG_ANSWERS sub ENDDOCUMENT { my $index=0; @@ -579,6 +635,8 @@ =cut +# ^function inc_ans_rule_count +# ^uses $ans_rule_count sub inc_ans_rule_count { eval(q!++$main::ans_rule_count!); # evalute at runtime to get correct main:: } @@ -592,6 +650,9 @@ =cut +# ^function RECORD_ANS_NAME +# ^uses $PG_STOP_FLAG +# ^uses @PG_ANSWER_ENTRY_ORDER sub RECORD_ANS_NAME { return "" if $PG_STOP_FLAG; my $label = shift; @@ -609,6 +670,11 @@ =cut +# ^function NEW_ANS_NAME +# ^uses $PG_STOP_FLAG +# ^uses $QUIZ_PREFIX +# ^uses $ANSWER_PREFIX +# ^uses @PG_UNLABELED_ANSWERS sub NEW_ANS_NAME { return "" if $PG_STOP_FLAG; my $number=shift; @@ -631,6 +697,9 @@ =cut +# ^function ANS_NUM_TO_NAME +# ^uses $QUIZ_PREFIX +# ^uses $ANSWER_PREFIX sub ANS_NUM_TO_NAME { my $number=shift; my $label = eval(q!$main::QUIZ_PREFIX.$main::ANSWER_PREFIX!).$number; @@ -648,6 +717,9 @@ =cut +# ^function RECORD_FORM_LABEL +# ^uses $PG_STOP_FLAG +# ^uses @KEPT_EXTRA_ANSWERS sub RECORD_FORM_LABEL { # this stores form data (such as sticky answers), but does nothing more # it's a bit of hack since we are storing these in the KEPT_EXTRA_ANSWERS queue even if they aren't answers per se. return "" if $PG_STOP_FLAG; @@ -665,6 +737,10 @@ =cut +# ^function NEW_ANS_ARRAY_NAME +# ^uses $PG_STOP_FLAG +# ^uses $QUIZ_PREFIX +# ^uses @PG_UNLABELED_ANSWERS sub NEW_ANS_ARRAY_NAME { # this keeps track of the answers which are entered implicitly, # rather than with a specific label return "" if $PG_STOP_FLAG; @@ -687,6 +763,8 @@ =cut +# ^function NEW_ANS_ARRAY_NAME_EXTENSION +# ^uses $PG_STOP_FLAG sub NEW_ANS_ARRAY_NAME_EXTENSION { # this keeps track of the answers which are entered implicitly, # rather than with a specific label return "" if $PG_STOP_FLAG; @@ -714,6 +792,10 @@ =cut +# ^function get_PG_ANSWERS_HASH +# ^uses %PG_ANSWERS_HASH +# ^uses @PG_UNLABELED_ANSWERS +# ^uses @PG_ANSWERS sub get_PG_ANSWERS_HASH { # update the PG_ANSWWERS_HASH, then report the result. # This is used in writing sequential problems @@ -751,6 +833,10 @@ =cut +# ^function includePGproblem +# ^uses %envir +# ^uses &read_whole_problem_file +# ^uses &includePGtext sub includePGproblem { my $filePath = shift; my %save_envir = %main::envir; @@ -783,4 +869,3 @@ =cut 1; - Index: extraAnswerEvaluators.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/extraAnswerEvaluators.pl,v retrieving revision 1.21 retrieving revision 1.22 diff -Lmacros/extraAnswerEvaluators.pl -Lmacros/extraAnswerEvaluators.pl -u -r1.21 -r1.22 --- macros/extraAnswerEvaluators.pl +++ macros/extraAnswerEvaluators.pl @@ -44,11 +44,14 @@ =cut +# ^uses loadMacros loadMacros('MathObjects.pl'); { + # ^package Equation_eval package Equation_eval; + # ^function split_eqn sub split_eqn { my $instring = shift; @@ -58,7 +61,11 @@ #FIXME -- this could be improved so that # 1. it uses an answer evaluator object instead of a sub routine # 2. it provides error messages when previous answers are equivalent - + # ^function equation_cmp + # ^uses AnswerHash::new + # ^uses split_eqn + # ^uses main::check_syntax + # ^uses main::fun_cmp sub equation_cmp { my $right_ans = shift; my %opts = @_; @@ -169,7 +176,15 @@ return $ans_eval; } } +# ^package main +# ^function mode2context +# ^uses Parser::Context::getCopy +# ^uses %context +# ^uses $numZeroLevelTolDefault +# ^uses $numAbsTolDefault +# ^uses $numRelPercentTolDefault +# ^uses $numFormatDefault sub mode2context { my $mode = shift; my %options = @_; @@ -297,6 +312,11 @@ =cut +# ^function interval_cmp +# ^uses Context +# ^uses mode2context +# ^uses List +# ^uses Union sub interval_cmp { my $correct_ans = shift; @@ -434,6 +454,10 @@ =cut +# ^function number_list_cmp +# ^uses Context +# ^uses mode2context +# ^uses List sub number_list_cmp { my $list = shift; @@ -488,6 +512,8 @@ =cut +# ^function equation_cmp +# ^uses Equation_eval::equation_cmp sub equation_cmp { Equation_eval::equation_cmp(@_); } |