Online Sentence Builder for Language Learning

Sentence Builder for Language Learning

Select your language and difficulty to start practicing.

Drag words into the box to form a sentence.

Drop words here

Practice Session Report

Suggestion: ${item.correctedSentence}

`}
`).join(''); } switchView('results'); }; async function generatePdf() { if (sessionHistory.length === 0) return; const reportTitle = `${currentSettings.language} Practice Report (${currentSettings.difficulty})`; pdfContentArea.innerHTML = `

${reportTitle}

` + sessionHistory.map(item => `

Your Attempt: ${item.userSentence}

Result: ${item.isCorrect ? 'Correct' : 'Incorrect'}

${!item.isCorrect ? `

Feedback: ${item.explanation}

Suggestion: ${item.correctedSentence}

` : ''}
`).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(`Sentence-Builder-Report.pdf`); } catch (error) { console.error("PDF generation failed:", error); alert("Could not generate PDF."); } finally { pdfContentArea.style.display = 'none'; } } // --- Event Listeners --- startBtn.addEventListener('click', startSession); checkBtn.addEventListener('click', checkSentence); hintBtn.addEventListener('click', getHint); clearBtn.addEventListener('click', clearTray); endSessionBtn.addEventListener('click', showResults); startOverBtn.addEventListener('click', () => switchView('setup')); downloadReportBtn.addEventListener('click', generatePdf); // --- Initial State --- switchView('setup'); });
Scroll to Top