New CL goodies for script reuse


#1

Hey gang, there are new CL goodies up on teacher.desmos.com Here’s an activity that demonstrates them (copy+edit it and read the scripts to see examples)

  1. There is now a this alias available in every component to refer to itself. This is an easy way to get a source from the component you’re currently editing number("a"): this.number("b").

  2. Components can now be assigned to local variables. This should make it a lot easier to duplicate slides, and copy-paste code between slides. You can now define some local names for your components at the top of your screen:

graph = g3
exp = e3

# complicated script using graph, exp

Then, use the local names in the rest of your script. When you copy the script to another component, you only need to change the bindings up top to update the script:

graph = e4
exp = e4

# rest of this is exactly the same

#2

:pray: that feeling when your prayers have been answered :pray:


#3

This is such an excellent development!

Here are two usages I can see straight away (for this).

For sketch components when I can’t work out the correctness but I want to alert the teacher to an empty sketch.

warning: 
    when sketchStrokeCount(this.sketch)=0 
         and sketchPointCount(this.sketch)=0 
         "Sketch has been left empty"
    otherwise ""

For expressions inputs when some feedback is provided to the student but the teacher might want to be alerted to a student who is using a guess-and-check strategy.

warning: 
    when this.submitCount > 5 
         "Student has submitted 
          ${this.submitCount} attempts" 
    otherwise ""

Previously I had to name the components in order to do these, which never felt very robust.