// ===== v32 - PUT TOGETHER - REAL QUESTIONS ONLY ===== function getAllQuestions(){ let all = []; try{ all = all.concat(getJSS1English()); }catch(e){} try{ all = all.concat(getJSS1Maths()); }catch(e){} try{ all = all.concat(getJSS1BasicScience()); }catch(e){} try{ all = all.concat(getJSS1BasicTech()); }catch(e){} try{ all = all.concat(getJSS2BasicScience()); }catch(e){} try{ all = all.concat(getJSS3BasicScience()); }catch(e){} try{ all = all.concat(getJSS3BasicTech()); }catch(e){} return all; } let Q_BANK = getAllQuestions(); let S = DEFAULT_SUBS; // ===== STUDENT EXAM ===== let curClass="", curSub="", curQs=[], curIdx=0, curAns=[], startTime=null; function studentView(name){ document.getElementById('welcome').innerHTML = "Welcome "+name+"
First Term Exam"; document.getElementById('content').innerHTML = `

1. Select Your Class

${CLASSES.map(c=>`
${c}
`).join('')}

2. Select Subject

`; } function pickClass(c,el){ curClass=c; document.querySelectorAll('.cls').forEach(x=>x.classList.remove('sel')); el.classList.add('sel'); } function startExam(){ curSub=document.getElementById('subSel').value; if(!curClass){ alert("Select Class first"); return; } if(!curSub){ alert("Select Subject"); return; } // Filter ONLY real questions for that class + subject curQs = Q_BANK.filter(q=>q.cls===curClass && q.sub.toLowerCase()===curSub.toLowerCase()); if(curQs.length===0){ alert("No real questions yet for "+curClass+" "+curSub); return; } curQs = mixAnswers(curQs); // shuffle options curIdx=0; curAns=new Array(curQs.length).fill(-1); showQ(); } function showQ(){ let q=curQs[curIdx]; let timeLeft = curSub==="Mathematics" ? 50*60 : 30*60; document.getElementById('content').innerHTML = `

${curClass} - ${curSub} | Question ${curIdx+1} / ${curQs.length}

${q.q}
${q.opts.map((o,i)=>`
${String.fromCharCode(65+i)}. ${o}
`).join('')} `; startTimer(timeLeft); } function ansQ(i,el){ curAns[curIdx]=i; document.querySelectorAll('.opt').forEach(x=>x.classList.remove('sel')); el.classList.add('sel'); } function prevQ(){ if(curIdx>0){curIdx--; showQ();} } function nextQ(){ if(curIdx{ if(curAns[i]===q.correct) score++; }); let name=document.getElementById('email').value; // Save to Firebase db.collection('results').add({name:name, cls:curClass, sub:curSub, score:score, total:curQs.length, date:new Date().toISOString()}); document.getElementById('content').innerHTML = `

✅ Exam Submitted

${score} / ${curQs.length}

${curClass} - ${curSub}

`; } // ===== REPORT CARD - POSITION BLANK ===== function viewReportCard(){ let name=document.getElementById('email').value; document.getElementById('content').innerHTML = `

📋 REPORT CARD - ${name}

Term: First Term | Class: ${curClass||'JSS1'}

${S.map(s=>``).join('')}
SubjectScoreGradePosition
${s}

Position: ___________ (Principal / Teacher will fill by hand)

`; }