Make toggle boxes equal a number and be used in a formula

I am working on creating a grading snippet for a 3 part assignment my students turn in. Part 1 is worth 20 points, and I want the value to be automatically calculated when I click the toggle boxes. So when I click the formtoggle B, It gives the written feedback to the student and also takes 5 points off the total for the section. The problem is also need the value of Part 1 to be added to the values of parts to create a total score. I can't get it to work right, and this would save me a ton of time grading if I could get this to work. We are not allowed to use data blaze, so that can not be part of the solution.

My textblaze for the specific part I am working on:

Part 1 - {formtext: name=Part1} {=20-{=bb}} / 20

{formtoggle: name=B}{note} {formtext: name=bb}{if:{=B}="yes"}{bb=5}{elseif:{=b}="no"}{bb=0}{endif}{endnote}
B- Newton's first law is about force changing the motion of an object. How does the interactive show this law? {endformtoggle}

Part 2- {formtext: name=Part2}

Part 3-{formtext: name=Part2}

TOTAL = {=Part1+Part2+Part3} / 60

Hi @Christiana_Swanson_M ,
Glad to see you back.
Here is a snippet you can use.
Please let me know if this works.

Part 1: {Part1=max(20 - penalty, 0)}{=Part1} pts
{note: preview=no}
{penalty= (5 if `Inertia Connection Missing` else 0)
+ (5 if `Force and Motion Change` else 0)
+ (5 if `Balanced vs Unbalanced Forces` else 0)
+ (5 if `Specific Examples Needed` else 0)
+ (5 if `Scientific Terminology Missing` else 0)
+ (5 if `Why Explanation Lacking` else 0)
}
{endnote}{formtoggle: name=Inertia Connection Missing; default=no}You identified inertia, but didn't explain how it relates to the interactive demonstration. Show the connection more clearly!{endformtoggle}

{formtoggle: name=Force and Motion Change; default=no}Newton's first law is about force changing the motion of an object. How does the interactive show this law? You need to specifically address force and motion change.{endformtoggle}

{formtoggle: name=Balanced vs Unbalanced Forces; default=no}You mentioned the object's behavior but didn't explain the role of balanced vs. unbalanced forces. This is crucial to understanding the first law!{endformtoggle}

{formtoggle: name=Specific Examples Needed; default=no}Your response lacks specific examples from the interactive. Reference particular moments or scenarios from the demonstration.{endformtoggle}

{formtoggle: name=Scientific Terminology Missing; default=no}The explanation needs more scientific terminology. Use terms like 'net force,' 'equilibrium,' and 'constant velocity' to strengthen your answer.{endformtoggle}

{formtoggle: name=Why Explanation Lacking; default=no}You described what happened but didn't explain WHY it demonstrates Newton's first law. Connect the observation to the underlying physics principle.{endformtoggle}

Part 2- {formtext: name=Part2; default=20} pts {if: not isnumber(Part2) or Part2 < 0 or Part2 > 20}{error: Should be between 0 and 20; block=yes}{endif}
Part 3- {formtext: name=Part3; default=20} pts {if: not isnumber(Part3) or Part3 < 0 or Part3 > 20}{error: Should be between 0 and 20; block=yes}{endif}

Total = {=(Part1 + Part2 + Part3)} / 60 pts

1 Like

That works wonderfully! Thank you!.

Now what if I made a Toggle box for if they are missing some questions or all of the questions. This is my current toggle box. I would like them to have a zero if I selected this section, and only lose 5 points for the other options.

{formtoggle: name=Part 1 Missing; default=no}
You are missing {formmenu: this section; A; B; C; D; multiple=yes; name=missingp1; formatter=items -> join(items, "BLAZE_AND"); }.{endformtoggle}

Something like this works?

Part 1: {Part1=max(20 - penalty, 0)}{=Part1} pts
{note: preview=no}
{penalty=20 if `Part 1 missing` else (
(5 if `Inertia Connection Missing` else 0)
+ (5 if `Force and Motion Change` else 0)
+ (5 if `Balanced vs Unbalanced Forces` else 0)
+ (5 if `Specific Examples Needed` else 0)
+ (5 if `Scientific Terminology Missing` else 0)
+ (5 if `Why Explanation Lacking` else 0)
)}
{endnote}{formtoggle: name=Part 1 missing; default=no}{if: not `Part 1 missing`}

{formtoggle: name=Inertia Connection Missing; default=no}You identified inertia, but didn't explain how it relates to the interactive demonstration. Show the connection more clearly!{endformtoggle}

{formtoggle: name=Force and Motion Change; default=no}Newton's first law is about force changing the motion of an object. How does the interactive show this law? You need to specifically address force and motion change.{endformtoggle}

{formtoggle: name=Balanced vs Unbalanced Forces; default=no}You mentioned the object's behavior but didn't explain the role of balanced vs. unbalanced forces. This is crucial to understanding the first law!{endformtoggle}

{formtoggle: name=Specific Examples Needed; default=no}Your response lacks specific examples from the interactive. Reference particular moments or scenarios from the demonstration.{endformtoggle}

{formtoggle: name=Scientific Terminology Missing; default=no}The explanation needs more scientific terminology. Use terms like 'net force,' 'equilibrium,' and 'constant velocity' to strengthen your answer.{endformtoggle}

{formtoggle: name=Why Explanation Lacking; default=no}You described what happened but didn't explain WHY it demonstrates Newton's first law. Connect the observation to the underlying physics principle.{endformtoggle}{endif}

Part 2- {formtext: name=Part2; default=20} pts {if: not isnumber(Part2) or Part2 < 0 or Part2 > 20}{error: Should be between 0 and 20; block=yes}{endif}
Part 3- {formtext: name=Part3; default=20} pts {if: not isnumber(Part3) or Part3 < 0 or Part3 > 20}{error: Should be between 0 and 20; block=yes}{endif}

Total = {=(Part1 + Part2 + Part3)} / 60 pts

Or if you like to use dropdown

Part 1: {Part1=max(20 - penalty, 0)}{=Part1} pts
{note: preview=no}
{penalty=20 if `Part 1 missing` else count(`part 1 items`) * 5}
{endnote}{formtoggle: name=Part 1 missing; default=no}{if: not `Part 1 missing`}
You are missing {formmenu: You identified inertia, but didn't explain how it relates to the interactive demonstration. Show the connection more clearly!; Newton's first law is about force changing the motion of an object. How does the interactive show this law? You need to specifically address force and motion change.; You mentioned the object's behavior but didn't explain the role of balanced vs. unbalanced forces. This is crucial to understanding the first law!; Your response lacks specific examples from the interactive. Reference particular moments or scenarios from the demonstration.; The explanation needs more scientific terminology. Use terms like 'net force,' 'equilibrium,' and 'constant velocity' to strengthen your answer.; You described what happened but didn't explain WHY it demonstrates Newton's first law. Connect the observation to the underlying physics principle.; multiple=yes; formatter=items -> join(items, "BLAZE_AND"); name=Part 1 items; cols=50}.{endif}

Part 2- {formtext: name=Part2; default=20} pts {if: not isnumber(Part2) or Part2 < 0 or Part2 > 20}{error: Should be between 0 and 20; block=yes}{endif}
Part 3- {formtext: name=Part3; default=20} pts {if: not isnumber(Part3) or Part3 < 0 or Part3 > 20}{error: Should be between 0 and 20; block=yes}{endif}

Total = {=(Part1 + Part2 + Part3)} / 60 pts

That is exactly what I wanted! Thank you!

1 Like