✍️ 연플래닝 오리지널 — 「아하! 보이는 직관수학」 자체 제작. 모든 문제·정답 손검산 완료. 답안을 제출해야 해설·정답이 열립니다(먼저 스스로 풀어 보세요).
💬 더 필요한 게 있나요?
난이도 조절(더 쉽게 / 더 어렵게) · 다른 유형 · 특정 개념 집중 · 문항 수 등 무엇이든 적어 주세요. 선생님이 확인합니다. (공개 아님)
`; return s;
}
const P=[
{ tier:'기초', type:'self', kind:'choice',
q:'2 : 3 와 비율이 같은 비는? (양쪽에 같은 수를 곱해 보세요)',
fig:null,
choices:['4 : 6','4 : 5','4 : 3','2 : 6'], answer:'4 : 6',
hint:'비는 양쪽에 같은 수를 곱해도 비율이 그대로예요!',
sol:{ ans:'4 : 6', fig:null,
steps:['2 : 3 의 비율 = 2/3.','양쪽에 2를 곱하면 4 : 6 → 비율 = 4/6 = 2/3 ✓','4 : 6! 양쪽에 같은 수를 곱하거나 나눠도 비율은 안 변해요.']}},
{ tier:'기초', type:'self', kind:'choice',
q:'3 : 4 와 비율이 같은 비는? (양쪽에 같은 수를 곱해 보세요)',
fig:null,
choices:['9 : 12','6 : 7','9 : 4','3 : 12'], answer:'9 : 12',
hint:'비는 양쪽에 같은 수를 곱해도 비율이 그대로예요!',
sol:{ ans:'9 : 12', fig:null,
steps:['3 : 4 의 비율 = 3/4.','양쪽에 3를 곱하면 9 : 12 → 비율 = 9/12 = 3/4 ✓','9 : 12! 양쪽에 같은 수를 곱하거나 나눠도 비율은 안 변해요.']}},
{ tier:'기초', type:'self', kind:'choice',
q:'1 : 2 와 비율이 같은 비는? (양쪽에 같은 수를 곱해 보세요)',
fig:null,
choices:['5 : 10','6 : 7','5 : 2','1 : 10'], answer:'5 : 10',
hint:'비는 양쪽에 같은 수를 곱해도 비율이 그대로예요!',
sol:{ ans:'5 : 10', fig:null,
steps:['1 : 2 의 비율 = 1/2.','양쪽에 5를 곱하면 5 : 10 → 비율 = 5/10 = 1/2 ✓','5 : 10! 양쪽에 같은 수를 곱하거나 나눠도 비율은 안 변해요.']}},
{ tier:'기초', type:'self', kind:'choice',
q:'5 : 6 와 비율이 같은 비는? (양쪽에 같은 수를 곱해 보세요)',
fig:null,
choices:['10 : 12','7 : 8','10 : 6','5 : 12'], answer:'10 : 12',
hint:'비는 양쪽에 같은 수를 곱해도 비율이 그대로예요!',
sol:{ ans:'10 : 12', fig:null,
steps:['5 : 6 의 비율 = 5/6.','양쪽에 2를 곱하면 10 : 12 → 비율 = 10/12 = 5/6 ✓','10 : 12! 양쪽에 같은 수를 곱하거나 나눠도 비율은 안 변해요.']}},
{ tier:'기초', type:'self', kind:'choice',
q:'4 : 5 와 비율이 같은 비는? (양쪽에 같은 수를 곱해 보세요)',
fig:null,
choices:['12 : 15','7 : 8','12 : 5','4 : 15'], answer:'12 : 15',
hint:'비는 양쪽에 같은 수를 곱해도 비율이 그대로예요!',
sol:{ ans:'12 : 15', fig:null,
steps:['4 : 5 의 비율 = 4/5.','양쪽에 3를 곱하면 12 : 15 → 비율 = 12/15 = 4/5 ✓','12 : 15! 양쪽에 같은 수를 곱하거나 나눠도 비율은 안 변해요.']}},
{ tier:'기초', type:'self', kind:'choice',
q:'2 : 7 와 비율이 같은 비는? (양쪽에 같은 수를 곱해 보세요)',
fig:null,
choices:['8 : 28','6 : 11','8 : 7','2 : 28'], answer:'8 : 28',
hint:'비는 양쪽에 같은 수를 곱해도 비율이 그대로예요!',
sol:{ ans:'8 : 28', fig:null,
steps:['2 : 7 의 비율 = 2/7.','양쪽에 4를 곱하면 8 : 28 → 비율 = 8/28 = 2/7 ✓','8 : 28! 양쪽에 같은 수를 곱하거나 나눠도 비율은 안 변해요.']}},
{ tier:'기초', type:'self', kind:'choice',
q:'3 : 5 와 비율이 같은 비는? (양쪽에 같은 수를 곱해 보세요)',
fig:null,
choices:['6 : 10','5 : 7','6 : 5','3 : 10'], answer:'6 : 10',
hint:'비는 양쪽에 같은 수를 곱해도 비율이 그대로예요!',
sol:{ ans:'6 : 10', fig:null,
steps:['3 : 5 의 비율 = 3/5.','양쪽에 2를 곱하면 6 : 10 → 비율 = 6/10 = 3/5 ✓','6 : 10! 양쪽에 같은 수를 곱하거나 나눠도 비율은 안 변해요.']}},
{ tier:'기초', type:'self', kind:'choice',
q:'6 : 7 와 비율이 같은 비는? (양쪽에 같은 수를 곱해 보세요)',
fig:null,
choices:['12 : 14','8 : 9','12 : 7','6 : 14'], answer:'12 : 14',
hint:'비는 양쪽에 같은 수를 곱해도 비율이 그대로예요!',
sol:{ ans:'12 : 14', fig:null,
steps:['6 : 7 의 비율 = 6/7.','양쪽에 2를 곱하면 12 : 14 → 비율 = 12/14 = 6/7 ✓','12 : 14! 양쪽에 같은 수를 곱하거나 나눠도 비율은 안 변해요.']}},
{ tier:'기초', type:'self', kind:'choice',
q:'1 : 4 와 비율이 같은 비는? (양쪽에 같은 수를 곱해 보세요)',
fig:null,
choices:['6 : 24','7 : 10','6 : 4','1 : 24'], answer:'6 : 24',
hint:'비는 양쪽에 같은 수를 곱해도 비율이 그대로예요!',
sol:{ ans:'6 : 24', fig:null,
steps:['1 : 4 의 비율 = 1/4.','양쪽에 6를 곱하면 6 : 24 → 비율 = 6/24 = 1/4 ✓','6 : 24! 양쪽에 같은 수를 곱하거나 나눠도 비율은 안 변해요.']}},
{ tier:'기초', type:'self', kind:'choice',
q:'5 : 8 와 비율이 같은 비는? (양쪽에 같은 수를 곱해 보세요)',
fig:null,
choices:['10 : 16','7 : 10','10 : 8','5 : 16'], answer:'10 : 16',
hint:'비는 양쪽에 같은 수를 곱해도 비율이 그대로예요!',
sol:{ ans:'10 : 16', fig:null,
steps:['5 : 8 의 비율 = 5/8.','양쪽에 2를 곱하면 10 : 16 → 비율 = 10/16 = 5/8 ✓','10 : 16! 양쪽에 같은 수를 곱하거나 나눠도 비율은 안 변해요.']}},
{ tier:'중급', type:'self', kind:'num',
q:'2 : 3 = 4 : □ 에서 □ 는 얼마일까요?',
fig:null,
answer:6,
hint:'비례식은 바깥끼리 곱한 것 = 안끼리 곱한 것이에요!',
sol:{ ans:'6', fig:null,
steps:['비례식 2 : 3 = 4 : □.','바깥끼리: 2 × □. 안끼리: 3 × 4 = 12.','2 × □ = 12 → □ = 12 ÷ 2 = 6.']}},
{ tier:'중급', type:'self', kind:'num',
q:'3 : 4 = 6 : □ 에서 □ 는 얼마일까요?',
fig:null,
answer:8,
hint:'비례식은 바깥끼리 곱한 것 = 안끼리 곱한 것이에요!',
sol:{ ans:'8', fig:null,
steps:['비례식 3 : 4 = 6 : □.','바깥끼리: 3 × □. 안끼리: 4 × 6 = 24.','3 × □ = 24 → □ = 24 ÷ 3 = 8.']}},
{ tier:'중급', type:'self', kind:'num',
q:'1 : 2 = 5 : □ 에서 □ 는 얼마일까요?',
fig:null,
answer:10,
hint:'비례식은 바깥끼리 곱한 것 = 안끼리 곱한 것이에요!',
sol:{ ans:'10', fig:null,
steps:['비례식 1 : 2 = 5 : □.','바깥끼리: 1 × □. 안끼리: 2 × 5 = 10.','1 × □ = 10 → □ = 10 ÷ 1 = 10.']}},
{ tier:'중급', type:'self', kind:'num',
q:'5 : 6 = 10 : □ 에서 □ 는 얼마일까요?',
fig:null,
answer:12,
hint:'비례식은 바깥끼리 곱한 것 = 안끼리 곱한 것이에요!',
sol:{ ans:'12', fig:null,
steps:['비례식 5 : 6 = 10 : □.','바깥끼리: 5 × □. 안끼리: 6 × 10 = 60.','5 × □ = 60 → □ = 60 ÷ 5 = 12.']}},
{ tier:'중급', type:'self', kind:'num',
q:'2 : 5 = 6 : □ 에서 □ 는 얼마일까요?',
fig:null,
answer:15,
hint:'비례식은 바깥끼리 곱한 것 = 안끼리 곱한 것이에요!',
sol:{ ans:'15', fig:null,
steps:['비례식 2 : 5 = 6 : □.','바깥끼리: 2 × □. 안끼리: 5 × 6 = 30.','2 × □ = 30 → □ = 30 ÷ 2 = 15.']}},
{ tier:'중급', type:'self', kind:'num',
q:'3 : 7 = 9 : □ 에서 □ 는 얼마일까요?',
fig:null,
answer:21,
hint:'비례식은 바깥끼리 곱한 것 = 안끼리 곱한 것이에요!',
sol:{ ans:'21', fig:null,
steps:['비례식 3 : 7 = 9 : □.','바깥끼리: 3 × □. 안끼리: 7 × 9 = 63.','3 × □ = 63 → □ = 63 ÷ 3 = 21.']}},
{ tier:'중급', type:'self', kind:'num',
q:'4 : 5 = 8 : □ 에서 □ 는 얼마일까요?',
fig:null,
answer:10,
hint:'비례식은 바깥끼리 곱한 것 = 안끼리 곱한 것이에요!',
sol:{ ans:'10', fig:null,
steps:['비례식 4 : 5 = 8 : □.','바깥끼리: 4 × □. 안끼리: 5 × 8 = 40.','4 × □ = 40 → □ = 40 ÷ 4 = 10.']}},
{ tier:'중급', type:'self', kind:'num',
q:'1 : 3 = 7 : □ 에서 □ 는 얼마일까요?',
fig:null,
answer:21,
hint:'비례식은 바깥끼리 곱한 것 = 안끼리 곱한 것이에요!',
sol:{ ans:'21', fig:null,
steps:['비례식 1 : 3 = 7 : □.','바깥끼리: 1 × □. 안끼리: 3 × 7 = 21.','1 × □ = 21 → □ = 21 ÷ 1 = 21.']}},
{ tier:'중급', type:'self', kind:'num',
q:'2 : 9 = 4 : □ 에서 □ 는 얼마일까요?',
fig:null,
answer:18,
hint:'비례식은 바깥끼리 곱한 것 = 안끼리 곱한 것이에요!',
sol:{ ans:'18', fig:null,
steps:['비례식 2 : 9 = 4 : □.','바깥끼리: 2 × □. 안끼리: 9 × 4 = 36.','2 × □ = 36 → □ = 36 ÷ 2 = 18.']}},
{ tier:'중급', type:'self', kind:'num',
q:'5 : 8 = 15 : □ 에서 □ 는 얼마일까요?',
fig:null,
answer:24,
hint:'비례식은 바깥끼리 곱한 것 = 안끼리 곱한 것이에요!',
sol:{ ans:'24', fig:null,
steps:['비례식 5 : 8 = 15 : □.','바깥끼리: 5 × □. 안끼리: 8 × 15 = 120.','5 × □ = 120 → □ = 120 ÷ 5 = 24.']}},
{ tier:'상위', type:'self', kind:'num',
q:'사탕 20개를 형과 동생이 3 : 2 로 나누면 형은 몇 개일까요?',
fig:null,
answer:12,
hint:'전체를 3 + 2 = 5등분해서 형이 3몫을 가져요!',
sol:{ ans:'12', fig:null,
steps:['3 : 2 → 전체를 3 + 2 = 5등분.','한 몫 = 20 ÷ 5 = 4개.','형은 3몫 → 4 × 3 = 12개. (동생은 4 × 2 = 8개, 합 20 ✓)']}},
{ tier:'상위', type:'self', kind:'num',
q:'사탕 20개를 3 : 2 로 나누면 동생은 몇 개일까요?',
fig:null,
answer:8,
hint:'한 몫 4개에 동생은 2몫!',
sol:{ ans:'8', fig:null,
steps:['전체 5등분 → 한 몫 = 20 ÷ 5 = 4개.','동생은 2몫 → 4 × 2 = 8개.','12 + 8 = 20 ✓ 합이 맞는지 꼭 확인하세요!']}},
{ tier:'상위', type:'self', kind:'num',
q:'색종이 36장을 4 : 5 로 나누면 많은 쪽은 몇 장일까요?',
fig:null,
answer:20,
hint:'4 + 5 = 9등분. 많은 쪽은 5몫!',
sol:{ ans:'20', fig:null,
steps:['전체 9등분 → 한 몫 = 36 ÷ 9 = 4장.','많은 쪽은 5몫 → 4 × 5 = 20장.','(적은 쪽은 16장. 20 + 16 = 36 ✓)']}},
{ tier:'상위', type:'self', kind:'num',
q:'돈 60000원을 2 : 3 : 1 로 나누면 가장 많은 몫은 얼마일까요?',
fig:null,
answer:30000,
hint:'2 + 3 + 1 = 6등분. 가장 많은 건 3몫!',
sol:{ ans:'30000', fig:null,
steps:['전체 6등분 → 한 몫 = 60000 ÷ 6 = 10000원.','가장 많은 건 3몫 → 10000 × 3 = 30000원.','(나머지는 20000원, 10000원. 합 60000 ✓ 셋으로 나눠도 방법은 똑같아요!)']}},
{ tier:'상위', type:'self', kind:'num',
q:'길이 45 cm 인 끈을 2 : 7 로 자르면 짧은 쪽은 몇 cm 일까요?',
fig:null,
answer:10,
hint:'2 + 7 = 9등분. 짧은 쪽은 2몫!',
sol:{ ans:'10', fig:null,
steps:['전체 9등분 → 한 몫 = 45 ÷ 9 = 5 cm.','짧은 쪽은 2몫 → 5 × 2 = 10 cm.','(긴 쪽은 35 cm. 10 + 35 = 45 ✓)']}},
{ tier:'상위', type:'self', kind:'choice',
q:'6 : 9 를 가장 간단한 비로 나타내면?',
fig:null,
choices:['2 : 3','3 : 2','6 : 9','1 : 2'], answer:'2 : 3',
hint:'양쪽을 같은 수로 나눠 보세요. 6과 9의 공통 약수는?',
sol:{ ans:'2 : 3', fig:null,
steps:['6과 9는 둘 다 3으로 나눠져요.','6 ÷ 3 = 2, 9 ÷ 3 = 3.','2 : 3! 더 이상 같이 나눠지지 않으니 이게 가장 간단해요.']}},
{ tier:'상위', type:'self', kind:'choice',
q:'12 : 18 을 가장 간단한 비로 나타내면?',
fig:null,
choices:['2 : 3','3 : 2','6 : 9','1 : 2'], answer:'2 : 3',
hint:'12와 18의 최대공약수는 6!',
sol:{ ans:'2 : 3', fig:null,
steps:['12와 18의 최대공약수 = 6.','12 ÷ 6 = 2, 18 ÷ 6 = 3.','2 : 3!']}},
{ tier:'상위', type:'self', kind:'choice',
q:'0.5 : 1.5 를 가장 간단한 자연수의 비로?',
fig:null,
choices:['1 : 3','3 : 1','5 : 15','1 : 2'], answer:'1 : 3',
hint:'먼저 양쪽에 10을 곱해 소수를 없애 보세요!',
sol:{ ans:'1 : 3', fig:null,
steps:['양쪽에 10을 곱하면 5 : 15.','5와 15의 최대공약수 = 5 → 1 : 3.','1 : 3! 소수는 10, 100을 곱해 자연수로 먼저 만들어요.']}},
{ tier:'상위', type:'self', kind:'choice',
q:'1/2 : 1/3 을 가장 간단한 자연수의 비로?',
fig:null,
choices:['3 : 2','2 : 3','1 : 1','6 : 4'], answer:'3 : 2',
hint:'분모 2와 3의 최소공배수 6을 양쪽에 곱하세요!',
sol:{ ans:'3 : 2', fig:null,
steps:['분모 2, 3의 최소공배수 = 6.','양쪽에 6을 곱하면 (1/2 × 6) : (1/3 × 6) = 3 : 2.','3 : 2! 분수는 분모의 최소공배수를 곱해 없애요. (1/2이 1/3보다 크니 앞이 커야 맞죠 ✓)']}},
{ tier:'상위', type:'self', kind:'choice',
q:'비례배분에서 가장 먼저 할 일은?',
fig:null,
choices:['전체를 몇 등분할지 구하기','큰 수부터 나누기','평균 구하기','알 수 없다'], answer:'전체를 몇 등분할지 구하기',
hint:'3 : 2 로 나눈다면 전체는 몇 등분일까요?',
sol:{ ans:'전체를 몇 등분할지 구하기', fig:null,
steps:['3 : 2 → 3몫 + 2몫 = 5등분.','먼저 비의 합을 구해 전체를 몇 등분할지 정해요.','그 다음 한 몫을 구하고, 각자 몇 몫인지 곱해요 — 이 순서가 비례배분의 전부!']}},
{ tier:'최상위', type:'self', kind:'choice',
q:'4 : 6 과 6 : 9 는 같은 비일까요?',
fig:null,
choices:['그렇다','아니다','4 : 6만','알 수 없다'], answer:'그렇다',
hint:'각각 가장 간단히 해 보세요!',
sol:{ ans:'그렇다', fig:null,
steps:['4 : 6 → 둘 다 2로 나누면 2 : 3.','6 : 9 → 둘 다 3으로 나누면 2 : 3.','둘 다 2 : 3 → 같은 비예요! 겉모습이 달라도 비율이 같으면 같은 비.']}},
{ tier:'최상위', type:'self', kind:'choice',
q:'2 : 3 에서 양쪽에 2를 더하면 4 : 5 — 비율이 같을까요?',
fig:null,
choices:['그렇다','아니다','4 : 6만','알 수 없다'], answer:'아니다',
hint:'2/3 와 4/5 를 비교해 보세요. 통분하면?',
sol:{ ans:'아니다', fig:null,
steps:['2 : 3 → 비율 2/3. 4 : 5 → 비율 4/5.','통분: 2/3 = 10/15, 4/5 = 12/15 — 달라요!','비는 곱하기·나누기로만 같은 비가 돼요. 더하기는 안 돼요!']}},
{ tier:'최상위', type:'self', kind:'num',
q:'가로 : 세로 = 3 : 2 인 직사각형의 가로가 12 cm 이면 세로는?',
fig:null,
answer:8,
hint:'3 : 2 = 12 : □ 인 비례식을 세우세요!',
sol:{ ans:'8', fig:null,
steps:['3 : 2 = 12 : □.','바깥끼리 3 × □, 안끼리 2 × 12 = 24.','3 × □ = 24 → □ = 8 cm.']}},
{ tier:'최상위', type:'self', kind:'num',
q:'사탕을 3 : 2 로 나눴더니 형이 동생보다 6개 많았습니다. 전체는 몇 개일까요?',
fig:null,
answer:30,
hint:'형 3몫, 동생 2몫 → 차이는 1몫! 그게 6개예요.',
sol:{ ans:'30', fig:null,
steps:['형 3몫, 동생 2몫 → 차이 = 3 − 2 = 1몫.','1몫 = 6개.','전체 = 3 + 2 = 5몫 = 6 × 5 = 30개. (형 18, 동생 12 — 차이 6 ✓)']}},
{ tier:'최상위', type:'self', kind:'num',
q:'톱니가 각각 20개, 30개인 두 톱니바퀴가 맞물려 돕니다. 큰 것이 2바퀴 돌면 작은 것은?',
fig:null,
answer:3,
hint:'맞물린 톱니 개수가 같아야 해요! 30 × 2 = 60개.',
sol:{ ans:'3', fig:null,
steps:['큰 바퀴 2바퀴 = 30 × 2 = 60개의 톱니가 지나감.','작은 바퀴도 60개가 지나가야 해요.','60 ÷ 20 = 3바퀴. 톱니가 적을수록 더 많이 돌아요 — 반비례!']}},
{ tier:'최상위', type:'self', kind:'num',
q:'지도에서 1 cm 가 실제 50000 cm 입니다. 지도의 4 cm 는 실제 몇 km 일까요?',
fig:null,
answer:2,
hint:'4 × 50000 cm = 200000 cm. km 로 바꾸면?',
sol:{ ans:'2', fig:null,
steps:['4 × 50000 = 200000 cm.','1 km = 100000 cm.','200000 ÷ 100000 = 2 km.']}},
{ tier:'최상위', type:'self', kind:'num',
q:'설탕물을 만드는데 설탕 : 물 = 1 : 4 로 넣습니다. 물 200 g 이면 설탕은?',
fig:null,
answer:50,
hint:'1 : 4 = □ : 200 인 비례식!',
sol:{ ans:'50', fig:null,
steps:['1 : 4 = □ : 200.','바깥끼리 1 × 200 = 200, 안끼리 4 × □.','4 × □ = 200 → □ = 50 g.']}},
{ tier:'최상위', type:'self', kind:'choice',
q:'일을 A는 6일, B는 3일에 끝냅니다. 하루에 하는 일의 비 A : B 는?',
fig:null,
choices:['1 : 2','2 : 1','6 : 3','1 : 3'], answer:'1 : 2',
hint:'A는 하루에 1/6, B는 하루에 1/3 을 해요. 그 비를 간단히!',
sol:{ ans:'1 : 2', fig:null,
steps:['A는 하루에 전체의 1/6, B는 1/3 을 해요.','1/6 : 1/3 → 양쪽에 6을 곱하면 1 : 2.','1 : 2! 시간은 A가 2배 걸리지만 속도는 B가 2배 — 거꾸로 뒤집혀요!']}},
{ tier:'최상위', type:'self', kind:'num',
q:'어떤 두 수의 비가 5 : 3 이고 합이 40 이면 큰 수는?',
fig:null,
answer:25,
hint:'5 + 3 = 8등분!',
sol:{ ans:'25', fig:null,
steps:['전체 8등분 → 한 몫 = 40 ÷ 8 = 5.','큰 수는 5몫 → 5 × 5 = 25.','(작은 수는 15. 25 + 15 = 40 ✓)']}},
{ tier:'최상위', type:'self', kind:'choice',
q:'비례식에서 바깥끼리 곱한 것 = 안끼리 곱한 것이 성립하는 이유는?',
fig:null,
choices:['비율이 같아서','숫자가 커서','약속이라서','알 수 없다'], answer:'비율이 같아서',
hint:'a : b = c : d 는 a/b = c/d 라는 뜻이에요. 양변에 b × d 를 곱하면?',
sol:{ ans:'비율이 같아서', fig:null,
steps:['a : b = c : d 는 a/b = c/d 라는 뜻.','양변에 b × d 를 곱하면 a × d = c × b.','이게 바로 바깥끼리 = 안끼리! 결국 비율이 같다는 말을 바꿔 쓴 것뿐이에요.']}},
];
const TIERS=['기초','중급','상위','최상위'];
const TIER_DESC={기초:'영상만 봐도 바로 풀려요 — 배운 걸 그대로 적용.',중급:'한 번 더 생각 — 거꾸로·변형. 영상 안에 답이 있어요.',상위:'아래 학년 개념(선수 단원)을 함께 써야 풀려요.',최상위:'여러 개념·역발상·함정까지. 최고 난도.'};
let curTier='기초';
function tierProblems(t){ return P.map((p,i)=>({p,i})).filter(o=>o.p.tier===t); }
function renderTabs(){
const tb=document.getElementById('tabs'); tb.innerHTML='';
TIERS.forEach(t=>{ const n=tierProblems(t).length;
const b=document.createElement('button'); b.className='tab'+(t===curTier?' on':''); b.textContent=`${t} (${n})`;
b.onclick=()=>{curTier=t; renderTabs(); renderList();}; tb.appendChild(b); });
document.getElementById('tierNote').textContent=TIER_DESC[curTier];
}
function esc(x){return String(x).replace(/&/g,'&').replace(//g,'>');}
function renderList(){
const L=document.getElementById('list'); L.innerHTML='';
const items=tierProblems(curTier);
if(!items.length){ L.innerHTML='이 난도는 곧 채워집니다 — 파일럿은 기초·중급·상위 예시.
'; return; }
items.forEach(({p,i},k)=>{
const badge = p.type==='video' ? '🎬 영상해설' : '✍ 텍스트해설';
const pre = p.prereq ? `🔗 ${p.prereq.name}` : '';
const c=document.createElement('div'); c.className='card'; c.id='card'+i;
let ansUI = p.kind==='choice'
? ``+p.choices.map(o=>``).join('')+`
`
: `← 내 답을 쓰고 제출
`;
c.innerHTML=`
${curTier} · 문제 ${k+1} ${badge} ${pre}
${mfx(p.q)}
${p.fig?`${p.fig}
`:''}
${ansUI}
🔒 답을 제출해야 해설·정답이 열려요.
💡 힌트 — ${p.hint}
`;
L.appendChild(c);
});
}
const picked={};
// 분수 답 입력 지원: '3/4', '1 1/2', '0.75' 모두 인식
function parseAns(v){ v=String(v).trim().replace(/\s+/g,' ');
let m=/^(-?\d+)\s+(\d+)\/(\d+)$/.exec(v);
if(m){ const s=(+m[1])<0?-1:1; return s*(Math.abs(+m[1])+(+m[2])/(+m[3])); }
m=/^(-?\d+)\/(-?\d+)$/.exec(v); if(m) return (+m[1])/(+m[2]);
return parseFloat(v.replace(/[^0-9.\-]/g,''));
}
function pick(i,val,el){ picked[i]=val; document.querySelectorAll('#ch'+i+' button').forEach(b=>b.classList.remove('sel')); el.classList.add('sel'); }
function mfx(t){ if(!window.mathToHTML) return t;
// HTML 태그( 등)는 그대로 두고, 태그 사이 텍스트만 교과서식 수식으로 변환
return String(t).split(/(<[^>]+>)/).map(s=> s.charAt(0)==='<' ? s : mathToHTML(s)).join(''); }
function submit(i){
const p=P[i]; let mine;
if(p.kind==='choice'){ mine=picked[i]; if(mine==null){ alert('보기 중 하나를 먼저 고르세요.'); return; } }
else { const v=document.getElementById('in'+i).value.trim(); if(v===''){ alert('답을 먼저 입력하세요.'); return; } mine=parseAns(v); if(isNaN(mine)){ alert('숫자나 분수(예: 3/4)로 입력해 주세요.'); return; } }
const correct = p.kind==='choice' ? (mine===p.answer) : (Math.abs(mine-p.answer)<1e-6);
const vd=document.getElementById('vd'+i); vd.classList.remove('hide');
document.getElementById('lock'+i).classList.add('hide');
document.getElementById('show'+i).classList.remove('hide'); // 제출했으니 해설 열람 가능
if(correct){ vd.className='verdict ok'; vd.innerHTML='✅ 정답이에요! 잘했어요.'; reveal(i); }
else{ vd.className='verdict no'; vd.innerHTML='❌ 아쉬워요. 힌트를 보고 다시 풀어 볼까요? (해설도 열렸어요)';
document.getElementById('hint'+i).classList.remove('hide'); }
}
function reveal(i){
const p=P[i], sol=document.getElementById('sol'+i); sol.classList.remove('hide');
let steps=p.sol.steps.map(s=>`• ${mfx(s)}
`).join('');
let pre=p.prereq?``:'';
let vsol = p.type==='video' ? `🎬 이 문제 영상 해설 보기 (짧게)` : '';
sol.innerHTML=`📝 해설
${pre}${p.sol.fig?`${p.sol.fig}
`:''}${steps}정답: ${mfx(p.sol.ans)}
${vsol}`
+`🙋 이 해설이 어렵거나 더 자세히 알고 싶으면 말씀해주세요 — 상세 해설지를 새로 만들어 보내드릴게요.
`
+``;
}
/* ───────── "이 해설도 어려워요" 체크 → 하단 요청 코너로 모으기 ───────── */
const hardSet=new Set();
function toggleHard(i,on){ on?hardSet.add(i):hardSet.delete(i); syncHard(); }
function syncHard(){
const box=document.getElementById('hardList'); if(!box) return;
if(!hardSet.size){ box.style.display='none'; box.textContent=''; return; }
const names=[...hardSet].sort((a,b)=>a-b).map(i=>{
const list=tierProblems(P[i].tier); const k=list.findIndex(o=>o.i===i);
return `${P[i].tier} ${k+1}번`;
});
box.style.display='block';
box.innerHTML='🙋 해설이 어렵다고 표시한 문제: '+names.join(', ')+' — 보내기를 누르면 함께 전달돼요.';
}
/* ───────── 추가요청 보내기 (선생님 확인용 · 이 기기에 저장) ───────── */
function reqKey(){ return 'pbreq:'+location.pathname; }
function loadReq(){ try{ return JSON.parse(localStorage.getItem(reqKey())||'[]'); }catch(e){ return []; } }
function nowStr(){ const d=new Date(), p=n=>(n<10?'0':'')+n; return d.getFullYear()+'-'+p(d.getMonth()+1)+'-'+p(d.getDate())+' '+p(d.getHours())+':'+p(d.getMinutes()); }
function sendReq(){
const ta=document.getElementById('reqText'), note=document.getElementById('reqNote');
const text=(ta.value||'').trim();
const hard=[...hardSet].sort((a,b)=>a-b).map(i=>{ const list=tierProblems(P[i].tier); const k=list.findIndex(o=>o.i===i); return `${P[i].tier} ${k+1}번`; });
if(!text && !hard.length){ note.style.color='#C0503D'; note.textContent='요청 내용을 적거나, 어려운 해설을 체크해 주세요.'; return; }
const arr=loadReq(); arr.push({ date:nowStr(), text, hard, unit:'초6 비례식과 비례배분' });
try{ localStorage.setItem(reqKey(), JSON.stringify(arr)); }catch(e){}
ta.value=''; hardSet.clear(); syncHard();
document.querySelectorAll('.retag input').forEach(c=>c.checked=false);
note.style.color='#2c8a55'; note.textContent='✅ 보냈어요! 선생님이 확인합니다. (이 기기에 저장됨)';
renderReq();
}
function renderReq(){
const box=document.getElementById('reqMine'); if(!box) return;
const arr=loadReq(); box.innerHTML='';
if(!arr.length) return;
box.innerHTML='📒 내가 보낸 요청 ('+arr.length+')
'
+ arr.slice().reverse().map(it=>`${it.hard&&it.hard.length?'🙋 어려운 해설: '+it.hard.join(', ')+'
':''}${(it.text||'').replace(/(내용 없음)'}
${it.date}
`).join('');
}
/* ───────── 인쇄 2모드 — 절약 인쇄(2단·컬러 유지) ───────── */
function ecoPrint(){
document.body.classList.add('eco-print');
window.addEventListener('afterprint', function h(){ document.body.classList.remove('eco-print'); window.removeEventListener('afterprint',h); });
window.print();
}
/* ───────── DrawBoard (문항별 손으로 풀기 — 화면 가득 전체화면) ───────── */
const canvas=document.getElementById('drawCanvas'), ctx=canvas.getContext('2d');
const drawOverlay=document.getElementById('drawOverlay'), drawWrap=document.getElementById('drawCanvasWrap');
let drawOn=false, tool='pen', dsize=6, dcolor='#1f2a2a', drawing=false, last=null, currentDrawQ=null;
const drawings={}; // i -> dataURL (문항별 손풀이)
const photos={}; // i -> dataURL (문항별 사진)
function sizeCanvas(restore){
const rect=drawWrap.getBoundingClientRect(), dpr=window.devicePixelRatio||1;
canvas.width=Math.round(rect.width*dpr); canvas.height=Math.round(rect.height*dpr);
canvas.style.width=rect.width+'px'; canvas.style.height=rect.height+'px';
ctx.setTransform(dpr,0,0,dpr,0,0); ctx.clearRect(0,0,rect.width,rect.height);
if(restore){ const img=new Image(); img.onload=()=>ctx.drawImage(img,0,0,rect.width,rect.height); img.src=restore; }
}
window.addEventListener('resize',()=>{ if(drawOn) sizeCanvas(drawings[currentDrawQ]); });
window.openDraw=function(i){
drawOn=true; currentDrawQ=i;
const plain=String(P[i].q).replace(/<[^>]*>/g,'');
document.getElementById('drawQref').textContent=P[i].tier+' · '+plain.slice(0,30)+'…';
drawOverlay.classList.add('on');
sizeCanvas(drawings[i]);
const el2=document.documentElement, req=el2.requestFullscreen||el2.webkitRequestFullscreen||el2.msRequestFullscreen;
if(req){ try{ req.call(el2).catch(()=>{}); }catch(e){} }
};
window.closeDraw=function(){
if(currentDrawQ!=null){
const hasInk=(()=>{ const d=ctx.getImageData(0,0,canvas.width,canvas.height).data; for(let k=3;k0) return true; return false; })();
if(hasInk){ drawings[currentDrawQ]=canvas.toDataURL('image/png'); renderThumbs(currentDrawQ); }
}
drawOn=false; currentDrawQ=null; drawOverlay.classList.remove('on');
if(document.fullscreenElement||document.webkitFullscreenElement){
(document.exitFullscreen||document.webkitExitFullscreen).call(document).catch(()=>{});
}
};
window.submitFromDraw=function(){ const i=currentDrawQ; closeDraw(); if(i!=null) submit(i); };
document.addEventListener('fullscreenchange',()=>{ if(!document.fullscreenElement && drawOn) closeDraw(); });
window.setTool=t=>{ tool=t; document.getElementById('toolPen').classList.toggle('on',t==='pen'); document.getElementById('toolErase').classList.toggle('on',t==='erase'); };
window.setSize=s=>{ dsize=s; ['szS','szM','szL'].forEach(id=>document.getElementById(id).classList.remove('on')); document.getElementById(s===3?'szS':s===12?'szL':'szM').classList.add('on'); };
window.setColor=c=>{ dcolor=c; };
window.clearDraw=()=>{ if(confirm('그린 것을 모두 지울까요?')) ctx.clearRect(0,0,canvas.width,canvas.height); };
function dpos(e){ const r=canvas.getBoundingClientRect(), t=e.touches?e.touches[0]:e; return [t.clientX-r.left, t.clientY-r.top]; }
function dstart(e){ if(!drawOn) return; e.preventDefault(); drawing=true; last=dpos(e); }
function dmove(e){ if(!drawOn||!drawing) return; e.preventDefault(); const p=dpos(e);
ctx.lineCap='round'; ctx.lineJoin='round';
if(tool==='erase'){ ctx.globalCompositeOperation='destination-out'; ctx.lineWidth=dsize*4; }
else{ ctx.globalCompositeOperation='source-over'; ctx.strokeStyle=dcolor; ctx.lineWidth=dsize; }
ctx.beginPath(); ctx.moveTo(last[0],last[1]); ctx.lineTo(p[0],p[1]); ctx.stroke(); last=p;
}
function dend(){ drawing=false; }
canvas.addEventListener('mousedown',dstart); canvas.addEventListener('mousemove',dmove); window.addEventListener('mouseup',dend);
canvas.addEventListener('touchstart',dstart,{passive:false}); canvas.addEventListener('touchmove',dmove,{passive:false}); canvas.addEventListener('touchend',dend,{passive:false});
/* ───────── 사진으로 올리기 (문항별) ───────── */
window.onPhoto=function(i,inputEl){
const file=inputEl.files&&inputEl.files[0]; if(!file) return;
const reader=new FileReader();
reader.onload=ev=>{ const img=new Image();
img.onload=()=>{ const maxW=900, sc=Math.min(1,maxW/img.width), w=Math.round(img.width*sc), h=Math.round(img.height*sc);
const cv=document.createElement('canvas'); cv.width=w; cv.height=h; cv.getContext('2d').drawImage(img,0,0,w,h);
photos[i]=cv.toDataURL('image/jpeg',0.6); renderThumbs(i); };
img.src=ev.target.result; };
reader.readAsDataURL(file); inputEl.value='';
};
window.removePhoto=function(i){ delete photos[i]; renderThumbs(i); };
window.removeDrawing=function(i){ delete drawings[i]; renderThumbs(i); };
function renderThumbs(i){
const box=document.getElementById('thumbs'+i); if(!box) return;
let h='';
if(drawings[i]) h+=`
`;
if(photos[i]) h+=`
`;
box.innerHTML=h;
const db=document.getElementById('drawBtn'+i), pb=document.getElementById('photoBtn'+i);
if(db) db.classList.toggle('has', !!drawings[i]);
if(pb) pb.classList.toggle('has', !!photos[i]);
}
// 탭을 바꿔 다시 그려도 그 문항의 손풀이·사진 썸네일이 되살아나게
const _renderList=renderList;
renderList=function(){ _renderList(); tierProblems(curTier).forEach(({p,i})=>renderThumbs(i)); };
renderTabs(); renderList(); renderReq();