./answers/PGfunctionevaluators.pl:# Until we get the PG cacheing business sorted out, we need to use ./answers/PGfunctionevaluators.pl:# PG_restricted_eval to get the correct values for some(?) PG environment ./answers/PGfunctionevaluators.pl:# variables. We do this once here and place the values in lexicals for later ./answers/PGfunctionevaluators.pl:# access. ./answers/PGfunctionevaluators.pl:## The following answer evaluator for comparing multivarable functions was ./answers/PGfunctionevaluators.pl:## contributed by Professor William K. Ziemer ./answers/PGfunctionevaluators.pl:## (Note: most of the multivariable functionality provided by Professor Ziemer ./answers/PGfunctionevaluators.pl:## has now been integrated into fun_cmp and FUNCTION_CMP) ./answers/PGfunctionevaluators.pl:############################ ./answers/PGfunctionevaluators.pl:# W.K. Ziemer, Sep. 1999 ./answers/PGfunctionevaluators.pl:# Math Dept. CSULB ./answers/PGfunctionevaluators.pl:# email: wziemer@csulb.edu ./answers/PGfunctionevaluators.pl:############################ ./answers/PGfunctionevaluators.pl:## LOW-LEVEL ROUTINE -- NOT NORMALLY FOR END USERS -- USE WITH CAUTION ./answers/PGfunctionevaluators.pl:## NOTE: PG_answer_eval is used instead of PG_restricted_eval in order to insure that the answer ./answers/PGfunctionevaluators.pl:## evaluated within the context of the package the problem was originally defined in. ./answers/PGfunctionevaluators.pl:## Includes multivariable modifications contributed by Professor William K. Ziemer ./answers/PGfunctionevaluators.pl:## ./answers/PGfunctionevaluators.pl:## IN: a hash consisting of the following keys (error checking to be added later?) ./answers/PGfunctionevaluators.pl:## correctEqn -- the correct equation as a string ./answers/PGfunctionevaluators.pl:## var -- the variable name as a string, ./answers/PGfunctionevaluators.pl:## or a reference to an array of variables ./answers/PGfunctionevaluators.pl:## limits -- reference to an array of arrays of type [lower,upper] ./answers/PGfunctionevaluators.pl:## tolerance -- the allowable margin of error ./answers/PGfunctionevaluators.pl:## tolType -- 'relative' or 'absolute' ./answers/PGfunctionevaluators.pl:## numPoints -- the number of points to evaluate the function at ./answers/PGfunctionevaluators.pl:## mode -- 'std' or 'antider' ./answers/PGfunctionevaluators.pl:## maxConstantOfIntegration -- maximum size of the constant of integration ./answers/PGfunctionevaluators.pl:## zeroLevel -- if the correct answer is this close to zero, ./answers/PGfunctionevaluators.pl:## then zeroLevelTol applies ./answers/PGfunctionevaluators.pl:## zeroLevelTol -- absolute tolerance to allow when answer is close to zero ./answers/PGfunctionevaluators.pl:## test_points -- user supplied points to use for testing the ./answers/PGfunctionevaluators.pl:## function, either array of arrays, or optionally ./answers/PGfunctionevaluators.pl:## reference to single array (for one variable) ./answers/PGfunctionevaluators.pl:# ./answers/PGfunctionevaluators.pl:# The original version, for backward compatibility ./answers/PGfunctionevaluators.pl:# (can be removed when the Parser-based version is more fully tested.) ./answers/PGfunctionevaluators.pl:# ./answers/PGnumericevaluators.pl:# Until we get the PG cacheing business sorted out, we need to use ./answers/PGnumericevaluators.pl:# PG_restricted_eval to get the correct values for some(?) PG environment ./answers/PGnumericevaluators.pl:# variables. We do this once here and place the values in lexicals for later ./answers/PGnumericevaluators.pl:# access. ./answers/PGnumericevaluators.pl:######################################################################### ./answers/PGnumericevaluators.pl:######################################################################### ./answers/PGnumericevaluators.pl:######################################################################### ./answers/PGnumericevaluators.pl:######################################################################### ./answers/PGnumericevaluators.pl:#legacy code for compatability purposes ./answers/PGnumericevaluators.pl:## Similar to std_num_cmp but accepts a list of numbers in the form ./answers/PGnumericevaluators.pl:## std_num_cmp_list(relpercentTol,format,ans1,ans2,ans3,...) ./answers/PGnumericevaluators.pl:## format is of the form "%10.3g" or "", i.e., a format suitable for sprintf(). Use "" for default ./answers/PGnumericevaluators.pl:## You must enter a format and tolerance ./answers/PGnumericevaluators.pl:## See std_num_cmp_list for usage ./answers/PGnumericevaluators.pl:## See std_num_cmp_list for usage ./answers/PGnumericevaluators.pl:## See std_num_cmp_list for usage ./answers/PGnumericevaluators.pl:## See std_num_cmp_list for usage ./answers/PGnumericevaluators.pl:## See std_num_cmp_list for usage ./answers/PGnumericevaluators.pl:## See std_num_cmp_list for usage ./answers/PGnumericevaluators.pl:## See std_num_cmp_list for usage ./answers/PGnumericevaluators.pl:## sub numerical_compare_with_units ./answers/PGnumericevaluators.pl:## Compares a number with units ./answers/PGnumericevaluators.pl:## Deprecated; use num_cmp() ./answers/PGnumericevaluators.pl:## ./answers/PGnumericevaluators.pl:## IN: a string which includes the numerical answer and the units ./answers/PGnumericevaluators.pl:## a hash with the following keys (all optional): ./answers/PGnumericevaluators.pl:## mode -- 'std', 'frac', 'arith', or 'strict' ./answers/PGnumericevaluators.pl:## format -- the format to use when displaying the answer ./answers/PGnumericevaluators.pl:## tol -- an absolute tolerance, or ./answers/PGnumericevaluators.pl:## relTol -- a relative tolerance ./answers/PGnumericevaluators.pl:## zeroLevel -- if the correct answer is this close to zero, then zeroLevelTol applies ./answers/PGnumericevaluators.pl:## zeroLevelTol -- absolute tolerance to allow when correct answer is close to zero ./answers/PGnumericevaluators.pl:# This mode is depricated. send input through num_cmp -- it can handle units. ./answers/PGnumericevaluators.pl:# ./answers/PGnumericevaluators.pl:# The original version, for backward compatibility ./answers/PGnumericevaluators.pl:# (can be removed when the Parser-based version is more fully tested.) ./answers/PGnumericevaluators.pl:# ./answers/PGnumericevaluators.pl:############################################################################### ./answers/PGnumericevaluators.pl:############################################################################### ./answers/Generic.pl:#From parserUtils.pl: ./answers/answerCustom.pl:# Set this to include any default parameters you want ./answers/answerCustom.pl:# to include in the custom answer checkers ./answers/answerCustom.pl:# Set this to include any default parameters you want ./answers/answerCustom.pl:# to include in the custom answer checkers. ./answers/PGstringevaluators.pl:################################ ./answers/PGstringevaluators.pl:## STRING ANSWER FILTERS ./answers/PGstringevaluators.pl:## IN: --the string to be filtered ./answers/PGstringevaluators.pl:## --a list of the filters to use ./answers/PGstringevaluators.pl:## ./answers/PGstringevaluators.pl:## OUT: --the modified string ./answers/PGstringevaluators.pl:## ./answers/PGstringevaluators.pl:## Use this subroutine instead of the ./answers/PGstringevaluators.pl:## individual filters below it ./answers/PGstringevaluators.pl:## LOW-LEVEL ROUTINE -- NOT NORMALLY FOR END USERS -- USE WITH CAUTION ./answers/PGstringevaluators.pl:## ./answers/PGstringevaluators.pl:## IN: a hashtable with the following entries (error-checking to be added later?): ./answers/PGstringevaluators.pl:## correctAnswer -- the correct answer, before filtering ./answers/PGstringevaluators.pl:## filters -- reference to an array containing the filters to be applied ./answers/PGstringevaluators.pl:## type -- a string containing the type of answer evaluator in use ./answers/PGstringevaluators.pl:## OUT: a reference to an answer evaluator subroutine ./answers/answerHints.pl:# ./answers/answerHints.pl:# Calls the answer checker on two values with a copy of the answer hash ./answers/answerHints.pl:# and returns true if the two values match and false otherwise. ./answers/answerHints.pl:# ./answers/weightedGrader.pl:################################################## ./answers/weightedGrader.pl:# ./answers/weightedGrader.pl:# Issue ANS() calls for the weighted checkers ./answers/weightedGrader.pl:# ./answers/weightedGrader.pl:################################################## ./answers/weightedGrader.pl:# ./answers/weightedGrader.pl:# Issue NAMED_ANS() calls for the weighted checkers ./answers/weightedGrader.pl:# ./answers/weightedGrader.pl:################################################## ./answers/weightedGrader.pl:# ./answers/weightedGrader.pl:# Issue an ANS() call for the checker, giving ./answers/weightedGrader.pl:# credit to the given answers. ./answers/weightedGrader.pl:# ./answers/weightedGrader.pl:################################################## ./answers/weightedGrader.pl:# ./answers/weightedGrader.pl:# Either add a weight to an AnswerEvaluator, or return a ./answers/weightedGrader.pl:# new checker that adds the weight to its result. Also, ./answers/weightedGrader.pl:# add the "credit" field, if supplied. ./answers/weightedGrader.pl:# ./answers/weightedGrader.pl:################################################## ./answers/weightedGrader.pl:# ./answers/weightedGrader.pl:# This is the weighted grader. It uses an extra field added to the ./answers/weightedGrader.pl:# AnswerHash (named "weight") to tell how much weight to give each ./answers/weightedGrader.pl:# problem. The grader adds up the total weights for the correct ./answers/weightedGrader.pl:# answers. For partially correct ones, it uses the score for that ./answers/weightedGrader.pl:# answer to give a portion of that weight. For example, if the ./answers/weightedGrader.pl:# weight is 40 and the score for the answer is .5, then 20 is added ./answers/weightedGrader.pl:# to the total for the problem. (Note that most answer checkers only ./answers/weightedGrader.pl:# return 1 or 0, but they are allowed to return partial credit as ./answers/weightedGrader.pl:# well.) ./answers/weightedGrader.pl:# ./answers/weightedGrader.pl:# When the student's total is computed, it is divided by the sum of ./answers/weightedGrader.pl:# all the weights in order to determine the final score. ./answers/weightedGrader.pl:# ./answers/weightedGrader.pl:# It also uses a special field called "credit" that determines ./answers/weightedGrader.pl:# what other (named) answers are given full credit if the given ./answers/weightedGrader.pl:# answer is correct. This can be used to make "optional" answers, ./answers/weightedGrader.pl:# where getting the "final" answer right gives credit for the other parts. ./answers/weightedGrader.pl:# ./answers/weightedGrader.pl:################################################## ./answers/weightedGrader.pl:# ./answers/weightedGrader.pl:# Syntactic sugar to avoid ugly ~~& construct in PG. ./answers/weightedGrader.pl:# ./answers/PGmiscevaluators.pl:# added 6/14/2000 by David Etlinger ./answers/PGmiscevaluators.pl:# because of the conversion of the answer ./answers/PGmiscevaluators.pl:# string to an array, I thought it better not ./answers/PGmiscevaluators.pl:# to force STR_CMP() to work with this ./answers/PGmiscevaluators.pl:#added 2/26/2003 by Mike Gage ./answers/PGmiscevaluators.pl:# handled the case where multiple answers are passed as an array reference ./answers/PGmiscevaluators.pl:# rather than as a \0 delimited string. ./answers/PGmiscevaluators.pl:#added 6/28/2000 by David Etlinger ./answers/PGmiscevaluators.pl:#exactly the same as strict_str_cmp, ./answers/PGmiscevaluators.pl:#but more intuitive to the user ./answers/PGmiscevaluators.pl:# check that answer is really a string and not an array ./answers/PGmiscevaluators.pl:# also use ordinary string compare ./answers/extraAnswerEvaluators.pl:# ^uses loadMacros ./answers/extraAnswerEvaluators.pl:# ^package main ./answers/extraAnswerEvaluators.pl:# ^function mode2context ./answers/extraAnswerEvaluators.pl:# ^uses Parser::Context::getCopy ./answers/extraAnswerEvaluators.pl:# ^uses %context ./answers/extraAnswerEvaluators.pl:# ^uses $numZeroLevelTolDefault ./answers/extraAnswerEvaluators.pl:# ^uses $numAbsTolDefault ./answers/extraAnswerEvaluators.pl:# ^uses $numRelPercentTolDefault ./answers/extraAnswerEvaluators.pl:# ^uses $numFormatDefault ./answers/extraAnswerEvaluators.pl:# ^function interval_cmp ./answers/extraAnswerEvaluators.pl:# ^uses Context ./answers/extraAnswerEvaluators.pl:# ^uses mode2context ./answers/extraAnswerEvaluators.pl:# ^uses List ./answers/extraAnswerEvaluators.pl:# ^uses Union ./answers/extraAnswerEvaluators.pl:# ^function number_list_cmp ./answers/extraAnswerEvaluators.pl:# ^uses Context ./answers/extraAnswerEvaluators.pl:# ^uses mode2context ./answers/extraAnswerEvaluators.pl:# ^uses List ./answers/extraAnswerEvaluators.pl:# ^function equation_cmp ./answers/extraAnswerEvaluators.pl:# ^uses Equation_eval::equation_cmp ./answers/unorderedAnswer.pl:########################################################################## ./answers/unorderedAnswer.pl:# ./answers/unorderedAnswer.pl:# Low-level routine for handling unordered collections of answer checkers ./answers/unorderedAnswer.pl:# ./answers/unorderedAnswer.pl:################################################## ./answers/unorderedAnswer.pl:# ./answers/unorderedAnswer.pl:# AnswerChecker that allows a blank answer in a collection of unordered ./answers/unorderedAnswer.pl:# answer checkers. It will return "correct" for a blank answer only if ./answers/unorderedAnswer.pl:# all the other answers are correct. (The blankOK value is set by ./answers/unorderedAnswer.pl:# unordered_answer_list when this is true.) This lets you ask a question ./answers/unorderedAnswer.pl:# where the number of answers is not known (by the student) ahead of time. ./answers/unorderedAnswer.pl:# ./answers/PGasu.pl:# ^function auto_right ./answers/PGasu.pl:# ^uses AnswerEvaluator::new ./answers/PGasu.pl:# ^uses auto_right_checker ./answers/PGasu.pl:# used in auto_right above ./answers/PGasu.pl:# ^function auto_right_checker ./answers/PGasu.pl:# ^function no_decs ./answers/PGasu.pl:# ^uses must_have_filter ./answers/PGasu.pl:# ^uses raw_student_answer_filter ./answers/PGasu.pl:# ^uses catch_errors_filter ./answers/PGasu.pl:# ^function must_include ./answers/PGasu.pl:# ^uses must_have_filter ./answers/PGasu.pl:# ^uses raw_student_answer_filter ./answers/PGasu.pl:# ^uses catch_errors_filter ./answers/PGasu.pl:# ^function no_trig_fun ./answers/PGasu.pl:# ^uses fun_cmp ./answers/PGasu.pl:# ^uses must_have_filter ./answers/PGasu.pl:# ^uses catch_errors_filter ./answers/PGasu.pl:# ^function no_trig ./answers/PGasu.pl:# ^uses num_cmp ./answers/PGasu.pl:# ^uses must_have_filter ./answers/PGasu.pl:# ^uses catch_errors_filter ./answers/PGasu.pl:# ^function exact_no_trig ./answers/PGasu.pl:# ^uses num_cmp ./answers/PGasu.pl:# ^uses no_decs ./answers/PGasu.pl:# ^uses must_have_filter ./answers/PGasu.pl:# First argument is the string to have, or not have ./answers/PGasu.pl:# Second argument is optional, and tells us whether yes or no ./answers/PGasu.pl:# Third argument is the error message to produce (if any). ./answers/PGasu.pl:# ^function must_have_filter ./answers/PGasu.pl:# ^function catch_errors_filter ./answers/PGasu.pl:# ^function raw_student_answer_filter ./answers/PGasu.pl:# ^function no_decimal_list ./answers/PGasu.pl:# ^uses number_list_cmp ./answers/PGasu.pl:# ^function no_decimals ./answers/PGasu.pl:# ^uses std_num_cmp ./answers/PGasu.pl:# ^function with_comments ./answers/PGasu.pl:# ^function pc_evaluator ./answers/PGasu.pl:# ^function weighted_partial_grader ./answers/PGasu.pl:# ^uses $ENV{grader_message} ./answers/PGasu.pl:# ^uses $ENV{partial_weights} ./PG.pl:# This loads the basic css needed by pg. ./PG.pl:# It is expected that the requestor will also load the styles for Bootstrap. ./PG.pl:# Some problems use jquery-ui still, and so the requestor should also load the css for that if those problems are used, ./PG.pl:# although those problems should also be rewritten to not use jquery-ui. ./PG.pl:# This loads the basic javascript needed by pg. ./PG.pl:# It is expected that the requestor will also load MathJax, Bootstrap, and jquery. ./PG.pl:# Some problems use jquery-ui still, and so the requestor should also load the js for that if those problems are used, ./PG.pl:# although those problems should also be rewritten to not use jquery-ui. ./PG.pl:# sageReturnedFail checks to see if the return from Sage indicates some kind of failure ./PG.pl:# undefined means old style return (a simple string) failed ./PG.pl:# $obj->{success} defined but equal to zero means that the failed return and error ./PG.pl:# messages are encoded in the $obj hash. ./PG.pl:# The store_persistent_data, update_persistent_data, and get_persistent_data methods are deprecated and are only still ./PG.pl:# here for backward compatability. Use the persistent_data method instead which can do everything these three methods ./PG.pl:# can do. Note that if you use the persistent_data method, then you will need to join the values as strings if you want ./PG.pl:# that. Even better pass the persistent_data method an array reference containing the values so you can avoid the hassle ./PG.pl:# of splitting the values when they are retrieved. ./PG.pl:# This stores form data (such as sticky answers), but does nothing more. ./PG.pl:# It's a bit of hack since we are storing these in the ./PG.pl:# KEPT_EXTRA_ANSWERS queue even if they aren't answers per se. ./PG.pl:# Creates a new array element answer name and records it. ./PG.pl:#FIXME -- examine the difference between insert_response and extend_response ./PG.pl:# For radio buttons and checkboxes. ./PG.pl:# This is a stub for deprecated problems that call this method. Some of the GeoGebra ./PG.pl:# problems that do so actually work even though this method does nothing. ./PG.pl:## Problem Grader Subroutines ./PG.pl:##################################### ./PG.pl:# This is a model for plug-in problem graders ./PG.pl:##################################### ./PG.pl:# ^function install_problem_grader ./PG.pl:# ^uses PG_restricted_eval ./PG.pl:# ^uses %PG_FLAGS{PROBLEM_GRADER_TO_USE} ./PG.pl:# FIXME? The following functions were taken from the former ./PG.pl:# dangerousMacros.pl file and might have issues when placed here. ./PG.pl:# ./PG.pl:# Some constants that can be used in perl expressions ./PG.pl:# ./PG.pl:# ^function i ./PG.pl:# ^uses $_parser_loaded ./PG.pl:# ^uses &Complex::i ./PG.pl:# ^uses &Value::Package ./PG.pl:# ^function j ./PG.pl:# ^uses $_parser_loaded ./PG.pl:# ^uses &Value::Package ./PG.pl:# ^function k ./PG.pl:# ^uses $_parser_loaded ./PG.pl:# ^uses &Value::Package ./PG.pl:# ^function pi ./PG.pl:# ^uses $_parser_loaded ./PG.pl:# ^uses &Value::Package ./PG.pl:# ^function Infinity ./PG.pl:# ^uses $_parser_loaded ./PG.pl:# ^uses &Value::Package ./PG.pl:# ^function abs ./PG.pl:# ^function sqrt ./PG.pl:# ^function exp ./PG.pl:# ^function log ./PG.pl:# ^function sin ./PG.pl:# ^function cos ./PG.pl:# ^function atan2 ./PG.pl:# ./PG.pl:# Allow these functions to be overridden without complaint. ./PG.pl:# (needed for log() to implement $useBaseTenLog) ./PG.pl:# ./PG.pl:#sub log {return CORE::log($_[0])}; ./PG.pl:# used to be Parser::defineLog -- but that generated redefined notices ./capa/PG_CAPAmacros.pl:# these are very commonly needed files ./capa/PG_CAPAmacros.pl:##################### ./ui/PGchoicemacros.pl:# ^function new_match_list ./ui/PGchoicemacros.pl:# ^uses Match::new ./ui/PGchoicemacros.pl:# ^uses &std_print_q ./ui/PGchoicemacros.pl:# ^uses &std_print_a ./ui/PGchoicemacros.pl:# ^function new_select_list ./ui/PGchoicemacros.pl:# ^uses Select::new ./ui/PGchoicemacros.pl:# ^uses &std_print_q ./ui/PGchoicemacros.pl:# ^uses &std_print_a ./ui/PGchoicemacros.pl:# ^function new_pop_up_select_list ./ui/PGchoicemacros.pl:# ^uses Select::new ./ui/PGchoicemacros.pl:# ^uses &pop_up_list_print_q ./ui/PGchoicemacros.pl:# ^uses &std_print_a ./ui/PGchoicemacros.pl:# ^function new_multiple_choice ./ui/PGchoicemacros.pl:# ^uses Multiple::new ./ui/PGchoicemacros.pl:# ^uses &std_print_q ./ui/PGchoicemacros.pl:# ^uses &radio_print_a ./ui/PGchoicemacros.pl:# ^function new_checkbox_multiple_choice ./ui/PGchoicemacros.pl:# ^uses Multiple::new ./ui/PGchoicemacros.pl:# ^uses &std_print_q ./ui/PGchoicemacros.pl:# ^uses &checkbox_print_a ./ui/PGchoicemacros.pl:# ^function std_print_q ./ui/PGchoicemacros.pl:# ^function pop_up_list_print_q ./ui/PGchoicemacros.pl:# To put pop-up-list at the end of a question. ./ui/PGchoicemacros.pl:# contributed by Mark Schmitt 3-6-03 ./ui/PGchoicemacros.pl:# ^function quest_first_pop_up_list_print_q ./ui/PGchoicemacros.pl:# To put pop-up-list in the middle of a question. ./ui/PGchoicemacros.pl:# contributed by Mark Schmitt 3-6-03 ./ui/PGchoicemacros.pl:# ^function ans_in_middle_pop_up_list_print_q ./ui/PGchoicemacros.pl:# Units for physics class ./ui/PGchoicemacros.pl:# contributed by Mark Schmitt 3-6-03 ./ui/PGchoicemacros.pl:# ^function units_list_print_q ./ui/PGchoicemacros.pl:#Standard method of printing answers in a matching list ./ui/PGchoicemacros.pl:# ^function std_print_a ./ui/PGchoicemacros.pl:#Alternate method of printing answers as a list of radio buttons for multiple choice ./ui/PGchoicemacros.pl:#Method for naming radio buttons is no longer round about and hackish ./ui/PGchoicemacros.pl:# ^function radio_print_a ./ui/PGchoicemacros.pl:# ^function checkbox_print_a ./ui/PGchoicemacros.pl:# ^function qa [DEPRECATED] ./ui/PGchoicemacros.pl:# ^function invert [DEPRECATED] ./ui/PGchoicemacros.pl:# ^function NchooseK [DEPRECATED] ./ui/PGchoicemacros.pl:# ^function shuffle [DEPRECATED] ./ui/PGchoicemacros.pl:# ^function match_questions_list [DEPRECATED] ./ui/PGchoicemacros.pl:# ^function match_questions_list_varbox [DEPRECATED] ./ui/unionTables.pl:# This could have been a variable, ./ui/unionTables.pl:# but all the other table commands are subroutines, so kept it ./ui/unionTables.pl:# one to be consistent. ./ui/unionLists.pl:###################################################################### ./ui/unionLists.pl:## ./ui/unionLists.pl:## Functions used to make