Hi,

> On Dec 4, 2015, at 11:58 AM, Jacob Bond <bon...@purdue.edu> wrote:
> 
> I have a stylistic question about preprocessing versus custom response.  An 
> example of the particular situation is that I have a question whose answer is 
> a rational number, say 5/2.  I would like either 5/2 or 2.5 to be accepted, 
> but only these two answers.  I don't want 10/4 or 2.50 to be accepted.  My 
> current approach (based on the discouragement of custom response problems 
> from the manual because they can't be statistically analyzed) is to use a 
> string response with answer 5/2 and a preprocessor that does the following:
> 
> if ($response eq 2.5) {return 5/2;}
> else {return $response;}


Needs quotation marks, return ‘5/2’;

Also, there are different comparisons

$response==2.5 would do (exact within floating point limitations) numerical 
equality, $response eq ‘2.5’ would do string comparison.

> 
> Is this considered bad form?  Should I be using a custom response instead?  
> Is there another approach that would be better?

This really depends on what you want to do exactly.

Will you accept

2.50
5 / 2
5.0/2.0
5*1/2
25E-1
?

Student might get *very* frustrated if the problem does not recognize correct 
answers as correct!

If this is really a static answer format, then it should indeed be a 
stringresponse. Note that stringresponses also take regular expressions, so you 
can do

/(2\.5)|(5\/2)/

to do “or” - you don’t need a preprocessor. LON-CAPA also has an explicit “or”, 
I think there’s a template for it. It may be “or” for numerical, but you can 
replace numerical by string.

In general, for things that are numerical (and not “static” like the above), 
the main decision criterion for preprocessor versus customresponse is whether 
you need the luxuries of numericalresponse:

* significant digits
* tolerances
* automated bubblesheet production
* easy printout of correct solution after answer date

If you can benefit from those luxuries, use numericalresponse and preprocessor. 
If not, or if those things are in the way, use customresponse.

Sorry, I need to run for a meeting. Hope this helps,

- Gerd.

_______________________________________________
LON-CAPA-users mailing list
LON-CAPA-users@mail.lon-capa.org
http://mail.lon-capa.org/mailman/listinfo/lon-capa-users

Reply via email to