WeBWorK Problems

Error: Undefined subroutine &main::negate

Error: Undefined subroutine &main::negate

by Hieu Nguyen -
Number of replies: 3
I received the error message below when viewing one of the problems (Library/SDSU/Discrete/Logic/ttlogicequivA7.pg) from the OPL. Not sure if this has anything to do with it, but we just installed Webwork on our school's server (CentOS 7). I'm able to view it fine on the MAA server, but not on our school server.

Appreciate any help with resolving this issue.

--Hieu

WeBWorK Error

WeBWorK has encountered a software error while attempting to process this problem. It is likely that there is an error in the problem itself. If you are a student, report this error message to your professor to have it corrected. If you are a professor, please consult the error output below for more information.

Error messages

ERRORS from evaluating PG file:
Undefined subroutine &main::negate called at line 51 of (eval 1405)

Error details

 Problem13 1. ERROR caught by Translator while processing problem file:Library/SDSU/Discrete/Logic/ttlogicequivA7.pg **************** ERRORS from evaluating PG file:
 Undefined subroutine &main::negate called at line 51 of (eval 1405)
 ****************
 ------Input Read 1 # DESCRIPTION 2 # Using a truth table to detemine the 3 # equivalence of two logical statements 4 # WeBWorK problem written by Michael E. O'Sullivan 5 # and Thomas Schmidt 6 # ENDDESCRIPTION 7 8 ## DBsubject(Set theory and logic) 9 ## DBchapter(Propositional logic) 10 ## DBsection(Truth tables) 11 ## Institution(SDSU) 12 ## Author(Thomas Schmidt','Michael E. O'Sullivan) 13 ## MLT(TruthTableOnly) 14 ## MLTleader(1) 15 ## Level(2) 16 ## Static(1) 17 ## MO(1) 18 ## KEYWORDS('truth table') 19 20 21 ############################ 22 # Initialization 23 24 DOCUMENT(); 25 26 loadMacros( 27 "PGstandard.pl", 28 "MathObjects.pl", 29 "logicMacros.pl", 30 "niceTables.pl" 31 ); 32 33 TEXT(beginproblem()); 34 35 ############################ 36 # Setup 37 38 $showPartialCorrectAnswers = 0; 39 40 @answer = qw(F F F T F 41 F T T F F 42 T F F T F 43 T T F T F); 44 Context()->strings->add(T=>{},F=>{}); 45 46 @fullsol = qw(T T F F F T F 47 T F F T T F F 48 F T T F F T F 49 F F T T F T F); 50 51 $headrow = ["\(p\)","\(q\)", "\(".negate()." p\)", "\(".negate()." q\)","\(p\wedge".negate()." q\)","\(".negate()." p\vee q\)","\((p\wedge".negate()." q)\wedge (".negate()." p\vee q)\)"]; 52 53 54 ############################ 55 # Main Text 56 57 Context()->texStrings; 58 BEGIN_TEXT 59 Complete the truth table for the following statement: $PAR 60 $BCENTER 61 \((p\wedge\{ negate()\} q)\wedge(\{ negate()\} p\vee q)\) 62 $BR 63 $BR 64 \{ 65 DataTable( 66 [ 67 $headrow, 68 ["T","T",ans_rule(1),ans_rule(1),ans_rule(1),ans_rule(1),ans_rule(1)], 69 ["T","F",ans_rule(1),ans_rule(1),ans_rule(1),ans_rule(1),ans_rule(1)], 70 ["F","T",ans_rule(1),ans_rule(1),ans_rule(1),ans_rule(1),ans_rule(1)], 71 ["F","F",ans_rule(1),ans_rule(1),ans_rule(1),ans_rule(1),ans_rule(1)] 72 ] 73 ); 74 \} 75 $ECENTER 76 END_TEXT 77 Context()->normalStrings; 78 79 ############################ 80 # Answer Evaluation 81 foreach my $i (@answer) { 82 ANS(String($i)->cmp()); 83 } 84 85 86 ############################ 87 # Solution 88 89 Context()->texStrings; 90 SOLUTION(EV3(<<'END_SOLUTION')); 91 $PAR Solution: $PAR 92 The correct truth table is as follows: $PAR 93 \{ 94 DataTable( 95 [ 96 $headrow, 97 [$fullsol[0],$fullsol[1],$fullsol[2],$fullsol[3],$fullsol[4],$fullsol[5],$fullsol[6]], 98 [$fullsol[7],$fullsol[8],$fullsol[9],$fullsol[10],$fullsol[11],$fullsol[12],$fullsol[13]], 99 [$fullsol[14],$fullsol[15],$fullsol[16],$fullsol[17],$fullsol[18],$fullsol[19],$fullsol[20]], 100 [$fullsol[21],$fullsol[22],$fullsol[23],$fullsol[24],$fullsol[25],$fullsol[26],$fullsol[27]] 101 ] 102 ); 103 \} $PAR 104 END_SOLUTION 105 Context()->normalStrings; 106 107 COMMENT("Logical symbols defined in logicMacros.pl are used in this problem. They can be overwritten by placing a copy of logicMacros.pl in the course directory and modifying the subroutines in that file."); 108 ENDDOCUMENT(); -----
In reply to Hieu Nguyen

Re: Error: Undefined subroutine &main::negate

by Andy Fuchs -
Hello Hieu,

We had this problem, too.

In a quick fix, you'd need to copy the file 'logicMacros.pl' (in the OPL: Library/macros/UniSiegen/logicMacros.pl) to the macros subdirectory (under templates) in your course. More generally, you'll need to add the UniSiegen macros to the search path; the pattern for this is in the distributed configuration, 'defaults.config', and you do this by adding the following line to the system configuration in 'localOverrides.conf':

$pg{directories}{macrosPath} = [
@{$pg{directories}{macrosPath}},
"$courseDirs{templates}/Library/macros/UniSiegen"
];

Hope this helps,

Andy

In reply to Andy Fuchs

Re: Error: Undefined subroutine &main::negate

by F. Heiderich -
The workarounds were already mentioned. The necessary changes were introduced in the master branch of webwork2 in

https://github.com/openwebwork/webwork2/commit/80e23f60e08c96cfc8a597673842c73991d3797f

There is a pull request to the develop branch:

https://github.com/openwebwork/webwork2/pull/803

Could someone please review it?

Let me also note that these macros allow you to customize the symbol for negation by changing the copy of logicMacros.pl in the macros folder of your courses without having to edit every single problem.

I am planing more customization options. See also the following pull request:

https://github.com/openwebwork/webwork-open-problem-library/pull/338
In reply to Andy Fuchs

Re: Error: Undefined subroutine &main::negate

by Hieu Nguyen -
Hi Andy,

The quick fix worked. Thank you!

Will try to add the UniSiegen macros to the search path.

--Hieu