WeBWorK Main Forum

Adding $ in tables, popup menues, and entered answers.

Adding $ in tables, popup menues, and entered answers.

by Mike May -
Number of replies: 5
We are trying to WeBWorK some problems for a course that uses Excel.

I need to deal with answers that look like B$2 for absolute references.
I can do this in the main text. However in tables, popup menus, and entered answers, I cannot make it work.

Any suggestions?


In reply to Mike May

Re: Adding $ in tables, popup menues, and entered answers.

by Danny Glin -
Are you using the $DOLLAR macro? That was intended to work in all contexts. I would expect it to work in tables and popup menus. If it doesn't, then that should probably be reported as a bug.

Using dollar signs in entered answers could be a bigger problem, since there's a good chance that the code does special things with that symbol to prevent interpolating variable names within student answers. It may be possible to add it to the context as a variable, though if you are using a string context I would expect that it would leave it alone. Do you have a sample answer checker to show what you've been trying?
In reply to Danny Glin

Re: Adding $ in tables, popup menues, and entered answers.

by Mike May -
A code snippet is useful.

Start with the spreadsheet section below
$BR
\{
begintable(9) .
row( " ","A", "B", "C", "D", "E","F", "G" ) .
row("1", "1" , "6", "11", "16", "", "", '') .
row("2", "2" , "7", "12", "17", B2, "", $popup1->menu()) .
row("3", "3" , "8", "13", "18", "=B$2", "", $popup2->menu()) .
row("4", "4" , "9", "14", "19", "=$B2", "", $popup3->menu()) .
row("5", "5" , "10", "15", "20", "=$B$2", "", $popup4->menu()) .
endtable();
\}

I use "=B$2" where I want to actually see =B$2, since that will be an Excel entry.
I have tried "B".$DOLLAR."2" and "B$DOLLAR2". Neither work.


In reply to Mike May

Re: Adding $ in tables, popup menues, and entered answers.

by Danny Glin -
I feel obligated to include a plug for niceTables, since the begintable/endtable construction is dated, and niceTables.pl has dedicated much more thought and effort to accessibility considerations. See the info at http://webwork.maa.org/wiki/Tables.

The syntax you're looking for is "B${DOLLAR}2". $DOLLAR2 reads the 2 as part of the variable name. "B$DOLLAR 2" would work, but would include a space after the dollar sign, which you don't want. Encapsulating a variable name in braces allows you to put another character immediately adjacent to the variable.
In reply to Danny Glin

Re: Adding $ in tables, popup menues, and entered answers.

by Michael Gage -
Another thing to try is 'B$2' (note single quotes). Things inside single quotes
don't interpolate variables. Also ~~ (tilde tilde) is the escape sequence pg (instead of \ ) so ~~$ might solve some problems where you want a literal dollar sign. $DOLLAR or ${DOLLAR} is probably preferable most of the time.


In reply to Michael Gage

Re: Adding $ in tables, popup menues, and entered answers.

by Mike May -
Thanks. Between the two replies I have it working in that problem.