Details

Type: Feature Request

Status: RESOLVED

Priority: Major

Resolution: Fixed

Affects Version/s: 2.9.1

Fix Version/s: 10.0

Component/s: Tests & Quizzes (Samigo)

Labels:None

Previous Issue Keys:SAM2151
Description
Currently there is no way to reference a calculated value in the calculated question unless it is part of the formula for the answer. Extend the existing Calculated Question work in order to allow the instructor to include calculations within the question itself. I.e. the instructor could set up a question something like the following:
Alice has
{A} apples, Bob has {B} apples, and Charles has {C} apples. Of the [[{A}+
{B} + {C}]] apples among the group, SOLUTION percent are Bob's.Formula: SOLUTION = ({B}
/ (
{A} + {B} + {C}))*100Wherein if the variable values were A=5, B=10, C=15, the actual display to the student would look like:
Alice has 5 apples, Bob has 10 apples, and Charles has 15 apples. Of the 30 apples among the group, (TEXT ENTRY BOX HERE) percent are Bob's?
IMPLEMENTATION NOTES:
Allowing the formula to be embedded WITHOUT {} around the variable names means that the embedded formula has to be converted from "{A + B + C}" into "{A}
+
{B} + {C}". This won't generally work, because something like "COS" or other text used in the formula confuses the parser, it can be quite difficult to detect when the C in COS is a variable and when it is part of a special word.One possible solution here is to force another variable delimiter to be used when writing the embedded formulas (like []). This also will keep the embedded formula variables from interacting with the regular replaced variable and serves as a type of indicator that these are not DEFINED variables but simply references to the defined variables. That can cause issues when the variables in the calculation do not match with the other variables in the item.
It probably makes the most sense to write the variables with braces in the embedded formula like: {{{{A} + {B}
+ {C}}}} or more likely with a different set of brackets like [[
{A} + {B} + {C}]]. This way any variables in the calculation are included in the scan and replace processing that already happens.The final alternative here is to simply define an additional formula name like {TOTAL} which is then entered below just like the formulas which are replaced by input boxes. TOTAL = {A}
+
{B}+
{C}