From 9314154ec1b5339c58939b66529a860bb742e0b3 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 31 May 2013 12:01:33 -0400 Subject: [PATCH 1/5] Move loncapa grading helpers into the sandbox-packages directory. --- {lms/lib => common/lib/sandbox-packages}/loncapa/__init__.py | 0 .../lib => common/lib/sandbox-packages}/loncapa/loncapa_check.py | 0 common/lib/sandbox-packages/setup.py | 1 + 3 files changed, 1 insertion(+) rename {lms/lib => common/lib/sandbox-packages}/loncapa/__init__.py (100%) rename {lms/lib => common/lib/sandbox-packages}/loncapa/loncapa_check.py (100%) diff --git a/lms/lib/loncapa/__init__.py b/common/lib/sandbox-packages/loncapa/__init__.py similarity index 100% rename from lms/lib/loncapa/__init__.py rename to common/lib/sandbox-packages/loncapa/__init__.py diff --git a/lms/lib/loncapa/loncapa_check.py b/common/lib/sandbox-packages/loncapa/loncapa_check.py similarity index 100% rename from lms/lib/loncapa/loncapa_check.py rename to common/lib/sandbox-packages/loncapa/loncapa_check.py diff --git a/common/lib/sandbox-packages/setup.py b/common/lib/sandbox-packages/setup.py index 96c1190e38d9..c4351149870b 100644 --- a/common/lib/sandbox-packages/setup.py +++ b/common/lib/sandbox-packages/setup.py @@ -4,6 +4,7 @@ name="sandbox-packages", version="0.1.1", packages=[ + "loncapa", "verifiers", ], py_modules=[ From 35a1dc123a5a6702ca89dd543725b7d11b5b9883 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 31 May 2013 12:23:16 -0400 Subject: [PATCH 2/5] Wrap the lines so I can read the text. --- common/lib/capa/symmath/README.md | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/common/lib/capa/symmath/README.md b/common/lib/capa/symmath/README.md index 68868fae4a10..3b05f07c480f 100644 --- a/common/lib/capa/symmath/README.md +++ b/common/lib/capa/symmath/README.md @@ -1,10 +1,27 @@ (Originally written by Ike.) -At a high level, the main challenges of checking symbolic math expressions are (1) making sure the expression is mathematically legal, and (2) simplifying the expression for comparison with what is expected. +At a high level, the main challenges of checking symbolic math expressions are +(1) making sure the expression is mathematically legal, and (2) simplifying the +expression for comparison with what is expected. -(1) Generation (and testing) of legal input is done by using MathJax to provide input math in an XML format known as Presentation MathML (PMathML). Such expressions typeset correctly, but may not be mathematically legal, like "5 / (1 = 2)". The PMathML is converted into "Content MathML" (CMathML), which is by definition mathematically legal, using an XSLT 2.0 stylesheet, via a module in SnuggleTeX. CMathML is then converted into a sympy expression. This work is all done in `lms/lib/symmath/formula.py` +(1) Generation (and testing) of legal input is done by using MathJax to provide +input math in an XML format known as Presentation MathML (PMathML). Such +expressions typeset correctly, but may not be mathematically legal, like "5 / +(1 = 2)". The PMathML is converted into "Content MathML" (CMathML), which is +by definition mathematically legal, using an XSLT 2.0 stylesheet, via a module +in SnuggleTeX. CMathML is then converted into a sympy expression. This work is +all done in `lms/lib/symmath/formula.py` -(2) Simplifying the expression and checking against what is expected is done by using sympy, and a set of heuristics based on options flags provided by the problem author. For example, the problem author may specify that the expected expression is a matrix, in which case the dimensionality of the input expression is checked. Other options include specifying that the comparison be checked numerically in addition to symbolically. The checking is done in stages, first with no simplification, then with increasing levels of testing; if a match is found at any stage, then an "ok" is returned. Helpful messages are also returned, eg if the input expression is of a different type than the expected. This work is all done in `lms/lib/symmath/symmath_check.py` +(2) Simplifying the expression and checking against what is expected is done by +using sympy, and a set of heuristics based on options flags provided by the +problem author. For example, the problem author may specify that the expected +expression is a matrix, in which case the dimensionality of the input +expression is checked. Other options include specifying that the comparison be +checked numerically in addition to symbolically. The checking is done in +stages, first with no simplification, then with increasing levels of testing; +if a match is found at any stage, then an "ok" is returned. Helpful messages +are also returned, eg if the input expression is of a different type than the +expected. This work is all done in `lms/lib/symmath/symmath_check.py` Links: From 1bedc2e4bda922b7a35623e963934484bbd204f4 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 31 May 2013 12:23:58 -0400 Subject: [PATCH 3/5] Change the file paths to be less specific. --- common/lib/capa/symmath/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/lib/capa/symmath/README.md b/common/lib/capa/symmath/README.md index 3b05f07c480f..8da9aa87eebd 100644 --- a/common/lib/capa/symmath/README.md +++ b/common/lib/capa/symmath/README.md @@ -10,7 +10,7 @@ expressions typeset correctly, but may not be mathematically legal, like "5 / (1 = 2)". The PMathML is converted into "Content MathML" (CMathML), which is by definition mathematically legal, using an XSLT 2.0 stylesheet, via a module in SnuggleTeX. CMathML is then converted into a sympy expression. This work is -all done in `lms/lib/symmath/formula.py` +all done in `symmath/formula.py`. (2) Simplifying the expression and checking against what is expected is done by using sympy, and a set of heuristics based on options flags provided by the @@ -21,7 +21,7 @@ checked numerically in addition to symbolically. The checking is done in stages, first with no simplification, then with increasing levels of testing; if a match is found at any stage, then an "ok" is returned. Helpful messages are also returned, eg if the input expression is of a different type than the -expected. This work is all done in `lms/lib/symmath/symmath_check.py` +expected. This work is all done in `symmath/symmath_check.py`. Links: From 98673f8e6ade45070889798f7adb12a628befe8a Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 31 May 2013 14:39:23 -0400 Subject: [PATCH 4/5] Somehow, when I moved symmath, I left behind its test files!? --- {lms/lib => common/lib/capa}/symmath/test_formula.py | 0 {lms/lib => common/lib/capa}/symmath/test_symmath_check.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {lms/lib => common/lib/capa}/symmath/test_formula.py (100%) rename {lms/lib => common/lib/capa}/symmath/test_symmath_check.py (100%) diff --git a/lms/lib/symmath/test_formula.py b/common/lib/capa/symmath/test_formula.py similarity index 100% rename from lms/lib/symmath/test_formula.py rename to common/lib/capa/symmath/test_formula.py diff --git a/lms/lib/symmath/test_symmath_check.py b/common/lib/capa/symmath/test_symmath_check.py similarity index 100% rename from lms/lib/symmath/test_symmath_check.py rename to common/lib/capa/symmath/test_symmath_check.py From 88d3f253b625c5d963148eab7c7a7867188e6f74 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 31 May 2013 15:22:16 -0400 Subject: [PATCH 5/5] Move symmath to be its own directory, and install it into the sandbox. --- common/lib/symmath/setup.py | 10 ++++++++++ common/lib/{capa => symmath}/symmath/README.md | 0 common/lib/{capa => symmath}/symmath/__init__.py | 0 common/lib/{capa => symmath}/symmath/formula.py | 0 common/lib/{capa => symmath}/symmath/symmath_check.py | 0 common/lib/{capa => symmath}/symmath/test_formula.py | 0 .../{capa => symmath}/symmath/test_symmath_check.py | 0 requirements/edx-sandbox/local.txt | 1 + requirements/edx/local.txt | 1 + 9 files changed, 12 insertions(+) create mode 100644 common/lib/symmath/setup.py rename common/lib/{capa => symmath}/symmath/README.md (100%) rename common/lib/{capa => symmath}/symmath/__init__.py (100%) rename common/lib/{capa => symmath}/symmath/formula.py (100%) rename common/lib/{capa => symmath}/symmath/symmath_check.py (100%) rename common/lib/{capa => symmath}/symmath/test_formula.py (100%) rename common/lib/{capa => symmath}/symmath/test_symmath_check.py (100%) diff --git a/common/lib/symmath/setup.py b/common/lib/symmath/setup.py new file mode 100644 index 000000000000..5aa81f09bf85 --- /dev/null +++ b/common/lib/symmath/setup.py @@ -0,0 +1,10 @@ +from setuptools import setup + +setup( + name="symmath", + version="0.1", + packages=["symmath"], + install_requires=[ + "sympy", + ], +) diff --git a/common/lib/capa/symmath/README.md b/common/lib/symmath/symmath/README.md similarity index 100% rename from common/lib/capa/symmath/README.md rename to common/lib/symmath/symmath/README.md diff --git a/common/lib/capa/symmath/__init__.py b/common/lib/symmath/symmath/__init__.py similarity index 100% rename from common/lib/capa/symmath/__init__.py rename to common/lib/symmath/symmath/__init__.py diff --git a/common/lib/capa/symmath/formula.py b/common/lib/symmath/symmath/formula.py similarity index 100% rename from common/lib/capa/symmath/formula.py rename to common/lib/symmath/symmath/formula.py diff --git a/common/lib/capa/symmath/symmath_check.py b/common/lib/symmath/symmath/symmath_check.py similarity index 100% rename from common/lib/capa/symmath/symmath_check.py rename to common/lib/symmath/symmath/symmath_check.py diff --git a/common/lib/capa/symmath/test_formula.py b/common/lib/symmath/symmath/test_formula.py similarity index 100% rename from common/lib/capa/symmath/test_formula.py rename to common/lib/symmath/symmath/test_formula.py diff --git a/common/lib/capa/symmath/test_symmath_check.py b/common/lib/symmath/symmath/test_symmath_check.py similarity index 100% rename from common/lib/capa/symmath/test_symmath_check.py rename to common/lib/symmath/symmath/test_symmath_check.py diff --git a/requirements/edx-sandbox/local.txt b/requirements/edx-sandbox/local.txt index ba24805057b1..c21a50338a00 100644 --- a/requirements/edx-sandbox/local.txt +++ b/requirements/edx-sandbox/local.txt @@ -4,3 +4,4 @@ common/lib/calc common/lib/chem common/lib/sandbox-packages +common/lib/symmath diff --git a/requirements/edx/local.txt b/requirements/edx/local.txt index a72f1f6dea77..f5ba60e21bf9 100644 --- a/requirements/edx/local.txt +++ b/requirements/edx/local.txt @@ -2,5 +2,6 @@ -e common/lib/calc -e common/lib/capa -e common/lib/chem +-e common/lib/symmath -e common/lib/xmodule -e .