Forum archive 2000-2006

Jun Wang - Multiple answers in str_com()?

Jun Wang - Multiple answers in str_com()?

by Arnold Pizer -
Number of replies: 0
inactiveTopicMultiple answers in str_com()? topic started 6/2/2003; 3:19:07 PM
last post 6/4/2003; 1:09:53 PM
userJun Wang - Multiple answers in str_com()?  blueArrow
6/2/2003; 3:19:07 PM (reads: 2043, responses: 11)
Hi, I am teaching history of mathematics in the summer and trying to use WeBWorK for it. In writing the problems involving string answers, I find that often I need to give more than one correct answer. For example, if I ask students the fill-in blank and complete sentence question: "Although Babylonians used a place-value system, they never had a symbol to represent -----", the answers could be "zero", "0", "nothing", or "nothingness". Is there a way to give multiple correct answers in str_cmp()?

Thanks.

Jun

<| Post or View Comments |>


userJohn Jones - Re: Multiple answers in str_com()?  blueArrow
6/2/2003; 3:37:09 PM (reads: 2245, responses: 0)
Hi,

One possibility would be to include PGasu.pl at the top and then use

ANS( pc_evaluator([str_cmp("zero"), 1], [str_cmp("0"), 1], [str_cmp("nothing"), 1], [str_cmp("nothingness"), 1], [str_cmp("zilch"), 0.5]) );

I haven't actually tested the line above, but I think it is right. It should also give 1/2 credit if the student answers zilch.

John

<| Post or View Comments |>


userJun Wang - Re: Multiple answers in str_com()?  blueArrow
6/2/2003; 4:37:07 PM (reads: 2233, responses: 0)
Thank you, John,

I tried the above code and it gave the following compiling errors:

"Compiler warnings: * Error in PGtranslator.pm::process_answers: Answer AnSwEr1: Not an ARRAY reference at (eval 126) line 275. ##More details: --------Error in PGtranslator.pm::process_answers: Answer AnSwEr1:

---- PGtranslator::process_answers called at processProblem8.pl line 532

-----------------------------------


* Error in PGtranslator.pm::process_answers: Answer AnSwEr1: Answer evaluators must return a hash or an AnswerEvaluator type, not type || at /usr/local/webwork/system/lib//PGtranslator.pm line 931. "

I will update PGasu.pl from your CVS and try it again. Thanks.

Jun

<| Post or View Comments |>


userJun Wang - Re: Multiple answers in str_com()?  blueArrow
6/2/2003; 4:51:06 PM (reads: 2219, responses: 0)
John, I downloaded a copy of PGasu.pl from the CVS and put it in our courseScripts directory. However, this time our system gives some conflicting errors saying:

"Error detected while loading /usr/local/webwork/system/courseScripts/PGbasicmacros.pl: PG_restricted_eval detected error at line 259 of file /usr/local/webwork/system/courseScripts/dangerousMacros.pl Subroutine list_random redefined at /usr/local/webwork/system/courseScripts/PGbasicmacros.pl line 801, line 1. The calling package is PG_priv"

Do I need to update the PGbasicmacros.pl?

Jun

<| Post or View Comments |>


userJohn Jones - Re: Multiple answers in str_com()?  blueArrow
6/2/2003; 6:18:22 PM (reads: 2213, responses: 0)
Hi,

First, you may have the wrong version of PGasu.pl from cvs. You should get the one in system/courseScripts . That one should not have a problem with list_random.

Second, I should probably change it to take the syntax I gave above, but the syntax for using it is really:

ANS( pc_evaluator([[str_cmp("zero"), 1, ''], [str_cmp("0"), 1, ''], [str_cmp("nothing"), 1, ''], [str_cmp("nothingness"), 1, ''], [str_cmp("zilch"), 0.5, 'For full credit, try using a less colloquial word']]) );

The third arguments are comments which can be displayed. There is also an extra set of brackets this time.

John

<| Post or View Comments |>


