Student: ${data.student}
Tutor/Date: ${data.tutor}
Total Duration: ${data.totalTime} Minutes
`;
// 2. Goals Section
html += `
Learning Goals
`;
data.goals.forEach((goal, index) => {
html += `- Goal ${index + 1}: ${goal.replace(`Goal ${index + 1}:`, '').trim()}
`;
});
html += `
`;
// 3. Agenda Table
html += `
Session Agenda (${data.totalTime} Minutes)
| Time |
Activity |
Goal |
`;
data.agenda.forEach(item => {
const goalLabel = GOAL_OPTIONS.find(opt => opt.value === item.goalId)?.text || item.goalId;
html += `
| ${item.time} min |
${item.activity} |
${goalLabel} |
`;
});
html += `
`;
// 4. Materials
html += `
Resources & Materials
`;
data.materials.forEach(item => {
if(item.item) html += `- ${item.item} (${item.source})
`;
});
html += `
`;
container.innerHTML = html;
}
// --- PDF Generation ---
function tspGeneratePDF() {
tspRenderPreview(); // Final update before export
const data = tspGetData();
const { jsPDF } = window.jspdf;
const doc = new jsPDF('p', 'mm', 'a4');
const navy = [30, 58, 138];
const gold = [245, 158, 11];
let y = 15;
// 1. Header Block
doc.setFillColor(...navy);
doc.rect(0, 0, 210, 20, 'F');
doc.setTextColor(255, 255, 255);
doc.setFontSize(16);
doc.text(data.subject + " Session Plan", 14, 13);
y = 28;
// 2. Metadata Table
const metaTable = [
['Student', data.student, 'Total Duration', `${data.totalTime} minutes`],
['Tutor / Date', data.tutor, 'Subject', data.subject]
];
doc.autoTable({
startY: y,
head: [['Session Details', '', '', '']],
body: metaTable,
theme: 'grid',
headStyles: { fillColor: [248, 250, 252], textColor: navy, fontStyle: 'bold', fontSize: 10 },
styles: { fontSize: 9 },
columnStyles: { 0: { cellWidth: 30, fontStyle: 'bold' }, 2: { cellWidth: 30, fontStyle: 'bold' } }
});
y = doc.lastAutoTable.finalY + 10;
// 3. Goals Section
doc.setFontSize(12);
doc.setFont("helvetica", "bold");
doc.setTextColor(...navy);
doc.text("Learning Goals", 14, y);
y += 5;
doc.setFontSize(10);
doc.setFont("helvetica", "normal");
doc.setTextColor(0, 0, 0);
data.goals.forEach((goal, index) => {
const goalText = `Goal ${index + 1}: ${goal.replace(`Goal ${index + 1}:`, '').trim()}`;
doc.text(`• ${goalText}`, 18, y);
y += 5;
});
y += 5;
// 4. Agenda Table
if (y > 270) { doc.addPage(); y = 20; }
doc.setFontSize(12);
doc.setFont("helvetica", "bold");
doc.setTextColor(...navy);
doc.text("Session Agenda", 14, y);
y += 5;
const agendaTableBody = data.agenda.map(item => {
const goalLabel = GOAL_OPTIONS.find(opt => opt.value === item.goalId)?.text || item.goalId;
return [`${item.time} min`, item.activity, goalLabel];
});
doc.autoTable({
startY: y,
head: [['Time', 'Activity / Procedure', 'Goal Focus']],
body: agendaTableBody,
theme: 'striped',
headStyles: { fillColor: navy, fontSize: 10 },
styles: { fontSize: 9 },
columnStyles: { 0: { cellWidth: 20, halign: 'center' }, 2: { cellWidth: 30, halign: 'center' } }
});
y = doc.lastAutoTable.finalY + 10;
// 5. Materials
if (y > 270) { doc.addPage(); y = 20; }
doc.setFontSize(12);
doc.setFont("helvetica", "bold");
doc.setTextColor(...navy);
doc.text("Required Materials & Resources", 14, y);
y += 5;
const materialTableBody = data.materials.map(item => [item.item, item.source]);
doc.autoTable({
startY: y,
head: [['Resource Item', 'Source / Reference']],
body: materialTableBody,
theme: 'plain',
headStyles: { fillColor: gold, textColor: navy, fontSize: 10 },
styles: { fontSize: 9, cellPadding: 3 },
columnStyles: { 0: { fontStyle: 'bold' } }
});
y = doc.lastAutoTable.finalY + 15;
// 6. Signature Block / Next Steps
doc.setFontSize(10);
doc.text("Tutor Signature: ___________________________", 14, y);
doc.text("Student Acknowledgment: ___________________________", 100, y);
doc.save(`SessionPlan_${data.student.replace(/\s+/g, '_')}.pdf`);
}
// Load Example data for builder fields
function tspLoadExample() {
document.getElementById('inp-subject').value = "AP Calculus - Integration";
document.getElementById('inp-student').value = "Maya Lopez";
document.getElementById('inp-tutor').value = `B. Smith / ${new Date().toLocaleDateString('en-US')}`;
document.getElementById('inp-goal-1').value = "Goal 1: Master integration by substitution (u-sub).";
document.getElementById('inp-goal-2').value = "Goal 2: Apply definite integrals to find area under a curve.";
document.getElementById('inp-goal-3').value = "Goal 3: Review two complex practice problems for test readiness.";
// Clear existing rows
document.getElementById('tsp-agenda-rows').innerHTML = '';
document.getElementById('tsp-materials-rows').innerHTML = '';
tspAddActivityRow(10, "Quick Review: Derivatives vs. Integrals", "intro");
tspAddActivityRow(20, "Interactive Whiteboard Demo: U-Substitution Method", "goal-1");
tspAddActivityRow(25, "Practice Problems 1-3 (Error Analysis)", "goal-1");
tspAddActivityRow(15, "Concept: Area under curve (Definite Integrals)", "goal-2");
tspAddActivityRow(10, "Work through Complex Practice Problem #1 (HW)", "goal-3");
tspAddActivityRow(5, "Plan Next Session & Goal Check", "closing");
tspAddMaterialRow("Calc Textbook (Chapter 5)", "Pages 180-185");
tspAddMaterialRow("U-Sub Practice Handout", "Tutor Created");
tspAddMaterialRow("Online Calculator (Desmos)", "Software");
tspUpdateTotalTime();
tspSwitchTab('preview');
alert("Example plan loaded and rendered in the Preview tab!");
}