drlippman / IMathAS

IMathAS Online Math Assessment
Other
112 stars 99 forks source link

Add.unit prefix plural case #318

Closed nick-chura closed 2 years ago

nick-chura commented 2 years ago

Changes here include:

Please check this out and let me know if I need to address anything.

nick-chura commented 2 years ago

I realize I didn't give a rationale for choosing what could be prefixed, etc. Looking online at a variety of resources, I landed on the following choices:

  1. Abbreviated units, such as "m" or "Pa, should not be pluralized with an ending "s". [I do see this a fair bit with U.S. customary units such as "qts" or "pts", but I left those nonpluralizable.]
  2. Abbreviated metric prefixes should only be allowed on abbreviated metric units, e.g. "1.21 GW" (with some exceptions like "ft" and "Btu" that still have some common use). [Note that we already had separate entries for "g" and "mg" and "kg", etc. which was not the best use of space.] Spelled out metric units can use long metric prefixes (e.g. "1.21 gigaWatts").
  3. I wanted to allow some flexibility with case-sensitivity where it made sense, so all spelled out units are case insensitive and abbreviated units are case sensitive. Together with allowing plurals, this allows "newton", "Newton", "newtons", "Newtons", "NEWTONS", etc. without having to include each of those in the main units array. [We already had some of these listed separately, so I wanted to keep and expand this to other units while decreasing the size of the units array.]

Also, I wasn't sure if defining the javascript regexes should have been done in the units.php file and then just called by the javascript files, or if you wouldn't mind those all living in the AMhelpers2.js file.

drlippman commented 2 years ago

Note to self: look to check that British/Canadian spellings of litre, metre, deca, gramme are handled