Dynamic Text (동적 글자)
원본: Computation Layer 문서(Dynamic Text)
Computation Layer lets you change the text on the page in response to work each student did. You can update a prompt or even use your students' own work from a previous screen on a later one.
Computation Layer를 쓰면 학생 각자가 한 작업에 따라 페이지의 글자를 바꿀 수 있다. 안내 문구를 바꿀 수도 있고, 학생이 앞 화면에서 한 작업을 뒤 화면에서 쓸 수도 있다.
The recommended way to dynamically use strings in Notes is to define a local variable in the computation layer for the script, and then insert it into the content by clicking the {#} button. For example:
메모에서 글자를 동적으로 쓰는 권장 방법은 그 메모의 Computation Layer 스크립트에 지역 변수를 정의한 뒤, {#} 버튼을 눌러 그 변수를 메모 내용에 넣는 것이다. 예를 들면 다음과 같다.
#define two variables that the note can reference. #this is the value v = input1.numericValue #this is the latex n = input1.latex
You can also overwrite the contents of a note wholesale using its "content" sink. In this case, you might want to take advantage of a feature called "interpolation." Inside of a string, you can write ${} to pull in a variable dynamically. For example:
메모의 "content" sink를 쓰면 메모 내용 전체를 덮어쓸 수도 있다. 이때는 "보간(interpolation)"이라는 기능을 쓰면 좋다. 글자(string) 안에 ${}를 쓰면 변수의 값을 그 자리에 동적으로 넣을 수 있다. 예를 들면 다음과 같다.
#this is the value v = input1.numericValue #this is the latex n = input1.latex content: " You wrote: ${n} Which evaluates to: ${v} "
Note that this technique works in other places that can accept strings, for example in the "pointLabel" sink for graphs:
이 방법은 글자를 받는 다른 곳에서도 쓸 수 있다. 예를 들어 그래프의 "pointLabel" sink에서도 쓸 수 있다.
#A is the name of a point in the graph pointLabel("A"): "Hello, ${input1.content}!"