When you create multi-part or multi-mode questions, especially answer-dependent questions,
you sometimes need to determine answer keys for later parts of the question based
on your student's responses to earlier parts of the question. But, your answer key
must be specified on a single line in Answer. To perform complex or repetitive parsing or computations for answer keys, you can
use the postcalc()
function.
The postcalc()
function lets you define a variable in Question that holds the code that you want to evaluate in Answer. You can pass values to your code, and postcalc()
returns the result of the last statement in your code. This helps you accomplish
two things:
- You can define a complex, multi-line algorithm that is evaluated to define an answer key based on your student's responses to other parts of the question.
- You can reuse a formula with different values for multiple lines in your answer key.
Example Question Using postcalc() to Calculate the Answer Key
The following table summarizes an actual question.
QID |
|
---|---|
Name |
|
Mode |
|
Question |
|
Answer |
|
Display to Students |
Example Question Using postcalc() to Parse Responses
The following table summarizes a question that uses postcalc()
to determine
characteristics of the student's triangle based on the lengths of its sides.
QID |
|
---|---|
Name |
|
Mode |
|
Question |
|
Answer |
|
Display to Students |