From 09b1c46888882b83ca3c0715bc241d8788119562 Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Thu, 18 Dec 2025 20:22:39 -0600 Subject: [PATCH] Remove everything CAPA. The CAPA problems have now been removed from the Contrib section of the OPL (see https://github.com/openwebwork/webwork-open-problem-library/pull/1277). So this is not needed anymore. Note that the files in the `macros/capa` directory were not used anyway. The webwork2 `specialPGEnvironmentVars` settings related to CAPA problems control where these files are used from, and those still were using the `Contrib/CAPA/macros` directories. We could update those, but there were files there that were not copied (they were .pg files that were actually macros and it was probably believed that they were problem files). So in short CAPA problems just will not work anymore even without this pull request. --- assets/tex/CAPA.tex | 15 --- assets/tex/pg.sty | 1 - conf/pg_config.dist.yml | 7 -- lib/PGloadfiles.pm | 2 +- lib/WeBWorK/PG/IO.pm | 10 +- macros/README.md | 3 +- macros/capa/PG_CAPAmacros.pl | 208 ----------------------------------- macros/capa/StdConst.pg | 36 ------ macros/capa/StdUnits.pg | 79 ------------- t/macros/load_macros.t | 3 +- 10 files changed, 7 insertions(+), 357 deletions(-) delete mode 100644 assets/tex/CAPA.tex delete mode 100644 macros/capa/PG_CAPAmacros.pl delete mode 100644 macros/capa/StdConst.pg delete mode 100644 macros/capa/StdUnits.pg diff --git a/assets/tex/CAPA.tex b/assets/tex/CAPA.tex deleted file mode 100644 index 61d1ffa208..0000000000 --- a/assets/tex/CAPA.tex +++ /dev/null @@ -1,15 +0,0 @@ -% capa tex macros - -\newcommand{\capa}{{\sl C\kern-.10em\raise-.00ex\hbox{\rm A}\kern-.22em% -{\sl P}\kern-.14em\kern-.01em{\rm A}}} - -\newenvironment{choicelist} -{\begin{list}{} - {\setlength{\rightmargin}{0in}\setlength{\leftmargin}{0.13in} - \setlength{\topsep}{0.05in}\setlength{\itemsep}{0.022in} - \setlength{\parsep}{0in}\setlength{\belowdisplayskip}{0.04in} - \setlength{\abovedisplayskip}{0.05in} - \setlength{\abovedisplayshortskip}{-0.04in} - \setlength{\belowdisplayshortskip}{0.04in}} - } -{\end{list}} diff --git a/assets/tex/pg.sty b/assets/tex/pg.sty index be1921fd80..0f895b87ff 100644 --- a/assets/tex/pg.sty +++ b/assets/tex/pg.sty @@ -22,7 +22,6 @@ \fi % PG macro collections -\input{CAPA.tex} \input{PGML.tex} % The macro alternatives for < should be used in math in PG problems to help diff --git a/conf/pg_config.dist.yml b/conf/pg_config.dist.yml index 4335415b49..5224755077 100644 --- a/conf/pg_config.dist.yml +++ b/conf/pg_config.dist.yml @@ -42,7 +42,6 @@ directories: - . - $pg_root/macros - $pg_root/macros/answers - - $pg_root/macros/capa - $pg_root/macros/contexts - $pg_root/macros/core - $pg_root/macros/graph @@ -145,12 +144,6 @@ specialPGEnvironmentVars: #Rserve: # host: localhost - # Locations of CAPA resources. (Only necessary if you need to use converted CAPA problems.) - CAPA_Tools: $Contrib_dir/CAPA/macros/CAPA_Tools/ - CAPA_MCTools: $Contrib_dir/Contrib/CAPA/macros/CAPA_MCTools/ - CAPA_GraphicsDirectory: $Contrib_dir/Contrib/CAPA/CAPA_Graphics/ - CAPA_Graphics_URL: $pg_root_url/CAPA_Graphics/ - # Answer evaluatior defaults ansEvalDefaults: functAbsTolDefault: 0.001 diff --git a/lib/PGloadfiles.pm b/lib/PGloadfiles.pm index 65f4932d5b..9af41b7bde 100644 --- a/lib/PGloadfiles.pm +++ b/lib/PGloadfiles.pm @@ -135,7 +135,7 @@ sub loadMacros { } my $macro_file_name = $fileName; $macro_file_name =~ s/\.pl//; # trim off the extension - $macro_file_name =~ s/\.pg//; # sometimes the extension is .pg (e.g. CAPA files) + $macro_file_name =~ s/\.pg//; # sometimes the extension is .pg my $init_subroutine_name = "_${macro_file_name}_init"; $init_subroutine_name =~ s![^a-zA-Z0-9_]!_!g; # remove dangerous chars diff --git a/lib/WeBWorK/PG/IO.pm b/lib/WeBWorK/PG/IO.pm index e1134b1f9a..6e944db2ff 100644 --- a/lib/WeBWorK/PG/IO.pm +++ b/lib/WeBWorK/PG/IO.pm @@ -38,9 +38,8 @@ our $pg_envir; =head2 includePGtext -This is used in processing some of the sample CAPA files and in creating aliases -to redirect calls to duplicate problems so that they go to the original problem -instead. It is called by includePGproblem. +This is used in creating aliases to redirect calls to duplicate problems so that +they go to the original problem instead. It is called by includePGproblem. Usage: C @@ -77,9 +76,8 @@ Read the contents of a pg file. Usage: C Don't use for huge files. The file name will have .pg appended to it if it -doesn't already end in .pg. This is used in importing additional .pg files as -is done in the sample problems translated from CAPA. Returns a reference to a -string containing the contents of the file. +doesn't already end in .pg. This is used in importing additional .pg files. +Returns a reference to a string containing the contents of the file. =cut diff --git a/macros/README.md b/macros/README.md index e9211e5cc0..692d678835 100644 --- a/macros/README.md +++ b/macros/README.md @@ -3,7 +3,6 @@ This directory now has a subdirectory structure for clarification. - **answers** answer and evaluator macros -- **capa** any CAPA related macros - **contexts** context related macros - **core** macros related to core PG functionality - **deprecated** macros that have been labelled deprecated @@ -178,7 +177,7 @@ This directory now has a subdirectory structure for clarification. ## Macros fixed - `math/algebraMacros.pl` (removed all code, already in `customizeLaTeX.pl`) -- `parsers/parserUtils.pl` (removed loadMacros call due to errors. ) +- `parsers/parserUtils.pl` (removed loadMacros call due to errors.) - `contexts/contextFiniteSolutionSets.pl` (fixed warnings) - `contexts/contextLimitedRadicalComplex.pl` (fixed warnings) - `contexts/contextRationalExponent.pl` (fixed warnings) diff --git a/macros/capa/PG_CAPAmacros.pl b/macros/capa/PG_CAPAmacros.pl deleted file mode 100644 index f279fe5d1a..0000000000 --- a/macros/capa/PG_CAPAmacros.pl +++ /dev/null @@ -1,208 +0,0 @@ - -BEGIN { strict->import; } - -sub CAPA_ans { - my $ans = shift; - my %options = @_; - my $answer_evaluator = 0; - - #TEXT("answerCounter =". ++$problemCounter,"$BR"); # checking whether values are reinitialized - - # explicitlty delete options which are meaningless to WeBWorK - if (defined($options{'sig'})) { delete($options{'sig'}); } - if (defined($options{'wgt'})) { delete($options{'wgt'}); } - if (defined($options{'tries'})) { delete($options{'tries'}); } - - # $options{'allow_unknown_options'} = 1; ## if uncommented, this is a fast and possibly dangerous - ## way to prevent warning message about unknown options - - if (defined($options{'reltol'}) or defined($options{'tol'}) or defined($options{'unit'})) { - - if (defined($options{'unit'})) { - #$ans = "$ans $options{'unit'}"; - $answer_evaluator = num_cmp( - $ans, - 'format' => $options{format}, - reltol => (defined($options{reltol})) ? $options{reltol} : undef, - tol => (defined($options{tol})) ? $options{tol} : undef, - unit => $options{unit}, - ); - } else { # numerical compare: - if (defined($options{'reltol'})) { #relative tolerance is given with a percent sign - my $reltol = $options{'reltol'}; - my $format = $options{'format'} if defined($options{'format'}); - $answer_evaluator = num_cmp($ans, reltol => $reltol, 'format' => $format); - } elsif (defined($options{'tol'})) { - my $format = $options{'format'} if defined($options{'format'}); - $answer_evaluator = num_cmp($ans, tol => $options{'tol'}, 'format' => $format); - } else { - my $tol = $ans * $main::numRelPercentTolDefault; - my $format = $options{'format'} if defined($options{'format'}); - $answer_evaluator = num_cmp($ans, reltol => $tol, 'format' => $format); - } - } - } else { - # string comparisons - if (defined($options{'str'}) and $options{'str'} =~ /CS/i) { - $answer_evaluator = str_cmp($ans, filters => ['compress_whitespace']); - } elsif (defined($options{'str'}) and $options{'str'} =~ /MC/i) { - $answer_evaluator = str_cmp($ans, filters => [qw( compress_whitespace ignore_case ignore_order )]); - } else { - $answer_evaluator = str_cmp($ans, filters => [qw( compress_whitespace ignore_case )]); - } - } - - $answer_evaluator; -} - -sub CAPA_import { - my $filePath = shift; - my %save_envir = %main::envir; - my $r_string = read_whole_problem_file($filePath); - - $main::envir{'probFileName'} = $filePath; - includePGtext($r_string); - %main::envir = %save_envir; -} - -sub CAPA_map { - my $seed = shift; - my $array_var_ref = shift; - my $PGrand = new PGrandom($seed); - local $main::array_values_ref = shift; # this must be local since it must be passed to PG_restricted_eval - my $size = @$main::array_values_ref; # get number of values - my @array = 0 .. ($size - 1); - my @slice = (); - while (@slice < $size) { - push(@slice, splice(@array, $PGrand->random(0, $#array), 1)); - } - my $string = ""; - my $var; - my $i = 0; - foreach $var (@$array_var_ref) { - $string .= "\$$var = \$\$main::array_values_ref[ $slice[$i++]]; "; - } - - # it is important that PG-restriced eval can accesss the $array_values_ref - my ($val, $PG_eval_errors, $PG_full_error_report) = PG_restricted_eval($string); - my $out = ''; - $string =~ s/\$/\\\$/g; # protect variables for error message - $out = "Error in MAP subroutine: $PG_eval_errors
\n" . $string . "
\n" if $PG_eval_errors; - $out; -} - -sub compare_units { - -} - -sub CAPA_hint { - my $hint = shift; - TEXT(hint(qq{ HINT: $hint $main::BR})); -} - -sub CAPA_explanation { - TEXT(solution(qq{ $main::BR$main::BR EXPLANATION: @_ $main::BR$main::BR})) if solution(@_); -} - -sub pow { - my ($base, $exponent) = @_; - $base**$exponent; -} - -sub CAPA_tex { - my $tex = shift; - # $tex =~ s|/*|\$|g; - #$tex =~ s/\\/\\\\/g; #protect backslashes??? - my $nontex = shift; - &M3($tex, $nontex, $nontex); -} - -sub CAPA_web { - my $text = shift; - my $tex = shift; - my $html = shift; - &M3($tex, "\\begin{rawhtml}$html\\end{rawhtml}", $html); -} - -sub CAPA_html { - my $html = shift; - &M3("", "\\begin{rawhtml}$html\\end{rawhtml}", $html); -} - -sub var_in_tex { - my ($tex) = $_[0]; - &M3("$tex", "$tex", ""); -} - -sub isNumberQ { # determine whether the input is a number - my $in = shift; - $in =~ /^[\d\.\+\-Ee]+$/; -} - -sub choose { - # my($in)=join(" ",@_); - my ($var) = $_[0]; - $_[$var]; -} - -sub problem { - $main::probNum; -} - -sub pin { - $main::psvn; -} - -sub section { - $main::sectionNumber; -} - -sub name { - $main::studentName; -} - -sub set { - $main::setNumber; -} - -sub question { - $main::probNum; -} - -sub due_date { - $main::formattedDueDate; -} - -sub answer_date { - $main::formattedAnswerDate; -} - -sub open_date { - $main::formattedOpenDate; -} - -sub to_string { - $_[0]; -} - -sub CAPA_EV { - - my $out = &EV3(@_); - $out =~ s/\n\n/\n/g; # hack to prevent introduction of paragraphs in TeX?? - # HACK TO DO THE RIGHT THING WITH DOLLAR SIGNS - $out = ev_substring($out, "/*/*", "/*/*", \&display_math_ev3); - $out = ev_substring($out, "/*", "/*", \&math_ev3); - # TEXT($main::BR, $main::BR, $out,$main::BR,$main::BR); - $out; -} - -# these are very commonly needed files -CAPA_import("${main::CAPA_Tools}StdMacros"); -CAPA_import("${main::CAPA_Tools}StdUnits"); -CAPA_import("${main::CAPA_Tools}StdConst"); -##################### - -$main::prob_val = ""; # gets rid of spurious errors. -$main::prob_try = ""; - -1; diff --git a/macros/capa/StdConst.pg b/macros/capa/StdConst.pg deleted file mode 100644 index f19fdae6e1..0000000000 --- a/macros/capa/StdConst.pg +++ /dev/null @@ -1,36 +0,0 @@ - -## -## macros for Fundamental Constants, in SI units! -## -## Gravitational constant CapG: Units-> m3/kgs2 or Nm2/kg2 -$CapG = 6.67e-11 ; -## -## Speed of light in m/s: -$smallc = 2.99792458e+8 ; -## -## Electron charge in C: -$smalle = 1.602177e-19 ; -## -## Planck constant, smallh: Units ->Js -$smallh = 6.626075e-34 ; -## -## Boltzmann constant, smallk: Units ->J/K -$smallk = 1.38066e-23 ; -## -## standardgrav. accel sea level, smallg: Units ->m/s2 -$smallg = 9.8 ; - -## -## Pi: -$pi = 3.1415926536 ; -## -## From degrees to radians: -$degrad = $pi / 180.0 ; -## -## From radians to degrees: -$raddeg = 180.0 / $pi ; - -1; -################################################# -## Processing time = 2 secs ( 1.96 usr 0.41 sys = 2.38 cpu) -################################################# diff --git a/macros/capa/StdUnits.pg b/macros/capa/StdUnits.pg deleted file mode 100644 index 80238f24d5..0000000000 --- a/macros/capa/StdUnits.pg +++ /dev/null @@ -1,79 +0,0 @@ - -## Define some macros for the units: -## Note: P means per in this notation, except for Pa =Pascal) -## u is the unit indication -## -$m_u = CAPA_tex( "/*m/*" , "m" ) ; # angle degree -$km_u = CAPA_tex( "/*km/*" , "km" ) ; -$cm_u = CAPA_tex( "/*cm/*" , "cm" ) ; -$mm_u = CAPA_tex( "/*mm/*" , "mm" ) ; -$um_u = CAPA_tex( "/*\micro m/*" , "um" ) ; -$nm_u = CAPA_tex( "/*nm/*" , "nm" ) ; -$fm_u = CAPA_tex( "/*fm/*" , "fm" ) ; -$m2_u = CAPA_tex( "/*m^2/*" , "m^2" ) ; -$m3_u = CAPA_tex( "/*m^3/*" , "m^3" ) ; -$cm2_u = CAPA_tex( "/*cm^2/*" , "cm^2" ) ; -$cm3_u = CAPA_tex( "/*cm^3/*" , "cm^3" ) ; -$mi_u = CAPA_tex( "/*mi/*" , "mi" ) ; -$ft_u = CAPA_tex( "/*ft/*" , "ft" ) ; -$in_u = CAPA_tex( "/*in./*" , "in." ) ; -$kg_u = CAPA_tex( "/*kg/*" , "kg" ) ; -$amu_u = CAPA_tex( "/*u/*" , "u" ) ; -$lb_u = CAPA_tex( "/*lb/*" , "lb" ) ; -$s_u = CAPA_tex( "/*s/*" , "s" ) ; -$min_u = CAPA_tex( "/*min/*" , "min" ) ; -$K_u = CAPA_tex( "/*K/*" , "K" ) ; -$degC_u = CAPA_tex( "/*^{\circ}\hspace*{-.015in}C/*" , "degC" ) ; -$degF_unit = CAPA_tex( "/*^{\circ}\hspace*{-.025in}F/*" , "degF" ) ; -$kmol_u = CAPA_tex( "/*kmol/*" , "kmol" ) ; -$Hz_u = CAPA_tex( "/*Hz/*" , "Hz" ) ; -$mPs_u = CAPA_tex( "/*m/s/*" , "m/s" ) ; -$cmPs_u = CAPA_tex( "/*cm/s/*" , "cm/s" ) ; -$kmPh_u = CAPA_tex( "/*km/h/*" , "km/h" ) ; -$miPh_u = CAPA_tex( "/*mi/h/*" , "mi/h" ) ; -$radPs_u = CAPA_tex( "/*rad/s/*" , "rad/s" ) ; -$Ps_u = CAPA_tex( "/*s^{-1}/*" , "s^-1" ) ; -$mPs2_u = CAPA_tex( "/*m/s^2/*" , "m/s2" ) ; -$cmPs2_u = CAPA_tex( "/*cm/s^2/*" , "cm/s2" ) ; -$radPs2_u = CAPA_tex( "/*rad/s^2/*" , "rad/s2" ) ; -$N_unit = CAPA_tex( "/*N/*" , "N" ) ; -$Pa_u = CAPA_tex( "/*Pa/*" , "Pa" ) ; -$atm_u = CAPA_tex( "/*atm/*" , "atm" ) ; -$NPm2_u = CAPA_tex( "/*N/m^2/*" , "N/m2" ) ; -$J_u = CAPA_tex( "/*J/*" , "J" ) ; -$hp_u = CAPA_tex( "/*hp/*" , "hp" ) ; -$eV_u = CAPA_tex( "/*eV/*" , "eV" ) ; -$cal_u = CAPA_tex( "/*cal/*" , "cal" ) ; -$kcal_u = CAPA_tex( "/*kcal/*" , "kcal" ) ; -$W_u = CAPA_tex( "/*W/*" , "W" ) ; -$kW_u = CAPA_tex( "/*kW/*" , "kW" ) ; -$Js_u = CAPA_tex( "/*J s/*" , "J s" ) ; -$C_u = CAPA_tex( "/*C/*" , "C" ) ; -$V_u = CAPA_tex( "/*V/*" , "V" ) ; -$ohm_u = CAPA_tex( "/*\Omega/*" , "ohm" ) ; -$F_u = CAPA_tex( "/*F/*" , "F" ) ; -$Wb_u = CAPA_tex( "/*Wb/*" , "Wb" ) ; -$H_u = CAPA_tex( "/*H/*" , "H" ) ; -$T_u = CAPA_tex( "/*T/*" , "T" ) ; -$N_u = CAPA_tex( "/*N/*" , "N" ) ; -$JPK_u = CAPA_tex( "/*J\over K/*" , "J/K" ) ; -$Nm2Pkg2_u = CAPA_tex( "/*Nm2\over kg^2/*" , "Nm^2/kg^2" ) ; -$kgPm3_u = CAPA_tex( "/*kg / m^3/*" , "kg/m3" ) ; -$gPm3_u = CAPA_tex( "/*g / m^3/*" , "g/m3" ) ; -$gPcm3_u = CAPA_tex( "/*g / cm^3/*" , "g/cm3" ) ; -$NPm_u = CAPA_tex( "/*N/m/*" , "N/m" ) ; -$kgm2_u = CAPA_tex( "/*kg\cdot m^2/*" , "kgm^2" ) ; -$deg_u = CAPA_tex( "/*^{\circ}/*" , "deg" ) ; -$rev_u = CAPA_tex( "/*rev/*" , "rev" ) ; -$rad_u = CAPA_tex( "/*rad/*" , "rad" ) ; -$G_u = CAPA_tex( "/*G/*" , "G" ) ; -$g_u = CAPA_tex( "/*g/*" , "g" ) ; -$h_u = CAPA_tex( "/*h/*" , "h" ) ; -$ton_u = CAPA_tex( "/*ton/*" , "ton" ) ; -$knots_u = CAPA_tex( "/*knots/*" , "knots" ) ; -$kgPs_u = CAPA_tex( "/*kg/s/*" , "kg/s" ) ; - -1; -################################################# -## Processing time = 5 secs ( 4.60 usr 0.37 sys = 4.97 cpu) -################################################# diff --git a/t/macros/load_macros.t b/t/macros/load_macros.t index 59d37ed799..c8ab7e6575 100644 --- a/t/macros/load_macros.t +++ b/t/macros/load_macros.t @@ -33,8 +33,7 @@ my %baseMacros = ( 'PGcommonFunctions.pl' => 1 ); -# PG_CAPAmacros.pl is not really broken, but it depends on files that are in the OPL and not in the PG repository. -my %brokenMacros = ('answerDiscussion.pl' => 1, 'PG_CAPAmacros.pl' => 1); +my %brokenMacros = ('answerDiscussion.pl' => 1); # Find all macro files inside the $ENV{PG_ROOT}/macros directory. my @macro_files;