Online AI-Powered Exam Practice Generator

AI-Powered Exam Practice Generator

Enter a topic to generate a custom practice exam.

Exam Results

Your Score:

Correct answer: ${q.correct_answer}

` : ''}
`).join('')} `; pdfContentArea.style.display = 'block'; pdfContentArea.style.position = 'absolute'; pdfContentArea.style.left = '-9999px'; pdfContentArea.style.width = '800px'; try { const canvas = await html2canvas(pdfContentArea, { scale: 2 }); const imgData = canvas.toDataURL('image/png'); const { jsPDF } = window.jspdf; const pdf = new jsPDF({ orientation: 'portrait', unit: 'px', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const imgHeight = canvas.height * pdfWidth / canvas.width; pdf.addImage(imgData, 'PNG', 0, 0, pdfWidth, imgHeight); pdf.save(`${examTitle.replace(/[^a-z0-9]/gi, '-')}-Results.pdf`); } catch (error) { console.error("PDF generation failed:", error); alert("Could not generate PDF."); } finally { pdfContentArea.style.display = 'none'; } } const showError = (msg) => { setupError.textContent = msg; setupError.style.display = 'block'; }; const hideError = () => { setupError.style.display = 'none'; }; // --- Event Listeners --- generateExamBtn.addEventListener('click', generateExam); submitExamBtn.addEventListener('click', submitExam); downloadResultsBtn.addEventListener('click', generatePdf); startOverBtn.addEventListener('click', () => switchView('setup')); // --- Initial State --- switchView('setup'); });
Scroll to Top