Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update contextReaction.pl with several new features #1114

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

dpvc
Copy link
Member

@dpvc dpvc commented Sep 3, 2024

This PR updates the Reaction context to include several new features. These are documented in the changes to the POD section, but the main additions are:

  • The ability to give ions with postfix notation, as in Cl^{2-} or Na^+.
  • Ability to enter complexes using brackets, as in [CoCl_4(NH_3)_2]^−
  • The ability to combine copies of the same element, molecule, etc., so that O + O and 2O are equivalent.
  • The ability to specify whether students must include states when the correct answer does, or whether a stateless answer is marked correct. This is controlled by a new flag: studentsMustUseStates whose default is true.

This is work I did a while ago, but never made a PR for it until now.

…ility to compute sums, and control over whether states are required or optional in student answers
@pstaabp
Copy link
Member

pstaabp commented Sep 6, 2024

Testing some of the examples in the POD, the complexes that you mentioned, I tried to create:

Formula("[CoCl_4(NH_3)_2]^−");

and got the error:

Unexpected character '−'; see position 18 of formula at line 15 of setunits/reaction.pg
   from within main::Formula called at line 15 of setunits/reaction.pg

and that line cited above is line 15.

I tested other cases using ^- without problems.

@pstaabp
Copy link
Member

pstaabp commented Sep 6, 2024

@drgrice1 when testing this with MQ, for the --> in the reactions, the --> show up in MQ as 3 characters. Could we add the --> to create a \longrightrarrow ? Not a huge thing, but would look nice.

@drgrice1
Copy link
Member

drgrice1 commented Sep 6, 2024

Perhaps. Add a feature request issue to https://github.com/openwebwork/mathquill, and I will look into it when I have time.

@dpvc
Copy link
Member Author

dpvc commented Sep 6, 2024

I tried to create: Formula("[CoCl_4(NH_3)_2]^−"); and got the error: ...

It turns out that the minus is the Unicode minus at U+2212 rather than the hyphen-minus at U+002D. Since U+2212 is not defined as an operator, you get that error.

I must have copied the TeX output or something. Sorry about that. I suppose we could add the alternatives like in other contexts. I'll make a PR to fix the comment.

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.

3 participants