Skip to content

Answer tests

An answer test is used to compare two expressions to establish whether they satisfy some mathematical criteria. The prototype test is to establish if they are algebraically equivalent. Informally, the answer tests have the following syntax

[Errors, Result, FeedBack, Note] = AnswerTest(StudentAnswer, TeacherAnswer, [Opt], [Raw])


Variable Description
StudentAnswer A CAS expression, assumed to be the student's answer.
TeacherAnswer A CAS expression, assumed to be the model answer.
Opt If needed, any options which the specific answer test provides. For example, a variable, the accuracy of the numerical comparison, number of significant figures.
Raw If needed, the raw string of the student's input to ensure, e.g. Maxima does not remove trailing zeros when establishing the number of significant figures.

Since the tests can provide feedback, tests which appear to be symmetrical, e.g. Algebraic Equivalence, really need to assume which expression belongs to the student and which to the teacher.

Variable Description
Errors Hopefully this will be empty!
Result is either true, false, or fail (which indicates a failure of the test). This determines which branch of the tree is traversed.
FeedBack This is a text string which is displayed to the student. It is CASText which may depend on properties of the student's answer.
Note This is a text string which is used for Reporting. Each answer note is concatenated with the previous notes and any contributions from the branch.

The feedback is only shown to a student if the quiet option is set to 'no'. We provide a static page giving the outcome of all answer test results. These pages are automatically generated by the STACK unit tests and help illustrate, by examples, the exact behaviour of the tests. These pages provide examples of feedback provided by each test.

The tests

Documentation is grouped as follows.

  1. Equivalence, e.g. algebraic equivalence (many variations).
  2. AlgEquiv
  3. AlgEquivNouns
  4. SubstEquiv
  5. CasEqual
  6. SameType
  7. SysEquiv
  8. Syntactic form, e.g. checking the student's expression is in factored form.
  9. FacForm
  10. PartFrac
  11. SingleFrac
  12. CompSquare
  13. Expanded
  14. LowestTerms
  15. Rules-based tests, e.g. equivalence up to associativity and commutativity and advanced bespoke tests.
  16. EqualComAss
  17. EqualComAssRules
  18. Numerical tests including accuracy, e.g. is written to 3 decimal places.
  19. NumRelative
  20. NumAbsolute
  21. NumSigFigs
  22. NumDecPlaces
  23. NumDecPlacesWrong
  24. SigFigsStrict
  25. GT
  26. GTE
  27. Scientific, e.g. for dealing with dimensional numerical quantities.
  28. Units
  29. UnitsStrict
  30. UnitsRelative
  31. UnitsStrictRelative
  32. UnitsAbsolute
  33. UnitsStrictAbsolute
  34. Calculus, e.g. for symbolic integration questions.
  35. Diff
  36. Int
  37. String match tests and regular expressions.
  38. String
  39. StringSloppy
  40. Levenshtein
  41. SRegExp
  42. Other specific subject tests, e.g. sets, logical expressions.
  43. Sets
  44. Equiv
  45. EquivFirst
  46. PropLogic

Pre-pocessing students' answers

You can apply functions before applying the tests using the feedback variables. For example, to ignore case sensitivity you can apply the Maxima commands defined by STACK exdowncase(ex) to the arguments, before you apply one of the other answer tests. However, some tests really require the raw student's input. E.g. the numerical decimal place test really requires the name of an input as the SAns field. If you manipulate an input, you may end up dropping trailing zeros and ruining the number of decimal places in the expression. STACK will warn you if you need to use the name of an input.

Offline testing

Sometimes it is very useful to work offline using the desktop version of Maxima. How to do this is explained in the STACK-maxima-sandbox.

The Maxima code for each answer test is the name of the test with AT in front. E.g. the algebraic equivalence AlgEquiv test is called in the sandbox as ATAlgEquiv. E.g. to test two expressions in the sandbox type

ATAlgEquiv((x-1)*(x+1), x^2-1);

In the STACK question dashboard, and some of the reporting features, you may see expressions such as the above. These can be copied into Maxima to help test individual questions.