← 수업 제작 도구
홈 › Index › evaluationFrame (type)

evaluationFrame (type) (타입 evaluationFrame)

원본: Computation Layer 문서(evaluationFrame (type))

코드 안의 회색 줄은 원문 영어 주석이고, 파란 줄은 그 영어 주석의 번역이며, 연분홍 줄은 코드가 하는 일의 설명이다. 항목 설명은 번역이 아니라 해석이며 원문은 접어 둔 "원문(영어) 보기"에 있다.

나중에 계산하기 위한 함수와 변수를 담아 두는 틀(frame) 객체이다.

원문(영어) 보기

A frame object to store functions and variables for future evaluation.

속성(Attributes)

define type:evaluationFrame:define

틀 안에서 나중에 계산하기 위해 함수를 정의하거나 변수에 숫자 값을 정한다.

원문(영어) 보기

Define a function or assign a number value to a variable for future evaluation in a frame.

# Open an evaluation frame.
▷ 평가 틀(evaluation frame)을 연다.
frame = evaluationFrame()
▶ 변수 frame은 evaluationFrame()으로 만든 틀에 아래 네 개의 .define(…)을 이어 붙인 것으로 한다.
evaluationFrame()은 나중에 계산하기 위한 함수와 변수를 담아 두는 틀(frame)을 만들고, .define(이름, 값)은 틀 안에 함수를 만들거나 변수에 숫자 값을 정해 나중에 계산할 수 있게 한다. 들여쓴 .define(…) 네 줄은 앞 줄에 이어져 하나의 문장이 된다.
# Define the variables a and b and assign their values # using the cell valuees from table1. ▷ 변수 a와 b를 정의하고, 그 값을 table1의 셀 값으로 정한다. .define(`a`,table1.cellNumericValue(1,1)) ▶ 틀 안의 변수 a는 table1.cellNumericValue(1,1), 즉 table1의 1행 1열 셀의 숫자 값으로 한다.
cellNumericValue(행, 열)은 그 셀을 계산한 숫자 값을 가져온다.
.define(`b`,table1.cellNumericValue(1,2)) ▶ 틀 안의 변수 b는 table1.cellNumericValue(1,2), 즉 table1의 1행 2열 셀의 숫자 값으로 한다. # Define the functions f and g and create them using # the cell content from table2. ▷ 함수 f와 g를 정의하고, table2의 셀 내용으로 만든다. .define(`f`,simpleFunction(table2.cellContent(1,1))) ▶ 틀 안의 함수 f는 simpleFunction(table2.cellContent(1,1)), 즉 table2의 1행 1열 셀 내용으로 만든 simpleFunction으로 한다.
simpleFunction(…)은 latex 글자를 받아 함수를 돌려주며, 첫 인자는 latex 글자이고 나머지 인자는 입력 변수 이름이다. cellContent(행, 열)은 행 번호와 열 번호로 셀의 내용을 가져오며, 행 번호 1은 머리글 바로 아래 첫 행이다.
.define(`g`,simpleFunction(table2.cellContent(1,2))) ▶ 틀 안의 함수 g는 simpleFunction(table2.cellContent(1,2)), 즉 table2의 1행 2열 셀 내용으로 만든 simpleFunction으로 한다.

evaluate type:evaluationFrame:evaluate

틀 안에서 식의 숫자 값을 구한다.

원문(영어) 보기

Get the numeric value of an expression within a frame.

# Evaluate the function and variables from the tables
# acording to the math input.
▷ 표에서 만든 함수와 변수를 수식 답변에 맞춰 계산한다.
output = input1.script.frame.evaluate(input1.latex)
▶ 변수 output은 input1.script.frame.evaluate(input1.latex), 즉 input1의 스크립트에서 만든 틀 frame 안에서 input1의 latex를 계산한 값으로 한다.
.evaluate(…)는 틀 안에서 식의 숫자 값을 구하고, 구성요소.script.변수는 다른 구성요소의 스크립트에서 만든 변수의 값을 가져오는 표기이다.
# Display the evaluation only after input1 is submitted ▷ input1이 제출된 뒤에만 계산 결과를 보여 준다. eval = when input1.submitted "`${input1.latex}=${output}`" otherwise "Press \"Submit\" to see the evaluation." ▶ 변수 eval은 input1.submitted가 참이면 "`${input1.latex}=${output}`"(입력한 식 = 계산 결과), 그렇지 않으면 "Press \"Submit\" to see the evaluation."(계산을 보려면 "Submit"을 누르시오.)로 한다.
글자 안의 \"는 따옴표 글자 하나이다. submitted는 입력(또는 구성요소)이 제출되었는지를 참 또는 거짓으로 알려 주고, ${ }는 글자 안에 변수의 값을 끼워 넣는 표기이다. when은 조건을 차례로 확인해 처음 맞는 값을 쓴다.