userJun Wang - Re: Multiple answers in str_com()?  blueArrow
6/2/2003; 6:33:43 PM (reads: 2213, responses: 0)
It works great, John, Thank you so much.

Jun

<| Post or View Comments |>


userJohn Jones - Re: Multiple answers in str_com()?  blueArrow
6/3/2003; 6:11:37 PM (reads: 2240, responses: 0)
I just uploaded a new version of PGasu.pl to system/courseScripts cvs. It will take the syntax I used in the message I was guessing at. The extra brackets are now optional, the comments are optional, and even the degree of partial credit is optional (defaulting to 1 = full credit). So, with that version you could use

ANS( pc_evaluator([str_cmp("zero")], [str_cmp("0")], [str_cmp("nothing")], [str_cmp("nothingness")], [str_cmp("zilch"), 0.5]) );

John

<| Post or View Comments |>


userArnold K. Pizer - Re: Multiple answers in str_com()?  blueArrow
6/4/2003; 10:10:10 AM (reads: 2249, responses: 0)
Hi John,

Thanks, this is very nice. I think it would be good to have an alias for this called or_evaluator or or_method or something with the word "or" in the name. I assume "pc" stands for positive credit which is reasonable since the method "or's" over the possible answers until it finds one with positive credit but I doubt most people would guess what pc_evaluator does from the name.

I think of this as an "or" method. Jun was thinking of it as allowing "multiple" answers. Can someone come up with a name that suggests what the method does?

Arnie

<| Post or View Comments |>


userJohn Jones - Re: Multiple answers in str_com()?  blueArrow
6/4/2003; 12:18:56 PM (reads: 2210, responses: 1)
Hi Arnie,

As I was making modification, I had the same idea. You are right that "pc" is for partial credit (someone here asked for it and then never used it).

Presumably the "or" evaluator could be simpler in its structure, so that

or_evaluator( str_cmp("zero"), str_cmp("nil"), num_cmp(0) )

would just call

pc_evaluator( [str_cmp("zero")], [str_cmp("nil")], [num_cmp(0)] )

I am open to better names than or_evaluator.

John

<| Post or View Comments |>


userMark Schmitt - Re: Multiple answers in str_com()?  blueArrow
6/4/2003; 12:26:12 PM (reads: 2226, responses: 0)
I think multiple_eval([str_cmp("")],etc) would be good.

Also perhaps as a default each answer could be assumed to call the evaluator from the previous answer, unless a new one is supplied. (I haven't looked at the code, I'm just thinking of ways to cut down syntax.):

multiple_eval([str_cmp("zero")],["nil"],["nothing"],[num_cmp(0)])

Mark

<| Post or View Comments |>


userJohn Jones - Re: Multiple answers in str_com()?  blueArrow
6/4/2003; 1:09:53 PM (reads: 2229, responses: 0)
I don't think

multiple_eval([str_cmp("zero")],["nil"],["nothing"],[num_cmp(0)])

is feasible. You probably could have a command which tried all values on the same answer evaluator, like

multiple_eval(~~str_cmp, ["zero","nil","nothing"], optional arguments)

where the square brackets are necessary to separate optional arguments. You would need those in case you wanted to pass extra arguments to the evaluator.

I think

multiple_eval( str_cmp("zero"), str_cmp("nil"), num_cmp(0) )

may be longer, but is more straightforward making it easier for people to remember how to invoke it.

John

<| Post or View Comments |>


userMichael Gage - Re: Multiple answers in str_com()?  blueArrow
6/4/2003; 3:00:08 PM (reads: 2435, responses: 0)
As you are implementing OR and AND evaluators take a look at the embryonic facility for this in AnswerHash.pm. You might well want to extend and/or modify that code in providing these extensions. (To my knowledge the OR and AND methods of AnswerHash have not yet been used. I put them there as hooks to allow later development of the type you seem to be doing. I don't think there will be any problem in modifying those methods to be more appropriate for the task you are working on.) -- Mike

<| Post or View Comments |>