Using student names in activities

Hello! I would like to be able to have a student input their name on a welcome screen at the beginning of the activity (which I found out how to do from one of the ‘Try It’ examples on the documentation) and then reference this inputted on subsequent screens.
Something like: the student enters, say, ‘Bob’ in for their name on the welcome screen, then on a subsequent screen, have them see something like, “So, Bob, what is the slope of this line?”
I can create a string variable corresponding to ‘Bob’; but I don’t know what the proper syntax would be to reference this variable in subsequent screens…

Say you have students enter their name into a text-input component, and you name the component input1. On Subsequent screens, you can refer to that string as input1.content.

thank you! ‘input.content’ works.
However, what I wanted to do was have a friendly little message in a note component saying something like:
“So, ‘input1.content’ [the student’s name], what is the slope of the blue dashed line in the graph?” Then with an input component below it.

I can make the note component display ‘input1.content’ by itself, showing just the student name, or the message by itself, but not both. Here’s one attempt I made:

content:
“So,” input1.content “what is the slope of the blue dashed line?”

Thank you for your help!

Use ${ } around any variable in a note to have it appear. You can look up “variable interpolation” in the documentation for more details.

thanks for you help! Got the following code to work on a note component labeled ‘note3’:

stName1 = input1.content

content: “So ${stName1} what is the slope of the blue dashed line?”

‘stName’ was the variable for the student name on the ‘input1’ component, which came from input1 on a different screen.

If I just put ${stName} in the content statement of by itself, without creating the new variable stName1, I got an error!

If you want to use the same text on multiple screens you have a few options without making multiple variables:

  1. reference the component: ${input1.content}
  2. reference the script: ${input1.script.stName} where inupt1 is wherever you made the variable, not necessarily the input.

Hope this helps

not sure if I responded to this. Thank you for your help on this!