Skip to content

Conversation

dpvc
Copy link
Member

@dpvc dpvc commented Sep 19, 2025

This is a PR that includes a bunch of new features that I had in the wings but was waiting for some feedback from the folks I made the changes for (which never came). In light of openwebwork/mathquill#41, I thought I'd fix that problem, and include these other changes as well.

The changes here are to:

  • Tighten syntactic checks,
  • combine adjacent equal elements,
  • add conversion to molecular form,
  • allow comparisons based on molecular forms,
  • and better handling of charges.

See the changes to the comments (in particular the new large section on molecular form). There are a bunch of new flags to control how the checking is performed.

The new section in the Close() method of the context::Reaction package is the part that fixes the parentheses around charges.

Some methods that are common to multiple objects have been moved into a new context::Reaction::common package, and there is new data stored about the elements in a compound that is used to manage the molecular form. Most of the rest is new methods used for computing the molecular forms.

…sion to molecular form, and allow comparisons based on molecular forms, better handling of charges
@sfiedle1
Copy link
Contributor

The following warning appears when running the MWE given in openwebwork/mathquill#41:

Argument "type" isn't numeric in subtraction (-) at line 874 of [PG]/macros/contexts/contextReaction.pl

Without sinking into the code, this warning can be suppressed if "$other -type" in line 874 is changed to "$other ->type".

@dpvc
Copy link
Member Author

dpvc commented Sep 19, 2025

Thanks @sfiedle1, I'm not sure how that got messed up. I've added a commit to fix it.

correct answer in the form the correct answer is given (molecular or
condensed structural form). If you want to allow either form, then
you can set the flag C<acceptMolecularForm> to C<1>, in which case,
the student's answwer is compared first to the original correct answer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: answwer => answer

$R = Compute("CH_3CH_2CH_3")->molecularForm;
would make C<$R> be the quivalent of C<Compute("C_3H_8")>.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quivalent => equivalent

you can set the flag C<acceptMolecularForm> to C<1>, in which case,
the student's answwer is compared first to the original correct answer
and then to its molecular form. For example, if the correct answer is
`(NH_4)_3PO_4`, then a student answer of `N_3H_12PO_4` would also be
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you fell into markdown mode here! This should probably be

Suggested change
`(NH_4)_3PO_4`, then a student answer of `N_3H_12PO_4` would also be
C<(NH_4)_3PO_4>, then a student answer of C<N_3H_12PO_4> would also be

Copy link
Member

@drgrice1 drgrice1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine to me. I tested to see that this fixes the issue that @sfiedle1 posted to the openwebwork/mathquill repository, but I don't have enough chemistry knowledge to really test the other changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants