Adjusting code in CL - quick "find and replace all"

I need to change variable names that are used several times in the CL. I can use CTRL+f to get a “find” window, but then it’s a manual process to change each of those names. Is there a shortcut to get a “find & replace all” window instead? (fyi,bctrl+h doesn’t work)

Thanks!

Hi Jennifer!
That’s not a feature I’ve come across, but it would be very (very!) useful. As a workaround, you could (1) copy CL code into your text editor of choice, use its find & replace all functionality, and copy the code back to Desmos, or (2) maybe you could use a browser extension like Search and Replace for Chrome to avoid the back-and-forth between Desmos and a text editor. I haven’t option (2) myself. If you do, I’d be curious to hear if it works!

Are you trying to repeat the same code, but with different variables within the same component? If so, I’d use @ianmcmeek 's suggestion. If you’re trying to create the same code in a different component and the variable you’re changing is a component, for example, you can define a variable at the beginning as the referent component and just change at the top:

T=coordinateTable1
displayText= "The points in your table were ${T.cellContent(1,1)}, ${T.cellContent(2,1)} and ${T.cellContent(3,1)}."

Then if I want this same code in a different component referencing another table, even if my code was much longer, I would only need to change my first line: “T=nextCoordinateTable2

2 Likes

General comment here about this and related issues.

There really should be a higher level abstraction available to address this sort of thing. Two features that would make a world of difference would be:

  • Activity level controls and properties that populate to all screens rather than having to write it over and over again. For example something like readOnly: true should be able to be toggled off for the entire activity in all components unless enabled. Coding the exception rather than the rule is much more efficient.

  • Component driven Activity creation. This goes hand in hand with the above but also allows for dropping in pre-built chunks into Activities that will just work. This is sort of there with copying screens but I think it’s clear this could be improved to make it more robust.

2 Likes

So, to make it clearer, I was trying to combine several practice questions into one practice for a whole unit. We did all of 8.7.01-06 in one day, so I wanted to make a practice to go along with it. This is what I ended up assigning:

  • 8.7.01 slides 1-3,
  • 8.7.02 slides 1-2,
  • 8.7.03 slides 1-5,
  • 8.7.04 slides 1-3,
  • 8.7.05 slides 1-3,
  • 8.7.06 slides 1-3

because I still wanted them to see if their answers were correct.

As I was consolidating practice questions, I could easily change each label in the Activity Builder, but I was receiving code errors. Come to find out, it’s because Desmos has every practice’s student response boxes named input1, input2, inputn and reuses note1, note2, noten for every practice, so the results pages all have code that looks like this:

cellContent(1,1):
when not(note1.script.complete) “”
when note1.script.incomplete “Incomplete”
when note1.script.type= 3 “Completed*”
when note1.script.type = 2 and note1.script.correct and not(note1.script.error) “Correct*”
when note1.script.type =1 and note1.script.correct and not(note1.script.error) “Correct”
otherwise “Incorrect”

cellContent(2,1):
when not(note2.script.complete) “”
when note2.script.incomplete “Incomplete”
when note2.script.type= 3 “Completed*”
when note2.script.type = 2 and note2.script.correct and not(note2.script.error) “Correct*”
when note2.script.type =1 and note2.script.correct and not(note2.script.error) “Correct”
otherwise “Incorrect”

cellErrorMessage(1,1): when note1.script.error and not(note1.script.incomplete) note1.script.errorM otherwise “”
cellErrorMessage(2,1): when note2.script.error and not(note2.script.incomplete) note2.script.errorM otherwise “”
cellErrorMessage(3,1): when note3.script.error and not(note3.script.incomplete) note3.script.errorM otherwise “”
cellErrorMessage(4,1): when note4.script.error and not(note4.script.incomplete) note4.script.errorM otherwise “”
cellErrorMessage(5,1): when note5.script.error and not(note5.script.incomplete) note5.script.errorM otherwise “”
cellErrorMessage(6,1): when note6.script.error and not(note6.script.incomplete) note6.script.errorM otherwise “”

so it didn’t know what to do with multiple note1 and multiple note2 and so forth. So I would do a “find” then manually replace 12

note1

with

note7

but I got very tired of doing that after the first 60 times and wanted to have an easy process to find all “note1” and replace with “note7” but apparently that doesn’t exist in Desmos.

*tl/dr Could Desmos give us a “find and replace all” or maybe even rename their objects so that there is specificity in the variable name (“note8.7.02.2” instead of “note2”) or better yet, define variables at the top of the code to refer to throughout the body so I could make one change at the top for every use of “note2”?

Yeah, that’s probably what I should have done, but I ended up just requiring the students to go to 6 different practices instead. I’ll see if I take this route next time (next school year, not now!)

Thanks.

This is what I was trying to explain in my response above. You can define variables like this.

N1= note1
N2= note2
cellContent(1,1):
when not(N1.script.complete) “”
when N1.script.incomplete “Incomplete”
when N1.script.type= 3 “Completed*”
when N1.script.type = 2 and N1.script.correct and not(N1.script.error) “Correct*”
when N1.script.type =1 and N1.script.correct and not(N1.script.error) “Correct”
otherwise “Incorrect”