RestrictedStudentAnswers
Restricting Allowed Student Answer Formats: PG Code Snippet
This PG code shows how to check student answers that are equations. Note that this is an insertion, not a complete PG file. This code will have to be incorporated into the problem file on which you are working.
In general, there are a number of different restrictions that one might want to place on a student answer: that it be completely simplified, that it be exact, etc. In the following we consider a number of these. Note that there are often many ways to accomplish the same goals, and the method suggested here may or may not be directly applicable to the case you are considering. Often using a Custom Answer Checker or setting a Custom Error Message will also be desirable.
Examples below:
- #Requiring that an answer be simplified to a constant
- To require that a student answer be simplified to a polynomial, we can use the LimitedPolynomial Context, described on the Restricting Functions and Operators in Student Answers page
- ...other examples should be added here
Requiring that an answer be simplified to a constant
PG problem file | Explanation |
---|---|
Context("Numeric"); $expr = Formula("sin(x)^2 + cos(x)^2"); $deriv = Compute(0); |
Setup:
The set up section has nothing out of the ordinary. Our variable
|
BEGIN_TEXT Find and simplify completely: $BR \(\frac{d}{dx}\left($expr\right) = \) \{ ans_rule(25) \} END_TEXT |
Main Text: The problem text section of the file is as we'd expect. |
$showPartialCorrectAnswers = 1; ANS( $deriv->cmp(showTypeWarnings=>0) ); ENDDOCUMENT(); |
Answer Evaluation:
Here we've turned off type warnings in the answer checking,
so that a student entering an un-simplified answer (e.g.,
|
- POD documentation: nameOfMacro.pl.html
- PG macro: nameOfMacro.pl