drlippman / IMathAS

IMathAS Online Math Assessment
Other
112 stars 99 forks source link

Added a comparenumberswithunits function #289

Closed nick-chura closed 2 years ago

nick-chura commented 2 years ago

Here's a comparenumberswithunits() function.

I thought this could be helpful in conditional-type problems where partial credit is to be earned for writing an equivalent measurement with units. Like the other compare...() functions, this allows for a relative or absolute tolerance.

When used, it calls the libs/units.php file, so it can be used whether or not the answerformat includes "units".

Do you think this could be useful?

nick-chura commented 2 years ago

Based on a question/comment in a MOM forum, I had considered also adding an option to ignore the numerical value and just check for compatible units (e.g. comparing "3 feet per second" and "2000 miles per hour" would evaluate to true, since they are both velocities), but I thought to first wait and see if you thought having a compare function even sounded like a good idea. [It was suggested in the forum that it would be nice to be able to give partial credit if the number was wrong but the units were "correct". This is one way to make that a possiblity.]