Forum archive 2000-2006

Stephen Corwin - truth tables in WebWorK

Stephen Corwin - truth tables in WebWorK

by Arnold Pizer -
Number of replies: 0
inactiveTopictruth tables in WebWorK topic started 8/26/2002; 8:37:29 AM
last post 8/29/2002; 3:45:44 AM
userStephen Corwin - truth tables in WebWorK  blueArrow
8/26/2002; 8:37:29 AM (reads: 1587, responses: 4)
Hi, All--

Has anyone managed to make decent truth-table questions in WK? I'd like, if possible, an actual table, like this:

p | q | pto q ------------


T | T | ???? ------------


T | F | ???? ------------


F | T | ???? ------------


F | F | ????

where the ???? is replaced either by ans_rules or, even better, HTML choose-lists.

If you know a solution, please email it to me at scorwin@radford.edu.

Thanks in advance,

Steve

<| Post or View Comments |>


userStephen Corwin - Re: truth tables in WebWorK  blueArrow
8/26/2002; 9:30:32 AM (reads: 1800, responses: 1)
Hi again--

Okay, I found the begintable() sub, and I got the solution below, but it prints a column of zeros before printing the table. Anyone know why, and what to do about it?

Thanks,

Steve =============================================

# initialize
DOCUMENT();



loadMacros(PG.pl,
PGbasicmacros.pl,
PGchoicemacros.pl,
PGanswermacros.pl,
PGauxiliaryFunctions.pl,
PGgraphmacros.pl);



# Do NOT show partial correct answers
$showPartialCorrectAnswers = 0;



TEXT(beginproblem());



BEGIN_TEXT
$PAR
Complete the following truth table.$BR
\{begintable(3)\}
\{row("\\(p\\)","\\(q\\)","\\(p\\to q\\)")\}
\{row("\\(T\\)","\\(T\\)",ans_rule(1))\}
\{ANS(str_cmp("T"));\}
\{row("\\(T\\)","\\(F\\)",ans_rule(1))\}
\{ANS(str_cmp("F"));\}
\{row("\\(F\\)","\\(T\\)",ans_rule(1))\}
\{ANS(str_cmp("T"));\}
\{row("\\(F\\)","\\(F\\)",ans_rule(1))\}
\{ANS(str_cmp("T"));\}



\{endtable\}
$PAR
END_TEXT



ENDDOCUMENT();

<| Post or View Comments |>


userMichael Gage - Re: truth tables in WebWorK  blueArrow
8/27/2002; 2:19:39 AM (reads: 2015, responses: 0)
Hi Steve,

The zero's are coming from the lines \{ANS(str_cmp("T"));\}. (This becomes clearer if you look directly at the source of the HTML -- one of many tricks for trouble shooting these problems.)

You can fix this in at least two ways:

Use \{ANS(str_cmp("T"));""; \}

The output from the second statement, which is an empty string, is the result of the evaluation instead of the 0, which is the result of the ANS function.

Alternatively you can simply collect the ANS() statements and execute them outside of the BEGIN_TEXT/END_TEXT block. (They need to be executed in the same order as the ans_rule statement, but not necessarily immediately after the ans_rule is printed.)

ANS wasn't originally originally conceived as being executed within TEXT blocks. It's possible that we could correct this "bug/feature" in ANS by insuring that it's output is always an empty string. I'll have to look into the ramifications of that.

Thanks for the alert about this "bug/feature".

--Mike

<| Post or View Comments |>


userArnold K. Pizer - Re: truth tables in WebWorK  blueArrow
8/27/2002; 2:24:20 AM (reads: 1780, responses: 0)
You might want to contact Andrew Wildenberg <awilden@cs.sunysb.edu>. Andy is no longer at Stony Brook (and he might be in Australia this semester) but hopefully email to the above address is being forwarded. You could also contact Christelle Scharff at Pace, CScharff@fsmail.pace.edu. Andy and Christelle developed Oliver, a web based interactive system for teaching propositional logic, and integrating it with WeBWorK. They used this (and other WeBWorK problems) in a finite math CS course at Stony Brook. Some of thier problems are in the CVS repository at http://webwork-db.math.rochester.edu/cgi-bin/cvsweb.cgi/ (look for Stony Brook under the CVS root).

Arnie

<| Post or View Comments |>


userStephen Corwin - Re: truth tables in WebWorK  blueArrow
8/29/2002; 3:45:44 AM (reads: 1826, responses: 0)
Thanks, everyone; that worked. I'm still a newbie, and I really appreciate the help.

--Steve

<| Post or View Comments |>