Skip to content

Commit ee7dfb9

Browse files
committed
Move contrib/chemistry.mac into core STACK Maxima function. Fixes #1764
1 parent 2bf8385 commit ee7dfb9

7 files changed

Lines changed: 456 additions & 434 deletions

File tree

doc/en/Developer/Development_track.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Issues with [github milestone 4.13.0](https://github.com/maths/moodle-qtype_stac
1212
1. Remove all "cte" code from Maxima - mostly install.
1313
2. Support for Maxima 5.47.0, 5.48.0, and 5.49.0. This includes a fix for issue #1281 from 5.48.0.
1414
3. Question tests can now test the whole route through a PRT, rather than just the final node. This is a significant improvement on the ability to test questions. This is back-compatible with older questions.
15+
4. Move chemistry data and some core functions into the Maxima supported code. Load these with `stack_chemistry_declare(true);` in the question variables.
1516

1617
--------------------------------------
1718

doc/en/Topics/Chemistry/index.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ STACK provides a comprehensive chemical data sheet for use in numerical problems
44

55
To include chemical data use the following within your STACK question (question variables).
66

7-
stack_include_contrib("chemistry.mac");
7+
stack_chemistry_declare(true);
88

9-
Developer notes:
10-
11-
* During development to load the code local to your development server use `stack_include("contribl://chemistry.mac");`
9+
(Older questions used an optional library `stack_include_contrib("chemistry.mac");` which has been moved to the core.)
1210

1311
## Using chemical data
1412

@@ -49,7 +47,7 @@ Notes.
4947
1. Names of elements are always given as strings. E.g. to access data for hydrogen use `"H"`.
5048
2. Field names are always given as strings, e.g. `"AtomicMass"` is a string (not an atom `AtomicMass`).
5149
3. The utility functions filter the `"Name"` field to give the name of the element with the local language selection. STACK uses the global `%_STACK_LANG` variable. If no local name is defined the `"Name"` in English is returned. If you really want _all_ the data, just use `assoc(element, %_STACK_CHEM_ELEMENTS)` rather than ` chem_data_all(element)`.
52-
4. Note that, for efficiency reasons, data is stored in flat table and the above arrays are reconstructed from the flat table, the list of field names and any languages available. Language data is separated which makes it easier to add a new language. Chemical names are _not_ part of Moodle's normal language pack and need to be added explicitly to `chemistry.mac`. See [github](https://github.com/maths/moodle-qtype_stack/blob/master/stack/maxima/contrib/chemistry.mac) for examples. As of Nov 2025, English, Finnish and German names are available.
50+
4. Note that, for efficiency reasons, data is stored in flat table and the above arrays are reconstructed from the flat table, the list of field names and any languages available. Language data is separated which makes it easier to add a new language. Chemical names are _not_ part of Moodle's normal language pack and need to be added explicitly to `chemistry.mac`. See [github](https://github.com/maths/moodle-qtype_stack/blob/master/stack/maxima/chemistry.mac) for examples. As of Nov 2025, English, Finnish and German names are available.
5351

5452
TODO: write a maxima function which gives an annotated atomic symbol in LaTeX, based on the chemical data e.g. \(^{25}_{12}\mbox{Mg}^{2+}\).
5553

samplequestions/stacklibrary/Topics/Chemistry/Molar-mass.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ M=
3636
<text>2025080100</text>
3737
</stackversion>
3838
<questionvariables>
39-
<text><![CDATA[stack_include_contrib("chemistry.mac");
39+
<text><![CDATA[stack_chemistry_declare(true);
4040
stack_unit_si_declare(true);
4141
4242
/* Each element must be a list of atoms and numbers. */

stack/cas/security-map.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7347,6 +7347,10 @@
73477347
"function": "t",
73487348
"built-in": true
73497349
},
7350+
"stack_chemistry_declare": {
7351+
"function": "s",
7352+
"contextvariable": "true"
7353+
},
73507354
"stack_matrix_col": {
73517355
"function": "?",
73527356
"contextvariable": "true"

0 commit comments

Comments
 (0)