[Methods for writing sequential problems, where answers depend on previous answers|SequentialProblems] Useful code snippets AderivFormula, a subclass of Formula that requires that student answers are the "most general antiderivative" of the given formula. This makes a couple of assumptions about the problem:
- The problem is a single-variable calculus problem, so that there is only one variable,
- The constant of integration will be called C or c,
- The constant of integration must appear as a linear parameter in the student's answer (that is, a student's answer with +C or -2C will be marked correct if the function provided is a correct antiderivative of the instructor's answer, but +sin(C) (etc.) will not), and
- The instructor's formula may include the +C or not, but if it does not it will be added when the !AderivFormula is created.
A different version of this idea is general_antideriv_cmp, which is an old style answer evaluator that does much the same thing. This makes the same assumptions as the version above. It is slightly less elegant, but has the one advantage that it gives different error messages depending on the nature of the student's error: if the student has the correct antiderivative but doesn't include the constant of integration, it returns an appropriate error message. This is shown on this [ExamplePage].
A third way of doing the same thing is Ted's adaptive parameters checker, shown in this forum post.