WeBWorK Problems

numbers with commas every third place

numbers with commas every third place

by Alex Jordan -
Number of replies: 2
I'm working on expanding WeBWorK interest outside of the math department, and in doing so, an instructor has asked for answers to accept commas in every third place.

I copied the example that is here for allow these kind of commas, but I'm having an issue. The problem times out and suggests I've gone into an infinite loop. If I comment out the Context()->update command, then the problem loads (but of course it doesn't recognize commas appropriately). I don't know if I'm timing out during the Context()->update call or as a consequence of something later after the update.

Is there a problem with this example that I copied? Am I having a problem because I am using this in conjunction with a the more complicated Inequalities-Only context?

The file is attached and any help is appreciated.
In reply to Alex Jordan

Re: numbers with commas every third place

by Davide Cervone -
Your example file doesn't include the code that you used to handle numbers with commas, so it is hard to tell what might be wrong.

Since the code you refer to uses ragex patterns, you have to be a little careful of the backslashes. That's because WeBWorK double all backslashes (because it wants you to be able to type TeX notation without doubling them yourself). But this causes patterns that use them to not work properly. Instead, you need to replace al the backslahses in the patterns by double tildes (~~), as WeBWorK translates these to a single backslash (awkward, but works).

So try replacing the backslashes in the pattern with ~~ and see fi that works. If not, can you post the pg file that actually includes the code you are using for this? Thanks.

Davide
In reply to Davide Cervone

Re: numbers with commas every third place

by Alex Jordan -
Sorry about that - I intended to post a version with the code for the commas, but I grabbed the wrong one. I tried replacing all of those backslashes to double tildes but the song remains the same. In this version, I've commented out some local macros,commands that rely on them, and also commented out the Context()->update; command. Bringing Context()->update back is what causes the timeout. This is happening on webwork 2.7 and PG 2.7.