Complicated conditional feedback

I’m trying to write a Graphing Stories exercise that will contain complicated conditional feedback based on each part of a student’s response. The student will create a piecewise function, eventually containing up to 5 line segments, and I want to generate a student facing response for each line segment, telling the student if they met the criteria for that segment.

I was hoping to write the criteria as strings, and then substitute the values from the students’ graphs into those strings within a function to evaluate whether the criteria were met. Here’s a bit of code I wrote. It’s supposed to check whether the value of a_0 in the student’s graph is equal to the value of b_lue, which is also defined in the graph.

#This line of code creates a string which is used to evaluate the student's value of a_0
#The string above is now used inside a function with a boolean output. It will be 1 if the student's value of a_0 is correct, and 0 if it's incorrect.
a_0CheckFunction = simpleFunction("\\{${a_0Criterion}:1,0\\}")
#Now we evaluate the a_0CheckFunction at the value of a_0 that the student entered.

#Displayed feedback for a_0:
  when (S=1 or S=2) and a_0Correctness=1 "Start here ✅"
  otherwise "Start on line ❌"

This may seem more complicated than it has to be, but it’ll be really helpful to me since in the long run, each screen will randomly pull one question from a number of possibilities, and writing separate checks for each possibility will be difficult. I’m hoping to just write the plain-language criterion I’m trying to check (in the instance above, that’s whether a_0=b_lue, but in other instances the criteria could be something like m_2>m_1), and have the code check it for correctness.

Am I making a mistake in this code? Thanks.

This code is in the graph of Screen 3 of the activity below. To experience it, you first need to do Screen 2 and then move on to Screen 3:

Looks like you’re trying to create a boolean command by taking two numbers, creating a boolean command, interpolating it into a piecewise function that outputs a boolean value? Seems inefficient, but I may be mistaken.

As far as I can understand a_0=b_lue and m_2 > m_1 are correctness conditions. Are the parts of these CL based scripts or numbers in the graph?

If they’re variables in CL and you want to perform a single check like a_0Correctness = (the thing) you can achieve a boolean correctness output just like this:

a_0Correctness = a_0 = b_lue

when (S=1 or S=2) and a_0Correctness "Start here ✅"
otherwise "Start on line ❌"

If these are variables in the graph, its best to just perform these calculations in graph and reference the numeric output of the piecewise function in CL.

1 Like