Final Grade: ${finalGrade}%
`;
// 3. Criteria Table
if (criteria.length > 0) {
html += `
Detailed Criteria Breakdown
`;
let tableHtml = `
| Criteria |
Max Points |
Score |
Feedback / Notes |
`;
criteria.forEach(item => {
tableHtml += `
| ${item.desc} |
${item.max} |
${item.scored !== null ? item.scored : '___'} |
|
`;
});
tableHtml += `
`;
html += tableHtml;
}
// 4. Overall Feedback
html += `
Overall Feedback (Investigator/Grader)
`;
container.innerHTML = html;
}
function asgSwitchTab(tabId) {
document.querySelectorAll('.asg-tab-btn').forEach(b => b.classList.remove('active'));
document.querySelectorAll('.asg-content').forEach(c => c.classList.remove('active'));
const idx = tabId === 'builder' ? 0 : 1;
document.querySelectorAll('.asg-tab-btn')[idx].classList.add('active');
document.getElementById('asg-' + tabId).classList.add('active');
if (tabId === 'preview') {
asgRenderReport();
}
}
function asgLoadExample() {
if(!confirm("Overwrite current data with example presentation rubric?")) return;
document.getElementById('inp-assignment').value = "History Final Presentation";
document.getElementById('inp-course').value = "History 101 / Dr. Smith";
document.getElementById('inp-student').value = "Group B (The Phoenicians)";
// Clear and fill rows
document.getElementById('asg-criteria-rows-container').innerHTML = '';
asgAddCriteriaRow("Content Accuracy & Depth", 50, 45);
asgAddCriteriaRow("Presentation Structure & Flow", 30, 28);
asgAddCriteriaRow("Visual Aids & Design Quality", 20, 15);
asgAddCriteriaRow("Q&A Handling & Engagement", 20, 18);
asgCalculateTotalPoints();
asgRenderReport();
asgSwitchTab('preview');
}
/* --- PDF Generation --- */
async function asgGeneratePDF() {
asgRenderReport(); // Final render check
const criteria = asgGetCriteriaData();
const totalMax = asgCalculateTotalPoints();
const totalScored = criteria.reduce((sum, c) => sum + (c.scored || 0), 0);
const finalGrade = totalMax > 0 ? (totalScored / totalMax * 100).toFixed(1) : 'N/A';
if (criteria.length === 0) {
alert("Please add at least one scoring criteria before generating the PDF.");
return;
}
const data = {
assignment: document.getElementById('inp-assignment').value || "Assignment Name",
course: document.getElementById('inp-course').value || "Course / Instructor",
student: document.getElementById('inp-student').value || "Student Name / ID",
totalMax: totalMax,
totalScored: totalScored,
finalGrade: finalGrade,
criteria: criteria
};
const { jsPDF } = window.jspdf;
const doc = new jsPDF('p', 'mm', 'a4');
const navy = [30, 58, 138];
const gold = [245, 158, 11];
let y = 20;
// 1. Header
doc.setFillColor(...navy);
doc.rect(0, 0, 210, 20, 'F');
doc.setTextColor(255, 255, 255);
doc.setFontSize(16);
doc.text(`ASSESSMENT SCORING SHEET`, 105, 10, { align: 'center' });
doc.setFontSize(10);
doc.text(`Assignment: ${data.assignment}`, 105, 16, { align: 'center' });
// 2. Metadata & Summary
doc.setTextColor(0, 0, 0);
doc.setFontSize(10);
doc.setFont("helvetica", "bold");
doc.text(`Course:`, 14, y + 15);
doc.text(`Student:`, 105, y + 15);
y += 5;
doc.setFont("helvetica", "normal");
doc.text(data.course, 14, y + 15);
doc.text(data.student, 105, y + 15);
y += 30;
// Summary Box
doc.setFillColor(248, 248, 248);
doc.rect(14, y, 182, 15, 'F');
doc.setFontSize(10);
doc.setFont("helvetica", "bold");
doc.setTextColor(...navy);
doc.text(`TOTAL SCORE: ${data.totalScored} / ${data.totalMax}`, 18, y + 5);
doc.text(`FINAL GRADE: ${data.finalGrade}%`, 105, y + 5);
y += 20;
// 3. Criteria Table
doc.setFontSize(12);
doc.setFont("helvetica", "bold");
doc.setTextColor(...navy);
doc.text("Detailed Criteria Breakdown", 14, y);
y += 5;
const tableBody = criteria.map(c => [
c.desc,
c.max,
c.scored !== null ? c.scored : '___',
'' // Empty column for feedback/notes
]);
doc.autoTable({
startY: y,
head: [['Criteria Description', 'Max Pts', 'Score', 'Feedback / Notes']],
body: tableBody,
theme: 'grid',
headStyles: { fillColor: navy, fontSize: 10 },
styles: { fontSize: 9, cellPadding: 4 },
columnStyles: {
1: { cellWidth: 20, halign: 'center' },
2: { cellWidth: 20, halign: 'center' },
3: { cellWidth: 50 } // Feedback column wide
}
});
// 4. Overall Feedback
y = doc.lastAutoTable.finalY + 10;
if (y > 250) { doc.addPage(); y = 20; }
doc.setFontSize(12);
doc.setFont("helvetica", "bold");
doc.setTextColor(...navy);
doc.text("Overall Feedback (Investigator/Grader)", 14, y);
y += 5;
doc.rect(14, y, 182, 30, 'S'); // Box for feedback
doc.save(`Assessment_Sheet_${data.assignment.replace(/\s/g, '_')}.pdf`);
}