Aggregate (집계)
원본: Computation Layer 문서(Aggregate)
For any source that returns a "number" you can use the "aggregate" function to generate a numberList, where each element is the number from a different student in the class. This is a powerful feature for social classrooms, but also challenging to use, test, and debug. Use with caution, and make sure to test (we suggest using multiple incognito windows) before using with any students.
"number"를 돌려주는 어떤 source에든 "aggregate" 함수를 쓰면 숫자배열(numberList)을 만들 수 있다. 이 숫자배열의 각 원소는 반의 서로 다른 학생에게서 가져온 숫자이다. 사회적 수업에는 강력한 기능이지만 쓰고, 테스트하고, 오류를 찾기가 어렵기도 하다. 조심해서 쓰고, 학생에게 쓰기 전에 반드시 테스트한다(여러 개의 시크릿 창을 쓰기를 권한다).
It's easiest to see how aggregate works with a few examples. In this first one, we'll make a dot plot using the numbers from everyone in the class:
aggregate가 어떻게 작동하는지는 몇 가지 예로 보는 것이 가장 쉽다. 첫 번째 예에서는 반 모두의 숫자로 점도표(dot plot)를 만든다:
numberList("L"): aggregate(exp1.numericValue)
For a more complicated example, we could aggregate the coordinates of the submitted points for everyone in the class. For this, we'll make use of an action button's "capture" sink + "last value" source to only include students who have pressed the button.
더 복잡한 예로, 반 모두가 제출한 점의 좌표를 모을 수 있다. 이를 위해 행동 버튼의 "capture" sink와 "last value" source를 써서 버튼을 누른 학생만 포함시킨다.
Here's the CL script for the button (named btn1):
버튼(이름 btn1)의 CL 스크립트는 다음과 같다:
resetLabel: "Reset" #disabled until the student has moved the point disabled: graph1.number("a") = -9 and graph1.number("b") = 9 # This captures the x- and y-values for the student's point. capture("a"): graph1.number("a") capture("b"): graph1.number("b")
And here's the script for the graph (graph1):
그리고 그래프(graph1)의 스크립트는 다음과 같다:
# Hide the movable point if submitted number("s"): when btn1.timeSincePress() > 0 1 otherwise 0 # We're using captured values in the button. Why? # this way only submitted points will be included. numberList("A"): aggregate(btn1.lastValue("a")) numberList("B"): aggregate(btn1.lastValue("b"))