I am trying to type a CL that will give the message ‘Great Job’ when the kids get the answer correct, a message for when they don’t. My MathAnswer Boxes are labeled A and B and here is my code:
content:
when A.submitted
when A.numericValue=3 “Great job!”
otherwise “Check your work to see if you can find your mistake. If you need help, ask your teacher or a classmate.
otherwise “Try Again.”
On the last line I get the error: Syntax Error: undetermined String. What am I doing wrong?
It was close. (@Charlie_Paulson, she was attempting a nested when-otherwise which is valid, and actually computationally more efficient.) Just needed a few parentheses and you were missing and endquote for your first otherwise:
when A.submitted
(when A.numericValue=3 “Great job!”
otherwise "Check your work to see if you can find your mistake.
If you need help, ask your teacher or a classmate." )
otherwise "Try Again."
Nested conditionals being computationally more efficient is debatable, given the conditional structure of Computation Layer. I agree that in some cases, nesting conditions makes for better organization, but in many, cleverly ordering your conditions is far more efficient. We talked a bit about it here: https://us5.campaign-archive.com/?u=ebec17c65ade785afdc700908&id=4f5ba29562
Maybe just the way I’ve been using them. For example, when having multiple when's that each have a .submitted condition, wouldn’t the code recheck whether it was submitted for every line? Whereas nested would check once, then go through each when if true, but also skip over all of them if false?
If you included a submitted condition in each line, yes. But CL will read through conditions from the top until it hits a true statement and then stop, so something like
when not(submitted) ""
when correct "✅"
otherwise "❌"
will do the same thing as
when submitted
when correct "✅"
otherwise "❌"
otherwise ""
Which only saves you a single line now, but can save a lot of condition duplicating when you scale to more complicated paths.