YEON PLANNING · 직관수학 (초4)
곱셈과 나눗셈 — 4단계 문제은행
영상으로 배우고 → 직접 풀고 → 답 제출 → 해설. 딱 떨어지는 짝을 알면 암산이 빨라져요 — 25×4=100, 125×8=1000.
✍️ 연플래닝 오리지널 — 「아하! 보이는 직관수학」 자체 제작. 모든 문제·정답 손검산 완료. 답안을 제출해야 해설·정답이 열립니다(먼저 스스로 풀어 보세요).
💬 더 필요한 게 있나요?
난이도 조절(더 쉽게 / 더 어렵게) · 다른 유형 · 특정 개념 집중 · 문항 수 등 무엇이든 적어 주세요. 선생님이 확인합니다. (공개 아님)
`; return s;
}
const P=[
{ tier:'기초', type:'self', kind:'num',
q:'250 × 4 을(를) 계산하세요.',
fig:null,
answer:1000,
hint:'딱 떨어지는 짝을 찾으세요! (25×4=100, 125×8=1000, 250×4=1000)',
sol:{ ans:'1000', fig:null,
steps:['250 × 4 를 계산합니다.','= 1000.','25×4=100, 125×8=1000, 250×4=1000 — 이런 짝을 외워두면 암산이 빨라져요!']}},
{ tier:'기초', type:'self', kind:'num',
q:'125 × 8 을(를) 계산하세요.',
fig:null,
answer:1000,
hint:'딱 떨어지는 짝을 찾으세요! (25×4=100, 125×8=1000, 250×4=1000)',
sol:{ ans:'1000', fig:null,
steps:['125 × 8 를 계산합니다.','= 1000.','25×4=100, 125×8=1000, 250×4=1000 — 이런 짝을 외워두면 암산이 빨라져요!']}},
{ tier:'기초', type:'self', kind:'num',
q:'250 × 2 을(를) 계산하세요.',
fig:null,
answer:500,
hint:'딱 떨어지는 짝을 찾으세요! (25×4=100, 125×8=1000, 250×4=1000)',
sol:{ ans:'500', fig:null,
steps:['250 × 2 를 계산합니다.','= 500.','25×4=100, 125×8=1000, 250×4=1000 — 이런 짝을 외워두면 암산이 빨라져요!']}},
{ tier:'기초', type:'self', kind:'num',
q:'500 × 2 을(를) 계산하세요.',
fig:null,
answer:1000,
hint:'딱 떨어지는 짝을 찾으세요! (25×4=100, 125×8=1000, 250×4=1000)',
sol:{ ans:'1000', fig:null,
steps:['500 × 2 를 계산합니다.','= 1000.','25×4=100, 125×8=1000, 250×4=1000 — 이런 짝을 외워두면 암산이 빨라져요!']}},
{ tier:'기초', type:'self', kind:'num',
q:'25 × 4 을(를) 계산하세요.',
fig:null,
answer:100,
hint:'딱 떨어지는 짝을 찾으세요! (25×4=100, 125×8=1000, 250×4=1000)',
sol:{ ans:'100', fig:null,
steps:['25 × 4 를 계산합니다.','= 100.','25×4=100, 125×8=1000, 250×4=1000 — 이런 짝을 외워두면 암산이 빨라져요!']}},
{ tier:'기초', type:'self', kind:'num',
q:'50 × 6 을(를) 계산하세요.',
fig:null,
answer:300,
hint:'딱 떨어지는 짝을 찾으세요! (25×4=100, 125×8=1000, 250×4=1000)',
sol:{ ans:'300', fig:null,
steps:['50 × 6 를 계산합니다.','= 300.','25×4=100, 125×8=1000, 250×4=1000 — 이런 짝을 외워두면 암산이 빨라져요!']}},
{ tier:'기초', type:'self', kind:'num',
q:'20 × 15 을(를) 계산하세요.',
fig:null,
answer:300,
hint:'딱 떨어지는 짝을 찾으세요! (25×4=100, 125×8=1000, 250×4=1000)',
sol:{ ans:'300', fig:null,
steps:['20 × 15 를 계산합니다.','= 300.','25×4=100, 125×8=1000, 250×4=1000 — 이런 짝을 외워두면 암산이 빨라져요!']}},
{ tier:'기초', type:'self', kind:'num',
q:'40 × 25 을(를) 계산하세요.',
fig:null,
answer:1000,
hint:'딱 떨어지는 짝을 찾으세요! (25×4=100, 125×8=1000, 250×4=1000)',
sol:{ ans:'1000', fig:null,
steps:['40 × 25 를 계산합니다.','= 1000.','25×4=100, 125×8=1000, 250×4=1000 — 이런 짝을 외워두면 암산이 빨라져요!']}},
{ tier:'기초', type:'self', kind:'num',
q:'250 × 8 을(를) 계산하세요.',
fig:null,
answer:2000,
hint:'딱 떨어지는 짝을 찾으세요! (25×4=100, 125×8=1000, 250×4=1000)',
sol:{ ans:'2000', fig:null,
steps:['250 × 8 를 계산합니다.','= 2000.','25×4=100, 125×8=1000, 250×4=1000 — 이런 짝을 외워두면 암산이 빨라져요!']}},
{ tier:'기초', type:'self', kind:'num',
q:'125 × 4 을(를) 계산하세요.',
fig:null,
answer:500,
hint:'딱 떨어지는 짝을 찾으세요! (25×4=100, 125×8=1000, 250×4=1000)',
sol:{ ans:'500', fig:null,
steps:['125 × 4 를 계산합니다.','= 500.','25×4=100, 125×8=1000, 250×4=1000 — 이런 짝을 외워두면 암산이 빨라져요!']}},
{ tier:'중급', type:'self', kind:'num',
q:'240 ÷ 6 을(를) 계산하세요.',
fig:null,
answer:40,
hint:'240 를 6 로 나누면? 앞자리부터 차례로 나눠 보세요.',
sol:{ ans:'40', fig:null,
steps:['240 ÷ 6 를 계산합니다.','= 40.','확인: 6 × 40 = 240 ✓']}},
{ tier:'중급', type:'self', kind:'num',
q:'360 ÷ 4 을(를) 계산하세요.',
fig:null,
answer:90,
hint:'360 를 4 로 나누면? 앞자리부터 차례로 나눠 보세요.',
sol:{ ans:'90', fig:null,
steps:['360 ÷ 4 를 계산합니다.','= 90.','확인: 4 × 90 = 360 ✓']}},
{ tier:'중급', type:'self', kind:'num',
q:'480 ÷ 8 을(를) 계산하세요.',
fig:null,
answer:60,
hint:'480 를 8 로 나누면? 앞자리부터 차례로 나눠 보세요.',
sol:{ ans:'60', fig:null,
steps:['480 ÷ 8 를 계산합니다.','= 60.','확인: 8 × 60 = 480 ✓']}},
{ tier:'중급', type:'self', kind:'num',
q:'150 ÷ 5 을(를) 계산하세요.',
fig:null,
answer:30,
hint:'150 를 5 로 나누면? 앞자리부터 차례로 나눠 보세요.',
sol:{ ans:'30', fig:null,
steps:['150 ÷ 5 를 계산합니다.','= 30.','확인: 5 × 30 = 150 ✓']}},
{ tier:'중급', type:'self', kind:'num',
q:'720 ÷ 9 을(를) 계산하세요.',
fig:null,
answer:80,
hint:'720 를 9 로 나누면? 앞자리부터 차례로 나눠 보세요.',
sol:{ ans:'80', fig:null,
steps:['720 ÷ 9 를 계산합니다.','= 80.','확인: 9 × 80 = 720 ✓']}},
{ tier:'중급', type:'self', kind:'num',
q:'320 ÷ 4 을(를) 계산하세요.',
fig:null,
answer:80,
hint:'320 를 4 로 나누면? 앞자리부터 차례로 나눠 보세요.',
sol:{ ans:'80', fig:null,
steps:['320 ÷ 4 를 계산합니다.','= 80.','확인: 4 × 80 = 320 ✓']}},
{ tier:'중급', type:'self', kind:'num',
q:'540 ÷ 6 을(를) 계산하세요.',
fig:null,
answer:90,
hint:'540 를 6 로 나누면? 앞자리부터 차례로 나눠 보세요.',
sol:{ ans:'90', fig:null,
steps:['540 ÷ 6 를 계산합니다.','= 90.','확인: 6 × 90 = 540 ✓']}},
{ tier:'중급', type:'self', kind:'num',
q:'280 ÷ 7 을(를) 계산하세요.',
fig:null,
answer:40,
hint:'280 를 7 로 나누면? 앞자리부터 차례로 나눠 보세요.',
sol:{ ans:'40', fig:null,
steps:['280 ÷ 7 를 계산합니다.','= 40.','확인: 7 × 40 = 280 ✓']}},
{ tier:'중급', type:'self', kind:'num',
q:'450 ÷ 5 을(를) 계산하세요.',
fig:null,
answer:90,
hint:'450 를 5 로 나누면? 앞자리부터 차례로 나눠 보세요.',
sol:{ ans:'90', fig:null,
steps:['450 ÷ 5 를 계산합니다.','= 90.','확인: 5 × 90 = 450 ✓']}},
{ tier:'중급', type:'self', kind:'num',
q:'630 ÷ 7 을(를) 계산하세요.',
fig:null,
answer:90,
hint:'630 를 7 로 나누면? 앞자리부터 차례로 나눠 보세요.',
sol:{ ans:'90', fig:null,
steps:['630 ÷ 7 를 계산합니다.','= 90.','확인: 7 × 90 = 630 ✓']}},
{ tier:'상위', type:'self', kind:'num',
q:'한 상자에 250개씩 든 구슬이 4상자 있습니다. 구슬은 모두 몇 개일까요?',
fig:null,
answer:1000,
hint:'‘몇 개씩 몇 묶음’은 곱셈, ‘똑같이 나누기’는 나눗셈이에요.',
sol:{ ans:'1000개', fig:null,
steps:['식: 250 × 4.','= 1000개.','딱 떨어지는 짝(25×4=100 등)을 알면 훨씬 빨라요.']}},
{ tier:'상위', type:'self', kind:'num',
q:'사탕 480개를 8명에게 똑같이 나누면 한 명당 몇 개일까요?',
fig:null,
answer:60,
hint:'‘몇 개씩 몇 묶음’은 곱셈, ‘똑같이 나누기’는 나눗셈이에요.',
sol:{ ans:'60개', fig:null,
steps:['식: 480 ÷ 8.','= 60개.','딱 떨어지는 짝(25×4=100 등)을 알면 훨씬 빨라요.']}},
{ tier:'상위', type:'self', kind:'num',
q:'한 줄에 125명씩 8줄로 섰습니다. 모두 몇 명일까요?',
fig:null,
answer:1000,
hint:'‘몇 개씩 몇 묶음’은 곱셈, ‘똑같이 나누기’는 나눗셈이에요.',
sol:{ ans:'1000명', fig:null,
steps:['식: 125 × 8.','= 1000명.','딱 떨어지는 짝(25×4=100 등)을 알면 훨씬 빨라요.']}},
{ tier:'상위', type:'self', kind:'num',
q:'색종이 360장을 6명이 똑같이 나누면 한 명당 몇 장일까요?',
fig:null,
answer:60,
hint:'‘몇 개씩 몇 묶음’은 곱셈, ‘똑같이 나누기’는 나눗셈이에요.',
sol:{ ans:'60장', fig:null,
steps:['식: 360 ÷ 6.','= 60장.','딱 떨어지는 짝(25×4=100 등)을 알면 훨씬 빨라요.']}},
{ tier:'상위', type:'self', kind:'num',
q:'한 봉지에 25개씩 든 과자가 4봉지 있습니다. 모두 몇 개일까요?',
fig:null,
answer:100,
hint:'‘몇 개씩 몇 묶음’은 곱셈, ‘똑같이 나누기’는 나눗셈이에요.',
sol:{ ans:'100개', fig:null,
steps:['식: 25 × 4.','= 100개.','딱 떨어지는 짝(25×4=100 등)을 알면 훨씬 빨라요.']}},
{ tier:'상위', type:'self', kind:'num',
q:'25 × 4 × 3 을(를) 계산하세요.',
fig:null,
answer:300,
hint:'순서를 바꿔도 돼요! 딱 떨어지는 짝부터 먼저 곱하세요.',
sol:{ ans:'300', fig:null,
steps:['25 × 4 = 100 를 먼저 계산(딱 떨어지는 짝!).','100 × 3 = 300.','곱셈은 순서를 바꿔도 답이 같아서 이런 요령이 통해요.']}},
{ tier:'상위', type:'self', kind:'num',
q:'125 × 8 × 2 을(를) 계산하세요.',
fig:null,
answer:2000,
hint:'순서를 바꿔도 돼요! 딱 떨어지는 짝부터 먼저 곱하세요.',
sol:{ ans:'2000', fig:null,
steps:['125 × 8 = 1000 를 먼저 계산(딱 떨어지는 짝!).','1000 × 2 = 2000.','곱셈은 순서를 바꿔도 답이 같아서 이런 요령이 통해요.']}},
{ tier:'상위', type:'self', kind:'num',
q:'250 × 4 × 5 을(를) 계산하세요.',
fig:null,
answer:5000,
hint:'순서를 바꿔도 돼요! 딱 떨어지는 짝부터 먼저 곱하세요.',
sol:{ ans:'5000', fig:null,
steps:['250 × 4 = 1000 를 먼저 계산(딱 떨어지는 짝!).','1000 × 5 = 5000.','곱셈은 순서를 바꿔도 답이 같아서 이런 요령이 통해요.']}},
{ tier:'상위', type:'self', kind:'num',
q:'50 × 2 × 7 을(를) 계산하세요.',
fig:null,
answer:700,
hint:'순서를 바꿔도 돼요! 딱 떨어지는 짝부터 먼저 곱하세요.',
sol:{ ans:'700', fig:null,
steps:['50 × 2 = 100 를 먼저 계산(딱 떨어지는 짝!).','100 × 7 = 700.','곱셈은 순서를 바꿔도 답이 같아서 이런 요령이 통해요.']}},
{ tier:'상위', type:'self', kind:'num',
q:'20 × 5 × 9 을(를) 계산하세요.',
fig:null,
answer:900,
hint:'순서를 바꿔도 돼요! 딱 떨어지는 짝부터 먼저 곱하세요.',
sol:{ ans:'900', fig:null,
steps:['20 × 5 = 100 를 먼저 계산(딱 떨어지는 짝!).','100 × 9 = 900.','곱셈은 순서를 바꿔도 답이 같아서 이런 요령이 통해요.']}},
{ tier:'최상위', type:'self', kind:'num',
q:'250 × 4 = 1000 입니다. 그러면 250 × 8 은 얼마일까요?',
fig:null,
answer:2000,
hint:'곱하는 수가 2배가 되면 답은?',
sol:{ ans:'2000', fig:null,
steps:['4 → 8 은 2배.','답도 2배: 1000 → 2000.','확인: 250 × 8 = 2000 ✓']}},
{ tier:'최상위', type:'self', kind:'num',
q:'□ × 25 = 100 일 때, □ 에 알맞은 수는?',
fig:null,
answer:4,
hint:'□ = 100 ÷ 25 예요.',
sol:{ ans:'4', fig:null,
steps:['□ = 100 ÷ 25 = 4.','25가 4개면 100 — 25원 동전 4개가 100원!','확인: 4 × 25 = 100 ✓']}},
{ tier:'최상위', type:'self', kind:'num',
q:'1000 ÷ 125 는 얼마일까요?',
fig:null,
answer:8,
hint:'125 × 8 = 1000 이라는 짝을 떠올리세요.',
sol:{ ans:'8', fig:null,
steps:['125 × 8 = 1000 이므로, 1000 ÷ 125 = 8.','곱셈 짝을 알면 나눗셈은 바로 나와요.','이 짝(125·8)도 외워두면 편해요!']}},
{ tier:'최상위', type:'self', kind:'num',
q:'구슬 1000개를 한 봉지에 250개씩 담고, 그중 2봉지를 선물했습니다. 남은 봉지는?',
fig:null,
answer:2,
hint:'두 걸음! 전체 봉지 수(1000 ÷ 250)를 구하고 2를 빼세요.',
sol:{ ans:'2봉지', fig:null,
steps:['전체 봉지: 1000 ÷ 250 = 4봉지.','2봉지 선물 → 4 − 2 = 2봉지.','식: 1000 ÷ 250 − 2 = 2']}},
{ tier:'최상위', type:'self', kind:'choice',
q:'25 × 4 × 5 와 25 × 20 중 어느 것이 더 클까요?',
fig:null,
choices:['25 × 4 × 5 가 크다','25 × 20 이 크다','두 값은 같다','알 수 없다'], answer:'두 값은 같다',
hint:'4 × 5 = 20 이죠. 순서를 바꿔 계산해 보세요.',
sol:{ ans:'두 값은 같다 (둘 다 500)', fig:null,
steps:['25 × 4 × 5 = 100 × 5 = 500.','25 × 20 = 500.','4 × 5 = 20 이므로 같은 식이에요 — 곱셈은 묶는 순서를 바꿔도 같아요!']}},
{ tier:'최상위', type:'self', kind:'num',
q:'125 × 8 = 1000 입니다. 그러면 125 × 16 은 얼마일까요?',
fig:null,
answer:2000,
hint:'8 → 16 은 2배예요.',
sol:{ ans:'2000', fig:null,
steps:['8 → 16 은 2배.','답도 2배: 1000 → 2000.','확인: 125 × 16 = 2000 ✓']}},
{ tier:'최상위', type:'self', kind:'num',
q:'500 × 4 을(를) 계산하세요.',
fig:null,
answer:2000,
hint:'5 × 4 = 20 이고 0이 두 개 붙어요.',
sol:{ ans:'2000', fig:null,
steps:['500 × 4 = 5 × 4 × 100 = 20 × 100.','= 2000.','0은 나중에 붙이면 계산이 쉬워요!']}},
{ tier:'최상위', type:'self', kind:'num',
q:'720 ÷ 8 ÷ 3 을(를) 앞에서부터 계산하세요.',
fig:null,
answer:30,
hint:'먼저 720 ÷ 8 을 구하세요.',
sol:{ ans:'30', fig:null,
steps:['720 ÷ 8 = 90.','90 ÷ 3 = 30.','나눗셈이 이어지면 앞에서부터!']}},
{ tier:'최상위', type:'self', kind:'num',
q:'어떤 수에 4 를 곱했더니 1000 이 되었습니다. 어떤 수는?',
fig:null,
answer:250,
hint:'곱셈을 거꾸로! 어떤 수 = 1000 ÷ 4.',
sol:{ ans:'250', fig:null,
steps:['어떤 수 × 4 = 1000 → 어떤 수 = 1000 ÷ 4.','= 250.','250 × 4 = 1000 — 외워두면 좋은 짝이에요!']}},
{ tier:'최상위', type:'self', kind:'num',
q:'구슬 250개씩 든 상자가 8개 있습니다. 이를 100개씩 봉지에 담으면 몇 봉지일까요?',
fig:null,
answer:20,
hint:'두 걸음! 전체(250 × 8)를 구하고 100으로 나눠요.',
sol:{ ans:'20봉지', fig:null,
steps:['전체: 250 × 8 = 2000개.','100개씩 담으면 2000 ÷ 100 = 20봉지.','식: 250 × 8 ÷ 100 = 20']}},
];
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:'초4 곱셈과 나눗셈' });
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();