[LON-CAPA-users] (no subject)

2015-12-04 Thread Jacob Bond
Search 'Thanks for the great response' in LON-CAPA-users
___
LON-CAPA-users mailing list
LON-CAPA-users@mail.lon-capa.org
http://mail.lon-capa.org/mailman/listinfo/lon-capa-users


Re: [LON-CAPA-users] Preprocessor vs. Custom Response

2015-12-04 Thread Gerd Kortemeyer
Hi,

> On Dec 4, 2015, at 11:58 AM, Jacob Bond  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


Re: [LON-CAPA-users] Preprocessor vs. Custom Response

2015-12-04 Thread Gerd Kortemeyer
Hi,

> On Dec 4, 2015, at 2:41 PM, Jacob Bond  wrote:
>> 
>> Are you actually looking for the fraction to be reduced? Because we can 
>> check that very generally. 
>> 
> 
> Yes, that is the main idea.

Okay, then I would use Maxima to figure out if the reduced fraction is equal to 
the fraction input by the student, see below.

- Gerd.



$a=&random(20,100,4);
$b=$a+&random(40,140,4);
$numerical=$a/$b;
$reduced=&cas('maxima',"$a/$b")



Input $a/$b as a reduced fraction.




# Split nominator and denominator
($nominator,$denominator)=split(/\//,$submission);
# Do we have a nominator? If not, be nice and don't charge a try
unless ($nominator) { return 'BAD_FORMULA'; }
# Is it valid? If not, don't charge a try
$nominator=("maxima",$nominator);
if ($nominator=~/^Error/i) { return 'BAD_FORMULA'; }
# If students just input a number, there would be no denominator
unless ($denominator) {
# Check for exact numerical equivalency:
   if ($nominator==$numerical) { return 'EXACT_ANS'; }
} else {
# There is a denominator
# Again, be nice and don't charge a try for syntax errors
   $denominator=("maxima",$denominator);
   if ($denominator=~/^Error/i) { return 'BAD_FORMULA'; }
# Okay, let's compare the fractions as strings
if ("$nominator/$denominator" eq $reduced) { return 'EXACT_ANS'; }
}
# Nope, sorry.
return 'INCORRECT';





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


Re: [LON-CAPA-users] Preprocessor vs. Custom Response

2015-12-04 Thread Gerd Kortemeyer
Hi,

Are you actually looking for the fraction to be reduced? Because we can check 
that very generally.

- Gerd.

--
Gerd Kortemeyer
http://www.msu.edu/user/kortemey/

On Dec 4, 2015, at 1:16 PM, Jacob Bond  wrote:

>> 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.
> 
> It is not a static answer.  I was not aware of the regular expression option, 
> this is promising and I think I could do either substitution ($frac =~ 
> s/\//\\\//;) or split (@fracarray = split('/', $frac);) and concatenate 
> strings into the desired regular expression.
> 
> Also, I have attempted using an  under a  and it 
> just doesn't recognize it.
> 
> Thank you!
> Jacob
> 
> ___
> LON-CAPA-users mailing list
> LON-CAPA-users@mail.lon-capa.org
> http://mail.lon-capa.org/mailman/listinfo/lon-capa-users
___
LON-CAPA-users mailing list
LON-CAPA-users@mail.lon-capa.org
http://mail.lon-capa.org/mailman/listinfo/lon-capa-users