Use values in multi-select to graph a polynomial

I’m trying to replicate slide 2 in this activity.

Thanks in advanced!

I’m guessing creating the function is the difficulty. Something to this effect in the multiple select CL:

a= when this.isSelected(1) "(2)" otherwise ""
b= when this.isSelected(2) "(-2)" otherwise ""
c= when this.isSelected(3) "(x+1)" otherwise ""
etc...
exp1="${a}*${b}*${c}*${d}*${e}*${f}"

In the graph CL:
f(x)=simpleFunction("${MSName.script.exp1}")
#Not sure how the variable name should be off the top of my head

In the graph:
y=f(x)